Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / Compress::Raw::Zlib.3pm
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "Compress::Raw::Zlib 3"
132 .TH Compress::Raw::Zlib 3 "2009-11-09" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 Compress::Raw::Zlib \- Low\-Level Interface to zlib compression library
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 1
138 \&    use Compress::Raw::Zlib ;
139 .Ve
140 .PP
141 .Vb 15
142 \&    ($d, $status) = new Compress::Raw::Zlib::Deflate( [OPT] ) ;
143 \&    $status = $d\->deflate($input, $output) ;
144 \&    $status = $d\->flush($output [, $flush_type]) ;
145 \&    $d\->deflateReset() ;
146 \&    $d\->deflateParams(OPTS) ;
147 \&    $d\->deflateTune(OPTS) ;
148 \&    $d\->dict_adler() ;
149 \&    $d\->crc32() ;
150 \&    $d\->adler32() ;
151 \&    $d\->total_in() ;
152 \&    $d\->total_out() ;
153 \&    $d\->msg() ;
154 \&    $d\->get_Strategy();
155 \&    $d\->get_Level();
156 \&    $d\->get_BufSize();
157 .Ve
158 .PP
159 .Vb 10
160 \&    ($i, $status) = new Compress::Raw::Zlib::Inflate( [OPT] ) ;
161 \&    $status = $i\->inflate($input, $output [, $eof]) ;
162 \&    $status = $i\->inflateSync($input) ;
163 \&    $i\->dict_adler() ;
164 \&    $d\->crc32() ;
165 \&    $d\->adler32() ;
166 \&    $i\->total_in() ;
167 \&    $i\->total_out() ;
168 \&    $i\->msg() ;
169 \&    $d\->get_BufSize();
170 .Ve
171 .PP
172 .Vb 2
173 \&    $crc = adler32($buffer [,$crc]) ;
174 \&    $crc = crc32($buffer [,$crc]) ;
175 .Ve
176 .PP
177 .Vb 2
178 \&    $crc = adler32_combine($crc1, $crc2, $len2)l
179 \&    $crc = crc32_combine($adler1, $adler2, $len2)
180 .Ve
181 .PP
182 .Vb 1
183 \&    my $version = Compress::Raw::Zlib::zlib_version();
184 .Ve
185 .SH "DESCRIPTION"
186 .IX Header "DESCRIPTION"
187 The \fICompress::Raw::Zlib\fR module provides a Perl interface to the \fIzlib\fR
188 compression library (see \*(L"\s-1AUTHOR\s0\*(R" for details about where to get
189 \&\fIzlib\fR). 
190 .SH "Compress::Raw::Zlib::Deflate"
191 .IX Header "Compress::Raw::Zlib::Deflate"
192 This section defines an interface that allows in-memory compression using
193 the \fIdeflate\fR interface provided by zlib.
194 .PP
195 Here is a definition of the interface available:
196 .ie n .Sh "\fB($d, \fP\fB$status\fP\fB) = new Compress::Raw::Zlib::Deflate( [\s-1OPT\s0] ) \fP"
197 .el .Sh "\fB($d, \fP\f(CB$status\fP\fB) = new Compress::Raw::Zlib::Deflate( [\s-1OPT\s0] ) \fP"
198 .IX Subsection "($d, $status) = new Compress::Raw::Zlib::Deflate( [OPT] ) "
199 Initialises a deflation object. 
200 .PP
201 If you are familiar with the \fIzlib\fR library, it combines the
202 features of the \fIzlib\fR functions \f(CW\*(C`deflateInit\*(C'\fR, \f(CW\*(C`deflateInit2\*(C'\fR
203 and \f(CW\*(C`deflateSetDictionary\*(C'\fR.
204 .PP
205 If successful, it will return the initialised deflation object, \f(CW$d\fR
206 and a \f(CW$status\fR of \f(CW\*(C`Z_OK\*(C'\fR in a list context. In scalar context it
207 returns the deflation object, \f(CW$d\fR, only.
208 .PP
209 If not successful, the returned deflation object, \f(CW$d\fR, will be
210 \&\fIundef\fR and \f(CW$status\fR will hold the a \fIzlib\fR error code.
211 .PP
212 The function optionally takes a number of named options specified as
213 \&\f(CW\*(C`Name => value\*(C'\fR pairs. This allows individual options to be
214 tailored without having to specify them all in the parameter list.
215 .PP
216 For backward compatibility, it is also possible to pass the parameters
217 as a reference to a hash containing the name=>value pairs.
218 .PP
219 Below is a list of the valid options:
220 .IP "\fB\-Level\fR" 5
221 .IX Item "-Level"
222 Defines the compression level. Valid values are 0 through 9,
223 \&\f(CW\*(C`Z_NO_COMPRESSION\*(C'\fR, \f(CW\*(C`Z_BEST_SPEED\*(C'\fR, \f(CW\*(C`Z_BEST_COMPRESSION\*(C'\fR, and
224 \&\f(CW\*(C`Z_DEFAULT_COMPRESSION\*(C'\fR.
225 .Sp
226 The default is \f(CW\*(C`Z_DEFAULT_COMPRESSION\*(C'\fR.
227 .IP "\fB\-Method\fR" 5
228 .IX Item "-Method"
229 Defines the compression method. The only valid value at present (and
230 the default) is Z_DEFLATED.
231 .IP "\fB\-WindowBits\fR" 5
232 .IX Item "-WindowBits"
233 To compress an \s-1RFC\s0 1950 data stream, set \f(CW\*(C`WindowBits\*(C'\fR to a positive
234 number between 8 and 15.
235 .Sp
236 To compress an \s-1RFC\s0 1951 data stream, set \f(CW\*(C`WindowBits\*(C'\fR to \f(CW\*(C`\-MAX_WBITS\*(C'\fR.
237 .Sp
238 To compress an \s-1RFC\s0 1952 data stream (i.e. gzip), set \f(CW\*(C`WindowBits\*(C'\fR to
239 \&\f(CW\*(C`WANT_GZIP\*(C'\fR.
240 .Sp
241 For a definition of the meaning and valid values for \f(CW\*(C`WindowBits\*(C'\fR
242 refer to the \fIzlib\fR documentation for \fIdeflateInit2\fR.
243 .Sp
244 Defaults to \f(CW\*(C`MAX_WBITS\*(C'\fR.
245 .IP "\fB\-MemLevel\fR" 5
246 .IX Item "-MemLevel"
247 For a definition of the meaning and valid values for \f(CW\*(C`MemLevel\*(C'\fR
248 refer to the \fIzlib\fR documentation for \fIdeflateInit2\fR.
249 .Sp
250 Defaults to \s-1MAX_MEM_LEVEL\s0.
251 .IP "\fB\-Strategy\fR" 5
252 .IX Item "-Strategy"
253 Defines the strategy used to tune the compression. The valid values are
254 \&\f(CW\*(C`Z_DEFAULT_STRATEGY\*(C'\fR, \f(CW\*(C`Z_FILTERED\*(C'\fR, \f(CW\*(C`Z_RLE\*(C'\fR, \f(CW\*(C`Z_FIXED\*(C'\fR and
255 \&\f(CW\*(C`Z_HUFFMAN_ONLY\*(C'\fR.
256 .Sp
257 The default is Z_DEFAULT_STRATEGY.
258 .IP "\fB\-Dictionary\fR" 5
259 .IX Item "-Dictionary"
260 When a dictionary is specified \fICompress::Raw::Zlib\fR will automatically
261 call \f(CW\*(C`deflateSetDictionary\*(C'\fR directly after calling \f(CW\*(C`deflateInit\*(C'\fR. The
262 Adler32 value for the dictionary can be obtained by calling the method 
263 \&\f(CW\*(C`$d\->dict_adler()\*(C'\fR.
264 .Sp
265 The default is no dictionary.
266 .IP "\fB\-Bufsize\fR" 5
267 .IX Item "-Bufsize"
268 Sets the initial size for the output buffer used by the \f(CW\*(C`$d\->deflate\*(C'\fR
269 and \f(CW\*(C`$d\->flush\*(C'\fR methods. If the buffer has to be
270 reallocated to increase the size, it will grow in increments of
271 \&\f(CW\*(C`Bufsize\*(C'\fR.
272 .Sp
273 The default buffer size is 4096.
274 .IP "\fB\-AppendOutput\fR" 5
275 .IX Item "-AppendOutput"
276 This option controls how data is written to the output buffer by the
277 \&\f(CW\*(C`$d\->deflate\*(C'\fR and \f(CW\*(C`$d\->flush\*(C'\fR methods.
278 .Sp
279 If the \f(CW\*(C`AppendOutput\*(C'\fR option is set to false, the output buffers in the
280 \&\f(CW\*(C`$d\->deflate\*(C'\fR and \f(CW\*(C`$d\->flush\*(C'\fR  methods will be truncated before
281 uncompressed data is written to them.
282 .Sp
283 If the option is set to true, uncompressed data will be appended to the
284 output buffer in the \f(CW\*(C`$d\->deflate\*(C'\fR and \f(CW\*(C`$d\->flush\*(C'\fR methods.
285 .Sp
286 This option defaults to false.
287 .IP "\fB\-CRC32\fR" 5
288 .IX Item "-CRC32"
289 If set to true, a crc32 checksum of the uncompressed data will be
290 calculated. Use the \f(CW\*(C`$d\->crc32\*(C'\fR method to retrieve this value.
291 .Sp
292 This option defaults to false.
293 .IP "\fB\-ADLER32\fR" 5
294 .IX Item "-ADLER32"
295 If set to true, an adler32 checksum of the uncompressed data will be
296 calculated. Use the \f(CW\*(C`$d\->adler32\*(C'\fR method to retrieve this value.
297 .Sp
298 This option defaults to false.
299 .PP
300 Here is an example of using the \f(CW\*(C`Compress::Raw::Zlib::Deflate\*(C'\fR optional
301 parameter list to override the default buffer size and compression
302 level. All other options will take their default values.
303 .PP
304 .Vb 2
305 \&    my $d = new Compress::Raw::Zlib::Deflate ( \-Bufsize => 300, 
306 \&                                               \-Level   => Z_BEST_SPEED ) ;
307 .Ve
308 .ie n .Sh "\fB$status = \fP\fB$d\fP\fB\->deflate($input, \fP\f(BI$output\fP\fB)\fP"
309 .el .Sh "\fB$status = \fP\f(CB$d\fP\fB\->deflate($input, \fP\f(CB$output\fP\fB)\fP"
310 .IX Subsection "$status = $d->deflate($input, $output)"
311 Deflates the contents of \f(CW$input\fR and writes the compressed data to
312 \&\f(CW$output\fR.
313 .PP
314 The \f(CW$input\fR and \f(CW$output\fR parameters can be either scalars or scalar
315 references.
316 .PP
317 When finished, \f(CW$input\fR will be completely processed (assuming there
318 were no errors). If the deflation was successful it writes the deflated
319 data to \f(CW$output\fR and returns a status value of \f(CW\*(C`Z_OK\*(C'\fR.
320 .PP
321 On error, it returns a \fIzlib\fR error code.
322 .PP
323 If the \f(CW\*(C`AppendOutput\*(C'\fR option is set to true in the constructor for
324 the \f(CW$d\fR object, the compressed data will be appended to \f(CW$output\fR. If
325 it is false, \f(CW$output\fR will be truncated before any compressed data is
326 written to it.
327 .PP
328 \&\fBNote\fR: This method will not necessarily write compressed data to
329 \&\f(CW$output\fR every time it is called. So do not assume that there has been
330 an error if the contents of \f(CW$output\fR is empty on returning from
331 this method. As long as the return code from the method is \f(CW\*(C`Z_OK\*(C'\fR,
332 the deflate has succeeded.
333 .ie n .Sh "\fB$status = \fP\fB$d\fP\fB\->flush($output [, \fP\f(BI$flush_type\fP\fB]) \fP"
334 .el .Sh "\fB$status = \fP\f(CB$d\fP\fB\->flush($output [, \fP\f(CB$flush_type\fP\fB]) \fP"
335 .IX Subsection "$status = $d->flush($output [, $flush_type]) "
336 Typically used to finish the deflation. Any pending output will be
337 written to \f(CW$output\fR.
338 .PP
339 Returns \f(CW\*(C`Z_OK\*(C'\fR if successful.
340 .PP
341 Note that flushing can seriously degrade the compression ratio, so it
342 should only be used to terminate a decompression (using \f(CW\*(C`Z_FINISH\*(C'\fR) or
343 when you want to create a \fIfull flush point\fR (using \f(CW\*(C`Z_FULL_FLUSH\*(C'\fR).
344 .PP
345 By default the \f(CW\*(C`flush_type\*(C'\fR used is \f(CW\*(C`Z_FINISH\*(C'\fR. Other valid values
346 for \f(CW\*(C`flush_type\*(C'\fR are \f(CW\*(C`Z_NO_FLUSH\*(C'\fR, \f(CW\*(C`Z_PARTIAL_FLUSH\*(C'\fR, \f(CW\*(C`Z_SYNC_FLUSH\*(C'\fR
347 and \f(CW\*(C`Z_FULL_FLUSH\*(C'\fR. It is strongly recommended that you only set the
348 \&\f(CW\*(C`flush_type\*(C'\fR parameter if you fully understand the implications of
349 what it does. See the \f(CW\*(C`zlib\*(C'\fR documentation for details.
350 .PP
351 If the \f(CW\*(C`AppendOutput\*(C'\fR option is set to true in the constructor for
352 the \f(CW$d\fR object, the compressed data will be appended to \f(CW$output\fR. If
353 it is false, \f(CW$output\fR will be truncated before any compressed data is
354 written to it.
355 .ie n .Sh "\fB$status = \fP\fB$d\fP\fB\->\fP\f(BIdeflateReset()\fP\fB \fP"
356 .el .Sh "\fB$status = \fP\f(CB$d\fP\fB\->\fP\f(BIdeflateReset()\fP\fB \fP"
357 .IX Subsection "$status = $d->deflateReset() "
358 This method will reset the deflation object \f(CW$d\fR. It can be used when you
359 are compressing multiple data streams and want to use the same object to
360 compress each of them. It should only be used once the previous data stream
361 has been flushed successfully, i.e. a call to \f(CW\*(C`$d\->flush(Z_FINISH)\*(C'\fR has
362 returned \f(CW\*(C`Z_OK\*(C'\fR.
363 .PP
364 Returns \f(CW\*(C`Z_OK\*(C'\fR if successful.
365 .ie n .Sh "\fB$status = \fP\fB$d\fP\fB\->deflateParams([\s-1OPT\s0])\fP"
366 .el .Sh "\fB$status = \fP\f(CB$d\fP\fB\->deflateParams([\s-1OPT\s0])\fP"
367 .IX Subsection "$status = $d->deflateParams([OPT])"
368 Change settings for the deflate object \f(CW$d\fR.
369 .PP
370 The list of the valid options is shown below. Options not specified
371 will remain unchanged.
372 .IP "\fB\-Level\fR" 5
373 .IX Item "-Level"
374 Defines the compression level. Valid values are 0 through 9,
375 \&\f(CW\*(C`Z_NO_COMPRESSION\*(C'\fR, \f(CW\*(C`Z_BEST_SPEED\*(C'\fR, \f(CW\*(C`Z_BEST_COMPRESSION\*(C'\fR, and
376 \&\f(CW\*(C`Z_DEFAULT_COMPRESSION\*(C'\fR.
377 .IP "\fB\-Strategy\fR" 5
378 .IX Item "-Strategy"
379 Defines the strategy used to tune the compression. The valid values are
380 \&\f(CW\*(C`Z_DEFAULT_STRATEGY\*(C'\fR, \f(CW\*(C`Z_FILTERED\*(C'\fR and \f(CW\*(C`Z_HUFFMAN_ONLY\*(C'\fR. 
381 .IP "\fB\-BufSize\fR" 5
382 .IX Item "-BufSize"
383 Sets the initial size for the output buffer used by the \f(CW\*(C`$d\->deflate\*(C'\fR
384 and \f(CW\*(C`$d\->flush\*(C'\fR methods. If the buffer has to be
385 reallocated to increase the size, it will grow in increments of
386 \&\f(CW\*(C`Bufsize\*(C'\fR.
387 .ie n .Sh "\fB$status = \fP\fB$d\fP\fB\->deflateTune($good_length, \fP\f(BI$max_lazy\fP\fB, \fP\f(CB$nice_length\fP\fB, \fP\f(CB$max_chain\fP\fB)\fP"
388 .el .Sh "\fB$status = \fP\f(CB$d\fP\fB\->deflateTune($good_length, \fP\f(CB$max_lazy\fP\fB, \fP\f(CB$nice_length\fP\fB, \fP\f(CB$max_chain\fP\fB)\fP"
389 .IX Subsection "$status = $d->deflateTune($good_length, $max_lazy, $nice_length, $max_chain)"
390 Tune the internal settings for the deflate object \f(CW$d\fR. This option is
391 only available if you are running zlib 1.2.2.3 or better.
392 .PP
393 Refer to the documentation in zlib.h for instructions on how to fly
394 \&\f(CW\*(C`deflateTune\*(C'\fR.
395 .Sh "\fB$d\->\fP\f(BIdict_adler()\fP\fB\fP"
396 .IX Subsection "$d->dict_adler()"
397 Returns the adler32 value for the dictionary.
398 .Sh "\fB$d\->\fP\f(BIcrc32()\fP\fB\fP"
399 .IX Subsection "$d->crc32()"
400 Returns the crc32 value for the uncompressed data to date. 
401 .PP
402 If the \f(CW\*(C`CRC32\*(C'\fR option is not enabled in the constructor for this object,
403 this method will always return 0;
404 .Sh "\fB$d\->\fP\f(BIadler32()\fP\fB\fP"
405 .IX Subsection "$d->adler32()"
406 Returns the adler32 value for the uncompressed data to date. 
407 .Sh "\fB$d\->\fP\f(BImsg()\fP\fB\fP"
408 .IX Subsection "$d->msg()"
409 Returns the last error message generated by zlib.
410 .Sh "\fB$d\->\fP\f(BItotal_in()\fP\fB\fP"
411 .IX Subsection "$d->total_in()"
412 Returns the total number of bytes uncompressed bytes input to deflate.
413 .Sh "\fB$d\->\fP\f(BItotal_out()\fP\fB\fP"
414 .IX Subsection "$d->total_out()"
415 Returns the total number of compressed bytes output from deflate.
416 .Sh "\fB$d\->\fP\f(BIget_Strategy()\fP\fB\fP"
417 .IX Subsection "$d->get_Strategy()"
418 Returns the deflation strategy currently used. Valid values are
419 \&\f(CW\*(C`Z_DEFAULT_STRATEGY\*(C'\fR, \f(CW\*(C`Z_FILTERED\*(C'\fR and \f(CW\*(C`Z_HUFFMAN_ONLY\*(C'\fR. 
420 .Sh "\fB$d\->\fP\f(BIget_Level()\fP\fB\fP"
421 .IX Subsection "$d->get_Level()"
422 Returns the compression level being used. 
423 .Sh "\fB$d\->\fP\f(BIget_BufSize()\fP\fB\fP"
424 .IX Subsection "$d->get_BufSize()"
425 Returns the buffer size used to carry out the compression.
426 .Sh "Example"
427 .IX Subsection "Example"
428 Here is a trivial example of using \f(CW\*(C`deflate\*(C'\fR. It simply reads standard
429 input, deflates it and writes it to standard output.
430 .PP
431 .Vb 2
432 \&    use strict ;
433 \&    use warnings ;
434 .Ve
435 .PP
436 .Vb 1
437 \&    use Compress::Raw::Zlib ;
438 .Ve
439 .PP
440 .Vb 4
441 \&    binmode STDIN;
442 \&    binmode STDOUT;
443 \&    my $x = new Compress::Raw::Zlib::Deflate
444 \&       or die "Cannot create a deflation stream\en" ;
445 .Ve
446 .PP
447 .Vb 4
448 \&    my ($output, $status) ;
449 \&    while (<>)
450 \&    {
451 \&        $status = $x\->deflate($_, $output) ;
452 .Ve
453 .PP
454 .Vb 2
455 \&        $status == Z_OK
456 \&            or die "deflation failed\en" ;
457 .Ve
458 .PP
459 .Vb 2
460 \&        print $output ;
461 \&    }
462 .Ve
463 .PP
464 .Vb 1
465 \&    $status = $x\->flush($output) ;
466 .Ve
467 .PP
468 .Vb 2
469 \&    $status == Z_OK
470 \&        or die "deflation failed\en" ;
471 .Ve
472 .PP
473 .Vb 1
474 \&    print $output ;
475 .Ve
476 .SH "Compress::Raw::Zlib::Inflate"
477 .IX Header "Compress::Raw::Zlib::Inflate"
478 This section defines an interface that allows in-memory uncompression using
479 the \fIinflate\fR interface provided by zlib.
480 .PP
481 Here is a definition of the interface:
482 .ie n .Sh "\fB ($i, \fP\fB$status\fP\fB) = new Compress::Raw::Zlib::Inflate( [\s-1OPT\s0] ) \fP"
483 .el .Sh "\fB ($i, \fP\f(CB$status\fP\fB) = new Compress::Raw::Zlib::Inflate( [\s-1OPT\s0] ) \fP"
484 .IX Subsection " ($i, $status) = new Compress::Raw::Zlib::Inflate( [OPT] ) "
485 Initialises an inflation object. 
486 .PP
487 In a list context it returns the inflation object, \f(CW$i\fR, and the
488 \&\fIzlib\fR status code (\f(CW$status\fR). In a scalar context it returns the
489 inflation object only.
490 .PP
491 If successful, \f(CW$i\fR will hold the inflation object and \f(CW$status\fR will
492 be \f(CW\*(C`Z_OK\*(C'\fR.
493 .PP
494 If not successful, \f(CW$i\fR will be \fIundef\fR and \f(CW$status\fR will hold the
495 \&\fIzlib\fR error code.
496 .PP
497 The function optionally takes a number of named options specified as
498 \&\f(CW\*(C`\-Name => value\*(C'\fR pairs. This allows individual options to be
499 tailored without having to specify them all in the parameter list.
500 .PP
501 For backward compatibility, it is also possible to pass the parameters
502 as a reference to a hash containing the \f(CW\*(C`name=>value\*(C'\fR pairs.
503 .PP
504 Here is a list of the valid options:
505 .IP "\fB\-WindowBits\fR" 5
506 .IX Item "-WindowBits"
507 To uncompress an \s-1RFC\s0 1950 data stream, set \f(CW\*(C`WindowBits\*(C'\fR to a positive
508 number between 8 and 15.
509 .Sp
510 To uncompress an \s-1RFC\s0 1951 data stream, set \f(CW\*(C`WindowBits\*(C'\fR to \f(CW\*(C`\-MAX_WBITS\*(C'\fR.
511 .Sp
512 To uncompress an \s-1RFC\s0 1952 data stream (i.e. gzip), set \f(CW\*(C`WindowBits\*(C'\fR to
513 \&\f(CW\*(C`WANT_GZIP\*(C'\fR.
514 .Sp
515 To auto-detect and uncompress an \s-1RFC\s0 1950 or \s-1RFC\s0 1952 data stream (i.e.
516 gzip), set \f(CW\*(C`WindowBits\*(C'\fR to \f(CW\*(C`WANT_GZIP_OR_ZLIB\*(C'\fR.
517 .Sp
518 For a full definition of the meaning and valid values for \f(CW\*(C`WindowBits\*(C'\fR
519 refer to the \fIzlib\fR documentation for \fIinflateInit2\fR.
520 .Sp
521 Defaults to \f(CW\*(C`MAX_WBITS\*(C'\fR.
522 .IP "\fB\-Bufsize\fR" 5
523 .IX Item "-Bufsize"
524 Sets the initial size for the output buffer used by the \f(CW\*(C`$i\->inflate\*(C'\fR
525 method. If the output buffer in this method has to be reallocated to
526 increase the size, it will grow in increments of \f(CW\*(C`Bufsize\*(C'\fR.
527 .Sp
528 Default is 4096.
529 .IP "\fB\-Dictionary\fR" 5
530 .IX Item "-Dictionary"
531 The default is no dictionary.
532 .IP "\fB\-AppendOutput\fR" 5
533 .IX Item "-AppendOutput"
534 This option controls how data is written to the output buffer by the
535 \&\f(CW\*(C`$i\->inflate\*(C'\fR method.
536 .Sp
537 If the option is set to false, the output buffer in the \f(CW\*(C`$i\->inflate\*(C'\fR
538 method will be truncated before uncompressed data is written to it.
539 .Sp
540 If the option is set to true, uncompressed data will be appended to the
541 output buffer by the \f(CW\*(C`$i\->inflate\*(C'\fR method.
542 .Sp
543 This option defaults to false.
544 .IP "\fB\-CRC32\fR" 5
545 .IX Item "-CRC32"
546 If set to true, a crc32 checksum of the uncompressed data will be
547 calculated. Use the \f(CW\*(C`$i\->crc32\*(C'\fR method to retrieve this value.
548 .Sp
549 This option defaults to false.
550 .IP "\fB\-ADLER32\fR" 5
551 .IX Item "-ADLER32"
552 If set to true, an adler32 checksum of the uncompressed data will be
553 calculated. Use the \f(CW\*(C`$i\->adler32\*(C'\fR method to retrieve this value.
554 .Sp
555 This option defaults to false.
556 .IP "\fB\-ConsumeInput\fR" 5
557 .IX Item "-ConsumeInput"
558 If set to true, this option will remove compressed data from the input
559 buffer of the \f(CW\*(C`$i\->inflate\*(C'\fR method as the inflate progresses.
560 .Sp
561 This option can be useful when you are processing compressed data that is
562 embedded in another file/buffer. In this case the data that immediately
563 follows the compressed stream will be left in the input buffer.
564 .Sp
565 This option defaults to true.
566 .IP "\fB\-LimitOutput\fR" 5
567 .IX Item "-LimitOutput"
568 The \f(CW\*(C`LimitOutput\*(C'\fR option changes the behavior of the \f(CW\*(C`$i\->inflate\*(C'\fR
569 method so that the amount of memory used by the output buffer can be
570 limited. 
571 .Sp
572 When \f(CW\*(C`LimitOutput\*(C'\fR is used the size of the output buffer used will either
573 be the value of the \f(CW\*(C`Bufsize\*(C'\fR option or the amount of memory already
574 allocated to \f(CW$output\fR, whichever is larger. Predicting the output size
575 available is tricky, so don't rely on getting an exact output buffer size.
576 .Sp
577 When \f(CW\*(C`LimitOutout\*(C'\fR is not specified \f(CW\*(C`$i\->inflate\*(C'\fR will use as much
578 memory as it takes to write all the uncompressed data it creates by
579 uncompressing the input buffer.
580 .Sp
581 If \f(CW\*(C`LimitOutput\*(C'\fR is enabled, the \f(CW\*(C`ConsumeInput\*(C'\fR option will also be
582 enabled.
583 .Sp
584 This option defaults to false.
585 .Sp
586 See \*(L"The LimitOutput option\*(R" for a discussion on why \f(CW\*(C`LimitOutput\*(C'\fR is
587 needed and how to use it.
588 .PP
589 Here is an example of using an optional parameter to override the default
590 buffer size.
591 .PP
592 .Vb 1
593 \&    my ($i, $status) = new Compress::Raw::Zlib::Inflate( \-Bufsize => 300 ) ;
594 .Ve
595 .ie n .Sh "\fB \fP\fB$status\fP\fB = \fP\f(BI$i\fP\fB\->inflate($input, \fP\f(CB$output\fP\fB [,$eof]) \fP"
596 .el .Sh "\fB \fP\f(CB$status\fP\fB = \fP\f(CB$i\fP\fB\->inflate($input, \fP\f(CB$output\fP\fB [,$eof]) \fP"
597 .IX Subsection " $status = $i->inflate($input, $output [,$eof]) "
598 Inflates the complete contents of \f(CW$input\fR and writes the uncompressed
599 data to \f(CW$output\fR. The \f(CW$input\fR and \f(CW$output\fR parameters can either be
600 scalars or scalar references.
601 .PP
602 Returns \f(CW\*(C`Z_OK\*(C'\fR if successful and \f(CW\*(C`Z_STREAM_END\*(C'\fR if the end of the
603 compressed data has been successfully reached. 
604 .PP
605 If not successful \f(CW$status\fR will hold the \fIzlib\fR error code.
606 .PP
607 If the \f(CW\*(C`ConsumeInput\*(C'\fR option has been set to true when the
608 \&\f(CW\*(C`Compress::Raw::Zlib::Inflate\*(C'\fR object is created, the \f(CW$input\fR parameter
609 is modified by \f(CW\*(C`inflate\*(C'\fR. On completion it will contain what remains
610 of the input buffer after inflation. In practice, this means that when
611 the return status is \f(CW\*(C`Z_OK\*(C'\fR the \f(CW$input\fR parameter will contain an
612 empty string, and when the return status is \f(CW\*(C`Z_STREAM_END\*(C'\fR the \f(CW$input\fR
613 parameter will contains what (if anything) was stored in the input buffer
614 after the deflated data stream.
615 .PP
616 This feature is useful when processing a file format that encapsulates
617 a compressed data stream (e.g. gzip, zip) and there is useful data
618 immediately after the deflation stream.
619 .PP
620 If the \f(CW\*(C`AppendOutput\*(C'\fR option is set to true in the constructor for
621 this object, the uncompressed data will be appended to \f(CW$output\fR. If
622 it is false, \f(CW$output\fR will be truncated before any uncompressed data
623 is written to it.
624 .PP
625 The \f(CW$eof\fR parameter needs a bit of explanation. 
626 .PP
627 Prior to version 1.2.0, zlib assumed that there was at least one trailing
628 byte immediately after the compressed data stream when it was carrying out
629 decompression. This normally isn't a problem because the majority of zlib
630 applications guarantee that there will be data directly after the
631 compressed data stream.  For example, both gzip (\s-1RFC\s0 1950) and zip both
632 define trailing data that follows the compressed data stream.
633 .PP
634 The \f(CW$eof\fR parameter only needs to be used if \fBall\fR of the following
635 conditions apply
636 .IP "1" 5
637 .IX Item "1"
638 You are either using a copy of zlib that is older than version 1.2.0 or you
639 want your application code to be able to run with as many different
640 versions of zlib as possible.
641 .IP "2" 5
642 .IX Item "2"
643 You have set the \f(CW\*(C`WindowBits\*(C'\fR parameter to \f(CW\*(C`\-MAX_WBITS\*(C'\fR in the constructor
644 for this object, i.e. you are uncompressing a raw deflated data stream
645 (\s-1RFC\s0 1951).
646 .IP "3" 5
647 .IX Item "3"
648 There is no data immediately after the compressed data stream.
649 .PP
650 If \fBall\fR of these are the case, then you need to set the \f(CW$eof\fR parameter
651 to true on the final call (and only the final call) to \f(CW\*(C`$i\->inflate\*(C'\fR. 
652 .PP
653 If you have built this module with zlib >= 1.2.0, the \f(CW$eof\fR parameter is
654 ignored. You can still set it if you want, but it won't be used behind the
655 scenes.
656 .ie n .Sh "\fB$status = \fP\fB$i\fP\fB\->inflateSync($input)\fP"
657 .el .Sh "\fB$status = \fP\f(CB$i\fP\fB\->inflateSync($input)\fP"
658 .IX Subsection "$status = $i->inflateSync($input)"
659 This method can be used to attempt to recover good data from a compressed
660 data stream that is partially corrupt.
661 It scans \f(CW$input\fR until it reaches either a \fIfull flush point\fR or the
662 end of the buffer.
663 .PP
664 If a \fIfull flush point\fR is found, \f(CW\*(C`Z_OK\*(C'\fR is returned and \f(CW$input\fR
665 will be have all data up to the flush point removed. This data can then be
666 passed to the \f(CW\*(C`$i\->inflate\*(C'\fR method to be uncompressed.
667 .PP
668 Any other return code means that a flush point was not found. If more
669 data is available, \f(CW\*(C`inflateSync\*(C'\fR can be called repeatedly with more
670 compressed data until the flush point is found.
671 .PP
672 Note \fIfull flush points\fR are not present by default in compressed
673 data streams. They must have been added explicitly when the data stream
674 was created by calling \f(CW\*(C`Compress::Deflate::flush\*(C'\fR  with \f(CW\*(C`Z_FULL_FLUSH\*(C'\fR.
675 .Sh "\fB$i\->\fP\f(BIdict_adler()\fP\fB\fP"
676 .IX Subsection "$i->dict_adler()"
677 Returns the adler32 value for the dictionary.
678 .Sh "\fB$i\->\fP\f(BIcrc32()\fP\fB\fP"
679 .IX Subsection "$i->crc32()"
680 Returns the crc32 value for the uncompressed data to date.
681 .PP
682 If the \f(CW\*(C`CRC32\*(C'\fR option is not enabled in the constructor for this object,
683 this method will always return 0;
684 .Sh "\fB$i\->\fP\f(BIadler32()\fP\fB\fP"
685 .IX Subsection "$i->adler32()"
686 Returns the adler32 value for the uncompressed data to date.
687 .PP
688 If the \f(CW\*(C`ADLER32\*(C'\fR option is not enabled in the constructor for this object,
689 this method will always return 0;
690 .Sh "\fB$i\->\fP\f(BImsg()\fP\fB\fP"
691 .IX Subsection "$i->msg()"
692 Returns the last error message generated by zlib.
693 .Sh "\fB$i\->\fP\f(BItotal_in()\fP\fB\fP"
694 .IX Subsection "$i->total_in()"
695 Returns the total number of bytes compressed bytes input to inflate.
696 .Sh "\fB$i\->\fP\f(BItotal_out()\fP\fB\fP"
697 .IX Subsection "$i->total_out()"
698 Returns the total number of uncompressed bytes output from inflate.
699 .Sh "\fB$d\->\fP\f(BIget_BufSize()\fP\fB\fP"
700 .IX Subsection "$d->get_BufSize()"
701 Returns the buffer size used to carry out the decompression.
702 .Sh "Examples"
703 .IX Subsection "Examples"
704 Here is an example of using \f(CW\*(C`inflate\*(C'\fR.
705 .PP
706 .Vb 2
707 \&    use strict ;
708 \&    use warnings ;
709 .Ve
710 .PP
711 .Vb 1
712 \&    use Compress::Raw::Zlib;
713 .Ve
714 .PP
715 .Vb 2
716 \&    my $x = new Compress::Raw::Zlib::Inflate()
717 \&       or die "Cannot create a inflation stream\en" ;
718 .Ve
719 .PP
720 .Vb 3
721 \&    my $input = '' ;
722 \&    binmode STDIN;
723 \&    binmode STDOUT;
724 .Ve
725 .PP
726 .Vb 4
727 \&    my ($output, $status) ;
728 \&    while (read(STDIN, $input, 4096))
729 \&    {
730 \&        $status = $x\->inflate($input, $output) ;
731 .Ve
732 .PP
733 .Vb 1
734 \&        print $output ;
735 .Ve
736 .PP
737 .Vb 2
738 \&        last if $status != Z_OK ;
739 \&    }
740 .Ve
741 .PP
742 .Vb 2
743 \&    die "inflation failed\en"
744 \&        unless $status == Z_STREAM_END ;
745 .Ve
746 .PP
747 The next example show how to use the \f(CW\*(C`LimitOutput\*(C'\fR option. Notice the use
748 of two nested loops in this case. The outer loop reads the data from the
749 input source \- \s-1STDIN\s0 and the inner loop repeatedly calls \f(CW\*(C`inflate\*(C'\fR until
750 \&\f(CW$input\fR is exhausted, we get an error, or the end of the stream is
751 reached. One point worth remembering is by using the \f(CW\*(C`LimitOutput\*(C'\fR option
752 you also get \f(CW\*(C`ConsumeInput\*(C'\fR set as well \- this makes the code below much
753 simpler.
754 .PP
755 .Vb 2
756 \&    use strict ;
757 \&    use warnings ;
758 .Ve
759 .PP
760 .Vb 1
761 \&    use Compress::Raw::Zlib;
762 .Ve
763 .PP
764 .Vb 2
765 \&    my $x = new Compress::Raw::Zlib::Inflate(LimitOutput => 1)
766 \&       or die "Cannot create a inflation stream\en" ;
767 .Ve
768 .PP
769 .Vb 3
770 \&    my $input = '' ;
771 \&    binmode STDIN;
772 \&    binmode STDOUT;
773 .Ve
774 .PP
775 .Vb 1
776 \&    my ($output, $status) ;
777 .Ve
778 .PP
779 .Vb 6
780 \&  OUTER:
781 \&    while (read(STDIN, $input, 4096))
782 \&    {
783 \&        do
784 \&        {
785 \&            $status = $x\->inflate($input, $output) ;
786 .Ve
787 .PP
788 .Vb 1
789 \&            print $output ;
790 .Ve
791 .PP
792 .Vb 5
793 \&            last OUTER
794 \&                unless $status == Z_OK || $status == Z_BUF_ERROR ;
795 \&        }
796 \&        while ($status == Z_OK && length $input);
797 \&    }
798 .Ve
799 .PP
800 .Vb 2
801 \&    die "inflation failed\en"
802 \&        unless $status == Z_STREAM_END ;
803 .Ve
804 .SH "CHECKSUM FUNCTIONS"
805 .IX Header "CHECKSUM FUNCTIONS"
806 Two functions are provided by \fIzlib\fR to calculate checksums. For the
807 Perl interface, the order of the two parameters in both functions has
808 been reversed. This allows both running checksums and one off
809 calculations to be done.
810 .PP
811 .Vb 2
812 \&    $crc = adler32($buffer [,$crc]) ;
813 \&    $crc = crc32($buffer [,$crc]) ;
814 .Ve
815 .PP
816 The buffer parameters can either be a scalar or a scalar reference.
817 .PP
818 If the \f(CW$crc\fR parameters is \f(CW\*(C`undef\*(C'\fR, the crc value will be reset.
819 .PP
820 If you have built this module with zlib 1.2.3 or better, two more
821 CRC-related functions are available.
822 .PP
823 .Vb 2
824 \&    $crc = adler32_combine($crc1, $crc2, $len2)l
825 \&    $crc = crc32_combine($adler1, $adler2, $len2)
826 .Ve
827 .PP
828 These functions allow checksums to be merged.
829 .SH "Misc"
830 .IX Header "Misc"
831 .ie n .Sh "my $version\fP = \fICompress::Raw::Zlib::zlib_version();"
832 .el .Sh "my \f(CW$version\fP = \fICompress::Raw::Zlib::zlib_version()\fP;"
833 .IX Subsection "my $version = Compress::Raw::Zlib::zlib_version();"
834 Returns the version of the zlib library.
835 .SH "The LimitOutput option."
836 .IX Header "The LimitOutput option."
837 By default \f(CW\*(C`$i\->inflate($input, $output)\*(C'\fR will uncompress \fIall\fR data
838 in \f(CW$input\fR and write \fIall\fR of the uncompressed data it has generated to
839 \&\f(CW$output\fR. This makes the interface to \f(CW\*(C`inflate\*(C'\fR much simpler \- if the
840 method has uncompressed \f(CW$input\fR successfully \fIall\fR compressed data in
841 \&\f(CW$input\fR will have been dealt with. So if you are reading from an input
842 source and uncompressing as you go the code will look something like this
843 .PP
844 .Vb 2
845 \&    use strict ;
846 \&    use warnings ;
847 .Ve
848 .PP
849 .Vb 1
850 \&    use Compress::Raw::Zlib;
851 .Ve
852 .PP
853 .Vb 2
854 \&    my $x = new Compress::Raw::Zlib::Inflate()
855 \&       or die "Cannot create a inflation stream\en" ;
856 .Ve
857 .PP
858 .Vb 1
859 \&    my $input = '' ;
860 .Ve
861 .PP
862 .Vb 4
863 \&    my ($output, $status) ;
864 \&    while (read(STDIN, $input, 4096))
865 \&    {
866 \&        $status = $x\->inflate($input, $output) ;
867 .Ve
868 .PP
869 .Vb 1
870 \&        print $output ;
871 .Ve
872 .PP
873 .Vb 2
874 \&        last if $status != Z_OK ;
875 \&    }
876 .Ve
877 .PP
878 .Vb 2
879 \&    die "inflation failed\en"
880 \&        unless $status == Z_STREAM_END ;
881 .Ve
882 .PP
883 The points to note are 
884 .IP "\(bu" 5
885 The main processing loop in the code handles reading of compressed data
886 from \s-1STDIN\s0.
887 .IP "\(bu" 5
888 The status code returned from \f(CW\*(C`inflate\*(C'\fR will only trigger termination of
889 the main processing loop if it isn't \f(CW\*(C`Z_OK\*(C'\fR. When \f(CW\*(C`LimitOutput\*(C'\fR has not
890 been used the \f(CW\*(C`Z_OK\*(C'\fR status means means that the end of the compressed
891 data stream has been reached or there has been an error in uncompression.
892 .IP "\(bu" 5
893 After the call to \f(CW\*(C`inflate\*(C'\fR \fIall\fR of the uncompressed data in \f(CW$input\fR
894 will have been processed. This means the subsequent call to \f(CW\*(C`read\*(C'\fR can
895 overwrite it's contents without any problem.
896 .PP
897 For most use-cases the behavior described above is acceptable (this module
898 and it's predecessor, \f(CW\*(C`Compress::Zlib\*(C'\fR, have used it for over 10 years
899 without an issue), but in a few very specific use-cases the amount of
900 memory required for \f(CW$output\fR can prohibitively large. For example, if the
901 compressed data stream contains the same pattern repeated thousands of
902 times, a relatively small compressed data stream can uncompress into
903 hundreds of megabytes.  Remember \f(CW\*(C`inflate\*(C'\fR will keep allocating memory
904 until \fIall\fR the uncompressed data has been written to the output buffer \-
905 the size of \f(CW$output\fR is unbounded. 
906 .PP
907 The \f(CW\*(C`LimitOutput\*(C'\fR option is designed to help with this use\-case.
908 .PP
909 The main difference in your code when using \f(CW\*(C`LimitOutput\*(C'\fR is having to
910 deal with cases where the \f(CW$input\fR parameter still contains some
911 uncompressed data that \f(CW\*(C`inflate\*(C'\fR hasn't processed yet. The status code
912 returned from \f(CW\*(C`inflate\*(C'\fR will be \f(CW\*(C`Z_OK\*(C'\fR if uncompression took place and
913 \&\f(CW\*(C`Z_BUF_ERROR\*(C'\fR if the output buffer is full.
914 .PP
915 Below is typical code that shows how to use \f(CW\*(C`LimitOutput\*(C'\fR.
916 .PP
917 .Vb 2
918 \&    use strict ;
919 \&    use warnings ;
920 .Ve
921 .PP
922 .Vb 1
923 \&    use Compress::Raw::Zlib;
924 .Ve
925 .PP
926 .Vb 2
927 \&    my $x = new Compress::Raw::Zlib::Inflate(LimitOutput => 1)
928 \&       or die "Cannot create a inflation stream\en" ;
929 .Ve
930 .PP
931 .Vb 3
932 \&    my $input = '' ;
933 \&    binmode STDIN;
934 \&    binmode STDOUT;
935 .Ve
936 .PP
937 .Vb 1
938 \&    my ($output, $status) ;
939 .Ve
940 .PP
941 .Vb 6
942 \&  OUTER:
943 \&    while (read(STDIN, $input, 4096))
944 \&    {
945 \&        do
946 \&        {
947 \&            $status = $x\->inflate($input, $output) ;
948 .Ve
949 .PP
950 .Vb 1
951 \&            print $output ;
952 .Ve
953 .PP
954 .Vb 5
955 \&            last OUTER
956 \&                unless $status == Z_OK || $status == Z_BUF_ERROR ;
957 \&        }
958 \&        while ($status == Z_OK && length $input);
959 \&    }
960 .Ve
961 .PP
962 .Vb 2
963 \&    die "inflation failed\en"
964 \&        unless $status == Z_STREAM_END ;
965 .Ve
966 .PP
967 Points to note this time:
968 .IP "\(bu" 5
969 There are now two nested loops in the code: the outer loop for reading the
970 compressed data from \s-1STDIN\s0, as before; and the inner loop to carry out the
971 uncompression.
972 .IP "\(bu" 5
973 There are two exit points from the inner uncompression loop.
974 .Sp
975 Firstly when \f(CW\*(C`inflate\*(C'\fR has returned a status other than \f(CW\*(C`Z_OK\*(C'\fR or
976 \&\f(CW\*(C`Z_BUF_ERROR\*(C'\fR.  This means that either the end of the compressed data
977 stream has been reached (\f(CW\*(C`Z_STREAM_END\*(C'\fR) or there is an error in the
978 compressed data. In either of these cases there is no point in continuing
979 with reading the compressed data, so both loops are terminated.
980 .Sp
981 The second exit point tests if there is any data left in the input buffer,
982 \&\f(CW$input\fR \- remember that the \f(CW\*(C`ConsumeInput\*(C'\fR option is automatically
983 enabled when \f(CW\*(C`LimitOutput\*(C'\fR is used.  When the input buffer has been
984 exhausted, the outer loop can run again and overwrite a now empty
985 \&\f(CW$input\fR.
986 .SH "ACCESSING ZIP FILES"
987 .IX Header "ACCESSING ZIP FILES"
988 Although it is possible (with some effort on your part) to use this module
989 to access .zip files, there are other perl modules available that will
990 do all the hard work for you. Check out \f(CW\*(C`Archive::Zip\*(C'\fR,
991 \&\f(CW\*(C`IO::Compress::Zip\*(C'\fR and \f(CW\*(C`IO::Uncompress::Unzip\*(C'\fR.
992 .SH "CONSTANTS"
993 .IX Header "CONSTANTS"
994 All the \fIzlib\fR constants are automatically imported when you make use
995 of \fICompress::Raw::Zlib\fR.
996 .SH "SEE ALSO"
997 .IX Header "SEE ALSO"
998 Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip, IO::Compress::Deflate, IO::Uncompress::Inflate, IO::Compress::RawDeflate, IO::Uncompress::RawInflate, IO::Compress::Bzip2, IO::Uncompress::Bunzip2, IO::Compress::Lzma, IO::Uncompress::UnLzma, IO::Compress::Xz, IO::Uncompress::UnXz, IO::Compress::Lzop, IO::Uncompress::UnLzop, IO::Compress::Lzf, IO::Uncompress::UnLzf, IO::Uncompress::AnyInflate, IO::Uncompress::AnyUncompress
999 .PP
1000 Compress::Zlib::FAQ
1001 .PP
1002 File::GlobMapper, Archive::Zip,
1003 Archive::Tar,
1004 IO::Zlib
1005 .PP
1006 For \s-1RFC\s0 1950, 1951 and 1952 see 
1007 \&\fIhttp://www.faqs.org/rfcs/rfc1950.html\fR,
1008 \&\fIhttp://www.faqs.org/rfcs/rfc1951.html\fR and
1009 \&\fIhttp://www.faqs.org/rfcs/rfc1952.html\fR
1010 .PP
1011 The \fIzlib\fR compression library was written by Jean-loup Gailly
1012 \&\fIgzip@prep.ai.mit.edu\fR and Mark Adler \fImadler@alumni.caltech.edu\fR.
1013 .PP
1014 The primary site for the \fIzlib\fR compression library is
1015 \&\fIhttp://www.zlib.org\fR.
1016 .PP
1017 The primary site for gzip is \fIhttp://www.gzip.org\fR.
1018 .SH "AUTHOR"
1019 .IX Header "AUTHOR"
1020 This module was written by Paul Marquess, \fIpmqs@cpan.org\fR. 
1021 .SH "MODIFICATION HISTORY"
1022 .IX Header "MODIFICATION HISTORY"
1023 See the Changes file.
1024 .SH "COPYRIGHT AND LICENSE"
1025 .IX Header "COPYRIGHT AND LICENSE"
1026 Copyright (c) 2005\-2009 Paul Marquess. All rights reserved.
1027 .PP
1028 This program is free software; you can redistribute it and/or
1029 modify it under the same terms as Perl itself.