2 78e51a8c 2005-01-14 devnull <title>flate(3) - Plan 9 from User Space</title>
3 78e51a8c 2005-01-14 devnull <meta content="text/html; charset=utf-8" http-equiv=Content-Type>
5 78e51a8c 2005-01-14 devnull <body bgcolor=#ffffff>
6 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0 width=100%>
7 78e51a8c 2005-01-14 devnull <tr height=10><td>
8 78e51a8c 2005-01-14 devnull <tr><td width=20><td>
9 78e51a8c 2005-01-14 devnull <tr><td width=20><td><b>FLATE(3)</b><td align=right><b>FLATE(3)</b>
10 78e51a8c 2005-01-14 devnull <tr><td width=20><td colspan=2>
12 78e51a8c 2005-01-14 devnull <p><font size=+1><b>NAME </b></font><br>
14 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
16 78e51a8c 2005-01-14 devnull deflateinit, deflate, deflatezlib, deflateblock, deflatezlibblock,
17 78e51a8c 2005-01-14 devnull inflateinit, inflate, inflatezlib, inflateblock, inflatezlibblock,
18 78e51a8c 2005-01-14 devnull flateerr, mkcrctab, blockcrc, adler32 – deflate compression<br>
21 78e51a8c 2005-01-14 devnull <p><font size=+1><b>SYNOPSIS </b></font><br>
23 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
25 78e51a8c 2005-01-14 devnull <tt><font size=+1>#include <u.h><br>
26 78e51a8c 2005-01-14 devnull #include <libc.h><br>
27 78e51a8c 2005-01-14 devnull #include <flate.h>
28 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
29 78e51a8c 2005-01-14 devnull </font></tt>
31 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
33 78e51a8c 2005-01-14 devnull <tt><font size=+1>int deflateinit(void)
34 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
35 78e51a8c 2005-01-14 devnull </font></tt>
36 78e51a8c 2005-01-14 devnull <tt><font size=+1>int deflate(void *wr, int (*w)(void*,void*,int),<br>
38 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
41 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
43 78e51a8c 2005-01-14 devnull void *rr, int (*r)(void*,void*,int),<br>
44 78e51a8c 2005-01-14 devnull int level, int debug)
45 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
50 78e51a8c 2005-01-14 devnull </font></tt>
51 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
54 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
61 78e51a8c 2005-01-14 devnull <tt><font size=+1>int deflatezlib(void *wr, int (*w)(void*,void*,int),<br>
63 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
66 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
68 78e51a8c 2005-01-14 devnull void *rr, int (*r)(void*,void*,int),<br>
69 78e51a8c 2005-01-14 devnull int level, int debug)
70 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
75 78e51a8c 2005-01-14 devnull </font></tt>
76 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
79 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
86 78e51a8c 2005-01-14 devnull <tt><font size=+1>int deflateblock(uchar *dst, int dsize,<br>
88 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
91 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
93 78e51a8c 2005-01-14 devnull uchar *src, int ssize,<br>
94 78e51a8c 2005-01-14 devnull int level, int debug)
95 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
100 78e51a8c 2005-01-14 devnull </font></tt>
101 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
104 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
108 78e51a8c 2005-01-14 devnull </table>
110 78e51a8c 2005-01-14 devnull </table>
111 78e51a8c 2005-01-14 devnull <tt><font size=+1>int deflatezlibblock(uchar *dst, int dsize,<br>
113 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
116 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
118 78e51a8c 2005-01-14 devnull uchar *src, int ssize,<br>
119 78e51a8c 2005-01-14 devnull int level, int debug)
120 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
122 78e51a8c 2005-01-14 devnull </table>
124 78e51a8c 2005-01-14 devnull </table>
125 78e51a8c 2005-01-14 devnull </font></tt>
126 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
129 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
133 78e51a8c 2005-01-14 devnull </table>
135 78e51a8c 2005-01-14 devnull </table>
136 78e51a8c 2005-01-14 devnull <tt><font size=+1>int inflateinit(void)
137 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
138 78e51a8c 2005-01-14 devnull </font></tt>
139 78e51a8c 2005-01-14 devnull <tt><font size=+1>int inflate(void *wr, int (*w)(void*, void*, int),<br>
141 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
144 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
146 78e51a8c 2005-01-14 devnull void *getr, int (*get)(void*))
147 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
149 78e51a8c 2005-01-14 devnull </table>
151 78e51a8c 2005-01-14 devnull </table>
152 78e51a8c 2005-01-14 devnull </font></tt>
153 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
156 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
160 78e51a8c 2005-01-14 devnull </table>
162 78e51a8c 2005-01-14 devnull </table>
163 78e51a8c 2005-01-14 devnull <tt><font size=+1>int inflatezlib(void *wr, int (*w)(void*, void*, int),<br>
165 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
168 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
170 78e51a8c 2005-01-14 devnull void *getr, int (*get)(void*))
171 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
173 78e51a8c 2005-01-14 devnull </table>
175 78e51a8c 2005-01-14 devnull </table>
176 78e51a8c 2005-01-14 devnull </font></tt>
177 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
180 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
184 78e51a8c 2005-01-14 devnull </table>
186 78e51a8c 2005-01-14 devnull </table>
187 78e51a8c 2005-01-14 devnull <tt><font size=+1>int inflateblock(uchar *dst, int dsize,<br>
189 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
192 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
194 78e51a8c 2005-01-14 devnull uchar *src, int ssize)
195 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
197 78e51a8c 2005-01-14 devnull </table>
199 78e51a8c 2005-01-14 devnull </table>
200 78e51a8c 2005-01-14 devnull </font></tt>
201 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
204 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
208 78e51a8c 2005-01-14 devnull </table>
210 78e51a8c 2005-01-14 devnull </table>
211 78e51a8c 2005-01-14 devnull <tt><font size=+1>int inflatezlibblock(uchar *dst, int dsize,<br>
213 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
216 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
218 78e51a8c 2005-01-14 devnull uchar *src, int ssize)
219 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
221 78e51a8c 2005-01-14 devnull </table>
223 78e51a8c 2005-01-14 devnull </table>
224 78e51a8c 2005-01-14 devnull </font></tt>
225 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
228 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
232 78e51a8c 2005-01-14 devnull </table>
234 78e51a8c 2005-01-14 devnull </table>
235 78e51a8c 2005-01-14 devnull <tt><font size=+1>char *flateerr(int error)
236 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
237 78e51a8c 2005-01-14 devnull </font></tt>
238 78e51a8c 2005-01-14 devnull <tt><font size=+1>ulong *mkcrctab(ulong poly)
239 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
240 78e51a8c 2005-01-14 devnull </font></tt>
241 78e51a8c 2005-01-14 devnull <tt><font size=+1>ulong blockcrc(ulong *tab, ulong crc, void *buf, int n)
242 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
243 78e51a8c 2005-01-14 devnull </font></tt>
244 78e51a8c 2005-01-14 devnull <tt><font size=+1>ulong adler32(ulong adler, void *buf, int n)<br>
245 78e51a8c 2005-01-14 devnull </font></tt>
246 78e51a8c 2005-01-14 devnull </table>
247 78e51a8c 2005-01-14 devnull <p><font size=+1><b>DESCRIPTION </b></font><br>
249 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
251 78e51a8c 2005-01-14 devnull These routines compress and decompress data using the deflate
252 78e51a8c 2005-01-14 devnull compression algorithm, which is used for most gzip, zip, and zlib
254 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
256 78e51a8c 2005-01-14 devnull <i>Deflate</i> compresses input data retrieved by calls to <i>r</i> with arguments
257 78e51a8c 2005-01-14 devnull <i>rr</i>, an input buffer, and a count of bytes to read. <i>R</i> should return
258 78e51a8c 2005-01-14 devnull the number of bytes read; end of input is signaled by returning
259 78e51a8c 2005-01-14 devnull zero, an input error by returning a negative number. The compressed
260 78e51a8c 2005-01-14 devnull output is written to <i>w</i> with arguments <i>wr</i>, the
261 78e51a8c 2005-01-14 devnull output data, and the number of bytes to write. <i>W</i> should return
262 78e51a8c 2005-01-14 devnull the number of bytes written; writing fewer than the requested
263 78e51a8c 2005-01-14 devnull number of bytes is an error. <i>Level</i> indicates the amount of computation
264 78e51a8c 2005-01-14 devnull deflate should do while compressing the data. Higher <i>levels</i> usually
265 78e51a8c 2005-01-14 devnull take more time and produce smaller outputs. Valid
266 78e51a8c 2005-01-14 devnull values are 1 to 9, inclusive; 6 is a good compromise. If <i>debug</i>
267 78e51a8c 2005-01-14 devnull is non-zero, cryptic debugging information is produced on standard
269 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
271 78e51a8c 2005-01-14 devnull <i>Inflate</i> reverses the process, converting compressed data into
272 78e51a8c 2005-01-14 devnull uncompressed output. Input is retrieved one byte at a time by
273 78e51a8c 2005-01-14 devnull calling <i>get</i> with the argument <i>getr</i>. End of input of signaled by
274 78e51a8c 2005-01-14 devnull returning a negative value. The uncompressed output is written
275 78e51a8c 2005-01-14 devnull to <i>w</i>, which has the same interface as for <i>deflate</i>.
276 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
278 78e51a8c 2005-01-14 devnull <i>Deflateblock</i> and <i>inflateblock</i> operate on blocks of memory but
279 78e51a8c 2005-01-14 devnull are otherwise similar to <i>deflate</i> and <i>inflate</i>.
280 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
282 78e51a8c 2005-01-14 devnull The zlib functions are similar, but operate on files with a zlib
283 78e51a8c 2005-01-14 devnull header and trailer.
284 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
286 78e51a8c 2005-01-14 devnull <i>Deflateinit</i> or <i>inflateinit</i> must be called once before any call
287 78e51a8c 2005-01-14 devnull to the corresponding routines.
288 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
290 78e51a8c 2005-01-14 devnull If the above routines fail, they return a negative number indicating
291 78e51a8c 2005-01-14 devnull the problem. The possible values are <i>FlateNoMem</i>, <i>FlateInputFail</i>,
292 78e51a8c 2005-01-14 devnull <i>FlateOutputFail</i>, <i>FlateCorrupted</i>, and <i>FlateInternal</i>. <i>Flateerr</i> converts
293 78e51a8c 2005-01-14 devnull the number into a printable message. <i>FlateOk</i> is defined to be
294 78e51a8c 2005-01-14 devnull zero, the successful return value for <i>deflateinit</i>,
295 78e51a8c 2005-01-14 devnull <i>deflate</i>, <i>deflatezlib</i>, <i>inflateinit</i>, <i>inflate</i>, and <i>inflatezlib</i>. The
296 78e51a8c 2005-01-14 devnull block functions return the number of bytes produced when they
297 78e51a8c 2005-01-14 devnull succeed.
298 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
300 78e51a8c 2005-01-14 devnull <i>Mkcrctab</i> allocates (using <a href="../man3/malloc.html"><i>malloc</i>(3)</a>), initializes, and returns
301 78e51a8c 2005-01-14 devnull a table for rapid computation of 32 bit CRC values using the polynomial
302 78e51a8c 2005-01-14 devnull <i>poly</i>. <i>Blockcrc</i> uses <i>tab</i>, a table returned by <i>mkcrctab</i>, to update
303 78e51a8c 2005-01-14 devnull <i>crc</i> for the <i>n</i> bytes of data in <i>buf</i>, and returns the new value.
304 78e51a8c 2005-01-14 devnull <i>Crc</i> should initially be zero. <i>Blockcrc</i> pre-conditions and
305 78e51a8c 2005-01-14 devnull post-conditions <i>crc</i> by ones complementation.
306 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
308 78e51a8c 2005-01-14 devnull <i>Adler32</i> updates the Adler 32-bit checksum of the <i>n</i> butes of data
309 78e51a8c 2005-01-14 devnull in <i>buf.</i> The initial value of <i>adler</i> (that is, its value after seeing
310 78e51a8c 2005-01-14 devnull zero bytes) should be 1.<br>
312 78e51a8c 2005-01-14 devnull </table>
313 78e51a8c 2005-01-14 devnull <p><font size=+1><b>SOURCE </b></font><br>
315 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
317 78e51a8c 2005-01-14 devnull <tt><font size=+1>/usr/local/plan9/src/libflate<br>
318 78e51a8c 2005-01-14 devnull </font></tt>
319 78e51a8c 2005-01-14 devnull </table>
321 78e51a8c 2005-01-14 devnull <td width=20>
322 78e51a8c 2005-01-14 devnull <tr height=20><td>
323 78e51a8c 2005-01-14 devnull </table>
324 78e51a8c 2005-01-14 devnull <!-- TRAILER -->
325 78e51a8c 2005-01-14 devnull <table border=0 cellpadding=0 cellspacing=0 width=100%>
326 78e51a8c 2005-01-14 devnull <tr height=15><td width=10><td><td width=10>
327 78e51a8c 2005-01-14 devnull <tr><td><td>
328 78e51a8c 2005-01-14 devnull <center>
329 78e51a8c 2005-01-14 devnull <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
330 78e51a8c 2005-01-14 devnull </center>
331 78e51a8c 2005-01-14 devnull </table>
332 78e51a8c 2005-01-14 devnull <!-- TRAILER -->
333 78e51a8c 2005-01-14 devnull </body></html>