This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Updated IO-Compress to CPAN version 2.052
[perl5.git] / cpan / IO-Compress / lib / IO / Compress / Deflate.pm
1 package IO::Compress::Deflate ;
2
3 require 5.006 ;
4
5 use strict ;
6 use warnings;
7 use bytes;
8
9 require Exporter ;
10
11 use IO::Compress::RawDeflate 2.052 ();
12 use IO::Compress::Adapter::Deflate 2.052 ;
13
14 use IO::Compress::Zlib::Constants 2.052 ;
15 use IO::Compress::Base::Common  2.052 qw(createSelfTiedObject);
16
17
18 our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $DeflateError);
19
20 $VERSION = '2.052';
21 $DeflateError = '';
22
23 @ISA    = qw(Exporter IO::Compress::RawDeflate);
24 @EXPORT_OK = qw( $DeflateError deflate ) ;
25 %EXPORT_TAGS = %IO::Compress::RawDeflate::DEFLATE_CONSTANTS ;
26
27 push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
28 Exporter::export_ok_tags('all');
29
30
31 sub new
32 {
33     my $class = shift ;
34
35     my $obj = createSelfTiedObject($class, \$DeflateError);
36     return $obj->_create(undef, @_);
37 }
38
39 sub deflate
40 {
41     my $obj = createSelfTiedObject(undef, \$DeflateError);
42     return $obj->_def(@_);
43 }
44
45
46 sub bitmask($$$$)
47 {
48     my $into  = shift ;
49     my $value  = shift ;
50     my $offset = shift ;
51     my $mask   = shift ;
52
53     return $into | (($value & $mask) << $offset ) ;
54 }
55
56 sub mkDeflateHdr($$$;$)
57 {
58     my $method = shift ;
59     my $cinfo  = shift;
60     my $level  = shift;
61     my $fdict_adler = shift  ;
62
63     my $cmf = 0;
64     my $flg = 0;
65     my $fdict = 0;
66     $fdict = 1 if defined $fdict_adler;
67
68     $cmf = bitmask($cmf, $method, ZLIB_CMF_CM_OFFSET,    ZLIB_CMF_CM_BITS);
69     $cmf = bitmask($cmf, $cinfo,  ZLIB_CMF_CINFO_OFFSET, ZLIB_CMF_CINFO_BITS);
70
71     $flg = bitmask($flg, $fdict,  ZLIB_FLG_FDICT_OFFSET, ZLIB_FLG_FDICT_BITS);
72     $flg = bitmask($flg, $level,  ZLIB_FLG_LEVEL_OFFSET, ZLIB_FLG_LEVEL_BITS);
73
74     my $fcheck = 31 - ($cmf * 256 + $flg) % 31 ;
75     $flg = bitmask($flg, $fcheck, ZLIB_FLG_FCHECK_OFFSET, ZLIB_FLG_FCHECK_BITS);
76
77     my $hdr =  pack("CC", $cmf, $flg) ;
78     $hdr .= pack("N", $fdict_adler) if $fdict ;
79
80     return $hdr;
81 }
82
83 sub mkHeader 
84 {
85     my $self = shift ;
86     my $param = shift ;
87
88     my $level = $param->value('Level');
89     my $strategy = $param->value('Strategy');
90
91     my $lflag ;
92     $level = 6 
93         if $level == Z_DEFAULT_COMPRESSION ;
94
95     if (ZLIB_VERNUM >= 0x1210)
96     {
97         if ($strategy >= Z_HUFFMAN_ONLY || $level < 2)
98          {  $lflag = ZLIB_FLG_LEVEL_FASTEST }
99         elsif ($level < 6)
100          {  $lflag = ZLIB_FLG_LEVEL_FAST }
101         elsif ($level == 6)
102          {  $lflag = ZLIB_FLG_LEVEL_DEFAULT }
103         else
104          {  $lflag = ZLIB_FLG_LEVEL_SLOWEST }
105     }
106     else
107     {
108         $lflag = ($level - 1) >> 1 ;
109         $lflag = 3 if $lflag > 3 ;
110     }
111
112      #my $wbits = (MAX_WBITS - 8) << 4 ;
113     my $wbits = 7;
114     mkDeflateHdr(ZLIB_CMF_CM_DEFLATED, $wbits, $lflag);
115 }
116
117 sub ckParams
118 {
119     my $self = shift ;
120     my $got = shift;
121     
122     $got->value('ADLER32' => 1);
123     return 1 ;
124 }
125
126
127 sub mkTrailer
128 {
129     my $self = shift ;
130     return pack("N", *$self->{Compress}->adler32()) ;
131 }
132
133 sub mkFinalTrailer
134 {
135     return '';
136 }
137
138 #sub newHeader
139 #{
140 #    my $self = shift ;
141 #    return *$self->{Header};
142 #}
143
144 sub getExtraParams
145 {
146     my $self = shift ;
147     return $self->getZlibParams(),
148 }
149
150 sub getInverseClass
151 {
152     return ('IO::Uncompress::Inflate',
153                 \$IO::Uncompress::Inflate::InflateError);
154 }
155
156 sub getFileInfo
157 {
158     my $self = shift ;
159     my $params = shift;
160     my $file = shift ;
161     
162 }
163
164
165
166 1;
167
168 __END__
169
170 =head1 NAME
171
172 IO::Compress::Deflate - Write RFC 1950 files/buffers
173  
174  
175
176 =head1 SYNOPSIS
177
178     use IO::Compress::Deflate qw(deflate $DeflateError) ;
179
180     my $status = deflate $input => $output [,OPTS] 
181         or die "deflate failed: $DeflateError\n";
182
183     my $z = new IO::Compress::Deflate $output [,OPTS]
184         or die "deflate failed: $DeflateError\n";
185
186     $z->print($string);
187     $z->printf($format, $string);
188     $z->write($string);
189     $z->syswrite($string [, $length, $offset]);
190     $z->flush();
191     $z->tell();
192     $z->eof();
193     $z->seek($position, $whence);
194     $z->binmode();
195     $z->fileno();
196     $z->opened();
197     $z->autoflush();
198     $z->input_line_number();
199     $z->newStream( [OPTS] );
200     
201     $z->deflateParams();
202     
203     $z->close() ;
204
205     $DeflateError ;
206
207     # IO::File mode
208
209     print $z $string;
210     printf $z $format, $string;
211     tell $z
212     eof $z
213     seek $z, $position, $whence
214     binmode $z
215     fileno $z
216     close $z ;
217     
218
219 =head1 DESCRIPTION
220
221 This module provides a Perl interface that allows writing compressed
222 data to files or buffer as defined in RFC 1950.
223
224 For reading RFC 1950 files/buffers, see the companion module 
225 L<IO::Uncompress::Inflate|IO::Uncompress::Inflate>.
226
227 =head1 Functional Interface
228
229 A top-level function, C<deflate>, is provided to carry out
230 "one-shot" compression between buffers and/or files. For finer
231 control over the compression process, see the L</"OO Interface">
232 section.
233
234     use IO::Compress::Deflate qw(deflate $DeflateError) ;
235
236     deflate $input => $output [,OPTS] 
237         or die "deflate failed: $DeflateError\n";
238
239 The functional interface needs Perl5.005 or better.
240
241 =head2 deflate $input => $output [, OPTS]
242
243 C<deflate> expects at least two parameters, C<$input> and C<$output>.
244
245 =head3 The C<$input> parameter
246
247 The parameter, C<$input>, is used to define the source of
248 the uncompressed data. 
249
250 It can take one of the following forms:
251
252 =over 5
253
254 =item A filename
255
256 If the C<$input> parameter is a simple scalar, it is assumed to be a
257 filename. This file will be opened for reading and the input data
258 will be read from it.
259
260 =item A filehandle
261
262 If the C<$input> parameter is a filehandle, the input data will be
263 read from it.
264 The string '-' can be used as an alias for standard input.
265
266 =item A scalar reference 
267
268 If C<$input> is a scalar reference, the input data will be read
269 from C<$$input>.
270
271 =item An array reference 
272
273 If C<$input> is an array reference, each element in the array must be a
274 filename.
275
276 The input data will be read from each file in turn. 
277
278 The complete array will be walked to ensure that it only
279 contains valid filenames before any data is compressed.
280
281 =item An Input FileGlob string
282
283 If C<$input> is a string that is delimited by the characters "<" and ">"
284 C<deflate> will assume that it is an I<input fileglob string>. The
285 input is the list of files that match the fileglob.
286
287 See L<File::GlobMapper|File::GlobMapper> for more details.
288
289 =back
290
291 If the C<$input> parameter is any other type, C<undef> will be returned.
292
293 =head3 The C<$output> parameter
294
295 The parameter C<$output> is used to control the destination of the
296 compressed data. This parameter can take one of these forms.
297
298 =over 5
299
300 =item A filename
301
302 If the C<$output> parameter is a simple scalar, it is assumed to be a
303 filename.  This file will be opened for writing and the compressed
304 data will be written to it.
305
306 =item A filehandle
307
308 If the C<$output> parameter is a filehandle, the compressed data
309 will be written to it.
310 The string '-' can be used as an alias for standard output.
311
312 =item A scalar reference 
313
314 If C<$output> is a scalar reference, the compressed data will be
315 stored in C<$$output>.
316
317 =item An Array Reference
318
319 If C<$output> is an array reference, the compressed data will be
320 pushed onto the array.
321
322 =item An Output FileGlob
323
324 If C<$output> is a string that is delimited by the characters "<" and ">"
325 C<deflate> will assume that it is an I<output fileglob string>. The
326 output is the list of files that match the fileglob.
327
328 When C<$output> is an fileglob string, C<$input> must also be a fileglob
329 string. Anything else is an error.
330
331 See L<File::GlobMapper|File::GlobMapper> for more details.
332
333 =back
334
335 If the C<$output> parameter is any other type, C<undef> will be returned.
336
337 =head2 Notes
338
339 When C<$input> maps to multiple files/buffers and C<$output> is a single
340 file/buffer the input files/buffers will be stored
341 in C<$output> as a concatenated series of compressed data streams.
342
343 =head2 Optional Parameters
344
345 Unless specified below, the optional parameters for C<deflate>,
346 C<OPTS>, are the same as those used with the OO interface defined in the
347 L</"Constructor Options"> section below.
348
349 =over 5
350
351 =item C<< AutoClose => 0|1 >>
352
353 This option applies to any input or output data streams to 
354 C<deflate> that are filehandles.
355
356 If C<AutoClose> is specified, and the value is true, it will result in all
357 input and/or output filehandles being closed once C<deflate> has
358 completed.
359
360 This parameter defaults to 0.
361
362 =item C<< BinModeIn => 0|1 >>
363
364 When reading from a file or filehandle, set C<binmode> before reading.
365
366 Defaults to 0.
367
368 =item C<< Append => 0|1 >>
369
370 The behaviour of this option is dependent on the type of output data
371 stream.
372
373 =over 5
374
375 =item * A Buffer
376
377 If C<Append> is enabled, all compressed data will be append to the end of
378 the output buffer. Otherwise the output buffer will be cleared before any
379 compressed data is written to it.
380
381 =item * A Filename
382
383 If C<Append> is enabled, the file will be opened in append mode. Otherwise
384 the contents of the file, if any, will be truncated before any compressed
385 data is written to it.
386
387 =item * A Filehandle
388
389 If C<Append> is enabled, the filehandle will be positioned to the end of
390 the file via a call to C<seek> before any compressed data is
391 written to it.  Otherwise the file pointer will not be moved.
392
393 =back
394
395 When C<Append> is specified, and set to true, it will I<append> all compressed 
396 data to the output data stream.
397
398 So when the output is a filehandle it will carry out a seek to the eof
399 before writing any compressed data. If the output is a filename, it will be opened for
400 appending. If the output is a buffer, all compressed data will be
401 appended to the existing buffer.
402
403 Conversely when C<Append> is not specified, or it is present and is set to
404 false, it will operate as follows.
405
406 When the output is a filename, it will truncate the contents of the file
407 before writing any compressed data. If the output is a filehandle
408 its position will not be changed. If the output is a buffer, it will be
409 wiped before any compressed data is output.
410
411 Defaults to 0.
412
413 =back
414
415 =head2 Examples
416
417 To read the contents of the file C<file1.txt> and write the compressed
418 data to the file C<file1.txt.1950>.
419
420     use strict ;
421     use warnings ;
422     use IO::Compress::Deflate qw(deflate $DeflateError) ;
423
424     my $input = "file1.txt";
425     deflate $input => "$input.1950"
426         or die "deflate failed: $DeflateError\n";
427
428 To read from an existing Perl filehandle, C<$input>, and write the
429 compressed data to a buffer, C<$buffer>.
430
431     use strict ;
432     use warnings ;
433     use IO::Compress::Deflate qw(deflate $DeflateError) ;
434     use IO::File ;
435
436     my $input = new IO::File "<file1.txt"
437         or die "Cannot open 'file1.txt': $!\n" ;
438     my $buffer ;
439     deflate $input => \$buffer 
440         or die "deflate failed: $DeflateError\n";
441
442 To compress all files in the directory "/my/home" that match "*.txt"
443 and store the compressed data in the same directory
444
445     use strict ;
446     use warnings ;
447     use IO::Compress::Deflate qw(deflate $DeflateError) ;
448
449     deflate '</my/home/*.txt>' => '<*.1950>'
450         or die "deflate failed: $DeflateError\n";
451
452 and if you want to compress each file one at a time, this will do the trick
453
454     use strict ;
455     use warnings ;
456     use IO::Compress::Deflate qw(deflate $DeflateError) ;
457
458     for my $input ( glob "/my/home/*.txt" )
459     {
460         my $output = "$input.1950" ;
461         deflate $input => $output 
462             or die "Error compressing '$input': $DeflateError\n";
463     }
464
465 =head1 OO Interface
466
467 =head2 Constructor
468
469 The format of the constructor for C<IO::Compress::Deflate> is shown below
470
471     my $z = new IO::Compress::Deflate $output [,OPTS]
472         or die "IO::Compress::Deflate failed: $DeflateError\n";
473
474 It returns an C<IO::Compress::Deflate> object on success and undef on failure. 
475 The variable C<$DeflateError> will contain an error message on failure.
476
477 If you are running Perl 5.005 or better the object, C<$z>, returned from 
478 IO::Compress::Deflate can be used exactly like an L<IO::File|IO::File> filehandle. 
479 This means that all normal output file operations can be carried out 
480 with C<$z>. 
481 For example, to write to a compressed file/buffer you can use either of 
482 these forms
483
484     $z->print("hello world\n");
485     print $z "hello world\n";
486
487 The mandatory parameter C<$output> is used to control the destination
488 of the compressed data. This parameter can take one of these forms.
489
490 =over 5
491
492 =item A filename
493
494 If the C<$output> parameter is a simple scalar, it is assumed to be a
495 filename. This file will be opened for writing and the compressed data
496 will be written to it.
497
498 =item A filehandle
499
500 If the C<$output> parameter is a filehandle, the compressed data will be
501 written to it.
502 The string '-' can be used as an alias for standard output.
503
504 =item A scalar reference 
505
506 If C<$output> is a scalar reference, the compressed data will be stored
507 in C<$$output>.
508
509 =back
510
511 If the C<$output> parameter is any other type, C<IO::Compress::Deflate>::new will
512 return undef.
513
514 =head2 Constructor Options
515
516 C<OPTS> is any combination of the following options:
517
518 =over 5
519
520 =item C<< AutoClose => 0|1 >>
521
522 This option is only valid when the C<$output> parameter is a filehandle. If
523 specified, and the value is true, it will result in the C<$output> being
524 closed once either the C<close> method is called or the C<IO::Compress::Deflate>
525 object is destroyed.
526
527 This parameter defaults to 0.
528
529 =item C<< Append => 0|1 >>
530
531 Opens C<$output> in append mode. 
532
533 The behaviour of this option is dependent on the type of C<$output>.
534
535 =over 5
536
537 =item * A Buffer
538
539 If C<$output> is a buffer and C<Append> is enabled, all compressed data
540 will be append to the end of C<$output>. Otherwise C<$output> will be
541 cleared before any data is written to it.
542
543 =item * A Filename
544
545 If C<$output> is a filename and C<Append> is enabled, the file will be
546 opened in append mode. Otherwise the contents of the file, if any, will be
547 truncated before any compressed data is written to it.
548
549 =item * A Filehandle
550
551 If C<$output> is a filehandle, the file pointer will be positioned to the
552 end of the file via a call to C<seek> before any compressed data is written
553 to it.  Otherwise the file pointer will not be moved.
554
555 =back
556
557 This parameter defaults to 0.
558
559 =item C<< Merge => 0|1 >>
560
561 This option is used to compress input data and append it to an existing
562 compressed data stream in C<$output>. The end result is a single compressed
563 data stream stored in C<$output>. 
564
565 It is a fatal error to attempt to use this option when C<$output> is not an
566 RFC 1950 data stream.
567
568 There are a number of other limitations with the C<Merge> option:
569
570 =over 5 
571
572 =item 1
573
574 This module needs to have been built with zlib 1.2.1 or better to work. A
575 fatal error will be thrown if C<Merge> is used with an older version of
576 zlib.  
577
578 =item 2
579
580 If C<$output> is a file or a filehandle, it must be seekable.
581
582 =back
583
584 This parameter defaults to 0.
585
586 =item -Level 
587
588 Defines the compression level used by zlib. The value should either be
589 a number between 0 and 9 (0 means no compression and 9 is maximum
590 compression), or one of the symbolic constants defined below.
591
592    Z_NO_COMPRESSION
593    Z_BEST_SPEED
594    Z_BEST_COMPRESSION
595    Z_DEFAULT_COMPRESSION
596
597 The default is Z_DEFAULT_COMPRESSION.
598
599 Note, these constants are not imported by C<IO::Compress::Deflate> by default.
600
601     use IO::Compress::Deflate qw(:strategy);
602     use IO::Compress::Deflate qw(:constants);
603     use IO::Compress::Deflate qw(:all);
604
605 =item -Strategy 
606
607 Defines the strategy used to tune the compression. Use one of the symbolic
608 constants defined below.
609
610    Z_FILTERED
611    Z_HUFFMAN_ONLY
612    Z_RLE
613    Z_FIXED
614    Z_DEFAULT_STRATEGY
615
616 The default is Z_DEFAULT_STRATEGY.
617
618 =item C<< Strict => 0|1 >>
619
620 This is a placeholder option.
621
622 =back
623
624 =head2 Examples
625
626 TODO
627
628 =head1 Methods 
629
630 =head2 print
631
632 Usage is
633
634     $z->print($data)
635     print $z $data
636
637 Compresses and outputs the contents of the C<$data> parameter. This
638 has the same behaviour as the C<print> built-in.
639
640 Returns true if successful.
641
642 =head2 printf
643
644 Usage is
645
646     $z->printf($format, $data)
647     printf $z $format, $data
648
649 Compresses and outputs the contents of the C<$data> parameter.
650
651 Returns true if successful.
652
653 =head2 syswrite
654
655 Usage is
656
657     $z->syswrite $data
658     $z->syswrite $data, $length
659     $z->syswrite $data, $length, $offset
660
661 Compresses and outputs the contents of the C<$data> parameter.
662
663 Returns the number of uncompressed bytes written, or C<undef> if
664 unsuccessful.
665
666 =head2 write
667
668 Usage is
669
670     $z->write $data
671     $z->write $data, $length
672     $z->write $data, $length, $offset
673
674 Compresses and outputs the contents of the C<$data> parameter.
675
676 Returns the number of uncompressed bytes written, or C<undef> if
677 unsuccessful.
678
679 =head2 flush
680
681 Usage is
682
683     $z->flush;
684     $z->flush($flush_type);
685
686 Flushes any pending compressed data to the output file/buffer.
687
688 This method takes an optional parameter, C<$flush_type>, that controls
689 how the flushing will be carried out. By default the C<$flush_type>
690 used is C<Z_FINISH>. Other valid values for C<$flush_type> are
691 C<Z_NO_FLUSH>, C<Z_SYNC_FLUSH>, C<Z_FULL_FLUSH> and C<Z_BLOCK>. It is
692 strongly recommended that you only set the C<flush_type> parameter if
693 you fully understand the implications of what it does - overuse of C<flush>
694 can seriously degrade the level of compression achieved. See the C<zlib>
695 documentation for details.
696
697 Returns true on success.
698
699 =head2 tell
700
701 Usage is
702
703     $z->tell()
704     tell $z
705
706 Returns the uncompressed file offset.
707
708 =head2 eof
709
710 Usage is
711
712     $z->eof();
713     eof($z);
714
715 Returns true if the C<close> method has been called.
716
717 =head2 seek
718
719     $z->seek($position, $whence);
720     seek($z, $position, $whence);
721
722 Provides a sub-set of the C<seek> functionality, with the restriction
723 that it is only legal to seek forward in the output file/buffer.
724 It is a fatal error to attempt to seek backward.
725
726 Empty parts of the file/buffer will have NULL (0x00) bytes written to them.
727
728 The C<$whence> parameter takes one the usual values, namely SEEK_SET,
729 SEEK_CUR or SEEK_END.
730
731 Returns 1 on success, 0 on failure.
732
733 =head2 binmode
734
735 Usage is
736
737     $z->binmode
738     binmode $z ;
739
740 This is a noop provided for completeness.
741
742 =head2 opened
743
744     $z->opened()
745
746 Returns true if the object currently refers to a opened file/buffer. 
747
748 =head2 autoflush
749
750     my $prev = $z->autoflush()
751     my $prev = $z->autoflush(EXPR)
752
753 If the C<$z> object is associated with a file or a filehandle, this method
754 returns the current autoflush setting for the underlying filehandle. If
755 C<EXPR> is present, and is non-zero, it will enable flushing after every
756 write/print operation.
757
758 If C<$z> is associated with a buffer, this method has no effect and always
759 returns C<undef>.
760
761 B<Note> that the special variable C<$|> B<cannot> be used to set or
762 retrieve the autoflush setting.
763
764 =head2 input_line_number
765
766     $z->input_line_number()
767     $z->input_line_number(EXPR)
768
769 This method always returns C<undef> when compressing. 
770
771 =head2 fileno
772
773     $z->fileno()
774     fileno($z)
775
776 If the C<$z> object is associated with a file or a filehandle, C<fileno>
777 will return the underlying file descriptor. Once the C<close> method is
778 called C<fileno> will return C<undef>.
779
780 If the C<$z> object is associated with a buffer, this method will return
781 C<undef>.
782
783 =head2 close
784
785     $z->close() ;
786     close $z ;
787
788 Flushes any pending compressed data and then closes the output file/buffer. 
789
790 For most versions of Perl this method will be automatically invoked if
791 the IO::Compress::Deflate object is destroyed (either explicitly or by the
792 variable with the reference to the object going out of scope). The
793 exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
794 these cases, the C<close> method will be called automatically, but
795 not until global destruction of all live objects when the program is
796 terminating.
797
798 Therefore, if you want your scripts to be able to run on all versions
799 of Perl, you should call C<close> explicitly and not rely on automatic
800 closing.
801
802 Returns true on success, otherwise 0.
803
804 If the C<AutoClose> option has been enabled when the IO::Compress::Deflate
805 object was created, and the object is associated with a file, the
806 underlying file will also be closed.
807
808 =head2 newStream([OPTS])
809
810 Usage is
811
812     $z->newStream( [OPTS] )
813
814 Closes the current compressed data stream and starts a new one.
815
816 OPTS consists of any of the the options that are available when creating
817 the C<$z> object.
818
819 See the L</"Constructor Options"> section for more details.
820
821 =head2 deflateParams
822
823 Usage is
824
825     $z->deflateParams
826
827 TODO
828
829 =head1 Importing 
830
831 A number of symbolic constants are required by some methods in 
832 C<IO::Compress::Deflate>. None are imported by default.
833
834 =over 5
835
836 =item :all
837
838 Imports C<deflate>, C<$DeflateError> and all symbolic
839 constants that can be used by C<IO::Compress::Deflate>. Same as doing this
840
841     use IO::Compress::Deflate qw(deflate $DeflateError :constants) ;
842
843 =item :constants
844
845 Import all symbolic constants. Same as doing this
846
847     use IO::Compress::Deflate qw(:flush :level :strategy) ;
848
849 =item :flush
850
851 These symbolic constants are used by the C<flush> method.
852
853     Z_NO_FLUSH
854     Z_PARTIAL_FLUSH
855     Z_SYNC_FLUSH
856     Z_FULL_FLUSH
857     Z_FINISH
858     Z_BLOCK
859
860 =item :level
861
862 These symbolic constants are used by the C<Level> option in the constructor.
863
864     Z_NO_COMPRESSION
865     Z_BEST_SPEED
866     Z_BEST_COMPRESSION
867     Z_DEFAULT_COMPRESSION
868
869 =item :strategy
870
871 These symbolic constants are used by the C<Strategy> option in the constructor.
872
873     Z_FILTERED
874     Z_HUFFMAN_ONLY
875     Z_RLE
876     Z_FIXED
877     Z_DEFAULT_STRATEGY
878
879     
880     
881
882 =back
883
884 =head1 EXAMPLES
885
886 =head2 Apache::GZip Revisited
887
888 See L<IO::Compress::FAQ|IO::Compress::FAQ/"Apache::GZip Revisited">
889
890 =head2 Working with Net::FTP
891
892 See L<IO::Compress::FAQ|IO::Compress::FAQ/"Compressed files and Net::FTP">
893
894 =head1 SEE ALSO
895
896 L<Compress::Zlib>, L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Uncompress::RawInflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzma>, L<IO::Uncompress::UnLzma>, L<IO::Compress::Xz>, L<IO::Uncompress::UnXz>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Compress::Lzf>, L<IO::Uncompress::UnLzf>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress>
897
898 L<IO::Compress::FAQ|IO::Compress::FAQ>
899
900 L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,
901 L<Archive::Tar|Archive::Tar>,
902 L<IO::Zlib|IO::Zlib>
903
904 For RFC 1950, 1951 and 1952 see 
905 F<http://www.faqs.org/rfcs/rfc1950.html>,
906 F<http://www.faqs.org/rfcs/rfc1951.html> and
907 F<http://www.faqs.org/rfcs/rfc1952.html>
908
909 The I<zlib> compression library was written by Jean-loup Gailly
910 F<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>.
911
912 The primary site for the I<zlib> compression library is
913 F<http://www.zlib.org>.
914
915 The primary site for gzip is F<http://www.gzip.org>.
916
917 =head1 AUTHOR
918
919 This module was written by Paul Marquess, F<pmqs@cpan.org>. 
920
921 =head1 MODIFICATION HISTORY
922
923 See the Changes file.
924
925 =head1 COPYRIGHT AND LICENSE
926
927 Copyright (c) 2005-2012 Paul Marquess. All rights reserved.
928
929 This program is free software; you can redistribute it and/or
930 modify it under the same terms as Perl itself.
931