WiP
[oweals/gnunet.git] / src / util / configuration.c
index eb201d79b688160b33b278534741076b9fa7dcca..10f2d757557384b8bd6a8d48db37103969d95131 100644 (file)
@@ -306,7 +306,11 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
   fn = GNUNET_STRINGS_filename_expand (filename);
   if (fn == NULL)
     return GNUNET_SYSERR;
-  GNUNET_DISK_directory_create_for_file (fn);
+  if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn))
+    {
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
+    }
   if (NULL == (fp = FOPEN (fn, "w")))
     {
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fopen", fn);
@@ -397,6 +401,25 @@ GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
 }
 
 
+/**
+ * Iterate over all sections in the configuration.
+ *
+ * @param cfg configuration to inspect
+ * @param iter function to call on each section
+ * @param iter_cls closure for iter
+ */
+void
+GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                                       GNUNET_CONFIGURATION_Section_Iterator iter,
+                                       void *iter_cls)
+{
+  struct ConfigSection *spos;
+
+  for (spos = cfg->sections; spos != NULL; spos = spos->next)
+    iter (iter_cls, spos->name);
+}
+
+
 /**
  * Copy a configuration value to the given target configuration.
  * Overwrites existing entries.