-LRN: fix dv test dependencies
[oweals/gnunet.git] / src / dv / dv_api.c
index 3450e584439e1e7ac32e9aa637fd4b5077049fda..93891ca1734f9d0deb3f109496a61ee0575f896e 100644 (file)
@@ -38,6 +38,8 @@
 #include "dv.h"
 #include "gnunet_transport_plugin.h"
 
+#define LOG(kind,...) GNUNET_log_from (kind, "dv-api",__VA_ARGS__)
+
 /**
  * Store ready to send messages
  */
@@ -174,13 +176,13 @@ try_connect (struct GNUNET_DV_Handle *ret)
   if (ret->client != NULL)
     return GNUNET_YES;
 #if DEBUG_DV_MESSAGES
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              _("Failed to connect to the dv service!\n"));
+  LOG (GNUNET_ERROR_TYPE_DEBUG, _("Failed to connect to the dv service!\n"));
 #endif
   return GNUNET_NO;
 }
 
-static void process_pending_message (struct GNUNET_DV_Handle *handle);
+static void
+process_pending_message (struct GNUNET_DV_Handle *handle);
 
 /**
  * Send complete, schedule next
@@ -218,16 +220,15 @@ transmit_pending (void *cls, size_t size, void *buf)
 
 #if DEBUG_DV
   if (handle->current != NULL)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "DV API: Transmit pending called with message type %d\n",
-                ntohs (handle->current->msg->header.type));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "DV API: Transmit pending called with message type %d\n",
+         ntohs (handle->current->msg->header.type));
 #endif
 
   if (buf == NULL)
   {
 #if DEBUG_DV
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "DV API: Transmit pending FAILED!\n\n\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "DV API: Transmit pending FAILED!\n\n\n");
 #endif
     finish (handle, GNUNET_SYSERR);
     return 0;
@@ -243,8 +244,8 @@ transmit_pending (void *cls, size_t size, void *buf)
     {
       memcpy (buf, handle->current->msg, tsize);
 #if DEBUG_DV
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "DV API: Copied %d bytes into buffer!\n\n\n", tsize);
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "DV API: Copied %d bytes into buffer!\n\n\n", tsize);
 #endif
       finish (handle, GNUNET_OK);
       return tsize;
@@ -284,15 +285,15 @@ process_pending_message (struct GNUNET_DV_Handle *handle)
   if (NULL ==
       (handle->th =
        GNUNET_CLIENT_notify_transmit_ready (handle->client,
-                                            ntohs (handle->current->msg->header.
-                                                   size),
+                                            ntohs (handle->current->msg->
+                                                   header.size),
                                             handle->current->msg->timeout,
                                             GNUNET_YES, &transmit_pending,
                                             handle)))
   {
 #if DEBUG_DV
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Failed to transmit request to dv service.\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Failed to transmit request to dv service.\n");
 #endif
     finish (handle, GNUNET_SYSERR);
   }
@@ -356,7 +357,7 @@ handle_message_receipt (void *cls, const struct GNUNET_MessageHeader *msg)
   if (msg == NULL)
   {
 #if DEBUG_DV_MESSAGES
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: connection closed\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: connection closed\n");
 #endif
     return;                     /* Connection closed? */
   }
@@ -384,15 +385,15 @@ handle_message_receipt (void *cls, const struct GNUNET_MessageHeader *msg)
     memcpy (packed_msg, &packed_msg_start[sender_address_len], packed_msg_len);
 
 #if DEBUG_DV_MESSAGES
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "DV_API receive: packed message type: %d or %d\n",
-                ntohs (((struct GNUNET_MessageHeader *) packed_msg)->type),
-                ((struct GNUNET_MessageHeader *) packed_msg)->type);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "DV_API receive: message sender reported as %s\n",
-                GNUNET_i2s (&received_msg->sender));
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: distance is %u\n",
-                ntohl (received_msg->distance));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "DV_API receive: packed message type: %d or %d\n",
+         ntohs (((struct GNUNET_MessageHeader *) packed_msg)->type),
+         ((struct GNUNET_MessageHeader *) packed_msg)->type);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "DV_API receive: message sender reported as %s\n",
+         GNUNET_i2s (&received_msg->sender));
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: distance is %u\n",
+         ntohl (received_msg->distance));
 #endif
 
     handle->receive_handler (handle->receive_cls, &received_msg->sender,
@@ -512,8 +513,7 @@ transmit_start (void *cls, size_t size, void *buf)
   size_t tsize;
 
 #if DEBUG_DV
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "DV API: sending start request to service\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "DV API: sending start request to service\n");
 #endif
   if (buf == NULL)
   {
@@ -618,7 +618,7 @@ GNUNET_DV_disconnect (struct GNUNET_DV_Handle *handle)
   }
   if (handle->client != NULL)   /* Finally, disconnect from the service */
   {
-    GNUNET_CLIENT_disconnect (handle->client, GNUNET_NO);
+    GNUNET_CLIENT_disconnect (handle->client);
     handle->client = NULL;
   }