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