diff options
-rw-r--r-- | doc/man/gnunet-namestore.1 | 4 | ||||
-rw-r--r-- | src/namestore/gnunet-namestore.c | 93 |
2 files changed, 89 insertions, 8 deletions
diff --git a/doc/man/gnunet-namestore.1 b/doc/man/gnunet-namestore.1 index 577785df1..c77eefb8d 100644 --- a/doc/man/gnunet-namestore.1 +++ b/doc/man/gnunet-namestore.1 | |||
@@ -20,7 +20,7 @@ Desired operation is adding a record | |||
20 | Use the configuration file FILENAME. | 20 | Use the configuration file FILENAME. |
21 | .B | 21 | .B |
22 | .IP "\-d, \-\-delete" | 22 | .IP "\-d, \-\-delete" |
23 | Desired operation is deleting all of the records under the given name | 23 | Desired operation is deleting records under the given name that match the specified type (\-t) and value (\-V). If type or value are not specified, it means that all types (or values) should be assumed to match (and possibly multiple or all values under the given label will be deleted). Specifying a label (\-n) is mandatory. Note that matching by expiration time or flags is (currently) not supported. |
24 | .B | 24 | .B |
25 | .IP "\-D, \-\-display" | 25 | .IP "\-D, \-\-display" |
26 | Desired operation is listing of matching records | 26 | Desired operation is listing of matching records |
@@ -41,7 +41,7 @@ Use LOGLEVEL for logging. Valid values are DEBUG, INFO, WARNING and ERROR. | |||
41 | Monitor changes to the zone on an ongoing basis (in contrast to \-D, which merely displays the current records) | 41 | Monitor changes to the zone on an ongoing basis (in contrast to \-D, which merely displays the current records) |
42 | .B | 42 | .B |
43 | .IP "\-n NAME, \-\-name=NAME" | 43 | .IP "\-n NAME, \-\-name=NAME" |
44 | Name of the record to add/delete/display | 44 | Label or name of the record to add/delete/display |
45 | .B | 45 | .B |
46 | .IP "\-p, \-\-public" | 46 | .IP "\-p, \-\-public" |
47 | Create a record that is public (shared with other users that know the label) | 47 | Create a record that is public (shared with other users that know the label) |
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 8dc35984e..07c79f033 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -537,6 +537,88 @@ handle_reverse_lookup (void *cls, | |||
537 | 537 | ||
538 | 538 | ||
539 | /** | 539 | /** |
540 | * We were asked to delete something; this function is called with | ||
541 | * the existing records. Now we should determine what should be | ||
542 | * deleted and then issue the deletion operation. | ||
543 | * | ||
544 | * @param cls NULL | ||
545 | * @param zone private key of the zone we are deleting from | ||
546 | * @param label name of the records we are editing | ||
547 | * @param rd_count size of the @a rd array | ||
548 | * @param rd existing records | ||
549 | */ | ||
550 | static void | ||
551 | del_monitor (void *cls, | ||
552 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
553 | const char *label, | ||
554 | unsigned int rd_count, | ||
555 | const struct GNUNET_GNSRECORD_Data *rd) | ||
556 | { | ||
557 | struct GNUNET_GNSRECORD_Data rdx[rd_count]; | ||
558 | unsigned int rd_left; | ||
559 | unsigned int i; | ||
560 | uint32_t type; | ||
561 | char *vs; | ||
562 | |||
563 | del_qe = NULL; | ||
564 | if (0 == rd_count) | ||
565 | { | ||
566 | FPRINTF (stderr, | ||
567 | _("There are no records under label `%s' that could be deleted.\n"), | ||
568 | label); | ||
569 | test_finished (); | ||
570 | return; | ||
571 | } | ||
572 | if ( (NULL == value) && | ||
573 | (NULL == typestring) ) | ||
574 | { | ||
575 | /* delete everything */ | ||
576 | del_qe = GNUNET_NAMESTORE_records_store (ns, | ||
577 | &zone_pkey, | ||
578 | name, | ||
579 | 0, NULL, | ||
580 | &del_continuation, | ||
581 | NULL); | ||
582 | return; | ||
583 | } | ||
584 | rd_left = 0; | ||
585 | if (NULL != typestring) | ||
586 | type = GNUNET_GNSRECORD_typename_to_number (typestring); | ||
587 | else | ||
588 | type = GNUNET_GNSRECORD_TYPE_ANY; | ||
589 | for (i=0;i<rd_count;i++) | ||
590 | { | ||
591 | vs = NULL; | ||
592 | if (! ( ( (GNUNET_GNSRECORD_TYPE_ANY == type) || | ||
593 | (rd[i].record_type == type) ) && | ||
594 | ( (NULL == value) || | ||
595 | (NULL == (vs = (GNUNET_GNSRECORD_value_to_string (rd[i].record_type, | ||
596 | rd[i].data, | ||
597 | rd[i].data_size)))) || | ||
598 | (0 == strcmp (vs, value)) ) ) ) | ||
599 | rdx[rd_left++] = rd[i]; | ||
600 | GNUNET_free_non_null (vs); | ||
601 | } | ||
602 | if (rd_count == rd_left) | ||
603 | { | ||
604 | /* nothing got deleted */ | ||
605 | FPRINTF (stderr, | ||
606 | _("There are no records under label `%s' that match the request for deletion.\n"), | ||
607 | label); | ||
608 | test_finished (); | ||
609 | return; | ||
610 | } | ||
611 | /* delete everything but what we copied to 'rdx' */ | ||
612 | del_qe = GNUNET_NAMESTORE_records_store (ns, | ||
613 | &zone_pkey, | ||
614 | name, | ||
615 | rd_left, rdx, | ||
616 | &del_continuation, | ||
617 | NULL); | ||
618 | } | ||
619 | |||
620 | |||
621 | /** | ||
540 | * Function called with the result from the check if the namestore | 622 | * Function called with the result from the check if the namestore |
541 | * service is actually running. If it is, we start the actual | 623 | * service is actually running. If it is, we start the actual |
542 | * operation. | 624 | * operation. |
@@ -675,12 +757,11 @@ testservice_task (void *cls, | |||
675 | ret = 1; | 757 | ret = 1; |
676 | return; | 758 | return; |
677 | } | 759 | } |
678 | del_qe = GNUNET_NAMESTORE_records_store (ns, | 760 | del_qe = GNUNET_NAMESTORE_records_lookup (ns, |
679 | &zone_pkey, | 761 | &zone_pkey, |
680 | name, | 762 | name, |
681 | 0, NULL, | 763 | &del_monitor, |
682 | &del_continuation, | 764 | NULL); |
683 | NULL); | ||
684 | } | 765 | } |
685 | if (list) | 766 | if (list) |
686 | { | 767 | { |