2 ** $Id: lzio.c,v 1.35.1.1 2013/04/12 18:48:47 roberto Exp $
4 ** See Copyright Notice in lua.h
11 #include <sys/lua/lua.h>
19 int luaZ_fill (ZIO
*z
) {
24 buff
= z
->reader(L
, z
->data
, &size
);
26 if (buff
== NULL
|| size
== 0)
28 z
->n
= size
- 1; /* discount char being returned */
30 return cast_uchar(*(z
->p
++));
34 void luaZ_init (lua_State
*L
, ZIO
*z
, lua_Reader reader
, void *data
) {
43 /* --------------------------------------------------------------- read --- */
44 size_t luaZ_read (ZIO
*z
, void *b
, size_t n
) {
47 if (z
->n
== 0) { /* no bytes in buffer? */
48 if (luaZ_fill(z
) == EOZ
) /* try to read more */
49 return n
; /* no more input; return number of missing bytes */
51 z
->n
++; /* luaZ_fill consumed first byte; put it back */
55 m
= (n
<= z
->n
) ? n
: z
->n
; /* min. between n and z->n */
65 /* ------------------------------------------------------------------------ */
66 char *luaZ_openspace (lua_State
*L
, Mbuffer
*buff
, size_t n
) {
67 if (n
> buff
->buffsize
) {
68 if (n
< LUA_MINBUFFER
) n
= LUA_MINBUFFER
;
69 luaZ_resizebuffer(L
, buff
, n
);