/*++ /* NAME /* smtp_stream 3 /* SUMMARY /* smtp stream I/O support /* SYNOPSIS /* #include <smtp_stream.h> /* /* void smtp_stream_setup(stream, timeout, enable_deadline, /* min_data_rate) /* VSTREAM *stream; /* int timeout; /* int enable_deadline; /* int min_data_rate; /* /* void smtp_printf(stream, format, ...) /* VSTREAM *stream; /* const char *format; /* /* void smtp_flush(stream) /* VSTREAM *stream; /* /* int smtp_fgetc(stream) /* VSTREAM *stream; /* /* int smtp_get(vp, stream, maxlen, flags) /* VSTRING *vp; /* VSTREAM *stream; /* ssize_t maxlen; /* int flags; /* /* void smtp_fputs(str, len, stream) /* const char *str; /* ssize_t len; /* VSTREAM *stream; /* /* void smtp_fwrite(str, len, stream) /* const char *str; /* ssize_t len; /* VSTREAM *stream; /* /* void smtp_fread_buf(vp, len, stream) /* VSTRING *vp; /* ssize_t len; /* VSTREAM *stream; /* /* void smtp_fputc(ch, stream) /* int ch; /* VSTREAM *stream; /* /* void smtp_vprintf(stream, format, ap) /* VSTREAM *stream; /* char *format; /* va_list ap; /* /* int smtp_detect_bare_lf; /* int smtp_got_bare_lf; /* AUXILIARY API /* int smtp_get_noexcept(vp, stream, maxlen, flags) /* VSTRING *vp; /* VSTREAM *stream; /* ssize_t maxlen; /* int flags; /* LEGACY API /* void smtp_timeout_setup(stream, timeout) /* VSTREAM *stream; /* int timeout; /* DESCRIPTION /* This module reads and writes text records delimited by CR LF, /* with error detection: timeouts or unexpected end-of-file. /* A trailing CR LF is added upon writing and removed upon reading. /* /* smtp_stream_setup() prepares the specified stream for SMTP read /* and write operations described below. /* This routine alters the behavior of streams as follows: /* .IP \(bu /* When enable_deadline is non-zero, then the timeout argument /* specifies a deadline for the total amount time that may be /* spent in all subsequent read/write operations. /* Otherwise, the stream is configured to enforce /* a time limit for each individual read/write system call. /* .IP \f(bu /* Additionally, when min_data_rate is > 0, the deadline is /* incremented by 1/min_data_rate seconds for every min_data_rate /* bytes transferred. However, the deadline will never exceed /* the value specified with the timeout argument. /* .IP \f(bu /* The stream is configured to use double buffering. /* .IP \f(bu /* The stream is configured to enable exception handling. /* .PP /* smtp_printf() formats its arguments and writes the result to /* the named stream, followed by a CR LF pair. The stream is NOT flushed. /* Long lines of text are not broken. /* /* smtp_flush() flushes the named stream. /* /* smtp_fgetc() reads one character from the named stream. /* /* smtp_get() reads the named stream up to and including /* the next LF character and strips the trailing CR LF. The /* \fImaxlen\fR argument limits the length of a line of text, /* and protects the program against running out of memory. /* Specify a zero bound to turn off bounds checking. /* The result is the last character read, or VSTREAM_EOF. /* The \fIflags\fR argument is zero or more of: /* .RS /* .IP SMTP_GET_FLAG_SKIP /* Skip over input in excess of \fImaxlen\fR). Either way, a result /* value of '\n' means that the input did not exceed \fImaxlen\fR. /* .IP SMTP_GET_FLAG_APPEND /* Append content to the buffer instead of overwriting it. /* .RE /* Specify SMTP_GET_FLAG_NONE for no special processing. /* /* smtp_fputs() writes its string argument to the named stream. /* Long strings are not broken. Each string is followed by a /* CR LF pair. The stream is not flushed. /* /* smtp_fwrite() writes its string argument to the named stream. /* Long strings are not broken. No CR LF is appended. The stream /* is not flushed. /* /* smtp_fread_buf() invokes vstream_fread_buf() to read the /* specified number of unformatted bytes from the stream. The /* result is not null-terminated. NOTE: do not skip calling /* smtp_fread_buf() when len == 0. This function has side /* effects including resetting the buffer write position, and /* skipping the call would invalidate the buffer state. /* /* smtp_fputc() writes one character to the named stream. /* The stream is not flushed. /* /* smtp_vprintf() is the machine underneath smtp_printf(). /* /* smtp_get_noexcept() implements the subset of smtp_get() /* without timeouts and without making long jumps. Instead, /* query the stream status with vstream_feof() etc. /* /* This function assigns smtp_got_bare_lf = smtp_detect_bare_lf, /* if smtp_detect_bare_lf is non-zero and the last read line /* was terminated with a bare newline. Otherwise, this function /* sets smtp_got_bare_lf to zero. /* /* smtp_timeout_setup() is a backwards-compatibility interface /* for programs that don't require deadline or data-rate support. /* DIAGNOSTICS /* .fi /* .ad /* In case of error, a vstream_longjmp() call is performed to the /* context specified with vstream_setjmp(). /* After write error, further writes to the socket are disabled. /* This eliminates the need for clumsy code to avoid unwanted /* I/O while shutting down a TLS engine or closing a VSTREAM. /* Error codes passed along with vstream_longjmp() are: /* .IP SMTP_ERR_EOF /* An I/O error happened, or the peer has disconnected unexpectedly. /* .IP SMTP_ERR_TIME /* The time limit specified to smtp_stream_setup() was exceeded. /* .PP /* Additional error codes that may be used by applications: /* .IP SMTP_ERR_QUIET /* Perform silent cleanup; the error was already reported by /* the application. /* This error is never generated by the smtp_stream(3) module, but /* is defined for application-specific use. /* .IP SMTP_ERR_DATA /* Application data error - the program cannot proceed with this /* SMTP session. /* .IP SMTP_ERR_NONE /* A non-error code that makes setjmp()/longjmp() convenient /* to use. /* BUGS /* The timeout deadline affects all I/O on the named stream, not /* just the I/O done on behalf of this module. /* /* The timeout deadline overwrites any previously set up state on /* the named stream. /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /* /* Wietse Venema /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA
/*--*/
/* *Important:thetimelimitfeaturemustnotintroduceanysystemcalls *whentheinputisalreadyinthebuffer,orwhentheoutputstillfitsin *thebuffer.Suchsystemcallswouldreallyhurtwhenreceivingorsending *bodycontentonelineatatime.
*/ int smtp_detect_bare_lf; int smtp_got_bare_lf;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.