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));
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-"))
continuation = c;
else {
continuation = strdup(l);
- if (!c) {
+ if (!continuation) {
r = -ENOMEM;
goto finish;
}
*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;
+}