mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
add bvprint
This commit is contained in:
parent
8b45564f0f
commit
727facb605
1 changed files with 39 additions and 0 deletions
39
src/libbio/bvprint.c
Normal file
39
src/libbio/bvprint.c
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue