summaryrefslogtreecommitdiff
path: root/lib/src/rdsvc.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-04 11:55:59 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-04 11:55:59 +0200
commitca7b7c15c5ecd344e844411e4b8409e552a3b06d (patch)
tree7bebbde8559d67e1f5450657f8a44ab05e48feac /lib/src/rdsvc.c
parent352a9060b6813c41527f0c5da43f0c86aecfde2a (diff)
Merge argument substitution into rdline
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'lib/src/rdsvc.c')
-rw-r--r--lib/src/rdsvc.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/lib/src/rdsvc.c b/lib/src/rdsvc.c
index ee898c3..b186cd9 100644
--- a/lib/src/rdsvc.c
+++ b/lib/src/rdsvc.c
@@ -171,7 +171,7 @@ static const struct {
service_t *rdsvc(int dirfd, const char *filename)
{
- const char *arg, *args[1];
+ const char *arg, *args[1], *error;
char *line, *key, *value;
size_t i, argc, lineno;
service_t *svc;
@@ -213,15 +213,30 @@ service_t *rdsvc(int dirfd, const char *filename)
for (lineno = 1; ; ++lineno) {
errno = 0;
- line = rdline(fd);
+ line = rdline(fd, argc, args);
if (line == NULL) {
- if (errno != 0) {
- fprintf(stderr, "read: %s: %zu: %s\n",
- filename, lineno, strerror(errno));
- goto fail;
+ if (errno == 0)
+ break;
+
+ switch (errno) {
+ case EINVAL:
+ error = "error in argument expansion";
+ break;
+ case ELOOP:
+ error = "recursive argument expansion";
+ break;
+ case EILSEQ:
+ error = "missing \"";
+ break;
+ default:
+ error = strerror(errno);
+ break;
}
- break;
+
+ fprintf(stderr, "%s: %zu: %s\n",
+ filename, lineno, error);
+ goto fail;
}
if (splitkv(line, &key, &value)) {
@@ -258,7 +273,7 @@ service_t *rdsvc(int dirfd, const char *filename)
goto fail_line;
}
- value = strexpand(value, argc, args);
+ value = strdup(value);
if (value == NULL) {
fputs("out of memory", stderr);
goto fail_line;