Manual Page Result
0
Command: setbuf | Section: 3 | Source: OpenBSD | File: setbuf.3
SETBUF(3) FreeBSD Library Functions Manual SETBUF(3)
NAME
setbuf, setbuffer, setlinebuf - stream buffering operations
SYNOPSIS
#include <stdio.h>
void
setbuf(FILE *stream, char *buf);
void
setbuffer(FILE *stream, char *buf, size_t size);
int
setlinebuf(FILE *stream);
DESCRIPTION
These interfaces are obsoleted by setvbuf(3).
The setbuf(), setbuffer(), and setlinebuf() functions are used to modify
the buffering of a stream. These functions are provided for
compatibility with legacy code. New code should use setvbuf(3) instead.
Except for the lack of a return value, the setbuf() function is exactly
equivalent to the call
setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
The setbuffer() function is the same, except that the size of the buffer
is up to the caller, rather than being determined by the default BUFSIZ.
The setlinebuf() function is exactly equivalent to the call:
setvbuf(stream, NULL, _IOLBF, 0);
RETURN VALUES
Upon successful completion, the setlinebuf() function returns 0. If the
request cannot be honored, a non-zero value is returned, possibly setting
errno to indicate the error. The stream is not modified in the error
case.
ERRORS
The setbuf(), setbuffer(), and setlinebuf() functions will fail if:
[EBADF] The stream specified is not associated with a valid
file descriptor.
SEE ALSO
fclose(3), fopen(3), fread(3), malloc(3), printf(3), puts(3), setvbuf(3)
STANDARDS
The setbuf() function conforms to ISO/IEC 9899:1999 ("ISO C99"). The
setbuffer() and setlinebuf() functions are non-standard and should not be
used if portability is required.
HISTORY
The setbuf() function first appeared in Version 7 AT&T UNIX. The
setbuffer() function first appeared in 4.1cBSD. The setlinebuf()
function first appeared in 4.2BSD.
BUGS
The setbuf() function usually uses a suboptimal buffer size and should be
avoided.
FreeBSD 14.1-RELEASE-p8 November 25, 2014 FreeBSD 14.1-RELEASE-p8