3 Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered, Blethal \- buffered input/output
13 Biobuf* Bopen(char *file, int mode)
16 Biobuf* Bfdopen(int fd, int mode)
19 int Binit(Biobuf *bp, int fd, int mode)
22 int Binits(Biobufhdr *bp, int fd, int mode, uchar *buf, int size)
25 int Bterm(Biobufhdr *bp)
28 int Bprint(Biobufhdr *bp, char *format, ...)
31 int Bvprint(Biobufhdr *bp, char *format, va_list arglist);
34 void* Brdline(Biobufhdr *bp, int delim)
37 char* Brdstr(Biobufhdr *bp, int delim, int nulldelim)
40 int Blinelen(Biobufhdr *bp)
43 vlong Boffset(Biobufhdr *bp)
46 int Bfildes(Biobufhdr *bp)
49 int Bgetc(Biobufhdr *bp)
52 long Bgetrune(Biobufhdr *bp)
55 int Bgetd(Biobufhdr *bp, double *d)
58 int Bungetc(Biobufhdr *bp)
61 int Bungetrune(Biobufhdr *bp)
64 vlong Bseek(Biobufhdr *bp, vlong n, int type)
67 int Bputc(Biobufhdr *bp, int c)
70 int Bputrune(Biobufhdr *bp, long c)
73 long Bread(Biobufhdr *bp, void *addr, long nbytes)
76 long Bwrite(Biobufhdr *bp, void *addr, long nbytes)
79 int Bflush(Biobufhdr *bp)
82 int Bbuffered(Biobufhdr *bp)
85 void Blethal(Biobufhdr *bp, void (*errorf)(char *))
88 These routines implement fast buffered I/O.
89 I/O on different file descriptors is independent.
100 to allocate a buffer.
103 allocates a buffer for the already-open file descriptor
111 to allocate a buffer.
114 initializes a standard size buffer, type
116 with the open file descriptor passed in
119 initializes a non-standard size buffer, type
121 with the open file descriptor,
122 buffer area, and buffer size passed in
127 are related by the declaration:
130 typedef struct Biobuf Biobuf;
134 uchar b[Bungetsize+Bsize];
139 of types pointer to Biobuf and pointer to Biobufhdr
140 can be used interchangeably in the following routines.
146 should be called before any of the
147 other routines on that buffer.
149 returns the integer file descriptor of the associated open file.
152 flushes the buffer for
157 If the buffer was allocated by
161 and the file is closed.
164 reads a string from the file associated with
166 up to and including the first
169 The delimiter character at the end of the line is
170 not altered, thus the returned string probably won't be NUL-terminated.
172 returns a pointer to the start of the line or
174 on end-of-file or read error.
176 returns the length (including the delimiter)
177 of the most recent string returned by
182 .IR malloc (2)-allocated
183 buffer containing the next line of input delimited by
185 terminated by a NUL (0) byte.
188 which returns when its buffer is full even if no delimiter has been found,
190 will return an arbitrarily long line in a single call.
193 is set, the terminal delimiter will be overwritten with a NUL.
194 After a successful call to
198 will be the length of the returned buffer, excluding the NUL.
201 returns the next character from
206 may be called immediately after
208 to allow the same character to be reread.
213 to read the bytes of the next
215 sequence in the input stream and returns the value of the rune
216 represented by the sequence.
217 It returns a negative value
220 may be called immediately after
224 sequence to be reread as either bytes or a rune.
228 may back up a maximum of five bytes.
237 to read the formatted
238 floating-point number in the input stream,
239 skipping initial blanks and tabs.
240 The value is stored in
248 into memory starting at
250 The number of bytes read is returned on success
251 and a negative value is returned if a read error occurred.
258 It returns the new file offset.
260 returns the file offset of the next character to be processed.
263 outputs the low order 8 bits of
269 to occur and there is an error,
270 a negative value is returned.
271 Otherwise, a zero is returned.
276 to output the low order
283 on the output stream.
286 is a buffered interface to
290 to occur and there is an error,
296 returns the number of bytes written.
298 does the same except it takes as argument a
300 parameter, so it can be called within a variadic function.
311 to occur and there is an error,
312 a negative value is returned.
313 Otherwise, the number of bytes written is returned.
316 causes any buffered output associated with
323 exit for every buffer still open
327 returns the number of bytes in the buffer.
328 When reading, this is the number of bytes still available from the last
329 read on the file; when writing, it is the number of bytes ready to be
335 to be called in case of an error happening on read/write.
338 will have the program terminated in case of error.
348 routines that return integers yield
352 is not the descriptor of an open file.
354 returns zero if the file cannot be opened in the given mode.
359 An error during read or write will call an error handler specified by
364 returns an error on strings longer than the buffer associated
366 and also if the end-of-file is encountered
369 will tell how many characters are available
371 In the case of a true end-of-file,
374 At the cost of allocating a buffer,
376 sidesteps these issues.
383 cannot be an arbitrary rune.
387 may be overwritten by calls to any other