From c07b23ca7ec8a90e51379595e056eda028bd58d8 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Tue, 5 Jun 2018 16:08:29 +0200 Subject: [PATCH] conf-parser: add config_parse_permille() --- src/shared/conf-parser.c | 31 +++++++++++++++++++++++++++++++ src/shared/conf-parser.h | 1 + 2 files changed, 32 insertions(+) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index b5ee07c9bd..29dd1ddc88 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -1203,3 +1203,34 @@ int config_parse_rlimit( return 0; } + +int config_parse_permille(const char* unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + + unsigned *permille = data; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(permille); + + r = parse_permille(rvalue); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, + "Failed to parse permille value, ignoring: %s", rvalue); + return 0; + } + + *permille = (unsigned) r; + + return 0; +} diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index 70d313d4eb..8546d5ce66 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -140,6 +140,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_log_facility); CONFIG_PARSER_PROTOTYPE(config_parse_log_level); CONFIG_PARSER_PROTOTYPE(config_parse_signal); CONFIG_PARSER_PROTOTYPE(config_parse_personality); +CONFIG_PARSER_PROTOTYPE(config_parse_permille); CONFIG_PARSER_PROTOTYPE(config_parse_ifname); CONFIG_PARSER_PROTOTYPE(config_parse_ip_port); CONFIG_PARSER_PROTOTYPE(config_parse_join_controllers);