2022-03-24 21:23:42 +08:00
|
|
|
# 1 "./lua/lzio.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-24 10:23:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef lzio_h
|
2022-03-24 21:23:42 +08:00
|
|
|
#define lzio_h
|
2022-01-24 10:23:08 +08:00
|
|
|
|
|
|
|
#include "lua.h"
|
|
|
|
|
|
|
|
#include "lmem.h"
|
|
|
|
|
|
|
|
|
2022-03-24 21:23:42 +08:00
|
|
|
#define EOZ (-1)
|
2022-01-24 10:23:08 +08:00
|
|
|
|
|
|
|
typedef struct Zio ZIO;
|
|
|
|
|
2022-03-24 21:23:42 +08:00
|
|
|
#define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
|
2022-01-24 10:23:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct Mbuffer {
|
|
|
|
char *buffer;
|
|
|
|
size_t n;
|
|
|
|
size_t buffsize;
|
|
|
|
} Mbuffer;
|
|
|
|
|
2022-03-24 21:23:42 +08:00
|
|
|
#define luaZ_initbuffer(L,buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-03-24 21:23:42 +08:00
|
|
|
#define luaZ_buffer(buff) ((buff)->buffer)
|
|
|
|
#define luaZ_sizebuffer(buff) ((buff)->buffsize)
|
|
|
|
#define luaZ_bufflen(buff) ((buff)->n)
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-03-24 21:23:42 +08:00
|
|
|
#define luaZ_buffremove(buff,i) ((buff)->n -= (i))
|
2022-01-24 10:23:08 +08:00
|
|
|
#define luaZ_resetbuffer(buff) ((buff)->n = 0)
|
|
|
|
|
|
|
|
|
2022-03-24 21:23:42 +08:00
|
|
|
#define luaZ_resizebuffer(L,buff,size) \
|
|
|
|
((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \
|
|
|
|
(buff)->buffsize, size), \
|
|
|
|
(buff)->buffsize = size)
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-03-24 21:23:42 +08:00
|
|
|
#define luaZ_freebuffer(L,buff) luaZ_resizebuffer(L, buff, 0)
|
2022-01-24 10:23:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
|
|
|
|
void *data);
|
2022-03-24 21:23:42 +08:00
|
|
|
LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n);
|
|
|
|
|
2022-01-24 10:23:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Zio {
|
2022-03-24 21:23:42 +08:00
|
|
|
size_t n;
|
|
|
|
const char *p;
|
|
|
|
lua_Reader reader;
|
|
|
|
void *data;
|
|
|
|
lua_State *L;
|
2022-01-24 10:23:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
LUAI_FUNC int luaZ_fill (ZIO *z);
|
|
|
|
|
|
|
|
#endif
|