gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r33273 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r33273 - in gnunet/src: include util
Date: Wed, 14 May 2014 10:09:42 +0200

Author: wachs
Date: 2014-05-14 10:09:42 +0200 (Wed, 14 May 2014)
New Revision: 33273

Modified:
   gnunet/src/include/gnunet_configuration_lib.h
   gnunet/src/util/configuration.c
Log:
adding function to read float from cfg


Modified: gnunet/src/include/gnunet_configuration_lib.h
===================================================================
--- gnunet/src/include/gnunet_configuration_lib.h       2014-05-13 22:50:28 UTC 
(rev 33272)
+++ gnunet/src/include/gnunet_configuration_lib.h       2014-05-14 08:09:42 UTC 
(rev 33273)
@@ -268,6 +268,22 @@
 
 
 /**
+ * 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);
+
+
+/**
  * Get a configuration value that should be a relative time.
  *
  * @param cfg configuration to inspect

Modified: gnunet/src/util/configuration.c
===================================================================
--- gnunet/src/util/configuration.c     2014-05-13 22:50:28 UTC (rev 33272)
+++ gnunet/src/util/configuration.c     2014-05-14 08:09:42 UTC (rev 33273)
@@ -879,7 +879,34 @@
   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.
  *




reply via email to

[Prev in Thread] Current Thread [Next in Thread]