convert fs publish to MQ
[oweals/gnunet.git] / src / core / test_core_api_mq.c
index 9b2603a6c9e50f0edc70cf38ac69f1cd7c71f697..8ece78e58b27c0e005bb75b7da8d608ea70aa1d8 100644 (file)
@@ -1,6 +1,6 @@
 /*
   This file is part of GNUnet.
-  Copyright (C) 2013 Christian Grothoff (and other contributing authors)
+  Copyright (C) 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
@@ -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.
 */
 
 #include "platform.h"
 /**
  * Has the test been successful?
  */
-int result;
+static int result;
 
-unsigned int num_received;
+static unsigned int num_received;
 
-struct GNUNET_CORE_Handle *core;
+static struct GNUNET_CORE_Handle *core;
 
-struct GNUNET_MQ_Handle *mq;
+static struct GNUNET_MQ_Handle *mq;
 
-struct GNUNET_PeerIdentity myself;
+static struct GNUNET_PeerIdentity myself;
 
 
 static void
@@ -55,15 +55,19 @@ init_cb (void *cls,
 
 
 static void
-connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer)
+connect_cb (void *cls,
+           const struct GNUNET_PeerIdentity *peer)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s.\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Connected to peer %s.\n",
               GNUNET_i2s (peer));
   if (0 == memcmp (peer, &myself, sizeof (struct GNUNET_PeerIdentity)))
   {
     unsigned int i;
     struct GNUNET_MQ_Envelope *ev;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queueing messages.\n");
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Queueing messages.\n");
     for (i = 0; i < NUM_MSG; i++)
     {
       ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_TEST);
@@ -78,7 +82,9 @@ handle_test (void *cls,
              const struct GNUNET_PeerIdentity *other,
              const struct GNUNET_MessageHeader *message)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got test message %d\n", num_received);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Got test message %d\n",
+             num_received);
   num_received++;
   if (NUM_MSG == num_received)
   {
@@ -88,7 +94,7 @@ handle_test (void *cls,
   }
   if (num_received > NUM_MSG)
   {
-    GNUNET_abort ();
+    GNUNET_assert (0);
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
@@ -96,10 +102,10 @@ handle_test (void *cls,
 
 
 static void
-shutdown_task (void *cls,
-               const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Shutting down\n");
   GNUNET_MQ_destroy (mq);
   GNUNET_CORE_disconnect (core);
 }
@@ -127,12 +133,13 @@ run (void *cls,
                               GNUNET_NO, handlers);
   if (NULL == core)
   {
-    GNUNET_abort ();
+    GNUNET_assert (0);
     return;
   }
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
 }
 
+
 int
 main (int argc, char *argv1[])
 {