Remove building with NOCRYPTO option
[minix.git] / external / mit / lua / dist / src / lzio.h
blobca06aa2c7a480c62c347e5e36fdd66e4b4114c10
1 /*
2 ** $Id: lzio.h,v 1.3 2015/02/02 14:03:05 lneto Exp $
3 ** Buffered streams
4 ** See Copyright Notice in lua.h
5 */
8 #ifndef lzio_h
9 #define lzio_h
11 #include "lua.h"
13 #include "lmem.h"
16 #define EOZ (-1) /* end of stream */
18 typedef struct Zio ZIO;
20 #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
23 typedef struct Mbuffer {
24 char *buffer;
25 size_t n;
26 size_t buffsize;
27 } Mbuffer;
29 #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
31 #define luaZ_buffer(buff) ((buff)->buffer)
32 #define luaZ_sizebuffer(buff) ((buff)->buffsize)
33 #define luaZ_bufflen(buff) ((buff)->n)
35 #define luaZ_buffremove(buff,i) ((buff)->n -= (i))
36 #define luaZ_resetbuffer(buff) ((buff)->n = 0)
39 #define luaZ_resizebuffer(L, buff, size) \
40 ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \
41 (buff)->buffsize, size), \
42 (buff)->buffsize = size)
44 #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
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,
49 void *data);
50 LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */
54 /* --------- Private Part ------------------ */
56 struct Zio {
57 size_t n; /* bytes still unread */
58 const char *p; /* current position in buffer */
59 lua_Reader reader; /* reader function */
60 void *data; /* additional data */
61 lua_State *L; /* Lua state (for reader) */
65 LUAI_FUNC int luaZ_fill (ZIO *z);
67 #endif