-fix time assertion introduce in last patch
[oweals/gnunet.git] / src / util / configuration.c
index c69b933a35278aba00a45beb9431329142499162..8444c2d7d0ce6bba4f2c2bc43334119ddaae122d 100644 (file)
@@ -328,7 +328,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
     return GNUNET_SYSERR;
   dirty = cfg->dirty;           /* back up value! */
   if (GNUNET_SYSERR ==
-       GNUNET_DISK_file_size (fn, &fs64, GNUNET_YES, GNUNET_YES))
+      GNUNET_DISK_file_size (fn, &fs64, GNUNET_YES, GNUNET_YES))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
         "Error while determining the file size of %s\n", fn);
@@ -879,6 +879,33 @@ GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle
   return GNUNET_OK;
 }
 
+/**
+ * Get a configuration value that should be a floating point number.
+ *
+ * @param cfg configuration to inspect
+ * @param section section of interest
+ * @param option option of interest
+ * @param number where to store the floating value of the option
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+int
+GNUNET_CONFIGURATION_get_value_float  (const struct GNUNET_CONFIGURATION_Handle
+                                       *cfg, const char *section,
+                                       const char *option,
+                                       float *number)
+{
+  struct ConfigEntry *e;
+
+  if (NULL == (e = find_entry (cfg, section, option)))
+    return GNUNET_SYSERR;
+  if (NULL == e->val)
+    return GNUNET_SYSERR;
+  if (1 != SSCANF (e->val, "%f", number))
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
+}
+
+
 
 /**
  * Get a configuration value that should be a relative time.
@@ -1632,7 +1659,7 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
   char *ipath;
 
   ipath = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
-  if (ipath == NULL)
+  if (NULL == ipath)
     return GNUNET_SYSERR;
   baseconfig = NULL;
   GNUNET_asprintf (&baseconfig, "%s%s", ipath, "config.d");
@@ -1644,7 +1671,7 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
     return GNUNET_SYSERR;       /* no configuration at all found */
   }
   GNUNET_free (baseconfig);
-  if ((filename != NULL) &&
+  if ((NULL != filename) &&
       (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, filename)))
   {
     /* specified configuration not found */