Add options in format -opt=value

This commit is contained in:
Kamil Trzcinski
2022-04-06 09:22:35 +02:00
parent 4e3c235b36
commit 23178325cf
5 changed files with 43 additions and 22 deletions

View File

@ -21,6 +21,7 @@ typedef struct options_s {
const char *help;
option_value_t *value_mapping;
unsigned size;
const char *default_value;
} option_t;
#define lambda(return_type, function_body) \
@ -43,6 +44,15 @@ typedef struct options_s {
.size = sizeof(_section##_options._name), \
}
#define DEFINE_OPTION_DEFAULT(_section, _name, _type, _default_value) \
{ \
.name = #_section "-" #_name, \
.value_##_type = &_section##_options._name, \
.format = OPTION_FORMAT_##_type, \
.size = sizeof(_section##_options._name), \
.default_value = _default_value, \
}
#define DEFINE_OPTION_VALUES(_section, _name, _value_mapping) \
{ \
.name = #_section "-" #_name, \