From 5f7a1f1f2f20f07706275c9270f2f4ed0eb61d7a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 4 Mar 2012 22:26:15 +0000 Subject: [PATCH] -adding GNUNET_CONFIGURATION_load_from --- src/include/gnunet_configuration_lib.h | 13 +++++++++++++ src/util/configuration.c | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h index f8f302a18..0fcb4e054 100644 --- a/src/include/gnunet_configuration_lib.h +++ b/src/include/gnunet_configuration_lib.h @@ -86,6 +86,19 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename); +/** + * Load default configuration. This function will parse the + * defaults from the given defaults_d directory. + * + * @param cfg configuration to update + * @param defaults_d directory with the defaults + * @return GNUNET_OK on success, GNUNET_SYSERR on error + */ +int +GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, + const char *defaults_d); + + /** * Parse a configuration file, add all of the options in the * file to the configuration environment. diff --git a/src/util/configuration.c b/src/util/configuration.c index f24b2c2c6..6ec9a7183 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -1235,6 +1235,25 @@ parse_configuration_file (void *cls, const char *filename) } +/** + * Load default configuration. This function will parse the + * defaults from the given defaults_d directory. + * + * @param cfg configuration to update + * @param defaults_d directory with the defaults + * @return GNUNET_OK on success, GNUNET_SYSERR on error + */ +int +GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, + const char *defaults_d) +{ + if (GNUNET_SYSERR == + GNUNET_DISK_directory_scan (defaults_d, &parse_configuration_file, cfg)) + return GNUNET_SYSERR; /* no configuration at all found */ + return GNUNET_OK; +} + + /** * Load configuration (starts with defaults, then loads * system-specific configuration). -- 2.25.1