-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcmdproc.h
More file actions
28 lines (22 loc) · 709 Bytes
/
Copy pathcmdproc.h
File metadata and controls
28 lines (22 loc) · 709 Bytes
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
// maximum number of arguments (including command itself)
#define CMD_MAX_ARGS 50
// default result codes
#define CMD_OK 0
#define CMD_NO_CMD -0x7F00
#define CMD_UNKNOWN -0x7F01
#define CMD_ARG -0x7F02
typedef int (cmd_fn)(int argc, char *argv[]);
// command table entry
typedef struct {
const char *name;
cmd_fn *cmd;
const char *help;
} cmd_t;
/**
* Parses the given line into arguments, matches it with a command and executes the command.
* @param[in] commands command table
* @param[in] line the line to parse
* @return the result of command execution
*/
int cmd_process(const cmd_t *commands, char *line);
const cmd_t *cmd_find(const cmd_t * commands, const char *name);