-adding GNUNET_CONFIGURATION_load_from
authorChristian Grothoff <christian@grothoff.org>
Sun, 4 Mar 2012 22:26:15 +0000 (22:26 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 4 Mar 2012 22:26:15 +0000 (22:26 +0000)
src/include/gnunet_configuration_lib.h
src/util/configuration.c

index f8f302a187b2ab675f4f21f40c79eab2cc5ad69e..0fcb4e054c1f2fde4cb237f1e000abf95326ead5 100644 (file)
@@ -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.
index f24b2c2c62002bb79f4d9e2a651bdb1aebf115f9..6ec9a718349316fb51949aad33b35a11fdf92ab1 100644 (file)
@@ -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).