1 #include "lib9.h" 2 #include <bio.h> 3 4 static int 5 fmtBflush(Fmt *f) 6 { 7 Biobuf *bp; 8 9 bp = f->farg; 10 bp->ocount = (char*)f->to - (char*)f->stop; 11 if(Bflush(bp) < 0) 12 return 0; 13 f->stop = bp->ebuf; 14 f->to = (char*)f->stop + bp->ocount; 15 f->start = f->to; 16 return 1; 17 } 18 19 int 20 Bvprint(Biobuf *bp, char *fmt, va_list arg) 21 { 22 int n; 23 Fmt f; 24 25 f.runes = 0; 26 f.stop = bp->ebuf; 27 f.start = (char*)f.stop + bp->ocount; 28 f.to = f.start; 29 f.flush = fmtBflush; 30 f.farg = bp; 31 f.nfmt = 0; 32 #ifdef va_copy 33 va_copy(f.args, arg); 34 #else 35 f.args = arg; 36 #endif 37 n = dofmt(&f, fmt); 38 #ifdef va_copy 39 va_end(f.args); 40 #endif 41 bp->ocount = (char*)f.to - (char*)f.stop; 42 return n; 43 } 44