Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)

Guardian Native C Library Calls (s) setvbuf(3)
NAME
setvbuf - Assigns buffering to a stream
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <stdio.h>
int setvbuf(
FILE *stream,
char *buffer,
int mode,
size_t size);
PARAMETERS
stream Species the input/output stream.
buffer Points to a character array.
mode Determines how the stream parameter is buffered.
size Species the size of the buffer to be used.
DESCRIPTION
The setvbuf( ) function causes the character array pointed to by the buffer parameter to be used
instead of an automatically allocated buffer. Use the setvbuf() function after a stream has been
opened, but before it is read or written.
The mode parameter determines how the stream parameter is buffered:
_IOFBF Causes input/output to be fully buffered.
_IOLBF Causes output to be line buffered. The buffer is ushed when a new line is writ-
ten, the buffer is full, or input is requested.
_IONBF Causes input/output to be completely unbuffered.
If the buffer parameter is not a null-character pointer, the array it points to is used for buffering
instead of an automatically allocated buffer. The size parameter species the size of the buffer to
be used. The constant BUFSIZ in the stdio.h header le is one buffer size. If input/output is
unbuffered, the buffer and size parameters are ignored.
A buffer is normally obtained from the malloc() function at the time of the rst getc() or putc()
function on the le, except that the standard error stream, stderr, is normally not buffered.
Output streams directed to terminals are always either line buffered or unbuffered.
NOTES
A common source of error is allocating buffer space as an automatic variable in a code block,
and then failing to close the stream in the same block.
ERRORS
If the following condition occurs, the setvbuf() function sets errno to the corresponding value.
[EBADF] The le descriptor that underlies stream is invalid.
527192-005 Hewlett-Packard Company 621