glitch in the license text detected by hyazinthe, thank you!
[oweals/gnunet.git] / src / revocation / test_revocation.c
index daafa65340ae5dcced7920eb8e88e79987304ef4..95a457590ceca9e440634c92159f6fccd3c2be7b 100644 (file)
@@ -1,21 +1,16 @@
 /*
    This file is part of GNUnet.
-   Copyright (C) 2009, 2013 Christian Grothoff (and other contributing authors)
+   Copyright (C) 2009, 2013, 2016 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
-   by the Free Software Foundation; either version 3, or (at your
-   option) any later version.
+   GNUnet is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Affero General Public License as published
+   by the Free Software Foundation, either version 3 of the License,
+   or (at your option) any later version.
 
    GNUnet is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   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.
+   Affero General Public License for more details.
 */
 /**
  * @file revocation/test_revocation.c
@@ -57,12 +52,9 @@ static int ok;
 
 
 static void
-do_shutdown (void *cls,
-             const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_shutdown (void *cls)
 {
-  unsigned int c;
-
-  for (c = 0; c < NUM_TEST_PEERS; c++)
+  for (unsigned int c = 0; c < NUM_TEST_PEERS; c++)
   {
     if (NULL != testpeers[c].create_id_op)
     {
@@ -94,8 +86,7 @@ do_shutdown (void *cls,
 
 
 static void
-check_revocation (void *cls,
-                  const struct GNUNET_SCHEDULER_TaskContext *tc);
+check_revocation (void *cls);
 
 
 static void
@@ -106,8 +97,8 @@ revocation_remote_cb (void *cls,
 
   if (GNUNET_NO == is_valid)
   {
-    fprintf (stderr,
-             "Local revocation successful\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Local revocation successful\n");
     ok = 0;
     GNUNET_SCHEDULER_shutdown ();
     return;
@@ -120,16 +111,15 @@ revocation_remote_cb (void *cls,
                                   NULL);
     return;
   }
-  fprintf (stderr,
-           "Flooding of revocation failed\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "Flooding of revocation failed\n");
   ok = 2;
   GNUNET_SCHEDULER_shutdown ();
 }
 
 
 static void
-check_revocation (void *cls,
-                  const struct GNUNET_SCHEDULER_TaskContext *tc)
+check_revocation (void *cls)
 {
   GNUNET_REVOCATION_query (testpeers[0].cfg,
                            &testpeers[1].pubkey,
@@ -144,9 +134,9 @@ revocation_cb (void *cls,
   testpeers[1].revok_handle = NULL;
   if (GNUNET_NO == is_valid)
   {
-    fprintf (stderr,
-             "Revocation successful\n");
-    check_revocation (NULL, NULL);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Revocation successful\n");
+    check_revocation (NULL);
   }
 }
 
@@ -263,11 +253,12 @@ identity_connect_adapter (void *cls,
                           const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct TestPeer *me = cls;
+
   me->cfg = cfg;
-  me->idh = GNUNET_IDENTITY_connect (cfg, NULL, NULL );
+  me->idh = GNUNET_IDENTITY_connect (cfg, NULL, NULL);
   if (NULL == me->idh)
-    GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
-               "Failed to create IDENTITY handle \n");
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to create IDENTITY handle \n");
   return me->idh;
 }
 
@@ -282,9 +273,10 @@ identity_disconnect_adapter (void *cls,
 }
 
 
-static void
+static void *
 connect_cb (void *cls,
-            const struct GNUNET_PeerIdentity *peer)
+            const struct GNUNET_PeerIdentity *peer,
+           struct GNUNET_MQ_Handle *mq)
 {
   static int connects = 0;
 
@@ -310,6 +302,7 @@ connect_cb (void *cls,
                                         &identity_disconnect_adapter,
                                         &testpeers[1]);
   }
+  return NULL;
 }
 
 
@@ -337,10 +330,11 @@ core_connect_adapter (void *cls,
   struct TestPeer *me = cls;
 
   me->cfg = cfg;
-  me->ch = GNUNET_CORE_connect (cfg, me, NULL,
-                                &connect_cb, NULL,
-                                NULL, GNUNET_NO,
-                                NULL, GNUNET_NO,
+  me->ch = GNUNET_CORE_connect (cfg,
+                               me,
+                               NULL,
+                                &connect_cb,
+                               NULL,
                                 NULL);
   if (NULL == me->ch)
     GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
@@ -370,9 +364,8 @@ test_connection (void *cls,
 {
   unsigned int c;
 
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
-                                &do_shutdown, NULL);
-
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+                                 NULL);
   if (NUM_TEST_PEERS != num_peers)
   {
     ok = 4;
@@ -386,8 +379,8 @@ test_connection (void *cls,
    /* We are generating a CLIQUE */
   if (NUM_TEST_PEERS * (NUM_TEST_PEERS -1) == links_succeeded)
   {
-    fprintf (stderr,
-             "Testbed connected peers, initializing test\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Testbed connected peers, initializing test\n");
     for (c = 0; c < num_peers; c++)
     {
       testpeers[c].p = peers[c];
@@ -403,8 +396,8 @@ test_connection (void *cls,
   }
   else
   {
-    fprintf (stderr,
-             "Testbed failed to connect peers\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Testbed failed to connect peers\n");
     ok = 5;
     GNUNET_SCHEDULER_shutdown ();
     return;