aboutsummaryrefslogtreecommitdiff
path: root/lib/libcfg
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-11-04 15:02:11 +0100
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-11-04 15:02:11 +0100
commitc0e8c7e245c09598478302155b37a15f3370571f (patch)
treec2e4d7d62f00c8de12d08d9d469b8c31b3f1e21d /lib/libcfg
parent074fe20a4761e284af2aa46f978f48410cfa60c5 (diff)
cleanup: let rdline_init open the file
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'lib/libcfg')
-rw-r--r--lib/libcfg/rdline.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/libcfg/rdline.c b/lib/libcfg/rdline.c
index dbb3069..b0cd789 100644
--- a/lib/libcfg/rdline.c
+++ b/lib/libcfg/rdline.c
@@ -23,15 +23,23 @@
#include <stdio.h>
#include "libcfg.h"
+#include "util.h"
-void rdline_init(rdline_t *t, int fd, const char *filename,
- int argc, const char *const *argv)
+int rdline_init(rdline_t *t, int dirfd, const char *filename,
+ int argc, const char *const *argv)
{
memset(t, 0, sizeof(*t));
- t->fp = fdopen(fd, "r");
+
+ t->fp = fopenat(dirfd, filename, "r");
+ if (t->fp == NULL) {
+ perror(filename);
+ return -1;
+ }
+
t->filename = filename;
t->argc = argc;
t->argv = argv;
+ return 0;
}
void rdline_cleanup(rdline_t *t)