-/* $Cambridge: exim/src/src/transports/autoreply.c,v 1.3 2005/06/07 15:20:56 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/autoreply.c,v 1.8 2006/02/07 11:19:03 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2005 */
+/* Copyright (c) University of Cambridge 1995 - 2006 */
/* See the file NOTICE for conditions of use and distribution. */
set, instead of a dbm file, we use a regular file containing a circular buffer
recipient cache. */
-if (oncelog != NULL && to != NULL)
+if (oncelog != NULL && *oncelog != 0 && to != NULL)
{
time_t then = 0;
uschar *ptr = log_buffer;
sprintf(CS ptr, "%s\n previously sent to %.200s\n", tod_stamp(tod_log), to);
while(*ptr) ptr++;
- write(log_fd, log_buffer, ptr - log_buffer);
- close(log_fd);
+ (void)write(log_fd, log_buffer, ptr - log_buffer);
+ (void)close(log_fd);
}
goto END_OFF;
}
}
/* Copy the original message if required, observing the return size
-limit. */
+limit if we are returning the body. */
if (return_message)
{
- if (bounce_return_size_limit > 0)
+ uschar *rubric = (tblock->headers_only)?
+ US"------ This is a copy of the message's header lines.\n"
+ : (tblock->body_only)?
+ US"------ This is a copy of the body of the message, without the headers.\n"
+ :
+ US"------ This is a copy of the message, including all the headers.\n";
+
+ if (bounce_return_size_limit > 0 && !tblock->headers_only)
{
struct stat statbuf;
int max = (bounce_return_size_limit/DELIVER_IN_BUFFER_SIZE + 1) *
DELIVER_IN_BUFFER_SIZE;
if (fstat(deliver_datafile, &statbuf) == 0 && statbuf.st_size > max)
{
- fprintf(f, "\n"
-"------ This is a copy of the message, including all the headers.\n"
-"------ The body of the message is %.30g characters long; only the first\n"
-"------ %d or so are included here.\n\n", (double)statbuf.st_size,
+ fprintf(f, "\n%s"
+"------ The body of the message is " OFF_T_FMT " characters long; only the first\n"
+"------ %d or so are included here.\n\n", rubric, statbuf.st_size,
(max/1000)*1000);
}
- else fprintf(f, "\n"
-"------ This is a copy of the message, including all the headers. ------\n\n");
+ else fprintf(f, "\n%s\n", rubric);
}
- else fprintf(f, "\n"
-"------ This is a copy of the message, including all the headers. ------\n\n");
+ else fprintf(f, "\n%s\n", rubric);
fflush(f);
transport_count = 0;
/* End the message and wait for the child process to end; no timeout. */
-fclose(f);
+(void)fclose(f);
rc = child_close(pid, 0);
/* Update the "sent to" log whatever the yield. This errs on the side of
}
memcpy(cache_time, &now, sizeof(time_t));
- write(cache_fd, from, size);
+ (void)write(cache_fd, from, size);
}
/* Update DBM file */
" %s\n", headers);
while(*ptr) ptr++;
}
- write(log_fd, log_buffer, ptr - log_buffer);
- close(log_fd);
+ (void)write(log_fd, log_buffer, ptr - log_buffer);
+ (void)close(log_fd);
}
else DEBUG(D_transport) debug_printf("Failed to open log file %s for %s "
"transport: %s\n", logfile, tblock->name, strerror(errno));
END_OFF:
if (dbm_file != NULL) EXIM_DBCLOSE(dbm_file);
-if (cache_fd > 0) close(cache_fd);
+if (cache_fd > 0) (void)close(cache_fd);
DEBUG(D_transport) debug_printf("%s transport succeeded\n", tblock->name);