aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration_loader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/configuration_loader.c')
-rw-r--r--src/util/configuration_loader.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/util/configuration_loader.c b/src/util/configuration_loader.c
index 095e69474..ccf9a25b2 100644
--- a/src/util/configuration_loader.c
+++ b/src/util/configuration_loader.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file src/util/configuration_loader.c 22 * @file src/util/configuration_loader.c
@@ -27,7 +27,7 @@
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29 29
30#define LOG(kind,...) GNUNET_log_from (kind, "util-configuration", __VA_ARGS__) 30#define LOG(kind, ...) GNUNET_log_from(kind, "util-configuration", __VA_ARGS__)
31 31
32 32
33/** 33/**
@@ -39,48 +39,48 @@
39 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 39 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
40 */ 40 */
41int 41int
42GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, 42GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg,
43 const char *filename) 43 const char *filename)
44{ 44{
45 char *baseconfig; 45 char *baseconfig;
46 const char *base_config_varname; 46 const char *base_config_varname;
47 47
48 base_config_varname = GNUNET_OS_project_data_get ()->base_config_varname; 48 base_config_varname = GNUNET_OS_project_data_get()->base_config_varname;
49 49
50 if (NULL != (baseconfig = getenv (base_config_varname))) 50 if (NULL != (baseconfig = getenv(base_config_varname)))
51 { 51 {
52 baseconfig = GNUNET_strdup (baseconfig); 52 baseconfig = GNUNET_strdup(baseconfig);
53 } 53 }
54 else 54 else
55 { 55 {
56 char *ipath; 56 char *ipath;
57 57
58 ipath = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); 58 ipath = GNUNET_OS_installation_get_path(GNUNET_OS_IPK_DATADIR);
59 if (NULL == ipath) 59 if (NULL == ipath)
60 return GNUNET_SYSERR; 60 return GNUNET_SYSERR;
61 GNUNET_asprintf (&baseconfig, "%s%s", ipath, "config.d"); 61 GNUNET_asprintf(&baseconfig, "%s%s", ipath, "config.d");
62 GNUNET_free (ipath); 62 GNUNET_free(ipath);
63 } 63 }
64 64
65 if (GNUNET_SYSERR == 65 if (GNUNET_SYSERR ==
66 GNUNET_CONFIGURATION_load_from (cfg, 66 GNUNET_CONFIGURATION_load_from(cfg,
67 baseconfig)) 67 baseconfig))
68 { 68 {
69 GNUNET_free (baseconfig); 69 GNUNET_free(baseconfig);
70 return GNUNET_SYSERR; /* no configuration at all found */ 70 return GNUNET_SYSERR; /* no configuration at all found */
71 } 71 }
72 GNUNET_free (baseconfig); 72 GNUNET_free(baseconfig);
73 if ((NULL != filename) && 73 if ((NULL != filename) &&
74 (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, filename))) 74 (GNUNET_OK != GNUNET_CONFIGURATION_parse(cfg, filename)))
75 { 75 {
76 /* specified configuration not found */ 76 /* specified configuration not found */
77 return GNUNET_SYSERR; 77 return GNUNET_SYSERR;
78 } 78 }
79 if (((GNUNET_YES != 79 if (((GNUNET_YES !=
80 GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) && 80 GNUNET_CONFIGURATION_have_value(cfg, "PATHS", "DEFAULTCONFIG"))) &&
81 (filename != NULL)) 81 (filename != NULL))
82 GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", 82 GNUNET_CONFIGURATION_set_value_string(cfg, "PATHS", "DEFAULTCONFIG",
83 filename); 83 filename);
84 return GNUNET_OK; 84 return GNUNET_OK;
85} 85}
86 86