diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2018-06-05 16:08:29 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-08-24 16:47:08 +0200 |
commit | da6d3a3807b6f30d3ae9b76b35069f760244f5b1 (patch) | |
tree | 2e39061d0cc6ecc4c392ef9fd19369c7d7fdd84c /src | |
parent | 14db62d166679aa43ac4a6d050d79aa9c7b301d7 (diff) |
conf-parser: add config_parse_permille()
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/conf-parser.c | 32 | ||||
-rw-r--r-- | src/shared/conf-parser.h | 1 |
2 files changed, 33 insertions, 0 deletions
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); |