indentation
[oweals/gnunet.git] / src / transport / plugin_transport_smtp.c
index 9c0ac5ea582754593980aed46fba0bc094eca20c..074bc16fced1afd28760b65162a058c817deeb76 100644 (file)
@@ -146,7 +146,7 @@ static GNUNET_CronTime last_transmission;
 
 #define FILLCHAR '='
 static char *cvt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-  "abcdefghijklmnopqrstuvwxyz" "0123456789+/";
+    "abcdefghijklmnopqrstuvwxyz" "0123456789+/";
 
 /**
  * Encode into Base64.
@@ -179,41 +179,41 @@ base64_encode (const char *data, unsigned int len, char **output)
   opt[1] = '\n';
   ret += 2;
   for (i = 0; i < len; ++i)
+  {
+    c = (data[i] >> 2) & 0x3f;
+    opt[ret++] = cvt[(int) c];
+    CHECKLINE;
+    c = (data[i] << 4) & 0x3f;
+    if (++i < len)
+      c |= (data[i] >> 4) & 0x0f;
+    opt[ret++] = cvt[(int) c];
+    CHECKLINE;
+    if (i < len)
     {
-      c = (data[i] >> 2) & 0x3f;
+      c = (data[i] << 2) & 0x3f;
+      if (++i < len)
+        c |= (data[i] >> 6) & 0x03;
       opt[ret++] = cvt[(int) c];
       CHECKLINE;
-      c = (data[i] << 4) & 0x3f;
-      if (++i < len)
-        c |= (data[i] >> 4) & 0x0f;
+    }
+    else
+    {
+      ++i;
+      opt[ret++] = FILLCHAR;
+      CHECKLINE;
+    }
+    if (i < len)
+    {
+      c = data[i] & 0x3f;
       opt[ret++] = cvt[(int) c];
       CHECKLINE;
-      if (i < len)
-        {
-          c = (data[i] << 2) & 0x3f;
-          if (++i < len)
-            c |= (data[i] >> 6) & 0x03;
-          opt[ret++] = cvt[(int) c];
-          CHECKLINE;
-        }
-      else
-        {
-          ++i;
-          opt[ret++] = FILLCHAR;
-          CHECKLINE;
-        }
-      if (i < len)
-        {
-          c = data[i] & 0x3f;
-          opt[ret++] = cvt[(int) c];
-          CHECKLINE;
-        }
-      else
-        {
-          opt[ret++] = FILLCHAR;
-          CHECKLINE;
-        }
     }
+    else
+    {
+      opt[ret++] = FILLCHAR;
+      CHECKLINE;
+    }
+  }
   opt[ret++] = FILLCHAR;
   return ret;
 }
@@ -252,38 +252,38 @@ base64_decode (const char *data, unsigned int len, char **output)
                  "base64_decode decoding len=%d\n", len);
 #endif
   for (i = 0; i < len; ++i)
+  {
+    CHECK_CRLF;
+    if (data[i] == FILLCHAR)
+      break;
+    c = (char) cvtfind (data[i]);
+    ++i;
+    CHECK_CRLF;
+    c1 = (char) cvtfind (data[i]);
+    c = (c << 2) | ((c1 >> 4) & 0x3);
+    (*output)[ret++] = c;
+    if (++i < len)
     {
       CHECK_CRLF;
-      if (data[i] == FILLCHAR)
+      c = data[i];
+      if (FILLCHAR == c)
         break;
-      c = (char) cvtfind (data[i]);
-      ++i;
+      c = (char) cvtfind (c);
+      c1 = ((c1 << 4) & 0xf0) | ((c >> 2) & 0xf);
+      (*output)[ret++] = c1;
+    }
+    if (++i < len)
+    {
       CHECK_CRLF;
-      c1 = (char) cvtfind (data[i]);
-      c = (c << 2) | ((c1 >> 4) & 0x3);
+      c1 = data[i];
+      if (FILLCHAR == c1)
+        break;
+
+      c1 = (char) cvtfind (c1);
+      c = ((c << 6) & 0xc0) | c1;
       (*output)[ret++] = c;
-      if (++i < len)
-        {
-          CHECK_CRLF;
-          c = data[i];
-          if (FILLCHAR == c)
-            break;
-          c = (char) cvtfind (c);
-          c1 = ((c1 << 4) & 0xf0) | ((c >> 2) & 0xf);
-          (*output)[ret++] = c1;
-        }
-      if (++i < len)
-        {
-          CHECK_CRLF;
-          c1 = data[i];
-          if (FILLCHAR == c1)
-            break;
-
-          c1 = (char) cvtfind (c1);
-          c = ((c << 6) & 0xc0) | c1;
-          (*output)[ret++] = c;
-        }
     }
+  }
 END:
   return ret;
 }
@@ -323,83 +323,83 @@ listenAndDistribute (void *unused)
 
 
   while (smtp_shutdown == GNUNET_NO)
+  {
+    fd = OPEN (pipename, O_RDONLY | O_ASYNC);
+    if (fd == -1)
     {
-      fd = OPEN (pipename, O_RDONLY | O_ASYNC);
-      if (fd == -1)
-        {
-          if (smtp_shutdown == GNUNET_NO)
-            GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);
-          continue;
-        }
-      fdes = fdopen (fd, "r");
-      while (smtp_shutdown == GNUNET_NO)
-        {
-          /* skip until end of header */
-          do
-            {
-              READLINE (line, linesize);
-            }
-          while ((line[0] != '\r') && (line[0] != '\n'));       /* expect newline */
-          READLINE (line, linesize);    /* read base64 encoded message; decode, process */
-          pos = 0;
-          while (1)
-            {
-              pos = strlen (line) - 1;  /* ignore new line */
-              READLINE (&line[pos], linesize - pos);    /* read base64 encoded message; decode, process */
-              if ((line[pos] == '\r') || (line[pos] == '\n'))
-                break;          /* empty line => end of message! */
-            }
-          size = base64_decode (line, pos, &out);
-          if (size < sizeof (SMTPMessage))
-            {
-              GNUNET_GE_BREAK (ectx, 0);
-              GNUNET_free (out);
-              goto END;
-            }
-
-          mp = (SMTPMessage *) & out[size - sizeof (SMTPMessage)];
-          if (ntohs (mp->header.size) != size)
-            {
-              GNUNET_GE_LOG (ectx,
-                             GNUNET_GE_WARNING | GNUNET_GE_BULK |
-                             GNUNET_GE_USER,
-                             _
-                             ("Received malformed message via %s. Ignored.\n"),
-                             "SMTP");
-#if DEBUG_SMTP
-              GNUNET_GE_LOG (ectx,
-                             GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
-                             GNUNET_GE_USER,
-                             "Size returned by base64=%d, in the msg=%d.\n",
-                             size, ntohl (mp->size));
-#endif
-              GNUNET_free (out);
-              goto END;
-            }
-          if (stats != NULL)
-            stats->change (stat_bytesReceived, size);
-          coreMP = GNUNET_malloc (sizeof (GNUNET_TransportPacket));
-          coreMP->msg = out;
-          coreMP->size = size - sizeof (SMTPMessage);
-          coreMP->tsession = NULL;
-          coreMP->sender = mp->sender;
+      if (smtp_shutdown == GNUNET_NO)
+        GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);
+      continue;
+    }
+    fdes = fdopen (fd, "r");
+    while (smtp_shutdown == GNUNET_NO)
+    {
+      /* skip until end of header */
+      do
+      {
+        READLINE (line, linesize);
+      }
+      while ((line[0] != '\r') && (line[0] != '\n'));   /* expect newline */
+      READLINE (line, linesize);        /* read base64 encoded message; decode, process */
+      pos = 0;
+      while (1)
+      {
+        pos = strlen (line) - 1;        /* ignore new line */
+        READLINE (&line[pos], linesize - pos);  /* read base64 encoded message; decode, process */
+        if ((line[pos] == '\r') || (line[pos] == '\n'))
+          break;                /* empty line => end of message! */
+      }
+      size = base64_decode (line, pos, &out);
+      if (size < sizeof (SMTPMessage))
+      {
+        GNUNET_GE_BREAK (ectx, 0);
+        GNUNET_free (out);
+        goto END;
+      }
+
+      mp = (SMTPMessage *) &out[size - sizeof (SMTPMessage)];
+      if (ntohs (mp->header.size) != size)
+      {
+        GNUNET_GE_LOG (ectx,
+                       GNUNET_GE_WARNING | GNUNET_GE_BULK |
+                       GNUNET_GE_USER,
+                       _
+                       ("Received malformed message via %s. Ignored.\n"),
+                       "SMTP");
 #if DEBUG_SMTP
-          GNUNET_GE_LOG (ectx,
-                         GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
-                         "SMTP message passed to the core.\n");
+        GNUNET_GE_LOG (ectx,
+                       GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
+                       GNUNET_GE_USER,
+                       "Size returned by base64=%d, in the msg=%d.\n",
+                       size, ntohl (mp->size));
 #endif
-
-          coreAPI->receive (coreMP);
-        }
-    END:
+        GNUNET_free (out);
+        goto END;
+      }
+      if (stats != NULL)
+        stats->change (stat_bytesReceived, size);
+      coreMP = GNUNET_malloc (sizeof (GNUNET_TransportPacket));
+      coreMP->msg = out;
+      coreMP->size = size - sizeof (SMTPMessage);
+      coreMP->tsession = NULL;
+      coreMP->sender = mp->sender;
 #if DEBUG_SMTP
       GNUNET_GE_LOG (ectx,
                      GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
-                     "SMTP message processed.\n");
+                     "SMTP message passed to the core.\n");
 #endif
-      if (fdes != NULL)
-        fclose (fdes);
+
+      coreAPI->receive (coreMP);
     }
+END:
+#if DEBUG_SMTP
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
+                   "SMTP message processed.\n");
+#endif
+    if (fdes != NULL)
+      fclose (fdes);
+  }
   GNUNET_free (line);
   return NULL;
 }
@@ -425,10 +425,10 @@ api_verify_hello (const GNUNET_MessageHello * hello)
        sizeof (GNUNET_MessageHello) + ntohs (hello->senderAddressSize)) ||
       (maddr->senderAddress[ntohs (hello->senderAddressSize) - 1 -
                             FILTER_STRING_SIZE] != '\0'))
-    {
-      GNUNET_GE_BREAK (ectx, 0);
-      return GNUNET_SYSERR;     /* obviously invalid */
-    }
+  {
+    GNUNET_GE_BREAK (ectx, 0);
+    return GNUNET_SYSERR;       /* obviously invalid */
+  }
   if (NULL == strstr (maddr->filter, ": "))
     return GNUNET_SYSERR;
   return GNUNET_OK;
@@ -453,27 +453,26 @@ api_create_hello ()
                                             "SMTP", "FILTER",
                                             "X-mailer: GNUnet", &filter);
   if (NULL == strstr (filter, ": "))
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                     _("SMTP filter string to invalid, lacks ': '\n"));
-      GNUNET_free (filter);
-      return NULL;
-    }
+  {
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+                   _("SMTP filter string to invalid, lacks ': '\n"));
+    GNUNET_free (filter);
+    return NULL;
+  }
 
   if (strlen (filter) > FILTER_STRING_SIZE)
-    {
-      filter[FILTER_STRING_SIZE] = '\0';
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                     _("SMTP filter string to long, capped to `%s'\n"),
-                     filter);
-    }
+  {
+    filter[FILTER_STRING_SIZE] = '\0';
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+                   _("SMTP filter string to long, capped to `%s'\n"), filter);
+  }
   i = (strlen (email) + 8) & (~7);      /* make multiple of 8 */
   msg =
-    GNUNET_malloc (sizeof (GNUNET_MessageHello) + sizeof (EmailAddress) + i);
+      GNUNET_malloc (sizeof (GNUNET_MessageHello) + sizeof (EmailAddress) + i);
   memset (msg, 0, sizeof (GNUNET_MessageHello) + sizeof (EmailAddress) + i);
-  haddr = (EmailAddress *) & msg[1];
+  haddr = (EmailAddress *) &msg[1];
   memset (&haddr->filter[0], 0, FILTER_STRING_SIZE);
   strcpy (&haddr->filter[0], filter);
   memcpy (&haddr->senderAddress[0], email, strlen (email) + 1);
@@ -501,10 +500,10 @@ get_message (void **buf, int *len, void *cls)
 
   *buf = NULL;
   if (len == NULL)
-    {
-      gmc->pos = 0;
-      return NULL;
-    }
+  {
+    gmc->pos = 0;
+    return NULL;
+  }
   if (gmc->pos == gmc->esize)
     return NULL;                /* done */
   *len = gmc->esize;
@@ -535,6 +534,7 @@ api_send (GNUNET_TSession * tsession,
   smtp_session_t session;
   smtp_message_t message;
   smtp_recipient_t recipient;
+
 #define EBUF_LEN 128
   char ebuf[EBUF_LEN];
   GNUNET_CronTime now;
@@ -542,10 +542,10 @@ api_send (GNUNET_TSession * tsession,
   if (smtp_shutdown == GNUNET_YES)
     return GNUNET_SYSERR;
   if ((size == 0) || (size > smtpAPI.mtu))
-    {
-      GNUNET_GE_BREAK (ectx, 0);
-      return GNUNET_SYSERR;
-    }
+  {
+    GNUNET_GE_BREAK (ectx, 0);
+    return GNUNET_SYSERR;
+  }
   now = GNUNET_get_time ();
   if ((important != GNUNET_YES) &&
       ((now - last_transmission) * rate_limit) < GNUNET_CRON_HOURS)
@@ -558,42 +558,42 @@ api_send (GNUNET_TSession * tsession,
   GNUNET_mutex_lock (lock);
   session = smtp_create_session ();
   if (session == NULL)
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_IMMEDIATE,
-                     _("SMTP: `%s' failed: %s.\n"),
-                     "smtp_create_session",
-                     smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
-      GNUNET_mutex_unlock (lock);
-      return GNUNET_SYSERR;
-    }
+  {
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                   GNUNET_GE_IMMEDIATE,
+                   _("SMTP: `%s' failed: %s.\n"),
+                   "smtp_create_session",
+                   smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
+    GNUNET_mutex_unlock (lock);
+    return GNUNET_SYSERR;
+  }
   if (0 == smtp_set_server (session, smtp_server_name))
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_IMMEDIATE,
-                     _("SMTP: `%s' failed: %s.\n"),
-                     "smtp_set_server",
-                     smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
-      smtp_destroy_session (session);
-      GNUNET_mutex_unlock (lock);
-      return GNUNET_SYSERR;
-    }
+  {
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                   GNUNET_GE_IMMEDIATE,
+                   _("SMTP: `%s' failed: %s.\n"),
+                   "smtp_set_server",
+                   smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
+    smtp_destroy_session (session);
+    GNUNET_mutex_unlock (lock);
+    return GNUNET_SYSERR;
+  }
   haddr = (const EmailAddress *) &hello[1];
   message = smtp_add_message (session);
   if (message == NULL)
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     _("SMTP: `%s' failed: %s.\n"),
-                     "smtp_add_message",
-                     smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
-      smtp_destroy_session (session);
-      GNUNET_mutex_unlock (lock);
-      return GNUNET_SYSERR;
-    }
+  {
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                   GNUNET_GE_BULK,
+                   _("SMTP: `%s' failed: %s.\n"),
+                   "smtp_add_message",
+                   smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
+    smtp_destroy_session (session);
+    GNUNET_mutex_unlock (lock);
+    return GNUNET_SYSERR;
+  }
   smtp_set_header (message, "To", NULL, haddr->senderAddress);
   smtp_set_header (message, "From", NULL, email);
 
@@ -603,84 +603,82 @@ api_send (GNUNET_TSession * tsession,
   fvalue[0] = '\0';
   fvalue += 2;
   if (0 == smtp_set_header (message, filter, fvalue))
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     _("SMTP: `%s' failed: %s.\n"),
-                     "smtp_set_header",
-                     smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
-      smtp_destroy_session (session);
-      GNUNET_mutex_unlock (lock);
-      GNUNET_free (filter);
-      return GNUNET_SYSERR;
-    }
+  {
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                   GNUNET_GE_BULK,
+                   _("SMTP: `%s' failed: %s.\n"),
+                   "smtp_set_header",
+                   smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
+    smtp_destroy_session (session);
+    GNUNET_mutex_unlock (lock);
+    GNUNET_free (filter);
+    return GNUNET_SYSERR;
+  }
   GNUNET_free (filter);
   m = GNUNET_malloc (size + sizeof (SMTPMessage));
   memcpy (m, msg, size);
-  mp = (SMTPMessage *) & m[size];
+  mp = (SMTPMessage *) &m[size];
   mp->header.size = htons (size + sizeof (SMTPMessage));
   mp->header.type = htons (0);
   mp->sender = *coreAPI->my_identity;
   gm_cls.ebody = NULL;
   gm_cls.pos = 0;
-  gm_cls.esize =
-    base64_encode (m, size + sizeof (SMTPMessage), &gm_cls.ebody);
+  gm_cls.esize = base64_encode (m, size + sizeof (SMTPMessage), &gm_cls.ebody);
   GNUNET_free (m);
   if (0 == smtp_size_set_estimate (message, gm_cls.esize))
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     _("SMTP: `%s' failed: %s.\n"),
-                     "smtp_size_set_estimate",
-                     smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
-    }
+  {
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                   GNUNET_GE_BULK,
+                   _("SMTP: `%s' failed: %s.\n"),
+                   "smtp_size_set_estimate",
+                   smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
+  }
   if (0 == smtp_set_messagecb (message, &get_message, &gm_cls))
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     _("SMTP: `%s' failed: %s.\n"),
-                     "smtp_set_messagecb",
-                     smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
-      smtp_destroy_session (session);
-      GNUNET_mutex_unlock (lock);
-      GNUNET_free (gm_cls.ebody);
-      return GNUNET_SYSERR;
-    }
+  {
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                   GNUNET_GE_BULK,
+                   _("SMTP: `%s' failed: %s.\n"),
+                   "smtp_set_messagecb",
+                   smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
+    smtp_destroy_session (session);
+    GNUNET_mutex_unlock (lock);
+    GNUNET_free (gm_cls.ebody);
+    return GNUNET_SYSERR;
+  }
   recipient = smtp_add_recipient (message, haddr->senderAddress);
   if (recipient == NULL)
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     _("SMTP: `%s' failed: %s.\n"),
-                     "smtp_add_recipient",
-                     smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
-      smtp_destroy_session (session);
-      GNUNET_mutex_unlock (lock);
-      return GNUNET_SYSERR;
-    }
+  {
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                   GNUNET_GE_BULK,
+                   _("SMTP: `%s' failed: %s.\n"),
+                   "smtp_add_recipient",
+                   smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
+    smtp_destroy_session (session);
+    GNUNET_mutex_unlock (lock);
+    return GNUNET_SYSERR;
+  }
   if (0 == smtp_start_session (session))
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     _("SMTP: `%s' failed: %s.\n"),
-                     "smtp_start_session",
-                     smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
-      smtp_destroy_session (session);
-      GNUNET_mutex_unlock (lock);
-      GNUNET_free (gm_cls.ebody);
-      return GNUNET_SYSERR;
-    }
+  {
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                   GNUNET_GE_BULK,
+                   _("SMTP: `%s' failed: %s.\n"),
+                   "smtp_start_session",
+                   smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
+    smtp_destroy_session (session);
+    GNUNET_mutex_unlock (lock);
+    GNUNET_free (gm_cls.ebody);
+    return GNUNET_SYSERR;
+  }
   if (stats != NULL)
     stats->change (stat_bytesSent, size);
   if (coreAPI->load_monitor != NULL)
     GNUNET_network_monitor_notify_transmission (coreAPI->load_monitor,
-                                                GNUNET_ND_UPLOAD,
-                                                gm_cls.esize);
+                                                GNUNET_ND_UPLOAD, gm_cls.esize);
   smtp_message_reset_status (message);  /* this is needed to plug a 28-byte/message memory leak in libesmtp */
   smtp_destroy_session (session);
   GNUNET_mutex_unlock (lock);
@@ -720,11 +718,11 @@ static int
 api_disconnect (GNUNET_TSession * tsession)
 {
   if (tsession != NULL)
-    {
-      if (tsession->internal != NULL)
-        GNUNET_free (tsession->internal);
-      GNUNET_free (tsession);
-    }
+  {
+    if (tsession->internal != NULL)
+      GNUNET_free (tsession->internal);
+    GNUNET_free (tsession);
+  }
   return GNUNET_OK;
 }
 
@@ -737,15 +735,14 @@ api_start_transport_server ()
 {
   smtp_shutdown = GNUNET_NO;
   /* initialize SMTP network */
-  dispatchThread =
-    GNUNET_thread_create (&listenAndDistribute, NULL, 1024 * 4);
+  dispatchThread = GNUNET_thread_create (&listenAndDistribute, NULL, 1024 * 4);
   if (dispatchThread == NULL)
-    {
-      GNUNET_GE_DIE_STRERROR (ectx,
-                              GNUNET_GE_ADMIN | GNUNET_GE_BULK |
-                              GNUNET_GE_FATAL, "pthread_create");
-      return GNUNET_SYSERR;
-    }
+  {
+    GNUNET_GE_DIE_STRERROR (ectx,
+                            GNUNET_GE_ADMIN | GNUNET_GE_BULK |
+                            GNUNET_GE_FATAL, "pthread_create");
+    return GNUNET_SYSERR;
+  }
   return GNUNET_OK;
 }
 
@@ -809,13 +806,13 @@ inittransport_smtp (GNUNET_CoreAPIForTransport * core)
   coreAPI = core;
   ectx = core->ectx;
   if (!GNUNET_GC_have_configuration_value (coreAPI->cfg, "SMTP", "EMAIL"))
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
-                     _
-                     ("No email-address specified, can not start SMTP transport.\n"));
-      return NULL;
-    }
+  {
+    GNUNET_GE_LOG (ectx,
+                   GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
+                   _
+                   ("No email-address specified, can not start SMTP transport.\n"));
+    return NULL;
+  }
   GNUNET_GC_get_configuration_value_number (coreAPI->cfg,
                                             "SMTP",
                                             "MTU",
@@ -828,13 +825,13 @@ inittransport_smtp (GNUNET_CoreAPIForTransport * core)
                                             0, 0, 1024 * 1024, &rate_limit);
   stats = coreAPI->service_request ("stats");
   if (stats != NULL)
-    {
-      stat_bytesReceived
+  {
+    stat_bytesReceived
         = stats->create (gettext_noop ("# bytes received via SMTP"));
-      stat_bytesSent = stats->create (gettext_noop ("# bytes sent via SMTP"));
-      stat_bytesDropped
+    stat_bytesSent = stats->create (gettext_noop ("# bytes sent via SMTP"));
+    stat_bytesDropped
         = stats->create (gettext_noop ("# bytes dropped by SMTP (outgoing)"));
-    }
+  }
   GNUNET_GC_get_configuration_value_filename (coreAPI->cfg,
                                               "SMTP",
                                               "PIPE",
@@ -842,17 +839,17 @@ inittransport_smtp (GNUNET_CoreAPIForTransport * core)
                                               "/smtp-pipe", &pipename);
   UNLINK (pipename);
   if (0 != mkfifo (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH))
-    {
-      GNUNET_GE_LOG_STRERROR (ectx,
-                              GNUNET_GE_ADMIN | GNUNET_GE_BULK |
-                              GNUNET_GE_FATAL, "mkfifo");
-      GNUNET_free (pipename);
-      coreAPI->service_release (stats);
-      stats = NULL;
-      return NULL;
-    }
+  {
+    GNUNET_GE_LOG_STRERROR (ectx,
+                            GNUNET_GE_ADMIN | GNUNET_GE_BULK |
+                            GNUNET_GE_FATAL, "mkfifo");
+    GNUNET_free (pipename);
+    coreAPI->service_release (stats);
+    stats = NULL;
+    return NULL;
+  }
   /* we need to allow the mailer program to send us messages;
-     easiest done by giving it write permissions (see Mantis #1142) */
+   * easiest done by giving it write permissions (see Mantis #1142) */
   if (0 != chmod (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH))
     GNUNET_GE_LOG_STRERROR (ectx,
                             GNUNET_GE_ADMIN | GNUNET_GE_BULK |
@@ -863,8 +860,7 @@ inittransport_smtp (GNUNET_CoreAPIForTransport * core)
   GNUNET_GC_get_configuration_value_string (coreAPI->cfg,
                                             "SMTP",
                                             "SERVER",
-                                            "localhost:25",
-                                            &smtp_server_name);
+                                            "localhost:25", &smtp_server_name);
   sa.sa_handler = SIG_IGN;
   sigemptyset (&sa.sa_mask);
   sa.sa_flags = 0;
@@ -892,10 +888,10 @@ donetransport_smtp ()
   sigaction (SIGPIPE, &old_handler, NULL);
   GNUNET_free (smtp_server_name);
   if (stats != NULL)
-    {
-      coreAPI->service_release (stats);
-      stats = NULL;
-    }
+  {
+    coreAPI->service_release (stats);
+    stats = NULL;
+  }
   GNUNET_mutex_destroy (lock);
   lock = NULL;
   UNLINK (pipename);