3 Bopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered \- 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 These routines implement fast buffered I/O.
83 I/O on different file descriptors is independent.
97 initializes a standard size buffer, type
99 with the open file descriptor passed in
102 initializes a non-standard size buffer, type
104 with the open file descriptor,
105 buffer area, and buffer size passed in
110 are related by the declaration:
113 typedef struct Biobuf Biobuf;
117 uchar b[Bungetsize+Bsize];
122 of types pointer to Biobuf and pointer to Biobufhdr
123 can be used interchangeably in the following routines.
129 should be called before any of the
130 other routines on that buffer.
132 returns the integer file descriptor of the associated open file.
135 flushes the buffer for
140 If the buffer was allocated by
144 and the file is closed.
147 reads a string from the file associated with
149 up to and including the first
152 The delimiter character at the end of the line is
153 not altered, thus the returned string probably won't be NUL-terminated.
155 returns a pointer to the start of the line or
157 on end-of-file or read error.
159 returns the length (including the delimiter)
160 of the most recent string returned by
165 .IR malloc (2)-allocated
166 buffer containing the next line of input delimited by
168 terminated by a NUL (0) byte.
171 which returns when its buffer is full even if no delimiter has been found,
173 will return an arbitrarily long line in a single call.
176 is set, the terminal delimiter will be overwritten with a NUL.
177 After a successful call to
181 will be the length of the returned buffer, excluding the NUL.
184 returns the next character from
189 may be called immediately after
191 to allow the same character to be reread.
196 to read the bytes of the next
198 sequence in the input stream and returns the value of the rune
199 represented by the sequence.
200 It returns a negative value
203 may be called immediately after
207 sequence to be reread as either bytes or a rune.
211 may back up a maximum of five bytes.
220 to read the formatted
221 floating-point number in the input stream,
222 skipping initial blanks and tabs.
223 The value is stored in
231 into memory starting at
233 The number of bytes read is returned on success
234 and a negative value is returned if a read error occurred.
241 It returns the new file offset.
243 returns the file offset of the next character to be processed.
246 outputs the low order 8 bits of
252 to occur and there is an error,
253 a negative value is returned.
254 Otherwise, a zero is returned.
259 to output the low order
266 on the output stream.
269 is a buffered interface to
273 to occur and there is an error,
279 returns the number of bytes written.
281 does the same except it takes as argument a
283 parameter, so it can be called within a variadic function.
294 to occur and there is an error,
295 a negative value is returned.
296 Otherwise, the number of bytes written is returned.
299 causes any buffered output associated with
306 exit for every buffer still open
310 returns the number of bytes in the buffer.
311 When reading, this is the number of bytes still available from the last
312 read on the file; when writing, it is the number of bytes ready to be
323 routines that return integers yield
327 is not the descriptor of an open file.
329 returns zero if the file cannot be opened in the given mode.
335 returns an error on strings longer than the buffer associated
337 and also if the end-of-file is encountered
340 will tell how many characters are available
342 In the case of a true end-of-file,
345 At the cost of allocating a buffer,
347 sidesteps these issues.
354 cannot be an arbitrary rune.
358 may be overwritten by calls to any other