From: Lennart Poettering Date: Mon, 26 Oct 2020 16:38:55 +0000 (+0100) Subject: conf-parser: add a flavour of DEFINE_CONFIG_PARSE_ENUM() that allows specifiying... X-Git-Tag: v247-rc2~50^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a2b06dbe15871f41deb107ee30a784e8a1ceb951;p=thirdparty%2Fsystemd.git conf-parser: add a flavour of DEFINE_CONFIG_PARSE_ENUM() that allows specifiying the precie from_string() function to call --- diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index 2514dcbf483..d2391d43bbe 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -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; \