************************************************************************* * Author : Tiago Dionizio <tiago.dionizio@gmail.com> * * Library : lzlib - Lua 5.1 interface to access zlib library functions* * * * Permission is hereby granted, free of charge, to any person obtaining * * a copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, sublicense, and/or sell copies of the Software, and to * * permit persons to whom the Software is furnished to do so, subject to * * the following conditions: * * * * The above copyright notice and this permission notice shall be * * included in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.* * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ************************************************************************* To use this library you need zlib library. You can get it from http://www.gzip.org/zlib/ Loading the library: If you built the library as a loadable package [local] zlib = require 'zlib' If you compiled the package statically into your application, call the function "luaopen_zlib(L)". It will create a table with the zlib functions and leave it on the stack. Definitions: ds = deflate stream is = inflate stream int = number (integer) * = (any type) [...] represent optional parameters that may be omited or nil, in wich case will be replaced by their default values -- zlib functions -- string zlib.version() int zlib.compile_flags() int zlib.adler32(int adler, string buf) int zlib.crc32(int crc, string buf) string zlib.compress(string buf [, int level] [, int method] [, int windowBits] [, int memLevel] [, int strategy]) string zlib.uncompress(string buf [, int windowBits]) ds zlib.deflate_init([int level] [, int method] [, int windowBits] [, int memLevel] [, int strategy]) is zlib.inflate_init([int windowBits]) -- deflate stream methods -- int ds:adler() int ds:data_type() int ds:total_in() int ds:total_out() int, int df:process(string [, int flush]) void ds:done() void ds:callback(function callback, * userdata) int ds:set_dictionary(string dictionary) ds [,int] ds:clone() int ds:reset() int ds:params(int level, int strategy) int ds:prime(int bits, int value) -- inflate stream methods -- int is:adler() int is:data_type() int is:total_in() int is:total_out() int, int if:process(string [, int flush]) void if:done() void is:callback([function callback] [, * userdata]) void is:dictionary([function callback] [, * userdata]) int is:set_dictionary(string dictionary) is [,int] is:clone() int is:reset() int, int is:sync(string buf) -- callbacks -- void callback(string buf, * userdata) void dictionary(* userdata) -- general description -- most functions/methods correspond to the original function in the zlib library, the main differences are: when (de)compressing blocks, the generated output is sent to the callback function, this is done to prevent passing too much meaningful result values from the process method deflate/inflate zlib functions are interfaced through the process method ds:params may invoke the output callback process method returns the error value and the number of input bytes processed clone method returns a copy of the stream (also copies callbacks) and returns a new stream object or nil plus an error code dictionary callback is not strictly necessary, but may avoid extra process calls if used, only needed when compressed stream also used a custom dictionary. when using it you must call is:set_dictionary as needed, if not you will have to watch the return code for zlib. is:sync returns an error code and the number of input bytes processed ** for more information please refer to zlib.h **
Forked from
tome / Tales of MajEyal
8037 commits behind the upstream repository.
dg
authored
upgraded some C libs cleanup some C code update osx compile git-svn-id: http://svn.net-core.org/repos/t-engine4@6578 51575b47-30f0-44d4-a5cc-537603b46e54
Name | Last commit | Last update |
---|---|---|
.. | ||
Makefile | ||
README | ||
README.lgzip | ||
lgzip.c | ||
lzlib.c | ||
test_gzip.lua | ||
test_zlib.lua |