diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c index f57696d..d0d8dbd 100644 --- a/src/config.c +++ b/src/config.c @@ -24,6 +24,8 @@ */ +#define _GNU_SOURCE + #include "fastd.h" #include "peer.h" #include <config.ll.h> @@ -32,6 +34,7 @@ #include <config.h> #include <arpa/inet.h> +#include <libgen.h> #include <stdarg.h> @@ -97,6 +100,12 @@ void fastd_read_config(fastd_context *ctx, fastd_config *conf, const char *filen } + char *oldcwd = get_current_dir_name(); + char *filename2 = strdup(filename); + char *dir = dirname(filename2); + + chdir(dir); + yyscan_t scanner; fastd_config_yylex_init(&scanner); fastd_config_yyset_in(file, scanner); @@ -121,6 +130,11 @@ void fastd_read_config(fastd_context *ctx, fastd_config *conf, const char *filen fastd_config_pstate_delete(ps); fastd_config_yylex_destroy(scanner); + chdir(oldcwd); + + free(filename2); + free(oldcwd); + if (!use_stdin) fclose(file); } |