00001
00002
00003
00004
00005
00006
00007
00008 #ifndef lzio_h
00009 #define lzio_h
00010
00011 #include "lua.h"
00012
00013
00014 #define EOZ (-1)
00015
00016 typedef struct Zio ZIO;
00017
00018
00019 #define char2int(c) cast(int, cast(unsigned char, (c)))
00020
00021 #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
00022
00023 #define zname(z) ((z)->name)
00024
00025 void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data, const char *name)
00026 ;
00027 size_t luaZ_read (ZIO* z, void* b, size_t n)
00028 ;
00029 int luaZ_lookahead (ZIO *z)
00030 ;
00031
00032
00033
00034 typedef struct Mbuffer {
00035
00036 char *buffer;
00037 size_t buffsize;
00038 } Mbuffer;
00039
00040
00041 char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n)
00042 ;
00043
00044 #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
00045
00046 #define luaZ_sizebuffer(buff) ((buff)->buffsize)
00047 #define luaZ_buffer(buff) ((buff)->buffer)
00048
00049 #define luaZ_resizebuffer(L, buff, size) \
00050 (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
00051 (buff)->buffsize = size)
00052
00053 #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
00054
00055
00056
00057
00058 struct Zio {
00059 size_t n;
00060
00061 const char *p;
00062 lua_Chunkreader reader;
00063 void* data;
00064 const char *name;
00065 };
00066
00067
00068 int luaZ_fill (ZIO *z)
00069 ;
00070
00071 #endif