use c99
[oweals/gnunet.git] / src / arm / test_exponential_backoff.c
index f94291acb25cd4bf6fadec8227c3852b03d418cf..3f33c91e69b28760ae73b9ede6027fc28ec011da 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009 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.
 */
 /**
  * @file arm/test_exponential_backoff.c
@@ -90,7 +90,7 @@ struct ShutdownContext
   /**
    * Task set up to cancel the shutdown request on timeout.
    */
-  struct GNUNET_SCHEDULER_Task * cancel_task;
+  struct GNUNET_SCHEDULER_Task *cancel_task;
 
   /**
    * Task to call once shutdown complete
@@ -141,11 +141,9 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg)
  * Shutting down took too long, cancel receive and return error.
  *
  * @param cls closure
- * @param tc context information (why was this task triggered now)
  */
-void
-service_shutdown_cancel (void *cls,
-                        const struct GNUNET_SCHEDULER_TaskContext *tc)
+static void
+service_shutdown_cancel (void *cls)
 {
   struct ShutdownContext *shutdown_ctx = cls;
 
@@ -227,7 +225,7 @@ do_nothing_service_shutdown (struct GNUNET_CLIENT_Connection *sock,
 
 
 static void
-kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc);
+kill_task (void *cbData);
 
 
 static void
@@ -237,7 +235,7 @@ shutdown_cont (void *cls, int reason)
   {
     /* Re-try shutdown */
     LOG ("do-nothing didn't die, trying again\n");
-    GNUNET_SCHEDULER_add_now (kill_task, NULL);
+    GNUNET_SCHEDULER_add_now (&kill_task, NULL);
     return;
   }
   startedWaitingAt = GNUNET_TIME_absolute_get ();
@@ -246,7 +244,7 @@ shutdown_cont (void *cls, int reason)
 
 
 static void
-kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc)
+kill_task (void *cbData)
 {
   static struct GNUNET_CLIENT_Connection *doNothingConnection = NULL;
 
@@ -284,7 +282,7 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
 
 static void
-trigger_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+trigger_disconnect (void *cls)
 {
   GNUNET_ARM_disconnect_and_free (arm);
   GNUNET_ARM_monitor_disconnect_and_free (mon);
@@ -292,12 +290,15 @@ trigger_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
 
 static void
-arm_stop_cb (void *cls, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result)
+arm_stop_cb (void *cls,
+            enum GNUNET_ARM_RequestStatus status,
+            const char *servicename,
+            enum GNUNET_ARM_Result result)
 {
   GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
   GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED);
   LOG ("ARM service stopped\n");
-  GNUNET_SCHEDULER_add_now (trigger_disconnect, NULL);
+  GNUNET_SCHEDULER_add_now (&trigger_disconnect, NULL);
 }
 
 
@@ -320,7 +321,8 @@ srv_status (void *cls, const char *service, enum GNUNET_ARM_ServiceStatus status
     LOG ("do-nothing is starting\n");
     phase++;
     ok = 1;
-    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &kill_task, NULL);
+    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                 &kill_task, NULL);
   }
   else if ((phase == 2) && (strcasecmp (SERVICE, service) == 0))
   {
@@ -330,7 +332,7 @@ srv_status (void *cls, const char *service, enum GNUNET_ARM_ServiceStatus status
     if (status == GNUNET_ARM_SERVICE_STARTING)
     {
       LOG ("do-nothing is starting\n");
-      GNUNET_SCHEDULER_add_now (kill_task, &ok);
+      GNUNET_SCHEDULER_add_now (&kill_task, &ok);
     }
     else if ((status == GNUNET_ARM_SERVICE_STOPPED) && (trialCount == 14))
     {
@@ -356,21 +358,7 @@ static void
 task (void *cls, char *const *args, const char *cfgfile,
       const struct GNUNET_CONFIGURATION_Handle *c)
 {
-  char *armconfig;
   cfg = c;
-  if (NULL != cfgfile)
-  {
-    if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "arm",
-        "CONFIG", &armconfig))
-    {
-      GNUNET_CONFIGURATION_set_value_string ((struct GNUNET_CONFIGURATION_Handle
-                                              *) cfg, "arm", "CONFIG",
-                                             cfgfile);
-    }
-    else
-      GNUNET_free (armconfig);
-  }
-
   arm = GNUNET_ARM_connect (cfg, NULL, NULL);
   if (NULL != arm)
   {
@@ -416,6 +404,14 @@ check ()
 }
 
 
+#ifndef PATH_MAX
+/**
+ * Assumed maximum path length (for the log file name).
+ */
+#define PATH_MAX 4096
+#endif
+
+
 static int
 init ()
 {