summaryrefslogtreecommitdiff
path: root/lib/cli++/cli++.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cli++/cli++.h')
-rw-r--r--lib/cli++/cli++.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/cli++/cli++.h b/lib/cli++/cli++.h
new file mode 100644
index 0000000..3dfeb14
--- /dev/null
+++ b/lib/cli++/cli++.h
@@ -0,0 +1,69 @@
+#ifndef VMAILMGR__CLIPP__CLIPP__H__
+#define VMAILMGR__CLIPP__CLIPP__H__
+
+typedef bool (*cli_funcptr)(void*);
+
+struct cli_stringlist
+{
+ const char* string;
+ cli_stringlist* next;
+
+ cli_stringlist(const char* s)
+ : string(s), next(0)
+ {
+ }
+};
+
+struct cli_option
+{
+ char ch;
+ const char* name;
+ enum { flag, counter, integer, string, stringlist, ulong } type;
+ int flag_value;
+ void* dataptr;
+ const char* helpstr;
+ const char* defaultstr;
+
+ int set(const char* arg);
+ int parse_long_eq(const char* arg, int as_short);
+ int parse_long_noeq(const char* arg, int as_short);
+};
+
+#define CLI_OPTION_END {0, 0, cli_option::flag, 0, 0, 0, 0}
+
+/* The following are required from the CLI program */
+extern const char* cli_program;
+extern const char* cli_help_prefix;
+extern const char* cli_help_suffix;
+extern const char* cli_args_usage;
+extern const int cli_args_min;
+extern const int cli_args_max;
+extern cli_option cli_options[];
+extern const bool cli_only_long;
+extern int cli_main(int argc, char* argv[]);
+
+/* The following are provided to the CLI program */
+extern const char* argv0;
+extern const char* argv0base;
+extern const char* argv0dir;
+extern void usage(int exit_value, const char* errorstr = 0);
+extern int cli_parse_args(int argc, char* argv[]);
+
+extern void cli_error(int exit_value,
+ const char*,
+ const char* = 0,
+ const char* = 0,
+ const char* = 0);
+
+extern void cli_syserror(int exit_value,
+ const char*,
+ const char* = 0,
+ const char* = 0,
+ const char* = 0);
+
+extern void cli_warning(const char*,
+ const char* = 0,
+ const char* = 0,
+ const char* = 0);
+
+#endif