2 ** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
4 ** See Copyright Notice in lua.h
16 #define EOZ (-1) /* end of stream */
18 typedef struct Zio ZIO
;
20 #define char2int(c) cast(int, cast(unsigned char, (c)))
22 #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
24 typedef struct Mbuffer
{
30 #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
32 #define luaZ_buffer(buff) ((buff)->buffer)
33 #define luaZ_sizebuffer(buff) ((buff)->buffsize)
34 #define luaZ_bufflen(buff) ((buff)->n)
36 #define luaZ_resetbuffer(buff) ((buff)->n = 0)
39 #define luaZ_resizebuffer(L, buff, size) \
40 (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
41 (buff)->buffsize = size)
43 #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
46 void luaZ_prepend(ZIO
*z
, const char *s
, int len
);
47 LUAI_FUNC
char *luaZ_openspace (lua_State
*L
, Mbuffer
*buff
, size_t n
);
48 LUAI_FUNC
void luaZ_init (lua_State
*L
, ZIO
*z
, lua_Reader reader
,
50 LUAI_FUNC
size_t luaZ_read (ZIO
* z
, void* b
, size_t n
); /* read next n bytes */
51 LUAI_FUNC
int luaZ_lookahead (ZIO
*z
);
55 /* --------- Private Part ------------------ */
58 size_t n
; /* bytes still unread */
59 const char *p
; /* current position in buffer */
61 void* data
; /* additional data */
62 lua_State
*L
; /* Lua state (for reader) */
66 LUAI_FUNC
int luaZ_fill (ZIO
*z
);