2 * Copyright (c) 1990 The Regents of the University of California.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 Modified copy of setbuf.c to support the setbuffer function
20 defined as part of BSD.
21 Modifications by Gareth Pearce, 2001.
26 <<setbuffer>>---specify full buffering for a file or stream with size
33 void setbuffer(FILE *<[fp]>, char *<[buf]>, int <[size]>);
37 void setbuffer(<[fp]>, <[buf]>, <[size]>)
43 <<setbuffer>> specifies that output to the file or stream identified by
44 <[fp]> should be fully buffered. All output for this file will go to a
45 buffer (of size <[size]>). Output will be passed on to the host system
46 only when the buffer is full, or when an input operation intervenes.
48 You may, if you wish, supply your own buffer by passing a pointer to
49 it as the argument <[buf]>. It must have size <[size]>. You can
50 also use <<NULL>> as the value of <[buf]>, to signal that the
51 <<setbuffer>> function is to allocate the buffer.
54 You may only use <<setbuffer>> before performing any file operation
55 other than opening the file.
57 If you supply a non-null <[buf]>, you must ensure that the associated
58 storage continues to be available until you close the stream
62 <<setbuffer>> does not return a result.
65 This function comes from BSD not ANSI or POSIX.
67 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
68 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
73 <<setlinebuf>>---specify line buffering for a file or stream
80 void setlinebuf(FILE *<[fp]>);
84 void setlinebuf(<[fp]>)
88 <<setlinebuf>> specifies that output to the file or stream identified by
89 <[fp]> should be line buffered. This causes the file or stream to pass
90 on output to the host system at every newline, as well as when the
91 buffer is full, or when an input operation intervenes.
94 You may only use <<setlinebuf>> before performing any file operation
95 other than opening the file.
98 <<setlinebuf>> returns as per setvbuf.
101 This function comes from BSD not ANSI or POSIX.
103 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
104 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
112 _DEFUN (setbuffer
, (fp
, buf
, size
),
117 (void) setvbuf (fp
, buf
, buf
? _IOFBF
: _IONBF
, (size_t) size
);