aboutsummaryrefslogtreecommitdiff
path: root/src/libbio
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2003-12-03 22:51:11 +0000
committerrsc <devnull@localhost>2003-12-03 22:51:11 +0000
commitb0be3b88261ddf09aaeca5c287f1b9ca26ccb558 (patch)
tree0a6afbc1b8122ecf2e2121f2318620e985d0afa7 /src/libbio
parent669250d159e93a6933afa4cd25f410af801515ec (diff)
downloadplan9port-b0be3b88261ddf09aaeca5c287f1b9ca26ccb558.tar.gz
plan9port-b0be3b88261ddf09aaeca5c287f1b9ca26ccb558.tar.bz2
plan9port-b0be3b88261ddf09aaeca5c287f1b9ca26ccb558.zip
add bfmt.
Diffstat (limited to 'src/libbio')
-rw-r--r--src/libbio/bfmt.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/libbio/bfmt.c b/src/libbio/bfmt.c
new file mode 100644
index 00000000..f1b6f5ab
--- /dev/null
+++ b/src/libbio/bfmt.c
@@ -0,0 +1,37 @@
+#include "lib9.h"
+#include <bio.h>
+
+static int
+_Bfmtflush(Fmt *f)
+{
+ Biobuf *b;
+
+ b = f->farg;
+ b->ocount = f->to - f->stop;
+ if(Bflush(b) < 0)
+ return 0;
+ f->to = b->ebuf+b->ocount;
+ return 1;
+}
+
+int
+Bfmtinit(Fmt *f, Biobuf *b)
+{
+ if(b->state != Bwactive)
+ return -1;
+ memset(f, 0, sizeof *f);
+ f->farg = b;
+ f->start = b->bbuf;
+ f->to = b->ebuf+b->ocount;
+ f->stop = b->ebuf;
+ f->flush = _Bfmtflush;
+ return 0;
+}
+
+int
+Bfmtflush(Fmt *f)
+{
+ if(_Bfmtflush(f) <= 0)
+ return -1;
+ return f->nfmt;
+}