diff options
Diffstat (limited to 'src/libbio')
-rw-r--r-- | src/libbio/binit.c | 19 | ||||
-rw-r--r-- | src/libbio/mkfile (renamed from src/libbio/Makefile) | 10 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/libbio/binit.c b/src/libbio/binit.c index d76168b7..33bf5812 100644 --- a/src/libbio/binit.c +++ b/src/libbio/binit.c @@ -98,6 +98,19 @@ Binit(Biobuf *bp, int f, int mode) } 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) { Biobuf *bp; @@ -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; } diff --git a/src/libbio/Makefile b/src/libbio/mkfile index f404f256..2c64b257 100644 --- a/src/libbio/Makefile +++ b/src/libbio/mkfile @@ -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 |