make -> mk.

add Bfdopen.
This commit is contained in:
rsc 2003-11-23 18:14:35 +00:00
parent f365e600d4
commit 986b36bccd
3 changed files with 21 additions and 9 deletions

View file

@ -55,6 +55,7 @@ struct Biobuf
(bp)->fid
int Bbuffered(Biobuf*);
Biobuf* Bfdopen(int, int);
int Bfildes(Biobuf*);
int Bflush(Biobuf*);
int Bgetc(Biobuf*);

View file

@ -97,6 +97,19 @@ Binit(Biobuf *bp, int f, int mode)
return Binits(bp, f, mode, bp->b, sizeof(bp->b));
}
Biobuf*
Bfdopen(int f, int mode)
{
Biobuf *bp;
bp = malloc(sizeof(Biobuf));
if(bp == 0)
return 0;
Binits(bp, f, mode, bp->b, sizeof(bp->b));
bp->flag = Bmagic;
return bp;
}
Biobuf*
Bopen(char *name, int mode)
{
@ -119,11 +132,9 @@ Bopen(char *name, int mode)
if(f < 0)
return 0;
}
bp = malloc(sizeof(Biobuf));
bp = Bfdopen(f, mode);
if(bp == 0)
return 0;
Binits(bp, f, mode, bp->b, sizeof(bp->b));
bp->flag = Bmagic;
close(f);
return bp;
}

View file

@ -1,5 +1,5 @@
PLAN9=../..
include $(PLAN9)/src/Makehdr
<$PLAN9/src/mkhdr
LIB=libbio.a
@ -22,10 +22,10 @@ OFILES=\
bputrune.$O\
HFILES=\
$(PLAN9)/include/bio.h\
$PLAN9/include/bio.h\
include $(PLAN9)/src/Makesyslib
<$PLAN9/src/mksyslib
bcat: bcat.$O $(LIB)
$(CC) -o bcat bcat.$O -L$(PLAN9)/lib -lbio -lfmt -lutf
bcat: bcat.$O $LIB
$CC -o bcat bcat.$O -L$PLAN9/lib -lbio -lfmt -lutf