commit - f365e600d41badc64b7a13ba385eb876d381abaa
commit + 986b36bccd134726eea42f2cfabff2943d729ac4
blob - fda598ac23afb9bc730a56e8c1708c801cc5328e
blob + 600f0948939a08905f275d40bebc91cb4db6a7f4
--- include/bio.h
+++ include/bio.h
(bp)->fid
int Bbuffered(Biobuf*);
+Biobuf* Bfdopen(int, int);
int Bfildes(Biobuf*);
int Bflush(Biobuf*);
int Bgetc(Biobuf*);
blob - f404f2566e56268dba43006da61a7b17fb357f1b (mode 644)
blob + /dev/null
--- src/libbio/Makefile
+++ /dev/null
-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
-
blob - d76168b7fdba8169c16f8c1c375e3c1b9a14dece
blob + 33bf581286e1e9d787c0d38e50f40e95b41910ed
--- src/libbio/binit.c
+++ src/libbio/binit.c
}
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;
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;
}
blob - /dev/null
blob + 2c64b257214d8305b7d1820c557c0e802c0ac940 (mode 644)
--- /dev/null
+++ src/libbio/mkfile
+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
+