Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / IO::Uncompress::Gunzip.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 "IO::Uncompress::Gunzip 3"
132 .TH IO::Uncompress::Gunzip 3 "2009-11-09" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 IO::Uncompress::Gunzip \- Read RFC 1952 files/buffers
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 1
138 \&    use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
139 .Ve
140 .PP
141 .Vb 2
142 \&    my $status = gunzip $input => $output [,OPTS]
143 \&        or die "gunzip failed: $GunzipError\en";
144 .Ve
145 .PP
146 .Vb 2
147 \&    my $z = new IO::Uncompress::Gunzip $input [OPTS] 
148 \&        or die "gunzip failed: $GunzipError\en";
149 .Ve
150 .PP
151 .Vb 7
152 \&    $status = $z\->read($buffer)
153 \&    $status = $z\->read($buffer, $length)
154 \&    $status = $z\->read($buffer, $length, $offset)
155 \&    $line = $z\->getline()
156 \&    $char = $z\->getc()
157 \&    $char = $z\->ungetc()
158 \&    $char = $z\->opened()
159 .Ve
160 .PP
161 .Vb 1
162 \&    $status = $z\->inflateSync()
163 .Ve
164 .PP
165 .Vb 9
166 \&    $data = $z\->trailingData()
167 \&    $status = $z\->nextStream()
168 \&    $data = $z\->getHeaderInfo()
169 \&    $z\->tell()
170 \&    $z\->seek($position, $whence)
171 \&    $z\->binmode()
172 \&    $z\->fileno()
173 \&    $z\->eof()
174 \&    $z\->close()
175 .Ve
176 .PP
177 .Vb 1
178 \&    $GunzipError ;
179 .Ve
180 .PP
181 .Vb 1
182 \&    # IO::File mode
183 .Ve
184 .PP
185 .Vb 10
186 \&    <$z>
187 \&    read($z, $buffer);
188 \&    read($z, $buffer, $length);
189 \&    read($z, $buffer, $length, $offset);
190 \&    tell($z)
191 \&    seek($z, $position, $whence)
192 \&    binmode($z)
193 \&    fileno($z)
194 \&    eof($z)
195 \&    close($z)
196 .Ve
197 .SH "DESCRIPTION"
198 .IX Header "DESCRIPTION"
199 This module provides a Perl interface that allows the reading of
200 files/buffers that conform to \s-1RFC\s0 1952.
201 .PP
202 For writing \s-1RFC\s0 1952 files/buffers, see the companion module IO::Compress::Gzip.
203 .SH "Functional Interface"
204 .IX Header "Functional Interface"
205 A top-level function, \f(CW\*(C`gunzip\*(C'\fR, is provided to carry out
206 \&\*(L"one\-shot\*(R" uncompression between buffers and/or files. For finer
207 control over the uncompression process, see the \*(L"\s-1OO\s0 Interface\*(R"
208 section.
209 .PP
210 .Vb 1
211 \&    use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
212 .Ve
213 .PP
214 .Vb 2
215 \&    gunzip $input => $output [,OPTS] 
216 \&        or die "gunzip failed: $GunzipError\en";
217 .Ve
218 .PP
219 The functional interface needs Perl5.005 or better.
220 .ie n .Sh "gunzip $input\fP => \f(CW$output [, \s-1OPTS\s0]"
221 .el .Sh "gunzip \f(CW$input\fP => \f(CW$output\fP [, \s-1OPTS\s0]"
222 .IX Subsection "gunzip $input => $output [, OPTS]"
223 \&\f(CW\*(C`gunzip\*(C'\fR expects at least two parameters, \f(CW$input\fR and \f(CW$output\fR.
224 .PP
225 \fIThe \f(CI$input\fI parameter\fR
226 .IX Subsection "The $input parameter"
227 .PP
228 The parameter, \f(CW$input\fR, is used to define the source of
229 the compressed data. 
230 .PP
231 It can take one of the following forms:
232 .IP "A filename" 5
233 .IX Item "A filename"
234 If the \f(CW$input\fR parameter is a simple scalar, it is assumed to be a
235 filename. This file will be opened for reading and the input data
236 will be read from it.
237 .IP "A filehandle" 5
238 .IX Item "A filehandle"
239 If the \f(CW$input\fR parameter is a filehandle, the input data will be
240 read from it.
241 The string '\-' can be used as an alias for standard input.
242 .IP "A scalar reference" 5
243 .IX Item "A scalar reference"
244 If \f(CW$input\fR is a scalar reference, the input data will be read
245 from \f(CW$$input\fR.
246 .IP "An array reference" 5
247 .IX Item "An array reference"
248 If \f(CW$input\fR is an array reference, each element in the array must be a
249 filename.
250 .Sp
251 The input data will be read from each file in turn. 
252 .Sp
253 The complete array will be walked to ensure that it only
254 contains valid filenames before any data is uncompressed.
255 .IP "An Input FileGlob string" 5
256 .IX Item "An Input FileGlob string"
257 If \f(CW$input\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R"
258 \&\f(CW\*(C`gunzip\*(C'\fR will assume that it is an \fIinput fileglob string\fR. The
259 input is the list of files that match the fileglob.
260 .Sp
261 If the fileglob does not match any files ...
262 .Sp
263 See File::GlobMapper for more details.
264 .PP
265 If the \f(CW$input\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned.
266 .PP
267 \fIThe \f(CI$output\fI parameter\fR
268 .IX Subsection "The $output parameter"
269 .PP
270 The parameter \f(CW$output\fR is used to control the destination of the
271 uncompressed data. This parameter can take one of these forms.
272 .IP "A filename" 5
273 .IX Item "A filename"
274 If the \f(CW$output\fR parameter is a simple scalar, it is assumed to be a
275 filename.  This file will be opened for writing and the uncompressed
276 data will be written to it.
277 .IP "A filehandle" 5
278 .IX Item "A filehandle"
279 If the \f(CW$output\fR parameter is a filehandle, the uncompressed data
280 will be written to it.
281 The string '\-' can be used as an alias for standard output.
282 .IP "A scalar reference" 5
283 .IX Item "A scalar reference"
284 If \f(CW$output\fR is a scalar reference, the uncompressed data will be
285 stored in \f(CW$$output\fR.
286 .IP "An Array Reference" 5
287 .IX Item "An Array Reference"
288 If \f(CW$output\fR is an array reference, the uncompressed data will be
289 pushed onto the array.
290 .IP "An Output FileGlob" 5
291 .IX Item "An Output FileGlob"
292 If \f(CW$output\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R"
293 \&\f(CW\*(C`gunzip\*(C'\fR will assume that it is an \fIoutput fileglob string\fR. The
294 output is the list of files that match the fileglob.
295 .Sp
296 When \f(CW$output\fR is an fileglob string, \f(CW$input\fR must also be a fileglob
297 string. Anything else is an error.
298 .PP
299 If the \f(CW$output\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned.
300 .Sh "Notes"
301 .IX Subsection "Notes"
302 When \f(CW$input\fR maps to multiple compressed files/buffers and \f(CW$output\fR is
303 a single file/buffer, after uncompression \f(CW$output\fR will contain a
304 concatenation of all the uncompressed data from each of the input
305 files/buffers.
306 .Sh "Optional Parameters"
307 .IX Subsection "Optional Parameters"
308 Unless specified below, the optional parameters for \f(CW\*(C`gunzip\*(C'\fR,
309 \&\f(CW\*(C`OPTS\*(C'\fR, are the same as those used with the \s-1OO\s0 interface defined in the
310 \&\*(L"Constructor Options\*(R" section below.
311 .ie n .IP """AutoClose => 0|1""" 5
312 .el .IP "\f(CWAutoClose => 0|1\fR" 5
313 .IX Item "AutoClose => 0|1"
314 This option applies to any input or output data streams to 
315 \&\f(CW\*(C`gunzip\*(C'\fR that are filehandles.
316 .Sp
317 If \f(CW\*(C`AutoClose\*(C'\fR is specified, and the value is true, it will result in all
318 input and/or output filehandles being closed once \f(CW\*(C`gunzip\*(C'\fR has
319 completed.
320 .Sp
321 This parameter defaults to 0.
322 .ie n .IP """BinModeOut => 0|1""" 5
323 .el .IP "\f(CWBinModeOut => 0|1\fR" 5
324 .IX Item "BinModeOut => 0|1"
325 When writing to a file or filehandle, set \f(CW\*(C`binmode\*(C'\fR before writing to the
326 file.
327 .Sp
328 Defaults to 0.
329 .ie n .IP """Append => 0|1""" 5
330 .el .IP "\f(CWAppend => 0|1\fR" 5
331 .IX Item "Append => 0|1"
332 The behaviour of this option is dependent on the type of output data
333 stream.
334 .RS 5
335 .IP "* A Buffer" 5
336 .IX Item "A Buffer"
337 If \f(CW\*(C`Append\*(C'\fR is enabled, all uncompressed data will be append to the end of
338 the output buffer. Otherwise the output buffer will be cleared before any
339 uncompressed data is written to it.
340 .IP "* A Filename" 5
341 .IX Item "A Filename"
342 If \f(CW\*(C`Append\*(C'\fR is enabled, the file will be opened in append mode. Otherwise
343 the contents of the file, if any, will be truncated before any uncompressed
344 data is written to it.
345 .IP "* A Filehandle" 5
346 .IX Item "A Filehandle"
347 If \f(CW\*(C`Append\*(C'\fR is enabled, the filehandle will be positioned to the end of
348 the file via a call to \f(CW\*(C`seek\*(C'\fR before any uncompressed data is
349 written to it.  Otherwise the file pointer will not be moved.
350 .RE
351 .RS 5
352 .Sp
353 When \f(CW\*(C`Append\*(C'\fR is specified, and set to true, it will \fIappend\fR all uncompressed 
354 data to the output data stream.
355 .Sp
356 So when the output is a filehandle it will carry out a seek to the eof
357 before writing any uncompressed data. If the output is a filename, it will be opened for
358 appending. If the output is a buffer, all uncompressed data will be appened to
359 the existing buffer.
360 .Sp
361 Conversely when \f(CW\*(C`Append\*(C'\fR is not specified, or it is present and is set to
362 false, it will operate as follows.
363 .Sp
364 When the output is a filename, it will truncate the contents of the file
365 before writing any uncompressed data. If the output is a filehandle
366 its position will not be changed. If the output is a buffer, it will be
367 wiped before any uncompressed data is output.
368 .Sp
369 Defaults to 0.
370 .RE
371 .ie n .IP """MultiStream => 0|1""" 5
372 .el .IP "\f(CWMultiStream => 0|1\fR" 5
373 .IX Item "MultiStream => 0|1"
374 If the input file/buffer contains multiple compressed data streams, this
375 option will uncompress the whole lot as a single data stream.
376 .Sp
377 Defaults to 0.
378 .ie n .IP """TrailingData => $scalar""" 5
379 .el .IP "\f(CWTrailingData => $scalar\fR" 5
380 .IX Item "TrailingData => $scalar"
381 Returns the data, if any, that is present immediately after the compressed
382 data stream once uncompression is complete. 
383 .Sp
384 This option can be used when there is useful information immediately
385 following the compressed data stream, and you don't know the length of the
386 compressed data stream.
387 .Sp
388 If the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from the
389 end of the compressed data stream to the end of the buffer.
390 .Sp
391 If the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that is
392 left in the filehandle input buffer once the end of the compressed data
393 stream has been reached. You can then use the filehandle to read the rest
394 of the input file. 
395 .Sp
396 Don't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename.
397 .Sp
398 If you know the length of the compressed data stream before you start
399 uncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the
400 \&\f(CW\*(C`InputLength\*(C'\fR option.
401 .Sh "Examples"
402 .IX Subsection "Examples"
403 To read the contents of the file \f(CW\*(C`file1.txt.gz\*(C'\fR and write the
404 uncompressed data to the file \f(CW\*(C`file1.txt\*(C'\fR.
405 .PP
406 .Vb 3
407 \&    use strict ;
408 \&    use warnings ;
409 \&    use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
410 .Ve
411 .PP
412 .Vb 4
413 \&    my $input = "file1.txt.gz";
414 \&    my $output = "file1.txt";
415 \&    gunzip $input => $output
416 \&        or die "gunzip failed: $GunzipError\en";
417 .Ve
418 .PP
419 To read from an existing Perl filehandle, \f(CW$input\fR, and write the
420 uncompressed data to a buffer, \f(CW$buffer\fR.
421 .PP
422 .Vb 4
423 \&    use strict ;
424 \&    use warnings ;
425 \&    use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
426 \&    use IO::File ;
427 .Ve
428 .PP
429 .Vb 5
430 \&    my $input = new IO::File "<file1.txt.gz"
431 \&        or die "Cannot open 'file1.txt.gz': $!\en" ;
432 \&    my $buffer ;
433 \&    gunzip $input => \e$buffer 
434 \&        or die "gunzip failed: $GunzipError\en";
435 .Ve
436 .PP
437 To uncompress all files in the directory \*(L"/my/home\*(R" that match \*(L"*.txt.gz\*(R" and store the compressed data in the same directory
438 .PP
439 .Vb 3
440 \&    use strict ;
441 \&    use warnings ;
442 \&    use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
443 .Ve
444 .PP
445 .Vb 2
446 \&    gunzip '</my/home/*.txt.gz>' => '</my/home/#1.txt>'
447 \&        or die "gunzip failed: $GunzipError\en";
448 .Ve
449 .PP
450 and if you want to compress each file one at a time, this will do the trick
451 .PP
452 .Vb 3
453 \&    use strict ;
454 \&    use warnings ;
455 \&    use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
456 .Ve
457 .PP
458 .Vb 7
459 \&    for my $input ( glob "/my/home/*.txt.gz" )
460 \&    {
461 \&        my $output = $input;
462 \&        $output =~ s/.gz// ;
463 \&        gunzip $input => $output 
464 \&            or die "Error compressing '$input': $GunzipError\en";
465 \&    }
466 .Ve
467 .SH "OO Interface"
468 .IX Header "OO Interface"
469 .Sh "Constructor"
470 .IX Subsection "Constructor"
471 The format of the constructor for IO::Uncompress::Gunzip is shown below
472 .PP
473 .Vb 2
474 \&    my $z = new IO::Uncompress::Gunzip $input [OPTS]
475 \&        or die "IO::Uncompress::Gunzip failed: $GunzipError\en";
476 .Ve
477 .PP
478 Returns an \f(CW\*(C`IO::Uncompress::Gunzip\*(C'\fR object on success and undef on failure.
479 The variable \f(CW$GunzipError\fR will contain an error message on failure.
480 .PP
481 If you are running Perl 5.005 or better the object, \f(CW$z\fR, returned from
482 IO::Uncompress::Gunzip can be used exactly like an IO::File filehandle.
483 This means that all normal input file operations can be carried out with
484 \&\f(CW$z\fR.  For example, to read a line from a compressed file/buffer you can
485 use either of these forms
486 .PP
487 .Vb 2
488 \&    $line = $z\->getline();
489 \&    $line = <$z>;
490 .Ve
491 .PP
492 The mandatory parameter \f(CW$input\fR is used to determine the source of the
493 compressed data. This parameter can take one of three forms.
494 .IP "A filename" 5
495 .IX Item "A filename"
496 If the \f(CW$input\fR parameter is a scalar, it is assumed to be a filename. This
497 file will be opened for reading and the compressed data will be read from it.
498 .IP "A filehandle" 5
499 .IX Item "A filehandle"
500 If the \f(CW$input\fR parameter is a filehandle, the compressed data will be
501 read from it.
502 The string '\-' can be used as an alias for standard input.
503 .IP "A scalar reference" 5
504 .IX Item "A scalar reference"
505 If \f(CW$input\fR is a scalar reference, the compressed data will be read from
506 \&\f(CW$$output\fR.
507 .Sh "Constructor Options"
508 .IX Subsection "Constructor Options"
509 The option names defined below are case insensitive and can be optionally
510 prefixed by a '\-'.  So all of the following are valid
511 .PP
512 .Vb 4
513 \&    \-AutoClose
514 \&    \-autoclose
515 \&    AUTOCLOSE
516 \&    autoclose
517 .Ve
518 .PP
519 \&\s-1OPTS\s0 is a combination of the following options:
520 .ie n .IP """AutoClose => 0|1""" 5
521 .el .IP "\f(CWAutoClose => 0|1\fR" 5
522 .IX Item "AutoClose => 0|1"
523 This option is only valid when the \f(CW$input\fR parameter is a filehandle. If
524 specified, and the value is true, it will result in the file being closed once
525 either the \f(CW\*(C`close\*(C'\fR method is called or the IO::Uncompress::Gunzip object is
526 destroyed.
527 .Sp
528 This parameter defaults to 0.
529 .ie n .IP """MultiStream => 0|1""" 5
530 .el .IP "\f(CWMultiStream => 0|1\fR" 5
531 .IX Item "MultiStream => 0|1"
532 Allows multiple concatenated compressed streams to be treated as a single
533 compressed stream. Decompression will stop once either the end of the
534 file/buffer is reached, an error is encountered (premature eof, corrupt
535 compressed data) or the end of a stream is not immediately followed by the
536 start of another stream.
537 .Sp
538 This parameter defaults to 0.
539 .ie n .IP """Prime => $string""" 5
540 .el .IP "\f(CWPrime => $string\fR" 5
541 .IX Item "Prime => $string"
542 This option will uncompress the contents of \f(CW$string\fR before processing the
543 input file/buffer.
544 .Sp
545 This option can be useful when the compressed data is embedded in another
546 file/data structure and it is not possible to work out where the compressed
547 data begins without having to read the first few bytes. If this is the
548 case, the uncompression can be \fIprimed\fR with these bytes using this
549 option.
550 .ie n .IP """Transparent => 0|1""" 5
551 .el .IP "\f(CWTransparent => 0|1\fR" 5
552 .IX Item "Transparent => 0|1"
553 If this option is set and the input file/buffer is not compressed data,
554 the module will allow reading of it anyway.
555 .Sp
556 In addition, if the input file/buffer does contain compressed data and
557 there is non-compressed data immediately following it, setting this option
558 will make this module treat the whole file/bufffer as a single data stream.
559 .Sp
560 This option defaults to 1.
561 .ie n .IP """BlockSize => $num""" 5
562 .el .IP "\f(CWBlockSize => $num\fR" 5
563 .IX Item "BlockSize => $num"
564 When reading the compressed input data, IO::Uncompress::Gunzip will read it in
565 blocks of \f(CW$num\fR bytes.
566 .Sp
567 This option defaults to 4096.
568 .ie n .IP """InputLength => $size""" 5
569 .el .IP "\f(CWInputLength => $size\fR" 5
570 .IX Item "InputLength => $size"
571 When present this option will limit the number of compressed bytes read
572 from the input file/buffer to \f(CW$size\fR. This option can be used in the
573 situation where there is useful data directly after the compressed data
574 stream and you know beforehand the exact length of the compressed data
575 stream. 
576 .Sp
577 This option is mostly used when reading from a filehandle, in which case
578 the file pointer will be left pointing to the first byte directly after the
579 compressed data stream.
580 .Sp
581 This option defaults to off.
582 .ie n .IP """Append => 0|1""" 5
583 .el .IP "\f(CWAppend => 0|1\fR" 5
584 .IX Item "Append => 0|1"
585 This option controls what the \f(CW\*(C`read\*(C'\fR method does with uncompressed data.
586 .Sp
587 If set to 1, all uncompressed data will be appended to the output parameter
588 of the \f(CW\*(C`read\*(C'\fR method.
589 .Sp
590 If set to 0, the contents of the output parameter of the \f(CW\*(C`read\*(C'\fR method
591 will be overwritten by the uncompressed data.
592 .Sp
593 Defaults to 0.
594 .ie n .IP """Strict => 0|1""" 5
595 .el .IP "\f(CWStrict => 0|1\fR" 5
596 .IX Item "Strict => 0|1"
597 This option controls whether the extra checks defined below are used when
598 carrying out the decompression. When Strict is on, the extra tests are
599 carried out, when Strict is off they are not.
600 .Sp
601 The default for this option is off.
602 .RS 5
603 .IP "1" 5
604 .IX Item "1"
605 If the \s-1FHCRC\s0 bit is set in the gzip \s-1FLG\s0 header byte, the \s-1CRC16\s0 bytes in the
606 header must match the crc16 value of the gzip header actually read.
607 .IP "2" 5
608 .IX Item "2"
609 If the gzip header contains a name field (\s-1FNAME\s0) it consists solely of \s-1ISO\s0
610 8859\-1 characters.
611 .IP "3" 5
612 .IX Item "3"
613 If the gzip header contains a comment field (\s-1FCOMMENT\s0) it consists solely
614 of \s-1ISO\s0 8859\-1 characters plus line\-feed.
615 .IP "4" 5
616 .IX Item "4"
617 If the gzip \s-1FEXTRA\s0 header field is present it must conform to the sub-field
618 structure as defined in \s-1RFC\s0 1952.
619 .IP "5" 5
620 .IX Item "5"
621 The \s-1CRC32\s0 and \s-1ISIZE\s0 trailer fields must be present.
622 .IP "6" 5
623 .IX Item "6"
624 The value of the \s-1CRC32\s0 field read must match the crc32 value of the
625 uncompressed data actually contained in the gzip file.
626 .IP "7" 5
627 .IX Item "7"
628 The value of the \s-1ISIZE\s0 fields read must match the length of the
629 uncompressed data actually read from the file.
630 .RE
631 .RS 5
632 .RE
633 .ie n .IP """ParseExtra => 0|1"" If the gzip \s-1FEXTRA\s0 header field is present and this option is set, it will force the module to check that it conforms to the sub-field structure as defined in \s-1RFC\s0 1952." 5
634 .el .IP "\f(CWParseExtra => 0|1\fR If the gzip \s-1FEXTRA\s0 header field is present and this option is set, it will force the module to check that it conforms to the sub-field structure as defined in \s-1RFC\s0 1952." 5
635 .IX Item "ParseExtra => 0|1 If the gzip FEXTRA header field is present and this option is set, it will force the module to check that it conforms to the sub-field structure as defined in RFC 1952."
636 If the \f(CW\*(C`Strict\*(C'\fR is on it will automatically enable this option.
637 .Sp
638 Defaults to 0.
639 .Sh "Examples"
640 .IX Subsection "Examples"
641 \&\s-1TODO\s0
642 .SH "Methods"
643 .IX Header "Methods"
644 .Sh "read"
645 .IX Subsection "read"
646 Usage is
647 .PP
648 .Vb 1
649 \&    $status = $z\->read($buffer)
650 .Ve
651 .PP
652 Reads a block of compressed data (the size the the compressed block is
653 determined by the \f(CW\*(C`Buffer\*(C'\fR option in the constructor), uncompresses it and
654 writes any uncompressed data into \f(CW$buffer\fR. If the \f(CW\*(C`Append\*(C'\fR parameter is
655 set in the constructor, the uncompressed data will be appended to the
656 \&\f(CW$buffer\fR parameter. Otherwise \f(CW$buffer\fR will be overwritten.
657 .PP
658 Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof
659 or a negative number on error.
660 .Sh "read"
661 .IX Subsection "read"
662 Usage is
663 .PP
664 .Vb 2
665 \&    $status = $z\->read($buffer, $length)
666 \&    $status = $z\->read($buffer, $length, $offset)
667 .Ve
668 .PP
669 .Vb 2
670 \&    $status = read($z, $buffer, $length)
671 \&    $status = read($z, $buffer, $length, $offset)
672 .Ve
673 .PP
674 Attempt to read \f(CW$length\fR bytes of uncompressed data into \f(CW$buffer\fR.
675 .PP
676 The main difference between this form of the \f(CW\*(C`read\*(C'\fR method and the
677 previous one, is that this one will attempt to return \fIexactly\fR \f(CW$length\fR
678 bytes. The only circumstances that this function will not is if end-of-file
679 or an \s-1IO\s0 error is encountered.
680 .PP
681 Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof
682 or a negative number on error.
683 .Sh "getline"
684 .IX Subsection "getline"
685 Usage is
686 .PP
687 .Vb 2
688 \&    $line = $z\->getline()
689 \&    $line = <$z>
690 .Ve
691 .PP
692 Reads a single line. 
693 .PP
694 This method fully supports the use of of the variable \f(CW$/\fR (or
695 \&\f(CW$INPUT_RECORD_SEPARATOR\fR or \f(CW$RS\fR when \f(CW\*(C`English\*(C'\fR is in use) to
696 determine what constitutes an end of line. Paragraph mode, record mode and
697 file slurp mode are all supported. 
698 .Sh "getc"
699 .IX Subsection "getc"
700 Usage is 
701 .PP
702 .Vb 1
703 \&    $char = $z\->getc()
704 .Ve
705 .PP
706 Read a single character.
707 .Sh "ungetc"
708 .IX Subsection "ungetc"
709 Usage is
710 .PP
711 .Vb 1
712 \&    $char = $z\->ungetc($string)
713 .Ve
714 .Sh "inflateSync"
715 .IX Subsection "inflateSync"
716 Usage is
717 .PP
718 .Vb 1
719 \&    $status = $z\->inflateSync()
720 .Ve
721 .PP
722 \&\s-1TODO\s0
723 .Sh "getHeaderInfo"
724 .IX Subsection "getHeaderInfo"
725 Usage is
726 .PP
727 .Vb 2
728 \&    $hdr  = $z\->getHeaderInfo();
729 \&    @hdrs = $z\->getHeaderInfo();
730 .Ve
731 .PP
732 This method returns either a hash reference (in scalar context) or a list
733 or hash references (in array context) that contains information about each
734 of the header fields in the compressed data stream(s).
735 .IP "Name" 5
736 .IX Item "Name"
737 The contents of the Name header field, if present. If no name is
738 present, the value will be undef. Note this is different from a zero length
739 name, which will return an empty string.
740 .IP "Comment" 5
741 .IX Item "Comment"
742 The contents of the Comment header field, if present. If no comment is
743 present, the value will be undef. Note this is different from a zero length
744 comment, which will return an empty string.
745 .Sh "tell"
746 .IX Subsection "tell"
747 Usage is
748 .PP
749 .Vb 2
750 \&    $z\->tell()
751 \&    tell $z
752 .Ve
753 .PP
754 Returns the uncompressed file offset.
755 .Sh "eof"
756 .IX Subsection "eof"
757 Usage is
758 .PP
759 .Vb 2
760 \&    $z\->eof();
761 \&    eof($z);
762 .Ve
763 .PP
764 Returns true if the end of the compressed input stream has been reached.
765 .Sh "seek"
766 .IX Subsection "seek"
767 .Vb 2
768 \&    $z\->seek($position, $whence);
769 \&    seek($z, $position, $whence);
770 .Ve
771 .PP
772 Provides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction
773 that it is only legal to seek forward in the input file/buffer.
774 It is a fatal error to attempt to seek backward.
775 .PP
776 The \f(CW$whence\fR parameter takes one the usual values, namely \s-1SEEK_SET\s0,
777 \&\s-1SEEK_CUR\s0 or \s-1SEEK_END\s0.
778 .PP
779 Returns 1 on success, 0 on failure.
780 .Sh "binmode"
781 .IX Subsection "binmode"
782 Usage is
783 .PP
784 .Vb 2
785 \&    $z\->binmode
786 \&    binmode $z ;
787 .Ve
788 .PP
789 This is a noop provided for completeness.
790 .Sh "opened"
791 .IX Subsection "opened"
792 .Vb 1
793 \&    $z\->opened()
794 .Ve
795 .PP
796 Returns true if the object currently refers to a opened file/buffer. 
797 .Sh "autoflush"
798 .IX Subsection "autoflush"
799 .Vb 2
800 \&    my $prev = $z\->autoflush()
801 \&    my $prev = $z\->autoflush(EXPR)
802 .Ve
803 .PP
804 If the \f(CW$z\fR object is associated with a file or a filehandle, this method
805 returns the current autoflush setting for the underlying filehandle. If
806 \&\f(CW\*(C`EXPR\*(C'\fR is present, and is non\-zero, it will enable flushing after every
807 write/print operation.
808 .PP
809 If \f(CW$z\fR is associated with a buffer, this method has no effect and always
810 returns \f(CW\*(C`undef\*(C'\fR.
811 .PP
812 \&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set or
813 retrieve the autoflush setting.
814 .Sh "input_line_number"
815 .IX Subsection "input_line_number"
816 .Vb 2
817 \&    $z\->input_line_number()
818 \&    $z\->input_line_number(EXPR)
819 .Ve
820 .PP
821 Returns the current uncompressed line number. If \f(CW\*(C`EXPR\*(C'\fR is present it has
822 the effect of setting the line number. Note that setting the line number
823 does not change the current position within the file/buffer being read.
824 .PP
825 The contents of \f(CW$/\fR are used to to determine what constitutes a line
826 terminator.
827 .Sh "fileno"
828 .IX Subsection "fileno"
829 .Vb 2
830 \&    $z\->fileno()
831 \&    fileno($z)
832 .Ve
833 .PP
834 If the \f(CW$z\fR object is associated with a file or a filehandle, \f(CW\*(C`fileno\*(C'\fR
835 will return the underlying file descriptor. Once the \f(CW\*(C`close\*(C'\fR method is
836 called \f(CW\*(C`fileno\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR.
837 .PP
838 If the \f(CW$z\fR object is is associated with a buffer, this method will return
839 \&\f(CW\*(C`undef\*(C'\fR.
840 .Sh "close"
841 .IX Subsection "close"
842 .Vb 2
843 \&    $z\->close() ;
844 \&    close $z ;
845 .Ve
846 .PP
847 Closes the output file/buffer. 
848 .PP
849 For most versions of Perl this method will be automatically invoked if
850 the IO::Uncompress::Gunzip object is destroyed (either explicitly or by the
851 variable with the reference to the object going out of scope). The
852 exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
853 these cases, the \f(CW\*(C`close\*(C'\fR method will be called automatically, but
854 not until global destruction of all live objects when the program is
855 terminating.
856 .PP
857 Therefore, if you want your scripts to be able to run on all versions
858 of Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automatic
859 closing.
860 .PP
861 Returns true on success, otherwise 0.
862 .PP
863 If the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Uncompress::Gunzip
864 object was created, and the object is associated with a file, the
865 underlying file will also be closed.
866 .Sh "nextStream"
867 .IX Subsection "nextStream"
868 Usage is
869 .PP
870 .Vb 1
871 \&    my $status = $z\->nextStream();
872 .Ve
873 .PP
874 Skips to the next compressed data stream in the input file/buffer. If a new
875 compressed data stream is found, the eof marker will be cleared and \f(CW$.\fR
876 will be reset to 0.
877 .PP
878 Returns 1 if a new stream was found, 0 if none was found, and \-1 if an
879 error was encountered.
880 .Sh "trailingData"
881 .IX Subsection "trailingData"
882 Usage is
883 .PP
884 .Vb 1
885 \&    my $data = $z\->trailingData();
886 .Ve
887 .PP
888 Returns the data, if any, that is present immediately after the compressed
889 data stream once uncompression is complete. It only makes sense to call
890 this method once the end of the compressed data stream has been
891 encountered.
892 .PP
893 This option can be used when there is useful information immediately
894 following the compressed data stream, and you don't know the length of the
895 compressed data stream.
896 .PP
897 If the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from the
898 end of the compressed data stream to the end of the buffer.
899 .PP
900 If the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that is
901 left in the filehandle input buffer once the end of the compressed data
902 stream has been reached. You can then use the filehandle to read the rest
903 of the input file. 
904 .PP
905 Don't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename.
906 .PP
907 If you know the length of the compressed data stream before you start
908 uncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the
909 \&\f(CW\*(C`InputLength\*(C'\fR option in the constructor.
910 .SH "Importing"
911 .IX Header "Importing"
912 No symbolic constants are required by this IO::Uncompress::Gunzip at present. 
913 .IP ":all" 5
914 .IX Item ":all"
915 Imports \f(CW\*(C`gunzip\*(C'\fR and \f(CW$GunzipError\fR.
916 Same as doing this
917 .Sp
918 .Vb 1
919 \&    use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
920 .Ve
921 .SH "EXAMPLES"
922 .IX Header "EXAMPLES"
923 .Sh "Working with Net::FTP"
924 .IX Subsection "Working with Net::FTP"
925 See IO::Uncompress::Gunzip::FAQ
926 .SH "SEE ALSO"
927 .IX Header "SEE ALSO"
928 Compress::Zlib, IO::Compress::Gzip, 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
929 .PP
930 Compress::Zlib::FAQ
931 .PP
932 File::GlobMapper, Archive::Zip,
933 Archive::Tar,
934 IO::Zlib
935 .PP
936 For \s-1RFC\s0 1950, 1951 and 1952 see 
937 \&\fIhttp://www.faqs.org/rfcs/rfc1950.html\fR,
938 \&\fIhttp://www.faqs.org/rfcs/rfc1951.html\fR and
939 \&\fIhttp://www.faqs.org/rfcs/rfc1952.html\fR
940 .PP
941 The \fIzlib\fR compression library was written by Jean-loup Gailly
942 \&\fIgzip@prep.ai.mit.edu\fR and Mark Adler \fImadler@alumni.caltech.edu\fR.
943 .PP
944 The primary site for the \fIzlib\fR compression library is
945 \&\fIhttp://www.zlib.org\fR.
946 .PP
947 The primary site for gzip is \fIhttp://www.gzip.org\fR.
948 .SH "AUTHOR"
949 .IX Header "AUTHOR"
950 This module was written by Paul Marquess, \fIpmqs@cpan.org\fR. 
951 .SH "MODIFICATION HISTORY"
952 .IX Header "MODIFICATION HISTORY"
953 See the Changes file.
954 .SH "COPYRIGHT AND LICENSE"
955 .IX Header "COPYRIGHT AND LICENSE"
956 Copyright (c) 2005\-2009 Paul Marquess. All rights reserved.
957 .PP
958 This program is free software; you can redistribute it and/or
959 modify it under the same terms as Perl itself.