]>
git.saurik.com Git - redis.git/blob - deps/lua/src/lzio.c
2 ** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
3 ** a generic input stream interface
4 ** See Copyright Notice in lua.h
21 int luaZ_fill (ZIO
*z
) {
26 buff
= z
->reader(L
, z
->data
, &size
);
28 if (buff
== NULL
|| size
== 0) return EOZ
;
31 return char2int(*(z
->p
++));
35 int luaZ_lookahead (ZIO
*z
) {
37 if (luaZ_fill(z
) == EOZ
)
40 z
->n
++; /* luaZ_fill removed first byte; put back it */
44 return char2int(*z
->p
);
48 void luaZ_init (lua_State
*L
, ZIO
*z
, lua_Reader reader
, void *data
) {
57 /* --------------------------------------------------------------- read --- */
58 size_t luaZ_read (ZIO
*z
, void *b
, size_t n
) {
61 if (luaZ_lookahead(z
) == EOZ
)
62 return n
; /* return number of missing bytes */
63 m
= (n
<= z
->n
) ? n
: z
->n
; /* min. between n and z->n */
73 /* ------------------------------------------------------------------------ */
74 char *luaZ_openspace (lua_State
*L
, Mbuffer
*buff
, size_t n
) {
75 if (n
> buff
->buffsize
) {
76 if (n
< LUA_MINBUFFER
) n
= LUA_MINBUFFER
;
77 luaZ_resizebuffer(L
, buff
, n
);