diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-28 22:26:02 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-28 22:26:02 +0200 |
commit | 0c1296cb862b92a936d57bc1e509e34e7cd65a17 (patch) | |
tree | e5532b6c0d11b4d3d5d3d96386c5836ee3bd0278 | |
parent | 9d572f3b53259e0cae8c396539f9b0226016e24d (diff) | |
download | fastd-0c1296cb862b92a936d57bc1e509e34e7cd65a17.tar fastd-0c1296cb862b92a936d57bc1e509e34e7cd65a17.zip |
Interpret includes relative to config file path
-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); } |