LRN: Fix automake deps to allow -j* builds again
[oweals/gnunet.git] / src / util / configuration.c
index 4aa5fed5a13b3a6d59eefa4996b46d8d7f6d9be5..88bde1c38f91c6b46ced9547f711f6118547176f 100644 (file)
@@ -389,6 +389,39 @@ GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
 }
 
 
+/**
+ * Iterate over values of a section in the configuration.
+ *
+ * @param cfg configuration to inspect
+ * @param section the section
+ * @param iter function to call on each option
+ * @param iter_cls closure for iter
+ */
+void
+GNUNET_CONFIGURATION_iterate_section_values (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                              const char *section,
+                              GNUNET_CONFIGURATION_Iterator iter,
+                              void *iter_cls)
+{
+  struct ConfigSection *spos;
+  struct ConfigEntry *epos;
+
+  spos = cfg->sections;
+  while ((spos != NULL) && (0 != strcmp (spos->name, section)))
+    spos = spos->next;
+
+  if (spos == NULL)
+    return;
+
+  epos = spos->entries;
+  while (epos != NULL)
+    {
+      iter (iter_cls, spos->name, epos->key, epos->val);
+      epos = epos->next;
+    }
+}
+
+
 /**
  * Iterate over all sections in the configuration.
  *
@@ -690,13 +723,22 @@ GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle
                                      const char *option,
                                      struct GNUNET_TIME_Relative *time)
 {
+  struct ConfigEntry *e;
   unsigned long long num;
-  int ret;
 
-  ret = GNUNET_CONFIGURATION_get_value_number (cfg, section, option, &num);
-  if (ret == GNUNET_OK)
-    time->rel_value = (uint64_t) num;
-  return ret;
+  e = findEntry (cfg, section, option);
+  if (e == NULL)
+    return GNUNET_SYSERR;
+  if ( (0 == strcasecmp (e->val, "infinity")) ||
+       (0 == strcasecmp (e->val, "forever")) )
+    {
+      *time = GNUNET_TIME_UNIT_FOREVER_REL;
+      return GNUNET_OK;
+    }
+  if (1 != SSCANF (e->val, "%llu", &num))
+    return GNUNET_SYSERR;
+  time->rel_value = (uint64_t) num;
+  return GNUNET_OK;
 }