X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fconf-parser.c;h=3ccd1c067a20c13b0aa085fa8d9a4093af3d6a63;hb=1124fe6f01b1d59d016c238026f20380f38d98dc;hp=970877650d642a269e27c8b2a28266c671646410;hpb=f975e971accc4d50c73ae53167db3df7a7099cf2;p=elogind.git diff --git a/src/conf-parser.c b/src/conf-parser.c index 970877650..3ccd1c067 100644 --- a/src/conf-parser.c +++ b/src/conf-parser.c @@ -88,7 +88,8 @@ int config_item_perf_lookup( else { char *key; - if (asprintf(&key, "%s.%s", section, lvalue) < 0) + key = join(section, ".", lvalue, NULL); + if (!key) return -ENOMEM; p = lookup(key, strlen(key)); @@ -131,8 +132,12 @@ static int next_assignment( if (r < 0) return r; - if (func) - return func(filename, line, section, lvalue, ltype, rvalue, data, userdata); + if (r > 0) { + if (func) + return func(filename, line, section, lvalue, ltype, rvalue, data, userdata); + + return 0; + } /* Warn about unknown non-extension fields. */ if (!relaxed && !startswith(lvalue, "X-")) @@ -309,7 +314,7 @@ int config_parse( continuation = c; else { continuation = strdup(l); - if (!c) { + if (!continuation) { r = -ENOMEM; goto finish; } @@ -747,3 +752,30 @@ int config_parse_mode( *m = (mode_t) l; return 0; } + +int config_parse_bytes( + const char *filename, + unsigned line, + const char *section, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + + off_t *bytes = data; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + assert_cc(sizeof(off_t) == sizeof(uint64_t)); + + if (parse_bytes(rvalue, bytes) < 0) { + log_error("[%s:%u] Failed to parse bytes value, ignoring: %s", filename, line, rvalue); + return 0; + } + + return 0; +}