README
4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
*************************************************************************
* 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 **