summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-27 15:04:09 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-27 15:04:09 +0000
commit92627182d83bb49b07e6f0a78285ca8b3a2fd4d9 (patch)
tree896eac13693a215ebe1446160bb1157f9ea1d2a7 /src
parentecaf813d69580ee1af4bbcaf501caaccf21441db (diff)
add GNUNET_CONFIGURATION_get_data from Taler
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_configuration_lib.h23
-rw-r--r--src/util/configuration.c54
2 files changed, 74 insertions, 3 deletions
diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h
index ac14dde64..ce5679c81 100644
--- a/src/include/gnunet_configuration_lib.h
+++ b/src/include/gnunet_configuration_lib.h
@@ -431,6 +431,29 @@ GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle *
/**
+ * 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,
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 3e6710543..26e65a378 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -920,8 +920,8 @@ GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle
* @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 @@ GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle
/**
+ * 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 @@ GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle
*/
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;