Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / fs / fs_publish_ksk.c
index 7cbc880a2653a837bdb89b49aff3038dd603b9ea..a7ad3e91f901af668872856868f2d6ded9b04e3b 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009, 2010, 2012, 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009, 2010, 2012, 2013 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
 
      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.
 */
 
 /**
  * @file fs/fs_publish_ksk.c
  * @brief publish a URI under a keyword in GNUnet
- * @see https://gnunet.org/encoding and #2564 
+ * @see https://gnunet.org/encoding and #2564
  * @author Krista Bennett
  * @author Christian Grothoff
  */
@@ -74,7 +74,7 @@ struct GNUNET_FS_PublishKskContext
   /**
    * Current task.
    */
-  GNUNET_SCHEDULER_TaskIdentifier ksk_task;
+  struct GNUNET_SCHEDULER_Task * ksk_task;
 
   /**
    * Function to call once we're done.
@@ -93,7 +93,7 @@ struct GNUNET_FS_PublishKskContext
 
   /**
    * Options to use.
-   */ 
+   */
   enum GNUNET_FS_PublishOptions options;
 
   /**
@@ -105,23 +105,21 @@ struct GNUNET_FS_PublishKskContext
 
 
 /**
- * Continuation of "GNUNET_FS_publish_ksk" that performs
+ * Continuation of #GNUNET_FS_publish_ksk() that performs
  * the actual publishing operation (iterating over all
  * of the keywords).
  *
- * @param cls closure of type "struct PublishKskContext*"
- * @param tc unused
+ * @param cls closure of type `struct PublishKskContext *`
  */
 static void
-publish_ksk_cont (void *cls, 
-                 const struct GNUNET_SCHEDULER_TaskContext *tc);
+publish_ksk_cont (void *cls);
 
 
 /**
  * Function called by the datastore API with
  * the result from the PUT request.
  *
- * @param cls closure of type "struct GNUNET_FS_PublishKskContext*"
+ * @param cls closure of type `struct GNUNET_FS_PublishKskContext *`
  * @param msg error message (or NULL)
  */
 static void
@@ -133,7 +131,7 @@ kb_put_cont (void *cls,
   pkc->uc = NULL;
   if (NULL != msg)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "KBlock PUT operation failed: %s\n", msg);
     pkc->cont (pkc->cont_cls, NULL, msg);
     GNUNET_FS_publish_ksk_cancel (pkc);
@@ -144,32 +142,34 @@ kb_put_cont (void *cls,
 
 
 /**
- * Continuation of "GNUNET_FS_publish_ksk" that performs the actual
+ * Continuation of #GNUNET_FS_publish_ksk() that performs the actual
  * publishing operation (iterating over all of the keywords).
  *
- * @param cls closure of type "struct GNUNET_FS_PublishKskContext*"
- * @param tc unused
+ * @param cls closure of type `struct GNUNET_FS_PublishKskContext *`
  */
 static void
-publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+publish_ksk_cont (void *cls)
 {
   struct GNUNET_FS_PublishKskContext *pkc = cls;
   const char *keyword;
 
-  pkc->ksk_task = GNUNET_SCHEDULER_NO_TASK;
+  pkc->ksk_task = NULL;
   if ( (pkc->i == pkc->ksk_uri->data.ksk.keywordCount) ||
        (NULL == pkc->dsh) )
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "KSK PUT operation complete\n");
-    pkc->cont (pkc->cont_cls, pkc->ksk_uri, NULL);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "KSK PUT operation complete\n");
+    pkc->cont (pkc->cont_cls, pkc->ksk_uri,
+               NULL);
     GNUNET_FS_publish_ksk_cancel (pkc);
     return;
   }
   keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++];
   pkc->uc = GNUNET_FS_publish_ublock_ (pkc->h,
                                       pkc->dsh,
-                                      keyword, NULL,
-                                      GNUNET_CRYPTO_ecc_key_get_anonymous (),
+                                      keyword + 1 /* skip '+' */,
+                                      NULL,
+                                      GNUNET_CRYPTO_ecdsa_key_get_anonymous (),
                                       pkc->meta,
                                       pkc->uri,
                                       &pkc->bo,
@@ -215,7 +215,9 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
     pkc->dsh = GNUNET_DATASTORE_connect (h->cfg);
     if (NULL == pkc->dsh)
     {
-      cont (cont_cls, NULL, _("Could not connect to datastore."));
+      cont (cont_cls,
+            NULL,
+            _("Could not connect to datastore."));
       GNUNET_free (pkc);
       return NULL;
     }
@@ -235,10 +237,10 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
 void
 GNUNET_FS_publish_ksk_cancel (struct GNUNET_FS_PublishKskContext *pkc)
 {
-  if (GNUNET_SCHEDULER_NO_TASK != pkc->ksk_task)
+  if (NULL != pkc->ksk_task)
   {
     GNUNET_SCHEDULER_cancel (pkc->ksk_task);
-    pkc->ksk_task = GNUNET_SCHEDULER_NO_TASK;
+    pkc->ksk_task = NULL;
   }
   if (NULL != pkc->uc)
   {