diff options
Diffstat (limited to 'src/lzio.h')
-rw-r--r-- | src/lzio.h | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -1,5 +1,5 @@ /* -** $Id: lzio.h,v 1.4 1998/01/09 14:57:43 roberto Exp $ +** $Id: lzio.h,v 1.7 2000/10/20 16:36:32 roberto Exp $ ** Buffered streams ** See Copyright Notice in lua.h */ @@ -22,28 +22,31 @@ typedef struct zio ZIO; -ZIO* zFopen (ZIO* z, FILE* f, char *name); /* open FILEs */ -ZIO* zsopen (ZIO* z, char* s, char *name); /* string */ -ZIO* zmopen (ZIO* z, char* b, int size, char *name); /* memory */ +ZIO* zFopen (ZIO* z, FILE* f, const char *name); /* open FILEs */ +ZIO* zsopen (ZIO* z, const char* s, const char *name); /* string */ +ZIO* zmopen (ZIO* z, const char* b, size_t size, const char *name); /* memory */ -int zread (ZIO* z, void* b, int n); /* read next n bytes */ +size_t zread (ZIO* z, void* b, size_t n); /* read next n bytes */ -#define zgetc(z) (--(z)->n>=0 ? ((int)*(z)->p++): (z)->filbuf(z)) +#define zgetc(z) (((z)->n--)>0 ? ((int)*(z)->p++): (z)->filbuf(z)) #define zungetc(z) (++(z)->n,--(z)->p) #define zname(z) ((z)->name) + /* --------- Private Part ------------------ */ +#ifndef ZBSIZE #define ZBSIZE 256 /* buffer size */ +#endif struct zio { - int n; /* bytes still unread */ - unsigned char* p; /* current position in buffer */ - int (*filbuf)(ZIO* z); - void* u; /* additional data */ - char *name; - unsigned char buffer[ZBSIZE]; /* buffer */ + size_t n; /* bytes still unread */ + const unsigned char* p; /* current position in buffer */ + int (*filbuf)(ZIO* z); + void* u; /* additional data */ + const char *name; + unsigned char buffer[ZBSIZE]; /* buffer */ }; |