summaryrefslogtreecommitdiff
path: root/src/reclaim-attribute
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/reclaim-attribute
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/reclaim-attribute')
-rw-r--r--src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c65
-rw-r--r--src/reclaim-attribute/reclaim_attribute.c301
-rw-r--r--src/reclaim-attribute/reclaim_attribute.h5
3 files changed, 187 insertions, 184 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
diff --git a/src/reclaim-attribute/reclaim_attribute.c b/src/reclaim-attribute/reclaim_attribute.c
index 9ef648708..ac51a6b86 100644
--- a/src/reclaim-attribute/reclaim_attribute.c
+++ b/src/reclaim-attribute/reclaim_attribute.c
@@ -32,7 +32,8 @@
32/** 32/**
33 * Handle for a plugin 33 * Handle for a plugin
34 */ 34 */
35struct Plugin { 35struct Plugin
36{
36 /** 37 /**
37 * Name of the plugin 38 * Name of the plugin
38 */ 39 */
@@ -71,18 +72,18 @@ static int initialized;
71 * @param lib_ret the plugin API pointer 72 * @param lib_ret the plugin API pointer
72 */ 73 */
73static void 74static void
74add_plugin(void *cls, const char *library_name, void *lib_ret) 75add_plugin (void *cls, const char *library_name, void *lib_ret)
75{ 76{
76 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = lib_ret; 77 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = lib_ret;
77 struct Plugin *plugin; 78 struct Plugin *plugin;
78 79
79 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
80 "Loading attribute plugin `%s'\n", 81 "Loading attribute plugin `%s'\n",
81 library_name); 82 library_name);
82 plugin = GNUNET_new(struct Plugin); 83 plugin = GNUNET_new (struct Plugin);
83 plugin->api = api; 84 plugin->api = api;
84 plugin->library_name = GNUNET_strdup(library_name); 85 plugin->library_name = GNUNET_strdup (library_name);
85 GNUNET_array_append(attr_plugins, num_plugins, plugin); 86 GNUNET_array_append (attr_plugins, num_plugins, plugin);
86} 87}
87 88
88 89
@@ -90,15 +91,15 @@ add_plugin(void *cls, const char *library_name, void *lib_ret)
90 * Load plugins 91 * Load plugins
91 */ 92 */
92static void 93static void
93init() 94init ()
94{ 95{
95 if (GNUNET_YES == initialized) 96 if (GNUNET_YES == initialized)
96 return; 97 return;
97 initialized = GNUNET_YES; 98 initialized = GNUNET_YES;
98 GNUNET_PLUGIN_load_all("libgnunet_plugin_reclaim_attribute_", 99 GNUNET_PLUGIN_load_all ("libgnunet_plugin_reclaim_attribute_",
99 NULL, 100 NULL,
100 &add_plugin, 101 &add_plugin,
101 NULL); 102 NULL);
102} 103}
103 104
104 105
@@ -109,20 +110,20 @@ init()
109 * @return corresponding number, UINT32_MAX on error 110 * @return corresponding number, UINT32_MAX on error
110 */ 111 */
111uint32_t 112uint32_t
112GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(const char *typename) 113GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename)
113{ 114{
114 unsigned int i; 115 unsigned int i;
115 struct Plugin *plugin; 116 struct Plugin *plugin;
116 uint32_t ret; 117 uint32_t ret;
117 118
118 init(); 119 init ();
119 for (i = 0; i < num_plugins; i++) 120 for (i = 0; i < num_plugins; i++)
120 { 121 {
121 plugin = attr_plugins[i]; 122 plugin = attr_plugins[i];
122 if (UINT32_MAX != 123 if (UINT32_MAX !=
123 (ret = plugin->api->typename_to_number(plugin->api->cls, typename))) 124 (ret = plugin->api->typename_to_number (plugin->api->cls, typename)))
124 return ret; 125 return ret;
125 } 126 }
126 return UINT32_MAX; 127 return UINT32_MAX;
127} 128}
128 129
@@ -134,20 +135,20 @@ GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(const char *typename)
134 * @return corresponding typestring, NULL on error 135 * @return corresponding typestring, NULL on error
135 */ 136 */
136const char * 137const char *
137GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(uint32_t type) 138GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type)
138{ 139{
139 unsigned int i; 140 unsigned int i;
140 struct Plugin *plugin; 141 struct Plugin *plugin;
141 const char *ret; 142 const char *ret;
142 143
143 init(); 144 init ();
144 for (i = 0; i < num_plugins; i++) 145 for (i = 0; i < num_plugins; i++)
145 { 146 {
146 plugin = attr_plugins[i]; 147 plugin = attr_plugins[i];
147 if (NULL != 148 if (NULL !=
148 (ret = plugin->api->number_to_typename(plugin->api->cls, type))) 149 (ret = plugin->api->number_to_typename (plugin->api->cls, type)))
149 return ret; 150 return ret;
150 } 151 }
151 return NULL; 152 return NULL;
152} 153}
153 154
@@ -163,25 +164,25 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(uint32_t type)
163 * @return #GNUNET_OK on success 164 * @return #GNUNET_OK on success
164 */ 165 */
165int 166int
166GNUNET_RECLAIM_ATTRIBUTE_string_to_value(uint32_t type, 167GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type,
167 const char *s, 168 const char *s,
168 void **data, 169 void **data,
169 size_t *data_size) 170 size_t *data_size)
170{ 171{
171 unsigned int i; 172 unsigned int i;
172 struct Plugin *plugin; 173 struct Plugin *plugin;
173 174
174 init(); 175 init ();
175 for (i = 0; i < num_plugins; i++) 176 for (i = 0; i < num_plugins; i++)
176 { 177 {
177 plugin = attr_plugins[i]; 178 plugin = attr_plugins[i];
178 if (GNUNET_OK == plugin->api->string_to_value(plugin->api->cls, 179 if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
179 type, 180 type,
180 s, 181 s,
181 data, 182 data,
182 data_size)) 183 data_size))
183 return GNUNET_OK; 184 return GNUNET_OK;
184 } 185 }
185 return GNUNET_SYSERR; 186 return GNUNET_SYSERR;
186} 187}
187 188
@@ -195,24 +196,24 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value(uint32_t type,
195 * @return NULL on error, otherwise human-readable representation of the claim 196 * @return NULL on error, otherwise human-readable representation of the claim
196 */ 197 */
197char * 198char *
198GNUNET_RECLAIM_ATTRIBUTE_value_to_string(uint32_t type, 199GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type,
199 const void *data, 200 const void *data,
200 size_t data_size) 201 size_t data_size)
201{ 202{
202 unsigned int i; 203 unsigned int i;
203 struct Plugin *plugin; 204 struct Plugin *plugin;
204 char *ret; 205 char *ret;
205 206
206 init(); 207 init ();
207 for (i = 0; i < num_plugins; i++) 208 for (i = 0; i < num_plugins; i++)
208 { 209 {
209 plugin = attr_plugins[i]; 210 plugin = attr_plugins[i];
210 if (NULL != (ret = plugin->api->value_to_string(plugin->api->cls, 211 if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
211 type, 212 type,
212 data, 213 data,
213 data_size))) 214 data_size)))
214 return ret; 215 return ret;
215 } 216 }
216 return NULL; 217 return NULL;
217} 218}
218 219
@@ -227,29 +228,29 @@ GNUNET_RECLAIM_ATTRIBUTE_value_to_string(uint32_t type,
227 * @return the new attribute 228 * @return the new attribute
228 */ 229 */
229struct GNUNET_RECLAIM_ATTRIBUTE_Claim * 230struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
230GNUNET_RECLAIM_ATTRIBUTE_claim_new(const char *attr_name, 231GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name,
231 uint32_t type, 232 uint32_t type,
232 const void *data, 233 const void *data,
233 size_t data_size) 234 size_t data_size)
234{ 235{
235 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; 236 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
236 char *write_ptr; 237 char *write_ptr;
237 char *attr_name_tmp = GNUNET_strdup(attr_name); 238 char *attr_name_tmp = GNUNET_strdup (attr_name);
238 239
239 GNUNET_STRINGS_utf8_tolower(attr_name, attr_name_tmp); 240 GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
240 241
241 attr = GNUNET_malloc(sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim) + 242 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)
242 strlen(attr_name_tmp) + 1 + data_size); 243 + strlen (attr_name_tmp) + 1 + data_size);
243 attr->type = type; 244 attr->type = type;
244 attr->data_size = data_size; 245 attr->data_size = data_size;
245 attr->version = 0; 246 attr->version = 0;
246 write_ptr = (char *)&attr[1]; 247 write_ptr = (char *) &attr[1];
247 GNUNET_memcpy(write_ptr, attr_name_tmp, strlen(attr_name_tmp) + 1); 248 GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
248 attr->name = write_ptr; 249 attr->name = write_ptr;
249 write_ptr += strlen(attr->name) + 1; 250 write_ptr += strlen (attr->name) + 1;
250 GNUNET_memcpy(write_ptr, data, data_size); 251 GNUNET_memcpy (write_ptr, data, data_size);
251 attr->data = write_ptr; 252 attr->data = write_ptr;
252 GNUNET_free(attr_name_tmp); 253 GNUNET_free (attr_name_tmp);
253 return attr; 254 return attr;
254} 255}
255 256
@@ -263,7 +264,7 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new(const char *attr_name,
263 * @param data_size claim payload size 264 * @param data_size claim payload size
264 */ 265 */
265void 266void
266GNUNET_RECLAIM_ATTRIBUTE_list_add( 267GNUNET_RECLAIM_ATTRIBUTE_list_add (
267 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *claim_list, 268 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *claim_list,
268 const char *attr_name, 269 const char *attr_name,
269 uint32_t type, 270 uint32_t type,
@@ -272,12 +273,12 @@ GNUNET_RECLAIM_ATTRIBUTE_list_add(
272{ 273{
273 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 274 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
274 275
275 le = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 276 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
276 le->claim = 277 le->claim =
277 GNUNET_RECLAIM_ATTRIBUTE_claim_new(attr_name, type, data, data_size); 278 GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size);
278 GNUNET_CONTAINER_DLL_insert(claim_list->list_head, 279 GNUNET_CONTAINER_DLL_insert (claim_list->list_head,
279 claim_list->list_tail, 280 claim_list->list_tail,
280 le); 281 le);
281} 282}
282 283
283 284
@@ -288,14 +289,14 @@ GNUNET_RECLAIM_ATTRIBUTE_list_add(
288 * @return the required buffer size 289 * @return the required buffer size
289 */ 290 */
290size_t 291size_t
291GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size( 292GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (
292 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) 293 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
293{ 294{
294 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 295 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
295 size_t len = 0; 296 size_t len = 0;
296 297
297 for (le = attrs->list_head; NULL != le; le = le->next) 298 for (le = attrs->list_head; NULL != le; le = le->next)
298 len += GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(le->claim); 299 len += GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (le->claim);
299 return len; 300 return len;
300} 301}
301 302
@@ -308,7 +309,7 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(
308 * @return length of serialized data 309 * @return length of serialized data
309 */ 310 */
310size_t 311size_t
311GNUNET_RECLAIM_ATTRIBUTE_list_serialize( 312GNUNET_RECLAIM_ATTRIBUTE_list_serialize (
312 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 313 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
313 char *result) 314 char *result)
314{ 315{
@@ -320,11 +321,11 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize(
320 write_ptr = result; 321 write_ptr = result;
321 total_len = 0; 322 total_len = 0;
322 for (le = attrs->list_head; NULL != le; le = le->next) 323 for (le = attrs->list_head; NULL != le; le = le->next)
323 { 324 {
324 len = GNUNET_RECLAIM_ATTRIBUTE_serialize(le->claim, write_ptr); 325 len = GNUNET_RECLAIM_ATTRIBUTE_serialize (le->claim, write_ptr);
325 total_len += len; 326 total_len += len;
326 write_ptr += len; 327 write_ptr += len;
327 } 328 }
328 return total_len; 329 return total_len;
329} 330}
330 331
@@ -337,7 +338,7 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize(
337 * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller 338 * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
338 */ 339 */
339struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * 340struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
340GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(const char *data, size_t data_size) 341GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size)
341{ 342{
342 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 343 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
343 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 344 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
@@ -347,21 +348,21 @@ GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(const char *data, size_t data_size)
347 if (data_size < sizeof(struct Attribute)) 348 if (data_size < sizeof(struct Attribute))
348 return NULL; 349 return NULL;
349 350
350 attrs = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 351 attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
351 read_ptr = data; 352 read_ptr = data;
352 while (((data + data_size) - read_ptr) >= sizeof(struct Attribute)) 353 while (((data + data_size) - read_ptr) >= sizeof(struct Attribute))
353 { 354 {
354 le = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 355 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
355 le->claim = 356 le->claim =
356 GNUNET_RECLAIM_ATTRIBUTE_deserialize(read_ptr, 357 GNUNET_RECLAIM_ATTRIBUTE_deserialize (read_ptr,
357 data_size - (read_ptr - data)); 358 data_size - (read_ptr - data));
358 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 359 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
359 "Deserialized attribute %s\n", 360 "Deserialized attribute %s\n",
360 le->claim->name); 361 le->claim->name);
361 GNUNET_CONTAINER_DLL_insert(attrs->list_head, attrs->list_tail, le); 362 GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le);
362 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(le->claim); 363 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (le->claim);
363 read_ptr += attr_len; 364 read_ptr += attr_len;
364 } 365 }
365 return attrs; 366 return attrs;
366} 367}
367 368
@@ -372,28 +373,28 @@ GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(const char *data, size_t data_size)
372 * @return copied claim list 373 * @return copied claim list
373 */ 374 */
374struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * 375struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
375GNUNET_RECLAIM_ATTRIBUTE_list_dup( 376GNUNET_RECLAIM_ATTRIBUTE_list_dup (
376 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) 377 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
377{ 378{
378 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 379 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
379 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *result_le; 380 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *result_le;
380 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *result; 381 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *result;
381 382
382 result = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 383 result = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
383 for (le = attrs->list_head; NULL != le; le = le->next) 384 for (le = attrs->list_head; NULL != le; le = le->next)
384 { 385 {
385 result_le = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 386 result_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
386 result_le->claim = 387 result_le->claim =
387 GNUNET_RECLAIM_ATTRIBUTE_claim_new(le->claim->name, 388 GNUNET_RECLAIM_ATTRIBUTE_claim_new (le->claim->name,
388 le->claim->type, 389 le->claim->type,
389 le->claim->data, 390 le->claim->data,
390 le->claim->data_size); 391 le->claim->data_size);
391 result_le->claim->version = le->claim->version; 392 result_le->claim->version = le->claim->version;
392 result_le->claim->id = le->claim->id; 393 result_le->claim->id = le->claim->id;
393 GNUNET_CONTAINER_DLL_insert(result->list_head, 394 GNUNET_CONTAINER_DLL_insert (result->list_head,
394 result->list_tail, 395 result->list_tail,
395 result_le); 396 result_le);
396 } 397 }
397 return result; 398 return result;
398} 399}
399 400
@@ -404,20 +405,20 @@ GNUNET_RECLAIM_ATTRIBUTE_list_dup(
404 * @param attrs list to destroy 405 * @param attrs list to destroy
405 */ 406 */
406void 407void
407GNUNET_RECLAIM_ATTRIBUTE_list_destroy( 408GNUNET_RECLAIM_ATTRIBUTE_list_destroy (
408 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) 409 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
409{ 410{
410 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 411 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
411 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *tmp_le; 412 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *tmp_le;
412 413
413 for (le = attrs->list_head; NULL != le;) 414 for (le = attrs->list_head; NULL != le;)
414 { 415 {
415 GNUNET_free(le->claim); 416 GNUNET_free (le->claim);
416 tmp_le = le; 417 tmp_le = le;
417 le = le->next; 418 le = le->next;
418 GNUNET_free(tmp_le); 419 GNUNET_free (tmp_le);
419 } 420 }
420 GNUNET_free(attrs); 421 GNUNET_free (attrs);
421} 422}
422 423
423 424
@@ -428,10 +429,10 @@ GNUNET_RECLAIM_ATTRIBUTE_list_destroy(
428 * @return the required buffer size 429 * @return the required buffer size
429 */ 430 */
430size_t 431size_t
431GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size( 432GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (
432 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 433 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
433{ 434{
434 return sizeof(struct Attribute) + strlen(attr->name) + attr->data_size; 435 return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size;
435} 436}
436 437
437 438
@@ -443,7 +444,7 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(
443 * @return length of serialized data 444 * @return length of serialized data
444 */ 445 */
445size_t 446size_t
446GNUNET_RECLAIM_ATTRIBUTE_serialize( 447GNUNET_RECLAIM_ATTRIBUTE_serialize (
447 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 448 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
448 char *result) 449 char *result)
449{ 450{
@@ -452,23 +453,23 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize(
452 struct Attribute *attr_ser; 453 struct Attribute *attr_ser;
453 char *write_ptr; 454 char *write_ptr;
454 455
455 attr_ser = (struct Attribute *)result; 456 attr_ser = (struct Attribute *) result;
456 attr_ser->attribute_type = htons(attr->type); 457 attr_ser->attribute_type = htons (attr->type);
457 attr_ser->attribute_version = htonl(attr->version); 458 attr_ser->attribute_version = htonl (attr->version);
458 attr_ser->attribute_id = GNUNET_htonll(attr->id); 459 attr_ser->attribute_id = GNUNET_htonll (attr->id);
459 name_len = strlen(attr->name); 460 name_len = strlen (attr->name);
460 attr_ser->name_len = htons(name_len); 461 attr_ser->name_len = htons (name_len);
461 write_ptr = (char *)&attr_ser[1]; 462 write_ptr = (char *) &attr_ser[1];
462 GNUNET_memcpy(write_ptr, attr->name, name_len); 463 GNUNET_memcpy (write_ptr, attr->name, name_len);
463 write_ptr += name_len; 464 write_ptr += name_len;
464 // TODO plugin-ize 465 // TODO plugin-ize
465 // data_len_ser = plugin->serialize_attribute_value (attr, 466 // data_len_ser = plugin->serialize_attribute_value (attr,
466 // &attr_ser[1]); 467 // &attr_ser[1]);
467 data_len_ser = attr->data_size; 468 data_len_ser = attr->data_size;
468 GNUNET_memcpy(write_ptr, attr->data, attr->data_size); 469 GNUNET_memcpy (write_ptr, attr->data, attr->data_size);
469 attr_ser->data_size = htons(data_len_ser); 470 attr_ser->data_size = htons (data_len_ser);
470 471
471 return sizeof(struct Attribute) + strlen(attr->name) + attr->data_size; 472 return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size;
472} 473}
473 474
474 475
@@ -481,7 +482,7 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize(
481 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller 482 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
482 */ 483 */
483struct GNUNET_RECLAIM_ATTRIBUTE_Claim * 484struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
484GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size) 485GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size)
485{ 486{
486 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; 487 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
487 struct Attribute *attr_ser; 488 struct Attribute *attr_ser;
@@ -492,29 +493,29 @@ GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
492 if (data_size < sizeof(struct Attribute)) 493 if (data_size < sizeof(struct Attribute))
493 return NULL; 494 return NULL;
494 495
495 attr_ser = (struct Attribute *)data; 496 attr_ser = (struct Attribute *) data;
496 data_len = ntohs(attr_ser->data_size); 497 data_len = ntohs (attr_ser->data_size);
497 name_len = ntohs(attr_ser->name_len); 498 name_len = ntohs (attr_ser->name_len);
498 if (data_size < sizeof(struct Attribute) + data_len + name_len) 499 if (data_size < sizeof(struct Attribute) + data_len + name_len)
499 { 500 {
500 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 501 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
501 "Buffer too small to deserialize\n"); 502 "Buffer too small to deserialize\n");
502 return NULL; 503 return NULL;
503 } 504 }
504 attr = GNUNET_malloc(sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim) + 505 attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)
505 data_len + name_len + 1); 506 + data_len + name_len + 1);
506 attr->type = ntohs(attr_ser->attribute_type); 507 attr->type = ntohs (attr_ser->attribute_type);
507 attr->version = ntohl(attr_ser->attribute_version); 508 attr->version = ntohl (attr_ser->attribute_version);
508 attr->id = GNUNET_ntohll(attr_ser->attribute_id); 509 attr->id = GNUNET_ntohll (attr_ser->attribute_id);
509 attr->data_size = data_len; 510 attr->data_size = data_len;
510 511
511 write_ptr = (char *)&attr[1]; 512 write_ptr = (char *) &attr[1];
512 GNUNET_memcpy(write_ptr, &attr_ser[1], name_len); 513 GNUNET_memcpy (write_ptr, &attr_ser[1], name_len);
513 write_ptr[name_len] = '\0'; 514 write_ptr[name_len] = '\0';
514 attr->name = write_ptr; 515 attr->name = write_ptr;
515 516
516 write_ptr += name_len + 1; 517 write_ptr += name_len + 1;
517 GNUNET_memcpy(write_ptr, (char *)&attr_ser[1] + name_len, attr->data_size); 518 GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, attr->data_size);
518 attr->data = write_ptr; 519 attr->data = write_ptr;
519 return attr; 520 return attr;
520} 521}
diff --git a/src/reclaim-attribute/reclaim_attribute.h b/src/reclaim-attribute/reclaim_attribute.h
index 5e87e6e16..d7358847e 100644
--- a/src/reclaim-attribute/reclaim_attribute.h
+++ b/src/reclaim-attribute/reclaim_attribute.h
@@ -31,7 +31,8 @@
31/** 31/**
32 * Serialized claim 32 * Serialized claim
33 */ 33 */
34struct Attribute { 34struct Attribute
35{
35 /** 36 /**
36 * Attribute type 37 * Attribute type
37 */ 38 */
@@ -57,7 +58,7 @@ struct Attribute {
57 */ 58 */
58 uint32_t data_size; 59 uint32_t data_size;
59 60
60 //followed by data_size Attribute value data 61 // followed by data_size Attribute value data
61}; 62};
62 63
63#endif 64#endif