]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/man/2/bio
fix manpage cross references
[plan9front.git] / sys / man / 2 / bio
old mode 100755 (executable)
new mode 100644 (file)
index 4d8189e..b62a587
@@ -1,6 +1,6 @@
 .TH BIO 2
 .SH NAME
-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
+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
 .SH SYNOPSIS
 .ta \w'Biobuf* 'u
 .B #include <u.h>
@@ -13,6 +13,9 @@ Bopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetru
 Biobuf* Bopen(char *file, int mode)
 .PP
 .B
+Biobuf* Bfdopen(int fd, int mode)
+.PP
+.B
 int    Binit(Biobuf *bp, int fd, int mode)
 .PP
 .B
@@ -78,6 +81,12 @@ int  Bflush(Biobufhdr *bp)
 .B
 int    Bbuffered(Biobufhdr *bp)
 .PP
+.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.
@@ -93,6 +102,17 @@ It calls
 .IR malloc (2)
 to allocate a buffer.
 .PP
+.I Bfdopen
+allocates a buffer for the already-open file descriptor
+.I fd
+for mode
+.B OREAD
+or
+.BR OWRITE .
+It calls
+.IR malloc (2)
+to allocate a buffer.
+.PP
 .I Binit
 initializes a standard size buffer, type
 .IR Biobuf ,
@@ -133,12 +153,14 @@ returns the integer file descriptor of the associated open file.
 .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.
@@ -248,7 +270,7 @@ outputs the low order 8 bits of
 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.
@@ -269,7 +291,7 @@ on the output stream.
 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 )
@@ -290,7 +312,7 @@ of data starting at
 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.
@@ -311,10 +333,31 @@ returns the number of bytes in the buffer.
 When reading, this is the number of bytes still available from the last
 read on the file; when writing, it is the number of bytes ready to be
 written.
+.PP
+.I Blethal
+arranges
+.I errorf
+to be called in case of an error happening on read/write.
+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),
@@ -330,6 +373,10 @@ returns zero if the file cannot be opened in the given mode.
 All routines set
 .I errstr
 on error.
+.PP
+An error during read or write will call an error handler specified by
+.IR Blethal ,
+if any.
 .SH BUGS
 .I Brdline
 returns an error on strings longer than the buffer associated