Rev 3265 | Rev 3397 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3265 | Rev 3346 | ||
---|---|---|---|
1 | #ifndef CMDS_H |
1 | #ifndef CMDS_H |
2 | #define CMDS_H |
2 | #define CMDS_H |
3 | 3 | ||
4 | #include "config.h" |
4 | #include "config.h" |
5 | #include "scli.h" |
5 | #include "scli.h" |
6 | 6 | ||
7 | /* Temporary to store strings */ |
7 | /* Temporary to store strings */ |
8 | #define EXT_HELP "extended" |
8 | #define EXT_HELP "extended" |
9 | #define SHORT_HELP "short" |
9 | #define SHORT_HELP "short" |
10 | #define TEST_ANNOUNCE "Hello, this is :" |
10 | #define TEST_ANNOUNCE "Hello, this is :" |
11 | 11 | ||
12 | /* Simple levels of help displays */ |
12 | /* Simple levels of help displays */ |
13 | #define HELP_SHORT 0 |
13 | #define HELP_SHORT 0 |
14 | #define HELP_LONG 1 |
14 | #define HELP_LONG 1 |
15 | 15 | ||
16 | /* Acceptable buffer sizes (for strn functions) */ |
16 | /* Acceptable buffer sizes (for strn functions) */ |
17 | /* TODO: Move me, other files duplicate these needlessly */ |
17 | /* TODO: Move me, other files duplicate these needlessly */ |
18 | #define BUFF_LARGE 1024 |
18 | #define BUFF_LARGE 1024 |
19 | #define BUFF_SMALL 255 |
19 | #define BUFF_SMALL 255 |
20 | 20 | ||
21 | /* Return macros for int type entry points */ |
21 | /* Return macros for int type entry points */ |
22 | #define CMD_FAILURE (int*)1 |
22 | #define CMD_FAILURE (int*)1 |
23 | #define CMD_SUCCESS 0 |
23 | #define CMD_SUCCESS 0 |
24 | #define CMD_VOID (void *)NULL |
24 | #define CMD_VOID (void *)NULL |
25 | 25 | ||
26 | /* Types for module command entry and help */ |
26 | /* Types for module command entry and help */ |
27 | typedef int * (* mod_entry_t)(char **); |
27 | typedef int * (* mod_entry_t)(char **); |
28 | typedef void * (* mod_help_t)(unsigned int); |
28 | typedef void * (* mod_help_t)(unsigned int); |
29 | 29 | ||
30 | /* Built-in commands need to be able to modify cliuser_t */ |
30 | /* Built-in commands need to be able to modify cliuser_t */ |
31 | typedef int * (* builtin_entry_t)(char **, cliuser_t *); |
31 | typedef int * (* builtin_entry_t)(char **, cliuser_t *); |
32 | typedef void * (* builtin_help_t)(unsigned int); |
32 | typedef void * (* builtin_help_t)(unsigned int); |
33 | 33 | ||
34 | /* Module structure */ |
34 | /* Module structure */ |
35 | typedef struct { |
35 | typedef struct { |
36 | char *name; /* Name of the command */ |
36 | char *name; /* Name of the command */ |
37 | char *desc; /* Description of the command */ |
37 | char *desc; /* Description of the command */ |
38 | mod_entry_t entry; /* Command (exec) entry function */ |
38 | mod_entry_t entry; /* Command (exec) entry function */ |
39 | mod_help_t help; /* Command (help) entry function */ |
39 | mod_help_t help; /* Command (help) entry function */ |
40 | int restricted; /* Restricts to interactive/non-interactive only */ |
40 | int restricted; /* Restricts to interactive/non-interactive only */ |
41 | } module_t; |
41 | } module_t; |
42 | 42 | ||
43 | /* Builtin structure, same as modules except different types of entry points */ |
43 | /* Builtin structure, same as modules except different types of entry points */ |
44 | typedef struct { |
44 | typedef struct { |
45 | char *name; |
45 | char *name; |
46 | char *desc; |
46 | char *desc; |
47 | builtin_entry_t entry; |
47 | builtin_entry_t entry; |
48 | builtin_help_t help; |
48 | builtin_help_t help; |
49 | int restricted; |
49 | int restricted; |
50 | } builtin_t; |
50 | } builtin_t; |
51 | 51 | ||
52 | /* Declared in cmds/modules/modules.h and cmds/builtins/builtins.h |
52 | /* Declared in cmds/modules/modules.h and cmds/builtins/builtins.h |
53 | * respectively */ |
53 | * respectively */ |
54 | extern module_t modules[]; |
54 | extern module_t modules[]; |
55 | extern builtin_t builtins[]; |
55 | extern builtin_t builtins[]; |
56 | 56 | ||
57 | /* Prototypes for module launchers */ |
57 | /* Prototypes for module launchers */ |
58 | extern int module_is_restricted(int); |
58 | extern int module_is_restricted(int); |
59 | extern int is_module(const char *); |
59 | extern int is_module(const char *); |
60 | extern int is_module_alias(const char *); |
60 | extern int is_module_alias(const char *); |
61 | extern char * alias_for_module(const char *); |
61 | extern char * alias_for_module(const char *); |
62 | extern int help_module(int, unsigned int); |
62 | extern int help_module(int, unsigned int); |
63 | extern int run_module(int, char *[]); |
63 | extern int run_module(int, char *[]); |
64 | 64 | ||
65 | /* Prototypes for builtin launchers */ |
65 | /* Prototypes for builtin launchers */ |
66 | extern int builtin_is_restricted(int); |
66 | extern int builtin_is_restricted(int); |
67 | extern int is_builtin(const char *); |
67 | extern int is_builtin(const char *); |
68 | extern int is_builtin_alias(const char *); |
68 | extern int is_builtin_alias(const char *); |
69 | extern char * alias_for_builtin(const char *); |
69 | extern char * alias_for_builtin(const char *); |
70 | extern int help_builtin(int, unsigned int); |
70 | extern int help_builtin(int, unsigned int); |
71 | extern int run_builtin(int, char *[], cliuser_t *); |
71 | extern int run_builtin(int, char *[], cliuser_t *); |
72 | 72 | ||
73 | #endif |
73 | #endif |
74 | 74 |