*/
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
-static void do_cleanup (void *cls)
+/**
+ * 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)
{
cleanup_task = NULL;
if (NULL != timeout)
GNUNET_free (abe_key);
if (NULL != attr_list)
GNUNET_free (attr_list);
+ if (NULL != attr_to_delete)
+ GNUNET_free (attr_to_delete);
}
-static void ticket_issue_cb (void *cls,
- const struct GNUNET_RECLAIM_Ticket *ticket)
+static void
+ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
{
char *ticket_str;
reclaim_op = NULL;
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void store_attr_cont (void *cls, int32_t success, const char *emsg)
+static void
+store_attr_cont (void *cls, int32_t success, const char *emsg)
{
reclaim_op = NULL;
if (GNUNET_SYSERR == success) {
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void process_attrs (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
+static void
+process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
+ 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 ticket_iter_err (void *cls)
+static void
+ticket_iter_err (void *cls)
{
ticket_iterator = NULL;
fprintf (stderr, "Failed to iterate over tickets\n");
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void ticket_iter_fin (void *cls)
+static void
+ticket_iter_fin (void *cls)
{
ticket_iterator = NULL;
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
+static void
+ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
{
- fprintf (stdout, "Found ticket\n");
+ char *aud;
+ char *ref;
+
+ aud = GNUNET_STRINGS_data_to_string_alloc (
+ &ticket->audience, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
+ ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t));
+
+ fprintf (stdout, "Ticket ID: %s | Audience: %s\n", ref, aud);
GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
}
-static void iter_error (void *cls)
+static void
+iter_error (void *cls)
{
attr_iterator = NULL;
fprintf (stderr, "Failed to iterate over attributes\n");
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void timeout_task (void *cls)
+static void
+timeout_task (void *cls)
{
timeout = NULL;
ret = 1;
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void process_rvk (void *cls, int success, const char *msg)
+static void
+process_rvk (void *cls, int success, const char *msg)
{
reclaim_op = NULL;
if (GNUNET_OK != success) {
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void iter_finished (void *cls)
+
+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)
{
char *data;
size_t data_size;
&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;
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
-static void iter_cb (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
+static void
+iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
+ const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
{
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);
}
-static void start_process ()
+static void
+start_process ()
{
if (NULL == pkey) {
fprintf (stderr, "Ego %s not found\n", ego_name);
static int init = GNUNET_YES;
-static void ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
- const char *name)
+static void
+ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
+ const char *name)
{
if (NULL == name) {
if (GNUNET_YES == init) {
}
-static void run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *c)
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
ret = 0;
if (NULL == ego_name) {
}
-int main (int argc, char *const argv[])
+int
+main (int argc, char *const argv[])
{
exp_interval = GNUNET_TIME_UNIT_HOURS;
struct GNUNET_GETOPT_CommandLineOption options[] = {
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),
gettext_noop ("Expiration interval of the attribute"), &exp_interval),
GNUNET_GETOPT_OPTION_END};
- if (GNUNET_OK !=
- GNUNET_PROGRAM_run (argc, argv, "ct", "ct", options, &run, NULL))
+ if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "gnunet-reclaim",
+ _ ("re:claimID command line tool"),
+ options, &run, NULL))
return 1;
else
return ret;