+static int
+read_message_bdat_smtp_wire(FILE *fout)
+{
+int ch;
+
+/* Remember that this message uses wireformat. */
+
+DEBUG(D_receive) debug_printf("CHUNKING: writing spoolfile in wire format\n");
+spool_file_wireformat = TRUE;
+
+/* Unfortunately cannot use sendfile() even if not TLS
+as that requires (on linux) mmap-like operations on the input fd.
+
+XXX but worthwhile doing a block interface to the bdat_getc buffer
+in the future */
+
+for (;;) switch (ch = bdat_getc(GETC_BUFFER_UNLIMITED))
+ {
+ case EOF: return END_EOF;
+ case EOD: return END_DOT;
+ case ERR: return END_PROTOCOL;
+
+ default:
+ message_size++;
+/*XXX not done:
+linelength
+max_received_linelength
+body_linecount
+body_zerocount
+*/
+ if (fout)
+ {
+ if (fputc(ch, fout) == EOF) return END_WERROR;
+ if (message_size > thismessage_size_limit) return END_SIZE;
+ }
+ break;
+ }
+/*NOTREACHED*/
+}
+