static z_stream *lzstream_check(lua_State *L, int index, void *state) { z_stream *s = lzstream_get(L, index); if ((state != LZANY && s->opaque != state) || s->opaque == LZNONE) luaL_argerror(L, index, "attempt to use invalid zlib stream"); return s; }
static lz_stream *lzstream_check(lua_State *L, int index, int state) { lz_stream *s = lzstream_get(L, index); if ((state != LZ_ANY && s->state != state) || s->state == LZ_NONE) { luaL_argerror(L, index, "attempt to use invalid zlib stream"); } return s; }
static int lzstream_close(lua_State *L) { lz_stream *s = lzstream_get(L, 1); if (s->state == LZ_DEFLATE) { lua_settop(L, 0); lua_pushliteral(L, ""); return lzstream_docompress(L, s, 1, 1, Z_FINISH); } lzstream_cleanup(L, s); lua_pushboolean(L, 1); return 1; }
static int lzstream_gc(lua_State *L) { z_stream *s = lzstream_get(L, 1); lzstream_cleanup(L, s); return 0; }