diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-04-12 16:34:16 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-04-14 10:01:23 +0200 |
commit | dfe11b6b541b47c85cdf56e55ebb816d6793db31 (patch) | |
tree | b1c05be186902b4e510ab803e489094402b8149a /src/reclaim/gnunet-reclaim.c | |
parent | a12b8c2c4cbf952c8c305cde193bb25c13a0912b (diff) | |
download | gnunet-dfe11b6b541b47c85cdf56e55ebb816d6793db31.tar.gz gnunet-dfe11b6b541b47c85cdf56e55ebb816d6793db31.zip |
RECLAIM: Towards -sql
Diffstat (limited to 'src/reclaim/gnunet-reclaim.c')
-rw-r--r-- | src/reclaim/gnunet-reclaim.c | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index df6ebc66f..c36955a04 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c | |||
@@ -77,6 +77,11 @@ static char* type_str; | |||
77 | static char* revoke_ticket; | 77 | static char* revoke_ticket; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Ticket listing | ||
81 | */ | ||
82 | static int list_tickets; | ||
83 | |||
84 | /** | ||
80 | * Ego name | 85 | * Ego name |
81 | */ | 86 | */ |
82 | static char* ego_name; | 87 | static char* ego_name; |
@@ -102,6 +107,11 @@ static struct GNUNET_RECLAIM_Operation *reclaim_op; | |||
102 | static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator; | 107 | static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator; |
103 | 108 | ||
104 | /** | 109 | /** |
110 | * Ticket iterator | ||
111 | */ | ||
112 | static struct GNUNET_RECLAIM_TicketIterator *ticket_iterator; | ||
113 | |||
114 | /** | ||
105 | * Master ABE key | 115 | * Master ABE key |
106 | */ | 116 | */ |
107 | static struct GNUNET_CRYPTO_AbeMasterKey *abe_key; | 117 | static struct GNUNET_CRYPTO_AbeMasterKey *abe_key; |
@@ -156,6 +166,8 @@ do_cleanup(void *cls) | |||
156 | GNUNET_RECLAIM_cancel (reclaim_op); | 166 | GNUNET_RECLAIM_cancel (reclaim_op); |
157 | if (NULL != attr_iterator) | 167 | if (NULL != attr_iterator) |
158 | GNUNET_RECLAIM_get_attributes_stop (attr_iterator); | 168 | GNUNET_RECLAIM_get_attributes_stop (attr_iterator); |
169 | if (NULL != ticket_iterator) | ||
170 | GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator); | ||
159 | if (NULL != reclaim_handle) | 171 | if (NULL != reclaim_handle) |
160 | GNUNET_RECLAIM_disconnect (reclaim_handle); | 172 | GNUNET_RECLAIM_disconnect (reclaim_handle); |
161 | if (NULL != identity_handle) | 173 | if (NULL != identity_handle) |
@@ -223,6 +235,30 @@ process_attrs (void *cls, | |||
223 | attr->name, value_str, attr_type, attr->version, attr->id); | 235 | attr->name, value_str, attr_type, attr->version, attr->id); |
224 | } | 236 | } |
225 | 237 | ||
238 | static void | ||
239 | ticket_iter_err (void *cls) | ||
240 | { | ||
241 | ticket_iterator = NULL; | ||
242 | fprintf (stderr, | ||
243 | "Failed to iterate over tickets\n"); | ||
244 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | ||
245 | } | ||
246 | |||
247 | static void | ||
248 | ticket_iter_fin (void *cls) | ||
249 | { | ||
250 | ticket_iterator = NULL; | ||
251 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | ||
252 | } | ||
253 | |||
254 | static void | ||
255 | ticket_iter (void *cls, | ||
256 | const struct GNUNET_RECLAIM_Ticket *ticket) | ||
257 | { | ||
258 | fprintf (stdout, | ||
259 | "Found ticket\n"); | ||
260 | GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator); | ||
261 | } | ||
226 | 262 | ||
227 | static void | 263 | static void |
228 | iter_error (void *cls) | 264 | iter_error (void *cls) |
@@ -396,7 +432,7 @@ iter_cb (void *cls, | |||
396 | } | 432 | } |
397 | 433 | ||
398 | static void | 434 | static void |
399 | start_get_attributes () | 435 | start_process () |
400 | { | 436 | { |
401 | if (NULL == pkey) | 437 | if (NULL == pkey) |
402 | { | 438 | { |
@@ -406,6 +442,19 @@ start_get_attributes () | |||
406 | return; | 442 | return; |
407 | } | 443 | } |
408 | 444 | ||
445 | if (list_tickets) | ||
446 | { | ||
447 | ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle, | ||
448 | pkey, | ||
449 | &ticket_iter_err, | ||
450 | NULL, | ||
451 | &ticket_iter, | ||
452 | NULL, | ||
453 | &ticket_iter_fin, | ||
454 | NULL); | ||
455 | return; | ||
456 | } | ||
457 | |||
409 | if (NULL != rp) | 458 | if (NULL != rp) |
410 | GNUNET_CRYPTO_ecdsa_public_key_from_string (rp, | 459 | GNUNET_CRYPTO_ecdsa_public_key_from_string (rp, |
411 | strlen (rp), | 460 | strlen (rp), |
@@ -446,7 +495,7 @@ ego_cb (void *cls, | |||
446 | if (NULL == name) { | 495 | if (NULL == name) { |
447 | if (GNUNET_YES == init) { | 496 | if (GNUNET_YES == init) { |
448 | init = GNUNET_NO; | 497 | init = GNUNET_NO; |
449 | start_get_attributes(); | 498 | start_process (); |
450 | } | 499 | } |
451 | return; | 500 | return; |
452 | } | 501 | } |
@@ -548,6 +597,10 @@ main(int argc, char *const argv[]) | |||
548 | "TYPE", | 597 | "TYPE", |
549 | gettext_noop ("Type of attribute"), | 598 | gettext_noop ("Type of attribute"), |
550 | &type_str), | 599 | &type_str), |
600 | GNUNET_GETOPT_option_flag ('T', | ||
601 | "tickets", | ||
602 | gettext_noop ("List tickets of ego"), | ||
603 | &list_tickets), | ||
551 | GNUNET_GETOPT_option_relative_time ('E', | 604 | GNUNET_GETOPT_option_relative_time ('E', |
552 | "expiration", | 605 | "expiration", |
553 | "INTERVAL", | 606 | "INTERVAL", |