-va_end(ap);
-}
-
-/* This is split off so that verify.c:respond_printf() can, in effect, call
-smtp_printf(), bearing in mind that in C a vararg function can't directly
-call another vararg function, only a function which accepts a va_list. */
-
-void
-smtp_vprintf(const char *format, BOOL more, va_list ap)
-{
-BOOL yield;
-
-yield = string_vformat(big_buffer, big_buffer_size, format, ap);
-
-DEBUG(D_receive)
- {
- void *reset_point = store_get(0);
- uschar *msg_copy, *cr, *end;
- msg_copy = string_copy(big_buffer);
- end = msg_copy + Ustrlen(msg_copy);
- while ((cr = Ustrchr(msg_copy, '\r')) != NULL) /* lose CRs */
- memmove(cr, cr + 1, (end--) - cr);
- debug_printf("SMTP>> %s", msg_copy);
- store_reset(reset_point);
- }
-
-if (!yield)
- {
- log_write(0, LOG_MAIN|LOG_PANIC, "string too large in smtp_printf()");
- smtp_closedown(US"Unexpected error");
- exim_exit(EXIT_FAILURE, NULL);
- }
-
-/* If this is the first output for a (non-batch) RCPT command, see if all RCPTs
-have had the same. Note: this code is also present in smtp_respond(). It would
-be tidier to have it only in one place, but when it was added, it was easier to
-do it that way, so as not to have to mess with the code for the RCPT command,
-which sometimes uses smtp_printf() and sometimes smtp_respond(). */
-
-if (fl.rcpt_in_progress)
- {
- if (rcpt_smtp_response == NULL)
- rcpt_smtp_response = string_copy(big_buffer);
- else if (fl.rcpt_smtp_response_same &&
- Ustrcmp(rcpt_smtp_response, big_buffer) != 0)
- fl.rcpt_smtp_response_same = FALSE;
- fl.rcpt_in_progress = FALSE;
- }
-
-/* Now write the string */
-
-#ifdef SUPPORT_TLS
-if (tls_in.active.sock >= 0)
- {
- if (tls_write(NULL, big_buffer, Ustrlen(big_buffer), more) < 0)
- smtp_write_error = -1;
- }
-else
-#endif
-
-if (fprintf(smtp_out, "%s", big_buffer) < 0) smtp_write_error = -1;
-}
-
-
-
-/*************************************************
-* Flush SMTP out and check for error *
-*************************************************/
-
-/* This function isn't currently used within Exim (it detects errors when it
-tries to read the next SMTP input), but is available for use in local_scan().
-For non-TLS connections, it flushes the output and checks for errors. For
-TLS-connections, it checks for a previously-detected TLS write error.
-
-Arguments: none
-Returns: 0 for no error; -1 after an error
-*/
-
-int
-smtp_fflush(void)
-{
-if (tls_in.active.sock < 0 && fflush(smtp_out) != 0) smtp_write_error = -1;
-return smtp_write_error;
-}
-
-
-
-/*************************************************
-* SMTP command read timeout *
-*************************************************/
-
-/* Signal handler for timing out incoming SMTP commands. This attempts to
-finish off tidily.
-
-Argument: signal number (SIGALRM)
-Returns: nothing
-*/
-
-static void
-command_timeout_handler(int sig)
-{
-had_command_timeout = sig;
-}
-
-
-
-/*************************************************
-* SIGTERM received *
-*************************************************/
-
-/* Signal handler for handling SIGTERM. Again, try to finish tidily.
-
-Argument: signal number (SIGTERM)
-Returns: nothing
-*/
-
-static void
-command_sigterm_handler(int sig)
-{
-had_command_sigterm = sig;
-}
-
-
-
-
-#ifdef SUPPORT_PROXY
-/*************************************************
-* Restore socket timeout to previous value *
-*************************************************/
-/* If the previous value was successfully retrieved, restore
-it before returning control to the non-proxy routines
-
-Arguments: fd - File descriptor for input
- get_ok - Successfully retrieved previous values
- tvtmp - Time struct with previous values
- vslen - Length of time struct
-Returns: none
-*/
-static void
-restore_socket_timeout(int fd, int get_ok, struct timeval * tvtmp, socklen_t vslen)
-{
-if (get_ok == 0)
- (void) setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, CS tvtmp, vslen);
-}
-
-/*************************************************
-* Check if host is required proxy host *
-*************************************************/
-/* The function determines if inbound host will be a regular smtp host
-or if it is configured that it must use Proxy Protocol. A local
-connection cannot.
-
-Arguments: none
-Returns: bool
-*/
-
-static BOOL
-check_proxy_protocol_host()
-{
-int rc;
-
-if ( sender_host_address
- && (rc = verify_check_this_host(CUSS &hosts_proxy, NULL, NULL,
- sender_host_address, NULL)) == OK)
- {
- DEBUG(D_receive)
- debug_printf("Detected proxy protocol configured host\n");
- proxy_session = TRUE;
- }
-return proxy_session;