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
22
int luaZ_fill (ZIO *z) {
27
buff = z->reader(L, z->data, &size);
29
if (buff == NULL || size == 0) return EOZ;
32
return char2int(*(z->p++));
36
int luaZ_lookahead (ZIO *z) {
38
if (luaZ_fill(z) == EOZ)
41
z->n++; /* luaZ_fill removed first byte; put back it */
45
return char2int(*z->p);
49
void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
58
/* --------------------------------------------------------------- read --- */
59
size_t luaZ_read (ZIO *z, void *b, size_t n) {
62
if (luaZ_lookahead(z) == EOZ)
63
return n; /* return number of missing bytes */
64
m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
74
/* ------------------------------------------------------------------------ */
75
char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
76
if (n > buff->buffsize) {
77
if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
78
luaZ_resizebuffer(L, buff, n);