aboutsummaryrefslogtreecommitdiff
path: root/zio.c
diff options
context:
space:
mode:
Diffstat (limited to 'zio.c')
-rw-r--r--zio.c40
1 files changed, 1 insertions, 39 deletions
diff --git a/zio.c b/zio.c
index aa400f7d..c0b25daa 100644
--- a/zio.c
+++ b/zio.c
@@ -1,7 +1,7 @@
1/* 1/*
2* zio.c 2* zio.c
3* a generic input stream interface 3* a generic input stream interface
4* $Id: zio.c,v 1.5 1997/06/13 13:49:16 lhf Exp $ 4* $Id: zio.c,v 1.1 1997/06/16 16:50:22 roberto Exp roberto $
5*/ 5*/
6 6
7#include <stdio.h> 7#include <stdio.h>
@@ -9,13 +9,6 @@
9#include <string.h> 9#include <string.h>
10#include "zio.h" 10#include "zio.h"
11 11
12#ifdef POPEN
13FILE *popen();
14int pclose();
15#else
16#define popen(x,y) NULL /* that is, popen always fails */
17#define pclose(x) (-1)
18#endif
19 12
20/* ----------------------------------------------------- memory buffers --- */ 13/* ----------------------------------------------------- memory buffers --- */
21 14
@@ -24,18 +17,12 @@ static int zmfilbuf(ZIO* z)
24 return EOZ; 17 return EOZ;
25} 18}
26 19
27static int zmclose(ZIO* z)
28{
29 return 1;
30}
31
32ZIO* zmopen(ZIO* z, char* b, int size) 20ZIO* zmopen(ZIO* z, char* b, int size)
33{ 21{
34 if (b==NULL) return NULL; 22 if (b==NULL) return NULL;
35 z->n=size; 23 z->n=size;
36 z->p= (unsigned char *)b; 24 z->p= (unsigned char *)b;
37 z->filbuf=zmfilbuf; 25 z->filbuf=zmfilbuf;
38 z->close=zmclose;
39 z->u=NULL; 26 z->u=NULL;
40 return z; 27 return z;
41} 28}
@@ -59,11 +46,6 @@ static int zffilbuf(ZIO* z)
59 return *(z->p++); 46 return *(z->p++);
60} 47}
61 48
62static int zfclose(ZIO* z)
63{
64 if (z->u==stdin) return 0;
65 return fclose(z->u);
66}
67 49
68ZIO* zFopen(ZIO* z, FILE* f) 50ZIO* zFopen(ZIO* z, FILE* f)
69{ 51{
@@ -71,30 +53,10 @@ ZIO* zFopen(ZIO* z, FILE* f)
71 z->n=0; 53 z->n=0;
72 z->p=z->buffer; 54 z->p=z->buffer;
73 z->filbuf=zffilbuf; 55 z->filbuf=zffilbuf;
74 z->close=zfclose;
75 z->u=f; 56 z->u=f;
76 return z; 57 return z;
77} 58}
78 59
79ZIO* zfopen(ZIO* z, char* s, char* m)
80{
81 return zFopen(z,fopen(s,m));
82}
83
84/* -------------------------------------------------------------- pipes --- */
85
86static int zpclose(ZIO* z)
87{
88 return pclose(z->u);
89}
90
91ZIO* zpopen(ZIO* z, char* s, char* m)
92{
93 z=zFopen(z,popen(s,m));
94 if (z==NULL) return NULL;
95 z->close=zpclose;
96 return z;
97}
98 60
99/* --------------------------------------------------------------- read --- */ 61/* --------------------------------------------------------------- read --- */
100int zread(ZIO *z, void *b, int n) 62int zread(ZIO *z, void *b, int n)