wmii/lib/libbio/bvprint.c

40 lines
626 B
C
Raw Normal View History

#include "plan9.h"
#include <bio.h>
2010-06-14 18:30:23 +04:00
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
2007-07-17 00:52:35 +04:00
Bvprint(Biobuf *bp, const 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;
2010-07-19 20:50:19 +04:00
fmtlocaleinit(&f, nil, nil, nil);
n = fmtvprint(&f, fmt, arg);
bp->ocount = (char*)f.to - (char*)f.stop;
2010-07-19 20:50:19 +04:00
if(n == 0)
n = f.nfmt;
return n;
}