forked from LuaDist/lzlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
112 lines (86 loc) · 4.01 KB
/
README
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
*************************************************************************
* Author : Tiago Dionizio <[email protected]> *
* 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.
-- zlib functions --
zlib.version()
returns zlib version
zlib.adler32([int adler32, string buffer])
Without any parameters, returns the inicial adler32 value.
Call to update the adler32 value, adler is the current value, buffer is passed
to adler32 zlib function and the updated value is returned.
zlib.crc32([int crc32, string buffer])
Same as zlib.adler32.
zlib.compress(string buffer [, int level] [, int method] [, int windowBits] [, int memLevel] [, int strategy])
Return a string containing the compressed buffer according to the given parameters.
zlib.decompress(string buffer [, int windowBits])
Return the decompressed stream after processing the given buffer.
zlib.deflate(
sink: function | { write: function [, close: function, flush: function ] },
compression level, [Z_DEFAILT_COMPRESSION]
method, [Z_DEFLATED]
windowBits, [15]
memLevel, [8]
strategy, [Z_DEFAULT_STRATEGY]
dictionary, [""]
)
Return a deflate stream.
stream:read((number | '*l' | '*a')*)
Return a value for each given parameter. Returns a line when
no format is specified.
stream:lines()
Return iterator that returns a line each time it is called, or nil
on end of file.
stream:close()
Close the stream.
zlib.inflate(
source: string | function | { read: function, close: function },
windowBits: number, [15]
dictionary, [""]
)
Return an inflate stream.
deflate and inflate streams can be used almost like a normal file:
stream:write(...)
Write each parameter into the sream.
stream:read([option [, ...]])
Read from the stream, each parameter corresponds to
a return value.
With no arguments, it reads a line.
Parameters are interpreted as follows:
number - reads the specified number of bytes
'a' - reads the remaining bytes
'l' - reads a line
stream:lines(...)
Returns an iterator that returns a new line each time
it is called.
stream:flush(['sync' | 'full' | 'finish'])
Flush output for deflate streams.
stream:close()
Close the stream.