-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.h
60 lines (43 loc) · 1.41 KB
/
commands.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef COMMANDS_H
#define COMMANDS_H
#include <stdint.h>
#include "object.h"
#include "shell.h"
#include "parser.h"
#define SHELL_COMMAND_COUNT 256
#define commands_status_return(_status) do { \
commands_status_set(_status); \
return; \
} while (0)
typedef void (*command_func_t)(const parser_t *parser);
struct command {
char *name;
char *alias;
char *description;
char *help;
command_func_t func;
int arg_count;
};
typedef enum {
COMMANDS_RET_OK,
COMMANDS_RET_INVALID_COMMAND,
} commands_ret_t;
typedef enum {
COMMANDS_STATUS_EXPECTED_SYMBOL,
COMMANDS_STATUS_EXPECTED_STRING,
COMMANDS_STATUS_EXPECTED_INTEGER,
COMMANDS_STATUS_ARGC_MISMATCH,
COMMANDS_STATUS_INSUFFICIENT_MEMORY,
COMMANDS_STATUS_INVALID_ADDRESS,
COMMANDS_STATUS_INVALID_SIZE,
COMMANDS_STATUS_FILE_NOT_FOUND,
COMMANDS_STATUS_NOT_A_FILE,
COMMANDS_STATUS_ERROR,
} commands_status_t;
void commands_init(void);
void commands_deinit(void);
const command_t *commands_find(const char *name);
void commands_printf(const char *format, ...);
void commands_status_set(commands_status_t status);
extern const command_t *commands[SHELL_COMMAND_COUNT];
#endif /* COMMANDS_H */