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