3 Bopen, 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 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 void Blethal(Biobufhdr *bp, void (*errorf)(char *))
85 These routines implement fast buffered I/O.
86 I/O on different file descriptors is independent.
100 initializes a standard size buffer, type
102 with the open file descriptor passed in
105 initializes a non-standard size buffer, type
107 with the open file descriptor,
108 buffer area, and buffer size passed in
113 are related by the declaration:
116 typedef struct Biobuf Biobuf;
120 uchar b[Bungetsize+Bsize];
125 of types pointer to Biobuf and pointer to Biobufhdr
126 can be used interchangeably in the following routines.
132 should be called before any of the
133 other routines on that buffer.
135 returns the integer file descriptor of the associated open file.
138 flushes the buffer for
143 If the buffer was allocated by
147 and the file is closed.
150 reads a string from the file associated with
152 up to and including the first
155 The delimiter character at the end of the line is
156 not altered, thus the returned string probably won't be NUL-terminated.
158 returns a pointer to the start of the line or
160 on end-of-file or read error.
162 returns the length (including the delimiter)
163 of the most recent string returned by
168 .IR malloc (2)-allocated
169 buffer containing the next line of input delimited by
171 terminated by a NUL (0) byte.
174 which returns when its buffer is full even if no delimiter has been found,
176 will return an arbitrarily long line in a single call.
179 is set, the terminal delimiter will be overwritten with a NUL.
180 After a successful call to
184 will be the length of the returned buffer, excluding the NUL.
187 returns the next character from
192 may be called immediately after
194 to allow the same character to be reread.
199 to read the bytes of the next
201 sequence in the input stream and returns the value of the rune
202 represented by the sequence.
203 It returns a negative value
206 may be called immediately after
210 sequence to be reread as either bytes or a rune.
214 may back up a maximum of five bytes.
223 to read the formatted
224 floating-point number in the input stream,
225 skipping initial blanks and tabs.
226 The value is stored in
234 into memory starting at
236 The number of bytes read is returned on success
237 and a negative value is returned if a read error occurred.
244 It returns the new file offset.
246 returns the file offset of the next character to be processed.
249 outputs the low order 8 bits of
255 to occur and there is an error,
256 a negative value is returned.
257 Otherwise, a zero is returned.
262 to output the low order
269 on the output stream.
272 is a buffered interface to
276 to occur and there is an error,
282 returns the number of bytes written.
284 does the same except it takes as argument a
286 parameter, so it can be called within a variadic function.
297 to occur and there is an error,
298 a negative value is returned.
299 Otherwise, the number of bytes written is returned.
302 causes any buffered output associated with
309 exit for every buffer still open
313 returns the number of bytes in the buffer.
314 When reading, this is the number of bytes still available from the last
315 read on the file; when writing, it is the number of bytes ready to be
321 to be called in case of an error happening on read/write.
324 will have the program terminated in case of error.
334 routines that return integers yield
338 is not the descriptor of an open file.
340 returns zero if the file cannot be opened in the given mode.
345 An error during read or write will call an error handler specified by
350 returns an error on strings longer than the buffer associated
352 and also if the end-of-file is encountered
355 will tell how many characters are available
357 In the case of a true end-of-file,
360 At the cost of allocating a buffer,
362 sidesteps these issues.
369 cannot be an arbitrary rune.
373 may be overwritten by calls to any other