*/
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
+/**
+ * Claim to delete
+ */
+static char *attr_delete;
+
+/**
+ * Claim object to delete
+ */
+static struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr_to_delete;
+
static void
do_cleanup (void *cls)
{
GNUNET_free (abe_key);
if (NULL != attr_list)
GNUNET_free (attr_list);
+ if (NULL != attr_to_delete)
+ GNUNET_free (attr_to_delete);
}
static void
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
{
char *value_str;
+ char *id;
const char *attr_type;
if (NULL == identity) {
value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data,
attr->data_size);
attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
- fprintf (stdout, "%s: %s [%s,v%u,id=%" PRIu64 "]\n", attr->name, value_str,
- attr_type, attr->version, attr->id);
+ id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof (uint64_t));
+ fprintf (stdout, "Name: %s; Value: %s (%s); Version %u; ID: %s\n", attr->name,
+ value_str, attr_type, attr->version, id);
+ GNUNET_free (id);
}
static void
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
+
+static void
+process_delete (void *cls, int success, const char *msg)
+{
+ reclaim_op = NULL;
+ if (GNUNET_OK != success) {
+ fprintf (stderr, "Deletion failed.\n");
+ ret = 1;
+ }
+ cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
+}
+
+
static void
iter_finished (void *cls)
{
&process_rvk, NULL);
return;
}
+ if (attr_delete) {
+ if (NULL == attr_to_delete) {
+ fprintf (stdout, "No such attribute ``%s''\n", attr_delete);
+ return;
+ }
+ reclaim_op = GNUNET_RECLAIM_attribute_delete (
+ reclaim_handle, pkey, attr_to_delete, &process_delete, NULL);
+ return;
+ }
if (attr_name) {
if (NULL == type_str)
type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING;
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
char *attrs_tmp;
char *attr_str;
+ char *label;
+ char *id;
const char *attr_type;
if ((NULL != attr_name) && (NULL != claim)) {
break;
}
GNUNET_free (attrs_tmp);
+ } else if (attr_delete && (NULL == attr_to_delete)) {
+ label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof (uint64_t));
+ if (0 == strcasecmp (attr_delete, label)) {
+ attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new (
+ attr->name, attr->type, attr->data, attr->data_size);
+ attr_to_delete->id = attr->id;
+ }
+ GNUNET_free (label);
} else if (list) {
attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data,
attr->data_size);
attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
- fprintf (stdout, "%s: %s [%s,v%u,id=%" PRIu64 "]\n", attr->name, attr_str,
- attr_type, attr->version, attr->id);
+ id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof (uint64_t));
+ fprintf (stdout, "Name: %s; Value: %s (%s); Version %u; ID: %s\n",
+ attr->name, attr_str, attr_type, attr->version, id);
+ GNUNET_free (id);
}
GNUNET_RECLAIM_get_attributes_next (attr_iterator);
}
GNUNET_GETOPT_option_string ('a', "add", "NAME",
gettext_noop ("Add an attribute NAME"),
&attr_name),
-
+ GNUNET_GETOPT_option_string ('d', "delete", "ID",
+ gettext_noop ("Add an attribute with ID"),
+ &attr_delete),
GNUNET_GETOPT_option_string ('V', "value", "VALUE",
gettext_noop ("The attribute VALUE"),
&attr_value),