diff options
author | jospaeth <spaethj@in.tum.de> | 2020-07-16 09:16:37 +0200 |
---|---|---|
committer | jospaeth <spaethj@in.tum.de> | 2020-07-16 09:16:37 +0200 |
commit | f6007d417be9f3030dad817151ed39d896d233ba (patch) | |
tree | d4de50f416578f767ac3fb75b42c86942f1b6b79 /src/util | |
parent | 2f20415d075a69198ede195e800b3cfc56a94f90 (diff) | |
parent | 5b4a00d35bd229180c6769ec582fee97c16ebf3d (diff) | |
download | gnunet-f6007d417be9f3030dad817151ed39d896d233ba.tar.gz gnunet-f6007d417be9f3030dad817151ed39d896d233ba.zip |
Merge branch 'master' into spaeth/escrow_plugins
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/configuration.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c index 34ecc9e73..faee9e3bf 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -1810,4 +1810,44 @@ GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1810 | } | 1810 | } |
1811 | 1811 | ||
1812 | 1812 | ||
1813 | /** | ||
1814 | * Return GNUnet's default configuration. A new configuration is allocated | ||
1815 | * each time and it's up to the caller to destroy it when done. This function | ||
1816 | * returns GNUnet's configuration even when #GNUNET_OS_init has been called | ||
1817 | * with a value different from #GNUNET_OS_project_data_default. | ||
1818 | * | ||
1819 | * @return a freshly allocated configuration | ||
1820 | */ | ||
1821 | struct GNUNET_CONFIGURATION_Handle * | ||
1822 | GNUNET_CONFIGURATION_default(void) | ||
1823 | { | ||
1824 | const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get (); | ||
1825 | const struct GNUNET_OS_ProjectData *dpd = GNUNET_OS_project_data_default (); | ||
1826 | |||
1827 | GNUNET_OS_init(dpd); | ||
1828 | |||
1829 | struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create (); | ||
1830 | const char *xdg = getenv ("XDG_CONFIG_HOME"); | ||
1831 | char *cfgname = NULL; | ||
1832 | |||
1833 | if (NULL != xdg) | ||
1834 | GNUNET_asprintf (&cfgname, "%s/%s", xdg, pd->config_file); | ||
1835 | else | ||
1836 | cfgname = GNUNET_strdup (pd->user_config_file); | ||
1837 | |||
1838 | if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfgname)) { | ||
1839 | GNUNET_OS_init (pd); | ||
1840 | GNUNET_CONFIGURATION_destroy (cfg); | ||
1841 | GNUNET_free (cfgname); | ||
1842 | return NULL; | ||
1843 | } | ||
1844 | |||
1845 | GNUNET_free (cfgname); | ||
1846 | |||
1847 | GNUNET_OS_init (pd); | ||
1848 | |||
1849 | return cfg; | ||
1850 | } | ||
1851 | |||
1852 | |||
1813 | /* end of configuration.c */ | 1853 | /* end of configuration.c */ |