diff options
| author | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-10-05 16:26:12 +0200 |
|---|---|---|
| committer | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-10-05 16:43:04 +0200 |
| commit | 4c96efa86e18cc836eb635c9dc61c0cf9eff8468 (patch) | |
| tree | 221182ada0a31f209db9cbff77742b58723dc982 /lib | |
| parent | 3f5c913bb2c534705b883edb813e36d5c72768da (diff) | |
| download | abrt-4c96efa86e18cc836eb635c9dc61c0cf9eff8468.tar.gz abrt-4c96efa86e18cc836eb635c9dc61c0cf9eff8468.tar.xz abrt-4c96efa86e18cc836eb635c9dc61c0cf9eff8468.zip | |
add OPT_GROUP option
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/utils/parse_options.c | 13 | ||||
| -rw-r--r-- | lib/utils/parse_options.h | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/utils/parse_options.c b/lib/utils/parse_options.c index 97454e1a..e65a1bb9 100644 --- a/lib/utils/parse_options.c +++ b/lib/utils/parse_options.c @@ -22,13 +22,22 @@ void parse_usage_and_die(const char * const * usage, const struct options *opt) while (*usage && **usage) fprintf(stderr, _(" or: %s\n"), *usage++); - fputc('\n', stderr); + if (opt->type != OPTION_GROUP) + fputc('\n', stderr); for (; opt->type != OPTION_END; opt++) { size_t pos; int pad; + if (opt->type == OPTION_GROUP) + { + fputc('\n', stderr); + if (*opt->help) + fprintf(stderr, "%s\n", opt->help); + continue; + } + pos = fprintf(stderr, " "); if (opt->short_name) pos += fprintf(stderr, "-%c", opt->short_name); @@ -81,6 +90,7 @@ void parse_opts(int argc, char **argv, const struct options *opt, if (opt[ii].short_name) strbuf_append_strf(shortopts, "%c:", opt[ii].short_name); break; + case OPTION_GROUP: case OPTION_END: break; } @@ -125,6 +135,7 @@ void parse_opts(int argc, char **argv, const struct options *opt, if (optarg) *(char**)opt[ii].value = (char*)optarg; break; + case OPTION_GROUP: case OPTION_END: break; } diff --git a/lib/utils/parse_options.h b/lib/utils/parse_options.h index 53a547d6..9f40fc94 100644 --- a/lib/utils/parse_options.h +++ b/lib/utils/parse_options.h @@ -9,6 +9,7 @@ extern "C" { enum parse_opt_type { OPTION_BOOL, + OPTION_GROUP, OPTION_STRING, OPTION_INTEGER, OPTION_END, @@ -32,6 +33,7 @@ struct options { */ #define OPT_END() { OPTION_END } #define OPT_BOOL(s, l, v, h) { OPTION_BOOL, (s), (l), (v), NULL, (h) } +#define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) } #define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), "n", (h) } #define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) } |
