conf-parser: add a flavour of DEFINE_CONFIG_PARSE_ENUM() that allows specifiying the precie from_string() function to call

This commit is contained in:
Lennart Poettering 2020-10-26 17:38:55 +01:00
parent 3b719003c3
commit a2b06dbe15
1 changed files with 5 additions and 2 deletions

View File

@ -193,7 +193,7 @@ typedef enum Disabled {
return 0; \
}
#define DEFINE_CONFIG_PARSE_ENUM(function, name, type, msg) \
#define DEFINE_CONFIG_PARSE_ENUM_FULL(function, from_string, type, msg) \
CONFIG_PARSER_PROTOTYPE(function) { \
type *i = data, x; \
\
@ -202,7 +202,7 @@ typedef enum Disabled {
assert(rvalue); \
assert(data); \
\
x = name##_from_string(rvalue); \
x = from_string(rvalue); \
if (x < 0) { \
log_syntax(unit, LOG_WARNING, filename, line, 0, \
msg ", ignoring: %s", rvalue); \
@ -213,6 +213,9 @@ typedef enum Disabled {
return 0; \
}
#define DEFINE_CONFIG_PARSE_ENUM(function, name, type, msg) \
DEFINE_CONFIG_PARSE_ENUM_FULL(function, name##_from_string, type, msg)
#define DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(function, name, type, default_value, msg) \
CONFIG_PARSER_PROTOTYPE(function) { \
type *i = data, x; \