aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/reclaim_api.c
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/reclaim_api.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/reclaim/reclaim_api.c')
-rw-r--r--src/reclaim/reclaim_api.c568
1 files changed, 286 insertions, 282 deletions
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