2 ** $Id: lzio.h,v 1.15 2003/03/20 16:00:56 roberto Exp $
4 ** See Copyright Notice in lua.h
14 #define EOZ (-1) /* end of stream */
16 typedef struct Zio ZIO
;
19 #define char2int(c) cast(int, cast(unsigned char, (c)))
21 #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
23 #define zname(z) ((z)->name)
25 void luaZ_init (ZIO
*z
, lua_Chunkreader reader
, void *data
, const char *name
);
26 size_t luaZ_read (ZIO
* z
, void* b
, size_t n
); /* read next n bytes */
27 int luaZ_lookahead (ZIO
*z
);
31 typedef struct Mbuffer
{
37 char *luaZ_openspace (lua_State
*L
, Mbuffer
*buff
, size_t n
);
39 #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
41 #define luaZ_sizebuffer(buff) ((buff)->buffsize)
42 #define luaZ_buffer(buff) ((buff)->buffer)
44 #define luaZ_resizebuffer(L, buff, size) \
45 (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
46 (buff)->buffsize = size)
48 #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
51 /* --------- Private Part ------------------ */
54 size_t n
; /* bytes still unread */
55 const char *p
; /* current position in buffer */
56 lua_Chunkreader reader
;
57 void* data
; /* additional data */
62 int luaZ_fill (ZIO
*z
);