Blob
1 #include "lib9.h"2 #include <bio.h>4 static int5 _Bfmtflush(Fmt *f)6 {7 Biobuf *b;9 b = f->farg;10 b->ocount = f->to - f->stop;11 if(Bflush(b) < 0)12 return 0;13 f->to = b->ebuf+b->ocount;14 return 1;15 }17 int18 Bfmtinit(Fmt *f, Biobuf *b)19 {20 if(b->state != Bwactive)21 return -1;22 memset(f, 0, sizeof *f);23 f->farg = b;24 f->start = b->bbuf;25 f->to = b->ebuf+b->ocount;26 f->stop = b->ebuf;27 f->flush = _Bfmtflush;28 return 0;29 }31 int32 Bfmtflush(Fmt *f)33 {34 if(_Bfmtflush(f) <= 0)35 return -1;36 return f->nfmt;37 }