aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim
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
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/reclaim')
-rw-r--r--src/reclaim/gnunet-reclaim.c708
-rw-r--r--src/reclaim/gnunet-service-reclaim.c1191
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c1115
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.h43
-rw-r--r--src/reclaim/json_reclaim.c209
-rw-r--r--src/reclaim/json_reclaim.h4
-rw-r--r--src/reclaim/oidc_helper.h44
-rw-r--r--src/reclaim/plugin_gnsrecord_reclaim.c91
-rw-r--r--src/reclaim/plugin_rest_reclaim.c917
-rw-r--r--src/reclaim/reclaim.h48
-rw-r--r--src/reclaim/reclaim_api.c568
11 files changed, 2493 insertions, 2445 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index 5160aef7f..c5f0ed4fa 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -168,176 +168,176 @@ static char *attr_delete;
168static struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr_to_delete; 168static struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr_to_delete;
169 169
170static void 170static void
171do_cleanup(void *cls) 171do_cleanup (void *cls)
172{ 172{
173 cleanup_task = NULL; 173 cleanup_task = NULL;
174 if (NULL != timeout) 174 if (NULL != timeout)
175 GNUNET_SCHEDULER_cancel(timeout); 175 GNUNET_SCHEDULER_cancel (timeout);
176 if (NULL != reclaim_op) 176 if (NULL != reclaim_op)
177 GNUNET_RECLAIM_cancel(reclaim_op); 177 GNUNET_RECLAIM_cancel (reclaim_op);
178 if (NULL != attr_iterator) 178 if (NULL != attr_iterator)
179 GNUNET_RECLAIM_get_attributes_stop(attr_iterator); 179 GNUNET_RECLAIM_get_attributes_stop (attr_iterator);
180 if (NULL != ticket_iterator) 180 if (NULL != ticket_iterator)
181 GNUNET_RECLAIM_ticket_iteration_stop(ticket_iterator); 181 GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator);
182 if (NULL != reclaim_handle) 182 if (NULL != reclaim_handle)
183 GNUNET_RECLAIM_disconnect(reclaim_handle); 183 GNUNET_RECLAIM_disconnect (reclaim_handle);
184 if (NULL != identity_handle) 184 if (NULL != identity_handle)
185 GNUNET_IDENTITY_disconnect(identity_handle); 185 GNUNET_IDENTITY_disconnect (identity_handle);
186 if (NULL != abe_key) 186 if (NULL != abe_key)
187 GNUNET_free(abe_key); 187 GNUNET_free (abe_key);
188 if (NULL != attr_list) 188 if (NULL != attr_list)
189 GNUNET_free(attr_list); 189 GNUNET_free (attr_list);
190 if (NULL != attr_to_delete) 190 if (NULL != attr_to_delete)
191 GNUNET_free(attr_to_delete); 191 GNUNET_free (attr_to_delete);
192} 192}
193 193
194static void 194static void
195ticket_issue_cb(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) 195ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
196{ 196{
197 char *ticket_str; 197 char *ticket_str;
198 198
199 reclaim_op = NULL; 199 reclaim_op = NULL;
200 if (NULL != ticket) 200 if (NULL != ticket)
201 { 201 {
202 ticket_str = 202 ticket_str =
203 GNUNET_STRINGS_data_to_string_alloc(ticket, 203 GNUNET_STRINGS_data_to_string_alloc (ticket,
204 sizeof( 204 sizeof(
205 struct GNUNET_RECLAIM_Ticket)); 205 struct GNUNET_RECLAIM_Ticket));
206 printf("%s\n", ticket_str); 206 printf ("%s\n", ticket_str);
207 GNUNET_free(ticket_str); 207 GNUNET_free (ticket_str);
208 } 208 }
209 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 209 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
210} 210}
211 211
212static void 212static void
213store_attr_cont(void *cls, int32_t success, const char *emsg) 213store_attr_cont (void *cls, int32_t success, const char *emsg)
214{ 214{
215 reclaim_op = NULL; 215 reclaim_op = NULL;
216 if (GNUNET_SYSERR == success) 216 if (GNUNET_SYSERR == success)
217 { 217 {
218 fprintf(stderr, "%s\n", emsg); 218 fprintf (stderr, "%s\n", emsg);
219 } 219 }
220 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 220 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
221} 221}
222 222
223static void 223static void
224process_attrs(void *cls, 224process_attrs (void *cls,
225 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 225 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
226 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 226 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
227{ 227{
228 char *value_str; 228 char *value_str;
229 char *id; 229 char *id;
230 const char *attr_type; 230 const char *attr_type;
231 231
232 if (NULL == identity) 232 if (NULL == identity)
233 { 233 {
234 reclaim_op = NULL; 234 reclaim_op = NULL;
235 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 235 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
236 return; 236 return;
237 } 237 }
238 if (NULL == attr) 238 if (NULL == attr)
239 { 239 {
240 ret = 1; 240 ret = 1;
241 return; 241 return;
242 } 242 }
243 value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string(attr->type, 243 value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type,
244 attr->data, 244 attr->data,
245 attr->data_size); 245 attr->data_size);
246 attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(attr->type); 246 attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
247 id = GNUNET_STRINGS_data_to_string_alloc(&attr->id, sizeof(uint64_t)); 247 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t));
248 fprintf(stdout, 248 fprintf (stdout,
249 "Name: %s; Value: %s (%s); Version %u; ID: %s\n", 249 "Name: %s; Value: %s (%s); Version %u; ID: %s\n",
250 attr->name, 250 attr->name,
251 value_str, 251 value_str,
252 attr_type, 252 attr_type,
253 attr->version, 253 attr->version,
254 id); 254 id);
255 GNUNET_free(id); 255 GNUNET_free (id);
256} 256}
257 257
258static void 258static void
259ticket_iter_err(void *cls) 259ticket_iter_err (void *cls)
260{ 260{
261 ticket_iterator = NULL; 261 ticket_iterator = NULL;
262 fprintf(stderr, "Failed to iterate over tickets\n"); 262 fprintf (stderr, "Failed to iterate over tickets\n");
263 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 263 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
264} 264}
265 265
266static void 266static void
267ticket_iter_fin(void *cls) 267ticket_iter_fin (void *cls)
268{ 268{
269 ticket_iterator = NULL; 269 ticket_iterator = NULL;
270 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 270 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
271} 271}
272 272
273static void 273static void
274ticket_iter(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) 274ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
275{ 275{
276 char *aud; 276 char *aud;
277 char *ref; 277 char *ref;
278 char *tkt; 278 char *tkt;
279 279
280 aud = 280 aud =
281 GNUNET_STRINGS_data_to_string_alloc(&ticket->audience, 281 GNUNET_STRINGS_data_to_string_alloc (&ticket->audience,
282 sizeof(struct 282 sizeof(struct
283 GNUNET_CRYPTO_EcdsaPublicKey)); 283 GNUNET_CRYPTO_EcdsaPublicKey));
284 ref = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t)); 284 ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
285 tkt = 285 tkt =
286 GNUNET_STRINGS_data_to_string_alloc(ticket, 286 GNUNET_STRINGS_data_to_string_alloc (ticket,
287 sizeof(struct GNUNET_RECLAIM_Ticket)); 287 sizeof(struct GNUNET_RECLAIM_Ticket));
288 fprintf(stdout, "Ticket: %s | ID: %s | Audience: %s\n", tkt, ref, aud); 288 fprintf (stdout, "Ticket: %s | ID: %s | Audience: %s\n", tkt, ref, aud);
289 GNUNET_free(aud); 289 GNUNET_free (aud);
290 GNUNET_free(ref); 290 GNUNET_free (ref);
291 GNUNET_free(tkt); 291 GNUNET_free (tkt);
292 GNUNET_RECLAIM_ticket_iteration_next(ticket_iterator); 292 GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
293} 293}
294 294
295static void 295static void
296iter_error(void *cls) 296iter_error (void *cls)
297{ 297{
298 attr_iterator = NULL; 298 attr_iterator = NULL;
299 fprintf(stderr, "Failed to iterate over attributes\n"); 299 fprintf (stderr, "Failed to iterate over attributes\n");
300 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 300 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
301} 301}
302 302
303static void 303static void
304timeout_task(void *cls) 304timeout_task (void *cls)
305{ 305{
306 timeout = NULL; 306 timeout = NULL;
307 ret = 1; 307 ret = 1;
308 fprintf(stderr, "Timeout\n"); 308 fprintf (stderr, "Timeout\n");
309 if (NULL == cleanup_task) 309 if (NULL == cleanup_task)
310 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 310 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
311} 311}
312 312
313static void 313static void
314process_rvk(void *cls, int success, const char *msg) 314process_rvk (void *cls, int success, const char *msg)
315{ 315{
316 reclaim_op = NULL; 316 reclaim_op = NULL;
317 if (GNUNET_OK != success) 317 if (GNUNET_OK != success)
318 { 318 {
319 fprintf(stderr, "Revocation failed.\n"); 319 fprintf (stderr, "Revocation failed.\n");
320 ret = 1; 320 ret = 1;
321 } 321 }
322 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 322 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
323} 323}
324 324
325 325
326static void 326static void
327process_delete(void *cls, int success, const char *msg) 327process_delete (void *cls, int success, const char *msg)
328{ 328{
329 reclaim_op = NULL; 329 reclaim_op = NULL;
330 if (GNUNET_OK != success) 330 if (GNUNET_OK != success)
331 { 331 {
332 fprintf(stderr, "Deletion failed.\n"); 332 fprintf (stderr, "Deletion failed.\n");
333 ret = 1; 333 ret = 1;
334 } 334 }
335 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 335 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
336} 336}
337 337
338 338
339static void 339static void
340iter_finished(void *cls) 340iter_finished (void *cls)
341{ 341{
342 char *data; 342 char *data;
343 size_t data_size; 343 size_t data_size;
@@ -345,97 +345,97 @@ iter_finished(void *cls)
345 345
346 attr_iterator = NULL; 346 attr_iterator = NULL;
347 if (list) 347 if (list)
348 { 348 {
349 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 349 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
350 return; 350 return;
351 } 351 }
352 352
353 if (issue_attrs) 353 if (issue_attrs)
354 { 354 {
355 reclaim_op = GNUNET_RECLAIM_ticket_issue(reclaim_handle, 355 reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle,
356 pkey, 356 pkey,
357 &rp_key, 357 &rp_key,
358 attr_list, 358 attr_list,
359 &ticket_issue_cb, 359 &ticket_issue_cb,
360 NULL); 360 NULL);
361 return; 361 return;
362 } 362 }
363 if (consume_ticket) 363 if (consume_ticket)
364 { 364 {
365 reclaim_op = GNUNET_RECLAIM_ticket_consume(reclaim_handle, 365 reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle,
366 pkey,
367 &ticket,
368 &process_attrs,
369 NULL);
370 timeout = GNUNET_SCHEDULER_add_delayed(
371 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10),
372 &timeout_task,
373 NULL);
374 return;
375 }
376 if (revoke_ticket)
377 {
378 reclaim_op = GNUNET_RECLAIM_ticket_revoke(reclaim_handle,
379 pkey, 366 pkey,
380 &ticket, 367 &ticket,
381 &process_rvk, 368 &process_attrs,
382 NULL); 369 NULL);
383 return; 370 timeout = GNUNET_SCHEDULER_add_delayed (
384 } 371 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
372 &timeout_task,
373 NULL);
374 return;
375 }
376 if (revoke_ticket)
377 {
378 reclaim_op = GNUNET_RECLAIM_ticket_revoke (reclaim_handle,
379 pkey,
380 &ticket,
381 &process_rvk,
382 NULL);
383 return;
384 }
385 if (attr_delete) 385 if (attr_delete)
386 {
387 if (NULL == attr_to_delete)
386 { 388 {
387 if (NULL == attr_to_delete) 389 fprintf (stdout, "No such attribute ``%s''\n", attr_delete);
388 {
389 fprintf(stdout, "No such attribute ``%s''\n", attr_delete);
390 return;
391 }
392 reclaim_op = GNUNET_RECLAIM_attribute_delete(reclaim_handle,
393 pkey,
394 attr_to_delete,
395 &process_delete,
396 NULL);
397 return; 390 return;
398 } 391 }
392 reclaim_op = GNUNET_RECLAIM_attribute_delete (reclaim_handle,
393 pkey,
394 attr_to_delete,
395 &process_delete,
396 NULL);
397 return;
398 }
399 if (attr_name) 399 if (attr_name)
400 { 400 {
401 if (NULL == type_str) 401 if (NULL == type_str)
402 type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; 402 type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING;
403 else 403 else
404 type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(type_str); 404 type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str);
405 405
406 GNUNET_assert(GNUNET_SYSERR != 406 GNUNET_assert (GNUNET_SYSERR !=
407 GNUNET_RECLAIM_ATTRIBUTE_string_to_value(type, 407 GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,
408 attr_value, 408 attr_value,
409 (void **)&data, 409 (void **) &data,
410 &data_size)); 410 &data_size));
411 if (NULL != claim) 411 if (NULL != claim)
412 { 412 {
413 claim->type = type; 413 claim->type = type;
414 claim->data = data; 414 claim->data = data;
415 claim->data_size = data_size; 415 claim->data_size = data_size;
416 }
417 else
418 {
419 claim =
420 GNUNET_RECLAIM_ATTRIBUTE_claim_new(attr_name, type, data, data_size);
421 }
422 reclaim_op = GNUNET_RECLAIM_attribute_store(reclaim_handle,
423 pkey,
424 claim,
425 &exp_interval,
426 &store_attr_cont,
427 NULL);
428 GNUNET_free(data);
429 GNUNET_free(claim);
430 return;
431 } 416 }
432 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 417 else
418 {
419 claim =
420 GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size);
421 }
422 reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle,
423 pkey,
424 claim,
425 &exp_interval,
426 &store_attr_cont,
427 NULL);
428 GNUNET_free (data);
429 GNUNET_free (claim);
430 return;
431 }
432 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
433} 433}
434 434
435static void 435static void
436iter_cb(void *cls, 436iter_cb (void *cls,
437 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 437 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
438 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 438 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
439{ 439{
440 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 440 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
441 char *attrs_tmp; 441 char *attrs_tmp;
@@ -445,260 +445,260 @@ iter_cb(void *cls,
445 const char *attr_type; 445 const char *attr_type;
446 446
447 if ((NULL != attr_name) && (NULL != claim)) 447 if ((NULL != attr_name) && (NULL != claim))
448 {
449 if (0 == strcasecmp (attr_name, attr->name))
448 { 450 {
449 if (0 == strcasecmp(attr_name, attr->name)) 451 claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
450 { 452 attr->type,
451 claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new(attr->name, 453 attr->data,
452 attr->type, 454 attr->data_size);
453 attr->data,
454 attr->data_size);
455 }
456 } 455 }
456 }
457 else if (issue_attrs) 457 else if (issue_attrs)
458 {
459 attrs_tmp = GNUNET_strdup (issue_attrs);
460 attr_str = strtok (attrs_tmp, ",");
461 while (NULL != attr_str)
458 { 462 {
459 attrs_tmp = GNUNET_strdup(issue_attrs); 463 if (0 != strcasecmp (attr_str, attr->name))
460 attr_str = strtok(attrs_tmp, ","); 464 {
461 while (NULL != attr_str) 465 attr_str = strtok (NULL, ",");
462 { 466 continue;
463 if (0 != strcasecmp(attr_str, attr->name)) 467 }
464 { 468 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
465 attr_str = strtok(NULL, ","); 469 le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
466 continue; 470 attr->type,
467 } 471 attr->data,
468 le = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 472 attr->data_size);
469 le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new(attr->name, 473 le->claim->version = attr->version;
470 attr->type, 474 le->claim->id = attr->id;
471 attr->data, 475 GNUNET_CONTAINER_DLL_insert (attr_list->list_head,
472 attr->data_size); 476 attr_list->list_tail,
473 le->claim->version = attr->version; 477 le);
474 le->claim->id = attr->id; 478 break;
475 GNUNET_CONTAINER_DLL_insert(attr_list->list_head,
476 attr_list->list_tail,
477 le);
478 break;
479 }
480 GNUNET_free(attrs_tmp);
481 } 479 }
480 GNUNET_free (attrs_tmp);
481 }
482 else if (attr_delete && (NULL == attr_to_delete)) 482 else if (attr_delete && (NULL == attr_to_delete))
483 {
484 label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t));
485 if (0 == strcasecmp (attr_delete, label))
483 { 486 {
484 label = GNUNET_STRINGS_data_to_string_alloc(&attr->id, sizeof(uint64_t)); 487 attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
485 if (0 == strcasecmp(attr_delete, label)) 488 attr->type,
486 { 489 attr->data,
487 attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new(attr->name, 490 attr->data_size);
488 attr->type, 491 attr_to_delete->id = attr->id;
489 attr->data,
490 attr->data_size);
491 attr_to_delete->id = attr->id;
492 }
493 GNUNET_free(label);
494 } 492 }
493 GNUNET_free (label);
494 }
495 else if (list) 495 else if (list)
496 { 496 {
497 attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string(attr->type, 497 attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type,
498 attr->data, 498 attr->data,
499 attr->data_size); 499 attr->data_size);
500 attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(attr->type); 500 attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
501 id = GNUNET_STRINGS_data_to_string_alloc(&attr->id, sizeof(uint64_t)); 501 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t));
502 fprintf(stdout, 502 fprintf (stdout,
503 "Name: %s; Value: %s (%s); Version %u; ID: %s\n", 503 "Name: %s; Value: %s (%s); Version %u; ID: %s\n",
504 attr->name, 504 attr->name,
505 attr_str, 505 attr_str,
506 attr_type, 506 attr_type,
507 attr->version, 507 attr->version,
508 id); 508 id);
509 GNUNET_free(id); 509 GNUNET_free (id);
510 } 510 }
511 GNUNET_RECLAIM_get_attributes_next(attr_iterator); 511 GNUNET_RECLAIM_get_attributes_next (attr_iterator);
512} 512}
513 513
514static void 514static void
515start_process() 515start_process ()
516{ 516{
517 if (NULL == pkey) 517 if (NULL == pkey)
518 { 518 {
519 fprintf(stderr, "Ego %s not found\n", ego_name); 519 fprintf (stderr, "Ego %s not found\n", ego_name);
520 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 520 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
521 return; 521 return;
522 } 522 }
523 523
524 if (list_tickets) 524 if (list_tickets)
525 { 525 {
526 ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start(reclaim_handle, 526 ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle,
527 pkey, 527 pkey,
528 &ticket_iter_err, 528 &ticket_iter_err,
529 NULL, 529 NULL,
530 &ticket_iter, 530 &ticket_iter,
531 NULL, 531 NULL,
532 &ticket_iter_fin, 532 &ticket_iter_fin,
533 NULL); 533 NULL);
534 return; 534 return;
535 } 535 }
536 536
537 if ((NULL != rp) && 537 if ((NULL != rp) &&
538 GNUNET_OK != 538 (GNUNET_OK !=
539 GNUNET_CRYPTO_ecdsa_public_key_from_string(rp, strlen(rp), &rp_key)) 539 GNUNET_CRYPTO_ecdsa_public_key_from_string (rp, strlen (rp), &rp_key)) )
540 { 540 {
541 fprintf(stderr, "%s is not a public key!\n", rp); 541 fprintf (stderr, "%s is not a public key!\n", rp);
542 cleanup_task = GNUNET_SCHEDULER_add_now(&do_cleanup, NULL); 542 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
543 return; 543 return;
544 } 544 }
545 if (NULL != consume_ticket) 545 if (NULL != consume_ticket)
546 GNUNET_STRINGS_string_to_data(consume_ticket, 546 GNUNET_STRINGS_string_to_data (consume_ticket,
547 strlen(consume_ticket), 547 strlen (consume_ticket),
548 &ticket, 548 &ticket,
549 sizeof(struct GNUNET_RECLAIM_Ticket)); 549 sizeof(struct GNUNET_RECLAIM_Ticket));
550 if (NULL != revoke_ticket) 550 if (NULL != revoke_ticket)
551 GNUNET_STRINGS_string_to_data(revoke_ticket, 551 GNUNET_STRINGS_string_to_data (revoke_ticket,
552 strlen(revoke_ticket), 552 strlen (revoke_ticket),
553 &ticket, 553 &ticket,
554 sizeof(struct GNUNET_RECLAIM_Ticket)); 554 sizeof(struct GNUNET_RECLAIM_Ticket));
555 555
556 attr_list = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 556 attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
557 claim = NULL; 557 claim = NULL;
558 attr_iterator = GNUNET_RECLAIM_get_attributes_start(reclaim_handle, 558 attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
559 pkey, 559 pkey,
560 &iter_error, 560 &iter_error,
561 NULL, 561 NULL,
562 &iter_cb, 562 &iter_cb,
563 NULL, 563 NULL,
564 &iter_finished, 564 &iter_finished,
565 NULL); 565 NULL);
566} 566}
567 567
568static int init = GNUNET_YES; 568static int init = GNUNET_YES;
569 569
570static void 570static void
571ego_cb(void *cls, 571ego_cb (void *cls,
572 struct GNUNET_IDENTITY_Ego *ego, 572 struct GNUNET_IDENTITY_Ego *ego,
573 void **ctx, 573 void **ctx,
574 const char *name) 574 const char *name)
575{ 575{
576 if (NULL == name) 576 if (NULL == name)
577 {
578 if (GNUNET_YES == init)
577 { 579 {
578 if (GNUNET_YES == init) 580 init = GNUNET_NO;
579 { 581 start_process ();
580 init = GNUNET_NO;
581 start_process();
582 }
583 return;
584 } 582 }
585 if (0 != strcmp(name, ego_name))
586 return; 583 return;
587 pkey = GNUNET_IDENTITY_ego_get_private_key(ego); 584 }
585 if (0 != strcmp (name, ego_name))
586 return;
587 pkey = GNUNET_IDENTITY_ego_get_private_key (ego);
588} 588}
589 589
590 590
591static void 591static void
592run(void *cls, 592run (void *cls,
593 char *const *args, 593 char *const *args,
594 const char *cfgfile, 594 const char *cfgfile,
595 const struct GNUNET_CONFIGURATION_Handle *c) 595 const struct GNUNET_CONFIGURATION_Handle *c)
596{ 596{
597 ret = 0; 597 ret = 0;
598 if (NULL == ego_name) 598 if (NULL == ego_name)
599 { 599 {
600 ret = 1; 600 ret = 1;
601 fprintf(stderr, _("Ego is required\n")); 601 fprintf (stderr, _ ("Ego is required\n"));
602 return; 602 return;
603 } 603 }
604 604
605 if ((NULL == attr_value) && (NULL != attr_name)) 605 if ((NULL == attr_value) && (NULL != attr_name))
606 { 606 {
607 ret = 1; 607 ret = 1;
608 fprintf(stderr, _("Attribute value missing!\n")); 608 fprintf (stderr, _ ("Attribute value missing!\n"));
609 return; 609 return;
610 } 610 }
611 611
612 if ((NULL == rp) && (NULL != issue_attrs)) 612 if ((NULL == rp) && (NULL != issue_attrs))
613 { 613 {
614 ret = 1; 614 ret = 1;
615 fprintf(stderr, _("Requesting party key is required!\n")); 615 fprintf (stderr, _ ("Requesting party key is required!\n"));
616 return; 616 return;
617 } 617 }
618 618
619 reclaim_handle = GNUNET_RECLAIM_connect(c); 619 reclaim_handle = GNUNET_RECLAIM_connect (c);
620 // Get Ego 620 // Get Ego
621 identity_handle = GNUNET_IDENTITY_connect(c, &ego_cb, NULL); 621 identity_handle = GNUNET_IDENTITY_connect (c, &ego_cb, NULL);
622} 622}
623 623
624 624
625int 625int
626main(int argc, char *const argv[]) 626main (int argc, char *const argv[])
627{ 627{
628 exp_interval = GNUNET_TIME_UNIT_HOURS; 628 exp_interval = GNUNET_TIME_UNIT_HOURS;
629 struct GNUNET_GETOPT_CommandLineOption options[] = { 629 struct GNUNET_GETOPT_CommandLineOption options[] = {
630 GNUNET_GETOPT_option_string('a', 630 GNUNET_GETOPT_option_string ('a',
631 "add", 631 "add",
632 "NAME", 632 "NAME",
633 gettext_noop("Add an attribute NAME"), 633 gettext_noop ("Add an attribute NAME"),
634 &attr_name), 634 &attr_name),
635 GNUNET_GETOPT_option_string('d', 635 GNUNET_GETOPT_option_string ('d',
636 "delete", 636 "delete",
637 "ID", 637 "ID",
638 gettext_noop("Delete the attribute with ID"), 638 gettext_noop ("Delete the attribute with ID"),
639 &attr_delete), 639 &attr_delete),
640 GNUNET_GETOPT_option_string('V', 640 GNUNET_GETOPT_option_string ('V',
641 "value", 641 "value",
642 "VALUE", 642 "VALUE",
643 gettext_noop("The attribute VALUE"), 643 gettext_noop ("The attribute VALUE"),
644 &attr_value), 644 &attr_value),
645 GNUNET_GETOPT_option_string('e', 645 GNUNET_GETOPT_option_string ('e',
646 "ego", 646 "ego",
647 "EGO", 647 "EGO",
648 gettext_noop("The EGO to use"), 648 gettext_noop ("The EGO to use"),
649 &ego_name), 649 &ego_name),
650 GNUNET_GETOPT_option_string('r', 650 GNUNET_GETOPT_option_string ('r',
651 "rp", 651 "rp",
652 "RP", 652 "RP",
653 gettext_noop( 653 gettext_noop (
654 "Specify the relying party for issue"), 654 "Specify the relying party for issue"),
655 &rp), 655 &rp),
656 GNUNET_GETOPT_option_flag('D', 656 GNUNET_GETOPT_option_flag ('D',
657 "dump", 657 "dump",
658 gettext_noop("List attributes for EGO"), 658 gettext_noop ("List attributes for EGO"),
659 &list), 659 &list),
660 GNUNET_GETOPT_option_string( 660 GNUNET_GETOPT_option_string (
661 'i', 661 'i',
662 "issue", 662 "issue",
663 "A1,A2,...", 663 "A1,A2,...",
664 gettext_noop( 664 gettext_noop (
665 "Issue a ticket for a set of attributes separated by comma"), 665 "Issue a ticket for a set of attributes separated by comma"),
666 &issue_attrs), 666 &issue_attrs),
667 GNUNET_GETOPT_option_string('C', 667 GNUNET_GETOPT_option_string ('C',
668 "consume", 668 "consume",
669 "TICKET", 669 "TICKET",
670 gettext_noop("Consume a ticket"), 670 gettext_noop ("Consume a ticket"),
671 &consume_ticket), 671 &consume_ticket),
672 GNUNET_GETOPT_option_string('R', 672 GNUNET_GETOPT_option_string ('R',
673 "revoke", 673 "revoke",
674 "TICKET", 674 "TICKET",
675 gettext_noop("Revoke a ticket"), 675 gettext_noop ("Revoke a ticket"),
676 &revoke_ticket), 676 &revoke_ticket),
677 GNUNET_GETOPT_option_string('t', 677 GNUNET_GETOPT_option_string ('t',
678 "type", 678 "type",
679 "TYPE", 679 "TYPE",
680 gettext_noop("Type of attribute"), 680 gettext_noop ("Type of attribute"),
681 &type_str), 681 &type_str),
682 GNUNET_GETOPT_option_flag('T', 682 GNUNET_GETOPT_option_flag ('T',
683 "tickets", 683 "tickets",
684 gettext_noop("List tickets of ego"), 684 gettext_noop ("List tickets of ego"),
685 &list_tickets), 685 &list_tickets),
686 GNUNET_GETOPT_option_relative_time('E', 686 GNUNET_GETOPT_option_relative_time ('E',
687 "expiration", 687 "expiration",
688 "INTERVAL", 688 "INTERVAL",
689 gettext_noop( 689 gettext_noop (
690 "Expiration interval of the attribute"), 690 "Expiration interval of the attribute"),
691 &exp_interval), 691 &exp_interval),
692 692
693 GNUNET_GETOPT_OPTION_END 693 GNUNET_GETOPT_OPTION_END
694 }; 694 };
695 if (GNUNET_OK != GNUNET_PROGRAM_run(argc, 695 if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
696 argv, 696 argv,
697 "gnunet-reclaim", 697 "gnunet-reclaim",
698 _("re:claimID command line tool"), 698 _ ("re:claimID command line tool"),
699 options, 699 options,
700 &run, 700 &run,
701 NULL)) 701 NULL))
702 return 1; 702 return 1;
703 else 703 else
704 return ret; 704 return ret;
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 23a5db1ed..440656343 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -58,7 +58,8 @@ struct IdpClient;
58/** 58/**
59 * A ticket iteration operation. 59 * A ticket iteration operation.
60 */ 60 */
61struct TicketIteration { 61struct TicketIteration
62{
62 /** 63 /**
63 * DLL 64 * DLL
64 */ 65 */
@@ -89,7 +90,8 @@ struct TicketIteration {
89/** 90/**
90 * An attribute iteration operation. 91 * An attribute iteration operation.
91 */ 92 */
92struct AttributeIterator { 93struct AttributeIterator
94{
93 /** 95 /**
94 * Next element in the DLL 96 * Next element in the DLL
95 */ 97 */
@@ -125,7 +127,8 @@ struct AttributeIterator {
125/** 127/**
126 * An idp client 128 * An idp client
127 */ 129 */
128struct IdpClient { 130struct IdpClient
131{
129 /** 132 /**
130 * DLL 133 * DLL
131 */ 134 */
@@ -224,7 +227,8 @@ struct IdpClient {
224/** 227/**
225 * Handle for attribute deletion request 228 * Handle for attribute deletion request
226 */ 229 */
227struct AttributeDeleteHandle { 230struct AttributeDeleteHandle
231{
228 /** 232 /**
229 * DLL 233 * DLL
230 */ 234 */
@@ -286,7 +290,8 @@ struct AttributeDeleteHandle {
286/** 290/**
287 * Handle for attribute store request 291 * Handle for attribute store request
288 */ 292 */
289struct AttributeStoreHandle { 293struct AttributeStoreHandle
294{
290 /** 295 /**
291 * DLL 296 * DLL
292 */ 297 */
@@ -337,7 +342,8 @@ struct AttributeStoreHandle {
337/** 342/**
338 * Handle for ticket consume request 343 * Handle for ticket consume request
339 */ 344 */
340struct ConsumeTicketOperation { 345struct ConsumeTicketOperation
346{
341 /** 347 /**
342 * DLL 348 * DLL
343 */ 349 */
@@ -368,7 +374,8 @@ struct ConsumeTicketOperation {
368/** 374/**
369 * Ticket revocation request handle 375 * Ticket revocation request handle
370 */ 376 */
371struct TicketRevocationOperation { 377struct TicketRevocationOperation
378{
372 /** 379 /**
373 * DLL 380 * DLL
374 */ 381 */
@@ -399,7 +406,8 @@ struct TicketRevocationOperation {
399/** 406/**
400 * Ticket issue operation handle 407 * Ticket issue operation handle
401 */ 408 */
402struct TicketIssueOperation { 409struct TicketIssueOperation
410{
403 /** 411 /**
404 * DLL 412 * DLL
405 */ 413 */
@@ -439,30 +447,30 @@ static struct IdpClient *client_list_tail = NULL;
439 * @param adh the attribute to cleanup 447 * @param adh the attribute to cleanup
440 */ 448 */
441static void 449static void
442cleanup_adh(struct AttributeDeleteHandle *adh) 450cleanup_adh (struct AttributeDeleteHandle *adh)
443{ 451{
444 struct TicketRecordsEntry *le; 452 struct TicketRecordsEntry *le;
445 453
446 if (NULL != adh->ns_it) 454 if (NULL != adh->ns_it)
447 GNUNET_NAMESTORE_zone_iteration_stop(adh->ns_it); 455 GNUNET_NAMESTORE_zone_iteration_stop (adh->ns_it);
448 if (NULL != adh->ns_qe) 456 if (NULL != adh->ns_qe)
449 GNUNET_NAMESTORE_cancel(adh->ns_qe); 457 GNUNET_NAMESTORE_cancel (adh->ns_qe);
450 if (NULL != adh->label) 458 if (NULL != adh->label)
451 GNUNET_free(adh->label); 459 GNUNET_free (adh->label);
452 if (NULL != adh->claim) 460 if (NULL != adh->claim)
453 GNUNET_free(adh->claim); 461 GNUNET_free (adh->claim);
454 while (NULL != (le = adh->tickets_to_update_head)) 462 while (NULL != (le = adh->tickets_to_update_head))
455 { 463 {
456 GNUNET_CONTAINER_DLL_remove(adh->tickets_to_update_head, 464 GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head,
457 adh->tickets_to_update_tail, 465 adh->tickets_to_update_tail,
458 le); 466 le);
459 if (NULL != le->label) 467 if (NULL != le->label)
460 GNUNET_free(le->label); 468 GNUNET_free (le->label);
461 if (NULL != le->data) 469 if (NULL != le->data)
462 GNUNET_free(le->data); 470 GNUNET_free (le->data);
463 GNUNET_free(le); 471 GNUNET_free (le);
464 } 472 }
465 GNUNET_free(adh); 473 GNUNET_free (adh);
466} 474}
467 475
468 476
@@ -472,13 +480,13 @@ cleanup_adh(struct AttributeDeleteHandle *adh)
472 * @param handle handle to clean up 480 * @param handle handle to clean up
473 */ 481 */
474static void 482static void
475cleanup_as_handle(struct AttributeStoreHandle *ash) 483cleanup_as_handle (struct AttributeStoreHandle *ash)
476{ 484{
477 if (NULL != ash->ns_qe) 485 if (NULL != ash->ns_qe)
478 GNUNET_NAMESTORE_cancel(ash->ns_qe); 486 GNUNET_NAMESTORE_cancel (ash->ns_qe);
479 if (NULL != ash->claim) 487 if (NULL != ash->claim)
480 GNUNET_free(ash->claim); 488 GNUNET_free (ash->claim);
481 GNUNET_free(ash); 489 GNUNET_free (ash);
482} 490}
483 491
484 492
@@ -488,7 +496,7 @@ cleanup_as_handle(struct AttributeStoreHandle *ash)
488 * @param idp the client to clean up 496 * @param idp the client to clean up
489 */ 497 */
490static void 498static void
491cleanup_client(struct IdpClient *idp) 499cleanup_client (struct IdpClient *idp)
492{ 500{
493 struct AttributeIterator *ai; 501 struct AttributeIterator *ai;
494 struct TicketIteration *ti; 502 struct TicketIteration *ti;
@@ -499,52 +507,52 @@ cleanup_client(struct IdpClient *idp)
499 struct AttributeDeleteHandle *adh; 507 struct AttributeDeleteHandle *adh;
500 508
501 while (NULL != (iss = idp->issue_op_head)) 509 while (NULL != (iss = idp->issue_op_head))
502 { 510 {
503 GNUNET_CONTAINER_DLL_remove(idp->issue_op_head, idp->issue_op_tail, iss); 511 GNUNET_CONTAINER_DLL_remove (idp->issue_op_head, idp->issue_op_tail, iss);
504 GNUNET_free(iss); 512 GNUNET_free (iss);
505 } 513 }
506 while (NULL != (ct = idp->consume_op_head)) 514 while (NULL != (ct = idp->consume_op_head))
507 { 515 {
508 GNUNET_CONTAINER_DLL_remove(idp->consume_op_head, 516 GNUNET_CONTAINER_DLL_remove (idp->consume_op_head,
509 idp->consume_op_tail, 517 idp->consume_op_tail,
510 ct); 518 ct);
511 if (NULL != ct->ch) 519 if (NULL != ct->ch)
512 RECLAIM_TICKETS_consume_cancel(ct->ch); 520 RECLAIM_TICKETS_consume_cancel (ct->ch);
513 GNUNET_free(ct); 521 GNUNET_free (ct);
514 } 522 }
515 while (NULL != (as = idp->store_op_head)) 523 while (NULL != (as = idp->store_op_head))
516 { 524 {
517 GNUNET_CONTAINER_DLL_remove(idp->store_op_head, idp->store_op_tail, as); 525 GNUNET_CONTAINER_DLL_remove (idp->store_op_head, idp->store_op_tail, as);
518 cleanup_as_handle(as); 526 cleanup_as_handle (as);
519 } 527 }
520 while (NULL != (adh = idp->delete_op_head)) 528 while (NULL != (adh = idp->delete_op_head))
521 { 529 {
522 GNUNET_CONTAINER_DLL_remove(idp->delete_op_head, idp->delete_op_tail, adh); 530 GNUNET_CONTAINER_DLL_remove (idp->delete_op_head, idp->delete_op_tail, adh);
523 cleanup_adh(adh); 531 cleanup_adh (adh);
524 } 532 }
525 533
526 while (NULL != (ai = idp->attr_iter_head)) 534 while (NULL != (ai = idp->attr_iter_head))
527 { 535 {
528 GNUNET_CONTAINER_DLL_remove(idp->attr_iter_head, idp->attr_iter_tail, ai); 536 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
529 GNUNET_free(ai); 537 GNUNET_free (ai);
530 } 538 }
531 while (NULL != (rop = idp->revoke_op_head)) 539 while (NULL != (rop = idp->revoke_op_head))
532 { 540 {
533 GNUNET_CONTAINER_DLL_remove(idp->revoke_op_head, idp->revoke_op_tail, rop); 541 GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop);
534 if (NULL != rop->rh) 542 if (NULL != rop->rh)
535 RECLAIM_TICKETS_revoke_cancel(rop->rh); 543 RECLAIM_TICKETS_revoke_cancel (rop->rh);
536 GNUNET_free(rop); 544 GNUNET_free (rop);
537 } 545 }
538 while (NULL != (ti = idp->ticket_iter_head)) 546 while (NULL != (ti = idp->ticket_iter_head))
539 { 547 {
540 GNUNET_CONTAINER_DLL_remove(idp->ticket_iter_head, 548 GNUNET_CONTAINER_DLL_remove (idp->ticket_iter_head,
541 idp->ticket_iter_tail, 549 idp->ticket_iter_tail,
542 ti); 550 ti);
543 if (NULL != ti->iter) 551 if (NULL != ti->iter)
544 RECLAIM_TICKETS_iteration_stop(ti->iter); 552 RECLAIM_TICKETS_iteration_stop (ti->iter);
545 GNUNET_free(ti); 553 GNUNET_free (ti);
546 } 554 }
547 GNUNET_free(idp); 555 GNUNET_free (idp);
548} 556}
549 557
550 558
@@ -552,24 +560,24 @@ cleanup_client(struct IdpClient *idp)
552 * Cleanup task 560 * Cleanup task
553 */ 561 */
554static void 562static void
555cleanup() 563cleanup ()
556{ 564{
557 struct IdpClient *cl; 565 struct IdpClient *cl;
558 566
559 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); 567 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
560 568
561 while (NULL != (cl = client_list_head)) 569 while (NULL != (cl = client_list_head))
562 { 570 {
563 GNUNET_CONTAINER_DLL_remove(client_list_head, 571 GNUNET_CONTAINER_DLL_remove (client_list_head,
564 client_list_tail, 572 client_list_tail,
565 cl); 573 cl);
566 cleanup_client(cl); 574 cleanup_client (cl);
567 } 575 }
568 RECLAIM_TICKETS_deinit(); 576 RECLAIM_TICKETS_deinit ();
569 if (NULL != timeout_task) 577 if (NULL != timeout_task)
570 GNUNET_SCHEDULER_cancel(timeout_task); 578 GNUNET_SCHEDULER_cancel (timeout_task);
571 if (NULL != nsh) 579 if (NULL != nsh)
572 GNUNET_NAMESTORE_disconnect(nsh); 580 GNUNET_NAMESTORE_disconnect (nsh);
573} 581}
574 582
575 583
@@ -579,10 +587,10 @@ cleanup()
579 * @param cls NULL 587 * @param cls NULL
580 */ 588 */
581static void 589static void
582do_shutdown(void *cls) 590do_shutdown (void *cls)
583{ 591{
584 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Shutting down...\n"); 592 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
585 cleanup(); 593 cleanup ();
586} 594}
587 595
588 596
@@ -595,24 +603,24 @@ do_shutdown(void *cls)
595 * @param success the success status of the request 603 * @param success the success status of the request
596 */ 604 */
597static void 605static void
598send_ticket_result(const struct IdpClient *client, 606send_ticket_result (const struct IdpClient *client,
599 uint32_t r_id, 607 uint32_t r_id,
600 const struct GNUNET_RECLAIM_Ticket *ticket, 608 const struct GNUNET_RECLAIM_Ticket *ticket,
601 uint32_t success) 609 uint32_t success)
602{ 610{
603 struct TicketResultMessage *irm; 611 struct TicketResultMessage *irm;
604 struct GNUNET_MQ_Envelope *env; 612 struct GNUNET_MQ_Envelope *env;
605 613
606 env = GNUNET_MQ_msg(irm, 614 env = GNUNET_MQ_msg (irm,
607 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); 615 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
608 if (NULL != ticket) 616 if (NULL != ticket)
609 { 617 {
610 irm->ticket = *ticket; 618 irm->ticket = *ticket;
611 } 619 }
612 // TODO add success member 620 // TODO add success member
613 irm->id = htonl(r_id); 621 irm->id = htonl (r_id);
614 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); 622 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
615 GNUNET_MQ_send(client->mq, env); 623 GNUNET_MQ_send (client->mq, env);
616} 624}
617 625
618 626
@@ -625,28 +633,28 @@ send_ticket_result(const struct IdpClient *client,
625 * @param emsg error message (NULL of success is GNUNET_OK) 633 * @param emsg error message (NULL of success is GNUNET_OK)
626 */ 634 */
627static void 635static void
628issue_ticket_result_cb(void *cls, 636issue_ticket_result_cb (void *cls,
629 struct GNUNET_RECLAIM_Ticket *ticket, 637 struct GNUNET_RECLAIM_Ticket *ticket,
630 int32_t success, 638 int32_t success,
631 const char *emsg) 639 const char *emsg)
632{ 640{
633 struct TicketIssueOperation *tio = cls; 641 struct TicketIssueOperation *tio = cls;
634 642
635 if (GNUNET_OK != success) 643 if (GNUNET_OK != success)
636 { 644 {
637 send_ticket_result(tio->client, tio->r_id, NULL, GNUNET_SYSERR); 645 send_ticket_result (tio->client, tio->r_id, NULL, GNUNET_SYSERR);
638 GNUNET_CONTAINER_DLL_remove(tio->client->issue_op_head, 646 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
639 tio->client->issue_op_tail, 647 tio->client->issue_op_tail,
640 tio); 648 tio);
641 GNUNET_free(tio); 649 GNUNET_free (tio);
642 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg); 650 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
643 return; 651 return;
644 } 652 }
645 send_ticket_result(tio->client, tio->r_id, ticket, GNUNET_SYSERR); 653 send_ticket_result (tio->client, tio->r_id, ticket, GNUNET_SYSERR);
646 GNUNET_CONTAINER_DLL_remove(tio->client->issue_op_head, 654 GNUNET_CONTAINER_DLL_remove (tio->client->issue_op_head,
647 tio->client->issue_op_tail, 655 tio->client->issue_op_tail,
648 tio); 656 tio);
649 GNUNET_free(tio); 657 GNUNET_free (tio);
650} 658}
651 659
652 660
@@ -658,16 +666,16 @@ issue_ticket_result_cb(void *cls,
658 * @return GNUNET_OK if message is ok 666 * @return GNUNET_OK if message is ok
659 */ 667 */
660static int 668static int
661check_issue_ticket_message(void *cls, const struct IssueTicketMessage *im) 669check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
662{ 670{
663 uint16_t size; 671 uint16_t size;
664 672
665 size = ntohs(im->header.size); 673 size = ntohs (im->header.size);
666 if (size <= sizeof(struct IssueTicketMessage)) 674 if (size <= sizeof(struct IssueTicketMessage))
667 { 675 {
668 GNUNET_break(0); 676 GNUNET_break (0);
669 return GNUNET_SYSERR; 677 return GNUNET_SYSERR;
670 } 678 }
671 return GNUNET_OK; 679 return GNUNET_OK;
672} 680}
673 681
@@ -679,27 +687,28 @@ check_issue_ticket_message(void *cls, const struct IssueTicketMessage *im)
679 * @param im the message 687 * @param im the message
680 */ 688 */
681static void 689static void
682handle_issue_ticket_message(void *cls, const struct IssueTicketMessage *im) 690handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
683{ 691{
684 struct TicketIssueOperation *tio; 692 struct TicketIssueOperation *tio;
685 struct IdpClient *idp = cls; 693 struct IdpClient *idp = cls;
686 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 694 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
687 size_t attrs_len; 695 size_t attrs_len;
688 696
689 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); 697 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
690 tio = GNUNET_new(struct TicketIssueOperation); 698 tio = GNUNET_new (struct TicketIssueOperation);
691 attrs_len = ntohs(im->attr_len); 699 attrs_len = ntohs (im->attr_len);
692 attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize((char *)&im[1], attrs_len); 700 attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &im[1],
693 tio->r_id = ntohl(im->id); 701 attrs_len);
702 tio->r_id = ntohl (im->id);
694 tio->client = idp; 703 tio->client = idp;
695 GNUNET_CONTAINER_DLL_insert(idp->issue_op_head, idp->issue_op_tail, tio); 704 GNUNET_CONTAINER_DLL_insert (idp->issue_op_head, idp->issue_op_tail, tio);
696 RECLAIM_TICKETS_issue(&im->identity, 705 RECLAIM_TICKETS_issue (&im->identity,
697 attrs, 706 attrs,
698 &im->rp, 707 &im->rp,
699 &issue_ticket_result_cb, 708 &issue_ticket_result_cb,
700 tio); 709 tio);
701 GNUNET_SERVICE_client_continue(idp->client); 710 GNUNET_SERVICE_client_continue (idp->client);
702 GNUNET_RECLAIM_ATTRIBUTE_list_destroy(attrs); 711 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
703} 712}
704 713
705 714
@@ -715,22 +724,23 @@ handle_issue_ticket_message(void *cls, const struct IssueTicketMessage *im)
715 * @param success revocation result (GNUNET_OK if successful) 724 * @param success revocation result (GNUNET_OK if successful)
716 */ 725 */
717static void 726static void
718revoke_result_cb(void *cls, int32_t success) 727revoke_result_cb (void *cls, int32_t success)
719{ 728{
720 struct TicketRevocationOperation *rop = cls; 729 struct TicketRevocationOperation *rop = cls;
721 struct GNUNET_MQ_Envelope *env; 730 struct GNUNET_MQ_Envelope *env;
722 struct RevokeTicketResultMessage *trm; 731 struct RevokeTicketResultMessage *trm;
723 732
724 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending REVOKE_TICKET_RESULT message\n"); 733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
734 "Sending REVOKE_TICKET_RESULT message\n");
725 rop->rh = NULL; 735 rop->rh = NULL;
726 env = GNUNET_MQ_msg(trm, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT); 736 env = GNUNET_MQ_msg (trm, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT);
727 trm->id = htonl(rop->r_id); 737 trm->id = htonl (rop->r_id);
728 trm->success = htonl(success); 738 trm->success = htonl (success);
729 GNUNET_MQ_send(rop->client->mq, env); 739 GNUNET_MQ_send (rop->client->mq, env);
730 GNUNET_CONTAINER_DLL_remove(rop->client->revoke_op_head, 740 GNUNET_CONTAINER_DLL_remove (rop->client->revoke_op_head,
731 rop->client->revoke_op_tail, 741 rop->client->revoke_op_tail,
732 rop); 742 rop);
733 GNUNET_free(rop); 743 GNUNET_free (rop);
734} 744}
735 745
736 746
@@ -742,16 +752,16 @@ revoke_result_cb(void *cls, int32_t success)
742 * @return GNUNET_OK if message is ok 752 * @return GNUNET_OK if message is ok
743 */ 753 */
744static int 754static int
745check_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *im) 755check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im)
746{ 756{
747 uint16_t size; 757 uint16_t size;
748 758
749 size = ntohs(im->header.size); 759 size = ntohs (im->header.size);
750 if (size != sizeof(struct RevokeTicketMessage)) 760 if (size != sizeof(struct RevokeTicketMessage))
751 { 761 {
752 GNUNET_break(0); 762 GNUNET_break (0);
753 return GNUNET_SYSERR; 763 return GNUNET_SYSERR;
754 } 764 }
755 return GNUNET_OK; 765 return GNUNET_OK;
756} 766}
757 767
@@ -763,19 +773,20 @@ check_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *im)
763 * @param rm the message to handle 773 * @param rm the message to handle
764 */ 774 */
765static void 775static void
766handle_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *rm) 776handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
767{ 777{
768 struct TicketRevocationOperation *rop; 778 struct TicketRevocationOperation *rop;
769 struct IdpClient *idp = cls; 779 struct IdpClient *idp = cls;
770 780
771 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n"); 781 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
772 rop = GNUNET_new(struct TicketRevocationOperation); 782 rop = GNUNET_new (struct TicketRevocationOperation);
773 rop->r_id = ntohl(rm->id); 783 rop->r_id = ntohl (rm->id);
774 rop->client = idp; 784 rop->client = idp;
775 GNUNET_CONTAINER_DLL_insert(idp->revoke_op_head, idp->revoke_op_tail, rop); 785 GNUNET_CONTAINER_DLL_insert (idp->revoke_op_head, idp->revoke_op_tail, rop);
776 rop->rh 786 rop->rh
777 = RECLAIM_TICKETS_revoke(&rm->ticket, &rm->identity, &revoke_result_cb, rop); 787 = RECLAIM_TICKETS_revoke (&rm->ticket, &rm->identity, &revoke_result_cb,
778 GNUNET_SERVICE_client_continue(idp->client); 788 rop);
789 GNUNET_SERVICE_client_continue (idp->client);
779} 790}
780 791
781 792
@@ -789,11 +800,11 @@ handle_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *rm)
789 * @param emsg error message (NULL if success=GNUNET_OK) 800 * @param emsg error message (NULL if success=GNUNET_OK)
790 */ 801 */
791static void 802static void
792consume_result_cb(void *cls, 803consume_result_cb (void *cls,
793 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 804 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
794 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 805 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
795 int32_t success, 806 int32_t success,
796 const char *emsg) 807 const char *emsg)
797{ 808{
798 struct ConsumeTicketOperation *cop = cls; 809 struct ConsumeTicketOperation *cop = cls;
799 struct ConsumeTicketResultMessage *crm; 810 struct ConsumeTicketResultMessage *crm;
@@ -802,25 +813,26 @@ consume_result_cb(void *cls,
802 size_t attrs_len; 813 size_t attrs_len;
803 814
804 if (GNUNET_OK != success) 815 if (GNUNET_OK != success)
805 { 816 {
806 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg); 817 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
807 } 818 }
808 attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(attrs); 819 attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs);
809 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending CONSUME_TICKET_RESULT message\n"); 820 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
810 env = GNUNET_MQ_msg_extra(crm, 821 "Sending CONSUME_TICKET_RESULT message\n");
811 attrs_len, 822 env = GNUNET_MQ_msg_extra (crm,
812 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); 823 attrs_len,
813 crm->id = htonl(cop->r_id); 824 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT);
814 crm->attrs_len = htons(attrs_len); 825 crm->id = htonl (cop->r_id);
826 crm->attrs_len = htons (attrs_len);
815 crm->identity = *identity; 827 crm->identity = *identity;
816 crm->result = htonl(success); 828 crm->result = htonl (success);
817 data_tmp = (char *)&crm[1]; 829 data_tmp = (char *) &crm[1];
818 GNUNET_RECLAIM_ATTRIBUTE_list_serialize(attrs, data_tmp); 830 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, data_tmp);
819 GNUNET_MQ_send(cop->client->mq, env); 831 GNUNET_MQ_send (cop->client->mq, env);
820 GNUNET_CONTAINER_DLL_remove(cop->client->consume_op_head, 832 GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head,
821 cop->client->consume_op_tail, 833 cop->client->consume_op_tail,
822 cop); 834 cop);
823 GNUNET_free(cop); 835 GNUNET_free (cop);
824} 836}
825 837
826 838
@@ -831,16 +843,16 @@ consume_result_cb(void *cls,
831 * @param cm the message to handle 843 * @param cm the message to handle
832 */ 844 */
833static int 845static int
834check_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm) 846check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
835{ 847{
836 uint16_t size; 848 uint16_t size;
837 849
838 size = ntohs(cm->header.size); 850 size = ntohs (cm->header.size);
839 if (size != sizeof(struct ConsumeTicketMessage)) 851 if (size != sizeof(struct ConsumeTicketMessage))
840 { 852 {
841 GNUNET_break(0); 853 GNUNET_break (0);
842 return GNUNET_SYSERR; 854 return GNUNET_SYSERR;
843 } 855 }
844 return GNUNET_OK; 856 return GNUNET_OK;
845} 857}
846 858
@@ -852,19 +864,20 @@ check_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm)
852 * @cm the message to handle 864 * @cm the message to handle
853 */ 865 */
854static void 866static void
855handle_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm) 867handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
856{ 868{
857 struct ConsumeTicketOperation *cop; 869 struct ConsumeTicketOperation *cop;
858 struct IdpClient *idp = cls; 870 struct IdpClient *idp = cls;
859 871
860 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n"); 872 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
861 cop = GNUNET_new(struct ConsumeTicketOperation); 873 cop = GNUNET_new (struct ConsumeTicketOperation);
862 cop->r_id = ntohl(cm->id); 874 cop->r_id = ntohl (cm->id);
863 cop->client = idp; 875 cop->client = idp;
864 cop->ch 876 cop->ch
865 = RECLAIM_TICKETS_consume(&cm->identity, &cm->ticket, &consume_result_cb, cop); 877 = RECLAIM_TICKETS_consume (&cm->identity, &cm->ticket, &consume_result_cb,
866 GNUNET_CONTAINER_DLL_insert(idp->consume_op_head, idp->consume_op_tail, cop); 878 cop);
867 GNUNET_SERVICE_client_continue(idp->client); 879 GNUNET_CONTAINER_DLL_insert (idp->consume_op_head, idp->consume_op_tail, cop);
880 GNUNET_SERVICE_client_continue (idp->client);
868} 881}
869 882
870/***************************************** 883/*****************************************
@@ -880,33 +893,33 @@ handle_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm)
880 * @param emsg error message (NULL if success=GNUNET_OK) 893 * @param emsg error message (NULL if success=GNUNET_OK)
881 */ 894 */
882static void 895static void
883attr_store_cont(void *cls, int32_t success, const char *emsg) 896attr_store_cont (void *cls, int32_t success, const char *emsg)
884{ 897{
885 struct AttributeStoreHandle *ash = cls; 898 struct AttributeStoreHandle *ash = cls;
886 struct GNUNET_MQ_Envelope *env; 899 struct GNUNET_MQ_Envelope *env;
887 struct SuccessResultMessage *acr_msg; 900 struct SuccessResultMessage *acr_msg;
888 901
889 ash->ns_qe = NULL; 902 ash->ns_qe = NULL;
890 GNUNET_CONTAINER_DLL_remove(ash->client->store_op_head, 903 GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head,
891 ash->client->store_op_tail, 904 ash->client->store_op_tail,
892 ash); 905 ash);
893 906
894 if (GNUNET_SYSERR == success) 907 if (GNUNET_SYSERR == success)
895 { 908 {
896 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 909 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
897 "Failed to store attribute %s\n", 910 "Failed to store attribute %s\n",
898 emsg); 911 emsg);
899 cleanup_as_handle(ash); 912 cleanup_as_handle (ash);
900 GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); 913 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
901 return; 914 return;
902 } 915 }
903 916
904 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); 917 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
905 env = GNUNET_MQ_msg(acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); 918 env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE);
906 acr_msg->id = htonl(ash->r_id); 919 acr_msg->id = htonl (ash->r_id);
907 acr_msg->op_result = htonl(GNUNET_OK); 920 acr_msg->op_result = htonl (GNUNET_OK);
908 GNUNET_MQ_send(ash->client->mq, env); 921 GNUNET_MQ_send (ash->client->mq, env);
909 cleanup_as_handle(ash); 922 cleanup_as_handle (ash);
910} 923}
911 924
912 925
@@ -916,7 +929,7 @@ attr_store_cont(void *cls, int32_t success, const char *emsg)
916 * @param cls the AttributeStoreHandle 929 * @param cls the AttributeStoreHandle
917 */ 930 */
918static void 931static void
919attr_store_task(void *cls) 932attr_store_task (void *cls)
920{ 933{
921 struct AttributeStoreHandle *ash = cls; 934 struct AttributeStoreHandle *ash = cls;
922 struct GNUNET_GNSRECORD_Data rd[1]; 935 struct GNUNET_GNSRECORD_Data rd[1];
@@ -924,32 +937,32 @@ attr_store_task(void *cls)
924 char *label; 937 char *label;
925 size_t buf_size; 938 size_t buf_size;
926 939
927 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n"); 940 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
928 buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(ash->claim); 941 buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (ash->claim);
929 buf = GNUNET_malloc(buf_size); 942 buf = GNUNET_malloc (buf_size);
930 // Give the ash a new id if unset 943 // Give the ash a new id if unset
931 if (0 == ash->claim->id) 944 if (0 == ash->claim->id)
932 ash->claim->id 945 ash->claim->id
933 = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); 946 = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX);
934 GNUNET_RECLAIM_ATTRIBUTE_serialize(ash->claim, buf); 947 GNUNET_RECLAIM_ATTRIBUTE_serialize (ash->claim, buf);
935 label 948 label
936 = GNUNET_STRINGS_data_to_string_alloc(&ash->claim->id, sizeof(uint64_t)); 949 = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, sizeof(uint64_t));
937 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); 950 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
938 951
939 rd[0].data_size = buf_size; 952 rd[0].data_size = buf_size;
940 rd[0].data = buf; 953 rd[0].data = buf;
941 rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR; 954 rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR;
942 rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 955 rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
943 rd[0].expiration_time = ash->exp.rel_value_us; 956 rd[0].expiration_time = ash->exp.rel_value_us;
944 ash->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 957 ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
945 &ash->identity, 958 &ash->identity,
946 label, 959 label,
947 1, 960 1,
948 rd, 961 rd,
949 &attr_store_cont, 962 &attr_store_cont,
950 ash); 963 ash);
951 GNUNET_free(buf); 964 GNUNET_free (buf);
952 GNUNET_free(label); 965 GNUNET_free (label);
953} 966}
954 967
955 968
@@ -960,17 +973,17 @@ attr_store_task(void *cls)
960 * @param sam the message to check 973 * @param sam the message to check
961 */ 974 */
962static int 975static int
963check_attribute_store_message(void *cls, 976check_attribute_store_message (void *cls,
964 const struct AttributeStoreMessage *sam) 977 const struct AttributeStoreMessage *sam)
965{ 978{
966 uint16_t size; 979 uint16_t size;
967 980
968 size = ntohs(sam->header.size); 981 size = ntohs (sam->header.size);
969 if (size <= sizeof(struct AttributeStoreMessage)) 982 if (size <= sizeof(struct AttributeStoreMessage))
970 { 983 {
971 GNUNET_break(0); 984 GNUNET_break (0);
972 return GNUNET_SYSERR; 985 return GNUNET_SYSERR;
973 } 986 }
974 return GNUNET_OK; 987 return GNUNET_OK;
975} 988}
976 989
@@ -982,29 +995,30 @@ check_attribute_store_message(void *cls,
982 * @param sam the message to handle 995 * @param sam the message to handle
983 */ 996 */
984static void 997static void
985handle_attribute_store_message(void *cls, 998handle_attribute_store_message (void *cls,
986 const struct AttributeStoreMessage *sam) 999 const struct AttributeStoreMessage *sam)
987{ 1000{
988 struct AttributeStoreHandle *ash; 1001 struct AttributeStoreHandle *ash;
989 struct IdpClient *idp = cls; 1002 struct IdpClient *idp = cls;
990 size_t data_len; 1003 size_t data_len;
991 1004
992 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n"); 1005 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
993 1006
994 data_len = ntohs(sam->attr_len); 1007 data_len = ntohs (sam->attr_len);
995 1008
996 ash = GNUNET_new(struct AttributeStoreHandle); 1009 ash = GNUNET_new (struct AttributeStoreHandle);
997 ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&sam[1], data_len); 1010 ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &sam[1],
1011 data_len);
998 1012
999 ash->r_id = ntohl(sam->id); 1013 ash->r_id = ntohl (sam->id);
1000 ash->identity = sam->identity; 1014 ash->identity = sam->identity;
1001 ash->exp.rel_value_us = GNUNET_ntohll(sam->exp); 1015 ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
1002 GNUNET_CRYPTO_ecdsa_key_get_public(&sam->identity, &ash->identity_pkey); 1016 GNUNET_CRYPTO_ecdsa_key_get_public (&sam->identity, &ash->identity_pkey);
1003 1017
1004 GNUNET_SERVICE_client_continue(idp->client); 1018 GNUNET_SERVICE_client_continue (idp->client);
1005 ash->client = idp; 1019 ash->client = idp;
1006 GNUNET_CONTAINER_DLL_insert(idp->store_op_head, idp->store_op_tail, ash); 1020 GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash);
1007 GNUNET_SCHEDULER_add_now(&attr_store_task, ash); 1021 GNUNET_SCHEDULER_add_now (&attr_store_task, ash);
1008} 1022}
1009 1023
1010 1024
@@ -1015,20 +1029,20 @@ handle_attribute_store_message(void *cls,
1015 * @param success the success status 1029 * @param success the success status
1016 */ 1030 */
1017static void 1031static void
1018send_delete_response(struct AttributeDeleteHandle *adh, int32_t success) 1032send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
1019{ 1033{
1020 struct GNUNET_MQ_Envelope *env; 1034 struct GNUNET_MQ_Envelope *env;
1021 struct SuccessResultMessage *acr_msg; 1035 struct SuccessResultMessage *acr_msg;
1022 1036
1023 GNUNET_CONTAINER_DLL_remove(adh->client->delete_op_head, 1037 GNUNET_CONTAINER_DLL_remove (adh->client->delete_op_head,
1024 adh->client->delete_op_tail, 1038 adh->client->delete_op_tail,
1025 adh); 1039 adh);
1026 1040
1027 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); 1041 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1028 env = GNUNET_MQ_msg(acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); 1042 env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE);
1029 acr_msg->id = htonl(adh->r_id); 1043 acr_msg->id = htonl (adh->r_id);
1030 acr_msg->op_result = htonl(success); 1044 acr_msg->op_result = htonl (success);
1031 GNUNET_MQ_send(adh->client->mq, env); 1045 GNUNET_MQ_send (adh->client->mq, env);
1032} 1046}
1033 1047
1034 1048
@@ -1043,41 +1057,41 @@ send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
1043 * @param rd record data 1057 * @param rd record data
1044 */ 1058 */
1045static void 1059static void
1046ticket_iter(void *cls, 1060ticket_iter (void *cls,
1047 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 1061 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1048 const char *label, 1062 const char *label,
1049 unsigned int rd_count, 1063 unsigned int rd_count,
1050 const struct GNUNET_GNSRECORD_Data *rd) 1064 const struct GNUNET_GNSRECORD_Data *rd)
1051{ 1065{
1052 struct AttributeDeleteHandle *adh = cls; 1066 struct AttributeDeleteHandle *adh = cls;
1053 struct TicketRecordsEntry *le; 1067 struct TicketRecordsEntry *le;
1054 int has_changed = GNUNET_NO; 1068 int has_changed = GNUNET_NO;
1055 1069
1056 for (int i = 0; i < rd_count; i++) 1070 for (int i = 0; i < rd_count; i++)
1057 { 1071 {
1058 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 1072 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1059 continue; 1073 continue;
1060 if (0 != memcmp(rd[i].data, &adh->claim->id, sizeof(uint64_t))) 1074 if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))
1061 continue; 1075 continue;
1062 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1076 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1063 "Attribute to delete found (%s)\n", 1077 "Attribute to delete found (%s)\n",
1064 adh->label); 1078 adh->label);
1065 has_changed = GNUNET_YES; 1079 has_changed = GNUNET_YES;
1066 break; 1080 break;
1067 } 1081 }
1068 if (GNUNET_YES == has_changed) 1082 if (GNUNET_YES == has_changed)
1069 { 1083 {
1070 le = GNUNET_new(struct TicketRecordsEntry); 1084 le = GNUNET_new (struct TicketRecordsEntry);
1071 le->data_size = GNUNET_GNSRECORD_records_get_size(rd_count, rd); 1085 le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
1072 le->data = GNUNET_malloc(le->data_size); 1086 le->data = GNUNET_malloc (le->data_size);
1073 le->rd_count = rd_count; 1087 le->rd_count = rd_count;
1074 le->label = GNUNET_strdup(label); 1088 le->label = GNUNET_strdup (label);
1075 GNUNET_GNSRECORD_records_serialize(rd_count, rd, le->data_size, le->data); 1089 GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
1076 GNUNET_CONTAINER_DLL_insert(adh->tickets_to_update_head, 1090 GNUNET_CONTAINER_DLL_insert (adh->tickets_to_update_head,
1077 adh->tickets_to_update_tail, 1091 adh->tickets_to_update_tail,
1078 le); 1092 le);
1079 } 1093 }
1080 GNUNET_NAMESTORE_zone_iterator_next(adh->ns_it, 1); 1094 GNUNET_NAMESTORE_zone_iterator_next (adh->ns_it, 1);
1081} 1095}
1082 1096
1083 1097
@@ -1086,7 +1100,7 @@ ticket_iter(void *cls,
1086 * @param cls our deletion handle 1100 * @param cls our deletion handle
1087 */ 1101 */
1088static void 1102static void
1089update_tickets(void *cls); 1103update_tickets (void *cls);
1090 1104
1091 1105
1092/** 1106/**
@@ -1097,12 +1111,12 @@ update_tickets(void *cls);
1097 * @param emsg error message (NULL if success=GNUNET_OK) 1111 * @param emsg error message (NULL if success=GNUNET_OK)
1098 */ 1112 */
1099static void 1113static void
1100ticket_updated(void *cls, int32_t success, const char *emsg) 1114ticket_updated (void *cls, int32_t success, const char *emsg)
1101{ 1115{
1102 struct AttributeDeleteHandle *adh = cls; 1116 struct AttributeDeleteHandle *adh = cls;
1103 1117
1104 adh->ns_qe = NULL; 1118 adh->ns_qe = NULL;
1105 GNUNET_SCHEDULER_add_now(&update_tickets, adh); 1119 GNUNET_SCHEDULER_add_now (&update_tickets, adh);
1106} 1120}
1107 1121
1108 1122
@@ -1114,58 +1128,58 @@ ticket_updated(void *cls, int32_t success, const char *emsg)
1114 * @param cls our attribute deletion handle 1128 * @param cls our attribute deletion handle
1115 */ 1129 */
1116static void 1130static void
1117update_tickets(void *cls) 1131update_tickets (void *cls)
1118{ 1132{
1119 struct AttributeDeleteHandle *adh = cls; 1133 struct AttributeDeleteHandle *adh = cls;
1120 struct TicketRecordsEntry *le; 1134 struct TicketRecordsEntry *le;
1121 1135
1122 if (NULL == adh->tickets_to_update_head) 1136 if (NULL == adh->tickets_to_update_head)
1123 { 1137 {
1124 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1138 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1125 "Finished updatding tickets, success\n"); 1139 "Finished updatding tickets, success\n");
1126 send_delete_response(adh, GNUNET_OK); 1140 send_delete_response (adh, GNUNET_OK);
1127 cleanup_adh(adh); 1141 cleanup_adh (adh);
1128 return; 1142 return;
1129 } 1143 }
1130 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1144 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1131 "Updating %s\n", 1145 "Updating %s\n",
1132 adh->tickets_to_update_head->label); 1146 adh->tickets_to_update_head->label);
1133 le = adh->tickets_to_update_head; 1147 le = adh->tickets_to_update_head;
1134 GNUNET_CONTAINER_DLL_remove(adh->tickets_to_update_head, 1148 GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head,
1135 adh->tickets_to_update_tail, 1149 adh->tickets_to_update_tail,
1136 le); 1150 le);
1137 struct GNUNET_GNSRECORD_Data rd[le->rd_count]; 1151 struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1138 struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1]; 1152 struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1139 if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize(le->data_size, 1153 if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize (le->data_size,
1140 le->data, 1154 le->data,
1141 le->rd_count, 1155 le->rd_count,
1142 rd)) 1156 rd))
1143 { 1157 {
1144 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1158 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1145 "Unable to deserialize record data!\n"); 1159 "Unable to deserialize record data!\n");
1146 send_delete_response(adh, GNUNET_SYSERR); 1160 send_delete_response (adh, GNUNET_SYSERR);
1147 cleanup_adh(adh); 1161 cleanup_adh (adh);
1148 return; 1162 return;
1149 } 1163 }
1150 int j = 0; 1164 int j = 0;
1151 for (int i = 0; i < le->rd_count; i++) 1165 for (int i = 0; i < le->rd_count; i++)
1152 { 1166 {
1153 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) 1167 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type)
1154 && (0 == memcmp(rd[i].data, &adh->claim->id, sizeof(uint64_t)))) 1168 && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))))
1155 continue; 1169 continue;
1156 rd_new[j] = rd[i]; 1170 rd_new[j] = rd[i];
1157 j++; 1171 j++;
1158 } 1172 }
1159 adh->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 1173 adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1160 &adh->identity, 1174 &adh->identity,
1161 le->label, 1175 le->label,
1162 j, 1176 j,
1163 rd_new, 1177 rd_new,
1164 &ticket_updated, 1178 &ticket_updated,
1165 adh); 1179 adh);
1166 GNUNET_free(le->label); 1180 GNUNET_free (le->label);
1167 GNUNET_free(le->data); 1181 GNUNET_free (le->data);
1168 GNUNET_free(le); 1182 GNUNET_free (le);
1169} 1183}
1170 1184
1171 1185
@@ -1175,12 +1189,12 @@ update_tickets(void *cls)
1175 * @param cls our attribute deletion handle 1189 * @param cls our attribute deletion handle
1176 */ 1190 */
1177static void 1191static void
1178ticket_iter_fin(void *cls) 1192ticket_iter_fin (void *cls)
1179{ 1193{
1180 struct AttributeDeleteHandle *adh = cls; 1194 struct AttributeDeleteHandle *adh = cls;
1181 1195
1182 adh->ns_it = NULL; 1196 adh->ns_it = NULL;
1183 GNUNET_SCHEDULER_add_now(&update_tickets, adh); 1197 GNUNET_SCHEDULER_add_now (&update_tickets, adh);
1184} 1198}
1185 1199
1186 1200
@@ -1190,16 +1204,16 @@ ticket_iter_fin(void *cls)
1190 * @param cls our attribute deletion handle 1204 * @param cls our attribute deletion handle
1191 */ 1205 */
1192static void 1206static void
1193ticket_iter_err(void *cls) 1207ticket_iter_err (void *cls)
1194{ 1208{
1195 struct AttributeDeleteHandle *adh = cls; 1209 struct AttributeDeleteHandle *adh = cls;
1196 1210
1197 adh->ns_it = NULL; 1211 adh->ns_it = NULL;
1198 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1212 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1199 "Namestore error on delete %s\n", 1213 "Namestore error on delete %s\n",
1200 adh->label); 1214 adh->label);
1201 send_delete_response(adh, GNUNET_SYSERR); 1215 send_delete_response (adh, GNUNET_SYSERR);
1202 cleanup_adh(adh); 1216 cleanup_adh (adh);
1203} 1217}
1204 1218
1205 1219
@@ -1210,18 +1224,18 @@ ticket_iter_err(void *cls)
1210 * @param cls attribute deletion handle 1224 * @param cls attribute deletion handle
1211 */ 1225 */
1212static void 1226static void
1213start_ticket_update(void *cls) 1227start_ticket_update (void *cls)
1214{ 1228{
1215 struct AttributeDeleteHandle *adh = cls; 1229 struct AttributeDeleteHandle *adh = cls;
1216 1230
1217 adh->ns_it = GNUNET_NAMESTORE_zone_iteration_start(nsh, 1231 adh->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh,
1218 &adh->identity, 1232 &adh->identity,
1219 &ticket_iter_err, 1233 &ticket_iter_err,
1220 adh, 1234 adh,
1221 &ticket_iter, 1235 &ticket_iter,
1222 adh, 1236 adh,
1223 &ticket_iter_fin, 1237 &ticket_iter_fin,
1224 adh); 1238 adh);
1225} 1239}
1226 1240
1227 1241
@@ -1233,22 +1247,22 @@ start_ticket_update(void *cls)
1233 * @param emsg error message (NULL if success=GNUNET_OK) 1247 * @param emsg error message (NULL if success=GNUNET_OK)
1234 */ 1248 */
1235static void 1249static void
1236attr_delete_cont(void *cls, int32_t success, const char *emsg) 1250attr_delete_cont (void *cls, int32_t success, const char *emsg)
1237{ 1251{
1238 struct AttributeDeleteHandle *adh = cls; 1252 struct AttributeDeleteHandle *adh = cls;
1239 1253
1240 adh->ns_qe = NULL; 1254 adh->ns_qe = NULL;
1241 if (GNUNET_SYSERR == success) 1255 if (GNUNET_SYSERR == success)
1242 { 1256 {
1243 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1257 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1244 "Error deleting attribute %s\n", 1258 "Error deleting attribute %s\n",
1245 adh->label); 1259 adh->label);
1246 send_delete_response(adh, GNUNET_SYSERR); 1260 send_delete_response (adh, GNUNET_SYSERR);
1247 cleanup_adh(adh); 1261 cleanup_adh (adh);
1248 return; 1262 return;
1249 } 1263 }
1250 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); 1264 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1251 GNUNET_SCHEDULER_add_now(&start_ticket_update, adh); 1265 GNUNET_SCHEDULER_add_now (&start_ticket_update, adh);
1252} 1266}
1253 1267
1254 1268
@@ -1259,17 +1273,17 @@ attr_delete_cont(void *cls, int32_t success, const char *emsg)
1259 * @dam message to check 1273 * @dam message to check
1260 */ 1274 */
1261static int 1275static int
1262check_attribute_delete_message(void *cls, 1276check_attribute_delete_message (void *cls,
1263 const struct AttributeDeleteMessage *dam) 1277 const struct AttributeDeleteMessage *dam)
1264{ 1278{
1265 uint16_t size; 1279 uint16_t size;
1266 1280
1267 size = ntohs(dam->header.size); 1281 size = ntohs (dam->header.size);
1268 if (size <= sizeof(struct AttributeDeleteMessage)) 1282 if (size <= sizeof(struct AttributeDeleteMessage))
1269 { 1283 {
1270 GNUNET_break(0); 1284 GNUNET_break (0);
1271 return GNUNET_SYSERR; 1285 return GNUNET_SYSERR;
1272 } 1286 }
1273 return GNUNET_OK; 1287 return GNUNET_OK;
1274} 1288}
1275 1289
@@ -1281,34 +1295,35 @@ check_attribute_delete_message(void *cls,
1281 * @param dam deletion message 1295 * @param dam deletion message
1282 */ 1296 */
1283static void 1297static void
1284handle_attribute_delete_message(void *cls, 1298handle_attribute_delete_message (void *cls,
1285 const struct AttributeDeleteMessage *dam) 1299 const struct AttributeDeleteMessage *dam)
1286{ 1300{
1287 struct AttributeDeleteHandle *adh; 1301 struct AttributeDeleteHandle *adh;
1288 struct IdpClient *idp = cls; 1302 struct IdpClient *idp = cls;
1289 size_t data_len; 1303 size_t data_len;
1290 1304
1291 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n"); 1305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1292 1306
1293 data_len = ntohs(dam->attr_len); 1307 data_len = ntohs (dam->attr_len);
1294 1308
1295 adh = GNUNET_new(struct AttributeDeleteHandle); 1309 adh = GNUNET_new (struct AttributeDeleteHandle);
1296 adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&dam[1], data_len); 1310 adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &dam[1],
1311 data_len);
1297 1312
1298 adh->r_id = ntohl(dam->id); 1313 adh->r_id = ntohl (dam->id);
1299 adh->identity = dam->identity; 1314 adh->identity = dam->identity;
1300 adh->label 1315 adh->label
1301 = GNUNET_STRINGS_data_to_string_alloc(&adh->claim->id, sizeof(uint64_t)); 1316 = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, sizeof(uint64_t));
1302 GNUNET_SERVICE_client_continue(idp->client); 1317 GNUNET_SERVICE_client_continue (idp->client);
1303 adh->client = idp; 1318 adh->client = idp;
1304 GNUNET_CONTAINER_DLL_insert(idp->delete_op_head, idp->delete_op_tail, adh); 1319 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1305 adh->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 1320 adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1306 &adh->identity, 1321 &adh->identity,
1307 adh->label, 1322 adh->label,
1308 0, 1323 0,
1309 NULL, 1324 NULL,
1310 &attr_delete_cont, 1325 &attr_delete_cont,
1311 adh); 1326 adh);
1312} 1327}
1313 1328
1314 1329
@@ -1323,21 +1338,21 @@ handle_attribute_delete_message(void *cls,
1323 * @param cls our iterator handle 1338 * @param cls our iterator handle
1324 */ 1339 */
1325static void 1340static void
1326attr_iter_finished(void *cls) 1341attr_iter_finished (void *cls)
1327{ 1342{
1328 struct AttributeIterator *ai = cls; 1343 struct AttributeIterator *ai = cls;
1329 struct GNUNET_MQ_Envelope *env; 1344 struct GNUNET_MQ_Envelope *env;
1330 struct AttributeResultMessage *arm; 1345 struct AttributeResultMessage *arm;
1331 1346
1332 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n"); 1347 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1333 env = GNUNET_MQ_msg(arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); 1348 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
1334 arm->id = htonl(ai->request_id); 1349 arm->id = htonl (ai->request_id);
1335 arm->attr_len = htons(0); 1350 arm->attr_len = htons (0);
1336 GNUNET_MQ_send(ai->client->mq, env); 1351 GNUNET_MQ_send (ai->client->mq, env);
1337 GNUNET_CONTAINER_DLL_remove(ai->client->attr_iter_head, 1352 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
1338 ai->client->attr_iter_tail, 1353 ai->client->attr_iter_tail,
1339 ai); 1354 ai);
1340 GNUNET_free(ai); 1355 GNUNET_free (ai);
1341} 1356}
1342 1357
1343/** 1358/**
@@ -1346,12 +1361,12 @@ attr_iter_finished(void *cls)
1346 * @param cls our attribute iteration handle 1361 * @param cls our attribute iteration handle
1347 */ 1362 */
1348static void 1363static void
1349attr_iter_error(void *cls) 1364attr_iter_error (void *cls)
1350{ 1365{
1351 struct AttributeIterator *ai = cls; 1366 struct AttributeIterator *ai = cls;
1352 1367
1353 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); 1368 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
1354 attr_iter_finished(ai); 1369 attr_iter_finished (ai);
1355} 1370}
1356 1371
1357 1372
@@ -1365,11 +1380,11 @@ attr_iter_error(void *cls)
1365 * @param rd records 1380 * @param rd records
1366 */ 1381 */
1367static void 1382static void
1368attr_iter_cb(void *cls, 1383attr_iter_cb (void *cls,
1369 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 1384 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1370 const char *label, 1385 const char *label,
1371 unsigned int rd_count, 1386 unsigned int rd_count,
1372 const struct GNUNET_GNSRECORD_Data *rd) 1387 const struct GNUNET_GNSRECORD_Data *rd)
1373{ 1388{
1374 struct AttributeIterator *ai = cls; 1389 struct AttributeIterator *ai = cls;
1375 struct AttributeResultMessage *arm; 1390 struct AttributeResultMessage *arm;
@@ -1377,27 +1392,27 @@ attr_iter_cb(void *cls,
1377 char *data_tmp; 1392 char *data_tmp;
1378 1393
1379 if (rd_count != 1) 1394 if (rd_count != 1)
1380 { 1395 {
1381 GNUNET_NAMESTORE_zone_iterator_next(ai->ns_it, 1); 1396 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
1382 return; 1397 return;
1383 } 1398 }
1384 1399
1385 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd->record_type) 1400 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd->record_type)
1386 { 1401 {
1387 GNUNET_NAMESTORE_zone_iterator_next(ai->ns_it, 1); 1402 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
1388 return; 1403 return;
1389 } 1404 }
1390 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label); 1405 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label);
1391 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n"); 1406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1392 env = GNUNET_MQ_msg_extra(arm, 1407 env = GNUNET_MQ_msg_extra (arm,
1393 rd->data_size, 1408 rd->data_size,
1394 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); 1409 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
1395 arm->id = htonl(ai->request_id); 1410 arm->id = htonl (ai->request_id);
1396 arm->attr_len = htons(rd->data_size); 1411 arm->attr_len = htons (rd->data_size);
1397 GNUNET_CRYPTO_ecdsa_key_get_public(zone, &arm->identity); 1412 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
1398 data_tmp = (char *)&arm[1]; 1413 data_tmp = (char *) &arm[1];
1399 GNUNET_memcpy(data_tmp, rd->data, rd->data_size); 1414 GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
1400 GNUNET_MQ_send(ai->client->mq, env); 1415 GNUNET_MQ_send (ai->client->mq, env);
1401} 1416}
1402 1417
1403 1418
@@ -1408,29 +1423,29 @@ attr_iter_cb(void *cls,
1408 * @param ais_msg the iteration message to start 1423 * @param ais_msg the iteration message to start
1409 */ 1424 */
1410static void 1425static void
1411handle_iteration_start(void *cls, 1426handle_iteration_start (void *cls,
1412 const struct AttributeIterationStartMessage *ais_msg) 1427 const struct AttributeIterationStartMessage *ais_msg)
1413{ 1428{
1414 struct IdpClient *idp = cls; 1429 struct IdpClient *idp = cls;
1415 struct AttributeIterator *ai; 1430 struct AttributeIterator *ai;
1416 1431
1417 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1432 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1418 "Received ATTRIBUTE_ITERATION_START message\n"); 1433 "Received ATTRIBUTE_ITERATION_START message\n");
1419 ai = GNUNET_new(struct AttributeIterator); 1434 ai = GNUNET_new (struct AttributeIterator);
1420 ai->request_id = ntohl(ais_msg->id); 1435 ai->request_id = ntohl (ais_msg->id);
1421 ai->client = idp; 1436 ai->client = idp;
1422 ai->identity = ais_msg->identity; 1437 ai->identity = ais_msg->identity;
1423 1438
1424 GNUNET_CONTAINER_DLL_insert(idp->attr_iter_head, idp->attr_iter_tail, ai); 1439 GNUNET_CONTAINER_DLL_insert (idp->attr_iter_head, idp->attr_iter_tail, ai);
1425 ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start(nsh, 1440 ai->ns_it = GNUNET_NAMESTORE_zone_iteration_start (nsh,
1426 &ai->identity, 1441 &ai->identity,
1427 &attr_iter_error, 1442 &attr_iter_error,
1428 ai, 1443 ai,
1429 &attr_iter_cb, 1444 &attr_iter_cb,
1430 ai, 1445 ai,
1431 &attr_iter_finished, 1446 &attr_iter_finished,
1432 ai); 1447 ai);
1433 GNUNET_SERVICE_client_continue(idp->client); 1448 GNUNET_SERVICE_client_continue (idp->client);
1434} 1449}
1435 1450
1436 1451
@@ -1441,29 +1456,29 @@ handle_iteration_start(void *cls,
1441 * @param ais_msg the stop message 1456 * @param ais_msg the stop message
1442 */ 1457 */
1443static void 1458static void
1444handle_iteration_stop(void *cls, 1459handle_iteration_stop (void *cls,
1445 const struct AttributeIterationStopMessage *ais_msg) 1460 const struct AttributeIterationStopMessage *ais_msg)
1446{ 1461{
1447 struct IdpClient *idp = cls; 1462 struct IdpClient *idp = cls;
1448 struct AttributeIterator *ai; 1463 struct AttributeIterator *ai;
1449 uint32_t rid; 1464 uint32_t rid;
1450 1465
1451 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1466 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1452 "Received `%s' message\n", 1467 "Received `%s' message\n",
1453 "ATTRIBUTE_ITERATION_STOP"); 1468 "ATTRIBUTE_ITERATION_STOP");
1454 rid = ntohl(ais_msg->id); 1469 rid = ntohl (ais_msg->id);
1455 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next) 1470 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
1456 if (ai->request_id == rid) 1471 if (ai->request_id == rid)
1457 break; 1472 break;
1458 if (NULL == ai) 1473 if (NULL == ai)
1459 { 1474 {
1460 GNUNET_break(0); 1475 GNUNET_break (0);
1461 GNUNET_SERVICE_client_drop(idp->client); 1476 GNUNET_SERVICE_client_drop (idp->client);
1462 return; 1477 return;
1463 } 1478 }
1464 GNUNET_CONTAINER_DLL_remove(idp->attr_iter_head, idp->attr_iter_tail, ai); 1479 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
1465 GNUNET_free(ai); 1480 GNUNET_free (ai);
1466 GNUNET_SERVICE_client_continue(idp->client); 1481 GNUNET_SERVICE_client_continue (idp->client);
1467} 1482}
1468 1483
1469 1484
@@ -1474,27 +1489,27 @@ handle_iteration_stop(void *cls,
1474 * @param ais_msg the message 1489 * @param ais_msg the message
1475 */ 1490 */
1476static void 1491static void
1477handle_iteration_next(void *cls, 1492handle_iteration_next (void *cls,
1478 const struct AttributeIterationNextMessage *ais_msg) 1493 const struct AttributeIterationNextMessage *ais_msg)
1479{ 1494{
1480 struct IdpClient *idp = cls; 1495 struct IdpClient *idp = cls;
1481 struct AttributeIterator *ai; 1496 struct AttributeIterator *ai;
1482 uint32_t rid; 1497 uint32_t rid;
1483 1498
1484 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1499 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1485 "Received ATTRIBUTE_ITERATION_NEXT message\n"); 1500 "Received ATTRIBUTE_ITERATION_NEXT message\n");
1486 rid = ntohl(ais_msg->id); 1501 rid = ntohl (ais_msg->id);
1487 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next) 1502 for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
1488 if (ai->request_id == rid) 1503 if (ai->request_id == rid)
1489 break; 1504 break;
1490 if (NULL == ai) 1505 if (NULL == ai)
1491 { 1506 {
1492 GNUNET_break(0); 1507 GNUNET_break (0);
1493 GNUNET_SERVICE_client_drop(idp->client); 1508 GNUNET_SERVICE_client_drop (idp->client);
1494 return; 1509 return;
1495 } 1510 }
1496 GNUNET_NAMESTORE_zone_iterator_next(ai->ns_it, 1); 1511 GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
1497 GNUNET_SERVICE_client_continue(idp->client); 1512 GNUNET_SERVICE_client_continue (idp->client);
1498} 1513}
1499 1514
1500/****************************************************** 1515/******************************************************
@@ -1508,29 +1523,29 @@ handle_iteration_next(void *cls,
1508 * @param ticket the ticket 1523 * @param ticket the ticket
1509 */ 1524 */
1510static void 1525static void
1511ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket) 1526ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
1512{ 1527{
1513 struct TicketIteration *ti = cls; 1528 struct TicketIteration *ti = cls;
1514 struct GNUNET_MQ_Envelope *env; 1529 struct GNUNET_MQ_Envelope *env;
1515 struct TicketResultMessage *trm; 1530 struct TicketResultMessage *trm;
1516 1531
1517 env = GNUNET_MQ_msg(trm, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); 1532 env = GNUNET_MQ_msg (trm, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT);
1518 if (NULL == ticket) 1533 if (NULL == ticket)
1519 { 1534 {
1520 /* send empty response to indicate end of list */ 1535 /* send empty response to indicate end of list */
1521 GNUNET_CONTAINER_DLL_remove(ti->client->ticket_iter_head, 1536 GNUNET_CONTAINER_DLL_remove (ti->client->ticket_iter_head,
1522 ti->client->ticket_iter_tail, 1537 ti->client->ticket_iter_tail,
1523 ti); 1538 ti);
1524 } 1539 }
1525 else 1540 else
1526 { 1541 {
1527 trm->ticket = *ticket; 1542 trm->ticket = *ticket;
1528 } 1543 }
1529 trm->id = htonl(ti->r_id); 1544 trm->id = htonl (ti->r_id);
1530 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); 1545 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
1531 GNUNET_MQ_send(ti->client->mq, env); 1546 GNUNET_MQ_send (ti->client->mq, env);
1532 if (NULL == ticket) 1547 if (NULL == ticket)
1533 GNUNET_free(ti); 1548 GNUNET_free (ti);
1534} 1549}
1535 1550
1536 1551
@@ -1541,25 +1556,25 @@ ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
1541 * @param tis_msg the iteration request message 1556 * @param tis_msg the iteration request message
1542 */ 1557 */
1543static void 1558static void
1544handle_ticket_iteration_start( 1559handle_ticket_iteration_start (
1545 void *cls, 1560 void *cls,
1546 const struct TicketIterationStartMessage *tis_msg) 1561 const struct TicketIterationStartMessage *tis_msg)
1547{ 1562{
1548 struct IdpClient *client = cls; 1563 struct IdpClient *client = cls;
1549 struct TicketIteration *ti; 1564 struct TicketIteration *ti;
1550 1565
1551 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1566 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1552 "Received TICKET_ITERATION_START message\n"); 1567 "Received TICKET_ITERATION_START message\n");
1553 ti = GNUNET_new(struct TicketIteration); 1568 ti = GNUNET_new (struct TicketIteration);
1554 ti->r_id = ntohl(tis_msg->id); 1569 ti->r_id = ntohl (tis_msg->id);
1555 ti->client = client; 1570 ti->client = client;
1556 1571
1557 GNUNET_CONTAINER_DLL_insert(client->ticket_iter_head, 1572 GNUNET_CONTAINER_DLL_insert (client->ticket_iter_head,
1558 client->ticket_iter_tail, 1573 client->ticket_iter_tail,
1559 ti); 1574 ti);
1560 ti->iter 1575 ti->iter
1561 = RECLAIM_TICKETS_iteration_start(&tis_msg->identity, &ticket_iter_cb, ti); 1576 = RECLAIM_TICKETS_iteration_start (&tis_msg->identity, &ticket_iter_cb, ti);
1562 GNUNET_SERVICE_client_continue(client->client); 1577 GNUNET_SERVICE_client_continue (client->client);
1563} 1578}
1564 1579
1565 1580
@@ -1570,32 +1585,32 @@ handle_ticket_iteration_start(
1570 * @param tis_msg the stop message 1585 * @param tis_msg the stop message
1571 */ 1586 */
1572static void 1587static void
1573handle_ticket_iteration_stop(void *cls, 1588handle_ticket_iteration_stop (void *cls,
1574 const struct TicketIterationStopMessage *tis_msg) 1589 const struct TicketIterationStopMessage *tis_msg)
1575{ 1590{
1576 struct IdpClient *client = cls; 1591 struct IdpClient *client = cls;
1577 struct TicketIteration *ti; 1592 struct TicketIteration *ti;
1578 uint32_t rid; 1593 uint32_t rid;
1579 1594
1580 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1595 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1581 "Received `%s' message\n", 1596 "Received `%s' message\n",
1582 "TICKET_ITERATION_STOP"); 1597 "TICKET_ITERATION_STOP");
1583 rid = ntohl(tis_msg->id); 1598 rid = ntohl (tis_msg->id);
1584 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next) 1599 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
1585 if (ti->r_id == rid) 1600 if (ti->r_id == rid)
1586 break; 1601 break;
1587 if (NULL == ti) 1602 if (NULL == ti)
1588 { 1603 {
1589 GNUNET_break(0); 1604 GNUNET_break (0);
1590 GNUNET_SERVICE_client_drop(client->client); 1605 GNUNET_SERVICE_client_drop (client->client);
1591 return; 1606 return;
1592 } 1607 }
1593 RECLAIM_TICKETS_iteration_stop(ti->iter); 1608 RECLAIM_TICKETS_iteration_stop (ti->iter);
1594 GNUNET_CONTAINER_DLL_remove(client->ticket_iter_head, 1609 GNUNET_CONTAINER_DLL_remove (client->ticket_iter_head,
1595 client->ticket_iter_tail, 1610 client->ticket_iter_tail,
1596 ti); 1611 ti);
1597 GNUNET_free(ti); 1612 GNUNET_free (ti);
1598 GNUNET_SERVICE_client_continue(client->client); 1613 GNUNET_SERVICE_client_continue (client->client);
1599} 1614}
1600 1615
1601 1616
@@ -1606,27 +1621,27 @@ handle_ticket_iteration_stop(void *cls,
1606 * @param tis_msg the message 1621 * @param tis_msg the message
1607 */ 1622 */
1608static void 1623static void
1609handle_ticket_iteration_next(void *cls, 1624handle_ticket_iteration_next (void *cls,
1610 const struct TicketIterationNextMessage *tis_msg) 1625 const struct TicketIterationNextMessage *tis_msg)
1611{ 1626{
1612 struct IdpClient *client = cls; 1627 struct IdpClient *client = cls;
1613 struct TicketIteration *ti; 1628 struct TicketIteration *ti;
1614 uint32_t rid; 1629 uint32_t rid;
1615 1630
1616 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1631 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1617 "Received TICKET_ITERATION_NEXT message\n"); 1632 "Received TICKET_ITERATION_NEXT message\n");
1618 rid = ntohl(tis_msg->id); 1633 rid = ntohl (tis_msg->id);
1619 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next) 1634 for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
1620 if (ti->r_id == rid) 1635 if (ti->r_id == rid)
1621 break; 1636 break;
1622 if (NULL == ti) 1637 if (NULL == ti)
1623 { 1638 {
1624 GNUNET_break(0); 1639 GNUNET_break (0);
1625 GNUNET_SERVICE_client_drop(client->client); 1640 GNUNET_SERVICE_client_drop (client->client);
1626 return; 1641 return;
1627 } 1642 }
1628 RECLAIM_TICKETS_iteration_next(ti->iter); 1643 RECLAIM_TICKETS_iteration_next (ti->iter);
1629 GNUNET_SERVICE_client_continue(client->client); 1644 GNUNET_SERVICE_client_continue (client->client);
1630} 1645}
1631 1646
1632 1647
@@ -1638,28 +1653,28 @@ handle_ticket_iteration_next(void *cls,
1638 * @param server the service handle 1653 * @param server the service handle
1639 */ 1654 */
1640static void 1655static void
1641run(void *cls, 1656run (void *cls,
1642 const struct GNUNET_CONFIGURATION_Handle *c, 1657 const struct GNUNET_CONFIGURATION_Handle *c,
1643 struct GNUNET_SERVICE_Handle *server) 1658 struct GNUNET_SERVICE_Handle *server)
1644{ 1659{
1645 cfg = c; 1660 cfg = c;
1646 1661
1647 if (GNUNET_OK != RECLAIM_TICKETS_init(cfg)) 1662 if (GNUNET_OK != RECLAIM_TICKETS_init (cfg))
1648 { 1663 {
1649 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1664 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1650 "Unable to initialize TICKETS subsystem.\n"); 1665 "Unable to initialize TICKETS subsystem.\n");
1651 GNUNET_SCHEDULER_shutdown(); 1666 GNUNET_SCHEDULER_shutdown ();
1652 return; 1667 return;
1653 } 1668 }
1654 // Connect to identity and namestore services 1669 // Connect to identity and namestore services
1655 nsh = GNUNET_NAMESTORE_connect(cfg); 1670 nsh = GNUNET_NAMESTORE_connect (cfg);
1656 if (NULL == nsh) 1671 if (NULL == nsh)
1657 { 1672 {
1658 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, 1673 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
1659 "error connecting to namestore"); 1674 "error connecting to namestore");
1660 } 1675 }
1661 1676
1662 GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); 1677 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
1663} 1678}
1664 1679
1665 1680
@@ -1671,17 +1686,17 @@ run(void *cls,
1671 * @param app_ctx @a client 1686 * @param app_ctx @a client
1672 */ 1687 */
1673static void 1688static void
1674client_disconnect_cb(void *cls, 1689client_disconnect_cb (void *cls,
1675 struct GNUNET_SERVICE_Client *client, 1690 struct GNUNET_SERVICE_Client *client,
1676 void *app_ctx) 1691 void *app_ctx)
1677{ 1692{
1678 struct IdpClient *idp = app_ctx; 1693 struct IdpClient *idp = app_ctx;
1679 1694
1680 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); 1695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
1681 GNUNET_CONTAINER_DLL_remove(client_list_head, 1696 GNUNET_CONTAINER_DLL_remove (client_list_head,
1682 client_list_tail, 1697 client_list_tail,
1683 idp); 1698 idp);
1684 cleanup_client(idp); 1699 cleanup_client (idp);
1685} 1700}
1686 1701
1687 1702
@@ -1694,19 +1709,19 @@ client_disconnect_cb(void *cls,
1694 * @return internal namestore client structure for this client 1709 * @return internal namestore client structure for this client
1695 */ 1710 */
1696static void * 1711static void *
1697client_connect_cb(void *cls, 1712client_connect_cb (void *cls,
1698 struct GNUNET_SERVICE_Client *client, 1713 struct GNUNET_SERVICE_Client *client,
1699 struct GNUNET_MQ_Handle *mq) 1714 struct GNUNET_MQ_Handle *mq)
1700{ 1715{
1701 struct IdpClient *idp; 1716 struct IdpClient *idp;
1702 1717
1703 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client); 1718 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1704 idp = GNUNET_new(struct IdpClient); 1719 idp = GNUNET_new (struct IdpClient);
1705 idp->client = client; 1720 idp->client = client;
1706 idp->mq = mq; 1721 idp->mq = mq;
1707 GNUNET_CONTAINER_DLL_insert(client_list_head, 1722 GNUNET_CONTAINER_DLL_insert (client_list_head,
1708 client_list_tail, 1723 client_list_tail,
1709 idp); 1724 idp);
1710 return idp; 1725 return idp;
1711} 1726}
1712 1727
@@ -1714,57 +1729,57 @@ client_connect_cb(void *cls,
1714/** 1729/**
1715 * Define "main" method using service macro. 1730 * Define "main" method using service macro.
1716 */ 1731 */
1717GNUNET_SERVICE_MAIN( 1732GNUNET_SERVICE_MAIN (
1718 "reclaim", 1733 "reclaim",
1719 GNUNET_SERVICE_OPTION_NONE, 1734 GNUNET_SERVICE_OPTION_NONE,
1720 &run, 1735 &run,
1721 &client_connect_cb, 1736 &client_connect_cb,
1722 &client_disconnect_cb, 1737 &client_disconnect_cb,
1723 NULL, 1738 NULL,
1724 GNUNET_MQ_hd_var_size(attribute_store_message, 1739 GNUNET_MQ_hd_var_size (attribute_store_message,
1725 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, 1740 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE,
1726 struct AttributeStoreMessage, 1741 struct AttributeStoreMessage,
1727 NULL), 1742 NULL),
1728 GNUNET_MQ_hd_var_size(attribute_delete_message, 1743 GNUNET_MQ_hd_var_size (attribute_delete_message,
1729 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, 1744 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE,
1730 struct AttributeDeleteMessage, 1745 struct AttributeDeleteMessage,
1731 NULL), 1746 NULL),
1732 GNUNET_MQ_hd_fixed_size( 1747 GNUNET_MQ_hd_fixed_size (
1733 iteration_start, 1748 iteration_start,
1734 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, 1749 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START,
1735 struct AttributeIterationStartMessage, 1750 struct AttributeIterationStartMessage,
1736 NULL), 1751 NULL),
1737 GNUNET_MQ_hd_fixed_size(iteration_next, 1752 GNUNET_MQ_hd_fixed_size (iteration_next,
1738 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, 1753 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT,
1739 struct AttributeIterationNextMessage, 1754 struct AttributeIterationNextMessage,
1740 NULL), 1755 NULL),
1741 GNUNET_MQ_hd_fixed_size(iteration_stop, 1756 GNUNET_MQ_hd_fixed_size (iteration_stop,
1742 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, 1757 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP,
1743 struct AttributeIterationStopMessage, 1758 struct AttributeIterationStopMessage,
1744 NULL), 1759 NULL),
1745 GNUNET_MQ_hd_var_size(issue_ticket_message, 1760 GNUNET_MQ_hd_var_size (issue_ticket_message,
1746 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, 1761 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET,
1747 struct IssueTicketMessage, 1762 struct IssueTicketMessage,
1748 NULL), 1763 NULL),
1749 GNUNET_MQ_hd_var_size(consume_ticket_message, 1764 GNUNET_MQ_hd_var_size (consume_ticket_message,
1750 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, 1765 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET,
1751 struct ConsumeTicketMessage, 1766 struct ConsumeTicketMessage,
1752 NULL), 1767 NULL),
1753 GNUNET_MQ_hd_fixed_size(ticket_iteration_start, 1768 GNUNET_MQ_hd_fixed_size (ticket_iteration_start,
1754 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, 1769 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START,
1755 struct TicketIterationStartMessage, 1770 struct TicketIterationStartMessage,
1756 NULL), 1771 NULL),
1757 GNUNET_MQ_hd_fixed_size(ticket_iteration_next, 1772 GNUNET_MQ_hd_fixed_size (ticket_iteration_next,
1758 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, 1773 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT,
1759 struct TicketIterationNextMessage, 1774 struct TicketIterationNextMessage,
1760 NULL), 1775 NULL),
1761 GNUNET_MQ_hd_fixed_size(ticket_iteration_stop, 1776 GNUNET_MQ_hd_fixed_size (ticket_iteration_stop,
1762 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, 1777 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP,
1763 struct TicketIterationStopMessage, 1778 struct TicketIterationStopMessage,
1764 NULL), 1779 NULL),
1765 GNUNET_MQ_hd_var_size(revoke_ticket_message, 1780 GNUNET_MQ_hd_var_size (revoke_ticket_message,
1766 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, 1781 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET,
1767 struct RevokeTicketMessage, 1782 struct RevokeTicketMessage,
1768 NULL), 1783 NULL),
1769 GNUNET_MQ_handler_end()); 1784 GNUNET_MQ_handler_end ());
1770/* end of gnunet-service-reclaim.c */ 1785/* end of gnunet-service-reclaim.c */
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index b38a5eb25..57c9e2167 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -44,7 +44,8 @@ struct ParallelLookup;
44/** 44/**
45 * A reference to a ticket stored in GNS 45 * A reference to a ticket stored in GNS
46 */ 46 */
47struct TicketReference { 47struct TicketReference
48{
48 /** 49 /**
49 * DLL 50 * DLL
50 */ 51 */
@@ -70,7 +71,8 @@ struct TicketReference {
70/** 71/**
71 * Handle to a consume operation 72 * Handle to a consume operation
72 */ 73 */
73struct RECLAIM_TICKETS_ConsumeHandle { 74struct RECLAIM_TICKETS_ConsumeHandle
75{
74 /** 76 /**
75 * Ticket 77 * Ticket
76 */ 78 */
@@ -131,7 +133,8 @@ struct RECLAIM_TICKETS_ConsumeHandle {
131/** 133/**
132 * Handle for a parallel GNS lookup job 134 * Handle for a parallel GNS lookup job
133 */ 135 */
134struct ParallelLookup { 136struct ParallelLookup
137{
135 /* DLL */ 138 /* DLL */
136 struct ParallelLookup *next; 139 struct ParallelLookup *next;
137 140
@@ -157,7 +160,8 @@ struct ParallelLookup {
157/** 160/**
158 * Ticket issue request handle 161 * Ticket issue request handle
159 */ 162 */
160struct TicketIssueHandle { 163struct TicketIssueHandle
164{
161 /** 165 /**
162 * Attributes to issue 166 * Attributes to issue
163 */ 167 */
@@ -198,7 +202,8 @@ struct TicketIssueHandle {
198/** 202/**
199 * Ticket iterator 203 * Ticket iterator
200 */ 204 */
201struct RECLAIM_TICKETS_Iterator { 205struct RECLAIM_TICKETS_Iterator
206{
202 /** 207 /**
203 * Namestore queue entry 208 * Namestore queue entry
204 */ 209 */
@@ -216,7 +221,8 @@ struct RECLAIM_TICKETS_Iterator {
216}; 221};
217 222
218 223
219struct RevokedAttributeEntry { 224struct RevokedAttributeEntry
225{
220 /** 226 /**
221 * DLL 227 * DLL
222 */ 228 */
@@ -242,7 +248,8 @@ struct RevokedAttributeEntry {
242/** 248/**
243 * Ticket revocation request handle 249 * Ticket revocation request handle
244 */ 250 */
245struct RECLAIM_TICKETS_RevokeHandle { 251struct RECLAIM_TICKETS_RevokeHandle
252{
246 /** 253 /**
247 * Issuer Key 254 * Issuer Key
248 */ 255 */
@@ -330,32 +337,32 @@ static struct GNUNET_STATISTICS_Handle *stats;
330 * @param rh the ticket revocation handle 337 * @param rh the ticket revocation handle
331 */ 338 */
332static void 339static void
333cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh) 340cleanup_rvk (struct RECLAIM_TICKETS_RevokeHandle *rh)
334{ 341{
335 struct RevokedAttributeEntry *ae; 342 struct RevokedAttributeEntry *ae;
336 struct TicketRecordsEntry *le; 343 struct TicketRecordsEntry *le;
337 344
338 if (NULL != rh->ns_qe) 345 if (NULL != rh->ns_qe)
339 GNUNET_NAMESTORE_cancel(rh->ns_qe); 346 GNUNET_NAMESTORE_cancel (rh->ns_qe);
340 if (NULL != rh->ns_it) 347 if (NULL != rh->ns_it)
341 GNUNET_NAMESTORE_zone_iteration_stop(rh->ns_it); 348 GNUNET_NAMESTORE_zone_iteration_stop (rh->ns_it);
342 while (NULL != (ae = rh->attrs_head)) 349 while (NULL != (ae = rh->attrs_head))
343 { 350 {
344 GNUNET_CONTAINER_DLL_remove(rh->attrs_head, rh->attrs_tail, ae); 351 GNUNET_CONTAINER_DLL_remove (rh->attrs_head, rh->attrs_tail, ae);
345 GNUNET_free(ae); 352 GNUNET_free (ae);
346 } 353 }
347 while (NULL != (le = rh->tickets_to_update_head)) 354 while (NULL != (le = rh->tickets_to_update_head))
348 { 355 {
349 GNUNET_CONTAINER_DLL_remove(rh->tickets_to_update_head, 356 GNUNET_CONTAINER_DLL_remove (rh->tickets_to_update_head,
350 rh->tickets_to_update_head, 357 rh->tickets_to_update_head,
351 le); 358 le);
352 if (NULL != le->data) 359 if (NULL != le->data)
353 GNUNET_free(le->data); 360 GNUNET_free (le->data);
354 if (NULL != le->label) 361 if (NULL != le->label)
355 GNUNET_free(le->label); 362 GNUNET_free (le->label);
356 GNUNET_free(le); 363 GNUNET_free (le);
357 } 364 }
358 GNUNET_free(rh); 365 GNUNET_free (rh);
359} 366}
360 367
361 368
@@ -366,7 +373,7 @@ cleanup_rvk(struct RECLAIM_TICKETS_RevokeHandle *rh)
366 * @param cls handle to the operation 373 * @param cls handle to the operation
367 */ 374 */
368static void 375static void
369process_tickets(void *cls); 376process_tickets (void *cls);
370 377
371 378
372/** 379/**
@@ -378,12 +385,12 @@ process_tickets(void *cls);
378 * @param emsg (NULL on success) 385 * @param emsg (NULL on success)
379 */ 386 */
380static void 387static void
381ticket_processed(void *cls, int32_t success, const char *emsg) 388ticket_processed (void *cls, int32_t success, const char *emsg)
382{ 389{
383 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 390 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
384 391
385 rvk->ns_qe = NULL; 392 rvk->ns_qe = NULL;
386 GNUNET_SCHEDULER_add_now(&process_tickets, rvk); 393 GNUNET_SCHEDULER_add_now (&process_tickets, rvk);
387} 394}
388 395
389 396
@@ -393,57 +400,57 @@ ticket_processed(void *cls, int32_t success, const char *emsg)
393 * @param cls handle to the operation 400 * @param cls handle to the operation
394 */ 401 */
395static void 402static void
396process_tickets(void *cls) 403process_tickets (void *cls)
397{ 404{
398 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 405 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
399 struct TicketRecordsEntry *le; 406 struct TicketRecordsEntry *le;
400 struct RevokedAttributeEntry *ae; 407 struct RevokedAttributeEntry *ae;
401 408
402 if (NULL == rvk->tickets_to_update_head) 409 if (NULL == rvk->tickets_to_update_head)
403 { 410 {
404 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 411 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
405 "Finished updatding tickets, success\n"); 412 "Finished updatding tickets, success\n");
406 rvk->cb(rvk->cb_cls, GNUNET_OK); 413 rvk->cb (rvk->cb_cls, GNUNET_OK);
407 cleanup_rvk(rvk); 414 cleanup_rvk (rvk);
408 return; 415 return;
409 } 416 }
410 le = rvk->tickets_to_update_head; 417 le = rvk->tickets_to_update_head;
411 GNUNET_CONTAINER_DLL_remove(rvk->tickets_to_update_head, 418 GNUNET_CONTAINER_DLL_remove (rvk->tickets_to_update_head,
412 rvk->tickets_to_update_tail, 419 rvk->tickets_to_update_tail,
413 le); 420 le);
414 struct GNUNET_GNSRECORD_Data rd[le->rd_count]; 421 struct GNUNET_GNSRECORD_Data rd[le->rd_count];
415 if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize(le->data_size, 422 if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize (le->data_size,
416 le->data, 423 le->data,
417 le->rd_count, 424 le->rd_count,
418 rd)) 425 rd))
419 { 426 {
420 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 427 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
421 "Unable to deserialize ticket record(s)\n"); 428 "Unable to deserialize ticket record(s)\n");
422 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 429 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
423 cleanup_rvk(rvk); 430 cleanup_rvk (rvk);
424 return; 431 return;
425 } 432 }
426 for (int i = 0; i < le->rd_count; i++) 433 for (int i = 0; i < le->rd_count; i++)
434 {
435 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
436 continue;
437 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
427 { 438 {
428 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 439 if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t)))
429 continue; 440 continue;
430 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) 441 rd[i].data = &ae->new_id;
431 {
432 if (0 != memcmp(rd[i].data, &ae->old_id, sizeof(uint64_t)))
433 continue;
434 rd[i].data = &ae->new_id;
435 }
436 } 442 }
437 rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 443 }
438 &rvk->identity, 444 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
439 le->label, 445 &rvk->identity,
440 le->rd_count, 446 le->label,
441 rd, 447 le->rd_count,
442 &ticket_processed, 448 rd,
443 rvk); 449 &ticket_processed,
444 GNUNET_free(le->label); 450 rvk);
445 GNUNET_free(le->data); 451 GNUNET_free (le->label);
446 GNUNET_free(le); 452 GNUNET_free (le->data);
453 GNUNET_free (le);
447} 454}
448 455
449 456
@@ -453,12 +460,12 @@ process_tickets(void *cls)
453 * @param cls handle to the operation 460 * @param cls handle to the operation
454 */ 461 */
455static void 462static void
456rvk_ticket_update_finished(void *cls) 463rvk_ticket_update_finished (void *cls)
457{ 464{
458 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 465 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
459 466
460 rvk->ns_it = NULL; 467 rvk->ns_it = NULL;
461 GNUNET_SCHEDULER_add_now(&process_tickets, rvk); 468 GNUNET_SCHEDULER_add_now (&process_tickets, rvk);
462} 469}
463 470
464 471
@@ -473,11 +480,11 @@ rvk_ticket_update_finished(void *cls)
473 * @param rd record set 480 * @param rd record set
474 */ 481 */
475static void 482static void
476rvk_ticket_update(void *cls, 483rvk_ticket_update (void *cls,
477 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 484 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
478 const char *label, 485 const char *label,
479 unsigned int rd_count, 486 unsigned int rd_count,
480 const struct GNUNET_GNSRECORD_Data *rd) 487 const struct GNUNET_GNSRECORD_Data *rd)
481{ 488{
482 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 489 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
483 struct TicketRecordsEntry *le; 490 struct TicketRecordsEntry *le;
@@ -486,32 +493,32 @@ rvk_ticket_update(void *cls,
486 493
487 /** Let everything point to the old record **/ 494 /** Let everything point to the old record **/
488 for (int i = 0; i < rd_count; i++) 495 for (int i = 0; i < rd_count; i++)
496 {
497 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
498 continue;
499 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
489 { 500 {
490 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 501 if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t)))
491 continue; 502 continue;
492 for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) 503 has_changed = GNUNET_YES;
493 { 504 break;
494 if (0 != memcmp(rd[i].data, &ae->old_id, sizeof(uint64_t)))
495 continue;
496 has_changed = GNUNET_YES;
497 break;
498 }
499 if (GNUNET_YES == has_changed)
500 break;
501 } 505 }
506 if (GNUNET_YES == has_changed)
507 break;
508 }
502 if (GNUNET_YES == has_changed) 509 if (GNUNET_YES == has_changed)
503 { 510 {
504 le = GNUNET_new(struct TicketRecordsEntry); 511 le = GNUNET_new (struct TicketRecordsEntry);
505 le->data_size = GNUNET_GNSRECORD_records_get_size(rd_count, rd); 512 le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
506 le->data = GNUNET_malloc(le->data_size); 513 le->data = GNUNET_malloc (le->data_size);
507 le->rd_count = rd_count; 514 le->rd_count = rd_count;
508 le->label = GNUNET_strdup(label); 515 le->label = GNUNET_strdup (label);
509 GNUNET_GNSRECORD_records_serialize(rd_count, rd, le->data_size, le->data); 516 GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
510 GNUNET_CONTAINER_DLL_insert(rvk->tickets_to_update_head, 517 GNUNET_CONTAINER_DLL_insert (rvk->tickets_to_update_head,
511 rvk->tickets_to_update_tail, 518 rvk->tickets_to_update_tail,
512 le); 519 le);
513 } 520 }
514 GNUNET_NAMESTORE_zone_iterator_next(rvk->ns_it, 1); 521 GNUNET_NAMESTORE_zone_iterator_next (rvk->ns_it, 1);
515} 522}
516 523
517 524
@@ -521,16 +528,16 @@ rvk_ticket_update(void *cls,
521 * @param cls handle to the operation 528 * @param cls handle to the operation
522 */ 529 */
523static void 530static void
524rvk_ns_iter_err(void *cls) 531rvk_ns_iter_err (void *cls)
525{ 532{
526 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 533 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
527 534
528 rvk->ns_it = NULL; 535 rvk->ns_it = NULL;
529 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 536 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
530 "Namestore error on revocation (id=%" PRIu64 "\n", 537 "Namestore error on revocation (id=%" PRIu64 "\n",
531 rvk->move_attr->old_id); 538 rvk->move_attr->old_id);
532 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 539 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
533 cleanup_rvk(rvk); 540 cleanup_rvk (rvk);
534} 541}
535 542
536 543
@@ -540,16 +547,16 @@ rvk_ns_iter_err(void *cls)
540 * @param cls handle to the operation 547 * @param cls handle to the operation
541 */ 548 */
542static void 549static void
543rvk_ns_err(void *cls) 550rvk_ns_err (void *cls)
544{ 551{
545 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 552 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
546 553
547 rvk->ns_qe = NULL; 554 rvk->ns_qe = NULL;
548 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 555 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
549 "Namestore error on revocation (id=%" PRIu64 "\n", 556 "Namestore error on revocation (id=%" PRIu64 "\n",
550 rvk->move_attr->old_id); 557 rvk->move_attr->old_id);
551 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 558 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
552 cleanup_rvk(rvk); 559 cleanup_rvk (rvk);
553} 560}
554 561
555 562
@@ -563,7 +570,7 @@ rvk_ns_err(void *cls)
563 * @param rvk handle to the operation 570 * @param rvk handle to the operation
564 */ 571 */
565static void 572static void
566move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh); 573move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rh);
567 574
568 575
569/** 576/**
@@ -572,9 +579,9 @@ move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rh);
572 * @param cls handle to the operation. 579 * @param cls handle to the operation.
573 */ 580 */
574static void 581static void
575move_attrs_cont(void *cls) 582move_attrs_cont (void *cls)
576{ 583{
577 move_attrs((struct RECLAIM_TICKETS_RevokeHandle *)cls); 584 move_attrs ((struct RECLAIM_TICKETS_RevokeHandle *) cls);
578} 585}
579 586
580 587
@@ -587,22 +594,22 @@ move_attrs_cont(void *cls)
587 * @param emsg error message (NULL on success) 594 * @param emsg error message (NULL on success)
588 */ 595 */
589static void 596static void
590del_attr_finished(void *cls, int32_t success, const char *emsg) 597del_attr_finished (void *cls, int32_t success, const char *emsg)
591{ 598{
592 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 599 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
593 600
594 rvk->ns_qe = NULL; 601 rvk->ns_qe = NULL;
595 if (GNUNET_SYSERR == success) 602 if (GNUNET_SYSERR == success)
596 { 603 {
597 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 604 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
598 "Error removing attribute: %s\n", 605 "Error removing attribute: %s\n",
599 emsg); 606 emsg);
600 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 607 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
601 cleanup_rvk(rvk); 608 cleanup_rvk (rvk);
602 return; 609 return;
603 } 610 }
604 rvk->move_attr = rvk->move_attr->next; 611 rvk->move_attr = rvk->move_attr->next;
605 GNUNET_SCHEDULER_add_now(&move_attrs_cont, rvk); 612 GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk);
606} 613}
607 614
608 615
@@ -616,31 +623,31 @@ del_attr_finished(void *cls, int32_t success, const char *emsg)
616 * @param emsg error message (NULL on success) 623 * @param emsg error message (NULL on success)
617 */ 624 */
618static void 625static void
619move_attr_finished(void *cls, int32_t success, const char *emsg) 626move_attr_finished (void *cls, int32_t success, const char *emsg)
620{ 627{
621 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 628 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
622 char *label; 629 char *label;
623 630
624 rvk->ns_qe = NULL; 631 rvk->ns_qe = NULL;
625 if (GNUNET_SYSERR == success) 632 if (GNUNET_SYSERR == success)
626 { 633 {
627 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg); 634 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg);
628 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 635 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
629 cleanup_rvk(rvk); 636 cleanup_rvk (rvk);
630 return; 637 return;
631 } 638 }
632 label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->old_id, 639 label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id,
633 sizeof(uint64_t)); 640 sizeof(uint64_t));
634 GNUNET_assert(NULL != label); 641 GNUNET_assert (NULL != label);
635 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); 642 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label);
636 rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 643 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
637 &rvk->identity, 644 &rvk->identity,
638 label, 645 label,
639 0, 646 0,
640 NULL, 647 NULL,
641 &del_attr_finished, 648 &del_attr_finished,
642 rvk); 649 rvk);
643 GNUNET_free(label); 650 GNUNET_free (label);
644} 651}
645 652
646 653
@@ -654,11 +661,11 @@ move_attr_finished(void *cls, int32_t success, const char *emsg)
654 * @param rd record set (the attribute) 661 * @param rd record set (the attribute)
655 */ 662 */
656static void 663static void
657rvk_move_attr_cb(void *cls, 664rvk_move_attr_cb (void *cls,
658 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 665 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
659 const char *label, 666 const char *label,
660 unsigned int rd_count, 667 unsigned int rd_count,
661 const struct GNUNET_GNSRECORD_Data *rd) 668 const struct GNUNET_GNSRECORD_Data *rd)
662{ 669{
663 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 670 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
664 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 671 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
@@ -669,44 +676,44 @@ rvk_move_attr_cb(void *cls,
669 676
670 rvk->ns_qe = NULL; 677 rvk->ns_qe = NULL;
671 if (0 == rd_count) 678 if (0 == rd_count)
672 { 679 {
673 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 680 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
674 "The attribute %s no longer exists!\n", 681 "The attribute %s no longer exists!\n",
675 label); 682 label);
676 le = rvk->move_attr; 683 le = rvk->move_attr;
677 rvk->move_attr = le->next; 684 rvk->move_attr = le->next;
678 GNUNET_CONTAINER_DLL_remove(rvk->attrs_head, rvk->attrs_tail, le); 685 GNUNET_CONTAINER_DLL_remove (rvk->attrs_head, rvk->attrs_tail, le);
679 GNUNET_free(le); 686 GNUNET_free (le);
680 GNUNET_SCHEDULER_add_now(&move_attrs_cont, rvk); 687 GNUNET_SCHEDULER_add_now (&move_attrs_cont, rvk);
681 return; 688 return;
682 } 689 }
683 /** find a new place for this attribute **/ 690 /** find a new place for this attribute **/
684 rvk->move_attr->new_id = 691 rvk->move_attr->new_id =
685 GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); 692 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX);
686 new_rd = *rd; 693 new_rd = *rd;
687 claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize(rd->data, rd->data_size); 694 claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size);
688 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
689 "Attribute to update: Name=%s, ID=%" PRIu64 "\n", 696 "Attribute to update: Name=%s, ID=%" PRIu64 "\n",
690 claim->name, 697 claim->name,
691 claim->id); 698 claim->id);
692 claim->id = rvk->move_attr->new_id; 699 claim->id = rvk->move_attr->new_id;
693 new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(claim); 700 new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim);
694 attr_data = GNUNET_malloc(rd->data_size); 701 attr_data = GNUNET_malloc (rd->data_size);
695 new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize(claim, attr_data); 702 new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, attr_data);
696 new_rd.data = attr_data; 703 new_rd.data = attr_data;
697 new_label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->new_id, 704 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
698 sizeof(uint64_t)); 705 sizeof(uint64_t));
699 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); 706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
700 rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 707 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
701 &rvk->identity, 708 &rvk->identity,
702 new_label, 709 new_label,
703 1, 710 1,
704 &new_rd, 711 &new_rd,
705 &move_attr_finished, 712 &move_attr_finished,
706 rvk); 713 rvk);
707 GNUNET_free(new_label); 714 GNUNET_free (new_label);
708 GNUNET_free(claim); 715 GNUNET_free (claim);
709 GNUNET_free(attr_data); 716 GNUNET_free (attr_data);
710} 717}
711 718
712 719
@@ -719,36 +726,36 @@ rvk_move_attr_cb(void *cls,
719 * @param rvk handle to the operation 726 * @param rvk handle to the operation
720 */ 727 */
721static void 728static void
722move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rvk) 729move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk)
723{ 730{
724 char *label; 731 char *label;
725 732
726 if (NULL == rvk->move_attr) 733 if (NULL == rvk->move_attr)
727 { 734 {
728 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n"); 735 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n");
729 rvk->ns_it = 736 rvk->ns_it =
730 GNUNET_NAMESTORE_zone_iteration_start(nsh, 737 GNUNET_NAMESTORE_zone_iteration_start (nsh,
731 &rvk->identity, 738 &rvk->identity,
732 &rvk_ns_iter_err, 739 &rvk_ns_iter_err,
733 rvk, 740 rvk,
734 &rvk_ticket_update, 741 &rvk_ticket_update,
735 rvk, 742 rvk,
736 &rvk_ticket_update_finished, 743 &rvk_ticket_update_finished,
737 rvk); 744 rvk);
738 return; 745 return;
739 } 746 }
740 label = GNUNET_STRINGS_data_to_string_alloc(&rvk->move_attr->old_id, 747 label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id,
741 sizeof(uint64_t)); 748 sizeof(uint64_t));
742 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label); 749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label);
743 750
744 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup(nsh, 751 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
745 &rvk->identity, 752 &rvk->identity,
746 label, 753 label,
747 &rvk_ns_err, 754 &rvk_ns_err,
748 rvk, 755 rvk,
749 &rvk_move_attr_cb, 756 &rvk_move_attr_cb,
750 rvk); 757 rvk);
751 GNUNET_free(label); 758 GNUNET_free (label);
752} 759}
753 760
754 761
@@ -764,29 +771,29 @@ move_attrs(struct RECLAIM_TICKETS_RevokeHandle *rvk)
764 * @param emsg error message (NULL on success) 771 * @param emsg error message (NULL on success)
765 */ 772 */
766static void 773static void
767remove_ticket_cont(void *cls, int32_t success, const char *emsg) 774remove_ticket_cont (void *cls, int32_t success, const char *emsg)
768{ 775{
769 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 776 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
770 777
771 rvk->ns_qe = NULL; 778 rvk->ns_qe = NULL;
772 if (GNUNET_SYSERR == success) 779 if (GNUNET_SYSERR == success)
773 { 780 {
774 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); 781 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
775 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 782 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
776 cleanup_rvk(rvk); 783 cleanup_rvk (rvk);
777 return; 784 return;
778 } 785 }
779 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n"); 786 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n");
780 if (0 == rvk->ticket_attrs) 787 if (0 == rvk->ticket_attrs)
781 { 788 {
782 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 789 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
783 "No attributes to move... strange\n"); 790 "No attributes to move... strange\n");
784 rvk->cb(rvk->cb_cls, GNUNET_OK); 791 rvk->cb (rvk->cb_cls, GNUNET_OK);
785 cleanup_rvk(rvk); 792 cleanup_rvk (rvk);
786 return; 793 return;
787 } 794 }
788 rvk->move_attr = rvk->attrs_head; 795 rvk->move_attr = rvk->attrs_head;
789 move_attrs(rvk); 796 move_attrs (rvk);
790} 797}
791 798
792 799
@@ -801,11 +808,11 @@ remove_ticket_cont(void *cls, int32_t success, const char *emsg)
801 * @param rd record set 808 * @param rd record set
802 */ 809 */
803static void 810static void
804revoke_attrs_cb(void *cls, 811revoke_attrs_cb (void *cls,
805 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 812 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
806 const char *label, 813 const char *label,
807 unsigned int rd_count, 814 unsigned int rd_count,
808 const struct GNUNET_GNSRECORD_Data *rd) 815 const struct GNUNET_GNSRECORD_Data *rd)
809 816
810{ 817{
811 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 818 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
@@ -817,23 +824,23 @@ revoke_attrs_cb(void *cls,
817 * We need it later. 824 * We need it later.
818 */ 825 */
819 for (int i = 0; i < rd_count; i++) 826 for (int i = 0; i < rd_count; i++)
820 { 827 {
821 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 828 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
822 continue; 829 continue;
823 le = GNUNET_new(struct RevokedAttributeEntry); 830 le = GNUNET_new (struct RevokedAttributeEntry);
824 le->old_id = *((uint64_t *)rd[i].data); 831 le->old_id = *((uint64_t *) rd[i].data);
825 GNUNET_CONTAINER_DLL_insert(rvk->attrs_head, rvk->attrs_tail, le); 832 GNUNET_CONTAINER_DLL_insert (rvk->attrs_head, rvk->attrs_tail, le);
826 rvk->ticket_attrs++; 833 rvk->ticket_attrs++;
827 } 834 }
828 835
829 /** Remove attribute references **/ 836 /** Remove attribute references **/
830 rvk->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 837 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
831 &rvk->identity, 838 &rvk->identity,
832 label, 839 label,
833 0, 840 0,
834 NULL, 841 NULL,
835 &remove_ticket_cont, 842 &remove_ticket_cont,
836 rvk); 843 rvk);
837} 844}
838 845
839 846
@@ -843,12 +850,12 @@ revoke_attrs_cb(void *cls,
843 * @param cls handle to the operation 850 * @param cls handle to the operation
844 */ 851 */
845static void 852static void
846rvk_attrs_err_cb(void *cls) 853rvk_attrs_err_cb (void *cls)
847{ 854{
848 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 855 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
849 856
850 rvk->cb(rvk->cb_cls, GNUNET_SYSERR); 857 rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
851 cleanup_rvk(rvk); 858 cleanup_rvk (rvk);
852} 859}
853 860
854 861
@@ -864,31 +871,31 @@ rvk_attrs_err_cb(void *cls)
864 * @return handle to the operation 871 * @return handle to the operation
865 */ 872 */
866struct RECLAIM_TICKETS_RevokeHandle * 873struct RECLAIM_TICKETS_RevokeHandle *
867RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, 874RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket,
868 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 875 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
869 RECLAIM_TICKETS_RevokeCallback cb, 876 RECLAIM_TICKETS_RevokeCallback cb,
870 void *cb_cls) 877 void *cb_cls)
871{ 878{
872 struct RECLAIM_TICKETS_RevokeHandle *rvk; 879 struct RECLAIM_TICKETS_RevokeHandle *rvk;
873 char *label; 880 char *label;
874 881
875 rvk = GNUNET_new(struct RECLAIM_TICKETS_RevokeHandle); 882 rvk = GNUNET_new (struct RECLAIM_TICKETS_RevokeHandle);
876 rvk->cb = cb; 883 rvk->cb = cb;
877 rvk->cb_cls = cb_cls; 884 rvk->cb_cls = cb_cls;
878 rvk->identity = *identity; 885 rvk->identity = *identity;
879 rvk->ticket = *ticket; 886 rvk->ticket = *ticket;
880 GNUNET_CRYPTO_ecdsa_key_get_public(&rvk->identity, &rvk->ticket.identity); 887 GNUNET_CRYPTO_ecdsa_key_get_public (&rvk->identity, &rvk->ticket.identity);
881 /** Get shared attributes **/ 888 /** Get shared attributes **/
882 label = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t)); 889 label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
883 GNUNET_assert(NULL != label); 890 GNUNET_assert (NULL != label);
884 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup(nsh, 891 rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
885 identity, 892 identity,
886 label, 893 label,
887 &rvk_attrs_err_cb, 894 &rvk_attrs_err_cb,
888 rvk, 895 rvk,
889 &revoke_attrs_cb, 896 &revoke_attrs_cb,
890 rvk); 897 rvk);
891 GNUNET_free(label); 898 GNUNET_free (label);
892 return rvk; 899 return rvk;
893} 900}
894 901
@@ -899,10 +906,10 @@ RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket,
899 * @param rh handle to the operation 906 * @param rh handle to the operation
900 */ 907 */
901void 908void
902RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh) 909RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh)
903{ 910{
904 GNUNET_assert(NULL != rh); 911 GNUNET_assert (NULL != rh);
905 cleanup_rvk(rh); 912 cleanup_rvk (rh);
906} 913}
907 914
908 915
@@ -916,28 +923,28 @@ RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh)
916 * @param cth the handle to clean up 923 * @param cth the handle to clean up
917 */ 924 */
918static void 925static void
919cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth) 926cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth)
920{ 927{
921 struct ParallelLookup *lu; 928 struct ParallelLookup *lu;
922 929
923 if (NULL != cth->lookup_request) 930 if (NULL != cth->lookup_request)
924 GNUNET_GNS_lookup_cancel(cth->lookup_request); 931 GNUNET_GNS_lookup_cancel (cth->lookup_request);
925 if (NULL != cth->kill_task) 932 if (NULL != cth->kill_task)
926 GNUNET_SCHEDULER_cancel(cth->kill_task); 933 GNUNET_SCHEDULER_cancel (cth->kill_task);
927 while (NULL != (lu = cth->parallel_lookups_head)) 934 while (NULL != (lu = cth->parallel_lookups_head))
928 { 935 {
929 if (NULL != lu->lookup_request) 936 if (NULL != lu->lookup_request)
930 GNUNET_GNS_lookup_cancel(lu->lookup_request); 937 GNUNET_GNS_lookup_cancel (lu->lookup_request);
931 GNUNET_free_non_null(lu->label); 938 GNUNET_free_non_null (lu->label);
932 GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, 939 GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head,
933 cth->parallel_lookups_tail, 940 cth->parallel_lookups_tail,
934 lu); 941 lu);
935 GNUNET_free(lu); 942 GNUNET_free (lu);
936 } 943 }
937 944
938 if (NULL != cth->attrs) 945 if (NULL != cth->attrs)
939 GNUNET_RECLAIM_ATTRIBUTE_list_destroy(cth->attrs); 946 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (cth->attrs);
940 GNUNET_free(cth); 947 GNUNET_free (cth);
941} 948}
942 949
943 950
@@ -949,51 +956,51 @@ cleanup_cth(struct RECLAIM_TICKETS_ConsumeHandle *cth)
949 * @param rd record set 956 * @param rd record set
950 */ 957 */
951static void 958static void
952process_parallel_lookup_result(void *cls, 959process_parallel_lookup_result (void *cls,
953 uint32_t rd_count, 960 uint32_t rd_count,
954 const struct GNUNET_GNSRECORD_Data *rd) 961 const struct GNUNET_GNSRECORD_Data *rd)
955{ 962{
956 struct ParallelLookup *parallel_lookup = cls; 963 struct ParallelLookup *parallel_lookup = cls;
957 struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; 964 struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
958 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; 965 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le;
959 966
960 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 967 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
961 "Parallel lookup finished (count=%u)\n", 968 "Parallel lookup finished (count=%u)\n",
962 rd_count); 969 rd_count);
963 970
964 GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, 971 GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head,
965 cth->parallel_lookups_tail, 972 cth->parallel_lookups_tail,
966 parallel_lookup); 973 parallel_lookup);
967 GNUNET_free(parallel_lookup->label); 974 GNUNET_free (parallel_lookup->label);
968 975
969 GNUNET_STATISTICS_update(stats, 976 GNUNET_STATISTICS_update (stats,
970 "attribute_lookup_time_total", 977 "attribute_lookup_time_total",
971 GNUNET_TIME_absolute_get_duration( 978 GNUNET_TIME_absolute_get_duration (
972 parallel_lookup->lookup_start_time) 979 parallel_lookup->lookup_start_time)
973 .rel_value_us, 980 .rel_value_us,
974 GNUNET_YES); 981 GNUNET_YES);
975 GNUNET_STATISTICS_update(stats, "attribute_lookups_count", 1, GNUNET_YES); 982 GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES);
976 983
977 984
978 GNUNET_free(parallel_lookup); 985 GNUNET_free (parallel_lookup);
979 if (1 != rd_count) 986 if (1 != rd_count)
980 GNUNET_break(0); // FIXME: We should never find this. 987 GNUNET_break (0); // FIXME: We should never find this.
981 if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR) 988 if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR)
982 { 989 {
983 attr_le = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); 990 attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
984 attr_le->claim = 991 attr_le->claim =
985 GNUNET_RECLAIM_ATTRIBUTE_deserialize(rd->data, rd->data_size); 992 GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size);
986 GNUNET_CONTAINER_DLL_insert(cth->attrs->list_head, 993 GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head,
987 cth->attrs->list_tail, 994 cth->attrs->list_tail,
988 attr_le); 995 attr_le);
989 } 996 }
990 997
991 if (NULL != cth->parallel_lookups_head) 998 if (NULL != cth->parallel_lookups_head)
992 return; // Wait for more 999 return; // Wait for more
993 1000
994 /* Else we are done */ 1001 /* Else we are done */
995 cth->cb(cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); 1002 cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
996 cleanup_cth(cth); 1003 cleanup_cth (cth);
997} 1004}
998 1005
999 1006
@@ -1003,7 +1010,7 @@ process_parallel_lookup_result(void *cls,
1003 * @param cls handle to the operation 1010 * @param cls handle to the operation
1004 */ 1011 */
1005static void 1012static void
1006abort_parallel_lookups(void *cls) 1013abort_parallel_lookups (void *cls)
1007{ 1014{
1008 struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; 1015 struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1009 struct ParallelLookup *lu; 1016 struct ParallelLookup *lu;
@@ -1011,17 +1018,17 @@ abort_parallel_lookups(void *cls)
1011 1018
1012 cth->kill_task = NULL; 1019 cth->kill_task = NULL;
1013 for (lu = cth->parallel_lookups_head; NULL != lu;) 1020 for (lu = cth->parallel_lookups_head; NULL != lu;)
1014 { 1021 {
1015 GNUNET_GNS_lookup_cancel(lu->lookup_request); 1022 GNUNET_GNS_lookup_cancel (lu->lookup_request);
1016 GNUNET_free(lu->label); 1023 GNUNET_free (lu->label);
1017 tmp = lu->next; 1024 tmp = lu->next;
1018 GNUNET_CONTAINER_DLL_remove(cth->parallel_lookups_head, 1025 GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head,
1019 cth->parallel_lookups_tail, 1026 cth->parallel_lookups_tail,
1020 lu); 1027 lu);
1021 GNUNET_free(lu); 1028 GNUNET_free (lu);
1022 lu = tmp; 1029 lu = tmp;
1023 } 1030 }
1024 cth->cb(cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted"); 1031 cth->cb (cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted");
1025} 1032}
1026 1033
1027 1034
@@ -1035,9 +1042,9 @@ abort_parallel_lookups(void *cls)
1035 * @param rd record set 1042 * @param rd record set
1036 */ 1043 */
1037static void 1044static void
1038lookup_authz_cb(void *cls, 1045lookup_authz_cb (void *cls,
1039 uint32_t rd_count, 1046 uint32_t rd_count,
1040 const struct GNUNET_GNSRECORD_Data *rd) 1047 const struct GNUNET_GNSRECORD_Data *rd)
1041{ 1048{
1042 struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; 1049 struct RECLAIM_TICKETS_ConsumeHandle *cth = cls;
1043 struct ParallelLookup *parallel_lookup; 1050 struct ParallelLookup *parallel_lookup;
@@ -1045,56 +1052,56 @@ lookup_authz_cb(void *cls,
1045 1052
1046 cth->lookup_request = NULL; 1053 cth->lookup_request = NULL;
1047 1054
1048 GNUNET_STATISTICS_update(stats, 1055 GNUNET_STATISTICS_update (stats,
1049 "reclaim_authz_lookup_time_total", 1056 "reclaim_authz_lookup_time_total",
1050 GNUNET_TIME_absolute_get_duration( 1057 GNUNET_TIME_absolute_get_duration (
1051 cth->lookup_start_time) 1058 cth->lookup_start_time)
1052 .rel_value_us, 1059 .rel_value_us,
1053 GNUNET_YES); 1060 GNUNET_YES);
1054 GNUNET_STATISTICS_update(stats, 1061 GNUNET_STATISTICS_update (stats,
1055 "reclaim_authz_lookups_count", 1062 "reclaim_authz_lookups_count",
1056 1, 1063 1,
1057 GNUNET_YES); 1064 GNUNET_YES);
1058 1065
1059 for (int i = 0; i < rd_count; i++) 1066 for (int i = 0; i < rd_count; i++)
1060 { 1067 {
1061 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) 1068 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1062 continue; 1069 continue;
1063 lbl = GNUNET_STRINGS_data_to_string_alloc(rd[i].data, rd[i].data_size); 1070 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
1064 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); 1071 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl);
1065 parallel_lookup = GNUNET_new(struct ParallelLookup); 1072 parallel_lookup = GNUNET_new (struct ParallelLookup);
1066 parallel_lookup->handle = cth; 1073 parallel_lookup->handle = cth;
1067 parallel_lookup->label = lbl; 1074 parallel_lookup->label = lbl;
1068 parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get(); 1075 parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get ();
1069 parallel_lookup->lookup_request = 1076 parallel_lookup->lookup_request =
1070 GNUNET_GNS_lookup(gns, 1077 GNUNET_GNS_lookup (gns,
1071 lbl, 1078 lbl,
1072 &cth->ticket.identity, 1079 &cth->ticket.identity,
1073 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, 1080 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR,
1074 GNUNET_GNS_LO_DEFAULT, 1081 GNUNET_GNS_LO_DEFAULT,
1075 &process_parallel_lookup_result, 1082 &process_parallel_lookup_result,
1076 parallel_lookup); 1083 parallel_lookup);
1077 GNUNET_CONTAINER_DLL_insert(cth->parallel_lookups_head, 1084 GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head,
1078 cth->parallel_lookups_tail, 1085 cth->parallel_lookups_tail,
1079 parallel_lookup); 1086 parallel_lookup);
1080 } 1087 }
1081 /** 1088 /**
1082 * We started lookups. Add a timeout task. 1089 * We started lookups. Add a timeout task.
1083 * FIXME: Really needed here? 1090 * FIXME: Really needed here?
1084 */ 1091 */
1085 if (NULL != cth->parallel_lookups_head) 1092 if (NULL != cth->parallel_lookups_head)
1086 { 1093 {
1087 cth->kill_task = GNUNET_SCHEDULER_add_delayed( 1094 cth->kill_task = GNUNET_SCHEDULER_add_delayed (
1088 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 3), 1095 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3),
1089 &abort_parallel_lookups, 1096 &abort_parallel_lookups,
1090 cth); 1097 cth);
1091 return; 1098 return;
1092 } 1099 }
1093 /** 1100 /**
1094 * No references found, return empty attribute list 1101 * No references found, return empty attribute list
1095 */ 1102 */
1096 cth->cb(cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); 1103 cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
1097 cleanup_cth(cth); 1104 cleanup_cth (cth);
1098} 1105}
1099 1106
1100 1107
@@ -1110,37 +1117,37 @@ lookup_authz_cb(void *cls,
1110 * @return handle to the operation 1117 * @return handle to the operation
1111 */ 1118 */
1112struct RECLAIM_TICKETS_ConsumeHandle * 1119struct RECLAIM_TICKETS_ConsumeHandle *
1113RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, 1120RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1114 const struct GNUNET_RECLAIM_Ticket *ticket, 1121 const struct GNUNET_RECLAIM_Ticket *ticket,
1115 RECLAIM_TICKETS_ConsumeCallback cb, 1122 RECLAIM_TICKETS_ConsumeCallback cb,
1116 void *cb_cls) 1123 void *cb_cls)
1117{ 1124{
1118 struct RECLAIM_TICKETS_ConsumeHandle *cth; 1125 struct RECLAIM_TICKETS_ConsumeHandle *cth;
1119 char *label; 1126 char *label;
1120 1127
1121 cth = GNUNET_new(struct RECLAIM_TICKETS_ConsumeHandle); 1128 cth = GNUNET_new (struct RECLAIM_TICKETS_ConsumeHandle);
1122 1129
1123 cth->identity = *id; 1130 cth->identity = *id;
1124 GNUNET_CRYPTO_ecdsa_key_get_public(&cth->identity, &cth->identity_pub); 1131 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub);
1125 cth->attrs = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); 1132 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
1126 cth->ticket = *ticket; 1133 cth->ticket = *ticket;
1127 cth->cb = cb; 1134 cth->cb = cb;
1128 cth->cb_cls = cb_cls; 1135 cth->cb_cls = cb_cls;
1129 label = 1136 label =
1130 GNUNET_STRINGS_data_to_string_alloc(&cth->ticket.rnd, sizeof(uint64_t)); 1137 GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof(uint64_t));
1131 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1138 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1132 "Looking for AuthZ info under %s\n", 1139 "Looking for AuthZ info under %s\n",
1133 label); 1140 label);
1134 cth->lookup_start_time = GNUNET_TIME_absolute_get(); 1141 cth->lookup_start_time = GNUNET_TIME_absolute_get ();
1135 cth->lookup_request = 1142 cth->lookup_request =
1136 GNUNET_GNS_lookup(gns, 1143 GNUNET_GNS_lookup (gns,
1137 label, 1144 label,
1138 &cth->ticket.identity, 1145 &cth->ticket.identity,
1139 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, 1146 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF,
1140 GNUNET_GNS_LO_DEFAULT, 1147 GNUNET_GNS_LO_DEFAULT,
1141 &lookup_authz_cb, 1148 &lookup_authz_cb,
1142 cth); 1149 cth);
1143 GNUNET_free(label); 1150 GNUNET_free (label);
1144 return cth; 1151 return cth;
1145} 1152}
1146 1153
@@ -1151,9 +1158,9 @@ RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1151 * @param cth the operation to cancel 1158 * @param cth the operation to cancel
1152 */ 1159 */
1153void 1160void
1154RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth) 1161RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth)
1155{ 1162{
1156 cleanup_cth(cth); 1163 cleanup_cth (cth);
1157 return; 1164 return;
1158} 1165}
1159 1166
@@ -1167,11 +1174,11 @@ RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
1167 * @param handle the handle to clean up 1174 * @param handle the handle to clean up
1168 */ 1175 */
1169static void 1176static void
1170cleanup_issue_handle(struct TicketIssueHandle *handle) 1177cleanup_issue_handle (struct TicketIssueHandle *handle)
1171{ 1178{
1172 if (NULL != handle->ns_qe) 1179 if (NULL != handle->ns_qe)
1173 GNUNET_NAMESTORE_cancel(handle->ns_qe); 1180 GNUNET_NAMESTORE_cancel (handle->ns_qe);
1174 GNUNET_free(handle); 1181 GNUNET_free (handle);
1175} 1182}
1176 1183
1177 1184
@@ -1184,21 +1191,21 @@ cleanup_issue_handle(struct TicketIssueHandle *handle)
1184 * @param emsg error message (or NULL on success) 1191 * @param emsg error message (or NULL on success)
1185 */ 1192 */
1186static void 1193static void
1187store_ticket_issue_cont(void *cls, int32_t success, const char *emsg) 1194store_ticket_issue_cont (void *cls, int32_t success, const char *emsg)
1188{ 1195{
1189 struct TicketIssueHandle *handle = cls; 1196 struct TicketIssueHandle *handle = cls;
1190 1197
1191 handle->ns_qe = NULL; 1198 handle->ns_qe = NULL;
1192 if (GNUNET_SYSERR == success) 1199 if (GNUNET_SYSERR == success)
1193 { 1200 {
1194 handle->cb(handle->cb_cls, 1201 handle->cb (handle->cb_cls,
1195 &handle->ticket, 1202 &handle->ticket,
1196 GNUNET_SYSERR, 1203 GNUNET_SYSERR,
1197 "Error storing AuthZ ticket in GNS"); 1204 "Error storing AuthZ ticket in GNS");
1198 return; 1205 return;
1199 } 1206 }
1200 handle->cb(handle->cb_cls, &handle->ticket, GNUNET_OK, NULL); 1207 handle->cb (handle->cb_cls, &handle->ticket, GNUNET_OK, NULL);
1201 cleanup_issue_handle(handle); 1208 cleanup_issue_handle (handle);
1202} 1209}
1203 1210
1204 1211
@@ -1210,7 +1217,7 @@ store_ticket_issue_cont(void *cls, int32_t success, const char *emsg)
1210 * @param ih handle to the operation containing relevant metadata 1217 * @param ih handle to the operation containing relevant metadata
1211 */ 1218 */
1212static void 1219static void
1213issue_ticket(struct TicketIssueHandle *ih) 1220issue_ticket (struct TicketIssueHandle *ih)
1214{ 1221{
1215 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 1222 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
1216 struct GNUNET_GNSRECORD_Data *attrs_record; 1223 struct GNUNET_GNSRECORD_Data *attrs_record;
@@ -1222,21 +1229,21 @@ issue_ticket(struct TicketIssueHandle *ih)
1222 list_len++; 1229 list_len++;
1223 1230
1224 attrs_record = 1231 attrs_record =
1225 GNUNET_malloc(list_len * sizeof(struct GNUNET_GNSRECORD_Data)); 1232 GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data));
1226 i = 0; 1233 i = 0;
1227 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1234 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1228 { 1235 {
1229 attrs_record[i].data = &le->claim->id; 1236 attrs_record[i].data = &le->claim->id;
1230 attrs_record[i].data_size = sizeof(le->claim->id); 1237 attrs_record[i].data_size = sizeof(le->claim->id);
1231 /** 1238 /**
1232 * FIXME: Should this be the attribute expiration time or ticket 1239 * FIXME: Should this be the attribute expiration time or ticket
1233 * refresh interval? Probably min(attrs.expiration) 1240 * refresh interval? Probably min(attrs.expiration)
1234 */ 1241 */
1235 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; 1242 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1236 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF; 1243 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF;
1237 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1244 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1238 i++; 1245 i++;
1239 } 1246 }
1240 attrs_record[i].data = &ih->ticket; 1247 attrs_record[i].data = &ih->ticket;
1241 attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket); 1248 attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
1242 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; 1249 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
@@ -1245,17 +1252,17 @@ issue_ticket(struct TicketIssueHandle *ih)
1245 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; 1252 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
1246 1253
1247 label = 1254 label =
1248 GNUNET_STRINGS_data_to_string_alloc(&ih->ticket.rnd, sizeof(uint64_t)); 1255 GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof(uint64_t));
1249 // Publish record 1256 // Publish record
1250 ih->ns_qe = GNUNET_NAMESTORE_records_store(nsh, 1257 ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1251 &ih->identity, 1258 &ih->identity,
1252 label, 1259 label,
1253 list_len, 1260 list_len,
1254 attrs_record, 1261 attrs_record,
1255 &store_ticket_issue_cont, 1262 &store_ticket_issue_cont,
1256 ih); 1263 ih);
1257 GNUNET_free(attrs_record); 1264 GNUNET_free (attrs_record);
1258 GNUNET_free(label); 1265 GNUNET_free (label);
1259} 1266}
1260 1267
1261/************************************************* 1268/*************************************************
@@ -1269,16 +1276,16 @@ issue_ticket(struct TicketIssueHandle *ih)
1269 * @param cls handle to the operation 1276 * @param cls handle to the operation
1270 */ 1277 */
1271static void 1278static void
1272filter_tickets_error_cb(void *cls) 1279filter_tickets_error_cb (void *cls)
1273{ 1280{
1274 struct TicketIssueHandle *tih = cls; 1281 struct TicketIssueHandle *tih = cls;
1275 1282
1276 tih->ns_it = NULL; 1283 tih->ns_it = NULL;
1277 tih->cb(tih->cb_cls, 1284 tih->cb (tih->cb_cls,
1278 &tih->ticket, 1285 &tih->ticket,
1279 GNUNET_SYSERR, 1286 GNUNET_SYSERR,
1280 "Error storing AuthZ ticket in GNS"); 1287 "Error storing AuthZ ticket in GNS");
1281 cleanup_issue_handle(tih); 1288 cleanup_issue_handle (tih);
1282} 1289}
1283 1290
1284 1291
@@ -1295,11 +1302,11 @@ filter_tickets_error_cb(void *cls)
1295 * @param rd record set 1302 * @param rd record set
1296 */ 1303 */
1297static void 1304static void
1298filter_tickets_cb(void *cls, 1305filter_tickets_cb (void *cls,
1299 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 1306 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1300 const char *label, 1307 const char *label,
1301 unsigned int rd_count, 1308 unsigned int rd_count,
1302 const struct GNUNET_GNSRECORD_Data *rd) 1309 const struct GNUNET_GNSRECORD_Data *rd)
1303{ 1310{
1304 struct TicketIssueHandle *tih = cls; 1311 struct TicketIssueHandle *tih = cls;
1305 struct GNUNET_RECLAIM_Ticket *ticket = NULL; 1312 struct GNUNET_RECLAIM_Ticket *ticket = NULL;
@@ -1315,53 +1322,53 @@ filter_tickets_cb(void *cls,
1315 unsigned int found_attrs_cnt = 0; 1322 unsigned int found_attrs_cnt = 0;
1316 1323
1317 for (int i = 0; i < rd_count; i++) 1324 for (int i = 0; i < rd_count; i++)
1325 {
1326 // found ticket
1327 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type)
1318 { 1328 {
1319 // found ticket 1329 ticket = (struct GNUNET_RECLAIM_Ticket *) rd[i].data;
1320 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET == rd[i].record_type) 1330 // cmp audience
1321 { 1331 if (0 == memcmp (&tih->ticket.audience,
1322 ticket = (struct GNUNET_RECLAIM_Ticket *)rd[i].data; 1332 &ticket->audience,
1323 // cmp audience 1333 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1324 if (0 == memcmp(&tih->ticket.audience, 1334 {
1325 &ticket->audience, 1335 tih->ticket = *ticket;
1326 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1327 {
1328 tih->ticket = *ticket;
1329 continue;
1330 }
1331 ticket = NULL;
1332 }
1333
1334 // cmp requested attributes with ticket attributes
1335 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1336 continue; 1336 continue;
1337 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1337 }
1338 { 1338 ticket = NULL;
1339 // cmp attr_ref id with requested attr id
1340 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1341 " %" PRIu64 "\n %" PRIu64 "\n",
1342 *((uint64_t *)rd[i].data),
1343 le->claim->id);
1344
1345
1346 if (0 == memcmp(rd[i].data, &le->claim->id, sizeof(uint64_t)))
1347 found_attrs_cnt++;
1348 }
1349 } 1339 }
1350 1340
1341 // cmp requested attributes with ticket attributes
1342 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1343 continue;
1344 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1345 {
1346 // cmp attr_ref id with requested attr id
1347 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1348 " %" PRIu64 "\n %" PRIu64 "\n",
1349 *((uint64_t *) rd[i].data),
1350 le->claim->id);
1351
1352
1353 if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(uint64_t)))
1354 found_attrs_cnt++;
1355 }
1356 }
1357
1351 /** 1358 /**
1352 * If we found a matching ticket, return that to the caller and 1359 * If we found a matching ticket, return that to the caller and
1353 * we are done. 1360 * we are done.
1354 */ 1361 */
1355 if (attr_cnt == found_attrs_cnt && NULL != ticket) 1362 if ((attr_cnt == found_attrs_cnt)&&(NULL != ticket))
1356 { 1363 {
1357 GNUNET_NAMESTORE_zone_iteration_stop(tih->ns_it); 1364 GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it);
1358 tih->cb(tih->cb_cls, &tih->ticket, GNUNET_OK, NULL); 1365 tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL);
1359 cleanup_issue_handle(tih); 1366 cleanup_issue_handle (tih);
1360 return; 1367 return;
1361 } 1368 }
1362 1369
1363 // ticket not found in current record, checking next record set 1370 // ticket not found in current record, checking next record set
1364 GNUNET_NAMESTORE_zone_iterator_next(tih->ns_it, 1); 1371 GNUNET_NAMESTORE_zone_iterator_next (tih->ns_it, 1);
1365} 1372}
1366 1373
1367 1374
@@ -1373,14 +1380,14 @@ filter_tickets_cb(void *cls,
1373 * @param cls handle to the operation 1380 * @param cls handle to the operation
1374 */ 1381 */
1375static void 1382static void
1376filter_tickets_finished_cb(void *cls) 1383filter_tickets_finished_cb (void *cls)
1377{ 1384{
1378 struct TicketIssueHandle *tih = cls; 1385 struct TicketIssueHandle *tih = cls;
1379 1386
1380 GNUNET_CRYPTO_ecdsa_key_get_public(&tih->identity, &tih->ticket.identity); 1387 GNUNET_CRYPTO_ecdsa_key_get_public (&tih->identity, &tih->ticket.identity);
1381 tih->ticket.rnd = 1388 tih->ticket.rnd =
1382 GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); 1389 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX);
1383 issue_ticket(tih); 1390 issue_ticket (tih);
1384} 1391}
1385 1392
1386 1393
@@ -1396,31 +1403,31 @@ filter_tickets_finished_cb(void *cls)
1396 * FIXME: Return handle?? 1403 * FIXME: Return handle??
1397 */ 1404 */
1398void 1405void
1399RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1406RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1400 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 1407 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
1401 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, 1408 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
1402 RECLAIM_TICKETS_TicketResult cb, 1409 RECLAIM_TICKETS_TicketResult cb,
1403 void *cb_cls) 1410 void *cb_cls)
1404{ 1411{
1405 struct TicketIssueHandle *tih; 1412 struct TicketIssueHandle *tih;
1406 1413
1407 tih = GNUNET_new(struct TicketIssueHandle); 1414 tih = GNUNET_new (struct TicketIssueHandle);
1408 tih->cb = cb; 1415 tih->cb = cb;
1409 tih->cb_cls = cb_cls; 1416 tih->cb_cls = cb_cls;
1410 tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup(attrs); 1417 tih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (attrs);
1411 tih->identity = *identity; 1418 tih->identity = *identity;
1412 tih->ticket.audience = *audience; 1419 tih->ticket.audience = *audience;
1413 1420
1414 // First check whether the ticket has already been issued 1421 // First check whether the ticket has already been issued
1415 tih->ns_it = 1422 tih->ns_it =
1416 GNUNET_NAMESTORE_zone_iteration_start(nsh, 1423 GNUNET_NAMESTORE_zone_iteration_start (nsh,
1417 &tih->identity, 1424 &tih->identity,
1418 &filter_tickets_error_cb, 1425 &filter_tickets_error_cb,
1419 tih, 1426 tih,
1420 &filter_tickets_cb, 1427 &filter_tickets_cb,
1421 tih, 1428 tih,
1422 &filter_tickets_finished_cb, 1429 &filter_tickets_finished_cb,
1423 tih); 1430 tih);
1424} 1431}
1425 1432
1426 1433
@@ -1434,11 +1441,11 @@ RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1434 * @param iter handle to the iteration 1441 * @param iter handle to the iteration
1435 */ 1442 */
1436static void 1443static void
1437cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter) 1444cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter)
1438{ 1445{
1439 if (NULL != iter->ns_it) 1446 if (NULL != iter->ns_it)
1440 GNUNET_NAMESTORE_zone_iteration_stop(iter->ns_it); 1447 GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it);
1441 GNUNET_free(iter); 1448 GNUNET_free (iter);
1442} 1449}
1443 1450
1444 1451
@@ -1454,22 +1461,22 @@ cleanup_iter(struct RECLAIM_TICKETS_Iterator *iter)
1454 * @param rd record set containing a ticket 1461 * @param rd record set containing a ticket
1455 */ 1462 */
1456static void 1463static void
1457collect_tickets_cb(void *cls, 1464collect_tickets_cb (void *cls,
1458 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 1465 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1459 const char *label, 1466 const char *label,
1460 unsigned int rd_count, 1467 unsigned int rd_count,
1461 const struct GNUNET_GNSRECORD_Data *rd) 1468 const struct GNUNET_GNSRECORD_Data *rd)
1462{ 1469{
1463 struct RECLAIM_TICKETS_Iterator *iter = cls; 1470 struct RECLAIM_TICKETS_Iterator *iter = cls;
1464 1471
1465 for (int i = 0; i < rd_count; i++) 1472 for (int i = 0; i < rd_count; i++)
1466 { 1473 {
1467 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) 1474 if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
1468 continue; 1475 continue;
1469 iter->cb(iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *)rd[i].data); 1476 iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *) rd[i].data);
1470 return; 1477 return;
1471 } 1478 }
1472 GNUNET_NAMESTORE_zone_iterator_next(iter->ns_it, 1); 1479 GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1);
1473} 1480}
1474 1481
1475 1482
@@ -1479,13 +1486,13 @@ collect_tickets_cb(void *cls,
1479 * @param cls handle to the iteration 1486 * @param cls handle to the iteration
1480 */ 1487 */
1481static void 1488static void
1482collect_tickets_finished_cb(void *cls) 1489collect_tickets_finished_cb (void *cls)
1483{ 1490{
1484 struct RECLAIM_TICKETS_Iterator *iter = cls; 1491 struct RECLAIM_TICKETS_Iterator *iter = cls;
1485 1492
1486 iter->ns_it = NULL; 1493 iter->ns_it = NULL;
1487 iter->cb(iter->cb_cls, NULL); 1494 iter->cb (iter->cb_cls, NULL);
1488 cleanup_iter(iter); 1495 cleanup_iter (iter);
1489} 1496}
1490 1497
1491 1498
@@ -1495,13 +1502,13 @@ collect_tickets_finished_cb(void *cls)
1495 * @param cls the iteration handle 1502 * @param cls the iteration handle
1496 */ 1503 */
1497static void 1504static void
1498collect_tickets_error_cb(void *cls) 1505collect_tickets_error_cb (void *cls)
1499{ 1506{
1500 struct RECLAIM_TICKETS_Iterator *iter = cls; 1507 struct RECLAIM_TICKETS_Iterator *iter = cls;
1501 1508
1502 iter->ns_it = NULL; 1509 iter->ns_it = NULL;
1503 iter->cb(iter->cb_cls, NULL); 1510 iter->cb (iter->cb_cls, NULL);
1504 cleanup_iter(iter); 1511 cleanup_iter (iter);
1505} 1512}
1506 1513
1507 1514
@@ -1511,9 +1518,9 @@ collect_tickets_error_cb(void *cls)
1511 * @param iter the iteration to continue 1518 * @param iter the iteration to continue
1512 */ 1519 */
1513void 1520void
1514RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter) 1521RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter)
1515{ 1522{
1516 GNUNET_NAMESTORE_zone_iterator_next(iter->ns_it, 1); 1523 GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1);
1517} 1524}
1518 1525
1519 1526
@@ -1523,10 +1530,10 @@ RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter)
1523 * @param iter iteration to cancel 1530 * @param iter iteration to cancel
1524 */ 1531 */
1525void 1532void
1526RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter) 1533RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter)
1527{ 1534{
1528 GNUNET_NAMESTORE_zone_iteration_stop(iter->ns_it); 1535 GNUNET_NAMESTORE_zone_iteration_stop (iter->ns_it);
1529 cleanup_iter(iter); 1536 cleanup_iter (iter);
1530} 1537}
1531 1538
1532 1539
@@ -1539,25 +1546,25 @@ RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
1539 * @return a handle to the iteration 1546 * @return a handle to the iteration
1540 */ 1547 */
1541struct RECLAIM_TICKETS_Iterator * 1548struct RECLAIM_TICKETS_Iterator *
1542RECLAIM_TICKETS_iteration_start( 1549RECLAIM_TICKETS_iteration_start (
1543 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1550 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1544 RECLAIM_TICKETS_TicketIter cb, 1551 RECLAIM_TICKETS_TicketIter cb,
1545 void *cb_cls) 1552 void *cb_cls)
1546{ 1553{
1547 struct RECLAIM_TICKETS_Iterator *iter; 1554 struct RECLAIM_TICKETS_Iterator *iter;
1548 1555
1549 iter = GNUNET_new(struct RECLAIM_TICKETS_Iterator); 1556 iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator);
1550 iter->cb = cb; 1557 iter->cb = cb;
1551 iter->cb_cls = cb_cls; 1558 iter->cb_cls = cb_cls;
1552 iter->ns_it = 1559 iter->ns_it =
1553 GNUNET_NAMESTORE_zone_iteration_start(nsh, 1560 GNUNET_NAMESTORE_zone_iteration_start (nsh,
1554 identity, 1561 identity,
1555 &collect_tickets_error_cb, 1562 &collect_tickets_error_cb,
1556 iter, 1563 iter,
1557 &collect_tickets_cb, 1564 &collect_tickets_cb,
1558 iter, 1565 iter,
1559 &collect_tickets_finished_cb, 1566 &collect_tickets_finished_cb,
1560 iter); 1567 iter);
1561 return iter; 1568 return iter;
1562} 1569}
1563 1570
@@ -1569,39 +1576,39 @@ RECLAIM_TICKETS_iteration_start(
1569 * @return GNUNET_SYSERR on error 1576 * @return GNUNET_SYSERR on error
1570 */ 1577 */
1571int 1578int
1572RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c) 1579RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c)
1573{ 1580{
1574 // Get ticket expiration time (relative) from config 1581 // Get ticket expiration time (relative) from config
1575 if (GNUNET_OK == 1582 if (GNUNET_OK ==
1576 GNUNET_CONFIGURATION_get_value_time(c, 1583 GNUNET_CONFIGURATION_get_value_time (c,
1577 "reclaim", 1584 "reclaim",
1578 "TICKET_REFRESH_INTERVAL", 1585 "TICKET_REFRESH_INTERVAL",
1579 &ticket_refresh_interval)) 1586 &ticket_refresh_interval))
1580 { 1587 {
1581 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1588 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1582 "Configured refresh interval for tickets: %s\n", 1589 "Configured refresh interval for tickets: %s\n",
1583 GNUNET_STRINGS_relative_time_to_string(ticket_refresh_interval, 1590 GNUNET_STRINGS_relative_time_to_string (ticket_refresh_interval,
1584 GNUNET_YES)); 1591 GNUNET_YES));
1585 } 1592 }
1586 else 1593 else
1587 { 1594 {
1588 ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; 1595 ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL;
1589 } 1596 }
1590 // Connect to identity and namestore services 1597 // Connect to identity and namestore services
1591 nsh = GNUNET_NAMESTORE_connect(c); 1598 nsh = GNUNET_NAMESTORE_connect (c);
1592 if (NULL == nsh) 1599 if (NULL == nsh)
1593 { 1600 {
1594 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, 1601 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
1595 "error connecting to namestore"); 1602 "error connecting to namestore");
1596 return GNUNET_SYSERR; 1603 return GNUNET_SYSERR;
1597 } 1604 }
1598 gns = GNUNET_GNS_connect(c); 1605 gns = GNUNET_GNS_connect (c);
1599 if (NULL == gns) 1606 if (NULL == gns)
1600 { 1607 {
1601 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "error connecting to gns"); 1608 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns");
1602 return GNUNET_SYSERR; 1609 return GNUNET_SYSERR;
1603 } 1610 }
1604 stats = GNUNET_STATISTICS_create("reclaim", c); 1611 stats = GNUNET_STATISTICS_create ("reclaim", c);
1605 return GNUNET_OK; 1612 return GNUNET_OK;
1606} 1613}
1607 1614
@@ -1611,17 +1618,17 @@ RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c)
1611 * FIXME: cancel all pending operations (gns, ns etc) 1618 * FIXME: cancel all pending operations (gns, ns etc)
1612 */ 1619 */
1613void 1620void
1614RECLAIM_TICKETS_deinit(void) 1621RECLAIM_TICKETS_deinit (void)
1615{ 1622{
1616 if (NULL != nsh) 1623 if (NULL != nsh)
1617 GNUNET_NAMESTORE_disconnect(nsh); 1624 GNUNET_NAMESTORE_disconnect (nsh);
1618 nsh = NULL; 1625 nsh = NULL;
1619 if (NULL != gns) 1626 if (NULL != gns)
1620 GNUNET_GNS_disconnect(gns); 1627 GNUNET_GNS_disconnect (gns);
1621 gns = NULL; 1628 gns = NULL;
1622 if (NULL != stats) 1629 if (NULL != stats)
1623 { 1630 {
1624 GNUNET_STATISTICS_destroy(stats, GNUNET_NO); 1631 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
1625 stats = NULL; 1632 stats = NULL;
1626 } 1633 }
1627} 1634}
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.h b/src/reclaim/gnunet-service-reclaim_tickets.h
index 20a7a8e6f..c75cefc03 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.h
+++ b/src/reclaim/gnunet-service-reclaim_tickets.h
@@ -63,7 +63,8 @@ struct RECLAIM_TICKETS_RevokeHandle;
63/** 63/**
64 * List of tickets 64 * List of tickets
65 */ 65 */
66struct TicketRecordsEntry { 66struct TicketRecordsEntry
67{
67 /** 68 /**
68 * DLL 69 * DLL
69 */ 70 */
@@ -161,10 +162,10 @@ typedef void (*RECLAIM_TICKETS_RevokeCallback) (void *cls, int32_t success);
161 * @return handle to the operation 162 * @return handle to the operation
162 */ 163 */
163struct RECLAIM_TICKETS_RevokeHandle * 164struct RECLAIM_TICKETS_RevokeHandle *
164RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, 165RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket,
165 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 166 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
166 RECLAIM_TICKETS_RevokeCallback cb, 167 RECLAIM_TICKETS_RevokeCallback cb,
167 void *cb_cls); 168 void *cb_cls);
168 169
169 170
170/** 171/**
@@ -173,7 +174,7 @@ RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket,
173 * @param rh handle to the operation 174 * @param rh handle to the operation
174 */ 175 */
175void 176void
176RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh); 177RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh);
177 178
178 179
179/** 180/**
@@ -188,10 +189,10 @@ RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh);
188 * @return handle to the operation 189 * @return handle to the operation
189 */ 190 */
190struct RECLAIM_TICKETS_ConsumeHandle * 191struct RECLAIM_TICKETS_ConsumeHandle *
191RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, 192RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
192 const struct GNUNET_RECLAIM_Ticket *ticket, 193 const struct GNUNET_RECLAIM_Ticket *ticket,
193 RECLAIM_TICKETS_ConsumeCallback cb, 194 RECLAIM_TICKETS_ConsumeCallback cb,
194 void *cb_cls); 195 void *cb_cls);
195 196
196 197
197/** 198/**
@@ -200,7 +201,7 @@ RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
200 * @param cth the operation to cancel 201 * @param cth the operation to cancel
201 */ 202 */
202void 203void
203RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth); 204RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth);
204 205
205 206
206/** 207/**
@@ -215,11 +216,11 @@ RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth);
215 * FIXME: Return handle?? 216 * FIXME: Return handle??
216 */ 217 */
217void 218void
218RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 219RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
219 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 220 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
220 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, 221 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
221 RECLAIM_TICKETS_TicketResult cb, 222 RECLAIM_TICKETS_TicketResult cb,
222 void *cb_cls); 223 void *cb_cls);
223 224
224 225
225/** 226/**
@@ -228,7 +229,7 @@ RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
228 * @param iter the iteration to continue 229 * @param iter the iteration to continue
229 */ 230 */
230void 231void
231RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter); 232RECLAIM_TICKETS_iteration_next (struct RECLAIM_TICKETS_Iterator *iter);
232 233
233 234
234/** 235/**
@@ -237,7 +238,7 @@ RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter);
237 * @param iter iteration to cancel 238 * @param iter iteration to cancel
238 */ 239 */
239void 240void
240RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter); 241RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter);
241 242
242 243
243/** 244/**
@@ -249,7 +250,7 @@ RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter);
249 * @return a handle to the iteration 250 * @return a handle to the iteration
250 */ 251 */
251struct RECLAIM_TICKETS_Iterator * 252struct RECLAIM_TICKETS_Iterator *
252RECLAIM_TICKETS_iteration_start( 253RECLAIM_TICKETS_iteration_start (
253 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 254 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
254 RECLAIM_TICKETS_TicketIter cb, 255 RECLAIM_TICKETS_TicketIter cb,
255 void *cb_cls); 256 void *cb_cls);
@@ -262,7 +263,7 @@ RECLAIM_TICKETS_iteration_start(
262 * @return GNUNET_SYSERR on error 263 * @return GNUNET_SYSERR on error
263 */ 264 */
264int 265int
265RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c); 266RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c);
266 267
267 268
268/** 269/**
@@ -270,6 +271,6 @@ RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c);
270 * FIXME: cancel all pending operations (gns, ns etc) 271 * FIXME: cancel all pending operations (gns, ns etc)
271 */ 272 */
272void 273void
273RECLAIM_TICKETS_deinit(void); 274RECLAIM_TICKETS_deinit (void);
274 275
275#endif 276#endif
diff --git a/src/reclaim/json_reclaim.c b/src/reclaim/json_reclaim.c
index a98dec717..fa3901e43 100644
--- a/src/reclaim/json_reclaim.c
+++ b/src/reclaim/json_reclaim.c
@@ -41,7 +41,7 @@
41 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error 41 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
42 */ 42 */
43static int 43static int
44parse_attr(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) 44parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
45{ 45{
46 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; 46 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
47 const char *name_str = NULL; 47 const char *name_str = NULL;
@@ -53,52 +53,52 @@ parse_attr(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
53 uint32_t type; 53 uint32_t type;
54 size_t data_size; 54 size_t data_size;
55 55
56 GNUNET_assert(NULL != root); 56 GNUNET_assert (NULL != root);
57 57
58 if (!json_is_object(root)) 58 if (! json_is_object (root))
59 { 59 {
60 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 60 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
61 "Error json is not array nor object!\n"); 61 "Error json is not array nor object!\n");
62 return GNUNET_SYSERR; 62 return GNUNET_SYSERR;
63 } 63 }
64 // interpret single attribute 64 // interpret single attribute
65 unpack_state = json_unpack(root, 65 unpack_state = json_unpack (root,
66 "{s:s, s?s, s:s, s:s!}", 66 "{s:s, s?s, s:s, s:s!}",
67 "name", 67 "name",
68 &name_str, 68 &name_str,
69 "id", 69 "id",
70 &id_str, 70 &id_str,
71 "type", 71 "type",
72 &type_str, 72 &type_str,
73 "value", 73 "value",
74 &val_str); 74 &val_str);
75 if ((0 != unpack_state) || (NULL == name_str) || (NULL == val_str) || 75 if ((0 != unpack_state) || (NULL == name_str) || (NULL == val_str) ||
76 (NULL == type_str)) 76 (NULL == type_str))
77 { 77 {
78 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 78 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
79 "Error json object has a wrong format!\n"); 79 "Error json object has a wrong format!\n");
80 return GNUNET_SYSERR; 80 return GNUNET_SYSERR;
81 } 81 }
82 type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(type_str); 82 type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str);
83 if (GNUNET_SYSERR == 83 if (GNUNET_SYSERR ==
84 (GNUNET_RECLAIM_ATTRIBUTE_string_to_value(type, 84 (GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,
85 val_str, 85 val_str,
86 (void **)&data, 86 (void **) &data,
87 &data_size))) 87 &data_size)))
88 { 88 {
89 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Attribute value invalid!\n"); 89 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute value invalid!\n");
90 return GNUNET_SYSERR; 90 return GNUNET_SYSERR;
91 } 91 }
92 attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new(name_str, type, data, data_size); 92 attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (name_str, type, data, data_size);
93 if ((NULL == id_str) || (0 == strlen(id_str))) 93 if ((NULL == id_str) || (0 == strlen (id_str)))
94 attr->id = 0; 94 attr->id = 0;
95 else 95 else
96 GNUNET_STRINGS_string_to_data(id_str, 96 GNUNET_STRINGS_string_to_data (id_str,
97 strlen(id_str), 97 strlen (id_str),
98 &attr->id, 98 &attr->id,
99 sizeof(uint64_t)); 99 sizeof(uint64_t));
100 100
101 *(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **)spec->ptr = attr; 101 *(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr = attr;
102 return GNUNET_OK; 102 return GNUNET_OK;
103} 103}
104 104
@@ -109,16 +109,16 @@ parse_attr(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
109 * @param[out] spec where to free the data 109 * @param[out] spec where to free the data
110 */ 110 */
111static void 111static void
112clean_attr(void *cls, struct GNUNET_JSON_Specification *spec) 112clean_attr (void *cls, struct GNUNET_JSON_Specification *spec)
113{ 113{
114 struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr; 114 struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr;
115 115
116 attr = (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **)spec->ptr; 116 attr = (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr;
117 if (NULL != *attr) 117 if (NULL != *attr)
118 { 118 {
119 GNUNET_free(*attr); 119 GNUNET_free (*attr);
120 *attr = NULL; 120 *attr = NULL;
121 } 121 }
122} 122}
123 123
124/** 124/**
@@ -128,7 +128,7 @@ clean_attr(void *cls, struct GNUNET_JSON_Specification *spec)
128 * @return JSON Specification 128 * @return JSON Specification
129 */ 129 */
130struct GNUNET_JSON_Specification 130struct GNUNET_JSON_Specification
131GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr) 131GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr)
132{ 132{
133 struct GNUNET_JSON_Specification ret = { .parser = &parse_attr, 133 struct GNUNET_JSON_Specification ret = { .parser = &parse_attr,
134 .cleaner = &clean_attr, 134 .cleaner = &clean_attr,
@@ -150,7 +150,7 @@ GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr)
150 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error 150 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
151 */ 151 */
152static int 152static int
153parse_ticket(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) 153parse_ticket (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
154{ 154{
155 struct GNUNET_RECLAIM_Ticket *ticket; 155 struct GNUNET_RECLAIM_Ticket *ticket;
156 const char *rnd_str; 156 const char *rnd_str;
@@ -158,63 +158,64 @@ parse_ticket(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
158 const char *id_str; 158 const char *id_str;
159 int unpack_state; 159 int unpack_state;
160 160
161 GNUNET_assert(NULL != root); 161 GNUNET_assert (NULL != root);
162 162
163 if (!json_is_object(root)) 163 if (! json_is_object (root))
164 { 164 {
165 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 165 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
166 "Error json is not array nor object!\n"); 166 "Error json is not array nor object!\n");
167 return GNUNET_SYSERR; 167 return GNUNET_SYSERR;
168 } 168 }
169 // interpret single ticket 169 // interpret single ticket
170 unpack_state = json_unpack(root, 170 unpack_state = json_unpack (root,
171 "{s:s, s:s, s:s!}", 171 "{s:s, s:s, s:s!}",
172 "rnd", 172 "rnd",
173 &rnd_str, 173 &rnd_str,
174 "audience", 174 "audience",
175 &aud_str, 175 &aud_str,
176 "issuer", 176 "issuer",
177 &id_str); 177 &id_str);
178 if (0 != unpack_state) 178 if (0 != unpack_state)
179 { 179 {
180 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
181 "Error json object has a wrong format!\n"); 181 "Error json object has a wrong format!\n");
182 return GNUNET_SYSERR; 182 return GNUNET_SYSERR;
183 } 183 }
184 ticket = GNUNET_new(struct GNUNET_RECLAIM_Ticket); 184 ticket = GNUNET_new (struct GNUNET_RECLAIM_Ticket);
185 if (GNUNET_OK != GNUNET_STRINGS_string_to_data(rnd_str, 185 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (rnd_str,
186 strlen(rnd_str), 186 strlen (rnd_str),
187 &ticket->rnd, 187 &ticket->rnd,
188 sizeof(uint64_t))) 188 sizeof(uint64_t)))
189 { 189 {
190 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Rnd invalid\n"); 190 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Rnd invalid\n");
191 GNUNET_free(ticket); 191 GNUNET_free (ticket);
192 return GNUNET_SYSERR; 192 return GNUNET_SYSERR;
193 } 193 }
194 if (GNUNET_OK != 194 if (GNUNET_OK !=
195 GNUNET_STRINGS_string_to_data(id_str, 195 GNUNET_STRINGS_string_to_data (id_str,
196 strlen(id_str), 196 strlen (id_str),
197 &ticket->identity, 197 &ticket->identity,
198 sizeof( 198 sizeof(
199 struct GNUNET_CRYPTO_EcdsaPublicKey))) 199 struct GNUNET_CRYPTO_EcdsaPublicKey)))
200 { 200 {
201 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Identity invalid\n"); 201 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Identity invalid\n");
202 GNUNET_free(ticket); 202 GNUNET_free (ticket);
203 return GNUNET_SYSERR; 203 return GNUNET_SYSERR;
204 } 204 }
205 205
206 if (GNUNET_OK != 206 if (GNUNET_OK !=
207 GNUNET_STRINGS_string_to_data(aud_str, 207 GNUNET_STRINGS_string_to_data (aud_str,
208 strlen(aud_str), 208 strlen (aud_str),
209 &ticket->audience, 209 &ticket->audience,
210 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) 210 sizeof(struct
211 { 211 GNUNET_CRYPTO_EcdsaPublicKey)))
212 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Audience invalid\n"); 212 {
213 GNUNET_free(ticket); 213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audience invalid\n");
214 return GNUNET_SYSERR; 214 GNUNET_free (ticket);
215 } 215 return GNUNET_SYSERR;
216 }
216 217
217 *(struct GNUNET_RECLAIM_Ticket **)spec->ptr = ticket; 218 *(struct GNUNET_RECLAIM_Ticket **) spec->ptr = ticket;
218 return GNUNET_OK; 219 return GNUNET_OK;
219} 220}
220 221
@@ -225,16 +226,16 @@ parse_ticket(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
225 * @param[out] spec where to free the data 226 * @param[out] spec where to free the data
226 */ 227 */
227static void 228static void
228clean_ticket(void *cls, struct GNUNET_JSON_Specification *spec) 229clean_ticket (void *cls, struct GNUNET_JSON_Specification *spec)
229{ 230{
230 struct GNUNET_RECLAIM_Ticket **ticket; 231 struct GNUNET_RECLAIM_Ticket **ticket;
231 232
232 ticket = (struct GNUNET_RECLAIM_Ticket **)spec->ptr; 233 ticket = (struct GNUNET_RECLAIM_Ticket **) spec->ptr;
233 if (NULL != *ticket) 234 if (NULL != *ticket)
234 { 235 {
235 GNUNET_free(*ticket); 236 GNUNET_free (*ticket);
236 *ticket = NULL; 237 *ticket = NULL;
237 } 238 }
238} 239}
239 240
240/** 241/**
@@ -244,7 +245,7 @@ clean_ticket(void *cls, struct GNUNET_JSON_Specification *spec)
244 * @return JSON Specification 245 * @return JSON Specification
245 */ 246 */
246struct GNUNET_JSON_Specification 247struct GNUNET_JSON_Specification
247GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket) 248GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket)
248{ 249{
249 struct GNUNET_JSON_Specification ret = { .parser = &parse_ticket, 250 struct GNUNET_JSON_Specification ret = { .parser = &parse_ticket,
250 .cleaner = &clean_ticket, 251 .cleaner = &clean_ticket,
diff --git a/src/reclaim/json_reclaim.h b/src/reclaim/json_reclaim.h
index 28db6937e..3fd26167f 100644
--- a/src/reclaim/json_reclaim.h
+++ b/src/reclaim/json_reclaim.h
@@ -36,7 +36,7 @@
36 * @return JSON Specification 36 * @return JSON Specification
37 */ 37 */
38struct GNUNET_JSON_Specification 38struct GNUNET_JSON_Specification
39GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr); 39GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr);
40 40
41/** 41/**
42 * JSON Specification for Reclaim tickets. 42 * JSON Specification for Reclaim tickets.
@@ -45,4 +45,4 @@ GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr);
45 * @return JSON Specification 45 * @return JSON Specification
46 */ 46 */
47struct GNUNET_JSON_Specification 47struct GNUNET_JSON_Specification
48GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket); 48GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket);
diff --git a/src/reclaim/oidc_helper.h b/src/reclaim/oidc_helper.h
index 46bd804e7..fa3d7f2d9 100644
--- a/src/reclaim/oidc_helper.h
+++ b/src/reclaim/oidc_helper.h
@@ -49,12 +49,12 @@
49 * @return a new base64-encoded JWT string. 49 * @return a new base64-encoded JWT string.
50 */ 50 */
51char* 51char*
52OIDC_id_token_new(const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, 52OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
53 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, 53 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
54 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 54 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
55 const struct GNUNET_TIME_Relative *expiration_time, 55 const struct GNUNET_TIME_Relative *expiration_time,
56 const char *nonce, 56 const char *nonce,
57 const char *secret_key); 57 const char *secret_key);
58 58
59/** 59/**
60 * Builds an OIDC authorization code including 60 * Builds an OIDC authorization code including
@@ -68,11 +68,11 @@ OIDC_id_token_new(const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
68 * @return a new authorization code (caller must free) 68 * @return a new authorization code (caller must free)
69 */ 69 */
70char* 70char*
71OIDC_build_authz_code(const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, 71OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
72 const struct GNUNET_RECLAIM_Ticket *ticket, 72 const struct GNUNET_RECLAIM_Ticket *ticket,
73 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, 73 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
74 const char *nonce, 74 const char *nonce,
75 const char *code_challenge); 75 const char *code_challenge);
76 76
77/** 77/**
78 * Parse reclaim ticket and nonce from 78 * Parse reclaim ticket and nonce from
@@ -88,12 +88,12 @@ OIDC_build_authz_code(const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
88 * @return GNUNET_OK if successful, else GNUNET_SYSERR 88 * @return GNUNET_OK if successful, else GNUNET_SYSERR
89 */ 89 */
90int 90int
91OIDC_parse_authz_code(const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa_priv, 91OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa_priv,
92 const char *code, 92 const char *code,
93 const char *code_verifier, 93 const char *code_verifier,
94 struct GNUNET_RECLAIM_Ticket *ticket, 94 struct GNUNET_RECLAIM_Ticket *ticket,
95 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList **attrs, 95 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList **attrs,
96 char **nonce); 96 char **nonce);
97 97
98/** 98/**
99 * Build a token response for a token request 99 * Build a token response for a token request
@@ -105,15 +105,15 @@ OIDC_parse_authz_code(const struct GNUNET_CRYPTO_EcdsaPrivateKey *ecdsa_priv,
105 * @param token_response where to store the response 105 * @param token_response where to store the response
106 */ 106 */
107void 107void
108OIDC_build_token_response(const char *access_token, 108OIDC_build_token_response (const char *access_token,
109 const char *id_token, 109 const char *id_token,
110 const struct GNUNET_TIME_Relative *expiration_time, 110 const struct GNUNET_TIME_Relative *expiration_time,
111 char **token_response); 111 char **token_response);
112/** 112/**
113 * Generate a new access token 113 * Generate a new access token
114 */ 114 */
115char* 115char*
116OIDC_access_token_new(); 116OIDC_access_token_new ();
117 117
118 118
119#endif 119#endif
diff --git a/src/reclaim/plugin_gnsrecord_reclaim.c b/src/reclaim/plugin_gnsrecord_reclaim.c
index 708142774..e4d1adfde 100644
--- a/src/reclaim/plugin_gnsrecord_reclaim.c
+++ b/src/reclaim/plugin_gnsrecord_reclaim.c
@@ -40,25 +40,25 @@
40 * @return NULL on error, otherwise human-readable representation of the value 40 * @return NULL on error, otherwise human-readable representation of the value
41 */ 41 */
42static char * 42static char *
43value_to_string(void *cls, uint32_t type, const void *data, size_t data_size) 43value_to_string (void *cls, uint32_t type, const void *data, size_t data_size)
44{ 44{
45 switch (type) 45 switch (type)
46 { 46 {
47 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR: 47 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR:
48 return GNUNET_STRINGS_data_to_string_alloc(data, data_size); 48 return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
49 49
50 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: 50 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT:
51 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: 51 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
52 return GNUNET_strndup(data, data_size); 52 return GNUNET_strndup (data, data_size);
53 53
54 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: 54 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF:
55 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: 55 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
56 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: 56 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
57 return GNUNET_STRINGS_data_to_string_alloc(data, data_size); 57 return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
58 58
59 default: 59 default:
60 return NULL; 60 return NULL;
61 } 61 }
62} 62}
63 63
64 64
@@ -74,30 +74,30 @@ value_to_string(void *cls, uint32_t type, const void *data, size_t data_size)
74 * @return #GNUNET_OK on success 74 * @return #GNUNET_OK on success
75 */ 75 */
76static int 76static int
77string_to_value(void *cls, uint32_t type, const char *s, void **data, 77string_to_value (void *cls, uint32_t type, const char *s, void **data,
78 size_t *data_size) 78 size_t *data_size)
79{ 79{
80 if (NULL == s) 80 if (NULL == s)
81 return GNUNET_SYSERR; 81 return GNUNET_SYSERR;
82 switch (type) 82 switch (type)
83 { 83 {
84 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR: 84 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR:
85 return GNUNET_STRINGS_string_to_data(s, strlen(s), *data, *data_size); 85 return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
86 86
87 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: 87 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT:
88 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: 88 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
89 *data = GNUNET_strdup(s); 89 *data = GNUNET_strdup (s);
90 *data_size = strlen(s); 90 *data_size = strlen (s);
91 return GNUNET_OK; 91 return GNUNET_OK;
92 92
93 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF: 93 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF:
94 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: 94 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
95 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: 95 case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
96 return GNUNET_STRINGS_string_to_data(s, strlen(s), *data, *data_size); 96 return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
97 97
98 default: 98 default:
99 return GNUNET_SYSERR; 99 return GNUNET_SYSERR;
100 } 100 }
101} 101}
102 102
103 103
@@ -105,7 +105,8 @@ string_to_value(void *cls, uint32_t type, const char *s, void **data,
105 * Mapping of record type numbers to human-readable 105 * Mapping of record type numbers to human-readable
106 * record type names. 106 * record type names.
107 */ 107 */
108static struct { 108static struct
109{
109 const char *name; 110 const char *name;
110 uint32_t number; 111 uint32_t number;
111} name_map[] = { 112} name_map[] = {
@@ -127,13 +128,13 @@ static struct {
127 * @return corresponding number, UINT32_MAX on error 128 * @return corresponding number, UINT32_MAX on error
128 */ 129 */
129static uint32_t 130static uint32_t
130typename_to_number(void *cls, const char *dns_typename) 131typename_to_number (void *cls, const char *dns_typename)
131{ 132{
132 unsigned int i; 133 unsigned int i;
133 134
134 i = 0; 135 i = 0;
135 while ((NULL != name_map[i].name) && 136 while ((NULL != name_map[i].name) &&
136 (0 != strcasecmp(dns_typename, name_map[i].name))) 137 (0 != strcasecmp (dns_typename, name_map[i].name)))
137 i++; 138 i++;
138 return name_map[i].number; 139 return name_map[i].number;
139} 140}
@@ -147,7 +148,7 @@ typename_to_number(void *cls, const char *dns_typename)
147 * @return corresponding typestring, NULL on error 148 * @return corresponding typestring, NULL on error
148 */ 149 */
149static const char * 150static const char *
150number_to_typename(void *cls, uint32_t type) 151number_to_typename (void *cls, uint32_t type)
151{ 152{
152 unsigned int i; 153 unsigned int i;
153 154
@@ -165,11 +166,11 @@ number_to_typename(void *cls, uint32_t type)
165 * @return the exported block API 166 * @return the exported block API
166 */ 167 */
167void * 168void *
168libgnunet_plugin_gnsrecord_reclaim_init(void *cls) 169libgnunet_plugin_gnsrecord_reclaim_init (void *cls)
169{ 170{
170 struct GNUNET_GNSRECORD_PluginFunctions *api; 171 struct GNUNET_GNSRECORD_PluginFunctions *api;
171 172
172 api = GNUNET_new(struct GNUNET_GNSRECORD_PluginFunctions); 173 api = GNUNET_new (struct GNUNET_GNSRECORD_PluginFunctions);
173 api->value_to_string = &value_to_string; 174 api->value_to_string = &value_to_string;
174 api->string_to_value = &string_to_value; 175 api->string_to_value = &string_to_value;
175 api->typename_to_number = &typename_to_number; 176 api->typename_to_number = &typename_to_number;
@@ -185,11 +186,11 @@ libgnunet_plugin_gnsrecord_reclaim_init(void *cls)
185 * @return NULL 186 * @return NULL
186 */ 187 */
187void * 188void *
188libgnunet_plugin_gnsrecord_reclaim_done(void *cls) 189libgnunet_plugin_gnsrecord_reclaim_done (void *cls)
189{ 190{
190 struct GNUNET_GNSRECORD_PluginFunctions *api = cls; 191 struct GNUNET_GNSRECORD_PluginFunctions *api = cls;
191 192
192 GNUNET_free(api); 193 GNUNET_free (api);
193 return NULL; 194 return NULL;
194} 195}
195 196
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index 176f46ffc..fd35059d7 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -86,14 +86,16 @@ static char *allow_methods;
86/** 86/**
87 * @brief struct returned by the initialization function of the plugin 87 * @brief struct returned by the initialization function of the plugin
88 */ 88 */
89struct Plugin { 89struct Plugin
90{
90 const struct GNUNET_CONFIGURATION_Handle *cfg; 91 const struct GNUNET_CONFIGURATION_Handle *cfg;
91}; 92};
92 93
93/** 94/**
94 * The ego list 95 * The ego list
95 */ 96 */
96struct EgoEntry { 97struct EgoEntry
98{
97 /** 99 /**
98 * DLL 100 * DLL
99 */ 101 */
@@ -121,7 +123,8 @@ struct EgoEntry {
121}; 123};
122 124
123 125
124struct RequestHandle { 126struct RequestHandle
127{
125 /** 128 /**
126 * Ego list 129 * Ego list
127 */ 130 */
@@ -238,56 +241,56 @@ struct RequestHandle {
238 * @param handle Handle to clean up 241 * @param handle Handle to clean up
239 */ 242 */
240static void 243static void
241cleanup_handle(struct RequestHandle *handle) 244cleanup_handle (struct RequestHandle *handle)
242{ 245{
243 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry; 246 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry;
244 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp; 247 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp;
245 struct EgoEntry *ego_entry; 248 struct EgoEntry *ego_entry;
246 struct EgoEntry *ego_tmp; 249 struct EgoEntry *ego_tmp;
247 250
248 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); 251 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
249 if (NULL != handle->resp_object) 252 if (NULL != handle->resp_object)
250 json_decref(handle->resp_object); 253 json_decref (handle->resp_object);
251 if (NULL != handle->timeout_task) 254 if (NULL != handle->timeout_task)
252 GNUNET_SCHEDULER_cancel(handle->timeout_task); 255 GNUNET_SCHEDULER_cancel (handle->timeout_task);
253 if (NULL != handle->identity_handle) 256 if (NULL != handle->identity_handle)
254 GNUNET_IDENTITY_disconnect(handle->identity_handle); 257 GNUNET_IDENTITY_disconnect (handle->identity_handle);
255 if (NULL != handle->attr_it) 258 if (NULL != handle->attr_it)
256 GNUNET_RECLAIM_get_attributes_stop(handle->attr_it); 259 GNUNET_RECLAIM_get_attributes_stop (handle->attr_it);
257 if (NULL != handle->ticket_it) 260 if (NULL != handle->ticket_it)
258 GNUNET_RECLAIM_ticket_iteration_stop(handle->ticket_it); 261 GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it);
259 if (NULL != handle->idp) 262 if (NULL != handle->idp)
260 GNUNET_RECLAIM_disconnect(handle->idp); 263 GNUNET_RECLAIM_disconnect (handle->idp);
261 if (NULL != handle->url) 264 if (NULL != handle->url)
262 GNUNET_free(handle->url); 265 GNUNET_free (handle->url);
263 if (NULL != handle->emsg) 266 if (NULL != handle->emsg)
264 GNUNET_free(handle->emsg); 267 GNUNET_free (handle->emsg);
265 if (NULL != handle->attr_list) 268 if (NULL != handle->attr_list)
269 {
270 for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;)
266 { 271 {
267 for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;) 272 claim_tmp = claim_entry;
268 { 273 claim_entry = claim_entry->next;
269 claim_tmp = claim_entry; 274 GNUNET_free (claim_tmp->claim);
270 claim_entry = claim_entry->next; 275 GNUNET_free (claim_tmp);
271 GNUNET_free(claim_tmp->claim);
272 GNUNET_free(claim_tmp);
273 }
274 GNUNET_free(handle->attr_list);
275 } 276 }
277 GNUNET_free (handle->attr_list);
278 }
276 for (ego_entry = handle->ego_head; NULL != ego_entry;) 279 for (ego_entry = handle->ego_head; NULL != ego_entry;)
277 { 280 {
278 ego_tmp = ego_entry; 281 ego_tmp = ego_entry;
279 ego_entry = ego_entry->next; 282 ego_entry = ego_entry->next;
280 GNUNET_free(ego_tmp->identifier); 283 GNUNET_free (ego_tmp->identifier);
281 GNUNET_free(ego_tmp->keystring); 284 GNUNET_free (ego_tmp->keystring);
282 GNUNET_free(ego_tmp); 285 GNUNET_free (ego_tmp);
283 } 286 }
284 GNUNET_free(handle); 287 GNUNET_free (handle);
285} 288}
286 289
287static void 290static void
288cleanup_handle_delayed(void *cls) 291cleanup_handle_delayed (void *cls)
289{ 292{
290 cleanup_handle(cls); 293 cleanup_handle (cls);
291} 294}
292 295
293 296
@@ -297,22 +300,22 @@ cleanup_handle_delayed(void *cls)
297 * @param cls the `struct RequestHandle` 300 * @param cls the `struct RequestHandle`
298 */ 301 */
299static void 302static void
300do_error(void *cls) 303do_error (void *cls)
301{ 304{
302 struct RequestHandle *handle = cls; 305 struct RequestHandle *handle = cls;
303 struct MHD_Response *resp; 306 struct MHD_Response *resp;
304 char *json_error; 307 char *json_error;
305 308
306 GNUNET_asprintf(&json_error, "{ \"error\" : \"%s\" }", handle->emsg); 309 GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg);
307 if (0 == handle->response_code) 310 if (0 == handle->response_code)
308 { 311 {
309 handle->response_code = MHD_HTTP_BAD_REQUEST; 312 handle->response_code = MHD_HTTP_BAD_REQUEST;
310 } 313 }
311 resp = GNUNET_REST_create_response(json_error); 314 resp = GNUNET_REST_create_response (json_error);
312 MHD_add_response_header(resp, "Content-Type", "application/json"); 315 MHD_add_response_header (resp, "Content-Type", "application/json");
313 handle->proc(handle->proc_cls, resp, handle->response_code); 316 handle->proc (handle->proc_cls, resp, handle->response_code);
314 GNUNET_SCHEDULER_add_now(&cleanup_handle_delayed, handle); 317 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
315 GNUNET_free(json_error); 318 GNUNET_free (json_error);
316} 319}
317 320
318 321
@@ -322,37 +325,37 @@ do_error(void *cls)
322 * @param cls the `struct RequestHandle` 325 * @param cls the `struct RequestHandle`
323 */ 326 */
324static void 327static void
325do_timeout(void *cls) 328do_timeout (void *cls)
326{ 329{
327 struct RequestHandle *handle = cls; 330 struct RequestHandle *handle = cls;
328 331
329 handle->timeout_task = NULL; 332 handle->timeout_task = NULL;
330 do_error(handle); 333 do_error (handle);
331} 334}
332 335
333 336
334static void 337static void
335collect_error_cb(void *cls) 338collect_error_cb (void *cls)
336{ 339{
337 struct RequestHandle *handle = cls; 340 struct RequestHandle *handle = cls;
338 341
339 do_error(handle); 342 do_error (handle);
340} 343}
341 344
342static void 345static void
343finished_cont(void *cls, int32_t success, const char *emsg) 346finished_cont (void *cls, int32_t success, const char *emsg)
344{ 347{
345 struct RequestHandle *handle = cls; 348 struct RequestHandle *handle = cls;
346 struct MHD_Response *resp; 349 struct MHD_Response *resp;
347 350
348 resp = GNUNET_REST_create_response(emsg); 351 resp = GNUNET_REST_create_response (emsg);
349 if (GNUNET_OK != success) 352 if (GNUNET_OK != success)
350 { 353 {
351 GNUNET_SCHEDULER_add_now(&do_error, handle); 354 GNUNET_SCHEDULER_add_now (&do_error, handle);
352 return; 355 return;
353 } 356 }
354 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); 357 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
355 GNUNET_SCHEDULER_add_now(&cleanup_handle_delayed, handle); 358 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
356} 359}
357 360
358 361
@@ -362,29 +365,29 @@ finished_cont(void *cls, int32_t success, const char *emsg)
362 * @param cls the request handle 365 * @param cls the request handle
363 */ 366 */
364static void 367static void
365return_response(void *cls) 368return_response (void *cls)
366{ 369{
367 char *result_str; 370 char *result_str;
368 struct RequestHandle *handle = cls; 371 struct RequestHandle *handle = cls;
369 struct MHD_Response *resp; 372 struct MHD_Response *resp;
370 373
371 result_str = json_dumps(handle->resp_object, 0); 374 result_str = json_dumps (handle->resp_object, 0);
372 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
373 resp = GNUNET_REST_create_response(result_str); 376 resp = GNUNET_REST_create_response (result_str);
374 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); 377 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
375 GNUNET_free(result_str); 378 GNUNET_free (result_str);
376 cleanup_handle(handle); 379 cleanup_handle (handle);
377} 380}
378 381
379static void 382static void
380collect_finished_cb(void *cls) 383collect_finished_cb (void *cls)
381{ 384{
382 struct RequestHandle *handle = cls; 385 struct RequestHandle *handle = cls;
383 386
384 // Done 387 // Done
385 handle->attr_it = NULL; 388 handle->attr_it = NULL;
386 handle->ticket_it = NULL; 389 handle->ticket_it = NULL;
387 GNUNET_SCHEDULER_add_now(&return_response, handle); 390 GNUNET_SCHEDULER_add_now (&return_response, handle);
388} 391}
389 392
390 393
@@ -393,38 +396,38 @@ collect_finished_cb(void *cls)
393 * 396 *
394 */ 397 */
395static void 398static void
396ticket_collect(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) 399ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
397{ 400{
398 json_t *json_resource; 401 json_t *json_resource;
399 struct RequestHandle *handle = cls; 402 struct RequestHandle *handle = cls;
400 json_t *value; 403 json_t *value;
401 char *tmp; 404 char *tmp;
402 405
403 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n"); 406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n");
404 tmp = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t)); 407 tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
405 json_resource = json_object(); 408 json_resource = json_object ();
406 GNUNET_free(tmp); 409 GNUNET_free (tmp);
407 json_array_append(handle->resp_object, json_resource); 410 json_array_append (handle->resp_object, json_resource);
408 411
409 tmp = 412 tmp =
410 GNUNET_STRINGS_data_to_string_alloc(&ticket->identity, 413 GNUNET_STRINGS_data_to_string_alloc (&ticket->identity,
411 sizeof(struct 414 sizeof(struct
412 GNUNET_CRYPTO_EcdsaPublicKey)); 415 GNUNET_CRYPTO_EcdsaPublicKey));
413 value = json_string(tmp); 416 value = json_string (tmp);
414 json_object_set_new(json_resource, "issuer", value); 417 json_object_set_new (json_resource, "issuer", value);
415 GNUNET_free(tmp); 418 GNUNET_free (tmp);
416 tmp = 419 tmp =
417 GNUNET_STRINGS_data_to_string_alloc(&ticket->audience, 420 GNUNET_STRINGS_data_to_string_alloc (&ticket->audience,
418 sizeof(struct 421 sizeof(struct
419 GNUNET_CRYPTO_EcdsaPublicKey)); 422 GNUNET_CRYPTO_EcdsaPublicKey));
420 value = json_string(tmp); 423 value = json_string (tmp);
421 json_object_set_new(json_resource, "audience", value); 424 json_object_set_new (json_resource, "audience", value);
422 GNUNET_free(tmp); 425 GNUNET_free (tmp);
423 tmp = GNUNET_STRINGS_data_to_string_alloc(&ticket->rnd, sizeof(uint64_t)); 426 tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
424 value = json_string(tmp); 427 value = json_string (tmp);
425 json_object_set_new(json_resource, "rnd", value); 428 json_object_set_new (json_resource, "rnd", value);
426 GNUNET_free(tmp); 429 GNUNET_free (tmp);
427 GNUNET_RECLAIM_ticket_iteration_next(handle->ticket_it); 430 GNUNET_RECLAIM_ticket_iteration_next (handle->ticket_it);
428} 431}
429 432
430 433
@@ -436,57 +439,57 @@ ticket_collect(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
436 * @param cls the RequestHandle 439 * @param cls the RequestHandle
437 */ 440 */
438static void 441static void
439list_tickets_cont(struct GNUNET_REST_RequestHandle *con_handle, 442list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle,
440 const char *url, 443 const char *url,
441 void *cls) 444 void *cls)
442{ 445{
443 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; 446 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
444 struct RequestHandle *handle = cls; 447 struct RequestHandle *handle = cls;
445 struct EgoEntry *ego_entry; 448 struct EgoEntry *ego_entry;
446 char *identity; 449 char *identity;
447 450
448 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 451 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
449 "Getting tickets for %s.\n", 452 "Getting tickets for %s.\n",
450 handle->url); 453 handle->url);
451 if (strlen(GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen(handle->url)) 454 if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url))
452 { 455 {
453 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); 456 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
454 GNUNET_SCHEDULER_add_now(&do_error, handle); 457 GNUNET_SCHEDULER_add_now (&do_error, handle);
455 return; 458 return;
456 } 459 }
457 identity = handle->url + strlen(GNUNET_REST_API_NS_IDENTITY_TICKETS) + 1; 460 identity = handle->url + strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) + 1;
458 461
459 for (ego_entry = handle->ego_head; NULL != ego_entry; 462 for (ego_entry = handle->ego_head; NULL != ego_entry;
460 ego_entry = ego_entry->next) 463 ego_entry = ego_entry->next)
461 if (0 == strcmp(identity, ego_entry->identifier)) 464 if (0 == strcmp (identity, ego_entry->identifier))
462 break; 465 break;
463 handle->resp_object = json_array(); 466 handle->resp_object = json_array ();
464 467
465 if (NULL == ego_entry) 468 if (NULL == ego_entry)
466 { 469 {
467 // Done 470 // Done
468 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); 471 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
469 GNUNET_SCHEDULER_add_now(&return_response, handle); 472 GNUNET_SCHEDULER_add_now (&return_response, handle);
470 return; 473 return;
471 } 474 }
472 priv_key = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); 475 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
473 handle->idp = GNUNET_RECLAIM_connect(cfg); 476 handle->idp = GNUNET_RECLAIM_connect (cfg);
474 handle->ticket_it = 477 handle->ticket_it =
475 GNUNET_RECLAIM_ticket_iteration_start(handle->idp, 478 GNUNET_RECLAIM_ticket_iteration_start (handle->idp,
476 priv_key, 479 priv_key,
477 &collect_error_cb, 480 &collect_error_cb,
478 handle, 481 handle,
479 &ticket_collect, 482 &ticket_collect,
480 handle, 483 handle,
481 &collect_finished_cb, 484 &collect_finished_cb,
482 handle); 485 handle);
483} 486}
484 487
485 488
486static void 489static void
487add_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, 490add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
488 const char *url, 491 const char *url,
489 void *cls) 492 void *cls)
490{ 493{
491 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; 494 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
492 const char *identity; 495 const char *identity;
@@ -498,68 +501,68 @@ add_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle,
498 json_t *data_json; 501 json_t *data_json;
499 json_error_t err; 502 json_error_t err;
500 struct GNUNET_JSON_Specification attrspec[] = 503 struct GNUNET_JSON_Specification attrspec[] =
501 { GNUNET_RECLAIM_JSON_spec_claim(&attribute), GNUNET_JSON_spec_end() }; 504 { GNUNET_RECLAIM_JSON_spec_claim (&attribute), GNUNET_JSON_spec_end () };
502 505
503 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
504 "Adding an attribute for %s.\n", 507 "Adding an attribute for %s.\n",
505 handle->url); 508 handle->url);
506 if (strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen(handle->url)) 509 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
507 { 510 {
508 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); 511 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
509 GNUNET_SCHEDULER_add_now(&do_error, handle); 512 GNUNET_SCHEDULER_add_now (&do_error, handle);
510 return; 513 return;
511 } 514 }
512 identity = handle->url + strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1; 515 identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1;
513 516
514 for (ego_entry = handle->ego_head; NULL != ego_entry; 517 for (ego_entry = handle->ego_head; NULL != ego_entry;
515 ego_entry = ego_entry->next) 518 ego_entry = ego_entry->next)
516 if (0 == strcmp(identity, ego_entry->identifier)) 519 if (0 == strcmp (identity, ego_entry->identifier))
517 break; 520 break;
518 521
519 if (NULL == ego_entry) 522 if (NULL == ego_entry)
520 { 523 {
521 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity); 524 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
522 return; 525 return;
523 } 526 }
524 identity_priv = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); 527 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
525 528
526 if (0 >= handle->rest_handle->data_size) 529 if (0 >= handle->rest_handle->data_size)
527 { 530 {
528 GNUNET_SCHEDULER_add_now(&do_error, handle); 531 GNUNET_SCHEDULER_add_now (&do_error, handle);
529 return; 532 return;
530 } 533 }
531 534
532 term_data[handle->rest_handle->data_size] = '\0'; 535 term_data[handle->rest_handle->data_size] = '\0';
533 GNUNET_memcpy(term_data, 536 GNUNET_memcpy (term_data,
534 handle->rest_handle->data, 537 handle->rest_handle->data,
535 handle->rest_handle->data_size); 538 handle->rest_handle->data_size);
536 data_json = json_loads(term_data, JSON_DECODE_ANY, &err); 539 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
537 GNUNET_assert(GNUNET_OK == 540 GNUNET_assert (GNUNET_OK ==
538 GNUNET_JSON_parse(data_json, attrspec, NULL, NULL)); 541 GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
539 json_decref(data_json); 542 json_decref (data_json);
540 if (NULL == attribute) 543 if (NULL == attribute)
541 { 544 {
542 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 545 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
543 "Unable to parse attribute from %s\n", 546 "Unable to parse attribute from %s\n",
544 term_data); 547 term_data);
545 GNUNET_SCHEDULER_add_now(&do_error, handle); 548 GNUNET_SCHEDULER_add_now (&do_error, handle);
546 return; 549 return;
547 } 550 }
548 /** 551 /**
549 * New ID for attribute 552 * New ID for attribute
550 */ 553 */
551 if (0 == attribute->id) 554 if (0 == attribute->id)
552 attribute->id = 555 attribute->id =
553 GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); 556 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX);
554 handle->idp = GNUNET_RECLAIM_connect(cfg); 557 handle->idp = GNUNET_RECLAIM_connect (cfg);
555 exp = GNUNET_TIME_UNIT_HOURS; 558 exp = GNUNET_TIME_UNIT_HOURS;
556 handle->idp_op = GNUNET_RECLAIM_attribute_store(handle->idp, 559 handle->idp_op = GNUNET_RECLAIM_attribute_store (handle->idp,
557 identity_priv, 560 identity_priv,
558 attribute, 561 attribute,
559 &exp, 562 &exp,
560 &finished_cont, 563 &finished_cont,
561 handle); 564 handle);
562 GNUNET_JSON_parse_free(attrspec); 565 GNUNET_JSON_parse_free (attrspec);
563} 566}
564 567
565 568
@@ -568,9 +571,9 @@ add_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle,
568 * 571 *
569 */ 572 */
570static void 573static void
571attr_collect(void *cls, 574attr_collect (void *cls,
572 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 575 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
573 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 576 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
574{ 577{
575 struct RequestHandle *handle = cls; 578 struct RequestHandle *handle = cls;
576 json_t *attr_obj; 579 json_t *attr_obj;
@@ -579,28 +582,28 @@ attr_collect(void *cls,
579 char *id_str; 582 char *id_str;
580 583
581 if ((NULL == attr->name) || (NULL == attr->data)) 584 if ((NULL == attr->name) || (NULL == attr->data))
582 { 585 {
583 GNUNET_RECLAIM_get_attributes_next(handle->attr_it); 586 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
584 return; 587 return;
585 } 588 }
586 589
587 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); 590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
588 591
589 tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string(attr->type, 592 tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type,
590 attr->data, 593 attr->data,
591 attr->data_size); 594 attr->data_size);
592 595
593 attr_obj = json_object(); 596 attr_obj = json_object ();
594 json_object_set_new(attr_obj, "value", json_string(tmp_value)); 597 json_object_set_new (attr_obj, "value", json_string (tmp_value));
595 json_object_set_new(attr_obj, "name", json_string(attr->name)); 598 json_object_set_new (attr_obj, "name", json_string (attr->name));
596 type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(attr->type); 599 type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
597 json_object_set_new(attr_obj, "type", json_string(type)); 600 json_object_set_new (attr_obj, "type", json_string (type));
598 id_str = GNUNET_STRINGS_data_to_string_alloc(&attr->id, sizeof(uint64_t)); 601 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t));
599 json_object_set_new(attr_obj, "id", json_string(id_str)); 602 json_object_set_new (attr_obj, "id", json_string (id_str));
600 json_array_append(handle->resp_object, attr_obj); 603 json_array_append (handle->resp_object, attr_obj);
601 json_decref(attr_obj); 604 json_decref (attr_obj);
602 GNUNET_free(tmp_value); 605 GNUNET_free (tmp_value);
603 GNUNET_RECLAIM_get_attributes_next(handle->attr_it); 606 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
604} 607}
605 608
606 609
@@ -612,67 +615,67 @@ attr_collect(void *cls,
612 * @param cls the RequestHandle 615 * @param cls the RequestHandle
613 */ 616 */
614static void 617static void
615list_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, 618list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
616 const char *url, 619 const char *url,
617 void *cls) 620 void *cls)
618{ 621{
619 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; 622 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
620 struct RequestHandle *handle = cls; 623 struct RequestHandle *handle = cls;
621 struct EgoEntry *ego_entry; 624 struct EgoEntry *ego_entry;
622 char *identity; 625 char *identity;
623 626
624 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 627 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
625 "Getting attributes for %s.\n", 628 "Getting attributes for %s.\n",
626 handle->url); 629 handle->url);
627 if (strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen(handle->url)) 630 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
628 { 631 {
629 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); 632 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
630 GNUNET_SCHEDULER_add_now(&do_error, handle); 633 GNUNET_SCHEDULER_add_now (&do_error, handle);
631 return; 634 return;
632 } 635 }
633 identity = handle->url + strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1; 636 identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1;
634 637
635 for (ego_entry = handle->ego_head; NULL != ego_entry; 638 for (ego_entry = handle->ego_head; NULL != ego_entry;
636 ego_entry = ego_entry->next) 639 ego_entry = ego_entry->next)
637 if (0 == strcmp(identity, ego_entry->identifier)) 640 if (0 == strcmp (identity, ego_entry->identifier))
638 break; 641 break;
639 handle->resp_object = json_array(); 642 handle->resp_object = json_array ();
640 643
641 644
642 if (NULL == ego_entry) 645 if (NULL == ego_entry)
643 { 646 {
644 // Done 647 // Done
645 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); 648 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
646 GNUNET_SCHEDULER_add_now(&return_response, handle); 649 GNUNET_SCHEDULER_add_now (&return_response, handle);
647 return; 650 return;
648 } 651 }
649 priv_key = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); 652 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
650 handle->idp = GNUNET_RECLAIM_connect(cfg); 653 handle->idp = GNUNET_RECLAIM_connect (cfg);
651 handle->attr_it = GNUNET_RECLAIM_get_attributes_start(handle->idp, 654 handle->attr_it = GNUNET_RECLAIM_get_attributes_start (handle->idp,
652 priv_key, 655 priv_key,
653 &collect_error_cb, 656 &collect_error_cb,
654 handle, 657 handle,
655 &attr_collect, 658 &attr_collect,
656 handle, 659 handle,
657 &collect_finished_cb, 660 &collect_finished_cb,
658 handle); 661 handle);
659} 662}
660 663
661 664
662static void 665static void
663delete_finished_cb(void *cls, int32_t success, const char *emsg) 666delete_finished_cb (void *cls, int32_t success, const char *emsg)
664{ 667{
665 struct RequestHandle *handle = cls; 668 struct RequestHandle *handle = cls;
666 struct MHD_Response *resp; 669 struct MHD_Response *resp;
667 670
668 resp = GNUNET_REST_create_response(emsg); 671 resp = GNUNET_REST_create_response (emsg);
669 if (GNUNET_OK != success) 672 if (GNUNET_OK != success)
670 { 673 {
671 GNUNET_SCHEDULER_add_now(&do_error, handle); 674 GNUNET_SCHEDULER_add_now (&do_error, handle);
672 return; 675 return;
673 } 676 }
674 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); 677 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
675 GNUNET_SCHEDULER_add_now(&cleanup_handle_delayed, handle); 678 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
676} 679}
677 680
678 681
@@ -684,9 +687,9 @@ delete_finished_cb(void *cls, int32_t success, const char *emsg)
684 * @param cls the RequestHandle 687 * @param cls the RequestHandle
685 */ 688 */
686static void 689static void
687delete_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, 690delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
688 const char *url, 691 const char *url,
689 void *cls) 692 void *cls)
690{ 693{
691 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; 694 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
692 struct RequestHandle *handle = cls; 695 struct RequestHandle *handle = cls;
@@ -696,56 +699,56 @@ delete_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle,
696 char *identity; 699 char *identity;
697 char *id; 700 char *id;
698 701
699 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n"); 702 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n");
700 if (strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen(handle->url)) 703 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
701 { 704 {
702 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); 705 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
703 GNUNET_SCHEDULER_add_now(&do_error, handle); 706 GNUNET_SCHEDULER_add_now (&do_error, handle);
704 return; 707 return;
705 } 708 }
706 identity_id_str = 709 identity_id_str =
707 strdup(handle->url + strlen(GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1); 710 strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1);
708 identity = strtok(identity_id_str, "/"); 711 identity = strtok (identity_id_str, "/");
709 id = strtok(NULL, "/"); 712 id = strtok (NULL, "/");
710 if ((NULL == identity) || (NULL == id)) 713 if ((NULL == identity) || (NULL == id))
711 { 714 {
712 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n"); 715 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
713 GNUNET_free(identity_id_str); 716 GNUNET_free (identity_id_str);
714 GNUNET_SCHEDULER_add_now(&do_error, handle); 717 GNUNET_SCHEDULER_add_now (&do_error, handle);
715 return; 718 return;
716 } 719 }
717 720
718 for (ego_entry = handle->ego_head; NULL != ego_entry; 721 for (ego_entry = handle->ego_head; NULL != ego_entry;
719 ego_entry = ego_entry->next) 722 ego_entry = ego_entry->next)
720 if (0 == strcmp(identity, ego_entry->identifier)) 723 if (0 == strcmp (identity, ego_entry->identifier))
721 break; 724 break;
722 handle->resp_object = json_array(); 725 handle->resp_object = json_array ();
723 if (NULL == ego_entry) 726 if (NULL == ego_entry)
724 { 727 {
725 // Done 728 // Done
726 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); 729 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
727 GNUNET_free(identity_id_str); 730 GNUNET_free (identity_id_str);
728 GNUNET_SCHEDULER_add_now(&return_response, handle); 731 GNUNET_SCHEDULER_add_now (&return_response, handle);
729 return; 732 return;
730 } 733 }
731 priv_key = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); 734 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
732 handle->idp = GNUNET_RECLAIM_connect(cfg); 735 handle->idp = GNUNET_RECLAIM_connect (cfg);
733 memset(&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)); 736 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim));
734 GNUNET_STRINGS_string_to_data(id, strlen(id), &attr.id, sizeof(uint64_t)); 737 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(uint64_t));
735 attr.name = ""; 738 attr.name = "";
736 handle->idp_op = GNUNET_RECLAIM_attribute_delete(handle->idp, 739 handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp,
737 priv_key, 740 priv_key,
738 &attr, 741 &attr,
739 &delete_finished_cb, 742 &delete_finished_cb,
740 handle); 743 handle);
741 GNUNET_free(identity_id_str); 744 GNUNET_free (identity_id_str);
742} 745}
743 746
744 747
745static void 748static void
746revoke_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, 749revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle,
747 const char *url, 750 const char *url,
748 void *cls) 751 void *cls)
749{ 752{
750 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; 753 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
751 struct RequestHandle *handle = cls; 754 struct RequestHandle *handle = cls;
@@ -756,101 +759,101 @@ revoke_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle,
756 json_t *data_json; 759 json_t *data_json;
757 json_error_t err; 760 json_error_t err;
758 struct GNUNET_JSON_Specification tktspec[] = 761 struct GNUNET_JSON_Specification tktspec[] =
759 { GNUNET_RECLAIM_JSON_spec_ticket(&ticket), GNUNET_JSON_spec_end() }; 762 { GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end () };
760 763
761 if (0 >= handle->rest_handle->data_size) 764 if (0 >= handle->rest_handle->data_size)
762 { 765 {
763 GNUNET_SCHEDULER_add_now(&do_error, handle); 766 GNUNET_SCHEDULER_add_now (&do_error, handle);
764 return; 767 return;
765 } 768 }
766 769
767 term_data[handle->rest_handle->data_size] = '\0'; 770 term_data[handle->rest_handle->data_size] = '\0';
768 GNUNET_memcpy(term_data, 771 GNUNET_memcpy (term_data,
769 handle->rest_handle->data, 772 handle->rest_handle->data,
770 handle->rest_handle->data_size); 773 handle->rest_handle->data_size);
771 data_json = json_loads(term_data, JSON_DECODE_ANY, &err); 774 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
772 if ((NULL == data_json) || 775 if ((NULL == data_json) ||
773 (GNUNET_OK != GNUNET_JSON_parse(data_json, tktspec, NULL, NULL))) 776 (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)))
774 { 777 {
775 handle->emsg = GNUNET_strdup("Not a ticket!\n"); 778 handle->emsg = GNUNET_strdup ("Not a ticket!\n");
776 GNUNET_SCHEDULER_add_now(&do_error, handle); 779 GNUNET_SCHEDULER_add_now (&do_error, handle);
777 GNUNET_JSON_parse_free(tktspec); 780 GNUNET_JSON_parse_free (tktspec);
778 if (NULL != data_json) 781 if (NULL != data_json)
779 json_decref(data_json); 782 json_decref (data_json);
780 return; 783 return;
781 } 784 }
782 json_decref(data_json); 785 json_decref (data_json);
783 if (NULL == ticket) 786 if (NULL == ticket)
784 { 787 {
785 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 788 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
786 "Unable to parse ticket from %s\n", 789 "Unable to parse ticket from %s\n",
787 term_data); 790 term_data);
788 GNUNET_SCHEDULER_add_now(&do_error, handle); 791 GNUNET_SCHEDULER_add_now (&do_error, handle);
789 return; 792 return;
790 } 793 }
791 794
792 for (ego_entry = handle->ego_head; NULL != ego_entry; 795 for (ego_entry = handle->ego_head; NULL != ego_entry;
793 ego_entry = ego_entry->next) 796 ego_entry = ego_entry->next)
794 { 797 {
795 GNUNET_IDENTITY_ego_get_public_key(ego_entry->ego, &tmp_pk); 798 GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
796 if (0 == memcmp(&ticket->identity, 799 if (0 == memcmp (&ticket->identity,
797 &tmp_pk, 800 &tmp_pk,
798 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) 801 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
799 break; 802 break;
800 } 803 }
801 if (NULL == ego_entry) 804 if (NULL == ego_entry)
802 { 805 {
803 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n"); 806 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
804 GNUNET_JSON_parse_free(tktspec); 807 GNUNET_JSON_parse_free (tktspec);
805 return; 808 return;
806 } 809 }
807 identity_priv = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); 810 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
808 811
809 handle->idp = GNUNET_RECLAIM_connect(cfg); 812 handle->idp = GNUNET_RECLAIM_connect (cfg);
810 handle->idp_op = GNUNET_RECLAIM_ticket_revoke(handle->idp, 813 handle->idp_op = GNUNET_RECLAIM_ticket_revoke (handle->idp,
811 identity_priv, 814 identity_priv,
812 ticket, 815 ticket,
813 &finished_cont, 816 &finished_cont,
814 handle); 817 handle);
815 GNUNET_JSON_parse_free(tktspec); 818 GNUNET_JSON_parse_free (tktspec);
816} 819}
817 820
818static void 821static void
819consume_cont(void *cls, 822consume_cont (void *cls,
820 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 823 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
821 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 824 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
822{ 825{
823 struct RequestHandle *handle = cls; 826 struct RequestHandle *handle = cls;
824 char *val_str; 827 char *val_str;
825 json_t *value; 828 json_t *value;
826 829
827 if (NULL == identity) 830 if (NULL == identity)
828 { 831 {
829 GNUNET_SCHEDULER_add_now(&return_response, handle); 832 GNUNET_SCHEDULER_add_now (&return_response, handle);
830 return; 833 return;
831 } 834 }
832 835
833 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); 836 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
834 val_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string(attr->type, 837 val_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type,
835 attr->data, 838 attr->data,
836 attr->data_size); 839 attr->data_size);
837 if (NULL == val_str) 840 if (NULL == val_str)
838 { 841 {
839 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 842 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
840 "Failed to parse value for: %s\n", 843 "Failed to parse value for: %s\n",
841 attr->name); 844 attr->name);
842 return; 845 return;
843 } 846 }
844 value = json_string(val_str); 847 value = json_string (val_str);
845 json_object_set_new(handle->resp_object, attr->name, value); 848 json_object_set_new (handle->resp_object, attr->name, value);
846 json_decref(value); 849 json_decref (value);
847 GNUNET_free(val_str); 850 GNUNET_free (val_str);
848} 851}
849 852
850static void 853static void
851consume_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, 854consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle,
852 const char *url, 855 const char *url,
853 void *cls) 856 void *cls)
854{ 857{
855 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; 858 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
856 struct RequestHandle *handle = cls; 859 struct RequestHandle *handle = cls;
@@ -861,59 +864,59 @@ consume_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle,
861 json_t *data_json; 864 json_t *data_json;
862 json_error_t err; 865 json_error_t err;
863 struct GNUNET_JSON_Specification tktspec[] = 866 struct GNUNET_JSON_Specification tktspec[] =
864 { GNUNET_RECLAIM_JSON_spec_ticket(&ticket), GNUNET_JSON_spec_end() }; 867 { GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end () };
865 868
866 if (0 >= handle->rest_handle->data_size) 869 if (0 >= handle->rest_handle->data_size)
867 { 870 {
868 GNUNET_SCHEDULER_add_now(&do_error, handle); 871 GNUNET_SCHEDULER_add_now (&do_error, handle);
869 return; 872 return;
870 } 873 }
871 874
872 term_data[handle->rest_handle->data_size] = '\0'; 875 term_data[handle->rest_handle->data_size] = '\0';
873 GNUNET_memcpy(term_data, 876 GNUNET_memcpy (term_data,
874 handle->rest_handle->data, 877 handle->rest_handle->data,
875 handle->rest_handle->data_size); 878 handle->rest_handle->data_size);
876 data_json = json_loads(term_data, JSON_DECODE_ANY, &err); 879 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
877 if (NULL == data_json) 880 if (NULL == data_json)
878 { 881 {
879 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 882 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
880 "Unable to parse JSON Object from %s\n", 883 "Unable to parse JSON Object from %s\n",
881 term_data); 884 term_data);
882 GNUNET_SCHEDULER_add_now(&do_error, handle); 885 GNUNET_SCHEDULER_add_now (&do_error, handle);
883 return; 886 return;
884 } 887 }
885 if (GNUNET_OK != GNUNET_JSON_parse(data_json, tktspec, NULL, NULL)) 888 if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL))
886 { 889 {
887 handle->emsg = GNUNET_strdup("Not a ticket!\n"); 890 handle->emsg = GNUNET_strdup ("Not a ticket!\n");
888 GNUNET_SCHEDULER_add_now(&do_error, handle); 891 GNUNET_SCHEDULER_add_now (&do_error, handle);
889 GNUNET_JSON_parse_free(tktspec); 892 GNUNET_JSON_parse_free (tktspec);
890 json_decref(data_json); 893 json_decref (data_json);
891 return; 894 return;
892 } 895 }
893 for (ego_entry = handle->ego_head; NULL != ego_entry; 896 for (ego_entry = handle->ego_head; NULL != ego_entry;
894 ego_entry = ego_entry->next) 897 ego_entry = ego_entry->next)
895 { 898 {
896 GNUNET_IDENTITY_ego_get_public_key(ego_entry->ego, &tmp_pk); 899 GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
897 if (0 == memcmp(&ticket->audience, 900 if (0 == memcmp (&ticket->audience,
898 &tmp_pk, 901 &tmp_pk,
899 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) 902 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
900 break; 903 break;
901 } 904 }
902 if (NULL == ego_entry) 905 if (NULL == ego_entry)
903 { 906 {
904 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n"); 907 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
905 GNUNET_JSON_parse_free(tktspec); 908 GNUNET_JSON_parse_free (tktspec);
906 return; 909 return;
907 } 910 }
908 identity_priv = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); 911 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
909 handle->resp_object = json_object(); 912 handle->resp_object = json_object ();
910 handle->idp = GNUNET_RECLAIM_connect(cfg); 913 handle->idp = GNUNET_RECLAIM_connect (cfg);
911 handle->idp_op = GNUNET_RECLAIM_ticket_consume(handle->idp, 914 handle->idp_op = GNUNET_RECLAIM_ticket_consume (handle->idp,
912 identity_priv, 915 identity_priv,
913 ticket, 916 ticket,
914 &consume_cont, 917 &consume_cont,
915 handle); 918 handle);
916 GNUNET_JSON_parse_free(tktspec); 919 GNUNET_JSON_parse_free (tktspec);
917} 920}
918 921
919 922
@@ -925,18 +928,18 @@ consume_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle,
925 * @param cls the RequestHandle 928 * @param cls the RequestHandle
926 */ 929 */
927static void 930static void
928options_cont(struct GNUNET_REST_RequestHandle *con_handle, 931options_cont (struct GNUNET_REST_RequestHandle *con_handle,
929 const char *url, 932 const char *url,
930 void *cls) 933 void *cls)
931{ 934{
932 struct MHD_Response *resp; 935 struct MHD_Response *resp;
933 struct RequestHandle *handle = cls; 936 struct RequestHandle *handle = cls;
934 937
935 // For now, independent of path return all options 938 // For now, independent of path return all options
936 resp = GNUNET_REST_create_response(NULL); 939 resp = GNUNET_REST_create_response (NULL);
937 MHD_add_response_header(resp, "Access-Control-Allow-Methods", allow_methods); 940 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
938 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); 941 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
939 cleanup_handle(handle); 942 cleanup_handle (handle);
940 return; 943 return;
941} 944}
942 945
@@ -946,7 +949,7 @@ options_cont(struct GNUNET_REST_RequestHandle *con_handle,
946 * @param handle the request handle 949 * @param handle the request handle
947 */ 950 */
948static void 951static void
949init_cont(struct RequestHandle *handle) 952init_cont (struct RequestHandle *handle)
950{ 953{
951 struct GNUNET_REST_RequestHandlerError err; 954 struct GNUNET_REST_RequestHandlerError err;
952 static const struct GNUNET_REST_RequestHandler handlers[] = 955 static const struct GNUNET_REST_RequestHandler handlers[] =
@@ -954,29 +957,29 @@ init_cont(struct RequestHandle *handle)
954 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, 957 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES,
955 &list_attribute_cont }, 958 &list_attribute_cont },
956 { MHD_HTTP_METHOD_POST, 959 { MHD_HTTP_METHOD_POST,
957 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, 960 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES,
958 &add_attribute_cont }, 961 &add_attribute_cont },
959 { MHD_HTTP_METHOD_DELETE, 962 { MHD_HTTP_METHOD_DELETE,
960 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, 963 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES,
961 &delete_attribute_cont }, 964 &delete_attribute_cont },
962 { MHD_HTTP_METHOD_GET, 965 { MHD_HTTP_METHOD_GET,
963 GNUNET_REST_API_NS_IDENTITY_TICKETS, 966 GNUNET_REST_API_NS_IDENTITY_TICKETS,
964 &list_tickets_cont }, 967 &list_tickets_cont },
965 { MHD_HTTP_METHOD_POST, 968 { MHD_HTTP_METHOD_POST,
966 GNUNET_REST_API_NS_IDENTITY_REVOKE, 969 GNUNET_REST_API_NS_IDENTITY_REVOKE,
967 &revoke_ticket_cont }, 970 &revoke_ticket_cont },
968 { MHD_HTTP_METHOD_POST, 971 { MHD_HTTP_METHOD_POST,
969 GNUNET_REST_API_NS_IDENTITY_CONSUME, 972 GNUNET_REST_API_NS_IDENTITY_CONSUME,
970 &consume_ticket_cont }, 973 &consume_ticket_cont },
971 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont }, 974 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
972 GNUNET_REST_HANDLER_END }; 975 GNUNET_REST_HANDLER_END };
973 976
974 if (GNUNET_NO == 977 if (GNUNET_NO ==
975 GNUNET_REST_handle_request(handle->rest_handle, handlers, &err, handle)) 978 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
976 { 979 {
977 handle->response_code = err.error_code; 980 handle->response_code = err.error_code;
978 GNUNET_SCHEDULER_add_now(&do_error, handle); 981 GNUNET_SCHEDULER_add_now (&do_error, handle);
979 } 982 }
980} 983}
981 984
982/** 985/**
@@ -1013,40 +1016,40 @@ init_cont(struct RequestHandle *handle)
1013 * must thus no longer be used 1016 * must thus no longer be used
1014 */ 1017 */
1015static void 1018static void
1016list_ego(void *cls, 1019list_ego (void *cls,
1017 struct GNUNET_IDENTITY_Ego *ego, 1020 struct GNUNET_IDENTITY_Ego *ego,
1018 void **ctx, 1021 void **ctx,
1019 const char *identifier) 1022 const char *identifier)
1020{ 1023{
1021 struct RequestHandle *handle = cls; 1024 struct RequestHandle *handle = cls;
1022 struct EgoEntry *ego_entry; 1025 struct EgoEntry *ego_entry;
1023 struct GNUNET_CRYPTO_EcdsaPublicKey pk; 1026 struct GNUNET_CRYPTO_EcdsaPublicKey pk;
1024 1027
1025 if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state)) 1028 if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state))
1026 { 1029 {
1027 handle->state = ID_REST_STATE_POST_INIT; 1030 handle->state = ID_REST_STATE_POST_INIT;
1028 init_cont(handle); 1031 init_cont (handle);
1029 return; 1032 return;
1030 } 1033 }
1031 if (ID_REST_STATE_INIT == handle->state) 1034 if (ID_REST_STATE_INIT == handle->state)
1032 { 1035 {
1033 ego_entry = GNUNET_new(struct EgoEntry); 1036 ego_entry = GNUNET_new (struct EgoEntry);
1034 GNUNET_IDENTITY_ego_get_public_key(ego, &pk); 1037 GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
1035 ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string(&pk); 1038 ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
1036 ego_entry->ego = ego; 1039 ego_entry->ego = ego;
1037 ego_entry->identifier = GNUNET_strdup(identifier); 1040 ego_entry->identifier = GNUNET_strdup (identifier);
1038 GNUNET_CONTAINER_DLL_insert_tail(handle->ego_head, 1041 GNUNET_CONTAINER_DLL_insert_tail (handle->ego_head,
1039 handle->ego_tail, 1042 handle->ego_tail,
1040 ego_entry); 1043 ego_entry);
1041 } 1044 }
1042} 1045}
1043 1046
1044static void 1047static void
1045rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle, 1048rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
1046 GNUNET_REST_ResultProcessor proc, 1049 GNUNET_REST_ResultProcessor proc,
1047 void *proc_cls) 1050 void *proc_cls)
1048{ 1051{
1049 struct RequestHandle *handle = GNUNET_new(struct RequestHandle); 1052 struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1050 1053
1051 handle->response_code = 0; 1054 handle->response_code = 0;
1052 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; 1055 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -1055,14 +1058,14 @@ rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle,
1055 handle->state = ID_REST_STATE_INIT; 1058 handle->state = ID_REST_STATE_INIT;
1056 handle->rest_handle = rest_handle; 1059 handle->rest_handle = rest_handle;
1057 1060
1058 handle->url = GNUNET_strdup(rest_handle->url); 1061 handle->url = GNUNET_strdup (rest_handle->url);
1059 if (handle->url[strlen(handle->url) - 1] == '/') 1062 if (handle->url[strlen (handle->url) - 1] == '/')
1060 handle->url[strlen(handle->url) - 1] = '\0'; 1063 handle->url[strlen (handle->url) - 1] = '\0';
1061 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); 1064 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
1062 handle->identity_handle = GNUNET_IDENTITY_connect(cfg, &list_ego, handle); 1065 handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, handle);
1063 handle->timeout_task = 1066 handle->timeout_task =
1064 GNUNET_SCHEDULER_add_delayed(handle->timeout, &do_timeout, handle); 1067 GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
1065 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); 1068 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
1066} 1069}
1067 1070
1068/** 1071/**
@@ -1072,7 +1075,7 @@ rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle,
1072 * @return NULL on error, otherwise the plugin context 1075 * @return NULL on error, otherwise the plugin context
1073 */ 1076 */
1074void * 1077void *
1075libgnunet_plugin_rest_reclaim_init(void *cls) 1078libgnunet_plugin_rest_reclaim_init (void *cls)
1076{ 1079{
1077 static struct Plugin plugin; 1080 static struct Plugin plugin;
1078 struct GNUNET_REST_Plugin *api; 1081 struct GNUNET_REST_Plugin *api;
@@ -1080,22 +1083,22 @@ libgnunet_plugin_rest_reclaim_init(void *cls)
1080 cfg = cls; 1083 cfg = cls;
1081 if (NULL != plugin.cfg) 1084 if (NULL != plugin.cfg)
1082 return NULL; /* can only initialize once! */ 1085 return NULL; /* can only initialize once! */
1083 memset(&plugin, 0, sizeof(struct Plugin)); 1086 memset (&plugin, 0, sizeof(struct Plugin));
1084 plugin.cfg = cfg; 1087 plugin.cfg = cfg;
1085 api = GNUNET_new(struct GNUNET_REST_Plugin); 1088 api = GNUNET_new (struct GNUNET_REST_Plugin);
1086 api->cls = &plugin; 1089 api->cls = &plugin;
1087 api->name = GNUNET_REST_API_NS_RECLAIM; 1090 api->name = GNUNET_REST_API_NS_RECLAIM;
1088 api->process_request = &rest_identity_process_request; 1091 api->process_request = &rest_identity_process_request;
1089 GNUNET_asprintf(&allow_methods, 1092 GNUNET_asprintf (&allow_methods,
1090 "%s, %s, %s, %s, %s", 1093 "%s, %s, %s, %s, %s",
1091 MHD_HTTP_METHOD_GET, 1094 MHD_HTTP_METHOD_GET,
1092 MHD_HTTP_METHOD_POST, 1095 MHD_HTTP_METHOD_POST,
1093 MHD_HTTP_METHOD_PUT, 1096 MHD_HTTP_METHOD_PUT,
1094 MHD_HTTP_METHOD_DELETE, 1097 MHD_HTTP_METHOD_DELETE,
1095 MHD_HTTP_METHOD_OPTIONS); 1098 MHD_HTTP_METHOD_OPTIONS);
1096 1099
1097 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1098 _("Identity Provider REST API initialized\n")); 1101 _ ("Identity Provider REST API initialized\n"));
1099 return api; 1102 return api;
1100} 1103}
1101 1104
@@ -1107,17 +1110,17 @@ libgnunet_plugin_rest_reclaim_init(void *cls)
1107 * @return always NULL 1110 * @return always NULL
1108 */ 1111 */
1109void * 1112void *
1110libgnunet_plugin_rest_reclaim_done(void *cls) 1113libgnunet_plugin_rest_reclaim_done (void *cls)
1111{ 1114{
1112 struct GNUNET_REST_Plugin *api = cls; 1115 struct GNUNET_REST_Plugin *api = cls;
1113 struct Plugin *plugin = api->cls; 1116 struct Plugin *plugin = api->cls;
1114 1117
1115 plugin->cfg = NULL; 1118 plugin->cfg = NULL;
1116 1119
1117 GNUNET_free_non_null(allow_methods); 1120 GNUNET_free_non_null (allow_methods);
1118 GNUNET_free(api); 1121 GNUNET_free (api);
1119 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1120 "Identity Provider REST plugin is finished\n"); 1123 "Identity Provider REST plugin is finished\n");
1121 return NULL; 1124 return NULL;
1122} 1125}
1123 1126
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h
index 87e343b51..8e731812e 100644
--- a/src/reclaim/reclaim.h
+++ b/src/reclaim/reclaim.h
@@ -37,7 +37,8 @@ GNUNET_NETWORK_STRUCT_BEGIN
37/** 37/**
38 * Use to store an identity attribute 38 * Use to store an identity attribute
39 */ 39 */
40struct AttributeStoreMessage { 40struct AttributeStoreMessage
41{
41 /** 42 /**
42 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT 43 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
43 */ 44 */
@@ -70,7 +71,8 @@ struct AttributeStoreMessage {
70/** 71/**
71 * Use to delete an identity attribute 72 * Use to delete an identity attribute
72 */ 73 */
73struct AttributeDeleteMessage { 74struct AttributeDeleteMessage
75{
74 /** 76 /**
75 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT 77 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
76 */ 78 */
@@ -98,7 +100,8 @@ struct AttributeDeleteMessage {
98/** 100/**
99 * Attribute store/delete response message 101 * Attribute store/delete response message
100 */ 102 */
101struct SuccessResultMessage { 103struct SuccessResultMessage
104{
102 /** 105 /**
103 * Message header 106 * Message header
104 */ 107 */
@@ -118,7 +121,8 @@ struct SuccessResultMessage {
118/** 121/**
119 * Attribute is returned from the idp. 122 * Attribute is returned from the idp.
120 */ 123 */
121struct AttributeResultMessage { 124struct AttributeResultMessage
125{
122 /** 126 /**
123 * Message header 127 * Message header
124 */ 128 */
@@ -153,7 +157,8 @@ struct AttributeResultMessage {
153/** 157/**
154 * Start a attribute iteration for the given identity 158 * Start a attribute iteration for the given identity
155 */ 159 */
156struct AttributeIterationStartMessage { 160struct AttributeIterationStartMessage
161{
157 /** 162 /**
158 * Message 163 * Message
159 */ 164 */
@@ -174,7 +179,8 @@ struct AttributeIterationStartMessage {
174/** 179/**
175 * Ask for next result of attribute iteration for the given operation 180 * Ask for next result of attribute iteration for the given operation
176 */ 181 */
177struct AttributeIterationNextMessage { 182struct AttributeIterationNextMessage
183{
178 /** 184 /**
179 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT 185 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
180 */ 186 */
@@ -190,7 +196,8 @@ struct AttributeIterationNextMessage {
190/** 196/**
191 * Stop attribute iteration for the given operation 197 * Stop attribute iteration for the given operation
192 */ 198 */
193struct AttributeIterationStopMessage { 199struct AttributeIterationStopMessage
200{
194 /** 201 /**
195 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP 202 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
196 */ 203 */
@@ -205,7 +212,8 @@ struct AttributeIterationStopMessage {
205/** 212/**
206 * Start a ticket iteration for the given identity 213 * Start a ticket iteration for the given identity
207 */ 214 */
208struct TicketIterationStartMessage { 215struct TicketIterationStartMessage
216{
209 /** 217 /**
210 * Message 218 * Message
211 */ 219 */
@@ -226,7 +234,8 @@ struct TicketIterationStartMessage {
226/** 234/**
227 * Ask for next result of ticket iteration for the given operation 235 * Ask for next result of ticket iteration for the given operation
228 */ 236 */
229struct TicketIterationNextMessage { 237struct TicketIterationNextMessage
238{
230 /** 239 /**
231 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT 240 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT
232 */ 241 */
@@ -242,7 +251,8 @@ struct TicketIterationNextMessage {
242/** 251/**
243 * Stop ticket iteration for the given operation 252 * Stop ticket iteration for the given operation
244 */ 253 */
245struct TicketIterationStopMessage { 254struct TicketIterationStopMessage
255{
246 /** 256 /**
247 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP 257 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP
248 */ 258 */
@@ -258,7 +268,8 @@ struct TicketIterationStopMessage {
258/** 268/**
259 * Ticket issue message 269 * Ticket issue message
260 */ 270 */
261struct IssueTicketMessage { 271struct IssueTicketMessage
272{
262 /** 273 /**
263 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET 274 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET
264 */ 275 */
@@ -290,7 +301,8 @@ struct IssueTicketMessage {
290/** 301/**
291 * Ticket revoke message 302 * Ticket revoke message
292 */ 303 */
293struct RevokeTicketMessage { 304struct RevokeTicketMessage
305{
294 /** 306 /**
295 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET 307 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET
296 */ 308 */
@@ -320,7 +332,8 @@ struct RevokeTicketMessage {
320/** 332/**
321 * Ticket revoke message 333 * Ticket revoke message
322 */ 334 */
323struct RevokeTicketResultMessage { 335struct RevokeTicketResultMessage
336{
324 /** 337 /**
325 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT 338 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
326 */ 339 */
@@ -341,7 +354,8 @@ struct RevokeTicketResultMessage {
341/** 354/**
342 * Ticket result message 355 * Ticket result message
343 */ 356 */
344struct TicketResultMessage { 357struct TicketResultMessage
358{
345 /** 359 /**
346 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT 360 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
347 */ 361 */
@@ -361,7 +375,8 @@ struct TicketResultMessage {
361/** 375/**
362 * Ticket consume message 376 * Ticket consume message
363 */ 377 */
364struct ConsumeTicketMessage { 378struct ConsumeTicketMessage
379{
365 /** 380 /**
366 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET 381 * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET
367 */ 382 */
@@ -386,7 +401,8 @@ struct ConsumeTicketMessage {
386/** 401/**
387 * Attribute list is returned from the idp. 402 * Attribute list is returned from the idp.
388 */ 403 */
389struct ConsumeTicketResultMessage { 404struct ConsumeTicketResultMessage
405{
390 /** 406 /**
391 * Message header 407 * Message header
392 */ 408 */
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index a8790cd8e..3e03d973b 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -32,13 +32,14 @@
32#include "gnunet_reclaim_service.h" 32#include "gnunet_reclaim_service.h"
33#include "reclaim.h" 33#include "reclaim.h"
34 34
35#define LOG(kind, ...) GNUNET_log_from(kind, "reclaim-api", __VA_ARGS__) 35#define LOG(kind, ...) GNUNET_log_from (kind, "reclaim-api", __VA_ARGS__)
36 36
37 37
38/** 38/**
39 * Handle for an operation with the service. 39 * Handle for an operation with the service.
40 */ 40 */
41struct GNUNET_RECLAIM_Operation { 41struct GNUNET_RECLAIM_Operation
42{
42 /** 43 /**
43 * Main handle. 44 * Main handle.
44 */ 45 */
@@ -100,7 +101,8 @@ struct GNUNET_RECLAIM_Operation {
100/** 101/**
101 * Handle for a ticket iterator operation 102 * Handle for a ticket iterator operation
102 */ 103 */
103struct GNUNET_RECLAIM_TicketIterator { 104struct GNUNET_RECLAIM_TicketIterator
105{
104 /** 106 /**
105 * Kept in a DLL. 107 * Kept in a DLL.
106 */ 108 */
@@ -162,7 +164,8 @@ struct GNUNET_RECLAIM_TicketIterator {
162/** 164/**
163 * Handle for a attribute iterator operation 165 * Handle for a attribute iterator operation
164 */ 166 */
165struct GNUNET_RECLAIM_AttributeIterator { 167struct GNUNET_RECLAIM_AttributeIterator
168{
166 /** 169 /**
167 * Kept in a DLL. 170 * Kept in a DLL.
168 */ 171 */
@@ -229,7 +232,8 @@ struct GNUNET_RECLAIM_AttributeIterator {
229/** 232/**
230 * Handle to the service. 233 * Handle to the service.
231 */ 234 */
232struct GNUNET_RECLAIM_Handle { 235struct GNUNET_RECLAIM_Handle
236{
233 /** 237 /**
234 * Configuration to use. 238 * Configuration to use.
235 */ 239 */
@@ -313,7 +317,7 @@ struct GNUNET_RECLAIM_Handle {
313 * @param h handle to the reclaim service. 317 * @param h handle to the reclaim service.
314 */ 318 */
315static void 319static void
316reconnect(struct GNUNET_RECLAIM_Handle *h); 320reconnect (struct GNUNET_RECLAIM_Handle *h);
317 321
318 322
319/** 323/**
@@ -322,12 +326,12 @@ reconnect(struct GNUNET_RECLAIM_Handle *h);
322 * @param cls the handle 326 * @param cls the handle
323 */ 327 */
324static void 328static void
325reconnect_task(void *cls) 329reconnect_task (void *cls)
326{ 330{
327 struct GNUNET_RECLAIM_Handle *handle = cls; 331 struct GNUNET_RECLAIM_Handle *handle = cls;
328 332
329 handle->reconnect_task = NULL; 333 handle->reconnect_task = NULL;
330 reconnect(handle); 334 reconnect (handle);
331} 335}
332 336
333 337
@@ -337,16 +341,16 @@ reconnect_task(void *cls)
337 * @param handle our service 341 * @param handle our service
338 */ 342 */
339static void 343static void
340force_reconnect(struct GNUNET_RECLAIM_Handle *handle) 344force_reconnect (struct GNUNET_RECLAIM_Handle *handle)
341{ 345{
342 GNUNET_MQ_destroy(handle->mq); 346 GNUNET_MQ_destroy (handle->mq);
343 handle->mq = NULL; 347 handle->mq = NULL;
344 handle->reconnect_backoff = 348 handle->reconnect_backoff =
345 GNUNET_TIME_STD_BACKOFF(handle->reconnect_backoff); 349 GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
346 handle->reconnect_task = 350 handle->reconnect_task =
347 GNUNET_SCHEDULER_add_delayed(handle->reconnect_backoff, 351 GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff,
348 &reconnect_task, 352 &reconnect_task,
349 handle); 353 handle);
350} 354}
351 355
352 356
@@ -356,14 +360,14 @@ force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
356 * @param it entry to free 360 * @param it entry to free
357 */ 361 */
358static void 362static void
359free_it(struct GNUNET_RECLAIM_AttributeIterator *it) 363free_it (struct GNUNET_RECLAIM_AttributeIterator *it)
360{ 364{
361 struct GNUNET_RECLAIM_Handle *h = it->h; 365 struct GNUNET_RECLAIM_Handle *h = it->h;
362 366
363 GNUNET_CONTAINER_DLL_remove(h->it_head, h->it_tail, it); 367 GNUNET_CONTAINER_DLL_remove (h->it_head, h->it_tail, it);
364 if (NULL != it->env) 368 if (NULL != it->env)
365 GNUNET_MQ_discard(it->env); 369 GNUNET_MQ_discard (it->env);
366 GNUNET_free(it); 370 GNUNET_free (it);
367} 371}
368 372
369/** 373/**
@@ -372,13 +376,13 @@ free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
372 * @param op the operation to free 376 * @param op the operation to free
373 */ 377 */
374static void 378static void
375free_op(struct GNUNET_RECLAIM_Operation *op) 379free_op (struct GNUNET_RECLAIM_Operation *op)
376{ 380{
377 if (NULL == op) 381 if (NULL == op)
378 return; 382 return;
379 if (NULL != op->env) 383 if (NULL != op->env)
380 GNUNET_MQ_discard(op->env); 384 GNUNET_MQ_discard (op->env);
381 GNUNET_free(op); 385 GNUNET_free (op);
382} 386}
383 387
384 388
@@ -391,11 +395,11 @@ free_op(struct GNUNET_RECLAIM_Operation *op)
391 * @param error error code 395 * @param error error code
392 */ 396 */
393static void 397static void
394mq_error_handler(void *cls, enum GNUNET_MQ_Error error) 398mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
395{ 399{
396 struct GNUNET_RECLAIM_Handle *handle = cls; 400 struct GNUNET_RECLAIM_Handle *handle = cls;
397 401
398 force_reconnect(handle); 402 force_reconnect (handle);
399} 403}
400 404
401 405
@@ -407,11 +411,11 @@ mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
407 * @param msg the message we received 411 * @param msg the message we received
408 */ 412 */
409static void 413static void
410handle_success_response(void *cls, const struct SuccessResultMessage *msg) 414handle_success_response (void *cls, const struct SuccessResultMessage *msg)
411{ 415{
412 struct GNUNET_RECLAIM_Handle *h = cls; 416 struct GNUNET_RECLAIM_Handle *h = cls;
413 struct GNUNET_RECLAIM_Operation *op; 417 struct GNUNET_RECLAIM_Operation *op;
414 uint32_t r_id = ntohl(msg->id); 418 uint32_t r_id = ntohl (msg->id);
415 int res; 419 int res;
416 const char *emsg; 420 const char *emsg;
417 421
@@ -421,20 +425,20 @@ handle_success_response(void *cls, const struct SuccessResultMessage *msg)
421 if (NULL == op) 425 if (NULL == op)
422 return; 426 return;
423 427
424 res = ntohl(msg->op_result); 428 res = ntohl (msg->op_result);
425 LOG(GNUNET_ERROR_TYPE_DEBUG, 429 LOG (GNUNET_ERROR_TYPE_DEBUG,
426 "Received SUCCESS_RESPONSE with result %d\n", 430 "Received SUCCESS_RESPONSE with result %d\n",
427 res); 431 res);
428 432
429 /* TODO: add actual error message to response... */ 433 /* TODO: add actual error message to response... */
430 if (GNUNET_SYSERR == res) 434 if (GNUNET_SYSERR == res)
431 emsg = _("failed to store record\n"); 435 emsg = _ ("failed to store record\n");
432 else 436 else
433 emsg = NULL; 437 emsg = NULL;
434 if (NULL != op->as_cb) 438 if (NULL != op->as_cb)
435 op->as_cb(op->cls, res, emsg); 439 op->as_cb (op->cls, res, emsg);
436 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); 440 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
437 free_op(op); 441 free_op (op);
438} 442}
439 443
440 444
@@ -447,19 +451,19 @@ handle_success_response(void *cls, const struct SuccessResultMessage *msg)
447 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 451 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
448 */ 452 */
449static int 453static int
450check_consume_ticket_result(void *cls, 454check_consume_ticket_result (void *cls,
451 const struct ConsumeTicketResultMessage *msg) 455 const struct ConsumeTicketResultMessage *msg)
452{ 456{
453 size_t msg_len; 457 size_t msg_len;
454 size_t attrs_len; 458 size_t attrs_len;
455 459
456 msg_len = ntohs(msg->header.size); 460 msg_len = ntohs (msg->header.size);
457 attrs_len = ntohs(msg->attrs_len); 461 attrs_len = ntohs (msg->attrs_len);
458 if (msg_len != sizeof(struct ConsumeTicketResultMessage) + attrs_len) 462 if (msg_len != sizeof(struct ConsumeTicketResultMessage) + attrs_len)
459 { 463 {
460 GNUNET_break(0); 464 GNUNET_break (0);
461 return GNUNET_SYSERR; 465 return GNUNET_SYSERR;
462 } 466 }
463 return GNUNET_OK; 467 return GNUNET_OK;
464} 468}
465 469
@@ -472,16 +476,16 @@ check_consume_ticket_result(void *cls,
472 * @param msg the message we received 476 * @param msg the message we received
473 */ 477 */
474static void 478static void
475handle_consume_ticket_result(void *cls, 479handle_consume_ticket_result (void *cls,
476 const struct ConsumeTicketResultMessage *msg) 480 const struct ConsumeTicketResultMessage *msg)
477{ 481{
478 struct GNUNET_RECLAIM_Handle *h = cls; 482 struct GNUNET_RECLAIM_Handle *h = cls;
479 struct GNUNET_RECLAIM_Operation *op; 483 struct GNUNET_RECLAIM_Operation *op;
480 size_t attrs_len; 484 size_t attrs_len;
481 uint32_t r_id = ntohl(msg->id); 485 uint32_t r_id = ntohl (msg->id);
482 486
483 attrs_len = ntohs(msg->attrs_len); 487 attrs_len = ntohs (msg->attrs_len);
484 LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); 488 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
485 489
486 490
487 for (op = h->op_head; NULL != op; op = op->next) 491 for (op = h->op_head; NULL != op; op = op->next)
@@ -494,28 +498,28 @@ handle_consume_ticket_result(void *cls,
494 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; 498 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
495 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 499 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
496 attrs = 500 attrs =
497 GNUNET_RECLAIM_ATTRIBUTE_list_deserialize((char *)&msg[1], attrs_len); 501 GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &msg[1], attrs_len);
498 if (NULL != op->ar_cb) 502 if (NULL != op->ar_cb)
503 {
504 if (NULL == attrs)
499 { 505 {
500 if (NULL == attrs) 506 op->ar_cb (op->cls, &msg->identity, NULL);
501 {
502 op->ar_cb(op->cls, &msg->identity, NULL);
503 }
504 else
505 {
506 for (le = attrs->list_head; NULL != le; le = le->next)
507 op->ar_cb(op->cls, &msg->identity, le->claim);
508 GNUNET_RECLAIM_ATTRIBUTE_list_destroy(attrs);
509 attrs = NULL;
510 }
511 op->ar_cb(op->cls, NULL, NULL);
512 } 507 }
513 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); 508 else
514 free_op(op); 509 {
515 GNUNET_free_non_null(attrs); 510 for (le = attrs->list_head; NULL != le; le = le->next)
511 op->ar_cb (op->cls, &msg->identity, le->claim);
512 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
513 attrs = NULL;
514 }
515 op->ar_cb (op->cls, NULL, NULL);
516 }
517 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
518 free_op (op);
519 GNUNET_free_non_null (attrs);
516 return; 520 return;
517 } 521 }
518 GNUNET_assert(0); 522 GNUNET_assert (0);
519} 523}
520 524
521 525
@@ -528,18 +532,18 @@ handle_consume_ticket_result(void *cls,
528 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 532 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
529 */ 533 */
530static int 534static int
531check_attribute_result(void *cls, const struct AttributeResultMessage *msg) 535check_attribute_result (void *cls, const struct AttributeResultMessage *msg)
532{ 536{
533 size_t msg_len; 537 size_t msg_len;
534 size_t attr_len; 538 size_t attr_len;
535 539
536 msg_len = ntohs(msg->header.size); 540 msg_len = ntohs (msg->header.size);
537 attr_len = ntohs(msg->attr_len); 541 attr_len = ntohs (msg->attr_len);
538 if (msg_len != sizeof(struct AttributeResultMessage) + attr_len) 542 if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
539 { 543 {
540 GNUNET_break(0); 544 GNUNET_break (0);
541 return GNUNET_SYSERR; 545 return GNUNET_SYSERR;
542 } 546 }
543 return GNUNET_OK; 547 return GNUNET_OK;
544} 548}
545 549
@@ -552,17 +556,17 @@ check_attribute_result(void *cls, const struct AttributeResultMessage *msg)
552 * @param msg the message we received 556 * @param msg the message we received
553 */ 557 */
554static void 558static void
555handle_attribute_result(void *cls, const struct AttributeResultMessage *msg) 559handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
556{ 560{
557 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; 561 static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
558 struct GNUNET_RECLAIM_Handle *h = cls; 562 struct GNUNET_RECLAIM_Handle *h = cls;
559 struct GNUNET_RECLAIM_AttributeIterator *it; 563 struct GNUNET_RECLAIM_AttributeIterator *it;
560 struct GNUNET_RECLAIM_Operation *op; 564 struct GNUNET_RECLAIM_Operation *op;
561 size_t attr_len; 565 size_t attr_len;
562 uint32_t r_id = ntohl(msg->id); 566 uint32_t r_id = ntohl (msg->id);
563 567
564 attr_len = ntohs(msg->attr_len); 568 attr_len = ntohs (msg->attr_len);
565 LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); 569 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
566 570
567 571
568 for (it = h->it_head; NULL != it; it = it->next) 572 for (it = h->it_head; NULL != it; it = it->next)
@@ -575,47 +579,47 @@ handle_attribute_result(void *cls, const struct AttributeResultMessage *msg)
575 return; 579 return;
576 580
577 if ((0 == 581 if ((0 ==
578 (memcmp(&msg->identity, &identity_dummy, sizeof(identity_dummy))))) 582 (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
583 {
584 if ((NULL == it) && (NULL == op))
579 { 585 {
580 if ((NULL == it) && (NULL == op)) 586 GNUNET_break (0);
581 { 587 force_reconnect (h);
582 GNUNET_break(0);
583 force_reconnect(h);
584 return;
585 }
586 if (NULL != it)
587 {
588 if (NULL != it->finish_cb)
589 it->finish_cb(it->finish_cb_cls);
590 free_it(it);
591 }
592 if (NULL != op)
593 {
594 if (NULL != op->ar_cb)
595 op->ar_cb(op->cls, NULL, NULL);
596 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op);
597 free_op(op);
598 }
599 return; 588 return;
600 } 589 }
590 if (NULL != it)
591 {
592 if (NULL != it->finish_cb)
593 it->finish_cb (it->finish_cb_cls);
594 free_it (it);
595 }
596 if (NULL != op)
597 {
598 if (NULL != op->ar_cb)
599 op->ar_cb (op->cls, NULL, NULL);
600 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
601 free_op (op);
602 }
603 return;
604 }
601 605
602 { 606 {
603 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; 607 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
604 attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&msg[1], attr_len); 608 attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &msg[1], attr_len);
605 if (NULL != it) 609 if (NULL != it)
606 { 610 {
607 if (NULL != it->proc) 611 if (NULL != it->proc)
608 it->proc(it->proc_cls, &msg->identity, attr); 612 it->proc (it->proc_cls, &msg->identity, attr);
609 } 613 }
610 else if (NULL != op) 614 else if (NULL != op)
611 { 615 {
612 if (NULL != op->ar_cb) 616 if (NULL != op->ar_cb)
613 op->ar_cb(op->cls, &msg->identity, attr); 617 op->ar_cb (op->cls, &msg->identity, attr);
614 } 618 }
615 GNUNET_free(attr); 619 GNUNET_free (attr);
616 return; 620 return;
617 } 621 }
618 GNUNET_assert(0); 622 GNUNET_assert (0);
619} 623}
620 624
621 625
@@ -627,12 +631,12 @@ handle_attribute_result(void *cls, const struct AttributeResultMessage *msg)
627 * @param msg the message we received 631 * @param msg the message we received
628 */ 632 */
629static void 633static void
630handle_ticket_result(void *cls, const struct TicketResultMessage *msg) 634handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
631{ 635{
632 struct GNUNET_RECLAIM_Handle *handle = cls; 636 struct GNUNET_RECLAIM_Handle *handle = cls;
633 struct GNUNET_RECLAIM_Operation *op; 637 struct GNUNET_RECLAIM_Operation *op;
634 struct GNUNET_RECLAIM_TicketIterator *it; 638 struct GNUNET_RECLAIM_TicketIterator *it;
635 uint32_t r_id = ntohl(msg->id); 639 uint32_t r_id = ntohl (msg->id);
636 static const struct GNUNET_RECLAIM_Ticket ticket; 640 static const struct GNUNET_RECLAIM_Ticket ticket;
637 641
638 for (op = handle->op_head; NULL != op; op = op->next) 642 for (op = handle->op_head; NULL != op; op = op->next)
@@ -644,41 +648,41 @@ handle_ticket_result(void *cls, const struct TicketResultMessage *msg)
644 if ((NULL == op) && (NULL == it)) 648 if ((NULL == op) && (NULL == it))
645 return; 649 return;
646 if (NULL != op) 650 if (NULL != op)
651 {
652 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
653 if (0 ==
654 memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
647 { 655 {
648 GNUNET_CONTAINER_DLL_remove(handle->op_head, handle->op_tail, op); 656 if (NULL != op->tr_cb)
649 if (0 == 657 op->tr_cb (op->cls, NULL);
650 memcmp(&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
651 {
652 if (NULL != op->tr_cb)
653 op->tr_cb(op->cls, NULL);
654 }
655 else
656 {
657 if (NULL != op->tr_cb)
658 op->tr_cb(op->cls, &msg->ticket);
659 }
660 free_op(op);
661 return;
662 } 658 }
659 else
660 {
661 if (NULL != op->tr_cb)
662 op->tr_cb (op->cls, &msg->ticket);
663 }
664 free_op (op);
665 return;
666 }
663 else if (NULL != it) 667 else if (NULL != it)
668 {
669 if (0 ==
670 memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
664 { 671 {
665 if (0 == 672 GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head,
666 memcmp(&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) 673 handle->ticket_it_tail,
667 { 674 it);
668 GNUNET_CONTAINER_DLL_remove(handle->ticket_it_head, 675 it->finish_cb (it->finish_cb_cls);
669 handle->ticket_it_tail, 676 GNUNET_free (it);
670 it); 677 }
671 it->finish_cb(it->finish_cb_cls); 678 else
672 GNUNET_free(it); 679 {
673 } 680 if (NULL != it->tr_cb)
674 else 681 it->tr_cb (it->cls, &msg->ticket);
675 {
676 if (NULL != it->tr_cb)
677 it->tr_cb(it->cls, &msg->ticket);
678 }
679 return;
680 } 682 }
681 GNUNET_break(0); 683 return;
684 }
685 GNUNET_break (0);
682} 686}
683 687
684 688
@@ -690,15 +694,15 @@ handle_ticket_result(void *cls, const struct TicketResultMessage *msg)
690 * @param msg the message we received 694 * @param msg the message we received
691 */ 695 */
692static void 696static void
693handle_revoke_ticket_result(void *cls, 697handle_revoke_ticket_result (void *cls,
694 const struct RevokeTicketResultMessage *msg) 698 const struct RevokeTicketResultMessage *msg)
695{ 699{
696 struct GNUNET_RECLAIM_Handle *h = cls; 700 struct GNUNET_RECLAIM_Handle *h = cls;
697 struct GNUNET_RECLAIM_Operation *op; 701 struct GNUNET_RECLAIM_Operation *op;
698 uint32_t r_id = ntohl(msg->id); 702 uint32_t r_id = ntohl (msg->id);
699 int32_t success; 703 int32_t success;
700 704
701 LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n"); 705 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
702 706
703 707
704 for (op = h->op_head; NULL != op; op = op->next) 708 for (op = h->op_head; NULL != op; op = op->next)
@@ -706,17 +710,17 @@ handle_revoke_ticket_result(void *cls,
706 break; 710 break;
707 if (NULL == op) 711 if (NULL == op)
708 return; 712 return;
709 success = ntohl(msg->success); 713 success = ntohl (msg->success);
710 { 714 {
711 if (NULL != op->rvk_cb) 715 if (NULL != op->rvk_cb)
712 { 716 {
713 op->rvk_cb(op->cls, success, NULL); 717 op->rvk_cb (op->cls, success, NULL);
714 } 718 }
715 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); 719 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
716 free_op(op); 720 free_op (op);
717 return; 721 return;
718 } 722 }
719 GNUNET_assert(0); 723 GNUNET_assert (0);
720} 724}
721 725
722 726
@@ -726,41 +730,41 @@ handle_revoke_ticket_result(void *cls,
726 * @param h handle to the reclaim service. 730 * @param h handle to the reclaim service.
727 */ 731 */
728static void 732static void
729reconnect(struct GNUNET_RECLAIM_Handle *h) 733reconnect (struct GNUNET_RECLAIM_Handle *h)
730{ 734{
731 struct GNUNET_MQ_MessageHandler handlers[] = 735 struct GNUNET_MQ_MessageHandler handlers[] =
732 { GNUNET_MQ_hd_fixed_size(success_response, 736 { GNUNET_MQ_hd_fixed_size (success_response,
733 GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE, 737 GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE,
734 struct SuccessResultMessage, 738 struct SuccessResultMessage,
735 h), 739 h),
736 GNUNET_MQ_hd_var_size(attribute_result, 740 GNUNET_MQ_hd_var_size (attribute_result,
737 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, 741 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT,
738 struct AttributeResultMessage, 742 struct AttributeResultMessage,
739 h), 743 h),
740 GNUNET_MQ_hd_fixed_size(ticket_result, 744 GNUNET_MQ_hd_fixed_size (ticket_result,
741 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, 745 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
742 struct TicketResultMessage, 746 struct TicketResultMessage,
743 h), 747 h),
744 GNUNET_MQ_hd_var_size(consume_ticket_result, 748 GNUNET_MQ_hd_var_size (consume_ticket_result,
745 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, 749 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT,
746 struct ConsumeTicketResultMessage, 750 struct ConsumeTicketResultMessage,
747 h), 751 h),
748 GNUNET_MQ_hd_fixed_size(revoke_ticket_result, 752 GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
749 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT, 753 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT,
750 struct RevokeTicketResultMessage, 754 struct RevokeTicketResultMessage,
751 h), 755 h),
752 GNUNET_MQ_handler_end() }; 756 GNUNET_MQ_handler_end () };
753 struct GNUNET_RECLAIM_Operation *op; 757 struct GNUNET_RECLAIM_Operation *op;
754 758
755 GNUNET_assert(NULL == h->mq); 759 GNUNET_assert (NULL == h->mq);
756 LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n"); 760 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
757 761
758 h->mq = 762 h->mq =
759 GNUNET_CLIENT_connect(h->cfg, "reclaim", handlers, &mq_error_handler, h); 763 GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h);
760 if (NULL == h->mq) 764 if (NULL == h->mq)
761 return; 765 return;
762 for (op = h->op_head; NULL != op; op = op->next) 766 for (op = h->op_head; NULL != op; op = op->next)
763 GNUNET_MQ_send_copy(h->mq, op->env); 767 GNUNET_MQ_send_copy (h->mq, op->env);
764} 768}
765 769
766 770
@@ -771,18 +775,18 @@ reconnect(struct GNUNET_RECLAIM_Handle *h)
771 * @return handle to use 775 * @return handle to use
772 */ 776 */
773struct GNUNET_RECLAIM_Handle * 777struct GNUNET_RECLAIM_Handle *
774GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg) 778GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
775{ 779{
776 struct GNUNET_RECLAIM_Handle *h; 780 struct GNUNET_RECLAIM_Handle *h;
777 781
778 h = GNUNET_new(struct GNUNET_RECLAIM_Handle); 782 h = GNUNET_new (struct GNUNET_RECLAIM_Handle);
779 h->cfg = cfg; 783 h->cfg = cfg;
780 reconnect(h); 784 reconnect (h);
781 if (NULL == h->mq) 785 if (NULL == h->mq)
782 { 786 {
783 GNUNET_free(h); 787 GNUNET_free (h);
784 return NULL; 788 return NULL;
785 } 789 }
786 return h; 790 return h;
787} 791}
788 792
@@ -796,12 +800,12 @@ GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
796 * @param op operation to cancel 800 * @param op operation to cancel
797 */ 801 */
798void 802void
799GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op) 803GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op)
800{ 804{
801 struct GNUNET_RECLAIM_Handle *h = op->h; 805 struct GNUNET_RECLAIM_Handle *h = op->h;
802 806
803 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); 807 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
804 free_op(op); 808 free_op (op);
805} 809}
806 810
807 811
@@ -811,21 +815,21 @@ GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
811 * @param h handle to destroy 815 * @param h handle to destroy
812 */ 816 */
813void 817void
814GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h) 818GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h)
815{ 819{
816 GNUNET_assert(NULL != h); 820 GNUNET_assert (NULL != h);
817 if (NULL != h->mq) 821 if (NULL != h->mq)
818 { 822 {
819 GNUNET_MQ_destroy(h->mq); 823 GNUNET_MQ_destroy (h->mq);
820 h->mq = NULL; 824 h->mq = NULL;
821 } 825 }
822 if (NULL != h->reconnect_task) 826 if (NULL != h->reconnect_task)
823 { 827 {
824 GNUNET_SCHEDULER_cancel(h->reconnect_task); 828 GNUNET_SCHEDULER_cancel (h->reconnect_task);
825 h->reconnect_task = NULL; 829 h->reconnect_task = NULL;
826 } 830 }
827 GNUNET_assert(NULL == h->op_head); 831 GNUNET_assert (NULL == h->op_head);
828 GNUNET_free(h); 832 GNUNET_free (h);
829} 833}
830 834
831/** 835/**
@@ -841,7 +845,7 @@ GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
841 * @return handle to abort the request 845 * @return handle to abort the request
842 */ 846 */
843struct GNUNET_RECLAIM_Operation * 847struct GNUNET_RECLAIM_Operation *
844GNUNET_RECLAIM_attribute_store( 848GNUNET_RECLAIM_attribute_store (
845 struct GNUNET_RECLAIM_Handle *h, 849 struct GNUNET_RECLAIM_Handle *h,
846 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 850 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
847 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 851 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
@@ -853,25 +857,25 @@ GNUNET_RECLAIM_attribute_store(
853 struct AttributeStoreMessage *sam; 857 struct AttributeStoreMessage *sam;
854 size_t attr_len; 858 size_t attr_len;
855 859
856 op = GNUNET_new(struct GNUNET_RECLAIM_Operation); 860 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
857 op->h = h; 861 op->h = h;
858 op->as_cb = cont; 862 op->as_cb = cont;
859 op->cls = cont_cls; 863 op->cls = cont_cls;
860 op->r_id = h->r_id_gen++; 864 op->r_id = h->r_id_gen++;
861 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); 865 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
862 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(attr); 866 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr);
863 op->env = GNUNET_MQ_msg_extra(sam, 867 op->env = GNUNET_MQ_msg_extra (sam,
864 attr_len, 868 attr_len,
865 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); 869 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE);
866 sam->identity = *pkey; 870 sam->identity = *pkey;
867 sam->id = htonl(op->r_id); 871 sam->id = htonl (op->r_id);
868 sam->exp = GNUNET_htonll(exp_interval->rel_value_us); 872 sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
869 873
870 GNUNET_RECLAIM_ATTRIBUTE_serialize(attr, (char *)&sam[1]); 874 GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &sam[1]);
871 875
872 sam->attr_len = htons(attr_len); 876 sam->attr_len = htons (attr_len);
873 if (NULL != h->mq) 877 if (NULL != h->mq)
874 GNUNET_MQ_send_copy(h->mq, op->env); 878 GNUNET_MQ_send_copy (h->mq, op->env);
875 return op; 879 return op;
876} 880}
877 881
@@ -888,7 +892,7 @@ GNUNET_RECLAIM_attribute_store(
888 * @return handle Used to to abort the request 892 * @return handle Used to to abort the request
889 */ 893 */
890struct GNUNET_RECLAIM_Operation * 894struct GNUNET_RECLAIM_Operation *
891GNUNET_RECLAIM_attribute_delete( 895GNUNET_RECLAIM_attribute_delete (
892 struct GNUNET_RECLAIM_Handle *h, 896 struct GNUNET_RECLAIM_Handle *h,
893 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 897 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
894 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 898 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
@@ -899,23 +903,23 @@ GNUNET_RECLAIM_attribute_delete(
899 struct AttributeDeleteMessage *dam; 903 struct AttributeDeleteMessage *dam;
900 size_t attr_len; 904 size_t attr_len;
901 905
902 op = GNUNET_new(struct GNUNET_RECLAIM_Operation); 906 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
903 op->h = h; 907 op->h = h;
904 op->as_cb = cont; 908 op->as_cb = cont;
905 op->cls = cont_cls; 909 op->cls = cont_cls;
906 op->r_id = h->r_id_gen++; 910 op->r_id = h->r_id_gen++;
907 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); 911 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
908 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(attr); 912 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr);
909 op->env = GNUNET_MQ_msg_extra(dam, 913 op->env = GNUNET_MQ_msg_extra (dam,
910 attr_len, 914 attr_len,
911 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); 915 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE);
912 dam->identity = *pkey; 916 dam->identity = *pkey;
913 dam->id = htonl(op->r_id); 917 dam->id = htonl (op->r_id);
914 GNUNET_RECLAIM_ATTRIBUTE_serialize(attr, (char *)&dam[1]); 918 GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &dam[1]);
915 919
916 dam->attr_len = htons(attr_len); 920 dam->attr_len = htons (attr_len);
917 if (NULL != h->mq) 921 if (NULL != h->mq)
918 GNUNET_MQ_send_copy(h->mq, op->env); 922 GNUNET_MQ_send_copy (h->mq, op->env);
919 return op; 923 return op;
920} 924}
921 925
@@ -945,7 +949,7 @@ GNUNET_RECLAIM_attribute_delete(
945 * @return an iterator Handle to use for iteration 949 * @return an iterator Handle to use for iteration
946 */ 950 */
947struct GNUNET_RECLAIM_AttributeIterator * 951struct GNUNET_RECLAIM_AttributeIterator *
948GNUNET_RECLAIM_get_attributes_start( 952GNUNET_RECLAIM_get_attributes_start (
949 struct GNUNET_RECLAIM_Handle *h, 953 struct GNUNET_RECLAIM_Handle *h,
950 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 954 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
951 GNUNET_SCHEDULER_TaskCallback error_cb, 955 GNUNET_SCHEDULER_TaskCallback error_cb,
@@ -961,7 +965,7 @@ GNUNET_RECLAIM_get_attributes_start(
961 uint32_t rid; 965 uint32_t rid;
962 966
963 rid = h->r_id_gen++; 967 rid = h->r_id_gen++;
964 it = GNUNET_new(struct GNUNET_RECLAIM_AttributeIterator); 968 it = GNUNET_new (struct GNUNET_RECLAIM_AttributeIterator);
965 it->h = h; 969 it->h = h;
966 it->error_cb = error_cb; 970 it->error_cb = error_cb;
967 it->error_cb_cls = error_cb_cls; 971 it->error_cb_cls = error_cb_cls;
@@ -971,15 +975,15 @@ GNUNET_RECLAIM_get_attributes_start(
971 it->proc_cls = proc_cls; 975 it->proc_cls = proc_cls;
972 it->r_id = rid; 976 it->r_id = rid;
973 it->identity = *identity; 977 it->identity = *identity;
974 GNUNET_CONTAINER_DLL_insert_tail(h->it_head, h->it_tail, it); 978 GNUNET_CONTAINER_DLL_insert_tail (h->it_head, h->it_tail, it);
975 env = 979 env =
976 GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START); 980 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START);
977 msg->id = htonl(rid); 981 msg->id = htonl (rid);
978 msg->identity = *identity; 982 msg->identity = *identity;
979 if (NULL == h->mq) 983 if (NULL == h->mq)
980 it->env = env; 984 it->env = env;
981 else 985 else
982 GNUNET_MQ_send(h->mq, env); 986 GNUNET_MQ_send (h->mq, env);
983 return it; 987 return it;
984} 988}
985 989
@@ -991,16 +995,16 @@ GNUNET_RECLAIM_get_attributes_start(
991 * @param it the iterator 995 * @param it the iterator
992 */ 996 */
993void 997void
994GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it) 998GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it)
995{ 999{
996 struct GNUNET_RECLAIM_Handle *h = it->h; 1000 struct GNUNET_RECLAIM_Handle *h = it->h;
997 struct AttributeIterationNextMessage *msg; 1001 struct AttributeIterationNextMessage *msg;
998 struct GNUNET_MQ_Envelope *env; 1002 struct GNUNET_MQ_Envelope *env;
999 1003
1000 env = 1004 env =
1001 GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT); 1005 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT);
1002 msg->id = htonl(it->r_id); 1006 msg->id = htonl (it->r_id);
1003 GNUNET_MQ_send(h->mq, env); 1007 GNUNET_MQ_send (h->mq, env);
1004} 1008}
1005 1009
1006 1010
@@ -1012,20 +1016,20 @@ GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it)
1012 * @param it the iterator 1016 * @param it the iterator
1013 */ 1017 */
1014void 1018void
1015GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it) 1019GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it)
1016{ 1020{
1017 struct GNUNET_RECLAIM_Handle *h = it->h; 1021 struct GNUNET_RECLAIM_Handle *h = it->h;
1018 struct GNUNET_MQ_Envelope *env; 1022 struct GNUNET_MQ_Envelope *env;
1019 struct AttributeIterationStopMessage *msg; 1023 struct AttributeIterationStopMessage *msg;
1020 1024
1021 if (NULL != h->mq) 1025 if (NULL != h->mq)
1022 { 1026 {
1023 env = 1027 env =
1024 GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP); 1028 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP);
1025 msg->id = htonl(it->r_id); 1029 msg->id = htonl (it->r_id);
1026 GNUNET_MQ_send(h->mq, env); 1030 GNUNET_MQ_send (h->mq, env);
1027 } 1031 }
1028 free_it(it); 1032 free_it (it);
1029} 1033}
1030 1034
1031 1035
@@ -1043,7 +1047,7 @@ GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
1043 * @return handle to abort the operation 1047 * @return handle to abort the operation
1044 */ 1048 */
1045struct GNUNET_RECLAIM_Operation * 1049struct GNUNET_RECLAIM_Operation *
1046GNUNET_RECLAIM_ticket_issue( 1050GNUNET_RECLAIM_ticket_issue (
1047 struct GNUNET_RECLAIM_Handle *h, 1051 struct GNUNET_RECLAIM_Handle *h,
1048 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, 1052 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1049 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, 1053 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
@@ -1055,26 +1059,26 @@ GNUNET_RECLAIM_ticket_issue(
1055 struct IssueTicketMessage *tim; 1059 struct IssueTicketMessage *tim;
1056 size_t attr_len; 1060 size_t attr_len;
1057 1061
1058 fprintf(stderr, "Issuing ticket\n"); 1062 fprintf (stderr, "Issuing ticket\n");
1059 op = GNUNET_new(struct GNUNET_RECLAIM_Operation); 1063 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1060 op->h = h; 1064 op->h = h;
1061 op->tr_cb = cb; 1065 op->tr_cb = cb;
1062 op->cls = cb_cls; 1066 op->cls = cb_cls;
1063 op->r_id = h->r_id_gen++; 1067 op->r_id = h->r_id_gen++;
1064 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); 1068 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1065 attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(attrs); 1069 attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs);
1066 op->env = GNUNET_MQ_msg_extra(tim, 1070 op->env = GNUNET_MQ_msg_extra (tim,
1067 attr_len, 1071 attr_len,
1068 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); 1072 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET);
1069 tim->identity = *iss; 1073 tim->identity = *iss;
1070 tim->rp = *rp; 1074 tim->rp = *rp;
1071 tim->id = htonl(op->r_id); 1075 tim->id = htonl (op->r_id);
1072 1076
1073 GNUNET_RECLAIM_ATTRIBUTE_list_serialize(attrs, (char *)&tim[1]); 1077 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, (char *) &tim[1]);
1074 1078
1075 tim->attr_len = htons(attr_len); 1079 tim->attr_len = htons (attr_len);
1076 if (NULL != h->mq) 1080 if (NULL != h->mq)
1077 GNUNET_MQ_send_copy(h->mq, op->env); 1081 GNUNET_MQ_send_copy (h->mq, op->env);
1078 return op; 1082 return op;
1079} 1083}
1080 1084
@@ -1092,7 +1096,7 @@ GNUNET_RECLAIM_ticket_issue(
1092 * @return handle to abort the operation 1096 * @return handle to abort the operation
1093 */ 1097 */
1094struct GNUNET_RECLAIM_Operation * 1098struct GNUNET_RECLAIM_Operation *
1095GNUNET_RECLAIM_ticket_consume( 1099GNUNET_RECLAIM_ticket_consume (
1096 struct GNUNET_RECLAIM_Handle *h, 1100 struct GNUNET_RECLAIM_Handle *h,
1097 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1101 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1098 const struct GNUNET_RECLAIM_Ticket *ticket, 1102 const struct GNUNET_RECLAIM_Ticket *ticket,
@@ -1102,18 +1106,18 @@ GNUNET_RECLAIM_ticket_consume(
1102 struct GNUNET_RECLAIM_Operation *op; 1106 struct GNUNET_RECLAIM_Operation *op;
1103 struct ConsumeTicketMessage *ctm; 1107 struct ConsumeTicketMessage *ctm;
1104 1108
1105 op = GNUNET_new(struct GNUNET_RECLAIM_Operation); 1109 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1106 op->h = h; 1110 op->h = h;
1107 op->ar_cb = cb; 1111 op->ar_cb = cb;
1108 op->cls = cb_cls; 1112 op->cls = cb_cls;
1109 op->r_id = h->r_id_gen++; 1113 op->r_id = h->r_id_gen++;
1110 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); 1114 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1111 op->env = GNUNET_MQ_msg(ctm, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); 1115 op->env = GNUNET_MQ_msg (ctm, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET);
1112 ctm->identity = *identity; 1116 ctm->identity = *identity;
1113 ctm->id = htonl(op->r_id); 1117 ctm->id = htonl (op->r_id);
1114 ctm->ticket = *ticket; 1118 ctm->ticket = *ticket;
1115 if (NULL != h->mq) 1119 if (NULL != h->mq)
1116 GNUNET_MQ_send_copy(h->mq, op->env); 1120 GNUNET_MQ_send_copy (h->mq, op->env);
1117 return op; 1121 return op;
1118} 1122}
1119 1123
@@ -1136,7 +1140,7 @@ GNUNET_RECLAIM_ticket_consume(
1136 * @return an iterator handle to use for iteration 1140 * @return an iterator handle to use for iteration
1137 */ 1141 */
1138struct GNUNET_RECLAIM_TicketIterator * 1142struct GNUNET_RECLAIM_TicketIterator *
1139GNUNET_RECLAIM_ticket_iteration_start( 1143GNUNET_RECLAIM_ticket_iteration_start (
1140 struct GNUNET_RECLAIM_Handle *h, 1144 struct GNUNET_RECLAIM_Handle *h,
1141 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1145 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1142 GNUNET_SCHEDULER_TaskCallback error_cb, 1146 GNUNET_SCHEDULER_TaskCallback error_cb,
@@ -1152,7 +1156,7 @@ GNUNET_RECLAIM_ticket_iteration_start(
1152 uint32_t rid; 1156 uint32_t rid;
1153 1157
1154 rid = h->r_id_gen++; 1158 rid = h->r_id_gen++;
1155 it = GNUNET_new(struct GNUNET_RECLAIM_TicketIterator); 1159 it = GNUNET_new (struct GNUNET_RECLAIM_TicketIterator);
1156 it->h = h; 1160 it->h = h;
1157 it->error_cb = error_cb; 1161 it->error_cb = error_cb;
1158 it->error_cb_cls = error_cb_cls; 1162 it->error_cb_cls = error_cb_cls;
@@ -1161,14 +1165,14 @@ GNUNET_RECLAIM_ticket_iteration_start(
1161 it->tr_cb = proc; 1165 it->tr_cb = proc;
1162 it->cls = proc_cls; 1166 it->cls = proc_cls;
1163 it->r_id = rid; 1167 it->r_id = rid;
1164 GNUNET_CONTAINER_DLL_insert_tail(h->ticket_it_head, h->ticket_it_tail, it); 1168 GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it);
1165 env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); 1169 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START);
1166 msg->id = htonl(rid); 1170 msg->id = htonl (rid);
1167 msg->identity = *identity; 1171 msg->identity = *identity;
1168 if (NULL == h->mq) 1172 if (NULL == h->mq)
1169 it->env = env; 1173 it->env = env;
1170 else 1174 else
1171 GNUNET_MQ_send(h->mq, env); 1175 GNUNET_MQ_send (h->mq, env);
1172 return it; 1176 return it;
1173} 1177}
1174 1178
@@ -1180,15 +1184,15 @@ GNUNET_RECLAIM_ticket_iteration_start(
1180 * @param it the iterator 1184 * @param it the iterator
1181 */ 1185 */
1182void 1186void
1183GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it) 1187GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it)
1184{ 1188{
1185 struct GNUNET_RECLAIM_Handle *h = it->h; 1189 struct GNUNET_RECLAIM_Handle *h = it->h;
1186 struct TicketIterationNextMessage *msg; 1190 struct TicketIterationNextMessage *msg;
1187 struct GNUNET_MQ_Envelope *env; 1191 struct GNUNET_MQ_Envelope *env;
1188 1192
1189 env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT); 1193 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT);
1190 msg->id = htonl(it->r_id); 1194 msg->id = htonl (it->r_id);
1191 GNUNET_MQ_send(h->mq, env); 1195 GNUNET_MQ_send (h->mq, env);
1192} 1196}
1193 1197
1194 1198
@@ -1200,20 +1204,20 @@ GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it)
1200 * @param it the iterator 1204 * @param it the iterator
1201 */ 1205 */
1202void 1206void
1203GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it) 1207GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it)
1204{ 1208{
1205 struct GNUNET_RECLAIM_Handle *h = it->h; 1209 struct GNUNET_RECLAIM_Handle *h = it->h;
1206 struct GNUNET_MQ_Envelope *env; 1210 struct GNUNET_MQ_Envelope *env;
1207 struct TicketIterationStopMessage *msg; 1211 struct TicketIterationStopMessage *msg;
1208 1212
1209 if (NULL != h->mq) 1213 if (NULL != h->mq)
1210 { 1214 {
1211 env = 1215 env =
1212 GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP); 1216 GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP);
1213 msg->id = htonl(it->r_id); 1217 msg->id = htonl (it->r_id);
1214 GNUNET_MQ_send(h->mq, env); 1218 GNUNET_MQ_send (h->mq, env);
1215 } 1219 }
1216 GNUNET_free(it); 1220 GNUNET_free (it);
1217} 1221}
1218 1222
1219 1223
@@ -1231,7 +1235,7 @@ GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
1231 * @return handle to abort the operation 1235 * @return handle to abort the operation
1232 */ 1236 */
1233struct GNUNET_RECLAIM_Operation * 1237struct GNUNET_RECLAIM_Operation *
1234GNUNET_RECLAIM_ticket_revoke( 1238GNUNET_RECLAIM_ticket_revoke (
1235 struct GNUNET_RECLAIM_Handle *h, 1239 struct GNUNET_RECLAIM_Handle *h,
1236 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, 1240 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
1237 const struct GNUNET_RECLAIM_Ticket *ticket, 1241 const struct GNUNET_RECLAIM_Ticket *ticket,
@@ -1243,21 +1247,21 @@ GNUNET_RECLAIM_ticket_revoke(
1243 uint32_t rid; 1247 uint32_t rid;
1244 1248
1245 rid = h->r_id_gen++; 1249 rid = h->r_id_gen++;
1246 op = GNUNET_new(struct GNUNET_RECLAIM_Operation); 1250 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1247 op->h = h; 1251 op->h = h;
1248 op->rvk_cb = cb; 1252 op->rvk_cb = cb;
1249 op->cls = cb_cls; 1253 op->cls = cb_cls;
1250 op->r_id = rid; 1254 op->r_id = rid;
1251 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); 1255 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1252 op->env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); 1256 op->env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET);
1253 msg->id = htonl(rid); 1257 msg->id = htonl (rid);
1254 msg->identity = *identity; 1258 msg->identity = *identity;
1255 msg->ticket = *ticket; 1259 msg->ticket = *ticket;
1256 if (NULL != h->mq) 1260 if (NULL != h->mq)
1257 { 1261 {
1258 GNUNET_MQ_send(h->mq, op->env); 1262 GNUNET_MQ_send (h->mq, op->env);
1259 op->env = NULL; 1263 op->env = NULL;
1260 } 1264 }
1261 return op; 1265 return op;
1262} 1266}
1263 1267