.B
void Blethal(Biobufhdr *bp, void (*errorf)(char *))
.PP
+.B
+void Biofn(Biobufhdr *bp, int (*iof)(Biobufhdr *, void *, long))
+.PP
.SH DESCRIPTION
These routines implement fast buffered I/O.
I/O on different file descriptors is independent.
.PP
.I Bterm
flushes the buffer for
-.IR bp
+.I bp
and returns
.IR Bflush 's
return value.
If the buffer was allocated by
-.IR Bopen ,
+.I Bopen
+or
+.IR Bfdopen ,
the buffer is
.I freed
and the file is closed.
on
.IR bp .
If this causes a
-.IR write
+.I write
to occur and there is an error,
a negative value is returned.
Otherwise, a zero is returned.
is a buffered interface to
.IR print (2).
If this causes a
-.IR write
+.I write
to occur and there is an error,
a negative value
.RB ( Beof )
to
.IR bp .
If this causes a
-.IR write
+.I write
to occur and there is an error,
a negative value is returned.
Otherwise, the number of bytes written is returned.
An argument of
.B nil
will have the program terminated in case of error.
+.PP
+If
+.I Biofn
+is called with a non-nil
+.I iof
+function, then that function is called for I/O in lieu of
+.IR read (2)
+and
+.IR write .
+A nil argument for
+.I iof
+restores normal behaviour.
.SH SOURCE
.B /sys/src/libbio
.SH SEE ALSO
.IR open (2),
+.IR read (2),
.IR print (2),
.IR exits (2),
.IR utf (6),