aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r--src/util/configuration.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index adfd4ea5a..a269ed036 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -1215,6 +1215,25 @@ GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle
1215 1215
1216 1216
1217/** 1217/**
1218 * Wrapper around GNUNET_CONFIGURATION_parse.
1219 *
1220 * @param cls the cfg
1221 * @param filename file to parse
1222 * @return GNUNET_OK on success
1223 */
1224static int
1225parse_configuration_file (void *cls,
1226 const char *filename)
1227{
1228 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1229 int ret;
1230
1231 ret = GNUNET_CONFIGURATION_parse (cfg, filename);
1232 return ret;
1233}
1234
1235
1236/**
1218 * Load configuration (starts with defaults, then loads 1237 * Load configuration (starts with defaults, then loads
1219 * system-specific configuration). 1238 * system-specific configuration).
1220 * 1239 *
@@ -1233,17 +1252,24 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
1233 if (ipath == NULL) 1252 if (ipath == NULL)
1234 return GNUNET_SYSERR; 1253 return GNUNET_SYSERR;
1235 baseconfig = NULL; 1254 baseconfig = NULL;
1236 GNUNET_asprintf (&baseconfig, "%s%s%s", ipath, DIR_SEPARATOR_STR, 1255 GNUNET_asprintf (&baseconfig, "%s%s", ipath,
1237 "defaults.conf"); 1256 "config.d");
1238 GNUNET_free (ipath); 1257 GNUNET_free (ipath);
1239 if ((GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, baseconfig)) || 1258 if (GNUNET_SYSERR ==
1240 (!((filename == NULL) || 1259 GNUNET_DISK_directory_scan (baseconfig,
1241 (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename))))) 1260 &parse_configuration_file,
1242 { 1261 cfg))
1243 GNUNET_free (baseconfig); 1262 {
1244 return (filename == NULL) ? GNUNET_OK : GNUNET_SYSERR; 1263 GNUNET_free (baseconfig);
1245 } 1264 return GNUNET_SYSERR; /* no configuration at all found */
1246 GNUNET_free (baseconfig); 1265 }
1266 GNUNET_free (baseconfig);
1267 if ( (filename != NULL) &&
1268 (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, filename)) )
1269 {
1270 /* specified configuration not found */
1271 return GNUNET_SYSERR;
1272 }
1247 if (((GNUNET_YES != 1273 if (((GNUNET_YES !=
1248 GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) && 1274 GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) &&
1249 (filename != NULL)) 1275 (filename != NULL))