diff options
| author | Charles Forsyth <charles.forsyth@gmail.com> | 2013-06-06 20:59:23 +0000 |
|---|---|---|
| committer | Charles Forsyth <charles.forsyth@gmail.com> | 2013-06-06 20:59:23 +0000 |
| commit | 72335078034e3cd7edcb1739556b405a3e1e9bf8 (patch) | |
| tree | 9e1baa8ea80bfab1885cfcf224a62040a417fa74 /libbio/bvprint.c | |
| parent | 3a0400887de9df81e4d4fb3bc3dec52af2d49f80 (diff) | |
sync with plan 9
Diffstat (limited to 'libbio/bvprint.c')
| -rw-r--r-- | libbio/bvprint.c | 36 |
1 files changed, 36 insertions, 0 deletions
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 <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; +} |
