3 Bopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered \- buffered input/output
13 Biobuf* Bopen(char *file, int mode)
16 int Binit(Biobuf *bp, int fd, int mode)
19 int Binits(Biobufhdr *bp, int fd, int mode, uchar *buf, int size)
22 int Bterm(Biobufhdr *bp)
25 int Bprint(Biobufhdr *bp, char *format, ...)
28 int Bvprint(Biobufhdr *bp, char *format, va_list arglist);
31 void* Brdline(Biobufhdr *bp, int delim)
34 char* Brdstr(Biobufhdr *bp, int delim, int nulldelim)
37 int Blinelen(Biobufhdr *bp)
40 vlong Boffset(Biobufhdr *bp)
43 int Bfildes(Biobufhdr *bp)
46 int Bgetc(Biobufhdr *bp)
49 long Bgetrune(Biobufhdr *bp)
52 int Bgetd(Biobufhdr *bp, double *d)
55 int Bungetc(Biobufhdr *bp)
58 int Bungetrune(Biobufhdr *bp)
61 vlong Bseek(Biobufhdr *bp, vlong n, int type)
64 int Bputc(Biobufhdr *bp, int c)
67 int Bputrune(Biobufhdr *bp, long c)
70 long Bread(Biobufhdr *bp, void *addr, long nbytes)
73 long Bwrite(Biobufhdr *bp, void *addr, long nbytes)
76 int Bflush(Biobufhdr *bp)
79 int Bbuffered(Biobufhdr *bp)
82 These routines implement fast buffered I/O.
83 I/O on different file descriptors is independent.
97 initializes a standard size buffer, type
99 with the open file descriptor passed in
102 initializes a non-standard size buffer, type
104 with the open file descriptor,
105 buffer area, and buffer size passed in
110 are related by the declaration:
113 typedef struct Biobuf Biobuf;
117 uchar b[Bungetsize+Bsize];
122 of types pointer to Biobuf and pointer to Biobufhdr
123 can be used interchangeably in the following routines.
129 should be called before any of the
130 other routines on that buffer.
132 returns the integer file descriptor of the associated open file.
135 flushes the buffer for
137 If the buffer was allocated by
141 and the file is closed.
144 reads a string from the file associated with
146 up to and including the first
149 The delimiter character at the end of the line is
152 returns a pointer to the start of the line or
154 on end-of-file or read error.
156 returns the length (including the delimiter)
157 of the most recent string returned by
162 .IR malloc (3)-allocated
163 buffer containing the next line of input delimited by
165 terminated by a NUL (0) byte.
168 which returns when its buffer is full even if no delimiter has been found,
170 will return an arbitrarily long line in a single call.
173 is set, the terminal delimiter will be overwritten with a NUL.
174 After a successful call to
178 will be the length of the returned buffer, excluding the NUL.
181 returns the next character from
186 may be called immediately after
188 to allow the same character to be reread.
193 to read the bytes of the next
195 sequence in the input stream and returns the value of the rune
196 represented by the sequence.
197 It returns a negative value
200 may be called immediately after
204 sequence to be reread as either bytes or a rune.
208 may back up a maximum of five bytes.
217 to read the formatted
218 floating-point number in the input stream,
219 skipping initial blanks and tabs.
220 The value is stored in
228 into memory starting at
230 The number of bytes read is returned on success
231 and a negative value is returned if a read error occurred.
238 It returns the new file offset.
240 returns the file offset of the next character to be processed.
243 outputs the low order 8 bits of
249 to occur and there is an error,
250 a negative value is returned.
251 Otherwise, a zero is returned.
256 to output the low order
263 on the output stream.
266 is a buffered interface to
270 to occur and there is an error,
274 Otherwise, the number of bytes output is returned.
276 does the same except it takes as argument a
278 parameter, so it can be called within a variadic function.
289 to occur and there is an error,
290 a negative value is returned.
291 Otherwise, the number of bytes written is returned.
294 causes any buffered output associated with
301 exit for every buffer still open
305 returns the number of bytes in the buffer.
306 When reading, this is the number of bytes still available from the last
307 read on the file; when writing, it is the number of bytes ready to be
310 .B /usr/local/plan9/src/libbio
318 routines that return integers yield
322 is not the descriptor of an open file.
324 returns zero if the file cannot be opened in the given mode.
330 returns an error on strings longer than the buffer associated
332 and also if the end-of-file is encountered
335 will tell how many characters are available
337 In the case of a true end-of-file,
340 At the cost of allocating a buffer,
342 sidesteps these issues.
346 may be overwritten by calls to any other