2 This file is part of GNUnet.
3 Copyright (C) 2006, 2007, 2008, 2009, 2013 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file src/util/configuration_loader.c
23 * @brief configuration loading
24 * @author Christian Grothoff
28 #include "gnunet_util_lib.h"
30 #define LOG(kind,...) GNUNET_log_from (kind, "util-configuration", __VA_ARGS__)
34 * Load configuration (starts with defaults, then loads
35 * system-specific configuration).
37 * @param cfg configuration to update
38 * @param filename name of the configuration file, NULL to load defaults
39 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
42 GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
46 const char *base_config_varname;
48 base_config_varname = GNUNET_OS_project_data_get ()->base_config_varname;
50 if (NULL != (baseconfig = getenv (base_config_varname)))
52 baseconfig = GNUNET_strdup (baseconfig);
58 ipath = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
61 GNUNET_asprintf (&baseconfig, "%s%s", ipath, "config.d");
66 GNUNET_CONFIGURATION_load_from (cfg,
69 GNUNET_free (baseconfig);
70 return GNUNET_SYSERR; /* no configuration at all found */
72 GNUNET_free (baseconfig);
73 if ((NULL != filename) &&
74 (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, filename)))
76 /* specified configuration not found */
80 GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) &&
82 GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG",
87 /* end of configuration_loader.c */