X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Fconf-parser.c;h=06c05a0ce35cdf70d2baf12951792842e894612f;hp=90f3167f523dc39233743d0b0f6b9027e9456bc8;hb=4a121b358bb9d90bd50d73a74a1f9f133f479c5c;hpb=f5eb2a086bc5d5d36bc2e4755a1d6b508e202250 diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 90f3167f5..06c05a0ce 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -100,7 +100,7 @@ int config_item_perf_lookup( else { char *key; - key = strjoin(section, ".", lvalue, NULL); + key = strjoin(section, ".", lvalue); if (!key) return -ENOMEM; @@ -508,6 +508,7 @@ int config_parse_many( DEFINE_PARSER(int, int, safe_atoi); DEFINE_PARSER(long, long, safe_atoli); #if 0 /// UNNEEDED by elogind +DEFINE_PARSER(uint8, uint8_t, safe_atou8); DEFINE_PARSER(uint16, uint16_t, safe_atou16); DEFINE_PARSER(uint32, uint32_t, safe_atou32); #endif // 0 @@ -790,7 +791,7 @@ int config_parse_strv(const char *unit, for (;;) { char *word = NULL; - r = extract_first_word(&rvalue, &word, WHITESPACE, EXTRACT_QUOTES|EXTRACT_RETAIN_ESCAPE); + r = extract_first_word(&rvalue, &word, NULL, EXTRACT_QUOTES|EXTRACT_RETAIN_ESCAPE); if (r == 0) break; if (r == -ENOMEM) @@ -972,3 +973,40 @@ int config_parse_ifname( return 0; } #endif // 0 + +int config_parse_ip_port( + 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) { + + uint16_t *s = data; + uint16_t port; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + if (isempty(rvalue)) { + *s = 0; + return 0; + } + + r = parse_ip_port(rvalue, &port); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse port '%s'.", rvalue); + return 0; + } + + *s = port; + + return 0; +}