aboutsummaryrefslogtreecommitdiff
path: root/src/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/options.c')
-rw-r--r--src/options.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/options.c b/src/options.c
index 6a122b5..28c9a58 100644
--- a/src/options.c
+++ b/src/options.c
@@ -98,11 +98,15 @@ static int setopt_list(struct opt *o, const char *optarg)
assert(o && o->type != OT_INVALID);
- if (o->type == OT_NOARG || !o->is_list)
+ if (!optarg || o->type == OT_NOARG || !o->is_list)
return 1;
l = &o->value.list;
while (*l) l = &(*l)->next;
+ *l = (opt_list *) calloc(1, sizeof **l);
+
+ if (opt_convert(o->type, &(*l)->value))
+ return 1;
o->used = 1;
@@ -191,3 +195,23 @@ getopt_str(opt_name on)
return str;
}
+
+char *
+getopt_strlist(opt_name on, opt_list **ol)
+{
+ opt_list *o;
+
+ assert(options[on].is_list && ol);
+ assert(options[on].type == OT_STR ||
+ options[on].type == OT_PATH);
+ assert(getopt_used(on) && !options[on].def_value.str);
+
+ if (*ol) {
+ o = (*ol)->next;
+ } else {
+ o = options[on].value.list;
+ }
+ *ol = o;
+
+ return (o ? o->value.str_dup : NULL);
+}