support overriding GNUNET_DEFAULT_USER_CONFIG_FILE
authorChristian Grothoff <christian@grothoff.org>
Sat, 16 Apr 2016 11:10:55 +0000 (11:10 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 16 Apr 2016 11:10:55 +0000 (11:10 +0000)
src/include/gnunet_constants.h
src/include/gnunet_os_lib.h
src/util/os_installation.c
src/util/program.c
src/util/service.c

index 747b8afd5ea0291459cc163732d06b0983e484ed..000def9029de81707c0ce877b37a1df61f3e6674 100644 (file)
@@ -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
index 5785bd67fc3defbe1a467bed1b50f41e3966e5ca..d4893f906b71833839e814b26b922136e7088cba 100644 (file)
@@ -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;
+
 };
 
 
index 8606d5c588b5924c28f5802da6784f5612179e07..45f5052aad58640c8d83f2c6159670b27ae715f5 100644 (file)
@@ -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"
 };
 
 /**
index a313ce87e61eedf385c3998b8b3a4c3e3361633a..bf7885fe91587655da23e14eca26865733bc6f94 100644 (file)
@@ -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';
index c7f96502142064f30b9178b6f6e43b53b4c6a1c5..93a51f2202df2e3e9f68b66f8c7227fe6c491623 100644 (file)
@@ -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;