7 /* command type constants */
10 * FILE *f, *** only when WITHFILE
11 * int fd, *** only when WITHFD
12 * int|char *arg) *** when INTARG or STRARG */
13 /* if type==NOARG int doit(void)
14 * if type==INTARG int doit(int arg)
15 * if type==WITHFILE|WITHFD|STRARG int doit(FILE *f,int fd,char *arg)
16 * doit returns 0 on success otherwise it returns a valid errno code */
17 #define NOARG 0 /*the command require no args */
18 #define INTARG 1 /* arg is an integer */
19 #define STRARG 2 /* arg is a string */
20 #define WITHFILE 0x40 /* command needs to return text output.
21 (the output will be sent to the user using
22 "0000 DATA END WITH '.'") */
23 #define WITHFD 0x80 /* fd is the identifier of the mgmt connection issuing
24 the command. fd== -1 when the command is executed by
25 an rc file. Fd should not be considered a file
28 typedef int (*intfun
)();
30 /* command structure */
32 char *path
; /*pathname of the command: pathname structured */
33 char *syntax
; /*description of the syntax */
34 char *help
; /*description of the command for help listings */
35 int (*doit
)(); /* the call back to the command code */
36 unsigned char type
; /* types of command: see constants above */
37 /* the following field is for management. never set or change it*/
41 /* pre-defined TAGs */
42 #define D_PACKET 01000
55 /* debug/event structure */
57 char *path
; /* pathname structured debug/event request */
58 char *help
; /* description for debug options listing
59 if help==NULL the entry will be used only for
60 plugin event publish/subscribe not directly accessible
61 from the user interface */
62 int tag
; /* numerical tag of the debug/event */
63 /* the following fields are for management. never set or change them*/
69 unsigned short maxfds
;
70 unsigned short maxfun
;
74 /* plugin element: one element named "vde_plugin_data" must
75 * be defined otherwise the dynamic library will not be recognized
76 * as a vde plugin module */
78 /* name of the plugin, it should be unique, maybe pathname structured.
79 * it identifies the plugin for listing and unloading plugins */
81 /* description of the plugin for listings */
83 /* the following fields should never be set or changed by
89 /* this adds a new management fd */
90 void mgmtnewfd(int new);
92 #define ADDCL(CL) addcl(sizeof(CL)/sizeof(struct comlist),(CL))
93 #define ADDDBGCL(CL) adddbgcl(sizeof(CL)/sizeof(struct dbgcl),(CL))
94 #define DELCL(CL) delcl(sizeof(CL)/sizeof(struct comlist),(CL))
95 #define DELDBGCL(CL) deldbgcl(sizeof(CL)/sizeof(struct dbgcl),(CL))
96 #define DBGOUT(CL, FORMAT, ...) \
97 if (__builtin_expect(((CL)->nfds) > 0, 0)) debugout((CL), (FORMAT), __VA_ARGS__)
98 #define EVENTOUT(CL, ...) \
99 if (__builtin_expect(((CL)->nfun) > 0, 0)) eventout((CL), __VA_ARGS__)
102 int eventadd(int (*fun
)(struct dbgcl
*event
,void *arg
,va_list v
),char *path
,void *arg
);
103 int eventdel(int (*fun
)(struct dbgcl
*event
,void *arg
,va_list v
),char *path
,void *arg
);
105 void debugout(struct dbgcl
* cl
, const char *format
, ...);
107 void addcl(int ncl
,struct comlist
*cl
);
108 void delcl(int ncl
,struct comlist
*cl
);
111 void adddbgcl(int ncl
,struct dbgcl
*cl
);
112 void deldbgcl(int ncl
,struct dbgcl
*cl
);
115 void printoutc(FILE *f
, const char *format
, ...);
116 void printlog(int priority
, const char *format
, ...);
118 uid_t
port_user(int port
);
119 char *port_descr(int portno
, int epn
);
121 time_t qtime(); // returns global time (faster than time())
122 void qtime_csenter();
124 unsigned int qtimer_add(time_t period
,int times
,void (*call
)(),void *arg
);
125 void qtimer_del(unsigned int n
);