Use enum { SEEN_LF, …} for ch_state(s)
[exim.git] / src / src / receive.c
index 67fcc8e15b73503c7e9035c8746478ab3debf97e..b152ceefb68173f5b1c2e1f5d2e8f8f2ea874c28 100644 (file)
@@ -25,6 +25,7 @@ static FILE   *data_file = NULL;
 static int     data_fd = -1;
 static uschar *spool_name = US"";
 
+enum CH_STATE {LF_SEEN, MID_LINE, CR_SEEN};
 
 
 /*************************************************
@@ -913,7 +914,8 @@ Returns:    One of the END_xxx values indicating why it stopped reading
 static int
 read_message_bdat_smtp(FILE *fout)
 {
-int ch_state = 0, linelength = 0, ch;
+int linelength = 0, ch;
+enum CH_STATE ch_state = LF_SEEN;
 
 for(;;)
   {
@@ -926,14 +928,14 @@ for(;;)
     }
   switch (ch_state)
     {
-    case 0:                             /* After LF or CRLF */
-      ch_state = 1;
+    case LF_SEEN:                             /* After LF or CRLF */
+      ch_state = MID_LINE;
       /* fall through to handle as normal uschar. */
 
-    case 1:                             /* Mid-line state */
+    case MID_LINE:                            /* Mid-line state */
       if (ch == '\n')
        {
-       ch_state = 0;
+       ch_state = LF_SEEN;
        body_linecount++;
        if (linelength > max_received_linelength)
          max_received_linelength = linelength;
@@ -941,25 +943,25 @@ for(;;)
        }
       else if (ch == '\r')
        {
-       ch_state = 2;
+       ch_state = CR_SEEN;
        continue;                       /* don't write CR */
        }
       break;
 
-    case 2:                             /* After (unwritten) CR */
+    case CR_SEEN:                       /* After (unwritten) CR */
       body_linecount++;
       if (linelength > max_received_linelength)
        max_received_linelength = linelength;
       linelength = -1;
       if (ch == '\n')
-       ch_state = 0;
+       ch_state = LF_SEEN;
       else
        {
        message_size++;
        if (fout != NULL && fputc('\n', fout) == EOF) return END_WERROR;
        (void) cutthrough_put_nl();
        if (ch == '\r') continue;       /* don't write CR */
-       ch_state = 1;
+       ch_state = MID_LINE;
        }
       break;
     }
@@ -1116,7 +1118,7 @@ switch(where)
 
 if (acl_removed_headers != NULL)
   {
-  DEBUG(D_receive|D_acl) debug_printf(">>Headers removed by %s ACL:\n", acl_name);
+  DEBUG(D_receive|D_acl) debug_printf_indent(">>Headers removed by %s ACL:\n", acl_name);
 
   for (h = header_list; h != NULL; h = h->next) if (h->type != htype_old)
     {
@@ -1129,15 +1131,15 @@ if (acl_removed_headers != NULL)
       if (header_testname(h, s, Ustrlen(s), FALSE))
        {
        h->type = htype_old;
-        DEBUG(D_receive|D_acl) debug_printf("  %s", h->text);
+        DEBUG(D_receive|D_acl) debug_printf_indent("  %s", h->text);
        }
     }
   acl_removed_headers = NULL;
-  DEBUG(D_receive|D_acl) debug_printf(">>\n");
+  DEBUG(D_receive|D_acl) debug_printf_indent(">>\n");
   }
 
 if (acl_added_headers == NULL) return;
-DEBUG(D_receive|D_acl) debug_printf(">>Headers added by %s ACL:\n", acl_name);
+DEBUG(D_receive|D_acl) debug_printf_indent(">>Headers added by %s ACL:\n", acl_name);
 
 for (h = acl_added_headers; h != NULL; h = next)
   {
@@ -1148,7 +1150,7 @@ for (h = acl_added_headers; h != NULL; h = next)
     case htype_add_top:
     h->next = header_list;
     header_list = h;
-    DEBUG(D_receive|D_acl) debug_printf("  (at top)");
+    DEBUG(D_receive|D_acl) debug_printf_indent("  (at top)");
     break;
 
     case htype_add_rec:
@@ -1163,7 +1165,7 @@ for (h = acl_added_headers; h != NULL; h = next)
       }
     h->next = last_received->next;
     last_received->next = h;
-    DEBUG(D_receive|D_acl) debug_printf("  (after Received:)");
+    DEBUG(D_receive|D_acl) debug_printf_indent("  (after Received:)");
     break;
 
     case htype_add_rfc:
@@ -1178,7 +1180,7 @@ for (h = acl_added_headers; h != NULL; h = next)
        of all headers. Our current header must follow it. */
     h->next = last_received->next;
     last_received->next = h;
-    DEBUG(D_receive|D_acl) debug_printf("  (before any non-Received: or Resent-*: header)");
+    DEBUG(D_receive|D_acl) debug_printf_indent("  (before any non-Received: or Resent-*: header)");
     break;
 
     default:
@@ -1198,11 +1200,11 @@ for (h = acl_added_headers; h != NULL; h = next)
   h->type = header_checkname(h, FALSE);
   if (h->type >= 'a') h->type = htype_other;
 
-  DEBUG(D_receive|D_acl) debug_printf("  %s", header_last->text);
+  DEBUG(D_receive|D_acl) debug_printf_indent("  %s", header_last->text);
   }
 
 acl_added_headers = NULL;
-DEBUG(D_receive|D_acl) debug_printf(">>\n");
+DEBUG(D_receive|D_acl) debug_printf_indent(">>\n");
 }
 
 
@@ -1354,7 +1356,7 @@ if (rc == OK)
       {
       (void) string_format(rfc822_file_path, sizeof(rfc822_file_path),
        "%s/scan/%s/%s", spool_directory, message_id, entry->d_name);
-      debug_printf("RFC822 attachment detected: running MIME ACL for '%s'\n",
+      DEBUG(D_receive) debug_printf("RFC822 attachment detected: running MIME ACL for '%s'\n",
        rfc822_file_path);
       break;
       }