/*
* Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*/
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include "local.h"
/*
** SM_IO_SETVBUF -- set the buffering type for a file
**
** Set one of the different kinds of buffering, optionally including
** a buffer.
** If 'size' is == 0 then an "optimal" size will be selected.
** If 'buf' is == NULL then space will be allocated at 'size'.
**
** Parameters:
** fp -- the file that buffering is to be changed for
** timeout -- time allowed for completing the function
** buf -- buffer to use
** mode -- buffering method to use
** size -- size of 'buf'
**
** Returns:
** Failure: SM_IO_EOF
** Success: 0 (zero)
*/
int
int timeout;
char *buf;
int mode;
{
int ttyflag;
int fd;
/*
** Verify arguments. The `int' limit on `size' is due to this
** particular implementation. Note, buf and size are ignored
** when setting SM_IO_NBF.
*/
return SM_IO_EOF;
/*
** Write current buffer, if any. Discard unread input (including
** ungetc data), cancel line buffering, and free old buffer if
** malloc()ed. We also clear any eof condition, as if this were
** a seek.
*/
ret = 0;
{
}
SMFBF);
/* If setting unbuffered mode, skip all the hard work. */
goto nbf;
/*
** Find optimal I/O size for seek optimization. This also returns
** a `tty flag' to suggest that we check isatty(fd), but we do not
** care since our caller told us how to buffer.
*/
if (size == 0)
{
}
/* Allocate buffer if needed. */
{
{
/*
** Unable to honor user's request. We will return
** failure, but try again with file system size.
*/
{
}
}
{
/* No luck; switch to unbuffered I/O. */
nbf:
return ret;
}
}
/*
** Kill any seek optimization if the buffer is not the
** right size.
**
** SHOULD WE ALLOW MULTIPLES HERE (i.e., ok iff (size % iosize) == 0)?
*/
/*
** Fix up the SM_FILE_T fields, and set sm_cleanup for output flush on
** exit (since we are buffered in some way).
*/
/* fp->f_lbfsize is still 0 */
{
/*
** Begin or continue writing: see sm_wsetup(). Note
** that SMNBF is impossible (it was handled earlier).
*/
{
}
else
}
else
{
}
return ret;
}