3 * a generic input stream interface
4 * $Id: zio.h,v 1.5 1997/06/20 19:25:54 roberto Exp $
15 #define zFopen luaZ_Fopen
16 #define zsopen luaZ_sopen
17 #define zmopen luaZ_mopen
18 #define zread luaZ_read
20 #define EOZ (-1) /* end of stream */
22 typedef struct zio ZIO
;
24 ZIO
* zFopen(ZIO
* z
, FILE* f
); /* open FILEs */
25 ZIO
* zsopen(ZIO
* z
, char* s
); /* string */
26 ZIO
* zmopen(ZIO
* z
, char* b
, int size
); /* memory */
28 int zread(ZIO
* z
, void* b
, int n
); /* read next n bytes */
30 #define zgetc(z) (--(z)->n>=0 ? ((int)*(z)->p++): (z)->filbuf(z))
31 #define zungetc(z) (++(z)->n,--(z)->p)
35 /* --------- Private Part ------------------ */
37 #define ZBSIZE 256 /* buffer size */
40 int n
; /* bytes still unread */
41 unsigned char* p
; /* current position in buffer */
42 int (*filbuf
)(ZIO
* z
);
43 void* u
; /* additional data */
44 unsigned char buffer
[ZBSIZE
]; /* buffer */