From d49d16a84422346630c3196e3de9727ea872371c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 16 Apr 2016 11:10:55 +0000 Subject: [PATCH] support overriding GNUNET_DEFAULT_USER_CONFIG_FILE --- src/include/gnunet_constants.h | 5 ----- src/include/gnunet_os_lib.h | 5 +++++ src/util/os_installation.c | 2 ++ src/util/program.c | 2 +- src/util/service.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/include/gnunet_constants.h b/src/include/gnunet_constants.h index 747b8afd5..000def902 100644 --- a/src/include/gnunet_constants.h +++ b/src/include/gnunet_constants.h @@ -40,11 +40,6 @@ extern "C" #endif #endif -/** - * Last resort choice for configuration file name. - */ -#define GNUNET_DEFAULT_USER_CONFIG_FILE "~/.config/gnunet.conf" - /** * Bandwidth (in/out) to assume initially (before either peer has * communicated any particular preference). Should be rather low; set diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h index 5785bd67f..d4893f906 100644 --- a/src/include/gnunet_os_lib.h +++ b/src/include/gnunet_os_lib.h @@ -255,6 +255,11 @@ struct GNUNET_OS_ProjectData */ const char *config_file; + /** + * Configuration file name to use (if $XDG_CONFIG_HOME is not set). + */ + const char *user_config_file; + }; diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 8606d5c58..45f5052aa 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -60,6 +60,8 @@ static const struct GNUNET_OS_ProjectData default_pd = { .env_varname = "GNUNET_PREFIX", .bug_email = "gnunet-developers@gnu.org", .homepage = "http://www.gnu.org/s/gnunet/", + .config_file = "gnunet.conf", + .user_config_file = "~/.config/gnunet.conf" }; /** diff --git a/src/util/program.c b/src/util/program.c index a313ce87e..bf7885fe9 100644 --- a/src/util/program.c +++ b/src/util/program.c @@ -225,7 +225,7 @@ GNUNET_PROGRAM_run2 (int argc, char *const *argv, const char *binaryName, DIR_SEPARATOR_STR, GNUNET_OS_project_data_get ()->config_file); else - cfg_fn = GNUNET_strdup (GNUNET_DEFAULT_USER_CONFIG_FILE); + cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file); lpfx = GNUNET_strdup (binaryName); if (NULL != (spc = strstr (lpfx, " "))) *spc = '\0'; diff --git a/src/util/service.c b/src/util/service.c index c7f965021..93a51f220 100644 --- a/src/util/service.c +++ b/src/util/service.c @@ -1429,7 +1429,7 @@ GNUNET_SERVICE_run (int argc, char *const *argv, DIR_SEPARATOR_STR, GNUNET_OS_project_data_get ()->config_file); else - cfg_fn = GNUNET_strdup (GNUNET_DEFAULT_USER_CONFIG_FILE); + cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file); memset (&sctx, 0, sizeof (sctx)); sctx.options = options; sctx.ready_confirm_fd = -1; -- 2.25.1