| rsc | 727facb | 2004-12-28 19:18:33 +0000 | [diff] [blame] | 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; |
| rsc | 5eb2d21 | 2005-01-06 23:45:51 +0000 | [diff] [blame] | 32 | n = fmtvprint(&f, fmt, arg); |
| rsc | 727facb | 2004-12-28 19:18:33 +0000 | [diff] [blame] | 33 | bp->ocount = (char*)f.to - (char*)f.stop; |
| 34 | return n; |
| 35 | } |
| 36 | |
| 37 | |
| 38 | |