1N/A * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. 1N/A * All rights reserved. 1N/A * Copyright (c) 1990, 1993 1N/A * The Regents of the University of California. All rights reserved. 1N/A * This code is derived from software contributed to Berkeley by 1N/A * By using this file, you agree to the terms and conditions set 1N/A * forth in the LICENSE file which can be found at the top level of 1N/A * the sendmail distribution. 1N/A#
pragma ident "%Z%%M% %I% %E% SMI" 1N/A** SM_FVWRITE -- write memory regions and buffer for file pointer 1N/A** fp -- the file pointer to write to 1N/A** timeout -- time length for function to return by 1N/A** uio -- the memory regions to write 1N/A** Failure: returns SM_IO_EOF and sets errno 1N/A** Success: returns 0 (zero) 1N/A** This routine is large and unsightly, but most of the ugliness due 1N/A** to the different kinds of output buffering handled here. 1N/A /* make sure we can write */ 1N/A /* Unbuffered: write up to BUFSIZ bytes at a time. */ 1N/A errno = 0;
/* needed to ensure EOF correctly found */ 1N/A break;
/* EOF found */ 1N/A /* write would block */ 1N/A ** Not SMLBF (line-buffered). Either SMFBF or SMNOW 1N/A ** buffered: fill partially full buffer, if any, 1N/A ** and then flush. If there is no partial buffer, write 1N/A ** one bf._size byte chunk directly (without copying). 1N/A ** String output is a special case: write as many bytes 1N/A ** as fit, but pretend we wrote everything. This makes 1N/A ** snprintf() return the number of bytes needed, rather 1N/A ** than the number used, and avoids its write function 1N/A ** (so that the write function can be invalid). 1N/A /* Allocate space exponentially. */ 1N/A errno = 0;
/* needed to ensure EOF correctly found */ 1N/A COPY(w);
/* copy SM_MIN(fp->f_w,len), */ 1N/A w =
len;
/* but pretend copied all */ 1N/A /* fill and flush */ 1N/A /* write directly */ 1N/A break;
/* EOF found */ 1N/A /* write would block */ 1N/A ** Line buffered: like fully buffered, but we 1N/A ** must check for newlines. Compute the distance 1N/A ** to the first newline (including the newline), 1N/A ** or `infinity' if there is none, then pretend 1N/A ** that the amount to write is SM_MIN(len,nldist). 1N/A errno = 0;
/* needed to ensure EOF correctly found */ 1N/A break;
/* EOF found */ 1N/A /* write would block */ 1N/A /* copied the newline: flush and forget */ 1N/A /* errno set before goto places us here */