aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c')
-rw-r--r--src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
index c47148c19..8b63fe856 100644
--- a/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
+++ b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
@@ -42,19 +42,19 @@
42 * @return NULL on error, otherwise human-readable representation of the value 42 * @return NULL on error, otherwise human-readable representation of the value
43 */ 43 */
44static char * 44static char *
45gnuid_value_to_string(void *cls, 45gnuid_value_to_string (void *cls,
46 uint32_t type, 46 uint32_t type,
47 const void *data, 47 const void *data,
48 size_t data_size) 48 size_t data_size)
49{ 49{
50 switch (type) 50 switch (type)
51 { 51 {
52 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: 52 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
53 return GNUNET_strndup(data, data_size); 53 return GNUNET_strndup (data, data_size);
54 54
55 default: 55 default:
56 return NULL; 56 return NULL;
57 } 57 }
58} 58}
59 59
60 60
@@ -70,24 +70,24 @@ gnuid_value_to_string(void *cls,
70 * @return #GNUNET_OK on success 70 * @return #GNUNET_OK on success
71 */ 71 */
72static int 72static int
73gnuid_string_to_value(void *cls, 73gnuid_string_to_value (void *cls,
74 uint32_t type, 74 uint32_t type,
75 const char *s, 75 const char *s,
76 void **data, 76 void **data,
77 size_t *data_size) 77 size_t *data_size)
78{ 78{
79 if (NULL == s) 79 if (NULL == s)
80 return GNUNET_SYSERR; 80 return GNUNET_SYSERR;
81 switch (type) 81 switch (type)
82 { 82 {
83 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: 83 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
84 *data = GNUNET_strdup(s); 84 *data = GNUNET_strdup (s);
85 *data_size = strlen(s); 85 *data_size = strlen (s);
86 return GNUNET_OK; 86 return GNUNET_OK;
87 87
88 default: 88 default:
89 return GNUNET_SYSERR; 89 return GNUNET_SYSERR;
90 } 90 }
91} 91}
92 92
93 93
@@ -95,7 +95,8 @@ gnuid_string_to_value(void *cls,
95 * Mapping of attribute type numbers to human-readable 95 * Mapping of attribute type numbers to human-readable
96 * attribute type names. 96 * attribute type names.
97 */ 97 */
98static struct { 98static struct
99{
99 const char *name; 100 const char *name;
100 uint32_t number; 101 uint32_t number;
101} gnuid_name_map[] = { { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING }, 102} gnuid_name_map[] = { { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING },
@@ -110,13 +111,13 @@ static struct {
110 * @return corresponding number, UINT32_MAX on error 111 * @return corresponding number, UINT32_MAX on error
111 */ 112 */
112static uint32_t 113static uint32_t
113gnuid_typename_to_number(void *cls, const char *gnuid_typename) 114gnuid_typename_to_number (void *cls, const char *gnuid_typename)
114{ 115{
115 unsigned int i; 116 unsigned int i;
116 117
117 i = 0; 118 i = 0;
118 while ((NULL != gnuid_name_map[i].name) && 119 while ((NULL != gnuid_name_map[i].name) &&
119 (0 != strcasecmp(gnuid_typename, gnuid_name_map[i].name))) 120 (0 != strcasecmp (gnuid_typename, gnuid_name_map[i].name)))
120 i++; 121 i++;
121 return gnuid_name_map[i].number; 122 return gnuid_name_map[i].number;
122} 123}
@@ -130,7 +131,7 @@ gnuid_typename_to_number(void *cls, const char *gnuid_typename)
130 * @return corresponding typestring, NULL on error 131 * @return corresponding typestring, NULL on error
131 */ 132 */
132static const char * 133static const char *
133gnuid_number_to_typename(void *cls, uint32_t type) 134gnuid_number_to_typename (void *cls, uint32_t type)
134{ 135{
135 unsigned int i; 136 unsigned int i;
136 137
@@ -148,11 +149,11 @@ gnuid_number_to_typename(void *cls, uint32_t type)
148 * @return the exported block API 149 * @return the exported block API
149 */ 150 */
150void * 151void *
151libgnunet_plugin_reclaim_attribute_gnuid_init(void *cls) 152libgnunet_plugin_reclaim_attribute_gnuid_init (void *cls)
152{ 153{
153 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api; 154 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api;
154 155
155 api = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions); 156 api = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions);
156 api->value_to_string = &gnuid_value_to_string; 157 api->value_to_string = &gnuid_value_to_string;
157 api->string_to_value = &gnuid_string_to_value; 158 api->string_to_value = &gnuid_string_to_value;
158 api->typename_to_number = &gnuid_typename_to_number; 159 api->typename_to_number = &gnuid_typename_to_number;
@@ -168,11 +169,11 @@ libgnunet_plugin_reclaim_attribute_gnuid_init(void *cls)
168 * @return NULL 169 * @return NULL
169 */ 170 */
170void * 171void *
171libgnunet_plugin_reclaim_attribute_gnuid_done(void *cls) 172libgnunet_plugin_reclaim_attribute_gnuid_done (void *cls)
172{ 173{
173 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = cls; 174 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = cls;
174 175
175 GNUNET_free(api); 176 GNUNET_free (api);
176 return NULL; 177 return NULL;
177} 178}
178 179