From: Marc Kleine-Budde Date: Tue, 5 Jun 2018 14:08:29 +0000 (+0200) Subject: conf-parser: add config_parse_permille() X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=da6d3a3807b6f30d3ae9b76b35069f760244f5b1;p=elogind.git conf-parser: add config_parse_permille() --- diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 949a77fd2..133d8f62c 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -48,6 +48,7 @@ //#include "rlimit-util.h" //#include "rlimit-util.h" //#include "rlimit-util.h" +//#include "rlimit-util.h" int config_item_table_lookup( const void *table, @@ -1231,3 +1232,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 6e77a4fe1..e0d9f268f 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -156,6 +156,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);