xref: /386bsd/usr/share/man/cat3/setbuffer.0 (revision a2142627)
1SETBUF(3)                 386BSD Programmer's Manual                 SETBUF(3)
2
3NNAAMMEE
4     sseettbbuuff, sseettbbuuffffeerr, sseettlliinneebbuuff, sseettvvbbuuff - stream buffering operations
5
6SSYYNNOOPPSSIISS
7     ##iinncclluuddee <<ssttddiioo..hh>>
8
9     _i_n_t
10     sseettbbuuff(_F_I_L_E *_s_t_r_e_a_m, _c_h_a_r *_b_u_f)
11
12     _i_n_t
13     sseettbbuuffffeerr(_F_I_L_E *_s_t_r_e_a_m, _c_h_a_r *_b_u_f, _s_i_z_e__t _s_i_z_e)
14
15     _i_n_t
16     sseettlliinneebbuuff(_F_I_L_E *_s_t_r_e_a_m)
17
18     _i_n_t
19     sseettvvbbuuff(_F_I_L_E *_s_t_r_e_a_m, _c_h_a_r *_b_u_f, _i_n_t _m_o_d_e, _s_i_z_e__t _s_i_z_e)
20
21DDEESSCCRRIIPPTTIIOONN
22     The three types of buffering available are unbuffered, block buffered,
23     and line buffered.  When an output stream is unbuffered, information
24     appears on the destination file or terminal as soon as written; when it
25     is block buffered many characters are saved up and written as a block;
26     when it is line buffered characters are saved up until a newline is
27     output or input is read from any stream attached to a terminal device
28     (typically stdin).  The function fflush(3) may be used to force the block
29     out early.  (See fclose(3).)  Normally all files are block buffered.
30     When the first I/O operation occurs on a file, malloc(3) is called, and a
31     buffer is obtained.  If a stream refers to a terminal (as _s_t_d_o_u_t normally
32     does) it is line buffered.  The standard error stream _s_t_d_e_r_r is always
33     unbuffered.
34
35     The sseettvvbbuuff() function may be used at any time on any open stream to
36     change its buffer.  The _m_o_d_e parameter must be one of the following three
37     macros:
38
39           _IONBF  unbuffered
40
41           _IOLBF  line buffered
42
43           _IOFBF  fully buffered
44
45     Except for unbuffered files, the _b_u_f argument should point to a buffer at
46     least _s_i_z_e bytes long; this buffer will be used instead of the current
47     buffer.  If the argument _b_u_f is NULL, only the mode is affected; a new
48     buffer will be allocated on the next read or write operation.  The
49     sseettvvbbuuff() function may be used at any time, but can only change the mode
50     of a stream when it is not ``active'': that is, before any I/O, or
51     immediately after a call to fflush.
52
53     The other three calls are, in effect, simply aliases for calls to
54     sseettvvbbuuff().  The sseettbbuuff() function is exactly equivalent to the call
55
56           setvbuf(stream, buf, buf ? _IOFBF: _IONBF, BUFSIZ);
57
58     The sseettbbuuffffeerr() function is the same, except that the size of the buffer
59     is up to the caller, rather than being determined by the default BUFSIZ.
60     The sseettlliinneebbuuff() function is exactly equivalent to the call:
61
62           setvbuf(stream, (char *)NULL, _IOLBF, 0);
63
64SSEEEE AALLSSOO
65     fopen(3),  fclose(3),  fread(3),  malloc(3),  puts(3),  printf(3)
66
67SSTTAANNDDAARRDDSS
68     The sseettbbuuff() and sseettvvbbuuff() functions conform to ANSI C3.159-1989 (``ANSI
69     C'').
70
71BBUUGGSS
72     The sseettbbuuffffeerr() and sseettlliinneebbuuff() functions are not portable to versions
73     of BSD UNIX before 4.2BSD. On 4.2BSD and 4.3BSD systems, sseettbbuuff() always
74     uses a suboptimal buffer size and should be avoided.
75
764th Berkeley Distribution        June 29, 1991                               2
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133