3 Bopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Breadn, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered, Blethal \- 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 Breadn(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 initializes a standard size buffer, type
105 with the open file descriptor passed in
108 initializes a non-standard size buffer, type
110 with the open file descriptor,
111 buffer area, and buffer size passed in
116 are related by the declaration:
119 typedef struct Biobuf Biobuf;
123 uchar b[Bungetsize+Bsize];
128 of types pointer to Biobuf and pointer to Biobufhdr
129 can be used interchangeably in the following routines.
135 should be called before any of the
136 other routines on that buffer.
138 returns the integer file descriptor of the associated open file.
141 flushes the buffer for
146 If the buffer was allocated by
150 and the file is closed.
153 reads a string from the file associated with
155 up to and including the first
158 The delimiter character at the end of the line is
159 not altered, thus the returned string probably won't be NUL-terminated.
161 returns a pointer to the start of the line or
163 on end-of-file or read error.
165 returns the length (including the delimiter)
166 of the most recent string returned by
171 .IR malloc (2)-allocated
172 buffer containing the next line of input delimited by
174 terminated by a NUL (0) byte.
177 which returns when its buffer is full even if no delimiter has been found,
179 will return an arbitrarily long line in a single call.
182 is set, the terminal delimiter will be overwritten with a NUL.
183 After a successful call to
187 will be the length of the returned buffer, excluding the NUL.
190 returns the next character from
195 may be called immediately after
197 to allow the same character to be reread.
202 to read the bytes of the next
204 sequence in the input stream and returns the value of the rune
205 represented by the sequence.
206 It returns a negative value
209 may be called immediately after
213 sequence to be reread as either bytes or a rune.
217 may back up a maximum of five bytes.
226 to read the formatted
227 floating-point number in the input stream,
228 skipping initial blanks and tabs.
229 The value is stored in
237 into memory starting at
239 The number of bytes read is returned on success
240 and a negative value is returned if a read error occurred.
245 but continues reading until
247 have been read into the buffer.
254 It returns the new file offset.
256 returns the file offset of the next character to be processed.
259 outputs the low order 8 bits of
265 to occur and there is an error,
266 a negative value is returned.
267 Otherwise, a zero is returned.
272 to output the low order
279 on the output stream.
282 is a buffered interface to
286 to occur and there is an error,
292 returns the number of bytes written.
294 does the same except it takes as argument a
296 parameter, so it can be called within a variadic function.
307 to occur and there is an error,
308 a negative value is returned.
309 Otherwise, the number of bytes written is returned.
312 causes any buffered output associated with
319 exit for every buffer still open
323 returns the number of bytes in the buffer.
324 When reading, this is the number of bytes still available from the last
325 read on the file; when writing, it is the number of bytes ready to be
331 to be called in case of an error happening on read/write.
334 will have the program terminated in case of error.
344 routines that return integers yield
348 is not the descriptor of an open file.
350 returns zero if the file cannot be opened in the given mode.
355 An error during read or write will call an error handler specified by
360 returns an error on strings longer than the buffer associated
362 and also if the end-of-file is encountered
365 will tell how many characters are available
367 In the case of a true end-of-file,
370 At the cost of allocating a buffer,
372 sidesteps these issues.
379 cannot be an arbitrary rune.
383 may be overwritten by calls to any other