]> git.sur5r.net Git - ngadmin/blob - cli/commands.h
Cli: refactor, change coding style
[ngadmin] / cli / commands.h
1
2 #ifndef DEF_COMMANDS
3 #define DEF_COMMANDS
4
5
6 #include "common.h"
7
8
9 struct TreeNode {
10         const char *name;
11         bool (* const comfunc)(int, const char**, struct ngadmin*);
12         bool hasArgs;
13         const struct TreeNode *sub;
14 };
15
16
17 #define COM_ROOT_START(v)               const struct TreeNode v = {.name = "<root>", .comfunc = NULL, .hasArgs = false, .sub = (const struct TreeNode[]){
18 #define COM_ROOT_END                    {.name = NULL, .comfunc = NULL, .hasArgs = false, .sub = NULL}}};
19 #define COM_START(nam)                  {.name = #nam, .comfunc = NULL, .hasArgs = false, .sub = (const struct TreeNode[]){
20 #define COM_END                         {.name = NULL, .comfunc = NULL, .hasArgs = false, .sub = NULL}}},
21 #define COM_TERM(nam, func, args)       {.name = #nam, .comfunc = func, .hasArgs = args, .sub = NULL}, 
22
23
24 extern const struct TreeNode coms;
25
26
27 #endif
28