obsolete due to alpine policy
[oweals/gnunet.git] / src / reclaim / gnunet-service-reclaim_tickets.c
index fcfb2267d59c9733578594a387849865936de1d9..57c9e2167dd0039e6affe392408446ed9e0ddceb 100644 (file)
@@ -16,7 +16,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
    SPDX-License-Identifier: AGPL3.0-or-later
  */
+ */
 
 /**
  * @author Martin Schanzenbach
@@ -341,6 +341,7 @@ cleanup_rvk (struct RECLAIM_TICKETS_RevokeHandle *rh)
 {
   struct RevokedAttributeEntry *ae;
   struct TicketRecordsEntry *le;
+
   if (NULL != rh->ns_qe)
     GNUNET_NAMESTORE_cancel (rh->ns_qe);
   if (NULL != rh->ns_it)
@@ -387,6 +388,7 @@ static void
 ticket_processed (void *cls, int32_t success, const char *emsg)
 {
   struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
+
   rvk->ns_qe = NULL;
   GNUNET_SCHEDULER_add_now (&process_tickets, rvk);
 }
@@ -403,6 +405,7 @@ process_tickets (void *cls)
   struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
   struct TicketRecordsEntry *le;
   struct RevokedAttributeEntry *ae;
+
   if (NULL == rvk->tickets_to_update_head)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -433,7 +436,7 @@ process_tickets (void *cls)
       continue;
     for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
     {
-      if (0 != memcmp (rd[i].data, &ae->old_id, sizeof (uint64_t)))
+      if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t)))
         continue;
       rd[i].data = &ae->new_id;
     }
@@ -460,6 +463,7 @@ static void
 rvk_ticket_update_finished (void *cls)
 {
   struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
+
   rvk->ns_it = NULL;
   GNUNET_SCHEDULER_add_now (&process_tickets, rvk);
 }
@@ -494,7 +498,7 @@ rvk_ticket_update (void *cls,
       continue;
     for (ae = rvk->attrs_head; NULL != ae; ae = ae->next)
     {
-      if (0 != memcmp (rd[i].data, &ae->old_id, sizeof (uint64_t)))
+      if (0 != memcmp (rd[i].data, &ae->old_id, sizeof(uint64_t)))
         continue;
       has_changed = GNUNET_YES;
       break;
@@ -527,6 +531,7 @@ static void
 rvk_ns_iter_err (void *cls)
 {
   struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
+
   rvk->ns_it = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
               "Namestore error on revocation (id=%" PRIu64 "\n",
@@ -545,6 +550,7 @@ static void
 rvk_ns_err (void *cls)
 {
   struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
+
   rvk->ns_qe = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
               "Namestore error on revocation (id=%" PRIu64 "\n",
@@ -591,6 +597,7 @@ static void
 del_attr_finished (void *cls, int32_t success, const char *emsg)
 {
   struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
+
   rvk->ns_qe = NULL;
   if (GNUNET_SYSERR == success)
   {
@@ -620,6 +627,7 @@ move_attr_finished (void *cls, int32_t success, const char *emsg)
 {
   struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
   char *label;
+
   rvk->ns_qe = NULL;
   if (GNUNET_SYSERR == success)
   {
@@ -629,7 +637,7 @@ move_attr_finished (void *cls, int32_t success, const char *emsg)
     return;
   }
   label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id,
-                                               sizeof (uint64_t));
+                                               sizeof(uint64_t));
   GNUNET_assert (NULL != label);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label);
   rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
@@ -665,6 +673,7 @@ rvk_move_attr_cb (void *cls,
   struct RevokedAttributeEntry *le;
   char *new_label;
   char *attr_data;
+
   rvk->ns_qe = NULL;
   if (0 == rd_count)
   {
@@ -693,7 +702,7 @@ rvk_move_attr_cb (void *cls,
   new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, attr_data);
   new_rd.data = attr_data;
   new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
-                                                   sizeof (uint64_t));
+                                                   sizeof(uint64_t));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
   rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
                                                &rvk->identity,
@@ -736,7 +745,7 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk)
     return;
   }
   label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id,
-                                               sizeof (uint64_t));
+                                               sizeof(uint64_t));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label);
 
   rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
@@ -765,6 +774,7 @@ static void
 remove_ticket_cont (void *cls, int32_t success, const char *emsg)
 {
   struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
+
   rvk->ns_qe = NULL;
   if (GNUNET_SYSERR == success)
   {
@@ -807,6 +817,7 @@ revoke_attrs_cb (void *cls,
 {
   struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
   struct RevokedAttributeEntry *le;
+
   rvk->ns_qe = NULL;
   /**
    * Temporarily store attribute references.
@@ -842,6 +853,7 @@ static void
 rvk_attrs_err_cb (void *cls)
 {
   struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
+
   rvk->cb (rvk->cb_cls, GNUNET_SYSERR);
   cleanup_rvk (rvk);
 }
@@ -874,7 +886,7 @@ RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket,
   rvk->ticket = *ticket;
   GNUNET_CRYPTO_ecdsa_key_get_public (&rvk->identity, &rvk->ticket.identity);
   /** Get shared attributes **/
-  label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t));
+  label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
   GNUNET_assert (NULL != label);
   rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh,
                                                 identity,
@@ -902,8 +914,8 @@ RECLAIM_TICKETS_revoke_cancel (struct RECLAIM_TICKETS_RevokeHandle *rh)
 
 
 /*******************************
- * Ticket consume
- *******************************/
+* Ticket consume
+*******************************/
 
 /**
  * Cleanup ticket consume handle
@@ -914,6 +926,7 @@ static void
 cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth)
 {
   struct ParallelLookup *lu;
+
   if (NULL != cth->lookup_request)
     GNUNET_GNS_lookup_cancel (cth->lookup_request);
   if (NULL != cth->kill_task)
@@ -950,6 +963,7 @@ process_parallel_lookup_result (void *cls,
   struct ParallelLookup *parallel_lookup = cls;
   struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
   struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le;
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Parallel lookup finished (count=%u)\n",
               rd_count);
@@ -963,7 +977,7 @@ process_parallel_lookup_result (void *cls,
                             "attribute_lookup_time_total",
                             GNUNET_TIME_absolute_get_duration (
                               parallel_lookup->lookup_start_time)
-                              .rel_value_us,
+                            .rel_value_us,
                             GNUNET_YES);
   GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES);
 
@@ -1042,7 +1056,7 @@ lookup_authz_cb (void *cls,
                             "reclaim_authz_lookup_time_total",
                             GNUNET_TIME_absolute_get_duration (
                               cth->lookup_start_time)
-                              .rel_value_us,
+                            .rel_value_us,
                             GNUNET_YES);
   GNUNET_STATISTICS_update (stats,
                             "reclaim_authz_lookups_count",
@@ -1110,6 +1124,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
 {
   struct RECLAIM_TICKETS_ConsumeHandle *cth;
   char *label;
+
   cth = GNUNET_new (struct RECLAIM_TICKETS_ConsumeHandle);
 
   cth->identity = *id;
@@ -1119,7 +1134,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
   cth->cb = cb;
   cth->cb_cls = cb_cls;
   label =
-    GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t));
+    GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof(uint64_t));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Looking for AuthZ info under %s\n",
               label);
@@ -1151,8 +1166,8 @@ RECLAIM_TICKETS_consume_cancel (struct RECLAIM_TICKETS_ConsumeHandle *cth)
 
 
 /*******************************
- * Ticket issue
- *******************************/
+* Ticket issue
+*******************************/
 
 /**
  * Cleanup ticket consume handle
@@ -1214,12 +1229,12 @@ issue_ticket (struct TicketIssueHandle *ih)
     list_len++;
 
   attrs_record =
-    GNUNET_malloc (list_len * sizeof (struct GNUNET_GNSRECORD_Data));
+    GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data));
   i = 0;
   for (le = ih->attrs->list_head; NULL != le; le = le->next)
   {
     attrs_record[i].data = &le->claim->id;
-    attrs_record[i].data_size = sizeof (le->claim->id);
+    attrs_record[i].data_size = sizeof(le->claim->id);
     /**
      * FIXME: Should this be the attribute expiration time or ticket
      * refresh interval? Probably min(attrs.expiration)
@@ -1230,14 +1245,14 @@ issue_ticket (struct TicketIssueHandle *ih)
     i++;
   }
   attrs_record[i].data = &ih->ticket;
-  attrs_record[i].data_size = sizeof (struct GNUNET_RECLAIM_Ticket);
+  attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
   attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
   attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET;
   attrs_record[i].flags =
     GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
 
   label =
-    GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t));
+    GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof(uint64_t));
   // Publish record
   ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
                                               &ih->identity,
@@ -1251,8 +1266,8 @@ issue_ticket (struct TicketIssueHandle *ih)
 }
 
 /*************************************************
- * Ticket iteration (finding a specific ticket)
- *************************************************/
+* Ticket iteration (finding a specific ticket)
+*************************************************/
 
 
 /**
@@ -1264,6 +1279,7 @@ static void
 filter_tickets_error_cb (void *cls)
 {
   struct TicketIssueHandle *tih = cls;
+
   tih->ns_it = NULL;
   tih->cb (tih->cb_cls,
            &tih->ticket,
@@ -1298,6 +1314,7 @@ filter_tickets_cb (void *cls,
   // figure out the number of requested attributes
   struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
   unsigned int attr_cnt = 0;
+
   for (le = tih->attrs->list_head; NULL != le; le = le->next)
     attr_cnt++;
 
@@ -1313,7 +1330,7 @@ filter_tickets_cb (void *cls,
       // cmp audience
       if (0 == memcmp (&tih->ticket.audience,
                        &ticket->audience,
-                       sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+                       sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
       {
         tih->ticket = *ticket;
         continue;
@@ -1333,7 +1350,7 @@ filter_tickets_cb (void *cls,
                   le->claim->id);
 
 
-      if (0 == memcmp (rd[i].data, &le->claim->id, sizeof (uint64_t)))
+      if (0 == memcmp (rd[i].data, &le->claim->id, sizeof(uint64_t)))
         found_attrs_cnt++;
     }
   }
@@ -1342,7 +1359,7 @@ filter_tickets_cb (void *cls,
    * If we found a matching ticket, return that to the caller and
    * we are done.
    */
-  if (attr_cnt == found_attrs_cnt && NULL != ticket)
+  if ((attr_cnt == found_attrs_cnt)&&(NULL != ticket))
   {
     GNUNET_NAMESTORE_zone_iteration_stop (tih->ns_it);
     tih->cb (tih->cb_cls, &tih->ticket, GNUNET_OK, NULL);
@@ -1366,6 +1383,7 @@ static void
 filter_tickets_finished_cb (void *cls)
 {
   struct TicketIssueHandle *tih = cls;
+
   GNUNET_CRYPTO_ecdsa_key_get_public (&tih->identity, &tih->ticket.identity);
   tih->ticket.rnd =
     GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX);
@@ -1392,6 +1410,7 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
                        void *cb_cls)
 {
   struct TicketIssueHandle *tih;
+
   tih = GNUNET_new (struct TicketIssueHandle);
   tih->cb = cb;
   tih->cb_cls = cb_cls;
@@ -1413,8 +1432,8 @@ RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
 
 
 /************************************
- * Ticket iteration
- ************************************/
+* Ticket iteration
+************************************/
 
 /**
  * Cleanup ticket iterator
@@ -1470,6 +1489,7 @@ static void
 collect_tickets_finished_cb (void *cls)
 {
   struct RECLAIM_TICKETS_Iterator *iter = cls;
+
   iter->ns_it = NULL;
   iter->cb (iter->cb_cls, NULL);
   cleanup_iter (iter);
@@ -1485,6 +1505,7 @@ static void
 collect_tickets_error_cb (void *cls)
 {
   struct RECLAIM_TICKETS_Iterator *iter = cls;
+
   iter->ns_it = NULL;
   iter->cb (iter->cb_cls, NULL);
   cleanup_iter (iter);