-bringing copyright tags up to FSF standard
[oweals/gnunet.git] / src / transport / test_plugin_transport.c
index e41a2d0e41635ba22ccbec35582bf850c3864f48..bad07f7fb141f38e7d3bb3a2c68d7dabec5d50f1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  This file is part of GNUnet.
- (C) 2009 Christian Grothoff (and other contributing authors)
Copyright (C) 2009 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
@@ -89,12 +89,12 @@ struct GNUNET_HELPER_Handle *suid_helper;
 /**
  * Timeout task
  */
-static GNUNET_SCHEDULER_TaskIdentifier timeout_endbadly;
+static struct GNUNET_SCHEDULER_Task * timeout_endbadly;
 
 /**
  * Timeout task
  */
-static GNUNET_SCHEDULER_TaskIdentifier timeout_wait;
+static struct GNUNET_SCHEDULER_Task * timeout_wait;
 
 /**
  * Library name
@@ -138,10 +138,10 @@ end ()
   int c = 0;
   ok = 0;
 
-  if (GNUNET_SCHEDULER_NO_TASK != timeout_endbadly)
+  if (NULL != timeout_endbadly)
   {
     GNUNET_SCHEDULER_cancel (timeout_endbadly);
-    timeout_endbadly = GNUNET_SCHEDULER_NO_TASK;
+    timeout_endbadly = NULL;
   }
   if (NULL != api)
     GNUNET_PLUGIN_unload (libname, api);
@@ -183,11 +183,11 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct AddressWrapper *w;
   int c = 0;
 
-  timeout_endbadly = GNUNET_SCHEDULER_NO_TASK;
-  if (GNUNET_SCHEDULER_NO_TASK != timeout_wait)
+  timeout_endbadly = NULL;
+  if (NULL != timeout_wait)
   {
     GNUNET_SCHEDULER_cancel (timeout_wait);
-    timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+    timeout_wait = NULL;
   }
 
   if (pretty_printers_running > 0)
@@ -249,7 +249,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 static void
 wait_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+  timeout_wait = NULL;
   if (0 == addresses_reported)
     GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
         "Plugin did not report any addresses, could not check address conversion functions\n");
@@ -260,15 +260,15 @@ wait_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 static void
 end_badly_now ()
 {
-  if (GNUNET_SCHEDULER_NO_TASK != timeout_wait)
+  if (NULL != timeout_wait)
   {
     GNUNET_SCHEDULER_cancel (timeout_wait);
-    timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+    timeout_wait = NULL;
   }
-  if (GNUNET_SCHEDULER_NO_TASK != timeout_endbadly)
+  if (NULL != timeout_endbadly)
   {
     GNUNET_SCHEDULER_cancel (timeout_endbadly);
-    timeout_endbadly = GNUNET_SCHEDULER_NO_TASK;
+    timeout_endbadly = NULL;
   }
   timeout_endbadly = GNUNET_SCHEDULER_add_now (&end_badly, NULL );
 }
@@ -291,31 +291,25 @@ static int got_reply;
  * Take the given address and append it to the set of results sent back to
  * the client.
  *
- * @param cls the transmission context used ('struct GNUNET_SERVER_TransmitContext*')
- * @param buf one of the names for the host, NULL on last callback
- * @param res #GNUNET_OK if conversion was successful, #GNUNET_SYSERR on failure,
- *      #GNUNET_OK on last callback
+ * @param cls closure
+ * @param address the address to print
+ * @param res result code
  */
 static void
-address_pretty_printer_cb (void *cls,
-                           const char *buf,
-                           int res)
+address_pretty_printer_cb (void *cls, const char *address, int res)
 {
-  if (NULL != buf)
+  if (NULL != address)
   {
     got_reply = GNUNET_YES;
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "Pretty address : `%s'\n",
-                buf);
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Pretty address : `%s'\n", address);
     pretty_printers_running--;
   }
   else
   {
-    if ( (GNUNET_OK == res) &&
-         (GNUNET_NO == got_reply) )
+    if (GNUNET_NO == got_reply)
     {
       pretty_printers_running--;
-      GNUNET_break (0);
+      GNUNET_break(0);
       end_badly_now ();
     }
   }
@@ -354,7 +348,7 @@ env_notify_address (void *cls,
     GNUNET_CONTAINER_DLL_insert(head, tail, w);
     got_reply = GNUNET_NO;
     GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Testing: address_to_string \n");
-    w->addrstring = strdup (
+    w->addrstring = GNUNET_strdup (
         api->address_to_string (api, w->address->address,
             w->address->address_length));
     if (NULL == w->addrstring)
@@ -424,10 +418,10 @@ env_notify_address (void *cls,
       end_badly_now ();
       return;
     }
-    if (GNUNET_SCHEDULER_NO_TASK != timeout_wait)
+    if (NULL != timeout_wait)
     {
       GNUNET_SCHEDULER_cancel (timeout_wait);
-      timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+      timeout_wait = NULL;
     }
 
     timeout_wait = GNUNET_SCHEDULER_add_delayed (WAIT, &wait_end, NULL );
@@ -473,13 +467,12 @@ env_notify_address (void *cls,
 }
 
 
-static struct GNUNET_ATS_Information
-env_get_address_type (void *cls, const struct sockaddr *addr, size_t addrlen)
+static enum GNUNET_ATS_Network_Type
+env_get_address_type (void *cls,
+                      const struct sockaddr *addr,
+                      size_t addrlen)
 {
-  struct GNUNET_ATS_Information ats;
-  ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
-  ats.value = htonl (GNUNET_ATS_NET_LOOPBACK);
-  return ats;
+  return GNUNET_ATS_NET_LOOPBACK;
 }