1 2package Compress::Zlib; 3 4require 5.004 ; 5require Exporter; 6use AutoLoader; 7use Carp ; 8use IO::Handle ; 9use Scalar::Util qw(dualvar); 10 11use IO::Compress::Base::Common 2.024 ; 12use Compress::Raw::Zlib 2.024 ; 13use IO::Compress::Gzip 2.024 ; 14use IO::Uncompress::Gunzip 2.024 ; 15 16use strict ; 17use warnings ; 18use bytes ; 19our ($VERSION, $XS_VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $AUTOLOAD); 20 21$VERSION = '2.024'; 22$XS_VERSION = $VERSION; 23$VERSION = eval $VERSION; 24 25@ISA = qw(Exporter); 26# Items to export into callers namespace by default. Note: do not export 27# names by default without a very good reason. Use EXPORT_OK instead. 28# Do not simply export all your public functions/methods/constants. 29@EXPORT = qw( 30 deflateInit inflateInit 31 32 compress uncompress 33 34 gzopen $gzerrno 35 ); 36 37push @EXPORT, @Compress::Raw::Zlib::EXPORT ; 38 39@EXPORT_OK = qw(memGunzip memGzip zlib_version); 40%EXPORT_TAGS = ( 41 ALL => \@EXPORT 42); 43 44BEGIN 45{ 46 *zlib_version = \&Compress::Raw::Zlib::zlib_version; 47} 48 49sub AUTOLOAD { 50 my($constname); 51 ($constname = $AUTOLOAD) =~ s/.*:://; 52 my ($error, $val) = Compress::Raw::Zlib::constant($constname); 53 Carp::croak $error if $error; 54 no strict 'refs'; 55 *{$AUTOLOAD} = sub { $val }; 56 goto &{$AUTOLOAD}; 57} 58 59use constant FLAG_APPEND => 1 ; 60use constant FLAG_CRC => 2 ; 61use constant FLAG_ADLER => 4 ; 62use constant FLAG_CONSUME_INPUT => 8 ; 63 64our (@my_z_errmsg); 65 66@my_z_errmsg = ( 67 "need dictionary", # Z_NEED_DICT 2 68 "stream end", # Z_STREAM_END 1 69 "", # Z_OK 0 70 "file error", # Z_ERRNO (-1) 71 "stream error", # Z_STREAM_ERROR (-2) 72 "data error", # Z_DATA_ERROR (-3) 73 "insufficient memory", # Z_MEM_ERROR (-4) 74 "buffer error", # Z_BUF_ERROR (-5) 75 "incompatible version",# Z_VERSION_ERROR(-6) 76 ); 77 78 79sub _set_gzerr 80{ 81 my $value = shift ; 82 83 if ($value == 0) { 84 $Compress::Zlib::gzerrno = 0 ; 85 } 86 elsif ($value == Z_ERRNO() || $value > 2) { 87 $Compress::Zlib::gzerrno = $! ; 88 } 89 else { 90 $Compress::Zlib::gzerrno = dualvar($value+0, $my_z_errmsg[2 - $value]); 91 } 92 93 return $value ; 94} 95 96sub _set_gzerr_undef 97{ 98 _set_gzerr(@_); 99 return undef; 100} 101sub _save_gzerr 102{ 103 my $gz = shift ; 104 my $test_eof = shift ; 105 106 my $value = $gz->errorNo() || 0 ; 107 108 if ($test_eof) { 109 #my $gz = $self->[0] ; 110 # gzread uses Z_STREAM_END to denote a successful end 111 $value = Z_STREAM_END() if $gz->eof() && $value == 0 ; 112 } 113 114 _set_gzerr($value) ; 115} 116 117sub gzopen($$) 118{ 119 my ($file, $mode) = @_ ; 120 121 my $gz ; 122 my %defOpts = (Level => Z_DEFAULT_COMPRESSION(), 123 Strategy => Z_DEFAULT_STRATEGY(), 124 ); 125 126 my $writing ; 127 $writing = ! ($mode =~ /r/i) ; 128 $writing = ($mode =~ /[wa]/i) ; 129 130 $defOpts{Level} = $1 if $mode =~ /(\d)/; 131 $defOpts{Strategy} = Z_FILTERED() if $mode =~ /f/i; 132 $defOpts{Strategy} = Z_HUFFMAN_ONLY() if $mode =~ /h/i; 133 $defOpts{Append} = 1 if $mode =~ /a/i; 134 135 my $infDef = $writing ? 'deflate' : 'inflate'; 136 my @params = () ; 137 138 croak "gzopen: file parameter is not a filehandle or filename" 139 unless isaFilehandle $file || isaFilename $file || 140 (ref $file && ref $file eq 'SCALAR'); 141 142 return undef unless $mode =~ /[rwa]/i ; 143 144 _set_gzerr(0) ; 145 146 if ($writing) { 147 $gz = new IO::Compress::Gzip($file, Minimal => 1, AutoClose => 1, 148 %defOpts) 149 or $Compress::Zlib::gzerrno = $IO::Compress::Gzip::GzipError; 150 } 151 else { 152 $gz = new IO::Uncompress::Gunzip($file, 153 Transparent => 1, 154 Append => 0, 155 AutoClose => 1, 156 MultiStream => 1, 157 Strict => 0) 158 or $Compress::Zlib::gzerrno = $IO::Uncompress::Gunzip::GunzipError; 159 } 160 161 return undef 162 if ! defined $gz ; 163 164 bless [$gz, $infDef], 'Compress::Zlib::gzFile'; 165} 166 167sub Compress::Zlib::gzFile::gzread 168{ 169 my $self = shift ; 170 171 return _set_gzerr(Z_STREAM_ERROR()) 172 if $self->[1] ne 'inflate'; 173 174 my $len = defined $_[1] ? $_[1] : 4096 ; 175 176 if ($self->gzeof() || $len == 0) { 177 # Zap the output buffer to match ver 1 behaviour. 178 $_[0] = "" ; 179 return 0 ; 180 } 181 182 my $gz = $self->[0] ; 183 my $status = $gz->read($_[0], $len) ; 184 _save_gzerr($gz, 1); 185 return $status ; 186} 187 188sub Compress::Zlib::gzFile::gzreadline 189{ 190 my $self = shift ; 191 192 my $gz = $self->[0] ; 193 { 194 # Maintain backward compatibility with 1.x behaviour 195 # It didn't support $/, so this can't either. 196 local $/ = "\n" ; 197 $_[0] = $gz->getline() ; 198 } 199 _save_gzerr($gz, 1); 200 return defined $_[0] ? length $_[0] : 0 ; 201} 202 203sub Compress::Zlib::gzFile::gzwrite 204{ 205 my $self = shift ; 206 my $gz = $self->[0] ; 207 208 return _set_gzerr(Z_STREAM_ERROR()) 209 if $self->[1] ne 'deflate'; 210 211 $] >= 5.008 and (utf8::downgrade($_[0], 1) 212 or croak "Wide character in gzwrite"); 213 214 my $status = $gz->write($_[0]) ; 215 _save_gzerr($gz); 216 return $status ; 217} 218 219sub Compress::Zlib::gzFile::gztell 220{ 221 my $self = shift ; 222 my $gz = $self->[0] ; 223 my $status = $gz->tell() ; 224 _save_gzerr($gz); 225 return $status ; 226} 227 228sub Compress::Zlib::gzFile::gzseek 229{ 230 my $self = shift ; 231 my $offset = shift ; 232 my $whence = shift ; 233 234 my $gz = $self->[0] ; 235 my $status ; 236 eval { $status = $gz->seek($offset, $whence) ; }; 237 if ($@) 238 { 239 my $error = $@; 240 $error =~ s/^.*: /gzseek: /; 241 $error =~ s/ at .* line \d+\s*$//; 242 croak $error; 243 } 244 _save_gzerr($gz); 245 return $status ; 246} 247 248sub Compress::Zlib::gzFile::gzflush 249{ 250 my $self = shift ; 251 my $f = shift ; 252 253 my $gz = $self->[0] ; 254 my $status = $gz->flush($f) ; 255 my $err = _save_gzerr($gz); 256 return $status ? 0 : $err; 257} 258 259sub Compress::Zlib::gzFile::gzclose 260{ 261 my $self = shift ; 262 my $gz = $self->[0] ; 263 264 my $status = $gz->close() ; 265 my $err = _save_gzerr($gz); 266 return $status ? 0 : $err; 267} 268 269sub Compress::Zlib::gzFile::gzeof 270{ 271 my $self = shift ; 272 my $gz = $self->[0] ; 273 274 return 0 275 if $self->[1] ne 'inflate'; 276 277 my $status = $gz->eof() ; 278 _save_gzerr($gz); 279 return $status ; 280} 281 282sub Compress::Zlib::gzFile::gzsetparams 283{ 284 my $self = shift ; 285 croak "Usage: Compress::Zlib::gzFile::gzsetparams(file, level, strategy)" 286 unless @_ eq 2 ; 287 288 my $gz = $self->[0] ; 289 my $level = shift ; 290 my $strategy = shift; 291 292 return _set_gzerr(Z_STREAM_ERROR()) 293 if $self->[1] ne 'deflate'; 294 295 my $status = *$gz->{Compress}->deflateParams(-Level => $level, 296 -Strategy => $strategy); 297 _save_gzerr($gz); 298 return $status ; 299} 300 301sub Compress::Zlib::gzFile::gzerror 302{ 303 my $self = shift ; 304 my $gz = $self->[0] ; 305 306 return $Compress::Zlib::gzerrno ; 307} 308 309 310sub compress($;$) 311{ 312 my ($x, $output, $err, $in) =('', '', '', '') ; 313 314 if (ref $_[0] ) { 315 $in = $_[0] ; 316 croak "not a scalar reference" unless ref $in eq 'SCALAR' ; 317 } 318 else { 319 $in = \$_[0] ; 320 } 321 322 $] >= 5.008 and (utf8::downgrade($$in, 1) 323 or croak "Wide character in compress"); 324 325 my $level = (@_ == 2 ? $_[1] : Z_DEFAULT_COMPRESSION() ); 326 327 $x = new Compress::Raw::Zlib::Deflate -AppendOutput => 1, -Level => $level 328 or return undef ; 329 330 $err = $x->deflate($in, $output) ; 331 return undef unless $err == Z_OK() ; 332 333 $err = $x->flush($output) ; 334 return undef unless $err == Z_OK() ; 335 336 return $output ; 337 338} 339 340sub uncompress($) 341{ 342 my ($x, $output, $err, $in) =('', '', '', '') ; 343 344 if (ref $_[0] ) { 345 $in = $_[0] ; 346 croak "not a scalar reference" unless ref $in eq 'SCALAR' ; 347 } 348 else { 349 $in = \$_[0] ; 350 } 351 352 $] >= 5.008 and (utf8::downgrade($$in, 1) 353 or croak "Wide character in uncompress"); 354 355 $x = new Compress::Raw::Zlib::Inflate -ConsumeInput => 0 or return undef ; 356 357 $err = $x->inflate($in, $output) ; 358 return undef unless $err == Z_STREAM_END() ; 359 360 return $output ; 361} 362 363 364 365sub deflateInit(@) 366{ 367 my ($got) = ParseParameters(0, 368 { 369 'Bufsize' => [1, 1, Parse_unsigned, 4096], 370 'Level' => [1, 1, Parse_signed, Z_DEFAULT_COMPRESSION()], 371 'Method' => [1, 1, Parse_unsigned, Z_DEFLATED()], 372 'WindowBits' => [1, 1, Parse_signed, MAX_WBITS()], 373 'MemLevel' => [1, 1, Parse_unsigned, MAX_MEM_LEVEL()], 374 'Strategy' => [1, 1, Parse_unsigned, Z_DEFAULT_STRATEGY()], 375 'Dictionary' => [1, 1, Parse_any, ""], 376 }, @_ ) ; 377 378 croak "Compress::Zlib::deflateInit: Bufsize must be >= 1, you specified " . 379 $got->value('Bufsize') 380 unless $got->value('Bufsize') >= 1; 381 382 my $obj ; 383 384 my $status = 0 ; 385 ($obj, $status) = 386 Compress::Raw::Zlib::_deflateInit(0, 387 $got->value('Level'), 388 $got->value('Method'), 389 $got->value('WindowBits'), 390 $got->value('MemLevel'), 391 $got->value('Strategy'), 392 $got->value('Bufsize'), 393 $got->value('Dictionary')) ; 394 395 my $x = ($status == Z_OK() ? bless $obj, "Zlib::OldDeflate" : undef) ; 396 return wantarray ? ($x, $status) : $x ; 397} 398 399sub inflateInit(@) 400{ 401 my ($got) = ParseParameters(0, 402 { 403 'Bufsize' => [1, 1, Parse_unsigned, 4096], 404 'WindowBits' => [1, 1, Parse_signed, MAX_WBITS()], 405 'Dictionary' => [1, 1, Parse_any, ""], 406 }, @_) ; 407 408 409 croak "Compress::Zlib::inflateInit: Bufsize must be >= 1, you specified " . 410 $got->value('Bufsize') 411 unless $got->value('Bufsize') >= 1; 412 413 my $status = 0 ; 414 my $obj ; 415 ($obj, $status) = Compress::Raw::Zlib::_inflateInit(FLAG_CONSUME_INPUT, 416 $got->value('WindowBits'), 417 $got->value('Bufsize'), 418 $got->value('Dictionary')) ; 419 420 my $x = ($status == Z_OK() ? bless $obj, "Zlib::OldInflate" : undef) ; 421 422 wantarray ? ($x, $status) : $x ; 423} 424 425package Zlib::OldDeflate ; 426 427our (@ISA); 428@ISA = qw(Compress::Raw::Zlib::deflateStream); 429 430 431sub deflate 432{ 433 my $self = shift ; 434 my $output ; 435 436 my $status = $self->SUPER::deflate($_[0], $output) ; 437 wantarray ? ($output, $status) : $output ; 438} 439 440sub flush 441{ 442 my $self = shift ; 443 my $output ; 444 my $flag = shift || Compress::Zlib::Z_FINISH(); 445 my $status = $self->SUPER::flush($output, $flag) ; 446 447 wantarray ? ($output, $status) : $output ; 448} 449 450package Zlib::OldInflate ; 451 452our (@ISA); 453@ISA = qw(Compress::Raw::Zlib::inflateStream); 454 455sub inflate 456{ 457 my $self = shift ; 458 my $output ; 459 my $status = $self->SUPER::inflate($_[0], $output) ; 460 wantarray ? ($output, $status) : $output ; 461} 462 463package Compress::Zlib ; 464 465use IO::Compress::Gzip::Constants 2.024 ; 466 467sub memGzip($) 468{ 469 my $out; 470 471 # if the deflation buffer isn't a reference, make it one 472 my $string = (ref $_[0] ? $_[0] : \$_[0]) ; 473 474 $] >= 5.008 and (utf8::downgrade($$string, 1) 475 or croak "Wide character in memGzip"); 476 477 _set_gzerr(0); 478 if ( ! IO::Compress::Gzip::gzip($string, \$out, Minimal => 1) ) 479 { 480 $Compress::Zlib::gzerrno = $IO::Compress::Gzip::GzipError; 481 return undef ; 482 } 483 484 return $out; 485} 486 487sub _removeGzipHeader($) 488{ 489 my $string = shift ; 490 491 return Z_DATA_ERROR() 492 if length($$string) < GZIP_MIN_HEADER_SIZE ; 493 494 my ($magic1, $magic2, $method, $flags, $time, $xflags, $oscode) = 495 unpack ('CCCCVCC', $$string); 496 497 return Z_DATA_ERROR() 498 unless $magic1 == GZIP_ID1 and $magic2 == GZIP_ID2 and 499 $method == Z_DEFLATED() and !($flags & GZIP_FLG_RESERVED) ; 500 substr($$string, 0, GZIP_MIN_HEADER_SIZE) = '' ; 501 502 # skip extra field 503 if ($flags & GZIP_FLG_FEXTRA) 504 { 505 return Z_DATA_ERROR() 506 if length($$string) < GZIP_FEXTRA_HEADER_SIZE ; 507 508 my ($extra_len) = unpack ('v', $$string); 509 $extra_len += GZIP_FEXTRA_HEADER_SIZE; 510 return Z_DATA_ERROR() 511 if length($$string) < $extra_len ; 512 513 substr($$string, 0, $extra_len) = ''; 514 } 515 516 # skip orig name 517 if ($flags & GZIP_FLG_FNAME) 518 { 519 my $name_end = index ($$string, GZIP_NULL_BYTE); 520 return Z_DATA_ERROR() 521 if $name_end == -1 ; 522 substr($$string, 0, $name_end + 1) = ''; 523 } 524 525 # skip comment 526 if ($flags & GZIP_FLG_FCOMMENT) 527 { 528 my $comment_end = index ($$string, GZIP_NULL_BYTE); 529 return Z_DATA_ERROR() 530 if $comment_end == -1 ; 531 substr($$string, 0, $comment_end + 1) = ''; 532 } 533 534 # skip header crc 535 if ($flags & GZIP_FLG_FHCRC) 536 { 537 return Z_DATA_ERROR() 538 if length ($$string) < GZIP_FHCRC_SIZE ; 539 substr($$string, 0, GZIP_FHCRC_SIZE) = ''; 540 } 541 542 return Z_OK(); 543} 544 545sub _ret_gun_error 546{ 547 $Compress::Zlib::gzerrno = $IO::Uncompress::Gunzip::GunzipError; 548 return undef; 549} 550 551 552sub memGunzip($) 553{ 554 # if the buffer isn't a reference, make it one 555 my $string = (ref $_[0] ? $_[0] : \$_[0]); 556 557 $] >= 5.008 and (utf8::downgrade($$string, 1) 558 or croak "Wide character in memGunzip"); 559 560 _set_gzerr(0); 561 562 my $status = _removeGzipHeader($string) ; 563 $status == Z_OK() 564 or return _set_gzerr_undef($status); 565 566 my $bufsize = length $$string > 4096 ? length $$string : 4096 ; 567 my $x = new Compress::Raw::Zlib::Inflate({-WindowBits => - MAX_WBITS(), 568 -Bufsize => $bufsize}) 569 570 or return _ret_gun_error(); 571 572 my $output = "" ; 573 $status = $x->inflate($string, $output); 574 575 if ( $status == Z_OK() ) 576 { 577 _set_gzerr(Z_DATA_ERROR()); 578 return undef; 579 } 580 581 return _ret_gun_error() 582 if ($status != Z_STREAM_END()); 583 584 if (length $$string >= 8) 585 { 586 my ($crc, $len) = unpack ("VV", substr($$string, 0, 8)); 587 substr($$string, 0, 8) = ''; 588 return _set_gzerr_undef(Z_DATA_ERROR()) 589 unless $len == length($output) and 590 $crc == crc32($output); 591 } 592 else 593 { 594 $$string = ''; 595 } 596 597 return $output; 598} 599 600# Autoload methods go after __END__, and are processed by the autosplit program. 601 6021; 603__END__ 604 605 606=head1 NAME 607 608Compress::Zlib - Interface to zlib compression library 609 610=head1 SYNOPSIS 611 612 use Compress::Zlib ; 613 614 ($d, $status) = deflateInit( [OPT] ) ; 615 $status = $d->deflate($input, $output) ; 616 $status = $d->flush([$flush_type]) ; 617 $d->deflateParams(OPTS) ; 618 $d->deflateTune(OPTS) ; 619 $d->dict_adler() ; 620 $d->crc32() ; 621 $d->adler32() ; 622 $d->total_in() ; 623 $d->total_out() ; 624 $d->msg() ; 625 $d->get_Strategy(); 626 $d->get_Level(); 627 $d->get_BufSize(); 628 629 ($i, $status) = inflateInit( [OPT] ) ; 630 $status = $i->inflate($input, $output [, $eof]) ; 631 $status = $i->inflateSync($input) ; 632 $i->dict_adler() ; 633 $d->crc32() ; 634 $d->adler32() ; 635 $i->total_in() ; 636 $i->total_out() ; 637 $i->msg() ; 638 $d->get_BufSize(); 639 640 $dest = compress($source) ; 641 $dest = uncompress($source) ; 642 643 $gz = gzopen($filename or filehandle, $mode) ; 644 $bytesread = $gz->gzread($buffer [,$size]) ; 645 $bytesread = $gz->gzreadline($line) ; 646 $byteswritten = $gz->gzwrite($buffer) ; 647 $status = $gz->gzflush($flush) ; 648 $offset = $gz->gztell() ; 649 $status = $gz->gzseek($offset, $whence) ; 650 $status = $gz->gzclose() ; 651 $status = $gz->gzeof() ; 652 $status = $gz->gzsetparams($level, $strategy) ; 653 $errstring = $gz->gzerror() ; 654 $gzerrno 655 656 $dest = Compress::Zlib::memGzip($buffer) ; 657 $dest = Compress::Zlib::memGunzip($buffer) ; 658 659 $crc = adler32($buffer [,$crc]) ; 660 $crc = crc32($buffer [,$crc]) ; 661 662 $crc = adler32_combine($crc1, $crc2, $len2)l 663 $crc = crc32_combine($adler1, $adler2, $len2) 664 665 my $version = Compress::Raw::Zlib::zlib_version(); 666 667=head1 DESCRIPTION 668 669The I<Compress::Zlib> module provides a Perl interface to the I<zlib> 670compression library (see L</AUTHOR> for details about where to get 671I<zlib>). 672 673The C<Compress::Zlib> module can be split into two general areas of 674functionality, namely a simple read/write interface to I<gzip> files 675and a low-level in-memory compression/decompression interface. 676 677Each of these areas will be discussed in the following sections. 678 679=head2 Notes for users of Compress::Zlib version 1 680 681The main change in C<Compress::Zlib> version 2.x is that it does not now 682interface directly to the zlib library. Instead it uses the 683C<IO::Compress::Gzip> and C<IO::Uncompress::Gunzip> modules for 684reading/writing gzip files, and the C<Compress::Raw::Zlib> module for some 685low-level zlib access. 686 687The interface provided by version 2 of this module should be 100% backward 688compatible with version 1. If you find a difference in the expected 689behaviour please contact the author (See L</AUTHOR>). See L<GZIP INTERFACE> 690 691With the creation of the C<IO::Compress> and C<IO::Uncompress> modules no 692new features are planned for C<Compress::Zlib> - the new modules do 693everything that C<Compress::Zlib> does and then some. Development on 694C<Compress::Zlib> will be limited to bug fixes only. 695 696If you are writing new code, your first port of call should be one of the 697new C<IO::Compress> or C<IO::Uncompress> modules. 698 699=head1 GZIP INTERFACE 700 701A number of functions are supplied in I<zlib> for reading and writing 702I<gzip> files that conform to RFC 1952. This module provides an interface 703to most of them. 704 705If you have previously used C<Compress::Zlib> 1.x, the following 706enhancements/changes have been made to the C<gzopen> interface: 707 708=over 5 709 710=item 1 711 712If you want to to open either STDIN or STDOUT with C<gzopen>, you can now 713optionally use the special filename "C<->" as a synonym for C<\*STDIN> and 714C<\*STDOUT>. 715 716=item 2 717 718In C<Compress::Zlib> version 1.x, C<gzopen> used the zlib library to open 719the underlying file. This made things especially tricky when a Perl 720filehandle was passed to C<gzopen>. Behind the scenes the numeric C file 721descriptor had to be extracted from the Perl filehandle and this passed to 722the zlib library. 723 724Apart from being non-portable to some operating systems, this made it 725difficult to use C<gzopen> in situations where you wanted to extract/create 726a gzip data stream that is embedded in a larger file, without having to 727resort to opening and closing the file multiple times. 728 729It also made it impossible to pass a perl filehandle that wasn't associated 730with a real filesystem file, like, say, an C<IO::String>. 731 732In C<Compress::Zlib> version 2.x, the C<gzopen> interface has been 733completely rewritten to use the L<IO::Compress::Gzip|IO::Compress::Gzip> 734for writing gzip files and L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip> 735for reading gzip files. None of the limitations mentioned above apply. 736 737=item 3 738 739Addition of C<gzseek> to provide a restricted C<seek> interface. 740 741=item 4. 742 743Added C<gztell>. 744 745=back 746 747A more complete and flexible interface for reading/writing gzip 748files/buffers is included with the module C<IO-Compress-Zlib>. See 749L<IO::Compress::Gzip|IO::Compress::Gzip> and 750L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip> for more details. 751 752=over 5 753 754=item B<$gz = gzopen($filename, $mode)> 755 756=item B<$gz = gzopen($filehandle, $mode)> 757 758This function opens either the I<gzip> file C<$filename> for reading or 759writing or attaches to the opened filehandle, C<$filehandle>. 760It returns an object on success and C<undef> on failure. 761 762When writing a gzip file this interface will I<always> create the smallest 763possible gzip header (exactly 10 bytes). If you want greater control over 764what gets stored in the gzip header (like the original filename or a 765comment) use L<IO::Compress::Gzip|IO::Compress::Gzip> instead. Similarly if 766you want to read the contents of the gzip header use 767L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip>. 768 769The second parameter, C<$mode>, is used to specify whether the file is 770opened for reading or writing and to optionally specify a compression 771level and compression strategy when writing. The format of the C<$mode> 772parameter is similar to the mode parameter to the 'C' function C<fopen>, 773so "rb" is used to open for reading, "wb" for writing and "ab" for 774appending (writing at the end of the file). 775 776To specify a compression level when writing, append a digit between 0 777and 9 to the mode string -- 0 means no compression and 9 means maximum 778compression. 779If no compression level is specified Z_DEFAULT_COMPRESSION is used. 780 781To specify the compression strategy when writing, append 'f' for filtered 782data, 'h' for Huffman only compression, or 'R' for run-length encoding. 783If no strategy is specified Z_DEFAULT_STRATEGY is used. 784 785So, for example, "wb9" means open for writing with the maximum compression 786using the default strategy and "wb4R" means open for writing with compression 787level 4 and run-length encoding. 788 789Refer to the I<zlib> documentation for the exact format of the C<$mode> 790parameter. 791 792=item B<$bytesread = $gz-E<gt>gzread($buffer [, $size]) ;> 793 794Reads C<$size> bytes from the compressed file into C<$buffer>. If 795C<$size> is not specified, it will default to 4096. If the scalar 796C<$buffer> is not large enough, it will be extended automatically. 797 798Returns the number of bytes actually read. On EOF it returns 0 and in 799the case of an error, -1. 800 801=item B<$bytesread = $gz-E<gt>gzreadline($line) ;> 802 803Reads the next line from the compressed file into C<$line>. 804 805Returns the number of bytes actually read. On EOF it returns 0 and in 806the case of an error, -1. 807 808It is legal to intermix calls to C<gzread> and C<gzreadline>. 809 810To maintain backward compatibility with version 1.x of this module 811C<gzreadline> ignores the C<$/> variable - it I<always> uses the string 812C<"\n"> as the line delimiter. 813 814If you want to read a gzip file a line at a time and have it respect the 815C<$/> variable (or C<$INPUT_RECORD_SEPARATOR>, or C<$RS> when C<English> is 816in use) see L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip>. 817 818=item B<$byteswritten = $gz-E<gt>gzwrite($buffer) ;> 819 820Writes the contents of C<$buffer> to the compressed file. Returns the 821number of bytes actually written, or 0 on error. 822 823=item B<$status = $gz-E<gt>gzflush($flush_type) ;> 824 825Flushes all pending output into the compressed file. 826 827This method takes an optional parameter, C<$flush_type>, that controls 828how the flushing will be carried out. By default the C<$flush_type> 829used is C<Z_FINISH>. Other valid values for C<$flush_type> are 830C<Z_NO_FLUSH>, C<Z_SYNC_FLUSH>, C<Z_FULL_FLUSH> and C<Z_BLOCK>. It is 831strongly recommended that you only set the C<flush_type> parameter if 832you fully understand the implications of what it does - overuse of C<flush> 833can seriously degrade the level of compression achieved. See the C<zlib> 834documentation for details. 835 836Returns 0 on success. 837 838=item B<$offset = $gz-E<gt>gztell() ;> 839 840Returns the uncompressed file offset. 841 842=item B<$status = $gz-E<gt>gzseek($offset, $whence) ;> 843 844Provides a sub-set of the C<seek> functionality, with the restriction 845that it is only legal to seek forward in the compressed file. 846It is a fatal error to attempt to seek backward. 847 848When opened for writing, empty parts of the file will have NULL (0x00) 849bytes written to them. 850 851The C<$whence> parameter should be one of SEEK_SET, SEEK_CUR or SEEK_END. 852 853Returns 1 on success, 0 on failure. 854 855=item B<$gz-E<gt>gzclose> 856 857Closes the compressed file. Any pending data is flushed to the file 858before it is closed. 859 860Returns 0 on success. 861 862=item B<$gz-E<gt>gzsetparams($level, $strategy> 863 864Change settings for the deflate stream C<$gz>. 865 866The list of the valid options is shown below. Options not specified 867will remain unchanged. 868 869Note: This method is only available if you are running zlib 1.0.6 or better. 870 871=over 5 872 873=item B<$level> 874 875Defines the compression level. Valid values are 0 through 9, 876C<Z_NO_COMPRESSION>, C<Z_BEST_SPEED>, C<Z_BEST_COMPRESSION>, and 877C<Z_DEFAULT_COMPRESSION>. 878 879=item B<$strategy> 880 881Defines the strategy used to tune the compression. The valid values are 882C<Z_DEFAULT_STRATEGY>, C<Z_FILTERED> and C<Z_HUFFMAN_ONLY>. 883 884=back 885 886=item B<$gz-E<gt>gzerror> 887 888Returns the I<zlib> error message or number for the last operation 889associated with C<$gz>. The return value will be the I<zlib> error 890number when used in a numeric context and the I<zlib> error message 891when used in a string context. The I<zlib> error number constants, 892shown below, are available for use. 893 894 Z_OK 895 Z_STREAM_END 896 Z_ERRNO 897 Z_STREAM_ERROR 898 Z_DATA_ERROR 899 Z_MEM_ERROR 900 Z_BUF_ERROR 901 902=item B<$gzerrno> 903 904The C<$gzerrno> scalar holds the error code associated with the most 905recent I<gzip> routine. Note that unlike C<gzerror()>, the error is 906I<not> associated with a particular file. 907 908As with C<gzerror()> it returns an error number in numeric context and 909an error message in string context. Unlike C<gzerror()> though, the 910error message will correspond to the I<zlib> message when the error is 911associated with I<zlib> itself, or the UNIX error message when it is 912not (i.e. I<zlib> returned C<Z_ERRORNO>). 913 914As there is an overlap between the error numbers used by I<zlib> and 915UNIX, C<$gzerrno> should only be used to check for the presence of 916I<an> error in numeric context. Use C<gzerror()> to check for specific 917I<zlib> errors. The I<gzcat> example below shows how the variable can 918be used safely. 919 920=back 921 922=head2 Examples 923 924Here is an example script which uses the interface. It implements a 925I<gzcat> function. 926 927 use strict ; 928 use warnings ; 929 930 use Compress::Zlib ; 931 932 # use stdin if no files supplied 933 @ARGV = '-' unless @ARGV ; 934 935 foreach my $file (@ARGV) { 936 my $buffer ; 937 938 my $gz = gzopen($file, "rb") 939 or die "Cannot open $file: $gzerrno\n" ; 940 941 print $buffer while $gz->gzread($buffer) > 0 ; 942 943 die "Error reading from $file: $gzerrno" . ($gzerrno+0) . "\n" 944 if $gzerrno != Z_STREAM_END ; 945 946 $gz->gzclose() ; 947 } 948 949Below is a script which makes use of C<gzreadline>. It implements a 950very simple I<grep> like script. 951 952 use strict ; 953 use warnings ; 954 955 use Compress::Zlib ; 956 957 die "Usage: gzgrep pattern [file...]\n" 958 unless @ARGV >= 1; 959 960 my $pattern = shift ; 961 962 # use stdin if no files supplied 963 @ARGV = '-' unless @ARGV ; 964 965 foreach my $file (@ARGV) { 966 my $gz = gzopen($file, "rb") 967 or die "Cannot open $file: $gzerrno\n" ; 968 969 while ($gz->gzreadline($_) > 0) { 970 print if /$pattern/ ; 971 } 972 973 die "Error reading from $file: $gzerrno\n" 974 if $gzerrno != Z_STREAM_END ; 975 976 $gz->gzclose() ; 977 } 978 979This script, I<gzstream>, does the opposite of the I<gzcat> script 980above. It reads from standard input and writes a gzip data stream to 981standard output. 982 983 use strict ; 984 use warnings ; 985 986 use Compress::Zlib ; 987 988 binmode STDOUT; # gzopen only sets it on the fd 989 990 my $gz = gzopen(\*STDOUT, "wb") 991 or die "Cannot open stdout: $gzerrno\n" ; 992 993 while (<>) { 994 $gz->gzwrite($_) 995 or die "error writing: $gzerrno\n" ; 996 } 997 998 $gz->gzclose ; 999 1000=head2 Compress::Zlib::memGzip 1001 1002This function is used to create an in-memory gzip file with the minimum 1003possible gzip header (exactly 10 bytes). 1004 1005 $dest = Compress::Zlib::memGzip($buffer) 1006 or die "Cannot compress: $gzerrno\n"; 1007 1008If successful, it returns the in-memory gzip file. Otherwise it returns 1009C<undef> and the C<$gzerrno> variable will store the zlib error code. 1010 1011The C<$buffer> parameter can either be a scalar or a scalar reference. 1012 1013See L<IO::Compress::Gzip|IO::Compress::Gzip> for an alternative way to 1014carry out in-memory gzip compression. 1015 1016=head2 Compress::Zlib::memGunzip 1017 1018This function is used to uncompress an in-memory gzip file. 1019 1020 $dest = Compress::Zlib::memGunzip($buffer) 1021 or die "Cannot uncomprss: $gzerrno\n"; 1022 1023If successful, it returns the uncompressed gzip file. Otherwise it 1024returns C<undef> and the C<$gzerrno> variable will store the zlib error 1025code. 1026 1027The C<$buffer> parameter can either be a scalar or a scalar reference. The 1028contents of the C<$buffer> parameter are destroyed after calling this function. 1029 1030If C<$buffer> consists of multiple concatenated gzip data streams only the 1031first will be uncompressed. Use C<gunzip> with the C<MultiStream> option in 1032the C<IO::Uncompress::Gunzip> module if you need to deal with concatenated 1033data streams. 1034 1035See L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip> for an alternative way 1036to carry out in-memory gzip uncompression. 1037 1038=head1 COMPRESS/UNCOMPRESS 1039 1040Two functions are provided to perform in-memory compression/uncompression of 1041RFC 1950 data streams. They are called C<compress> and C<uncompress>. 1042 1043=over 5 1044 1045=item B<$dest = compress($source [, $level] ) ;> 1046 1047Compresses C<$source>. If successful it returns the compressed 1048data. Otherwise it returns I<undef>. 1049 1050The source buffer, C<$source>, can either be a scalar or a scalar 1051reference. 1052 1053The C<$level> parameter defines the compression level. Valid values are 10540 through 9, C<Z_NO_COMPRESSION>, C<Z_BEST_SPEED>, 1055C<Z_BEST_COMPRESSION>, and C<Z_DEFAULT_COMPRESSION>. 1056If C<$level> is not specified C<Z_DEFAULT_COMPRESSION> will be used. 1057 1058=item B<$dest = uncompress($source) ;> 1059 1060Uncompresses C<$source>. If successful it returns the uncompressed 1061data. Otherwise it returns I<undef>. 1062 1063The source buffer can either be a scalar or a scalar reference. 1064 1065=back 1066 1067Please note: the two functions defined above are I<not> compatible with 1068the Unix commands of the same name. 1069 1070See L<IO::Deflate|IO::Deflate> and L<IO::Inflate|IO::Inflate> included with 1071this distribution for an alternative interface for reading/writing RFC 1950 1072files/buffers. 1073 1074=head1 Deflate Interface 1075 1076This section defines an interface that allows in-memory compression using 1077the I<deflate> interface provided by zlib. 1078 1079Here is a definition of the interface available: 1080 1081=head2 B<($d, $status) = deflateInit( [OPT] )> 1082 1083Initialises a deflation stream. 1084 1085It combines the features of the I<zlib> functions C<deflateInit>, 1086C<deflateInit2> and C<deflateSetDictionary>. 1087 1088If successful, it will return the initialised deflation stream, C<$d> 1089and C<$status> of C<Z_OK> in a list context. In scalar context it 1090returns the deflation stream, C<$d>, only. 1091 1092If not successful, the returned deflation stream (C<$d>) will be 1093I<undef> and C<$status> will hold the exact I<zlib> error code. 1094 1095The function optionally takes a number of named options specified as 1096C<< -Name=>value >> pairs. This allows individual options to be 1097tailored without having to specify them all in the parameter list. 1098 1099For backward compatibility, it is also possible to pass the parameters 1100as a reference to a hash containing the name=>value pairs. 1101 1102The function takes one optional parameter, a reference to a hash. The 1103contents of the hash allow the deflation interface to be tailored. 1104 1105Here is a list of the valid options: 1106 1107=over 5 1108 1109=item B<-Level> 1110 1111Defines the compression level. Valid values are 0 through 9, 1112C<Z_NO_COMPRESSION>, C<Z_BEST_SPEED>, C<Z_BEST_COMPRESSION>, and 1113C<Z_DEFAULT_COMPRESSION>. 1114 1115The default is Z_DEFAULT_COMPRESSION. 1116 1117=item B<-Method> 1118 1119Defines the compression method. The only valid value at present (and 1120the default) is Z_DEFLATED. 1121 1122=item B<-WindowBits> 1123 1124To create an RFC 1950 data stream, set C<WindowBits> to a positive number. 1125 1126To create an RFC 1951 data stream, set C<WindowBits> to C<-MAX_WBITS>. 1127 1128For a full definition of the meaning and valid values for C<WindowBits> refer 1129to the I<zlib> documentation for I<deflateInit2>. 1130 1131Defaults to MAX_WBITS. 1132 1133=item B<-MemLevel> 1134 1135For a definition of the meaning and valid values for C<MemLevel> 1136refer to the I<zlib> documentation for I<deflateInit2>. 1137 1138Defaults to MAX_MEM_LEVEL. 1139 1140=item B<-Strategy> 1141 1142Defines the strategy used to tune the compression. The valid values are 1143C<Z_DEFAULT_STRATEGY>, C<Z_FILTERED> and C<Z_HUFFMAN_ONLY>. 1144 1145The default is Z_DEFAULT_STRATEGY. 1146 1147=item B<-Dictionary> 1148 1149When a dictionary is specified I<Compress::Zlib> will automatically 1150call C<deflateSetDictionary> directly after calling C<deflateInit>. The 1151Adler32 value for the dictionary can be obtained by calling the method 1152C<$d->dict_adler()>. 1153 1154The default is no dictionary. 1155 1156=item B<-Bufsize> 1157 1158Sets the initial size for the deflation buffer. If the buffer has to be 1159reallocated to increase the size, it will grow in increments of 1160C<Bufsize>. 1161 1162The default is 4096. 1163 1164=back 1165 1166Here is an example of using the C<deflateInit> optional parameter list 1167to override the default buffer size and compression level. All other 1168options will take their default values. 1169 1170 deflateInit( -Bufsize => 300, 1171 -Level => Z_BEST_SPEED ) ; 1172 1173=head2 B<($out, $status) = $d-E<gt>deflate($buffer)> 1174 1175Deflates the contents of C<$buffer>. The buffer can either be a scalar 1176or a scalar reference. When finished, C<$buffer> will be 1177completely processed (assuming there were no errors). If the deflation 1178was successful it returns the deflated output, C<$out>, and a status 1179value, C<$status>, of C<Z_OK>. 1180 1181On error, C<$out> will be I<undef> and C<$status> will contain the 1182I<zlib> error code. 1183 1184In a scalar context C<deflate> will return C<$out> only. 1185 1186As with the I<deflate> function in I<zlib>, it is not necessarily the 1187case that any output will be produced by this method. So don't rely on 1188the fact that C<$out> is empty for an error test. 1189 1190=head2 B<($out, $status) = $d-E<gt>flush()> 1191=head2 B<($out, $status) = $d-E<gt>flush($flush_type)> 1192 1193Typically used to finish the deflation. Any pending output will be 1194returned via C<$out>. 1195C<$status> will have a value C<Z_OK> if successful. 1196 1197In a scalar context C<flush> will return C<$out> only. 1198 1199Note that flushing can seriously degrade the compression ratio, so it 1200should only be used to terminate a decompression (using C<Z_FINISH>) or 1201when you want to create a I<full flush point> (using C<Z_FULL_FLUSH>). 1202 1203By default the C<flush_type> used is C<Z_FINISH>. Other valid values 1204for C<flush_type> are C<Z_NO_FLUSH>, C<Z_PARTIAL_FLUSH>, C<Z_SYNC_FLUSH> 1205and C<Z_FULL_FLUSH>. It is strongly recommended that you only set the 1206C<flush_type> parameter if you fully understand the implications of 1207what it does. See the C<zlib> documentation for details. 1208 1209=head2 B<$status = $d-E<gt>deflateParams([OPT])> 1210 1211Change settings for the deflate stream C<$d>. 1212 1213The list of the valid options is shown below. Options not specified 1214will remain unchanged. 1215 1216=over 5 1217 1218=item B<-Level> 1219 1220Defines the compression level. Valid values are 0 through 9, 1221C<Z_NO_COMPRESSION>, C<Z_BEST_SPEED>, C<Z_BEST_COMPRESSION>, and 1222C<Z_DEFAULT_COMPRESSION>. 1223 1224=item B<-Strategy> 1225 1226Defines the strategy used to tune the compression. The valid values are 1227C<Z_DEFAULT_STRATEGY>, C<Z_FILTERED> and C<Z_HUFFMAN_ONLY>. 1228 1229=back 1230 1231=head2 B<$d-E<gt>dict_adler()> 1232 1233Returns the adler32 value for the dictionary. 1234 1235=head2 B<$d-E<gt>msg()> 1236 1237Returns the last error message generated by zlib. 1238 1239=head2 B<$d-E<gt>total_in()> 1240 1241Returns the total number of bytes uncompressed bytes input to deflate. 1242 1243=head2 B<$d-E<gt>total_out()> 1244 1245Returns the total number of compressed bytes output from deflate. 1246 1247=head2 Example 1248 1249Here is a trivial example of using C<deflate>. It simply reads standard 1250input, deflates it and writes it to standard output. 1251 1252 use strict ; 1253 use warnings ; 1254 1255 use Compress::Zlib ; 1256 1257 binmode STDIN; 1258 binmode STDOUT; 1259 my $x = deflateInit() 1260 or die "Cannot create a deflation stream\n" ; 1261 1262 my ($output, $status) ; 1263 while (<>) 1264 { 1265 ($output, $status) = $x->deflate($_) ; 1266 1267 $status == Z_OK 1268 or die "deflation failed\n" ; 1269 1270 print $output ; 1271 } 1272 1273 ($output, $status) = $x->flush() ; 1274 1275 $status == Z_OK 1276 or die "deflation failed\n" ; 1277 1278 print $output ; 1279 1280=head1 Inflate Interface 1281 1282This section defines the interface available that allows in-memory 1283uncompression using the I<deflate> interface provided by zlib. 1284 1285Here is a definition of the interface: 1286 1287=head2 B<($i, $status) = inflateInit()> 1288 1289Initialises an inflation stream. 1290 1291In a list context it returns the inflation stream, C<$i>, and the 1292I<zlib> status code in C<$status>. In a scalar context it returns the 1293inflation stream only. 1294 1295If successful, C<$i> will hold the inflation stream and C<$status> will 1296be C<Z_OK>. 1297 1298If not successful, C<$i> will be I<undef> and C<$status> will hold the 1299I<zlib> error code. 1300 1301The function optionally takes a number of named options specified as 1302C<< -Name=>value >> pairs. This allows individual options to be 1303tailored without having to specify them all in the parameter list. 1304 1305For backward compatibility, it is also possible to pass the parameters 1306as a reference to a hash containing the name=>value pairs. 1307 1308The function takes one optional parameter, a reference to a hash. The 1309contents of the hash allow the deflation interface to be tailored. 1310 1311Here is a list of the valid options: 1312 1313=over 5 1314 1315=item B<-WindowBits> 1316 1317To uncompress an RFC 1950 data stream, set C<WindowBits> to a positive number. 1318 1319To uncompress an RFC 1951 data stream, set C<WindowBits> to C<-MAX_WBITS>. 1320 1321For a full definition of the meaning and valid values for C<WindowBits> refer 1322to the I<zlib> documentation for I<inflateInit2>. 1323 1324Defaults to MAX_WBITS. 1325 1326=item B<-Bufsize> 1327 1328Sets the initial size for the inflation buffer. If the buffer has to be 1329reallocated to increase the size, it will grow in increments of 1330C<Bufsize>. 1331 1332Default is 4096. 1333 1334=item B<-Dictionary> 1335 1336The default is no dictionary. 1337 1338=back 1339 1340Here is an example of using the C<inflateInit> optional parameter to 1341override the default buffer size. 1342 1343 inflateInit( -Bufsize => 300 ) ; 1344 1345=head2 B<($out, $status) = $i-E<gt>inflate($buffer)> 1346 1347Inflates the complete contents of C<$buffer>. The buffer can either be 1348a scalar or a scalar reference. 1349 1350Returns C<Z_OK> if successful and C<Z_STREAM_END> if the end of the 1351compressed data has been successfully reached. 1352If not successful, C<$out> will be I<undef> and C<$status> will hold 1353the I<zlib> error code. 1354 1355The C<$buffer> parameter is modified by C<inflate>. On completion it 1356will contain what remains of the input buffer after inflation. This 1357means that C<$buffer> will be an empty string when the return status is 1358C<Z_OK>. When the return status is C<Z_STREAM_END> the C<$buffer> 1359parameter will contains what (if anything) was stored in the input 1360buffer after the deflated data stream. 1361 1362This feature is useful when processing a file format that encapsulates 1363a compressed data stream (e.g. gzip, zip). 1364 1365=head2 B<$status = $i-E<gt>inflateSync($buffer)> 1366 1367Scans C<$buffer> until it reaches either a I<full flush point> or the 1368end of the buffer. 1369 1370If a I<full flush point> is found, C<Z_OK> is returned and C<$buffer> 1371will be have all data up to the flush point removed. This can then be 1372passed to the C<deflate> method. 1373 1374Any other return code means that a flush point was not found. If more 1375data is available, C<inflateSync> can be called repeatedly with more 1376compressed data until the flush point is found. 1377 1378=head2 B<$i-E<gt>dict_adler()> 1379 1380Returns the adler32 value for the dictionary. 1381 1382=head2 B<$i-E<gt>msg()> 1383 1384Returns the last error message generated by zlib. 1385 1386=head2 B<$i-E<gt>total_in()> 1387 1388Returns the total number of bytes compressed bytes input to inflate. 1389 1390=head2 B<$i-E<gt>total_out()> 1391 1392Returns the total number of uncompressed bytes output from inflate. 1393 1394=head2 Example 1395 1396Here is an example of using C<inflate>. 1397 1398 use strict ; 1399 use warnings ; 1400 1401 use Compress::Zlib ; 1402 1403 my $x = inflateInit() 1404 or die "Cannot create a inflation stream\n" ; 1405 1406 my $input = '' ; 1407 binmode STDIN; 1408 binmode STDOUT; 1409 1410 my ($output, $status) ; 1411 while (read(STDIN, $input, 4096)) 1412 { 1413 ($output, $status) = $x->inflate(\$input) ; 1414 1415 print $output 1416 if $status == Z_OK or $status == Z_STREAM_END ; 1417 1418 last if $status != Z_OK ; 1419 } 1420 1421 die "inflation failed\n" 1422 unless $status == Z_STREAM_END ; 1423 1424=head1 CHECKSUM FUNCTIONS 1425 1426Two functions are provided by I<zlib> to calculate checksums. For the 1427Perl interface, the order of the two parameters in both functions has 1428been reversed. This allows both running checksums and one off 1429calculations to be done. 1430 1431 $crc = adler32($buffer [,$crc]) ; 1432 $crc = crc32($buffer [,$crc]) ; 1433 1434The buffer parameters can either be a scalar or a scalar reference. 1435 1436If the $crc parameters is C<undef>, the crc value will be reset. 1437 1438If you have built this module with zlib 1.2.3 or better, two more 1439CRC-related functions are available. 1440 1441 $crc = adler32_combine($crc1, $crc2, $len2)l 1442 $crc = crc32_combine($adler1, $adler2, $len2) 1443 1444These functions allow checksums to be merged. 1445 1446=head1 Misc 1447 1448=head2 my $version = Compress::Zlib::zlib_version(); 1449 1450Returns the version of the zlib library. 1451 1452=head1 CONSTANTS 1453 1454All the I<zlib> constants are automatically imported when you make use 1455of I<Compress::Zlib>. 1456 1457=head1 SEE ALSO 1458 1459L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Compress::Deflate>, 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> 1460 1461L<Compress::Zlib::FAQ|Compress::Zlib::FAQ> 1462 1463L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>, 1464L<Archive::Tar|Archive::Tar>, 1465L<IO::Zlib|IO::Zlib> 1466 1467For RFC 1950, 1951 and 1952 see 1468F<http://www.faqs.org/rfcs/rfc1950.html>, 1469F<http://www.faqs.org/rfcs/rfc1951.html> and 1470F<http://www.faqs.org/rfcs/rfc1952.html> 1471 1472The I<zlib> compression library was written by Jean-loup Gailly 1473F<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>. 1474 1475The primary site for the I<zlib> compression library is 1476F<http://www.zlib.org>. 1477 1478The primary site for gzip is F<http://www.gzip.org>. 1479 1480=head1 AUTHOR 1481 1482This module was written by Paul Marquess, F<pmqs@cpan.org>. 1483 1484=head1 MODIFICATION HISTORY 1485 1486See the Changes file. 1487 1488=head1 COPYRIGHT AND LICENSE 1489 1490Copyright (c) 1995-2010 Paul Marquess. All rights reserved. 1491 1492This program is free software; you can redistribute it and/or 1493modify it under the same terms as Perl itself. 1494 1495