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
163 and the file is closed.
166 reads a string from the file associated with
168 up to and including the first
171 The delimiter character at the end of the line is
172 not altered, thus the returned string probably won't be NUL-terminated.
174 returns a pointer to the start of the line or
176 on end-of-file or read error.
178 returns the length (including the delimiter)
179 of the most recent string returned by
184 .IR malloc (2)-allocated
185 buffer containing the next line of input delimited by
187 terminated by a NUL (0) byte.
190 which returns when its buffer is full even if no delimiter has been found,
192 will return an arbitrarily long line in a single call.
195 is set, the terminal delimiter will be overwritten with a NUL.
196 After a successful call to
200 will be the length of the returned buffer, excluding the NUL.
203 returns the next character from
208 may be called immediately after
210 to allow the same character to be reread.
215 to read the bytes of the next
217 sequence in the input stream and returns the value of the rune
218 represented by the sequence.
219 It returns a negative value
222 may be called immediately after
226 sequence to be reread as either bytes or a rune.
230 may back up a maximum of five bytes.
239 to read the formatted
240 floating-point number in the input stream,
241 skipping initial blanks and tabs.
242 The value is stored in
250 into memory starting at
252 The number of bytes read is returned on success
253 and a negative value is returned if a read error occurred.
260 It returns the new file offset.
262 returns the file offset of the next character to be processed.
265 outputs the low order 8 bits of
271 to occur and there is an error,
272 a negative value is returned.
273 Otherwise, a zero is returned.
278 to output the low order
285 on the output stream.
288 is a buffered interface to
292 to occur and there is an error,
298 returns the number of bytes written.
300 does the same except it takes as argument a
302 parameter, so it can be called within a variadic function.
313 to occur and there is an error,
314 a negative value is returned.
315 Otherwise, the number of bytes written is returned.
318 causes any buffered output associated with
325 exit for every buffer still open
329 returns the number of bytes in the buffer.
330 When reading, this is the number of bytes still available from the last
331 read on the file; when writing, it is the number of bytes ready to be
337 to be called in case of an error happening on read/write.
340 will have the program terminated in case of error.
350 routines that return integers yield
354 is not the descriptor of an open file.
356 returns zero if the file cannot be opened in the given mode.
361 An error during read or write will call an error handler specified by
366 returns an error on strings longer than the buffer associated
368 and also if the end-of-file is encountered
371 will tell how many characters are available
373 In the case of a true end-of-file,
376 At the cost of allocating a buffer,
378 sidesteps these issues.
385 cannot be an arbitrary rune.
389 may be overwritten by calls to any other