summaryrefslogtreecommitdiff
path: root/conf-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'conf-parser.c')
-rw-r--r--conf-parser.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/conf-parser.c b/conf-parser.c
index 2ea6911257..2618858331 100644
--- a/conf-parser.c
+++ b/conf-parser.c
@@ -337,6 +337,36 @@ int config_parse_string(
return 0;
}
+int config_parse_path(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ char **s = data;
+ char *n;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ if (*rvalue != '/') {
+ log_error("[%s:%u] Not an absolute path: %s", filename, line, rvalue);
+ return -EINVAL;
+ }
+
+ if (!(n = strdup(rvalue)))
+ return -ENOMEM;
+
+ free(*s);
+ *s = n;
+
+ return 0;
+}
int config_parse_strv(
const char *filename,
@@ -360,7 +390,7 @@ int config_parse_strv(
assert(data);
k = strv_length(*sv);
- FOREACH_WORD(w, &l, rvalue, state)
+ FOREACH_WORD_QUOTED(w, l, rvalue, state)
k++;
if (!(n = new(char*, k+1)))
@@ -368,7 +398,7 @@ int config_parse_strv(
for (k = 0; (*sv)[k]; k++)
n[k] = (*sv)[k];
- FOREACH_WORD(w, &l, rvalue, state)
+ FOREACH_WORD_QUOTED(w, l, rvalue, state)
if (!(n[k++] = strndup(w, l)))
goto fail;
@@ -381,6 +411,7 @@ int config_parse_strv(
fail:
for (; k > 0; k--)
free(n[k-1]);
+ free(n);
return -ENOMEM;
}