mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-24 11:41:58 +00:00
add bfmt.
This commit is contained in:
parent
669250d159
commit
b0be3b8826
1 changed files with 37 additions and 0 deletions
37
src/libbio/bfmt.c
Normal file
37
src/libbio/bfmt.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "lib9.h"
|
||||
#include <bio.h>
|
||||
|
||||
static int
|
||||
_Bfmtflush(Fmt *f)
|
||||
{
|
||||
Biobuf *b;
|
||||
|
||||
b = f->farg;
|
||||
b->ocount = f->to - f->stop;
|
||||
if(Bflush(b) < 0)
|
||||
return 0;
|
||||
f->to = b->ebuf+b->ocount;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
Bfmtinit(Fmt *f, Biobuf *b)
|
||||
{
|
||||
if(b->state != Bwactive)
|
||||
return -1;
|
||||
memset(f, 0, sizeof *f);
|
||||
f->farg = b;
|
||||
f->start = b->bbuf;
|
||||
f->to = b->ebuf+b->ocount;
|
||||
f->stop = b->ebuf;
|
||||
f->flush = _Bfmtflush;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
Bfmtflush(Fmt *f)
|
||||
{
|
||||
if(_Bfmtflush(f) <= 0)
|
||||
return -1;
|
||||
return f->nfmt;
|
||||
}
|
Loading…
Reference in a new issue