Example #1
0
static int lmz_inflator_init(lua_State* L) {
  lmz_stream_t* stream = lua_newuserdata(L, sizeof(*stream));
  mz_streamp miniz_stream = &(stream->stream);
  luaL_getmetatable(L, "miniz_inflator");
  lua_setmetatable(L, -2);
  memset(miniz_stream, 0, sizeof(*miniz_stream));
  int status = mz_inflateInit(miniz_stream);
  if (status != MZ_OK) {
    const char* msg = mz_error(status);
    if (msg) {
      luaL_error(L, "Problem initializing stream: %s", msg);
    } else {
      luaL_error(L, "Problem initializing stream");
    }
  }
  stream->mode = 1;
  return 1;
}
Example #2
0
	deflate_source(source const& src, bool compress, bool pull = true)
	: octet_reader(src)
	, pull(pull)
	, compress(compress)
	{
		str.zalloc = 0;
		str.zfree = 0;
		str.opaque = 0;
		
		if (compress)
			mz_deflateInit(&str, MZ_DEFAULT_COMPRESSION);
		else
			mz_inflateInit(&str);
		
		str.avail_in = 0;
		str.avail_out = 0;

		prepare_out();
	}