|
0
|
1 |
#ifndef VMAILMGR__CLI__CLI__H__
|
|
|
2 |
#define VMAILMGR__CLI__CLI__H__
|
|
|
3 |
|
|
|
4 |
typedef bool (*cli_funcptr)(void*);
|
|
|
5 |
|
|
|
6 |
struct cli_stringlist
|
|
|
7 |
{
|
|
|
8 |
const char* string;
|
|
|
9 |
cli_stringlist* next;
|
|
|
10 |
|
|
|
11 |
cli_stringlist(const char* s)
|
|
|
12 |
: string(s), next(0)
|
|
|
13 |
{
|
|
|
14 |
}
|
|
|
15 |
};
|
|
|
16 |
|
|
|
17 |
struct cli_option
|
|
|
18 |
{
|
|
|
19 |
char ch;
|
|
|
20 |
const char* name;
|
|
|
21 |
enum { flag, counter, integer, string, stringlist, uinteger } type;
|
|
|
22 |
int flag_value;
|
|
|
23 |
void* dataptr;
|
|
|
24 |
const char* helpstr;
|
|
|
25 |
const char* defaultstr;
|
|
|
26 |
|
|
|
27 |
int set(const char* arg);
|
|
|
28 |
int parse_long_eq(const char* arg);
|
|
|
29 |
int parse_long_noeq(const char* arg);
|
|
|
30 |
};
|
|
|
31 |
|
|
|
32 |
/* The following are required from the CLI program */
|
|
|
33 |
extern const char* cli_program;
|
|
|
34 |
extern const char* cli_help_prefix;
|
|
|
35 |
extern const char* cli_help_suffix;
|
|
|
36 |
extern const char* cli_args_usage;
|
|
|
37 |
extern const int cli_args_min;
|
|
|
38 |
extern const int cli_args_max;
|
|
|
39 |
extern cli_option cli_options[];
|
|
|
40 |
extern int cli_main(int argc, char* argv[]);
|
|
|
41 |
|
|
|
42 |
/* The following are provided to the CLI program */
|
|
|
43 |
extern const char* argv0;
|
|
|
44 |
extern const char* argv0base;
|
|
|
45 |
extern const char* argv0dir;
|
|
|
46 |
extern void usage(int exit_value, const char* errorstr = 0);
|
|
|
47 |
|
|
|
48 |
extern void cli_error(int exit_value,
|
|
|
49 |
const char*,
|
|
|
50 |
const char* = 0,
|
|
|
51 |
const char* = 0,
|
|
|
52 |
const char* = 0);
|
|
|
53 |
|
|
|
54 |
extern void cli_warning(const char*,
|
|
|
55 |
const char* = 0,
|
|
|
56 |
const char* = 0,
|
|
|
57 |
const char* = 0);
|
|
|
58 |
|
|
|
59 |
#endif // VMAILMGR__CLI__CLI__H__
|