beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luazlib / zlib.lua
blobd50db24fe798ef0b6f25865de36cee6a2502ca8e
1 --[[------------------------------------------------------------------------
2 zlib.lua
3 support code for zlib library version 1.2.1
4 usage lua -lzlib ...
6 Author: Tiago Dionizio (tngd@mega.ist.utl.pt)
7 $Id: zlib.lua,v 1.3 2004/07/22 19:11:55 tngd Exp $
8 --]]------------------------------------------------------------------------
10 --[[ Exports ---------------------------------------------------------------
12 ds = deflate stream
13 is = inflate stream
14 int = number (integer)
15 * = (any type)
17 [...] represent optional parameters that may be omited or nil, in wich case
18 will be replaced by their default values
20 -- zlib constants --
22 int zlib.XXXX
24 -- zlib functions --
26 string zlib.version()
27 int zlib.compile_flags()
28 int zlib.adler32(int adler, string buf)
29 int zlib.crc32(int crc, string buf)
31 string zlib.compress(string buf [, int level] [, int method] [, int windowBits] [, int memLevel] [, int strategy])
32 string zlib.uncompress(string buf [, int windowBits])
34 ds zlib.deflate_init([int level] [, int method] [, int windowBits] [, int memLevel] [, int strategy])
35 is zlib.inflate_init([int windowBits])
37 -- deflate stream methods --
39 int ds:adler()
40 int ds:data_type()
41 int ds:total_in()
42 int ds:total_out()
43 int, int df:process(string [, int flush])
44 void ds:done()
45 void ds:callback(function callback, * userdata)
46 int ds:set_dictionary(string dictionary)
47 ds [,int] ds:clone()
48 int ds:reset()
49 int ds:params(int level, int strategy)
50 int ds:prime(int bits, int value)
52 -- inflate stream methods --
54 int is:adler()
55 int is:data_type()
56 int is:total_in()
57 int is:total_out()
58 int, int if:process(string [, int flush])
59 void if:done()
60 void is:callback([function callback] [, * userdata])
61 void is:dictionary([function callback] [, * userdata])
62 int is:set_dictionary(string dictionary)
63 is [,int] is:clone()
64 int is:reset()
65 int, int is:sync(string buf)
67 -- callbacks --
68 void callback(string buf, * userdata)
69 void dictionary(* userdata)
71 -- general description --
72 most functions/methods correspond to the original function in the zlib
73 library, the main differences are:
75 zlib.XXXX constants correspond to the Z_XXXX constants defined in the
76 zlib library
78 when (de)compressing blocks, the generated output is sent to the callback
79 function, this is done to prevent passing too much meaningful result values
80 from the process method
82 deflate/inflate zlib functions are interfaced through the process method
84 ds:params may invoke the output callback
86 process method returns the error value and the number of input bytes
87 processed
89 clone method returns a copy of the stream (also copies callbacks) and
90 returns a new stream object or nil plus an error code
92 dictionary callback is not strictly necessary, but may avoid extra process
93 calls if used, only needed when compressed stream also used a custom
94 dictionary. when using it you must call is:set_dictionary as needed, if not
95 you will have to watch the return code for zlib.
97 is:sync returns an error code and the number of input bytes processed
100 ** for more information please refer to zlib.h **
101 --]]------------------------------------------------------------------------
103 require('requirelib')
105 requirelib('lzlib', 'luaopen_zlib', true)