-fixing indentation
[oweals/gnunet.git] / src / hello / test_hello.c
index b6a9dc68168c70092da2dc367affc85df1abbaf0..eb15668f4555e61d6a981eaee3afbf4315322f4f 100644 (file)
@@ -25,9 +25,9 @@
 #include "platform.h"
 #include "gnunet_hello_lib.h"
 
-#define DEBUG GNUNET_NO
+#define DEBUG GNUNET_EXTRA_LOGGING
 
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_EXTRA_LOGGING
 
 
 static size_t
@@ -35,57 +35,60 @@ my_addr_gen (void *cls, size_t max, void *buf)
 {
   unsigned int *i = cls;
   size_t ret;
+  struct GNUNET_HELLO_Address address;
 
 #if DEBUG
   fprintf (stderr, "DEBUG: my_addr_gen called with i = %d\n", *i);
 #endif
   if (0 == *i)
     return 0;
-  ret = GNUNET_HELLO_add_address ("test",
-                                  GNUNET_TIME_absolute_get (),
-                                  "address_information", *i, buf, max);
+  memset (&address.peer, 0, sizeof (struct GNUNET_PeerIdentity));
+  address.address = "address_information";
+  address.transport_name = "test";
+  address.address_length = *i;
+  ret =
+      GNUNET_HELLO_add_address (&address, GNUNET_TIME_absolute_get (), buf,
+                                max);
   (*i)--;
   return ret;
 }
 
 
 static int
-check_addr (void *cls,
-            const char *tname,
-            struct GNUNET_TIME_Absolute expiration,
-            const void *addr, uint16_t addrlen)
+check_addr (void *cls, const struct GNUNET_HELLO_Address *address,
+            struct GNUNET_TIME_Absolute expiration)
 {
   unsigned int *i = cls;
 
 #if DEBUG
   fprintf (stderr, "DEBUG: check_addr called with i = %d and addrlen = %u\n",
-           *i, addrlen);
+           *i, address->address_length);
 #endif
-  GNUNET_assert (addrlen > 0);
-  GNUNET_assert (*i & (1 << (addrlen - 1)));
-  *i -= (1 << (addrlen - 1));
-  GNUNET_assert (0 == strncmp ("address_information", addr, addrlen));
-  GNUNET_assert (0 == strcmp ("test", tname));
+  GNUNET_assert (address->address_length > 0);
+  GNUNET_assert (*i & (1 << (address->address_length - 1)));
+  *i -= (1 << (address->address_length - 1));
+  GNUNET_assert (0 ==
+                 strncmp ("address_information", address->address,
+                          address->address_length));
+  GNUNET_assert (0 == strcmp ("test", address->transport_name));
   return GNUNET_OK;
 }
 
 
 static int
-remove_some (void *cls,
-             const char *tname,
-             struct GNUNET_TIME_Absolute expiration,
-             const void *addr, uint16_t addrlen)
+remove_some (void *cls, const struct GNUNET_HELLO_Address *address,
+             struct GNUNET_TIME_Absolute expiration)
 {
   unsigned int *i = cls;
 
 #if DEBUG
   fprintf (stderr, "DEBUG: remove_some called with i = %d and addrlen = %u\n",
-           *i, addrlen);
+           *i, address->address_length);
 #endif
-  GNUNET_assert (addrlen > 0);
-  if (*i & (1 << (addrlen - 1)))
+  GNUNET_assert (address->address_length > 0);
+  if (*i & (1 << (address->address_length - 1)))
   {
-    *i -= (1 << (addrlen - 1));
+    *i -= (1 << (address->address_length - 1));
     return GNUNET_NO;
   }
   return GNUNET_OK;
@@ -118,8 +121,8 @@ main (int argc, char *argv[])
   fprintf (stderr, "Testing address iteration (empty set)...\n");
 #endif
   GNUNET_assert (NULL ==
-                 GNUNET_HELLO_iterate_addresses (msg1,
-                                                 GNUNET_NO, &check_addr, &i));
+                 GNUNET_HELLO_iterate_addresses (msg1, GNUNET_NO, &check_addr,
+                                                 &i));
 
 #if VERBOSE
   fprintf (stderr, "Testing HELLO creation (with one address)...\n");
@@ -134,8 +137,8 @@ main (int argc, char *argv[])
 #endif
   i = 1;
   GNUNET_assert (NULL ==
-                 GNUNET_HELLO_iterate_addresses (msg2,
-                                                 GNUNET_NO, &check_addr, &i));
+                 GNUNET_HELLO_iterate_addresses (msg2, GNUNET_NO, &check_addr,
+                                                 &i));
   GNUNET_assert (i == 0);
 
 #if VERBOSE
@@ -158,8 +161,8 @@ main (int argc, char *argv[])
 #endif
   i = 3;
   GNUNET_assert (NULL ==
-                 GNUNET_HELLO_iterate_addresses (msg3,
-                                                 GNUNET_NO, &check_addr, &i));
+                 GNUNET_HELLO_iterate_addresses (msg3, GNUNET_NO, &check_addr,
+                                                 &i));
   GNUNET_assert (i == 0);
 
 #if VERBOSE
@@ -170,8 +173,8 @@ main (int argc, char *argv[])
 
   i = 3;
   GNUNET_assert (NULL ==
-                 GNUNET_HELLO_iterate_addresses (msg1,
-                                                 GNUNET_NO, &check_addr, &i));
+                 GNUNET_HELLO_iterate_addresses (msg1, GNUNET_NO, &check_addr,
+                                                 &i));
   GNUNET_assert (i == 0);
   GNUNET_free (msg1);
 
@@ -184,8 +187,8 @@ main (int argc, char *argv[])
   GNUNET_assert (i == 0);
   i = 1;
   GNUNET_assert (NULL ==
-                 GNUNET_HELLO_iterate_addresses (msg1,
-                                                 GNUNET_NO, &check_addr, &i));
+                 GNUNET_HELLO_iterate_addresses (msg1, GNUNET_NO, &check_addr,
+                                                 &i));
   GNUNET_assert (i == 0);
   GNUNET_free (msg1);
 
@@ -193,8 +196,8 @@ main (int argc, char *argv[])
   fprintf (stderr, "Testing delta address iteration...\n");
 #endif
   i = 2;
-  GNUNET_HELLO_iterate_new_addresses (msg3,
-                                      msg2, startup_time, &check_addr, &i);
+  GNUNET_HELLO_iterate_new_addresses (msg3, msg2, startup_time, &check_addr,
+                                      &i);
   GNUNET_assert (i == 0);
   GNUNET_free (msg2);
   GNUNET_free (msg3);