From 72335078034e3cd7edcb1739556b405a3e1e9bf8 Mon Sep 17 00:00:00 2001 From: Charles Forsyth Date: Thu, 6 Jun 2013 20:59:23 +0000 Subject: sync with plan 9 --- libbio/bvprint.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 libbio/bvprint.c (limited to 'libbio/bvprint.c') diff --git a/libbio/bvprint.c b/libbio/bvprint.c new file mode 100644 index 00000000..c11b1dc3 --- /dev/null +++ b/libbio/bvprint.c @@ -0,0 +1,36 @@ +#include "lib9.h" +#include + +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; +} -- cgit v1.2.3