1SETBUF(3P) POSIX Programmer's Manual SETBUF(3P)
2
3
4
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
12 setbuf — assign buffering to a stream
13
15 #include <stdio.h>
16
17 void setbuf(FILE *restrict stream, char *restrict buf);
18
20 The functionality described on this reference page is aligned with the
21 ISO C standard. Any conflict between the requirements described here
22 and the ISO C standard is unintentional. This volume of POSIX.1‐2017
23 defers to the ISO C standard.
24
25 Except that it returns no value, the function call:
26
27
28 setbuf(stream, buf)
29
30 shall be equivalent to:
31
32
33 setvbuf(stream, buf, _IOFBF, BUFSIZ)
34
35 if buf is not a null pointer, or to:
36
37
38 setvbuf(stream, buf, _IONBF, BUFSIZ)
39
40 if buf is a null pointer.
41
43 The setbuf() function shall not return a value.
44
46 Although the setvbuf() interface may set errno in defined ways, the
47 value of errno after a call to setbuf() is unspecified.
48
49 The following sections are informative.
50
52 None.
53
55 A common source of error is allocating buffer space as an ``automatic''
56 variable in a code block, and then failing to close the stream in the
57 same block.
58
59 With setbuf(), allocating a buffer of BUFSIZ bytes does not necessarily
60 imply that all of BUFSIZ bytes are used for the buffer area.
61
62 Since errno is not required to be unchanged on success, in order to
63 correctly detect and possibly recover from errors, applications should
64 use setvbuf() instead of setbuf().
65
67 None.
68
70 None.
71
73 Section 2.5, Standard I/O Streams, fopen(), setvbuf()
74
75 The Base Definitions volume of POSIX.1‐2017, <stdio.h>
76
78 Portions of this text are reprinted and reproduced in electronic form
79 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
80 table Operating System Interface (POSIX), The Open Group Base Specifi‐
81 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
82 Electrical and Electronics Engineers, Inc and The Open Group. In the
83 event of any discrepancy between this version and the original IEEE and
84 The Open Group Standard, the original IEEE and The Open Group Standard
85 is the referee document. The original Standard can be obtained online
86 at http://www.opengroup.org/unix/online.html .
87
88 Any typographical or formatting errors that appear in this page are
89 most likely to have been introduced during the conversion of the source
90 files to man page format. To report such errors, see https://www.ker‐
91 nel.org/doc/man-pages/reporting_bugs.html .
92
93
94
95IEEE/The Open Group 2017 SETBUF(3P)