Blob


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