+/* When doing RFC3030 CHUNKING output, work out how much data will be in the
+last BDAT, consisting of the current write_chunk() output buffer fill
+(optimally, all of the headers - but it does not matter if we already had to
+flush that buffer with non-last BDAT prependix) plus the amount of body data
+(as expanded for CRLF lines). Then create and write the BDAT, and ensure
+that further use of write_chunk() will not prepend BDATs. */
+
+if (options & topt_use_bdat)
+ {
+ if ((size = chunk_ptr - deliver_out_buffer) < 0)
+ size = 0;
+ if (!(options & topt_no_body))
+ {
+ if ((fsize = lseek(deliver_datafile, 0, SEEK_END)) < 0) return FALSE;
+ fsize -= SPOOL_DATA_START_OFFSET;
+ if (size_limit > 0 && fsize > size_limit)
+ fsize = size_limit;
+ size += fsize;
+ if (options & topt_use_crlf)
+ size += body_linecount; /* account for CRLF-expansion */
+ }
+
+ /*XXX need an smtp_outblock here; can't really use the smtp
+ tpts one. so that had better have been flushed.
+
+ WORRY: smtp cmd response sync, needs an inblock and a LOT
+ of tpt info. NEED a callback into the tpt.
+
+#ifdef notdef
+ smtp_write_command(&outblock, FALSE, "BDAT %d LAST\r\n", size);
+ if (count < 0) return FALSE;
+ if (count > 0)
+ {
+ }
+#endif
+ */
+
+ wck_flags &= ~topt_use_bdat;
+ }
+