aboutsummaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-10-10 11:28:46 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-10-10 16:45:11 +0200
commit24c90b7700e18d0668799f8f343bc854a42dea20 (patch)
tree224d9b5e81a46e27f354c6975fc3fa4cd1f1fb79 /lib/util
parent7b647eefef00afb6104e84fae2a2fbf0481d4364 (diff)
Configuration parser cleanup
- Do a getline() & process in rdline instead of doing a read per character and feeding it through a state machine. - Move splitkv to rdcfg.c, the only place where it is used Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/rdsvc.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/util/rdsvc.c b/lib/util/rdsvc.c
index 747d753..ca60731 100644
--- a/lib/util/rdsvc.c
+++ b/lib/util/rdsvc.c
@@ -266,8 +266,6 @@ service_t *rdsvc(int dirfd, const char *filename, int flags)
argc = 0;
}
- rdline_init(&rd, fd, filename, argc, args);
-
nlen = (arg != NULL) ? (size_t)(arg - filename) : strlen(filename);
svc = calloc(1, sizeof(*svc) + nlen + 1);
@@ -282,14 +280,17 @@ service_t *rdsvc(int dirfd, const char *filename, int flags)
memcpy(svc->name, filename, nlen);
- if (rdcfg(svc, &rd, svc_params, ARRAY_SIZE(svc_params), flags))
- goto fail;
+ rdline_init(&rd, fd, filename, argc, args);
+
+ if (rdcfg(svc, &rd, svc_params, ARRAY_SIZE(svc_params), flags)) {
+ delsvc(svc);
+ svc = NULL;
+ }
- close(fd);
+ rdline_cleanup(&rd);
return svc;
fail_oom:
fputs("out of memory\n", stderr);
-fail:
delsvc(svc);
close(fd);
return NULL;