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_IO_SETVBUF -- set the buffering type for a file 1N/A** Set one of the different kinds of buffering, optionally including 1N/A** If 'size' is == 0 then an "optimal" size will be selected. 1N/A** If 'buf' is == NULL then space will be allocated at 'size'. 1N/A** fp -- the file that buffering is to be changed for 1N/A** timeout -- time allowed for completing the function 1N/A** buf -- buffer to use 1N/A** mode -- buffering method to use 1N/A** size -- size of 'buf' 1N/A** Failure: SM_IO_EOF 1N/A ** Verify arguments. The `int' limit on `size' is due to this 1N/A ** particular implementation. Note, buf and size are ignored 1N/A ** when setting SM_IO_NBF. 1N/A ** Write current buffer, if any. Discard unread input (including 1N/A ** ungetc data), cancel line buffering, and free old buffer if 1N/A ** malloc()ed. We also clear any eof condition, as if this were 1N/A /* If setting unbuffered mode, skip all the hard work. */ 1N/A ** Find optimal I/O size for seek optimization. This also returns 1N/A ** a `tty flag' to suggest that we check isatty(fd), but we do not 1N/A ** care since our caller told us how to buffer. 1N/A /* Allocate buffer if needed. */ 1N/A ** Unable to honor user's request. We will return 1N/A ** failure, but try again with file system size. 1N/A /* No luck; switch to unbuffered I/O. */ 1N/A ** Kill any seek optimization if the buffer is not the 1N/A ** SHOULD WE ALLOW MULTIPLES HERE (i.e., ok iff (size % iosize) == 0)? 1N/A ** Fix up the SM_FILE_T fields, and set sm_cleanup for output flush on 1N/A ** exit (since we are buffered in some way). 1N/A /* fp->f_lbfsize is still 0 */ 1N/A ** Begin or continue writing: see sm_wsetup(). Note 1N/A ** that SMNBF is impossible (it was handled earlier).