support infinity/forever for time value in configuration
authorChristian Grothoff <christian@grothoff.org>
Thu, 30 Jun 2011 20:34:47 +0000 (20:34 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 30 Jun 2011 20:34:47 +0000 (20:34 +0000)
src/util/configuration.c

index 4aa5fed5a13b3a6d59eefa4996b46d8d7f6d9be5..978765970c80fbb69857b7da4cc21fc0849f805c 100644 (file)
@@ -690,13 +690,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;
 }