gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r35020 - in gnunet/src: include util
Date: Tue, 27 Jan 2015 16:04:09 +0100

Author: grothoff
Date: 2015-01-27 16:04:09 +0100 (Tue, 27 Jan 2015)
New Revision: 35020

Modified:
   gnunet/src/include/gnunet_configuration_lib.h
   gnunet/src/util/configuration.c
Log:
add GNUNET_CONFIGURATION_get_data from Taler

Modified: gnunet/src/include/gnunet_configuration_lib.h
===================================================================
--- gnunet/src/include/gnunet_configuration_lib.h       2015-01-26 23:14:50 UTC 
(rev 35019)
+++ gnunet/src/include/gnunet_configuration_lib.h       2015-01-27 15:04:09 UTC 
(rev 35020)
@@ -431,6 +431,29 @@
 
 
 /**
+ * Get Crockford32-encoded fixed-size binary data from a configuration.
+ *
+ * @param cfg configuration to access
+ * @param section section to access
+ * @param option option to access
+ * @param buf where to store the decoded binary result
+ * @param buf_size exact number of bytes to store in @a buf
+ * @return #GNUNET_OK on success
+ *         #GNUNET_NO is the value does not exist
+ *         #GNUNET_SYSERR on decoding error
+ */
+int
+GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                               const char *section,
+                               const char *option,
+                               void *buf,
+                               size_t buf_size);
+
+
+
+
+
+/**
  * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
  * where either in the "PATHS" section or the environtment "FOO" is
  * set to "DIRECTORY".  We also support default expansion,

Modified: gnunet/src/util/configuration.c
===================================================================
--- gnunet/src/util/configuration.c     2015-01-26 23:14:50 UTC (rev 35019)
+++ gnunet/src/util/configuration.c     2015-01-27 15:04:09 UTC (rev 35020)
@@ -920,8 +920,8 @@
  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  */
 int
-GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle
-                                     *cfg, const char *section,
+GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle 
*cfg,
+                                     const char *section,
                                      const char *option,
                                      struct GNUNET_TIME_Relative *time)
 {
@@ -1036,6 +1036,53 @@
 
 
 /**
+ * Get crockford32-encoded fixed-size binary data from a configuration.
+ *
+ * @param cfg configuration to access
+ * @param section section to access
+ * @param option option to access
+ * @param buf where to store the decoded binary result
+ * @param buf_size exact number of bytes to store in @a buf
+ * @return #GNUNET_OK on success
+ *         #GNUNET_NO is the value does not exist
+ *         #GNUNET_SYSERR on decoding error
+ */
+int
+GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                               const char *section,
+                               const char *option,
+                               void *buf,
+                               size_t buf_size)
+{
+  char *enc;
+  int res;
+  size_t data_size;
+
+  if (GNUNET_OK !=
+      (res = GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                    section,
+                                                    option,
+                                                    &enc)))
+    return res;
+  data_size = (strlen (enc) * 5) / 8;
+  if (data_size != buf_size)
+  {
+    GNUNET_free (enc);
+    return GNUNET_SYSERR;
+  }
+  if (GNUNET_OK !=
+      GNUNET_STRINGS_string_to_data (enc,
+                                     strlen (enc),
+                                     buf, buf_size))
+  {
+    GNUNET_free (enc);
+    return GNUNET_SYSERR;
+  }
+  return GNUNET_OK;
+}
+
+
+/**
  * Test if we have a value for a particular option
  *
  * @param cfg configuration to inspect
@@ -1045,7 +1092,8 @@
  */
 int
 GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                 const char *section, const char *option)
+                                 const char *section,
+                                 const char *option)
 {
   struct ConfigEntry *e;
 




reply via email to

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