diff options
author | Lua Team <team@lua.org> | 2000-11-06 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2000-11-06 12:00:00 +0000 |
commit | 8cb71cb5548e3138e5d4e4744f52c79d9fafb116 (patch) | |
tree | 25859eb162c67eafc46866e0ec3a9a7ebf93157a /src/lzio.h | |
parent | b7610da5fed99f59ac73ae452da8839a0f2c1bda (diff) | |
download | lua-github-4.0.tar.gz |
Lua 4.04.0
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 */ }; |