]>
Commit | Line | Data |
---|---|---|
4a59fd13 PH |
1 | #ifndef PARSE_OPTIONS_H |
2 | #define PARSE_OPTIONS_H | |
3 | ||
4 | enum parse_opt_type { | |
5 | OPTION_END, | |
6 | OPTION_BOOLEAN, | |
7 | OPTION_STRING, | |
8 | OPTION_INTEGER, | |
9 | }; | |
10 | ||
11 | enum parse_opt_flags { | |
12 | PARSE_OPT_KEEP_DASHDASH = 1, | |
13 | }; | |
14 | ||
15 | struct option { | |
16 | enum parse_opt_type type; | |
17 | int short_name; | |
18 | const char *long_name; | |
19 | void *value; | |
20 | }; | |
21 | ||
22 | #define OPT_END() { OPTION_END } | |
23 | #define OPT_BOOLEAN(s, l, v, h) { OPTION_BOOLEAN, (s), (l), (v) } | |
24 | #define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v) } | |
25 | #define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v) } | |
26 | ||
27 | /* parse_options() will filter out the processed options and leave the | |
28 | * non-option argments in argv[]. | |
29 | * Returns the number of arguments left in argv[]. | |
30 | */ | |
31 | extern int parse_options(int argc, const char **argv, | |
32 | const struct option *options, | |
33 | const char *usagestr, int flags); | |
34 | ||
35 | #endif |