plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit 986b36bccd134726eea42f2cfabff2943d729ac4
parent f365e600d41badc64b7a13ba385eb876d381abaa
Author: rsc <devnull@localhost>
Date:   Sun, 23 Nov 2003 18:14:35 +0000

make -> mk.

add Bfdopen.

Diffstat:
Minclude/bio.h | 1+
Dsrc/libbio/Makefile | 31-------------------------------
Msrc/libbio/binit.c | 19+++++++++++++++----
Asrc/libbio/mkfile | 31+++++++++++++++++++++++++++++++
4 files changed, 47 insertions(+), 35 deletions(-)

diff --git a/include/bio.h b/include/bio.h @@ -55,6 +55,7 @@ struct Biobuf (bp)->fid int Bbuffered(Biobuf*); +Biobuf* Bfdopen(int, int); int Bfildes(Biobuf*); int Bflush(Biobuf*); int Bgetc(Biobuf*); diff --git a/src/libbio/Makefile b/src/libbio/Makefile @@ -1,31 +0,0 @@ -PLAN9=../.. -include $(PLAN9)/src/Makehdr - -LIB=libbio.a - -OFILES=\ - bbuffered.$O\ - bfildes.$O\ - bflush.$O\ - bgetc.$O\ - bgetd.$O\ - binit.$O\ - boffset.$O\ - bprint.$O\ - bputc.$O\ - brdline.$O\ - brdstr.$O\ - bread.$O\ - bseek.$O\ - bwrite.$O\ - bgetrune.$O\ - bputrune.$O\ - -HFILES=\ - $(PLAN9)/include/bio.h\ - -include $(PLAN9)/src/Makesyslib - -bcat: bcat.$O $(LIB) - $(CC) -o bcat bcat.$O -L$(PLAN9)/lib -lbio -lfmt -lutf - diff --git 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/mkfile b/src/libbio/mkfile @@ -0,0 +1,31 @@ +PLAN9=../.. +<$PLAN9/src/mkhdr + +LIB=libbio.a + +OFILES=\ + bbuffered.$O\ + bfildes.$O\ + bflush.$O\ + bgetc.$O\ + bgetd.$O\ + binit.$O\ + boffset.$O\ + bprint.$O\ + bputc.$O\ + brdline.$O\ + brdstr.$O\ + bread.$O\ + bseek.$O\ + bwrite.$O\ + bgetrune.$O\ + bputrune.$O\ + +HFILES=\ + $PLAN9/include/bio.h\ + +<$PLAN9/src/mksyslib + +bcat: bcat.$O $LIB + $CC -o bcat bcat.$O -L$PLAN9/lib -lbio -lfmt -lutf +