Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

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 and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcrtldll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycrtldll
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 Specifies 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 flushed 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 specifies the size of the buffer to
be used. The constant BUFSIZ in the stdio.h header file 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 first getc() or putc()
function on the file, 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.
527192-018 Hewlett-Packard Company 637