All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.
@(#)setbuf.3 6.7 (Berkeley) 03/05/91
#include <stdio.h> int setbuf(FILE *stream, char *buf); int setbuffer(FILE *stream, char *buf, size_t size); int setlinebuf(FILE *stream); int setvbuf(FILE *stream, char *buf, int mode, size_t size);
Setvbuf may be used at any time on any open stream to change its buffer. The mode parameter must be one of the following three macros:
8 _IONBF unbuffered
.ns
8 _IOLBF line buffered
.ns
8 _IOFBF fully buffered
Except for unbuffered files, the buf argument should point to a buffer at least size bytes long; this buffer will be used instead of the current buffer. If buf is NULL, only the mode is affected; a new buffer will be allocated on the next read or write operation. Setvbuf may be used at any time, but can only change the mode of a stream when it is not ``active'': that is, before any I/O, or immediately after a call to fflush .
The other three calls are, in effect, simply aliases for calls to setvbuf . Setbuf is exactly equivalent to the call setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ); Setbuffer is the same, except that the size of the buffer is up to the caller, rather than being determined by the manifest constant BUFSIZ . Setlinebuf is exactly equivalent to the call setvbuf(stream, (char *)NULL, _IOLBF, 0);