summaryrefslogtreecommitdiff
path: root/src/util/option.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/option.h')
-rw-r--r--src/util/option.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util/option.h b/src/util/option.h
index 780a6e9..a5a698b 100644
--- a/src/util/option.h
+++ b/src/util/option.h
@@ -7,6 +7,7 @@ enum option_spec_kind {
OPTSPECKIND_SETBOOL,
OPTSPECKIND_CALL,
OPTSPECKIND_CALLP,
+ OPTSPECKIND_WITHARG,
OPTSPECKIND_HELPUSAGE,
OPTSPECKIND_VERSION,
@@ -25,6 +26,7 @@ struct option_spec {
struct { bool *ptr; } setbool;
struct { void (*fun)(void); } call;
struct { void (*fun)(void*); void *data; } callp;
+ struct { char **dst; } witharg;
struct { const char *usagestr; } helpusage;
struct {} version;
} spec_sub;
@@ -43,6 +45,12 @@ struct option_spec {
#define OPTION_CALLP(funptr, dataptr) \
OPTSPECKIND_CALLP, {.callp={.fun=(funptr), .data=(dataptr)}}
+// An option with an argument. Takes a char** and stores a newly malloc()ed
+// string in that pointer for the given argument. Later occurrences override any
+// previous ones, and NULL is written if the option never occurs.
+#define OPTION_WITHARG(argptr) \
+ OPTSPECKIND_WITHARG, {.witharg={.dst=(argptr)}}
+
// Takes a printf format string with a single %s, which is substituted (by
// printf) for argv[0]. Prints the formatted string and exits with code 0.
#define OPTION_HELPUSAGE(usagestring) \