summaryrefslogtreecommitdiffstats
path: root/util/argconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/argconfig.c')
-rw-r--r--util/argconfig.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/util/argconfig.c b/util/argconfig.c
index 341a049..59d8f1d 100644
--- a/util/argconfig.c
+++ b/util/argconfig.c
@@ -39,6 +39,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include <stdbool.h>
static argconfig_help_func *help_funcs[MAX_HELP_FUNC] = { NULL };
@@ -176,17 +177,8 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
if (s->option && strlen(s->option)) {
long_opts[option_index].name = s->option;
long_opts[option_index].has_arg = s->argument_type;
-
- if (s->argument_type == no_argument
- && s->default_value != NULL) {
- value_addr = (void *)(char *)s->default_value;
-
- long_opts[option_index].flag = value_addr;
- long_opts[option_index].val = 1;
- } else {
- long_opts[option_index].flag = NULL;
- long_opts[option_index].val = 0;
- }
+ long_opts[option_index].flag = NULL;
+ long_opts[option_index].val = 0;
}
option_index++;
}
@@ -219,10 +211,6 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
}
if (option_index == options_count)
continue;
- if (long_opts[option_index].flag) {
- *(uint8_t *)(long_opts[option_index].flag) = 1;
- continue;
- }
}
s = &options[option_index];
@@ -282,7 +270,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
}
*((uint32_t *) value_addr) = tmp;
} else if (s->config_type == CFG_INCREMENT) {
- (*((int *)value_addr))++;
+ *((int *)value_addr) += 1;
} else if (s->config_type == CFG_LONG) {
*((unsigned long *)value_addr) = strtoul(optarg, &endptr, 0);
if (errno || optarg == endptr) {
@@ -363,6 +351,8 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
goto out;
}
*((FILE **) value_addr) = f;
+ } else if (s->config_type == CFG_FLAG) {
+ *((bool *)value_addr) = true;
}
}
free(short_opts);