aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-05-13 19:38:42 +0200
committerChristian Grothoff <christian@grothoff.org>2018-05-13 19:38:42 +0200
commit2bb2faa207e4015609100a1aca38af344c65596f (patch)
tree44a54e6733a7ee912c9088501bebd30e5417d94d /src
parent633132e29e6003aa441e67913ea33d1de9d0d36d (diff)
downloadgnunet-2bb2faa207e4015609100a1aca38af344c65596f.tar.gz
gnunet-2bb2faa207e4015609100a1aca38af344c65596f.zip
support grabbing individual records
Diffstat (limited to 'src')
-rw-r--r--src/namestore/gnunet-namestore.c81
1 files changed, 71 insertions, 10 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 32b1a39d0..753ee79d1 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -80,6 +80,11 @@ static struct GNUNET_NAMESTORE_QueueEntry *add_qe_uri;
80static struct GNUNET_NAMESTORE_QueueEntry *add_qe; 80static struct GNUNET_NAMESTORE_QueueEntry *add_qe;
81 81
82/** 82/**
83 * Queue entry for the 'lookup' operation.
84 */
85static struct GNUNET_NAMESTORE_QueueEntry *get_qe;
86
87/**
83 * Queue entry for the 'reverse lookup' operation (in combination with a name). 88 * Queue entry for the 'reverse lookup' operation (in combination with a name).
84 */ 89 */
85static struct GNUNET_NAMESTORE_QueueEntry *reverse_qe; 90static struct GNUNET_NAMESTORE_QueueEntry *reverse_qe;
@@ -234,6 +239,11 @@ do_shutdown (void *cls)
234 GNUNET_NAMESTORE_cancel (add_qe_uri); 239 GNUNET_NAMESTORE_cancel (add_qe_uri);
235 add_qe_uri = NULL; 240 add_qe_uri = NULL;
236 } 241 }
242 if (NULL != get_qe)
243 {
244 GNUNET_NAMESTORE_cancel (get_qe);
245 get_qe = NULL;
246 }
237 if (NULL != del_qe) 247 if (NULL != del_qe)
238 { 248 {
239 GNUNET_NAMESTORE_cancel (del_qe); 249 GNUNET_NAMESTORE_cancel (del_qe);
@@ -271,6 +281,7 @@ test_finished ()
271{ 281{
272 if ( (NULL == add_qe) && 282 if ( (NULL == add_qe) &&
273 (NULL == add_qe_uri) && 283 (NULL == add_qe_uri) &&
284 (NULL == get_qe) &&
274 (NULL == del_qe) && 285 (NULL == del_qe) &&
275 (NULL == reverse_qe) && 286 (NULL == reverse_qe) &&
276 (NULL == list_it) ) 287 (NULL == list_it) )
@@ -492,6 +503,30 @@ display_record_monitor (void *cls,
492 503
493 504
494/** 505/**
506 * Process a record that was stored in the namestore.
507 *
508 * @param cls closure
509 * @param zone_key private key of the zone
510 * @param rname name that is being mapped (at most 255 characters long)
511 * @param rd_len number of entries in @a rd array
512 * @param rd array of records with data to store
513 */
514static void
515display_record_lookup (void *cls,
516 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
517 const char *rname,
518 unsigned int rd_len,
519 const struct GNUNET_GNSRECORD_Data *rd)
520{
521 get_qe = NULL;
522 display_record (rname,
523 rd_len,
524 rd);
525 test_finished ();
526}
527
528
529/**
495 * Function called once we are in sync in monitor mode. 530 * Function called once we are in sync in monitor mode.
496 * 531 *
497 * @param cls NULL 532 * @param cls NULL
@@ -522,12 +557,29 @@ monitor_error_cb (void *cls)
522 557
523 558
524/** 559/**
525 * Function called if lookup fails. 560 * Function called on errors while monitoring.
561 *
562 * @param cls NULL
526 */ 563 */
527static void 564static void
528lookup_error_cb (void *cls) 565lookup_error_cb (void *cls)
529{ 566{
530 (void) cls; 567 (void) cls;
568 get_qe = NULL;
569 FPRINTF (stderr,
570 "%s",
571 "Failed to lookup record.\n");
572 test_finished ();
573}
574
575
576/**
577 * Function called if lookup fails.
578 */
579static void
580add_error_cb (void *cls)
581{
582 (void) cls;
531 add_qe = NULL; 583 add_qe = NULL;
532 GNUNET_break (0); 584 GNUNET_break (0);
533 ret = 1; 585 ret = 1;
@@ -970,7 +1022,7 @@ identity_cb (void *cls,
970 add_qe = GNUNET_NAMESTORE_records_lookup (ns, 1022 add_qe = GNUNET_NAMESTORE_records_lookup (ns,
971 &zone_pkey, 1023 &zone_pkey,
972 name, 1024 name,
973 &lookup_error_cb, 1025 &add_error_cb,
974 NULL, 1026 NULL,
975 &get_existing_record, 1027 &get_existing_record,
976 NULL); 1028 NULL);
@@ -996,14 +1048,23 @@ identity_cb (void *cls,
996 } 1048 }
997 if (list) 1049 if (list)
998 { 1050 {
999 list_it = GNUNET_NAMESTORE_zone_iteration_start (ns, 1051 if (NULL != name)
1000 &zone_pkey, 1052 get_qe = GNUNET_NAMESTORE_records_lookup (ns,
1001 &zone_iteration_error_cb, 1053 &zone_pkey,
1002 NULL, 1054 name,
1003 &display_record_iterator, 1055 &lookup_error_cb,
1004 NULL, 1056 NULL,
1005 &zone_iteration_finished, 1057 &display_record_lookup,
1006 NULL); 1058 NULL);
1059 else
1060 list_it = GNUNET_NAMESTORE_zone_iteration_start (ns,
1061 &zone_pkey,
1062 &zone_iteration_error_cb,
1063 NULL,
1064 &display_record_iterator,
1065 NULL,
1066 &zone_iteration_finished,
1067 NULL);
1007 } 1068 }
1008 if (NULL != reverse_pkey) 1069 if (NULL != reverse_pkey)
1009 { 1070 {