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