Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / Compress::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::Zlib 3"
132 .TH Compress::Zlib 3 "2009-11-09" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 Compress::Zlib \- Interface to zlib compression library
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 1
138 \&    use Compress::Zlib ;
139 .Ve
140 .PP
141 .Vb 14
142 \&    ($d, $status) = deflateInit( [OPT] ) ;
143 \&    $status = $d\->deflate($input, $output) ;
144 \&    $status = $d\->flush([$flush_type]) ;
145 \&    $d\->deflateParams(OPTS) ;
146 \&    $d\->deflateTune(OPTS) ;
147 \&    $d\->dict_adler() ;
148 \&    $d\->crc32() ;
149 \&    $d\->adler32() ;
150 \&    $d\->total_in() ;
151 \&    $d\->total_out() ;
152 \&    $d\->msg() ;
153 \&    $d\->get_Strategy();
154 \&    $d\->get_Level();
155 \&    $d\->get_BufSize();
156 .Ve
157 .PP
158 .Vb 10
159 \&    ($i, $status) = inflateInit( [OPT] ) ;
160 \&    $status = $i\->inflate($input, $output [, $eof]) ;
161 \&    $status = $i\->inflateSync($input) ;
162 \&    $i\->dict_adler() ;
163 \&    $d\->crc32() ;
164 \&    $d\->adler32() ;
165 \&    $i\->total_in() ;
166 \&    $i\->total_out() ;
167 \&    $i\->msg() ;
168 \&    $d\->get_BufSize();
169 .Ve
170 .PP
171 .Vb 2
172 \&    $dest = compress($source) ;
173 \&    $dest = uncompress($source) ;
174 .Ve
175 .PP
176 .Vb 12
177 \&    $gz = gzopen($filename or filehandle, $mode) ;
178 \&    $bytesread = $gz\->gzread($buffer [,$size]) ;
179 \&    $bytesread = $gz\->gzreadline($line) ;
180 \&    $byteswritten = $gz\->gzwrite($buffer) ;
181 \&    $status = $gz\->gzflush($flush) ;
182 \&    $offset = $gz\->gztell() ;
183 \&    $status = $gz\->gzseek($offset, $whence) ;
184 \&    $status = $gz\->gzclose() ;
185 \&    $status = $gz\->gzeof() ;
186 \&    $status = $gz\->gzsetparams($level, $strategy) ;
187 \&    $errstring = $gz\->gzerror() ; 
188 \&    $gzerrno
189 .Ve
190 .PP
191 .Vb 2
192 \&    $dest = Compress::Zlib::memGzip($buffer) ;
193 \&    $dest = Compress::Zlib::memGunzip($buffer) ;
194 .Ve
195 .PP
196 .Vb 2
197 \&    $crc = adler32($buffer [,$crc]) ;
198 \&    $crc = crc32($buffer [,$crc]) ;
199 .Ve
200 .PP
201 .Vb 2
202 \&    $crc = adler32_combine($crc1, $crc2, $len2)l
203 \&    $crc = crc32_combine($adler1, $adler2, $len2)
204 .Ve
205 .PP
206 .Vb 1
207 \&    my $version = Compress::Raw::Zlib::zlib_version();
208 .Ve
209 .SH "DESCRIPTION"
210 .IX Header "DESCRIPTION"
211 The \fICompress::Zlib\fR module provides a Perl interface to the \fIzlib\fR
212 compression library (see \*(L"\s-1AUTHOR\s0\*(R" for details about where to get
213 \&\fIzlib\fR). 
214 .PP
215 The \f(CW\*(C`Compress::Zlib\*(C'\fR module can be split into two general areas of
216 functionality, namely a simple read/write interface to \fIgzip\fR files
217 and a low-level in-memory compression/decompression interface.
218 .PP
219 Each of these areas will be discussed in the following sections.
220 .Sh "Notes for users of Compress::Zlib version 1"
221 .IX Subsection "Notes for users of Compress::Zlib version 1"
222 The main change in \f(CW\*(C`Compress::Zlib\*(C'\fR version 2.x is that it does not now
223 interface directly to the zlib library. Instead it uses the
224 \&\f(CW\*(C`IO::Compress::Gzip\*(C'\fR and \f(CW\*(C`IO::Uncompress::Gunzip\*(C'\fR modules for
225 reading/writing gzip files, and the \f(CW\*(C`Compress::Raw::Zlib\*(C'\fR module for some
226 low-level zlib access. 
227 .PP
228 The interface provided by version 2 of this module should be 100% backward
229 compatible with version 1. If you find a difference in the expected
230 behaviour please contact the author (See \*(L"\s-1AUTHOR\s0\*(R"). See \*(L"\s-1GZIP\s0 \s-1INTERFACE\s0\*(R" 
231 .PP
232 With the creation of the \f(CW\*(C`IO::Compress\*(C'\fR and \f(CW\*(C`IO::Uncompress\*(C'\fR modules no
233 new features are planned for \f(CW\*(C`Compress::Zlib\*(C'\fR \- the new modules do
234 everything that \f(CW\*(C`Compress::Zlib\*(C'\fR does and then some. Development on
235 \&\f(CW\*(C`Compress::Zlib\*(C'\fR will be limited to bug fixes only.
236 .PP
237 If you are writing new code, your first port of call should be one of the
238 new \f(CW\*(C`IO::Compress\*(C'\fR or \f(CW\*(C`IO::Uncompress\*(C'\fR modules.
239 .SH "GZIP INTERFACE"
240 .IX Header "GZIP INTERFACE"
241 A number of functions are supplied in \fIzlib\fR for reading and writing
242 \&\fIgzip\fR files that conform to \s-1RFC\s0 1952. This module provides an interface
243 to most of them. 
244 .PP
245 If you have previously used \f(CW\*(C`Compress::Zlib\*(C'\fR 1.x, the following
246 enhancements/changes have been made to the \f(CW\*(C`gzopen\*(C'\fR interface:
247 .IP "1" 5
248 .IX Item "1"
249 If you want to to open either \s-1STDIN\s0 or \s-1STDOUT\s0 with \f(CW\*(C`gzopen\*(C'\fR, you can now
250 optionally use the special filename "\f(CW\*(C`\-\*(C'\fR" as a synonym for \f(CW\*(C`\e*STDIN\*(C'\fR and
251 \&\f(CW\*(C`\e*STDOUT\*(C'\fR.
252 .IP "2" 5
253 .IX Item "2"
254 In \f(CW\*(C`Compress::Zlib\*(C'\fR version 1.x, \f(CW\*(C`gzopen\*(C'\fR used the zlib library to open
255 the underlying file. This made things especially tricky when a Perl
256 filehandle was passed to \f(CW\*(C`gzopen\*(C'\fR. Behind the scenes the numeric C file
257 descriptor had to be extracted from the Perl filehandle and this passed to
258 the zlib library.
259 .Sp
260 Apart from being non-portable to some operating systems, this made it
261 difficult to use \f(CW\*(C`gzopen\*(C'\fR in situations where you wanted to extract/create
262 a gzip data stream that is embedded in a larger file, without having to
263 resort to opening and closing the file multiple times. 
264 .Sp
265 It also made it impossible to pass a perl filehandle that wasn't associated
266 with a real filesystem file, like, say, an \f(CW\*(C`IO::String\*(C'\fR.
267 .Sp
268 In \f(CW\*(C`Compress::Zlib\*(C'\fR version 2.x, the \f(CW\*(C`gzopen\*(C'\fR interface has been
269 completely rewritten to use the IO::Compress::Gzip
270 for writing gzip files and IO::Uncompress::Gunzip
271 for reading gzip files. None of the limitations mentioned above apply.
272 .IP "3" 5
273 .IX Item "3"
274 Addition of \f(CW\*(C`gzseek\*(C'\fR to provide a restricted \f(CW\*(C`seek\*(C'\fR interface.
275 .IP "4." 5
276 Added \f(CW\*(C`gztell\*(C'\fR.
277 .PP
278 A more complete and flexible interface for reading/writing gzip
279 files/buffers is included with the module \f(CW\*(C`IO\-Compress\-Zlib\*(C'\fR. See
280 IO::Compress::Gzip and
281 IO::Uncompress::Gunzip for more details.
282 .ie n .IP "\fB$gz = gzopen($filename, \fB$mode\fB)\fR" 5
283 .el .IP "\fB$gz = gzopen($filename, \f(CB$mode\fB)\fR" 5
284 .IX Item "$gz = gzopen($filename, $mode)"
285 .PD 0
286 .ie n .IP "\fB$gz = gzopen($filehandle, \fB$mode\fB)\fR" 5
287 .el .IP "\fB$gz = gzopen($filehandle, \f(CB$mode\fB)\fR" 5
288 .IX Item "$gz = gzopen($filehandle, $mode)"
289 .PD
290 This function opens either the \fIgzip\fR file \f(CW$filename\fR for reading or
291 writing or attaches to the opened filehandle, \f(CW$filehandle\fR. 
292 It returns an object on success and \f(CW\*(C`undef\*(C'\fR on failure.
293 .Sp
294 When writing a gzip file this interface will \fIalways\fR create the smallest
295 possible gzip header (exactly 10 bytes). If you want greater control over
296 what gets stored in the gzip header (like the original filename or a
297 comment) use IO::Compress::Gzip instead. Similarly if
298 you want to read the contents of the gzip header use
299 IO::Uncompress::Gunzip.
300 .Sp
301 The second parameter, \f(CW$mode\fR, is used to specify whether the file is
302 opened for reading or writing and to optionally specify a compression
303 level and compression strategy when writing. The format of the \f(CW$mode\fR
304 parameter is similar to the mode parameter to the 'C' function \f(CW\*(C`fopen\*(C'\fR,
305 so \*(L"rb\*(R" is used to open for reading, \*(L"wb\*(R" for writing and \*(L"ab\*(R" for
306 appending (writing at the end of the file).
307 .Sp
308 To specify a compression level when writing, append a digit between 0
309 and 9 to the mode string \*(-- 0 means no compression and 9 means maximum
310 compression.
311 If no compression level is specified Z_DEFAULT_COMPRESSION is used.
312 .Sp
313 To specify the compression strategy when writing, append 'f' for filtered
314 data, 'h' for Huffman only compression, or 'R' for run-length encoding.
315 If no strategy is specified Z_DEFAULT_STRATEGY is used.
316 .Sp
317 So, for example, \*(L"wb9\*(R" means open for writing with the maximum compression
318 using the default strategy and \*(L"wb4R\*(R" means open for writing with compression
319 level 4 and run-length encoding.
320 .Sp
321 Refer to the \fIzlib\fR documentation for the exact format of the \f(CW$mode\fR
322 parameter.
323 .ie n .IP "\fB$bytesread = \fB$gz\fB\->gzread($buffer [, \f(BI$size\fB]) ;\fR" 5
324 .el .IP "\fB$bytesread = \f(CB$gz\fB\->gzread($buffer [, \f(CB$size\fB]) ;\fR" 5
325 .IX Item "$bytesread = $gz->gzread($buffer [, $size]) ;"
326 Reads \f(CW$size\fR bytes from the compressed file into \f(CW$buffer\fR. If
327 \&\f(CW$size\fR is not specified, it will default to 4096. If the scalar
328 \&\f(CW$buffer\fR is not large enough, it will be extended automatically.
329 .Sp
330 Returns the number of bytes actually read. On \s-1EOF\s0 it returns 0 and in
331 the case of an error, \-1.
332 .ie n .IP "\fB$bytesread = \fB$gz\fB\->gzreadline($line) ;\fR" 5
333 .el .IP "\fB$bytesread = \f(CB$gz\fB\->gzreadline($line) ;\fR" 5
334 .IX Item "$bytesread = $gz->gzreadline($line) ;"
335 Reads the next line from the compressed file into \f(CW$line\fR. 
336 .Sp
337 Returns the number of bytes actually read. On \s-1EOF\s0 it returns 0 and in
338 the case of an error, \-1.
339 .Sp
340 It is legal to intermix calls to \f(CW\*(C`gzread\*(C'\fR and \f(CW\*(C`gzreadline\*(C'\fR.
341 .Sp
342 To maintain backward compatibility with version 1.x of this module
343 \&\f(CW\*(C`gzreadline\*(C'\fR ignores the \f(CW$/\fR variable \- it \fIalways\fR uses the string
344 \&\f(CW"\en"\fR as the line delimiter.  
345 .Sp
346 If you want to read a gzip file a line at a time and have it respect the
347 \&\f(CW$/\fR variable (or \f(CW$INPUT_RECORD_SEPARATOR\fR, or \f(CW$RS\fR when \f(CW\*(C`English\*(C'\fR is
348 in use) see IO::Uncompress::Gunzip.
349 .ie n .IP "\fB$byteswritten = \fB$gz\fB\->gzwrite($buffer) ;\fR" 5
350 .el .IP "\fB$byteswritten = \f(CB$gz\fB\->gzwrite($buffer) ;\fR" 5
351 .IX Item "$byteswritten = $gz->gzwrite($buffer) ;"
352 Writes the contents of \f(CW$buffer\fR to the compressed file. Returns the
353 number of bytes actually written, or 0 on error.
354 .ie n .IP "\fB$status = \fB$gz\fB\->gzflush($flush_type) ;\fR" 5
355 .el .IP "\fB$status = \f(CB$gz\fB\->gzflush($flush_type) ;\fR" 5
356 .IX Item "$status = $gz->gzflush($flush_type) ;"
357 Flushes all pending output into the compressed file.
358 .Sp
359 This method takes an optional parameter, \f(CW$flush_type\fR, that controls
360 how the flushing will be carried out. By default the \f(CW$flush_type\fR
361 used is \f(CW\*(C`Z_FINISH\*(C'\fR. Other valid values for \f(CW$flush_type\fR are
362 \&\f(CW\*(C`Z_NO_FLUSH\*(C'\fR, \f(CW\*(C`Z_SYNC_FLUSH\*(C'\fR, \f(CW\*(C`Z_FULL_FLUSH\*(C'\fR and \f(CW\*(C`Z_BLOCK\*(C'\fR. It is
363 strongly recommended that you only set the \f(CW\*(C`flush_type\*(C'\fR parameter if
364 you fully understand the implications of what it does \- overuse of \f(CW\*(C`flush\*(C'\fR
365 can seriously degrade the level of compression achieved. See the \f(CW\*(C`zlib\*(C'\fR
366 documentation for details.
367 .Sp
368 Returns 0 on success.
369 .ie n .IP "\fB$offset = \fB$gz\fB\->\f(BIgztell()\fB ;\fR" 5
370 .el .IP "\fB$offset = \f(CB$gz\fB\->\f(BIgztell()\fB ;\fR" 5
371 .IX Item "$offset = $gz->gztell() ;"
372 Returns the uncompressed file offset.
373 .ie n .IP "\fB$status = \fB$gz\fB\->gzseek($offset, \f(BI$whence\fB) ;\fR" 5
374 .el .IP "\fB$status = \f(CB$gz\fB\->gzseek($offset, \f(CB$whence\fB) ;\fR" 5
375 .IX Item "$status = $gz->gzseek($offset, $whence) ;"
376 Provides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction
377 that it is only legal to seek forward in the compressed file.
378 It is a fatal error to attempt to seek backward.
379 .Sp
380 When opened for writing, empty parts of the file will have \s-1NULL\s0 (0x00)
381 bytes written to them.
382 .Sp
383 The \f(CW$whence\fR parameter should be one of \s-1SEEK_SET\s0, \s-1SEEK_CUR\s0 or \s-1SEEK_END\s0.
384 .Sp
385 Returns 1 on success, 0 on failure.
386 .IP "\fB$gz\->gzclose\fR" 5
387 .IX Item "$gz->gzclose"
388 Closes the compressed file. Any pending data is flushed to the file
389 before it is closed.
390 .Sp
391 Returns 0 on success.
392 .ie n .IP "\fB$gz\->gzsetparams($level, \fB$strategy\fB\fR" 5
393 .el .IP "\fB$gz\->gzsetparams($level, \f(CB$strategy\fB\fR" 5
394 .IX Item "$gz->gzsetparams($level, $strategy"
395 Change settings for the deflate stream \f(CW$gz\fR.
396 .Sp
397 The list of the valid options is shown below. Options not specified
398 will remain unchanged.
399 .Sp
400 Note: This method is only available if you are running zlib 1.0.6 or better.
401 .RS 5
402 .IP "\fB$level\fR" 5
403 .IX Item "$level"
404 Defines the compression level. Valid values are 0 through 9,
405 \&\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
406 \&\f(CW\*(C`Z_DEFAULT_COMPRESSION\*(C'\fR.
407 .IP "\fB$strategy\fR" 5
408 .IX Item "$strategy"
409 Defines the strategy used to tune the compression. The valid values are
410 \&\f(CW\*(C`Z_DEFAULT_STRATEGY\*(C'\fR, \f(CW\*(C`Z_FILTERED\*(C'\fR and \f(CW\*(C`Z_HUFFMAN_ONLY\*(C'\fR. 
411 .RE
412 .RS 5
413 .RE
414 .IP "\fB$gz\->gzerror\fR" 5
415 .IX Item "$gz->gzerror"
416 Returns the \fIzlib\fR error message or number for the last operation
417 associated with \f(CW$gz\fR. The return value will be the \fIzlib\fR error
418 number when used in a numeric context and the \fIzlib\fR error message
419 when used in a string context. The \fIzlib\fR error number constants,
420 shown below, are available for use.
421 .Sp
422 .Vb 7
423 \&    Z_OK
424 \&    Z_STREAM_END
425 \&    Z_ERRNO
426 \&    Z_STREAM_ERROR
427 \&    Z_DATA_ERROR
428 \&    Z_MEM_ERROR
429 \&    Z_BUF_ERROR
430 .Ve
431 .IP "\fB$gzerrno\fR" 5
432 .IX Item "$gzerrno"
433 The \f(CW$gzerrno\fR scalar holds the error code associated with the most
434 recent \fIgzip\fR routine. Note that unlike \f(CW\*(C`gzerror()\*(C'\fR, the error is
435 \&\fInot\fR associated with a particular file.
436 .Sp
437 As with \f(CW\*(C`gzerror()\*(C'\fR it returns an error number in numeric context and
438 an error message in string context. Unlike \f(CW\*(C`gzerror()\*(C'\fR though, the
439 error message will correspond to the \fIzlib\fR message when the error is
440 associated with \fIzlib\fR itself, or the \s-1UNIX\s0 error message when it is
441 not (i.e. \fIzlib\fR returned \f(CW\*(C`Z_ERRORNO\*(C'\fR).
442 .Sp
443 As there is an overlap between the error numbers used by \fIzlib\fR and
444 \&\s-1UNIX\s0, \f(CW$gzerrno\fR should only be used to check for the presence of
445 \&\fIan\fR error in numeric context. Use \f(CW\*(C`gzerror()\*(C'\fR to check for specific
446 \&\fIzlib\fR errors. The \fIgzcat\fR example below shows how the variable can
447 be used safely.
448 .Sh "Examples"
449 .IX Subsection "Examples"
450 Here is an example script which uses the interface. It implements a
451 \&\fIgzcat\fR function.
452 .PP
453 .Vb 2
454 \&    use strict ;
455 \&    use warnings ;
456 .Ve
457 .PP
458 .Vb 1
459 \&    use Compress::Zlib ;
460 .Ve
461 .PP
462 .Vb 2
463 \&    # use stdin if no files supplied
464 \&    @ARGV = '\-' unless @ARGV ;
465 .Ve
466 .PP
467 .Vb 2
468 \&    foreach my $file (@ARGV) {
469 \&        my $buffer ;
470 .Ve
471 .PP
472 .Vb 2
473 \&        my $gz = gzopen($file, "rb") 
474 \&             or die "Cannot open $file: $gzerrno\en" ;
475 .Ve
476 .PP
477 .Vb 1
478 \&        print $buffer while $gz\->gzread($buffer) > 0 ;
479 .Ve
480 .PP
481 .Vb 2
482 \&        die "Error reading from $file: $gzerrno" . ($gzerrno+0) . "\en" 
483 \&            if $gzerrno != Z_STREAM_END ;
484 .Ve
485 .PP
486 .Vb 2
487 \&        $gz\->gzclose() ;
488 \&    }
489 .Ve
490 .PP
491 Below is a script which makes use of \f(CW\*(C`gzreadline\*(C'\fR. It implements a
492 very simple \fIgrep\fR like script.
493 .PP
494 .Vb 2
495 \&    use strict ;
496 \&    use warnings ;
497 .Ve
498 .PP
499 .Vb 1
500 \&    use Compress::Zlib ;
501 .Ve
502 .PP
503 .Vb 2
504 \&    die "Usage: gzgrep pattern [file...]\en"
505 \&        unless @ARGV >= 1;
506 .Ve
507 .PP
508 .Vb 1
509 \&    my $pattern = shift ;
510 .Ve
511 .PP
512 .Vb 2
513 \&    # use stdin if no files supplied
514 \&    @ARGV = '\-' unless @ARGV ;
515 .Ve
516 .PP
517 .Vb 3
518 \&    foreach my $file (@ARGV) {
519 \&        my $gz = gzopen($file, "rb") 
520 \&             or die "Cannot open $file: $gzerrno\en" ;
521 .Ve
522 .PP
523 .Vb 3
524 \&        while ($gz\->gzreadline($_) > 0) {
525 \&            print if /$pattern/ ;
526 \&        }
527 .Ve
528 .PP
529 .Vb 2
530 \&        die "Error reading from $file: $gzerrno\en" 
531 \&            if $gzerrno != Z_STREAM_END ;
532 .Ve
533 .PP
534 .Vb 2
535 \&        $gz\->gzclose() ;
536 \&    }
537 .Ve
538 .PP
539 This script, \fIgzstream\fR, does the opposite of the \fIgzcat\fR script
540 above. It reads from standard input and writes a gzip data stream to
541 standard output.
542 .PP
543 .Vb 2
544 \&    use strict ;
545 \&    use warnings ;
546 .Ve
547 .PP
548 .Vb 1
549 \&    use Compress::Zlib ;
550 .Ve
551 .PP
552 .Vb 1
553 \&    binmode STDOUT;  # gzopen only sets it on the fd
554 .Ve
555 .PP
556 .Vb 2
557 \&    my $gz = gzopen(\e*STDOUT, "wb")
558 \&          or die "Cannot open stdout: $gzerrno\en" ;
559 .Ve
560 .PP
561 .Vb 4
562 \&    while (<>) {
563 \&        $gz\->gzwrite($_) 
564 \&          or die "error writing: $gzerrno\en" ;
565 \&    }
566 .Ve
567 .PP
568 .Vb 1
569 \&    $gz\->gzclose ;
570 .Ve
571 .Sh "Compress::Zlib::memGzip"
572 .IX Subsection "Compress::Zlib::memGzip"
573 This function is used to create an in-memory gzip file with the minimum
574 possible gzip header (exactly 10 bytes).
575 .PP
576 .Vb 1
577 \&    $dest = Compress::Zlib::memGzip($buffer) ;
578 .Ve
579 .PP
580 If successful, it returns the in-memory gzip file, otherwise it returns
581 undef.
582 .PP
583 The \f(CW$buffer\fR parameter can either be a scalar or a scalar reference.
584 .PP
585 See IO::Compress::Gzip for an alternative way to
586 carry out in-memory gzip compression.
587 .Sh "Compress::Zlib::memGunzip"
588 .IX Subsection "Compress::Zlib::memGunzip"
589 This function is used to uncompress an in-memory gzip file.
590 .PP
591 .Vb 1
592 \&    $dest = Compress::Zlib::memGunzip($buffer) ;
593 .Ve
594 .PP
595 If successful, it returns the uncompressed gzip file, otherwise it
596 returns undef.
597 .PP
598 The \f(CW$buffer\fR parameter can either be a scalar or a scalar reference. The
599 contents of the \f(CW$buffer\fR parameter are destroyed after calling this function.
600 .PP
601 If \f(CW$buffer\fR consists of multiple concatenated gzip data streams only the
602 first will be uncompressed. Use \f(CW\*(C`gunzip\*(C'\fR with the \f(CW\*(C`MultiStream\*(C'\fR option in
603 the \f(CW\*(C`IO::Uncompress::Gunzip\*(C'\fR module if you need to deal with concatenated
604 data streams.
605 .PP
606 See IO::Uncompress::Gunzip for an alternative way
607 to carry out in-memory gzip uncompression.
608 .SH "COMPRESS/UNCOMPRESS"
609 .IX Header "COMPRESS/UNCOMPRESS"
610 Two functions are provided to perform in-memory compression/uncompression of
611 \&\s-1RFC\s0 1950 data streams. They are called \f(CW\*(C`compress\*(C'\fR and \f(CW\*(C`uncompress\*(C'\fR.
612 .ie n .IP "\fB$dest = compress($source [, \fB$level\fB] ) ;\fR" 5
613 .el .IP "\fB$dest = compress($source [, \f(CB$level\fB] ) ;\fR" 5
614 .IX Item "$dest = compress($source [, $level] ) ;"
615 Compresses \f(CW$source\fR. If successful it returns the compressed
616 data. Otherwise it returns \fIundef\fR.
617 .Sp
618 The source buffer, \f(CW$source\fR, can either be a scalar or a scalar
619 reference.
620 .Sp
621 The \f(CW$level\fR parameter defines the compression level. Valid values are
622 0 through 9, \f(CW\*(C`Z_NO_COMPRESSION\*(C'\fR, \f(CW\*(C`Z_BEST_SPEED\*(C'\fR,
623 \&\f(CW\*(C`Z_BEST_COMPRESSION\*(C'\fR, and \f(CW\*(C`Z_DEFAULT_COMPRESSION\*(C'\fR.
624 If \f(CW$level\fR is not specified \f(CW\*(C`Z_DEFAULT_COMPRESSION\*(C'\fR will be used.
625 .IP "\fB$dest = uncompress($source) ;\fR" 5
626 .IX Item "$dest = uncompress($source) ;"
627 Uncompresses \f(CW$source\fR. If successful it returns the uncompressed
628 data. Otherwise it returns \fIundef\fR.
629 .Sp
630 The source buffer can either be a scalar or a scalar reference.
631 .PP
632 Please note: the two functions defined above are \fInot\fR compatible with
633 the Unix commands of the same name.
634 .PP
635 See IO::Deflate and IO::Inflate included with
636 this distribution for an alternative interface for reading/writing \s-1RFC\s0 1950
637 files/buffers.
638 .SH "Deflate Interface"
639 .IX Header "Deflate Interface"
640 This section defines an interface that allows in-memory compression using
641 the \fIdeflate\fR interface provided by zlib.
642 .PP
643 Here is a definition of the interface available:
644 .ie n .Sh "\fB($d, \fP\fB$status\fP\fB) = deflateInit( [\s-1OPT\s0] )\fP"
645 .el .Sh "\fB($d, \fP\f(CB$status\fP\fB) = deflateInit( [\s-1OPT\s0] )\fP"
646 .IX Subsection "($d, $status) = deflateInit( [OPT] )"
647 Initialises a deflation stream. 
648 .PP
649 It combines the features of the \fIzlib\fR functions \f(CW\*(C`deflateInit\*(C'\fR,
650 \&\f(CW\*(C`deflateInit2\*(C'\fR and \f(CW\*(C`deflateSetDictionary\*(C'\fR.
651 .PP
652 If successful, it will return the initialised deflation stream, \f(CW$d\fR
653 and \f(CW$status\fR of \f(CW\*(C`Z_OK\*(C'\fR in a list context. In scalar context it
654 returns the deflation stream, \f(CW$d\fR, only.
655 .PP
656 If not successful, the returned deflation stream (\f(CW$d\fR) will be
657 \&\fIundef\fR and \f(CW$status\fR will hold the exact \fIzlib\fR error code.
658 .PP
659 The function optionally takes a number of named options specified as
660 \&\f(CW\*(C`\-Name=>value\*(C'\fR pairs. This allows individual options to be
661 tailored without having to specify them all in the parameter list.
662 .PP
663 For backward compatibility, it is also possible to pass the parameters
664 as a reference to a hash containing the name=>value pairs.
665 .PP
666 The function takes one optional parameter, a reference to a hash.  The
667 contents of the hash allow the deflation interface to be tailored.
668 .PP
669 Here is a list of the valid options:
670 .IP "\fB\-Level\fR" 5
671 .IX Item "-Level"
672 Defines the compression level. Valid values are 0 through 9,
673 \&\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
674 \&\f(CW\*(C`Z_DEFAULT_COMPRESSION\*(C'\fR.
675 .Sp
676 The default is Z_DEFAULT_COMPRESSION.
677 .IP "\fB\-Method\fR" 5
678 .IX Item "-Method"
679 Defines the compression method. The only valid value at present (and
680 the default) is Z_DEFLATED.
681 .IP "\fB\-WindowBits\fR" 5
682 .IX Item "-WindowBits"
683 To create an \s-1RFC\s0 1950 data stream, set \f(CW\*(C`WindowBits\*(C'\fR to a positive number.
684 .Sp
685 To create an \s-1RFC\s0 1951 data stream, set \f(CW\*(C`WindowBits\*(C'\fR to \f(CW\*(C`\-MAX_WBITS\*(C'\fR.
686 .Sp
687 For a full definition of the meaning and valid values for \f(CW\*(C`WindowBits\*(C'\fR refer
688 to the \fIzlib\fR documentation for \fIdeflateInit2\fR.
689 .Sp
690 Defaults to \s-1MAX_WBITS\s0.
691 .IP "\fB\-MemLevel\fR" 5
692 .IX Item "-MemLevel"
693 For a definition of the meaning and valid values for \f(CW\*(C`MemLevel\*(C'\fR
694 refer to the \fIzlib\fR documentation for \fIdeflateInit2\fR.
695 .Sp
696 Defaults to \s-1MAX_MEM_LEVEL\s0.
697 .IP "\fB\-Strategy\fR" 5
698 .IX Item "-Strategy"
699 Defines the strategy used to tune the compression. The valid values are
700 \&\f(CW\*(C`Z_DEFAULT_STRATEGY\*(C'\fR, \f(CW\*(C`Z_FILTERED\*(C'\fR and \f(CW\*(C`Z_HUFFMAN_ONLY\*(C'\fR. 
701 .Sp
702 The default is Z_DEFAULT_STRATEGY.
703 .IP "\fB\-Dictionary\fR" 5
704 .IX Item "-Dictionary"
705 When a dictionary is specified \fICompress::Zlib\fR will automatically
706 call \f(CW\*(C`deflateSetDictionary\*(C'\fR directly after calling \f(CW\*(C`deflateInit\*(C'\fR. The
707 Adler32 value for the dictionary can be obtained by calling the method 
708 \&\f(CW\*(C`$d\-\*(C'\fR\fIdict_adler()\fR>.
709 .Sp
710 The default is no dictionary.
711 .IP "\fB\-Bufsize\fR" 5
712 .IX Item "-Bufsize"
713 Sets the initial size for the deflation buffer. If the buffer has to be
714 reallocated to increase the size, it will grow in increments of
715 \&\f(CW\*(C`Bufsize\*(C'\fR.
716 .Sp
717 The default is 4096.
718 .PP
719 Here is an example of using the \f(CW\*(C`deflateInit\*(C'\fR optional parameter list
720 to override the default buffer size and compression level. All other
721 options will take their default values.
722 .PP
723 .Vb 2
724 \&    deflateInit( \-Bufsize => 300, 
725 \&                 \-Level => Z_BEST_SPEED  ) ;
726 .Ve
727 .ie n .Sh "\fB($out, \fP\fB$status\fP\fB) = \fP\f(BI$d\fP\fB\->deflate($buffer)\fP"
728 .el .Sh "\fB($out, \fP\f(CB$status\fP\fB) = \fP\f(CB$d\fP\fB\->deflate($buffer)\fP"
729 .IX Subsection "($out, $status) = $d->deflate($buffer)"
730 Deflates the contents of \f(CW$buffer\fR. The buffer can either be a scalar
731 or a scalar reference.  When finished, \f(CW$buffer\fR will be
732 completely processed (assuming there were no errors). If the deflation
733 was successful it returns the deflated output, \f(CW$out\fR, and a status
734 value, \f(CW$status\fR, of \f(CW\*(C`Z_OK\*(C'\fR.
735 .PP
736 On error, \f(CW$out\fR will be \fIundef\fR and \f(CW$status\fR will contain the
737 \&\fIzlib\fR error code.
738 .PP
739 In a scalar context \f(CW\*(C`deflate\*(C'\fR will return \f(CW$out\fR only.
740 .PP
741 As with the \fIdeflate\fR function in \fIzlib\fR, it is not necessarily the
742 case that any output will be produced by this method. So don't rely on
743 the fact that \f(CW$out\fR is empty for an error test.
744 .ie n .Sh "\fB($out, \fP\fB$status\fP\fB) = \fP\f(BI$d\fP\fB\->\fP\f(BIflush()\fP\fB\fP =head2 \fB($out, \fP\f(CB$status\fP\fB) = \fP\f(CB$d\fP\fB\->flush($flush_type)\fP"
745 .el .Sh "\fB($out, \fP\f(CB$status\fP\fB) = \fP\f(CB$d\fP\fB\->\fP\f(BIflush()\fP\fB\fP =head2 \fB($out, \fP\f(CB$status\fP\fB) = \fP\f(CB$d\fP\fB\->flush($flush_type)\fP"
746 .IX Subsection "($out, $status) = $d->flush() =head2 ($out, $status) = $d->flush($flush_type)"
747 Typically used to finish the deflation. Any pending output will be
748 returned via \f(CW$out\fR.
749 \&\f(CW$status\fR will have a value \f(CW\*(C`Z_OK\*(C'\fR if successful.
750 .PP
751 In a scalar context \f(CW\*(C`flush\*(C'\fR will return \f(CW$out\fR only.
752 .PP
753 Note that flushing can seriously degrade the compression ratio, so it
754 should only be used to terminate a decompression (using \f(CW\*(C`Z_FINISH\*(C'\fR) or
755 when you want to create a \fIfull flush point\fR (using \f(CW\*(C`Z_FULL_FLUSH\*(C'\fR).
756 .PP
757 By default the \f(CW\*(C`flush_type\*(C'\fR used is \f(CW\*(C`Z_FINISH\*(C'\fR. Other valid values
758 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
759 and \f(CW\*(C`Z_FULL_FLUSH\*(C'\fR. It is strongly recommended that you only set the
760 \&\f(CW\*(C`flush_type\*(C'\fR parameter if you fully understand the implications of
761 what it does. See the \f(CW\*(C`zlib\*(C'\fR documentation for details.
762 .ie n .Sh "\fB$status = \fP\fB$d\fP\fB\->deflateParams([\s-1OPT\s0])\fP"
763 .el .Sh "\fB$status = \fP\f(CB$d\fP\fB\->deflateParams([\s-1OPT\s0])\fP"
764 .IX Subsection "$status = $d->deflateParams([OPT])"
765 Change settings for the deflate stream \f(CW$d\fR.
766 .PP
767 The list of the valid options is shown below. Options not specified
768 will remain unchanged.
769 .IP "\fB\-Level\fR" 5
770 .IX Item "-Level"
771 Defines the compression level. Valid values are 0 through 9,
772 \&\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
773 \&\f(CW\*(C`Z_DEFAULT_COMPRESSION\*(C'\fR.
774 .IP "\fB\-Strategy\fR" 5
775 .IX Item "-Strategy"
776 Defines the strategy used to tune the compression. The valid values are
777 \&\f(CW\*(C`Z_DEFAULT_STRATEGY\*(C'\fR, \f(CW\*(C`Z_FILTERED\*(C'\fR and \f(CW\*(C`Z_HUFFMAN_ONLY\*(C'\fR. 
778 .Sh "\fB$d\->\fP\f(BIdict_adler()\fP\fB\fP"
779 .IX Subsection "$d->dict_adler()"
780 Returns the adler32 value for the dictionary.
781 .Sh "\fB$d\->\fP\f(BImsg()\fP\fB\fP"
782 .IX Subsection "$d->msg()"
783 Returns the last error message generated by zlib.
784 .Sh "\fB$d\->\fP\f(BItotal_in()\fP\fB\fP"
785 .IX Subsection "$d->total_in()"
786 Returns the total number of bytes uncompressed bytes input to deflate.
787 .Sh "\fB$d\->\fP\f(BItotal_out()\fP\fB\fP"
788 .IX Subsection "$d->total_out()"
789 Returns the total number of compressed bytes output from deflate.
790 .Sh "Example"
791 .IX Subsection "Example"
792 Here is a trivial example of using \f(CW\*(C`deflate\*(C'\fR. It simply reads standard
793 input, deflates it and writes it to standard output.
794 .PP
795 .Vb 2
796 \&    use strict ;
797 \&    use warnings ;
798 .Ve
799 .PP
800 .Vb 1
801 \&    use Compress::Zlib ;
802 .Ve
803 .PP
804 .Vb 4
805 \&    binmode STDIN;
806 \&    binmode STDOUT;
807 \&    my $x = deflateInit()
808 \&       or die "Cannot create a deflation stream\en" ;
809 .Ve
810 .PP
811 .Vb 4
812 \&    my ($output, $status) ;
813 \&    while (<>)
814 \&    {
815 \&        ($output, $status) = $x\->deflate($_) ;
816 .Ve
817 .PP
818 .Vb 2
819 \&        $status == Z_OK
820 \&            or die "deflation failed\en" ;
821 .Ve
822 .PP
823 .Vb 2
824 \&        print $output ;
825 \&    }
826 .Ve
827 .PP
828 .Vb 1
829 \&    ($output, $status) = $x\->flush() ;
830 .Ve
831 .PP
832 .Vb 2
833 \&    $status == Z_OK
834 \&        or die "deflation failed\en" ;
835 .Ve
836 .PP
837 .Vb 1
838 \&    print $output ;
839 .Ve
840 .SH "Inflate Interface"
841 .IX Header "Inflate Interface"
842 This section defines the interface available that allows in-memory
843 uncompression using the \fIdeflate\fR interface provided by zlib.
844 .PP
845 Here is a definition of the interface:
846 .ie n .Sh "\fB($i, \fP\fB$status\fP\fB) = \fP\f(BIinflateInit()\fP\fB\fP"
847 .el .Sh "\fB($i, \fP\f(CB$status\fP\fB) = \fP\f(BIinflateInit()\fP\fB\fP"
848 .IX Subsection "($i, $status) = inflateInit()"
849 Initialises an inflation stream. 
850 .PP
851 In a list context it returns the inflation stream, \f(CW$i\fR, and the
852 \&\fIzlib\fR status code in \f(CW$status\fR. In a scalar context it returns the
853 inflation stream only.
854 .PP
855 If successful, \f(CW$i\fR will hold the inflation stream and \f(CW$status\fR will
856 be \f(CW\*(C`Z_OK\*(C'\fR.
857 .PP
858 If not successful, \f(CW$i\fR will be \fIundef\fR and \f(CW$status\fR will hold the
859 \&\fIzlib\fR error code.
860 .PP
861 The function optionally takes a number of named options specified as
862 \&\f(CW\*(C`\-Name=>value\*(C'\fR pairs. This allows individual options to be
863 tailored without having to specify them all in the parameter list.
864 .PP
865 For backward compatibility, it is also possible to pass the parameters
866 as a reference to a hash containing the name=>value pairs.
867 .PP
868 The function takes one optional parameter, a reference to a hash.  The
869 contents of the hash allow the deflation interface to be tailored.
870 .PP
871 Here is a list of the valid options:
872 .IP "\fB\-WindowBits\fR" 5
873 .IX Item "-WindowBits"
874 To uncompress an \s-1RFC\s0 1950 data stream, set \f(CW\*(C`WindowBits\*(C'\fR to a positive number.
875 .Sp
876 To uncompress an \s-1RFC\s0 1951 data stream, set \f(CW\*(C`WindowBits\*(C'\fR to \f(CW\*(C`\-MAX_WBITS\*(C'\fR.
877 .Sp
878 For a full definition of the meaning and valid values for \f(CW\*(C`WindowBits\*(C'\fR refer
879 to the \fIzlib\fR documentation for \fIinflateInit2\fR.
880 .Sp
881 Defaults to \s-1MAX_WBITS\s0.
882 .IP "\fB\-Bufsize\fR" 5
883 .IX Item "-Bufsize"
884 Sets the initial size for the inflation buffer. If the buffer has to be
885 reallocated to increase the size, it will grow in increments of
886 \&\f(CW\*(C`Bufsize\*(C'\fR. 
887 .Sp
888 Default is 4096.
889 .IP "\fB\-Dictionary\fR" 5
890 .IX Item "-Dictionary"
891 The default is no dictionary.
892 .PP
893 Here is an example of using the \f(CW\*(C`inflateInit\*(C'\fR optional parameter to
894 override the default buffer size.
895 .PP
896 .Vb 1
897 \&    inflateInit( \-Bufsize => 300 ) ;
898 .Ve
899 .ie n .Sh "\fB($out, \fP\fB$status\fP\fB) = \fP\f(BI$i\fP\fB\->inflate($buffer)\fP"
900 .el .Sh "\fB($out, \fP\f(CB$status\fP\fB) = \fP\f(CB$i\fP\fB\->inflate($buffer)\fP"
901 .IX Subsection "($out, $status) = $i->inflate($buffer)"
902 Inflates the complete contents of \f(CW$buffer\fR. The buffer can either be
903 a scalar or a scalar reference.
904 .PP
905 Returns \f(CW\*(C`Z_OK\*(C'\fR if successful and \f(CW\*(C`Z_STREAM_END\*(C'\fR if the end of the
906 compressed data has been successfully reached. 
907 If not successful, \f(CW$out\fR will be \fIundef\fR and \f(CW$status\fR will hold
908 the \fIzlib\fR error code.
909 .PP
910 The \f(CW$buffer\fR parameter is modified by \f(CW\*(C`inflate\*(C'\fR. On completion it
911 will contain what remains of the input buffer after inflation. This
912 means that \f(CW$buffer\fR will be an empty string when the return status is
913 \&\f(CW\*(C`Z_OK\*(C'\fR. When the return status is \f(CW\*(C`Z_STREAM_END\*(C'\fR the \f(CW$buffer\fR
914 parameter will contains what (if anything) was stored in the input
915 buffer after the deflated data stream.
916 .PP
917 This feature is useful when processing a file format that encapsulates
918 a  compressed data stream (e.g. gzip, zip).
919 .ie n .Sh "\fB$status = \fP\fB$i\fP\fB\->inflateSync($buffer)\fP"
920 .el .Sh "\fB$status = \fP\f(CB$i\fP\fB\->inflateSync($buffer)\fP"
921 .IX Subsection "$status = $i->inflateSync($buffer)"
922 Scans \f(CW$buffer\fR until it reaches either a \fIfull flush point\fR or the
923 end of the buffer.
924 .PP
925 If a \fIfull flush point\fR is found, \f(CW\*(C`Z_OK\*(C'\fR is returned and \f(CW$buffer\fR
926 will be have all data up to the flush point removed. This can then be
927 passed to the \f(CW\*(C`deflate\*(C'\fR method.
928 .PP
929 Any other return code means that a flush point was not found. If more
930 data is available, \f(CW\*(C`inflateSync\*(C'\fR can be called repeatedly with more
931 compressed data until the flush point is found.
932 .Sh "\fB$i\->\fP\f(BIdict_adler()\fP\fB\fP"
933 .IX Subsection "$i->dict_adler()"
934 Returns the adler32 value for the dictionary.
935 .Sh "\fB$i\->\fP\f(BImsg()\fP\fB\fP"
936 .IX Subsection "$i->msg()"
937 Returns the last error message generated by zlib.
938 .Sh "\fB$i\->\fP\f(BItotal_in()\fP\fB\fP"
939 .IX Subsection "$i->total_in()"
940 Returns the total number of bytes compressed bytes input to inflate.
941 .Sh "\fB$i\->\fP\f(BItotal_out()\fP\fB\fP"
942 .IX Subsection "$i->total_out()"
943 Returns the total number of uncompressed bytes output from inflate.
944 .Sh "Example"
945 .IX Subsection "Example"
946 Here is an example of using \f(CW\*(C`inflate\*(C'\fR.
947 .PP
948 .Vb 2
949 \&    use strict ;
950 \&    use warnings ;
951 .Ve
952 .PP
953 .Vb 1
954 \&    use Compress::Zlib ;
955 .Ve
956 .PP
957 .Vb 2
958 \&    my $x = inflateInit()
959 \&       or die "Cannot create a inflation stream\en" ;
960 .Ve
961 .PP
962 .Vb 3
963 \&    my $input = '' ;
964 \&    binmode STDIN;
965 \&    binmode STDOUT;
966 .Ve
967 .PP
968 .Vb 4
969 \&    my ($output, $status) ;
970 \&    while (read(STDIN, $input, 4096))
971 \&    {
972 \&        ($output, $status) = $x\->inflate(\e$input) ;
973 .Ve
974 .PP
975 .Vb 2
976 \&        print $output 
977 \&            if $status == Z_OK or $status == Z_STREAM_END ;
978 .Ve
979 .PP
980 .Vb 2
981 \&        last if $status != Z_OK ;
982 \&    }
983 .Ve
984 .PP
985 .Vb 2
986 \&    die "inflation failed\en"
987 \&        unless $status == Z_STREAM_END ;
988 .Ve
989 .SH "CHECKSUM FUNCTIONS"
990 .IX Header "CHECKSUM FUNCTIONS"
991 Two functions are provided by \fIzlib\fR to calculate checksums. For the
992 Perl interface, the order of the two parameters in both functions has
993 been reversed. This allows both running checksums and one off
994 calculations to be done.
995 .PP
996 .Vb 2
997 \&    $crc = adler32($buffer [,$crc]) ;
998 \&    $crc = crc32($buffer [,$crc]) ;
999 .Ve
1000 .PP
1001 The buffer parameters can either be a scalar or a scalar reference.
1002 .PP
1003 If the \f(CW$crc\fR parameters is \f(CW\*(C`undef\*(C'\fR, the crc value will be reset.
1004 .PP
1005 If you have built this module with zlib 1.2.3 or better, two more
1006 CRC-related functions are available.
1007 .PP
1008 .Vb 2
1009 \&    $crc = adler32_combine($crc1, $crc2, $len2)l
1010 \&    $crc = crc32_combine($adler1, $adler2, $len2)
1011 .Ve
1012 .PP
1013 These functions allow checksums to be merged.
1014 .SH "Misc"
1015 .IX Header "Misc"
1016 .ie n .Sh "my $version\fP = \fICompress::Zlib::zlib_version();"
1017 .el .Sh "my \f(CW$version\fP = \fICompress::Zlib::zlib_version()\fP;"
1018 .IX Subsection "my $version = Compress::Zlib::zlib_version();"
1019 Returns the version of the zlib library.
1020 .SH "CONSTANTS"
1021 .IX Header "CONSTANTS"
1022 All the \fIzlib\fR constants are automatically imported when you make use
1023 of \fICompress::Zlib\fR.
1024 .SH "SEE ALSO"
1025 .IX Header "SEE ALSO"
1026 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
1027 .PP
1028 Compress::Zlib::FAQ
1029 .PP
1030 File::GlobMapper, Archive::Zip,
1031 Archive::Tar,
1032 IO::Zlib
1033 .PP
1034 For \s-1RFC\s0 1950, 1951 and 1952 see 
1035 \&\fIhttp://www.faqs.org/rfcs/rfc1950.html\fR,
1036 \&\fIhttp://www.faqs.org/rfcs/rfc1951.html\fR and
1037 \&\fIhttp://www.faqs.org/rfcs/rfc1952.html\fR
1038 .PP
1039 The \fIzlib\fR compression library was written by Jean-loup Gailly
1040 \&\fIgzip@prep.ai.mit.edu\fR and Mark Adler \fImadler@alumni.caltech.edu\fR.
1041 .PP
1042 The primary site for the \fIzlib\fR compression library is
1043 \&\fIhttp://www.zlib.org\fR.
1044 .PP
1045 The primary site for gzip is \fIhttp://www.gzip.org\fR.
1046 .SH "AUTHOR"
1047 .IX Header "AUTHOR"
1048 This module was written by Paul Marquess, \fIpmqs@cpan.org\fR. 
1049 .SH "MODIFICATION HISTORY"
1050 .IX Header "MODIFICATION HISTORY"
1051 See the Changes file.
1052 .SH "COPYRIGHT AND LICENSE"
1053 .IX Header "COPYRIGHT AND LICENSE"
1054 Copyright (c) 1995\-2009 Paul Marquess. All rights reserved.
1055 .PP
1056 This program is free software; you can redistribute it and/or
1057 modify it under the same terms as Perl itself.