aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r--src/util/configuration.c54
1 files changed, 51 insertions, 3 deletions
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
920 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 920 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
921 */ 921 */
922int 922int
923GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle 923GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle *cfg,
924 *cfg, const char *section, 924 const char *section,
925 const char *option, 925 const char *option,
926 struct GNUNET_TIME_Relative *time) 926 struct GNUNET_TIME_Relative *time)
927{ 927{
@@ -1036,6 +1036,53 @@ GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle
1036 1036
1037 1037
1038/** 1038/**
1039 * Get crockford32-encoded fixed-size binary data from a configuration.
1040 *
1041 * @param cfg configuration to access
1042 * @param section section to access
1043 * @param option option to access
1044 * @param buf where to store the decoded binary result
1045 * @param buf_size exact number of bytes to store in @a buf
1046 * @return #GNUNET_OK on success
1047 * #GNUNET_NO is the value does not exist
1048 * #GNUNET_SYSERR on decoding error
1049 */
1050int
1051GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg,
1052 const char *section,
1053 const char *option,
1054 void *buf,
1055 size_t buf_size)
1056{
1057 char *enc;
1058 int res;
1059 size_t data_size;
1060
1061 if (GNUNET_OK !=
1062 (res = GNUNET_CONFIGURATION_get_value_string (cfg,
1063 section,
1064 option,
1065 &enc)))
1066 return res;
1067 data_size = (strlen (enc) * 5) / 8;
1068 if (data_size != buf_size)
1069 {
1070 GNUNET_free (enc);
1071 return GNUNET_SYSERR;
1072 }
1073 if (GNUNET_OK !=
1074 GNUNET_STRINGS_string_to_data (enc,
1075 strlen (enc),
1076 buf, buf_size))
1077 {
1078 GNUNET_free (enc);
1079 return GNUNET_SYSERR;
1080 }
1081 return GNUNET_OK;
1082}
1083
1084
1085/**
1039 * Test if we have a value for a particular option 1086 * Test if we have a value for a particular option
1040 * 1087 *
1041 * @param cfg configuration to inspect 1088 * @param cfg configuration to inspect
@@ -1045,7 +1092,8 @@ GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle
1045 */ 1092 */
1046int 1093int
1047GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, 1094GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg,
1048 const char *section, const char *option) 1095 const char *section,
1096 const char *option)
1049{ 1097{
1050 struct ConfigEntry *e; 1098 struct ConfigEntry *e;
1051 1099