- revert plugin move. Add new identity-token
[oweals/gnunet.git] / src / namestore / gnunet-service-namestore.c
index 64c844d1c87ee5a3af7b0a64a4bc82f0469eaaeb..78347f2becfaa931fa50cc1fb05248f5299ffcb7 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2012, 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2012, 2013, 2014 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 
 /**
@@ -152,7 +152,7 @@ struct ZoneMonitor
   /**
    * Task active during initial iteration.
    */
-  GNUNET_SCHEDULER_TaskIdentifier task;
+  struct GNUNET_SCHEDULER_Task * task;
 
   /**
    * Offset of the zone iteration used to address next result of the zone
@@ -304,7 +304,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       GNUNET_free (no);
     }
     GNUNET_CONTAINER_DLL_remove (client_head, client_tail, nc);
-    GNUNET_SERVER_client_set_user_context (nc->client, (void *)NULL);
+    GNUNET_SERVER_client_set_user_context (nc->client, NULL);
     GNUNET_free (nc);
   }
   GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, GSN_database));
@@ -355,10 +355,10 @@ client_disconnect_notification (void *cls,
       GNUNET_CONTAINER_DLL_remove (monitor_head,
                                   monitor_tail,
                                   zm);
-      if (GNUNET_SCHEDULER_NO_TASK != zm->task)
+      if (NULL != zm->task)
       {
        GNUNET_SCHEDULER_cancel (zm->task);
-       zm->task = GNUNET_SCHEDULER_NO_TASK;
+       zm->task = NULL;
       }
       GNUNET_free (zm);
       break;
@@ -397,6 +397,17 @@ client_lookup (struct GNUNET_SERVER_Client *client)
 }
 
 
+/**
+ * Function called with the records for the #GNUNET_GNS_MASTERZONE_STR
+ * label in the zone.  Used to locate the #GNUNET_GNSRECORD_TYPE_NICK
+ * record, which (if found) is then copied to @a cls for future use.
+ *
+ * @param cls a `struct GNUNET_GNSRECORD_Data **` for storing the nick (if found)
+ * @param private_key the private key of the zone (unused)
+ * @param label should be #GNUNET_GNS_MASTERZONE_STR
+ * @param rd_count number of records in @a rd
+ * @param rd records stored under @a label in the zone
+ */
 static void
 lookup_nick_it (void *cls,
                 const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key,
@@ -430,6 +441,12 @@ lookup_nick_it (void *cls,
 }
 
 
+/**
+ * Return the NICK record for the zone (if it exists).
+ *
+ * @param zone private key for the zone to look for nick
+ * @return NULL if no NICK record was found
+ */
 static struct GNUNET_GNSRECORD_Data *
 get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone)
 {
@@ -440,7 +457,8 @@ get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone)
   res = GSN_database->lookup_records (GSN_database->cls, zone,
                                       GNUNET_GNS_MASTERZONE_STR,
                                       &lookup_nick_it, &nick);
-  if ((NULL == nick) || (GNUNET_OK != res))
+  if ( (GNUNET_OK != res) ||
+       (NULL == nick) )
   {
     GNUNET_CRYPTO_ecdsa_key_get_public (zone, &pub);
     GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
@@ -516,7 +534,7 @@ merge_with_nick_records ( const struct GNUNET_GNSRECORD_Data *nick_rd,
 
 
 /**
- * Generate a 'struct LookupNameResponseMessage' and send it to the
+ * Generate a `struct LookupNameResponseMessage` and send it to the
  * given client using the given notification context.
  *
  * @param nc notification context to use
@@ -720,6 +738,9 @@ refresh_block (struct GNUNET_SERVER_Client *client,
 }
 
 
+/**
+ * Closure for #lookup_it().
+ */
 struct RecordLookupContext
 {
   const char *label;
@@ -1290,8 +1311,7 @@ zone_iterate_proc (void *cls,
                        rd);
   do_refresh_block = GNUNET_NO;
   for (i=0;i<rd_count;i++)
-    if(  (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) &&
-         (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PENDING)) )
+    if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
     {
       do_refresh_block = GNUNET_YES;
       break;
@@ -1595,7 +1615,7 @@ monitor_next (void *cls,
   struct ZoneMonitor *zm = cls;
   int ret;
 
-  zm->task = GNUNET_SCHEDULER_NO_TASK;
+  zm->task = NULL;
   ret = GSN_database->iterate_records (GSN_database->cls,
                                        (0 == memcmp (&zm->zone, &zero, sizeof (zero)))
                                        ? NULL
@@ -1695,4 +1715,3 @@ main (int argc, char *const *argv)
 }
 
 /* end of gnunet-service-namestore.c */
-