From f97307b54893a53c985a0dcd8b3bb2b94cedd48d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 20 Jun 1997 16:25:54 -0300 Subject: zio should not care about how a user creates a FILE (pipe, socket, popen, etc). --- zio.c | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'zio.c') diff --git a/zio.c b/zio.c index aa400f7d..c0b25daa 100644 --- a/zio.c +++ b/zio.c @@ -1,7 +1,7 @@ /* * zio.c * a generic input stream interface -* $Id: zio.c,v 1.5 1997/06/13 13:49:16 lhf Exp $ +* $Id: zio.c,v 1.1 1997/06/16 16:50:22 roberto Exp roberto $ */ #include @@ -9,13 +9,6 @@ #include #include "zio.h" -#ifdef POPEN -FILE *popen(); -int pclose(); -#else -#define popen(x,y) NULL /* that is, popen always fails */ -#define pclose(x) (-1) -#endif /* ----------------------------------------------------- memory buffers --- */ @@ -24,18 +17,12 @@ static int zmfilbuf(ZIO* z) return EOZ; } -static int zmclose(ZIO* z) -{ - return 1; -} - ZIO* zmopen(ZIO* z, char* b, int size) { if (b==NULL) return NULL; z->n=size; z->p= (unsigned char *)b; z->filbuf=zmfilbuf; - z->close=zmclose; z->u=NULL; return z; } @@ -59,11 +46,6 @@ static int zffilbuf(ZIO* z) return *(z->p++); } -static int zfclose(ZIO* z) -{ - if (z->u==stdin) return 0; - return fclose(z->u); -} ZIO* zFopen(ZIO* z, FILE* f) { @@ -71,30 +53,10 @@ ZIO* zFopen(ZIO* z, FILE* f) z->n=0; z->p=z->buffer; z->filbuf=zffilbuf; - z->close=zfclose; z->u=f; return z; } -ZIO* zfopen(ZIO* z, char* s, char* m) -{ - return zFopen(z,fopen(s,m)); -} - -/* -------------------------------------------------------------- pipes --- */ - -static int zpclose(ZIO* z) -{ - return pclose(z->u); -} - -ZIO* zpopen(ZIO* z, char* s, char* m) -{ - z=zFopen(z,popen(s,m)); - if (z==NULL) return NULL; - z->close=zpclose; - return z; -} /* --------------------------------------------------------------- read --- */ int zread(ZIO *z, void *b, int n) -- cgit v1.2.3-55-g6feb