summaryrefslogtreecommitdiff
path: root/accel-pptpd/cli/cli.h
blob: aec62fd3825a9c3c2c4000c10929360aa296fb8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef __CLI_H
#define __CLI_H

#include <pcre.h>
#include <list.h>

#define CLI_CMD_OK 0
#define CLI_CMD_FAILED -1
#define CLI_CMD_EXIT -2
#define CLI_CMD_SYNTAX 1

struct cli_simple_cmd_t
{
	struct list_head entry;
	int hdr_len;
	const char **hdr;
	int (*exec)(const char *cmd, char * const *fields, int fields_cnt, void *client);
	int (*help)(char * const *fields, int field_cnt, void *client);
};

struct cli_regexp_cmd_t
{
	struct list_head entry;
	pcre *re;
	const char *pattern;
	int options;
	int (*exec)(const char *cmd, void *client);
	int (*help)(char * const *fields, int field_cnt, void *client);
};

void cli_register_simple_cmd(struct cli_simple_cmd_t *cmd);
void cli_register_regexp_cmd(struct cli_regexp_cmd_t *cmd);

int cli_send(void *client, const char *data);

#endif