summaryrefslogtreecommitdiff
path: root/sys/src/libbio/bvprint.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/libbio/bvprint.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/libbio/bvprint.c')
-rwxr-xr-xsys/src/libbio/bvprint.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/src/libbio/bvprint.c b/sys/src/libbio/bvprint.c
new file mode 100755
index 000000000..4881bee9d
--- /dev/null
+++ b/sys/src/libbio/bvprint.c
@@ -0,0 +1,37 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+
+static int
+fmtBflush(Fmt *f)
+{
+ Biobufhdr *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(Biobufhdr *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;
+}