Skip to content

Commit cccefc4

Browse files
ikegami-tigaw
authored andcommitted
argconfig: add argconfig_get_value()
This is to get the option value by name. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 4b5ac98 commit cccefc4

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

util/argconfig.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,16 @@ bool argconfig_parse_seen(struct argconfig_commandline_options *s,
429429

430430
return false;
431431
}
432+
433+
void *argconfig_get_value(struct argconfig_commandline_options *s, const char *option)
434+
{
435+
for (; s && s->option; s++) {
436+
if (!strcmp(s->option, option)) {
437+
if (s->seen)
438+
return s->default_value;
439+
break;
440+
}
441+
}
442+
443+
return NULL;
444+
}

util/argconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,5 @@ int argconfig_parse_comma_sep_array_u64(char *string, __u64 *val,
190190
void print_word_wrapped(const char *s, int indent, int start, FILE *stream);
191191
bool argconfig_parse_seen(struct argconfig_commandline_options *options,
192192
const char *option);
193+
void *argconfig_get_value(struct argconfig_commandline_options *s, const char *option);
193194
#endif

0 commit comments

Comments
 (0)