use putenv instead of setenv for portability
[oweals/gnunet.git] / src / util / server_mst.c
index f48ef5475f96ce3a8ebbd79ccfe7d6415a4a0934..dcb8c48102f631287d2de3f14f07d797ab2d33e9 100644 (file)
@@ -31,7 +31,7 @@
 #include "gnunet_server_lib.h"
 #include "gnunet_time_lib.h"
 
-#define DEBUG_SERVER_MST GNUNET_NO
+#define DEBUG_SERVER_MST GNUNET_EXTRA_LOGGING
 
 #if HAVE_UNALIGNED_64_ACCESS
 #define ALIGN_FACTOR 4
@@ -39,6 +39,8 @@
 #define ALIGN_FACTOR 8
 #endif
 
+#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
+
 
 /**
  * Handle to a message stream tokenizer.
@@ -110,7 +112,7 @@ GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb,
  * @param client_identity ID of client for which this is a buffer
  * @param buf input data to add
  * @param size number of bytes in buf
- * @param purge should any excess bytes in the buffer be discarded 
+ * @param purge should any excess bytes in the buffer be discarded
  *       (i.e. for packet-based services like UDP)
  * @param one_shot only call callback once, keep rest of message in buffer
  * @return GNUNET_OK if we are done processing (need more data)
@@ -119,9 +121,8 @@ GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb,
  */
 int
 GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
-                           void *client_identity,
-                           const char *buf,
-                           size_t size, int purge, int one_shot)
+                           void *client_identity, const char *buf, size_t size,
+                           int purge, int one_shot)
 {
   const struct GNUNET_MessageHeader *hdr;
   size_t delta;
@@ -132,9 +133,9 @@ GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
   int ret;
 
 #if DEBUG_SERVER_MST
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Server-mst receives %u bytes with %u bytes already in private buffer\n",
-              (unsigned int) size, (unsigned int) (mst->pos - mst->off));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Server-mst receives %u bytes with %u bytes already in private buffer\n",
+       (unsigned int) size, (unsigned int) (mst->pos - mst->off));
 #endif
   ret = GNUNET_OK;
   ibuf = (char *) mst->hdr;
@@ -227,9 +228,9 @@ do_align:
   while (size > 0)
   {
 #if DEBUG_SERVER_MST
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Server-mst has %u bytes left in inbound buffer\n",
-                (unsigned int) size);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Server-mst has %u bytes left in inbound buffer\n",
+         (unsigned int) size);
 #endif
     if (size < sizeof (struct GNUNET_MessageHeader))
       break;
@@ -284,9 +285,9 @@ copy:
   if (purge)
     mst->off = 0;
 #if DEBUG_SERVER_MST
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Server-mst leaves %u bytes in private buffer\n",
-              (unsigned int) (mst->pos - mst->off));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Server-mst leaves %u bytes in private buffer\n",
+       (unsigned int) (mst->pos - mst->off));
 #endif
   return ret;
 }