diff options
author | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-11-04 15:02:11 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-11-04 15:02:11 +0100 |
commit | c0e8c7e245c09598478302155b37a15f3370571f (patch) | |
tree | c2e4d7d62f00c8de12d08d9d469b8c31b3f1e21d /lib/libcfg | |
parent | 074fe20a4761e284af2aa46f978f48410cfa60c5 (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.c | 14 |
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) |