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 void Biofn(Biobufhdr *bp, int (*iof)(Biobufhdr *, void *, long))
91 These routines implement fast buffered I/O.
92 I/O on different file descriptors is independent.
103 to allocate a buffer.
106 allocates a buffer for the already-open file descriptor
114 to allocate a buffer.
117 initializes a standard size buffer, type
119 with the open file descriptor passed in
122 initializes a non-standard size buffer, type
124 with the open file descriptor,
125 buffer area, and buffer size passed in
130 are related by the declaration:
133 typedef struct Biobuf Biobuf;
137 uchar b[Bungetsize+Bsize];
142 of types pointer to Biobuf and pointer to Biobufhdr
143 can be used interchangeably in the following routines.
149 should be called before any of the
150 other routines on that buffer.
152 returns the integer file descriptor of the associated open file.
155 flushes the buffer for
160 If the buffer was allocated by
166 and the file is closed.
169 reads a string from the file associated with
171 up to and including the first
174 The delimiter character at the end of the line is
175 not altered, thus the returned string probably won't be NUL-terminated.
177 returns a pointer to the start of the line or
179 on end-of-file or read error.
181 returns the length (including the delimiter)
182 of the most recent string returned by
187 .IR malloc (2)-allocated
188 buffer containing the next line of input delimited by
190 terminated by a NUL (0) byte.
193 which returns when its buffer is full even if no delimiter has been found,
195 will return an arbitrarily long line in a single call.
198 is set, the terminal delimiter will be overwritten with a NUL.
199 After a successful call to
203 will be the length of the returned buffer, excluding the NUL.
206 returns the next character from
211 may be called immediately after
213 to allow the same character to be reread.
218 to read the bytes of the next
220 sequence in the input stream and returns the value of the rune
221 represented by the sequence.
222 It returns a negative value
225 may be called immediately after
229 sequence to be reread as either bytes or a rune.
233 may back up a maximum of five bytes.
242 to read the formatted
243 floating-point number in the input stream,
244 skipping initial blanks and tabs.
245 The value is stored in
253 into memory starting at
255 The number of bytes read is returned on success
256 and a negative value is returned if a read error occurred.
263 It returns the new file offset.
265 returns the file offset of the next character to be processed.
268 outputs the low order 8 bits of
274 to occur and there is an error,
275 a negative value is returned.
276 Otherwise, a zero is returned.
281 to output the low order
288 on the output stream.
291 is a buffered interface to
295 to occur and there is an error,
301 returns the number of bytes written.
303 does the same except it takes as argument a
305 parameter, so it can be called within a variadic function.
316 to occur and there is an error,
317 a negative value is returned.
318 Otherwise, the number of bytes written is returned.
321 causes any buffered output associated with
328 exit for every buffer still open
332 returns the number of bytes in the buffer.
333 When reading, this is the number of bytes still available from the last
334 read on the file; when writing, it is the number of bytes ready to be
340 to be called in case of an error happening on read/write.
343 will have the program terminated in case of error.
347 is called with a non-nil
349 function, then that function is called for I/O in lieu of
355 restores normal behaviour.
366 routines that return integers yield
370 is not the descriptor of an open file.
372 returns zero if the file cannot be opened in the given mode.
377 An error during read or write will call an error handler specified by
382 returns an error on strings longer than the buffer associated
384 and also if the end-of-file is encountered
387 will tell how many characters are available
389 In the case of a true end-of-file,
392 At the cost of allocating a buffer,
394 sidesteps these issues.
401 cannot be an arbitrary rune.
405 may be overwritten by calls to any other