1SETVBUF(3P)                POSIX Programmer's Manual               SETVBUF(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       setvbuf — assign buffering to a stream
13

SYNOPSIS

15       #include <stdio.h>
16
17       int setvbuf(FILE *restrict stream, char *restrict buf, int type,
18           size_t size);
19

DESCRIPTION

21       The functionality described on this reference page is aligned with  the
22       ISO C  standard.  Any  conflict between the requirements described here
23       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
24       defers to the ISO C standard.
25
26       The  setvbuf()  function  may  be  used  after the stream pointed to by
27       stream is associated with an open file but before any  other  operation
28       (other  than  an  unsuccessful  call  to setvbuf()) is performed on the
29       stream. The argument type determines how stream shall be  buffered,  as
30       follows:
31
32        *  {_IOFBF} shall cause input/output to be fully buffered.
33
34        *  {_IOLBF} shall cause input/output to be line buffered.
35
36        *  {_IONBF} shall cause input/output to be unbuffered.
37
38       If  buf  is  not  a  null  pointer,  the array it points to may be used
39       instead of a buffer allocated by setvbuf() and the argument size speci‐
40       fies the size of the array; otherwise, size may determine the size of a
41       buffer allocated by the setvbuf() function. The contents of  the  array
42       at any time are unspecified.
43
44       For information about streams, see Section 2.5, Standard I/O Streams.
45

RETURN VALUE

47       Upon  successful  completion,  setvbuf()  shall return 0. Otherwise, it
48       shall return a non-zero value if an invalid value is given for type  or
49       if  the  request  cannot  be honored, and may set errno to indicate the
50       error.
51

ERRORS

53       The setvbuf() function may fail if:
54
55       EBADF  The file descriptor underlying stream is not valid.
56
57       The following sections are informative.
58

EXAMPLES

60       None.
61

APPLICATION USAGE

63       A common source of error is allocating buffer space as an ``automatic''
64       variable  in  a code block, and then failing to close the stream in the
65       same block.
66
67       With setvbuf(), allocating a buffer of size bytes does not  necessarily
68       imply that all of size bytes are used for the buffer area.
69
70       Applications  should  note  that many implementations only provide line
71       buffering on input from terminal devices.
72

RATIONALE

74       None.
75

FUTURE DIRECTIONS

77       None.
78

SEE ALSO

80       Section 2.5, Standard I/O Streams, fopen(), setbuf()
81
82       The Base Definitions volume of POSIX.1‐2017, <stdio.h>
83
85       Portions of this text are reprinted and reproduced in  electronic  form
86       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
87       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
88       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
89       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
90       event of any discrepancy between this version and the original IEEE and
91       The Open Group Standard, the original IEEE and The Open Group  Standard
92       is  the  referee document. The original Standard can be obtained online
93       at http://www.opengroup.org/unix/online.html .
94
95       Any typographical or formatting errors that appear  in  this  page  are
96       most likely to have been introduced during the conversion of the source
97       files to man page format. To report such errors,  see  https://www.ker
98       nel.org/doc/man-pages/reporting_bugs.html .
99
100
101
102IEEE/The Open Group                  2017                          SETVBUF(3P)
Impressum