diff options
| author | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-10-04 16:08:58 +0200 |
|---|---|---|
| committer | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-10-04 16:08:58 +0200 |
| commit | aacc4082c747557a04627b304fce07ca7cdae8b2 (patch) | |
| tree | 9ad3fad4ff72e31f35019c7453aa84a805fb3f83 /lib/utils/parse_options.h | |
| parent | 1ae327bd0df1eb621fc6a9b4d8b81f10bf7f019d (diff) | |
| parent | 97ced498a972810547d2e87cbbce932593b1bc40 (diff) | |
Merge branch 'new-parser'
* new-parser:
Daemon.cpp: remove getopt and use parse_opts instead
new args parser
xfunc.c: add new funtion xcalloc
Diffstat (limited to 'lib/utils/parse_options.h')
| -rw-r--r-- | lib/utils/parse_options.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/utils/parse_options.h b/lib/utils/parse_options.h new file mode 100644 index 00000000..fe76a7f3 --- /dev/null +++ b/lib/utils/parse_options.h @@ -0,0 +1,37 @@ + +#ifndef PARSE_OPTIONS_H +#define PARSE_OPTIONS_H + + +#ifdef __cplusplus +extern "C" { +#endif + +enum parse_opt_type { + OPTION_BOOL, + OPTION_STRING, + OPTION_END, +}; + +struct options { + enum parse_opt_type type; + int short_name; + const char *long_name; + void *value; + const char *help; +}; + +#define OPT_END() { OPTION_END } +#define OPT_BOOL(s, l, v, h) { OPTION_BOOL, (s), (l), (v), (h) } +#define OPT_STRING(s, l, v, h) { OPTION_STRING, (s), (l), (v), (h) } + +void parse_opts(int argc, char **argv, const struct options *opt, + const char * const usage[]); + +void parse_usage_and_die(const char * const * usage, const struct options *opt); + +#ifdef __cplusplus +} +#endif + +#endif |
