aboutsummaryrefslogtreecommitdiff
path: root/src/libbio
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-12-28 19:18:33 +0000
committerrsc <devnull@localhost>2004-12-28 19:18:33 +0000
commit727facb60539f522635f0d8978435ce4680fecd6 (patch)
treecb00433277ba5ff02170eda636c11dab1c5c095a /src/libbio
parent8b45564f0fd8eccbeaefc79d25470a451c5328d2 (diff)
downloadplan9port-727facb60539f522635f0d8978435ce4680fecd6.tar.gz
plan9port-727facb60539f522635f0d8978435ce4680fecd6.tar.bz2
plan9port-727facb60539f522635f0d8978435ce4680fecd6.zip
add bvprint
Diffstat (limited to 'src/libbio')
-rw-r--r--src/libbio/bvprint.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/libbio/bvprint.c b/src/libbio/bvprint.c
new file mode 100644
index 00000000..7a09f1c0
--- /dev/null
+++ b/src/libbio/bvprint.c
@@ -0,0 +1,39 @@
+#include "lib9.h"
+#include <bio.h>
+
+static int
+fmtBflush(Fmt *f)
+{
+ Biobuf *bp;
+
+ bp = f->farg;
+ bp->ocount = (char*)f->to - (char*)f->stop;
+ if(Bflush(bp) < 0)
+ return 0;
+ f->stop = bp->ebuf;
+ f->to = (char*)f->stop + bp->ocount;
+ f->start = f->to;
+ return 1;
+}
+
+int
+Bvprint(Biobuf *bp, char *fmt, va_list arg)
+{
+ int n;
+ Fmt f;
+
+ f.runes = 0;
+ f.stop = bp->ebuf;
+ f.start = (char*)f.stop + bp->ocount;
+ f.to = f.start;
+ f.flush = fmtBflush;
+ f.farg = bp;
+ f.nfmt = 0;
+ f.args = arg;
+ n = dofmt(&f, fmt);
+ bp->ocount = (char*)f.to - (char*)f.stop;
+ return n;
+}
+
+
+