Blame lib/Compress/Raw/Zlib.pm

Packit d03632
Packit d03632
package Compress::Raw::Zlib;
Packit d03632
Packit d03632
require 5.006 ;
Packit d03632
require Exporter;
Packit d03632
use Carp ;
Packit d03632
Packit d03632
use strict ;
Packit d03632
use warnings ;
Packit d03632
use bytes ;
Packit d03632
our ($VERSION, $XS_VERSION, @ISA, @EXPORT, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD, %DEFLATE_CONSTANTS, @DEFLATE_CONSTANTS);
Packit d03632
Packit d03632
$VERSION = '2.081';
Packit d03632
$XS_VERSION = $VERSION; 
Packit d03632
$VERSION = eval $VERSION;
Packit d03632
Packit d03632
@ISA = qw(Exporter);
Packit d03632
%EXPORT_TAGS = ( flush     => [qw{  
Packit d03632
                                    Z_NO_FLUSH
Packit d03632
                                    Z_PARTIAL_FLUSH
Packit d03632
                                    Z_SYNC_FLUSH
Packit d03632
                                    Z_FULL_FLUSH
Packit d03632
                                    Z_FINISH
Packit d03632
                                    Z_BLOCK
Packit d03632
                              }],
Packit d03632
                 level     => [qw{  
Packit d03632
                                    Z_NO_COMPRESSION
Packit d03632
                                    Z_BEST_SPEED
Packit d03632
                                    Z_BEST_COMPRESSION
Packit d03632
                                    Z_DEFAULT_COMPRESSION
Packit d03632
                              }],
Packit d03632
                 strategy  => [qw{  
Packit d03632
                                    Z_FILTERED
Packit d03632
                                    Z_HUFFMAN_ONLY
Packit d03632
                                    Z_RLE
Packit d03632
                                    Z_FIXED
Packit d03632
                                    Z_DEFAULT_STRATEGY
Packit d03632
                              }],
Packit d03632
                 status   => [qw{  
Packit d03632
                                    Z_OK
Packit d03632
                                    Z_STREAM_END
Packit d03632
                                    Z_NEED_DICT
Packit d03632
                                    Z_ERRNO
Packit d03632
                                    Z_STREAM_ERROR
Packit d03632
                                    Z_DATA_ERROR  
Packit d03632
                                    Z_MEM_ERROR   
Packit d03632
                                    Z_BUF_ERROR 
Packit d03632
                                    Z_VERSION_ERROR 
Packit d03632
                              }],                              
Packit d03632
              );
Packit d03632
Packit d03632
%DEFLATE_CONSTANTS = %EXPORT_TAGS;
Packit d03632
Packit d03632
# Items to export into callers namespace by default. Note: do not export
Packit d03632
# names by default without a very good reason. Use EXPORT_OK instead.
Packit d03632
# Do not simply export all your public functions/methods/constants.
Packit d03632
@DEFLATE_CONSTANTS = 
Packit d03632
@EXPORT = qw(
Packit d03632
        ZLIB_VERSION
Packit d03632
        ZLIB_VERNUM
Packit d03632
Packit d03632
        
Packit d03632
        OS_CODE
Packit d03632
Packit d03632
        MAX_MEM_LEVEL
Packit d03632
        MAX_WBITS
Packit d03632
Packit d03632
        Z_ASCII
Packit d03632
        Z_BEST_COMPRESSION
Packit d03632
        Z_BEST_SPEED
Packit d03632
        Z_BINARY
Packit d03632
        Z_BLOCK
Packit d03632
        Z_BUF_ERROR
Packit d03632
        Z_DATA_ERROR
Packit d03632
        Z_DEFAULT_COMPRESSION
Packit d03632
        Z_DEFAULT_STRATEGY
Packit d03632
        Z_DEFLATED
Packit d03632
        Z_ERRNO
Packit d03632
        Z_FILTERED
Packit d03632
        Z_FIXED
Packit d03632
        Z_FINISH
Packit d03632
        Z_FULL_FLUSH
Packit d03632
        Z_HUFFMAN_ONLY
Packit d03632
        Z_MEM_ERROR
Packit d03632
        Z_NEED_DICT
Packit d03632
        Z_NO_COMPRESSION
Packit d03632
        Z_NO_FLUSH
Packit d03632
        Z_NULL
Packit d03632
        Z_OK
Packit d03632
        Z_PARTIAL_FLUSH
Packit d03632
        Z_RLE
Packit d03632
        Z_STREAM_END
Packit d03632
        Z_STREAM_ERROR
Packit d03632
        Z_SYNC_FLUSH
Packit d03632
        Z_TREES
Packit d03632
        Z_UNKNOWN
Packit d03632
        Z_VERSION_ERROR
Packit d03632
Packit d03632
        WANT_GZIP
Packit d03632
        WANT_GZIP_OR_ZLIB
Packit d03632
);
Packit d03632
Packit d03632
push @EXPORT, qw(crc32 adler32 DEF_WBITS);
Packit d03632
Packit d03632
use constant WANT_GZIP           => 16;
Packit d03632
use constant WANT_GZIP_OR_ZLIB   => 32;
Packit d03632
Packit d03632
sub AUTOLOAD {
Packit d03632
    my($constname);
Packit d03632
    ($constname = $AUTOLOAD) =~ s/.*:://;
Packit d03632
    my ($error, $val) = constant($constname);
Packit d03632
    Carp::croak $error if $error;
Packit d03632
    no strict 'refs';
Packit d03632
    *{$AUTOLOAD} = sub { $val };
Packit d03632
    goto &{$AUTOLOAD};
Packit d03632
}
Packit d03632
Packit d03632
use constant FLAG_APPEND             => 1 ;
Packit d03632
use constant FLAG_CRC                => 2 ;
Packit d03632
use constant FLAG_ADLER              => 4 ;
Packit d03632
use constant FLAG_CONSUME_INPUT      => 8 ;
Packit d03632
use constant FLAG_LIMIT_OUTPUT       => 16 ;
Packit d03632
Packit d03632
eval {
Packit d03632
    require XSLoader;
Packit d03632
    XSLoader::load('Compress::Raw::Zlib', $XS_VERSION);
Packit d03632
    1;
Packit d03632
} 
Packit d03632
or do {
Packit d03632
    require DynaLoader;
Packit d03632
    local @ISA = qw(DynaLoader);
Packit d03632
    bootstrap Compress::Raw::Zlib $XS_VERSION ; 
Packit d03632
};
Packit d03632
 
Packit d03632
Packit d03632
use constant Parse_any      => 0x01;
Packit d03632
use constant Parse_unsigned => 0x02;
Packit d03632
use constant Parse_signed   => 0x04;
Packit d03632
use constant Parse_boolean  => 0x08;
Packit d03632
#use constant Parse_string   => 0x10;
Packit d03632
#use constant Parse_custom   => 0x12;
Packit d03632
Packit d03632
#use constant Parse_store_ref => 0x100 ;
Packit d03632
Packit d03632
use constant OFF_PARSED     => 0 ;
Packit d03632
use constant OFF_TYPE       => 1 ;
Packit d03632
use constant OFF_DEFAULT    => 2 ;
Packit d03632
use constant OFF_FIXED      => 3 ;
Packit d03632
use constant OFF_FIRST_ONLY => 4 ;
Packit d03632
use constant OFF_STICKY     => 5 ;
Packit d03632
Packit d03632
Packit d03632
Packit d03632
sub ParseParameters
Packit d03632
{
Packit d03632
    my $level = shift || 0 ; 
Packit d03632
Packit d03632
    my $sub = (caller($level + 1))[3] ;
Packit d03632
    #local $Carp::CarpLevel = 1 ;
Packit d03632
    my $p = new Compress::Raw::Zlib::Parameters() ;
Packit d03632
    $p->parse(@_)
Packit d03632
        or croak "$sub: $p->{Error}" ;
Packit d03632
Packit d03632
    return $p;
Packit d03632
}
Packit d03632
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::Parameters::new
Packit d03632
{
Packit d03632
    my $class = shift ;
Packit d03632
Packit d03632
    my $obj = { Error => '',
Packit d03632
                Got   => {},
Packit d03632
              } ;
Packit d03632
Packit d03632
    #return bless $obj, ref($class) || $class || __PACKAGE__ ;
Packit d03632
    return bless $obj, 'Compress::Raw::Zlib::Parameters' ;
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::Parameters::setError
Packit d03632
{
Packit d03632
    my $self = shift ;
Packit d03632
    my $error = shift ;
Packit d03632
    my $retval = @_ ? shift : undef ;
Packit d03632
Packit d03632
    $self->{Error} = $error ;
Packit d03632
    return $retval;
Packit d03632
}
Packit d03632
          
Packit d03632
#sub getError
Packit d03632
#{
Packit d03632
#    my $self = shift ;
Packit d03632
#    return $self->{Error} ;
Packit d03632
#}
Packit d03632
          
Packit d03632
sub Compress::Raw::Zlib::Parameters::parse
Packit d03632
{
Packit d03632
    my $self = shift ;
Packit d03632
Packit d03632
    my $default = shift ;
Packit d03632
Packit d03632
    my $got = $self->{Got} ;
Packit d03632
    my $firstTime = keys %{ $got } == 0 ;
Packit d03632
Packit d03632
    my (@Bad) ;
Packit d03632
    my @entered = () ;
Packit d03632
Packit d03632
    # Allow the options to be passed as a hash reference or
Packit d03632
    # as the complete hash.
Packit d03632
    if (@_ == 0) {
Packit d03632
        @entered = () ;
Packit d03632
    }
Packit d03632
    elsif (@_ == 1) {
Packit d03632
        my $href = $_[0] ;    
Packit d03632
        return $self->setError("Expected even number of parameters, got 1")
Packit d03632
            if ! defined $href or ! ref $href or ref $href ne "HASH" ;
Packit d03632
 
Packit d03632
        foreach my $key (keys %$href) {
Packit d03632
            push @entered, $key ;
Packit d03632
            push @entered, \$href->{$key} ;
Packit d03632
        }
Packit d03632
    }
Packit d03632
    else {
Packit d03632
        my $count = @_;
Packit d03632
        return $self->setError("Expected even number of parameters, got $count")
Packit d03632
            if $count % 2 != 0 ;
Packit d03632
        
Packit d03632
        for my $i (0.. $count / 2 - 1) {
Packit d03632
            push @entered, $_[2* $i] ;
Packit d03632
            push @entered, \$_[2* $i+1] ;
Packit d03632
        }
Packit d03632
    }
Packit d03632
Packit d03632
Packit d03632
    while (my ($key, $v) = each %$default)
Packit d03632
    {
Packit d03632
        croak "need 4 params [@$v]"
Packit d03632
            if @$v != 4 ;
Packit d03632
Packit d03632
        my ($first_only, $sticky, $type, $value) = @$v ;
Packit d03632
        my $x ;
Packit d03632
        $self->_checkType($key, \$value, $type, 0, \$x) 
Packit d03632
            or return undef ;
Packit d03632
Packit d03632
        $key = lc $key;
Packit d03632
Packit d03632
        if ($firstTime || ! $sticky) {
Packit d03632
            $got->{$key} = [0, $type, $value, $x, $first_only, $sticky] ;
Packit d03632
        }
Packit d03632
Packit d03632
        $got->{$key}[OFF_PARSED] = 0 ;
Packit d03632
    }
Packit d03632
Packit d03632
    for my $i (0.. @entered / 2 - 1) {
Packit d03632
        my $key = $entered[2* $i] ;
Packit d03632
        my $value = $entered[2* $i+1] ;
Packit d03632
Packit d03632
        #print "Key [$key] Value [$value]" ;
Packit d03632
        #print defined $$value ? "[$$value]\n" : "[undef]\n";
Packit d03632
Packit d03632
        $key =~ s/^-// ;
Packit d03632
        my $canonkey = lc $key;
Packit d03632
 
Packit d03632
        if ($got->{$canonkey} && ($firstTime ||
Packit d03632
                                  ! $got->{$canonkey}[OFF_FIRST_ONLY]  ))
Packit d03632
        {
Packit d03632
            my $type = $got->{$canonkey}[OFF_TYPE] ;
Packit d03632
            my $s ;
Packit d03632
            $self->_checkType($key, $value, $type, 1, \$s)
Packit d03632
                or return undef ;
Packit d03632
            #$value = $$value unless $type & Parse_store_ref ;
Packit d03632
            $value = $$value ;
Packit d03632
            $got->{$canonkey} = [1, $type, $value, $s] ;
Packit d03632
        }
Packit d03632
        else
Packit d03632
          { push (@Bad, $key) }
Packit d03632
    }
Packit d03632
 
Packit d03632
    if (@Bad) {
Packit d03632
        my ($bad) = join(", ", @Bad) ;
Packit d03632
        return $self->setError("unknown key value(s) @Bad") ;
Packit d03632
    }
Packit d03632
Packit d03632
    return 1;
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::Parameters::_checkType
Packit d03632
{
Packit d03632
    my $self = shift ;
Packit d03632
Packit d03632
    my $key   = shift ;
Packit d03632
    my $value = shift ;
Packit d03632
    my $type  = shift ;
Packit d03632
    my $validate  = shift ;
Packit d03632
    my $output  = shift;
Packit d03632
Packit d03632
    #local $Carp::CarpLevel = $level ;
Packit d03632
    #print "PARSE $type $key $value $validate $sub\n" ;
Packit d03632
#    if ( $type & Parse_store_ref)
Packit d03632
#    {
Packit d03632
#        #$value = $$value
Packit d03632
#        #    if ref ${ $value } ;
Packit d03632
#
Packit d03632
#        $$output = $value ;
Packit d03632
#        return 1;
Packit d03632
#    }
Packit d03632
Packit d03632
    $value = $$value ;
Packit d03632
Packit d03632
    if ($type & Parse_any)
Packit d03632
    {
Packit d03632
        $$output = $value ;
Packit d03632
        return 1;
Packit d03632
    }
Packit d03632
    elsif ($type & Parse_unsigned)
Packit d03632
    {
Packit d03632
        return $self->setError("Parameter '$key' must be an unsigned int, got 'undef'")
Packit d03632
            if $validate && ! defined $value ;
Packit d03632
        return $self->setError("Parameter '$key' must be an unsigned int, got '$value'")
Packit d03632
            if $validate && $value !~ /^\d+$/;
Packit d03632
Packit d03632
        $$output = defined $value ? $value : 0 ;    
Packit d03632
        return 1;
Packit d03632
    }
Packit d03632
    elsif ($type & Parse_signed)
Packit d03632
    {
Packit d03632
        return $self->setError("Parameter '$key' must be a signed int, got 'undef'")
Packit d03632
            if $validate && ! defined $value ;
Packit d03632
        return $self->setError("Parameter '$key' must be a signed int, got '$value'")
Packit d03632
            if $validate && $value !~ /^-?\d+$/;
Packit d03632
Packit d03632
        $$output = defined $value ? $value : 0 ;    
Packit d03632
        return 1 ;
Packit d03632
    }
Packit d03632
    elsif ($type & Parse_boolean)
Packit d03632
    {
Packit d03632
        return $self->setError("Parameter '$key' must be an int, got '$value'")
Packit d03632
            if $validate && defined $value && $value !~ /^\d*$/;
Packit d03632
        $$output =  defined $value ? $value != 0 : 0 ;    
Packit d03632
        return 1;
Packit d03632
    }
Packit d03632
#    elsif ($type & Parse_string)
Packit d03632
#    {
Packit d03632
#        $$output = defined $value ? $value : "" ;    
Packit d03632
#        return 1;
Packit d03632
#    }
Packit d03632
Packit d03632
    $$output = $value ;
Packit d03632
    return 1;
Packit d03632
}
Packit d03632
Packit d03632
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::Parameters::parsed
Packit d03632
{
Packit d03632
    my $self = shift ;
Packit d03632
    my $name = shift ;
Packit d03632
Packit d03632
    return $self->{Got}{lc $name}[OFF_PARSED] ;
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::Parameters::value
Packit d03632
{
Packit d03632
    my $self = shift ;
Packit d03632
    my $name = shift ;
Packit d03632
Packit d03632
    if (@_)
Packit d03632
    {
Packit d03632
        $self->{Got}{lc $name}[OFF_PARSED]  = 1;
Packit d03632
        $self->{Got}{lc $name}[OFF_DEFAULT] = $_[0] ;
Packit d03632
        $self->{Got}{lc $name}[OFF_FIXED]   = $_[0] ;
Packit d03632
    }
Packit d03632
Packit d03632
    return $self->{Got}{lc $name}[OFF_FIXED] ;
Packit d03632
}
Packit d03632
Packit d03632
our $OPTIONS_deflate =   
Packit d03632
    {
Packit d03632
        'AppendOutput'  => [1, 1, Parse_boolean,  0],
Packit d03632
        'CRC32'         => [1, 1, Parse_boolean,  0],
Packit d03632
        'ADLER32'       => [1, 1, Parse_boolean,  0],
Packit d03632
        'Bufsize'       => [1, 1, Parse_unsigned, 4096],
Packit d03632
Packit d03632
        'Level'         => [1, 1, Parse_signed,   Z_DEFAULT_COMPRESSION()],
Packit d03632
        'Method'        => [1, 1, Parse_unsigned, Z_DEFLATED()],
Packit d03632
        'WindowBits'    => [1, 1, Parse_signed,   MAX_WBITS()],
Packit d03632
        'MemLevel'      => [1, 1, Parse_unsigned, MAX_MEM_LEVEL()],
Packit d03632
        'Strategy'      => [1, 1, Parse_unsigned, Z_DEFAULT_STRATEGY()],
Packit d03632
        'Dictionary'    => [1, 1, Parse_any,      ""],
Packit d03632
    };
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::Deflate::new
Packit d03632
{
Packit d03632
    my $pkg = shift ;
Packit d03632
    my ($got) = ParseParameters(0, $OPTIONS_deflate, @_);
Packit d03632
Packit d03632
    croak "Compress::Raw::Zlib::Deflate::new: Bufsize must be >= 1, you specified " . 
Packit d03632
            $got->value('Bufsize')
Packit d03632
        unless $got->value('Bufsize') >= 1;
Packit d03632
Packit d03632
    my $flags = 0 ;
Packit d03632
    $flags |= FLAG_APPEND if $got->value('AppendOutput') ;
Packit d03632
    $flags |= FLAG_CRC    if $got->value('CRC32') ;
Packit d03632
    $flags |= FLAG_ADLER  if $got->value('ADLER32') ;
Packit d03632
Packit d03632
    my $windowBits =  $got->value('WindowBits');
Packit d03632
    $windowBits += MAX_WBITS()
Packit d03632
        if ($windowBits & MAX_WBITS()) == 0 ;
Packit d03632
Packit d03632
    _deflateInit($flags,
Packit d03632
                $got->value('Level'), 
Packit d03632
                $got->value('Method'), 
Packit d03632
                $windowBits, 
Packit d03632
                $got->value('MemLevel'), 
Packit d03632
                $got->value('Strategy'), 
Packit d03632
                $got->value('Bufsize'),
Packit d03632
                $got->value('Dictionary')) ;
Packit d03632
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::deflateStream::STORABLE_freeze
Packit d03632
{
Packit d03632
    my $type = ref shift;
Packit d03632
    croak "Cannot freeze $type object\n";
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::deflateStream::STORABLE_thaw
Packit d03632
{
Packit d03632
    my $type = ref shift;
Packit d03632
    croak "Cannot thaw $type object\n";
Packit d03632
}
Packit d03632
Packit d03632
Packit d03632
our $OPTIONS_inflate = 
Packit d03632
    {
Packit d03632
        'AppendOutput'  => [1, 1, Parse_boolean,  0],
Packit d03632
        'LimitOutput'   => [1, 1, Parse_boolean,  0],
Packit d03632
        'CRC32'         => [1, 1, Parse_boolean,  0],
Packit d03632
        'ADLER32'       => [1, 1, Parse_boolean,  0],
Packit d03632
        'ConsumeInput'  => [1, 1, Parse_boolean,  1],
Packit d03632
        'Bufsize'       => [1, 1, Parse_unsigned, 4096],
Packit d03632
 
Packit d03632
        'WindowBits'    => [1, 1, Parse_signed,   MAX_WBITS()],
Packit d03632
        'Dictionary'    => [1, 1, Parse_any,      ""],
Packit d03632
    } ;
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::Inflate::new
Packit d03632
{
Packit d03632
    my $pkg = shift ;
Packit d03632
    my ($got) = ParseParameters(0, $OPTIONS_inflate, @_);
Packit d03632
Packit d03632
    croak "Compress::Raw::Zlib::Inflate::new: Bufsize must be >= 1, you specified " . 
Packit d03632
            $got->value('Bufsize')
Packit d03632
        unless $got->value('Bufsize') >= 1;
Packit d03632
Packit d03632
    my $flags = 0 ;
Packit d03632
    $flags |= FLAG_APPEND if $got->value('AppendOutput') ;
Packit d03632
    $flags |= FLAG_CRC    if $got->value('CRC32') ;
Packit d03632
    $flags |= FLAG_ADLER  if $got->value('ADLER32') ;
Packit d03632
    $flags |= FLAG_CONSUME_INPUT if $got->value('ConsumeInput') ;
Packit d03632
    $flags |= FLAG_LIMIT_OUTPUT if $got->value('LimitOutput') ;
Packit d03632
Packit d03632
Packit d03632
    my $windowBits =  $got->value('WindowBits');
Packit d03632
    $windowBits += MAX_WBITS()
Packit d03632
        if ($windowBits & MAX_WBITS()) == 0 ;
Packit d03632
Packit d03632
    _inflateInit($flags, $windowBits, $got->value('Bufsize'), 
Packit d03632
                 $got->value('Dictionary')) ;
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::inflateStream::STORABLE_freeze
Packit d03632
{
Packit d03632
    my $type = ref shift;
Packit d03632
    croak "Cannot freeze $type object\n";
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::inflateStream::STORABLE_thaw
Packit d03632
{
Packit d03632
    my $type = ref shift;
Packit d03632
    croak "Cannot thaw $type object\n";
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::InflateScan::new
Packit d03632
{
Packit d03632
    my $pkg = shift ;
Packit d03632
    my ($got) = ParseParameters(0,
Packit d03632
                    {
Packit d03632
                        'CRC32'         => [1, 1, Parse_boolean,  0],
Packit d03632
                        'ADLER32'       => [1, 1, Parse_boolean,  0],
Packit d03632
                        'Bufsize'       => [1, 1, Parse_unsigned, 4096],
Packit d03632
                 
Packit d03632
                        'WindowBits'    => [1, 1, Parse_signed,   -MAX_WBITS()],
Packit d03632
                        'Dictionary'    => [1, 1, Parse_any,      ""],
Packit d03632
            }, @_) ;
Packit d03632
Packit d03632
Packit d03632
    croak "Compress::Raw::Zlib::InflateScan::new: Bufsize must be >= 1, you specified " . 
Packit d03632
            $got->value('Bufsize')
Packit d03632
        unless $got->value('Bufsize') >= 1;
Packit d03632
Packit d03632
    my $flags = 0 ;
Packit d03632
    #$flags |= FLAG_APPEND if $got->value('AppendOutput') ;
Packit d03632
    $flags |= FLAG_CRC    if $got->value('CRC32') ;
Packit d03632
    $flags |= FLAG_ADLER  if $got->value('ADLER32') ;
Packit d03632
    #$flags |= FLAG_CONSUME_INPUT if $got->value('ConsumeInput') ;
Packit d03632
Packit d03632
    _inflateScanInit($flags, $got->value('WindowBits'), $got->value('Bufsize'), 
Packit d03632
                 '') ;
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::inflateScanStream::createDeflateStream
Packit d03632
{
Packit d03632
    my $pkg = shift ;
Packit d03632
    my ($got) = ParseParameters(0,
Packit d03632
            {
Packit d03632
                'AppendOutput'  => [1, 1, Parse_boolean,  0],
Packit d03632
                'CRC32'         => [1, 1, Parse_boolean,  0],
Packit d03632
                'ADLER32'       => [1, 1, Parse_boolean,  0],
Packit d03632
                'Bufsize'       => [1, 1, Parse_unsigned, 4096],
Packit d03632
 
Packit d03632
                'Level'         => [1, 1, Parse_signed,   Z_DEFAULT_COMPRESSION()],
Packit d03632
                'Method'        => [1, 1, Parse_unsigned, Z_DEFLATED()],
Packit d03632
                'WindowBits'    => [1, 1, Parse_signed,   - MAX_WBITS()],
Packit d03632
                'MemLevel'      => [1, 1, Parse_unsigned, MAX_MEM_LEVEL()],
Packit d03632
                'Strategy'      => [1, 1, Parse_unsigned, Z_DEFAULT_STRATEGY()],
Packit d03632
            }, @_) ;
Packit d03632
Packit d03632
    croak "Compress::Raw::Zlib::InflateScan::createDeflateStream: Bufsize must be >= 1, you specified " . 
Packit d03632
            $got->value('Bufsize')
Packit d03632
        unless $got->value('Bufsize') >= 1;
Packit d03632
Packit d03632
    my $flags = 0 ;
Packit d03632
    $flags |= FLAG_APPEND if $got->value('AppendOutput') ;
Packit d03632
    $flags |= FLAG_CRC    if $got->value('CRC32') ;
Packit d03632
    $flags |= FLAG_ADLER  if $got->value('ADLER32') ;
Packit d03632
Packit d03632
    $pkg->_createDeflateStream($flags,
Packit d03632
                $got->value('Level'), 
Packit d03632
                $got->value('Method'), 
Packit d03632
                $got->value('WindowBits'), 
Packit d03632
                $got->value('MemLevel'), 
Packit d03632
                $got->value('Strategy'), 
Packit d03632
                $got->value('Bufsize'),
Packit d03632
                ) ;
Packit d03632
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::inflateScanStream::inflate
Packit d03632
{
Packit d03632
    my $self = shift ;
Packit d03632
    my $buffer = $_[1];
Packit d03632
    my $eof = $_[2];
Packit d03632
Packit d03632
    my $status = $self->scan(@_);
Packit d03632
Packit d03632
    if ($status == Z_OK() && $_[2]) {
Packit d03632
        my $byte = ' ';
Packit d03632
        
Packit d03632
        $status = $self->scan(\$byte, $_[1]) ;
Packit d03632
    }
Packit d03632
    
Packit d03632
    return $status ;
Packit d03632
}
Packit d03632
Packit d03632
sub Compress::Raw::Zlib::deflateStream::deflateParams
Packit d03632
{
Packit d03632
    my $self = shift ;
Packit d03632
    my ($got) = ParseParameters(0, {
Packit d03632
                'Level'      => [1, 1, Parse_signed,   undef],
Packit d03632
                'Strategy'   => [1, 1, Parse_unsigned, undef],
Packit d03632
                'Bufsize'    => [1, 1, Parse_unsigned, undef],
Packit d03632
                }, 
Packit d03632
                @_) ;
Packit d03632
Packit d03632
    croak "Compress::Raw::Zlib::deflateParams needs Level and/or Strategy"
Packit d03632
        unless $got->parsed('Level') + $got->parsed('Strategy') +
Packit d03632
            $got->parsed('Bufsize');
Packit d03632
Packit d03632
    croak "Compress::Raw::Zlib::Inflate::deflateParams: Bufsize must be >= 1, you specified " . 
Packit d03632
            $got->value('Bufsize')
Packit d03632
        if $got->parsed('Bufsize') && $got->value('Bufsize') <= 1;
Packit d03632
Packit d03632
    my $flags = 0;
Packit d03632
    $flags |= 1 if $got->parsed('Level') ;
Packit d03632
    $flags |= 2 if $got->parsed('Strategy') ;
Packit d03632
    $flags |= 4 if $got->parsed('Bufsize') ;
Packit d03632
Packit d03632
    $self->_deflateParams($flags, $got->value('Level'), 
Packit d03632
                          $got->value('Strategy'), $got->value('Bufsize'));
Packit d03632
Packit d03632
}
Packit d03632
Packit d03632
Packit d03632
1;
Packit d03632
__END__
Packit d03632
Packit d03632
Packit d03632
=head1 NAME
Packit d03632
Packit d03632
Compress::Raw::Zlib - Low-Level Interface to zlib compression library
Packit d03632
Packit d03632
=head1 SYNOPSIS
Packit d03632
Packit d03632
    use Compress::Raw::Zlib ;
Packit d03632
Packit d03632
    ($d, $status) = new Compress::Raw::Zlib::Deflate( [OPT] ) ;
Packit d03632
    $status = $d->deflate($input, $output) ;
Packit d03632
    $status = $d->flush($output [, $flush_type]) ;
Packit d03632
    $d->deflateReset() ;
Packit d03632
    $d->deflateParams(OPTS) ;
Packit d03632
    $d->deflateTune(OPTS) ;
Packit d03632
    $d->dict_adler() ;
Packit d03632
    $d->crc32() ;
Packit d03632
    $d->adler32() ;
Packit d03632
    $d->total_in() ;
Packit d03632
    $d->total_out() ;
Packit d03632
    $d->msg() ;
Packit d03632
    $d->get_Strategy();
Packit d03632
    $d->get_Level();
Packit d03632
    $d->get_BufSize();
Packit d03632
Packit d03632
    ($i, $status) = new Compress::Raw::Zlib::Inflate( [OPT] ) ;
Packit d03632
    $status = $i->inflate($input, $output [, $eof]) ;
Packit d03632
    $status = $i->inflateSync($input) ;
Packit d03632
    $i->inflateReset() ;
Packit d03632
    $i->dict_adler() ;
Packit d03632
    $d->crc32() ;
Packit d03632
    $d->adler32() ;
Packit d03632
    $i->total_in() ;
Packit d03632
    $i->total_out() ;
Packit d03632
    $i->msg() ;
Packit d03632
    $d->get_BufSize();
Packit d03632
Packit d03632
    $crc = adler32($buffer [,$crc]) ;
Packit d03632
    $crc = crc32($buffer [,$crc]) ;
Packit d03632
Packit d03632
    $crc = crc32_combine($crc1, $crc2, $len2);
Packit d03632
    $adler = adler32_combine($adler1, $adler2, $len2);
Packit d03632
Packit d03632
    my $version = Compress::Raw::Zlib::zlib_version();
Packit d03632
    my $flags = Compress::Raw::Zlib::zlibCompileFlags();
Packit d03632
Packit d03632
=head1 DESCRIPTION
Packit d03632
Packit d03632
The I<Compress::Raw::Zlib> module provides a Perl interface to the I<zlib>
Packit d03632
compression library (see L</AUTHOR> for details about where to get
Packit d03632
I<zlib>).
Packit d03632
Packit d03632
=head1 Compress::Raw::Zlib::Deflate
Packit d03632
Packit d03632
This section defines an interface that allows in-memory compression using
Packit d03632
the I<deflate> interface provided by zlib.
Packit d03632
Packit d03632
Here is a definition of the interface available:
Packit d03632
Packit d03632
=head2 B<($d, $status) = new Compress::Raw::Zlib::Deflate( [OPT] ) >
Packit d03632
Packit d03632
Initialises a deflation object.
Packit d03632
Packit d03632
If you are familiar with the I<zlib> library, it combines the
Packit d03632
features of the I<zlib> functions C<deflateInit>, C<deflateInit2>
Packit d03632
and C<deflateSetDictionary>.
Packit d03632
Packit d03632
If successful, it will return the initialised deflation object, C<$d>
Packit d03632
and a C<$status> of C<Z_OK> in a list context. In scalar context it
Packit d03632
returns the deflation object, C<$d>, only.
Packit d03632
Packit d03632
If not successful, the returned deflation object, C<$d>, will be
Packit d03632
I<undef> and C<$status> will hold the a I<zlib> error code.
Packit d03632
Packit d03632
The function optionally takes a number of named options specified as
Packit d03632
C<< Name => value >> pairs. This allows individual options to be
Packit d03632
tailored without having to specify them all in the parameter list.
Packit d03632
Packit d03632
For backward compatibility, it is also possible to pass the parameters
Packit d03632
as a reference to a hash containing the name=>value pairs.
Packit d03632
Packit d03632
Below is a list of the valid options:
Packit d03632
Packit d03632
=over 5
Packit d03632
Packit d03632
=item B<-Level>
Packit d03632
Packit d03632
Defines the compression level. Valid values are 0 through 9,
Packit d03632
C<Z_NO_COMPRESSION>, C<Z_BEST_SPEED>, C<Z_BEST_COMPRESSION>, and
Packit d03632
C<Z_DEFAULT_COMPRESSION>.
Packit d03632
Packit d03632
The default is C<Z_DEFAULT_COMPRESSION>.
Packit d03632
Packit d03632
=item B<-Method>
Packit d03632
Packit d03632
Defines the compression method. The only valid value at present (and
Packit d03632
the default) is C<Z_DEFLATED>.
Packit d03632
Packit d03632
=item B<-WindowBits>
Packit d03632
Packit d03632
To compress an RFC 1950 data stream, set C<WindowBits> to a positive
Packit d03632
number between 8 and 15.
Packit d03632
Packit d03632
To compress an RFC 1951 data stream, set C<WindowBits> to C<-MAX_WBITS>.
Packit d03632
Packit d03632
To compress an RFC 1952 data stream (i.e. gzip), set C<WindowBits> to
Packit d03632
C<WANT_GZIP>.
Packit d03632
Packit d03632
For a definition of the meaning and valid values for C<WindowBits>
Packit d03632
refer to the I<zlib> documentation for I<deflateInit2>.
Packit d03632
Packit d03632
Defaults to C<MAX_WBITS>.
Packit d03632
Packit d03632
=item B<-MemLevel>
Packit d03632
Packit d03632
For a definition of the meaning and valid values for C<MemLevel>
Packit d03632
refer to the I<zlib> documentation for I<deflateInit2>.
Packit d03632
Packit d03632
Defaults to MAX_MEM_LEVEL.
Packit d03632
Packit d03632
=item B<-Strategy>
Packit d03632
Packit d03632
Defines the strategy used to tune the compression. The valid values are
Packit d03632
C<Z_DEFAULT_STRATEGY>, C<Z_FILTERED>, C<Z_RLE>, C<Z_FIXED> and
Packit d03632
C<Z_HUFFMAN_ONLY>.
Packit d03632
Packit d03632
The default is C<Z_DEFAULT_STRATEGY>.
Packit d03632
Packit d03632
=item B<-Dictionary>
Packit d03632
Packit d03632
When a dictionary is specified I<Compress::Raw::Zlib> will automatically
Packit d03632
call C<deflateSetDictionary> directly after calling C<deflateInit>. The
Packit d03632
Adler32 value for the dictionary can be obtained by calling the method
Packit d03632
C<$d-E<gt>dict_adler()>.
Packit d03632
Packit d03632
The default is no dictionary.
Packit d03632
Packit d03632
=item B<-Bufsize>
Packit d03632
Packit d03632
Sets the initial size for the output buffer used by the C<$d-E<gt>deflate>
Packit d03632
and C<$d-E<gt>flush> methods. If the buffer has to be
Packit d03632
reallocated to increase the size, it will grow in increments of
Packit d03632
C<Bufsize>.
Packit d03632
Packit d03632
The default buffer size is 4096.
Packit d03632
Packit d03632
=item B<-AppendOutput>
Packit d03632
Packit d03632
This option controls how data is written to the output buffer by the
Packit d03632
C<$d-E<gt>deflate> and C<$d-E<gt>flush> methods.
Packit d03632
Packit d03632
If the C<AppendOutput> option is set to false, the output buffers in the
Packit d03632
C<$d-E<gt>deflate> and C<$d-E<gt>flush>  methods will be truncated before
Packit d03632
uncompressed data is written to them.
Packit d03632
Packit d03632
If the option is set to true, uncompressed data will be appended to the
Packit d03632
output buffer in the C<$d-E<gt>deflate> and C<$d-E<gt>flush> methods.
Packit d03632
Packit d03632
This option defaults to false.
Packit d03632
Packit d03632
=item B<-CRC32>
Packit d03632
Packit d03632
If set to true, a crc32 checksum of the uncompressed data will be
Packit d03632
calculated. Use the C<$d-E<gt>crc32> method to retrieve this value.
Packit d03632
Packit d03632
This option defaults to false.
Packit d03632
Packit d03632
=item B<-ADLER32>
Packit d03632
Packit d03632
If set to true, an adler32 checksum of the uncompressed data will be
Packit d03632
calculated. Use the C<$d-E<gt>adler32> method to retrieve this value.
Packit d03632
Packit d03632
This option defaults to false.
Packit d03632
Packit d03632
=back
Packit d03632
Packit d03632
Here is an example of using the C<Compress::Raw::Zlib::Deflate> optional
Packit d03632
parameter list to override the default buffer size and compression
Packit d03632
level. All other options will take their default values.
Packit d03632
Packit d03632
    my $d = new Compress::Raw::Zlib::Deflate ( -Bufsize => 300,
Packit d03632
                                               -Level   => Z_BEST_SPEED ) ;
Packit d03632
Packit d03632
=head2 B<$status = $d-E<gt>deflate($input, $output)>
Packit d03632
Packit d03632
Deflates the contents of C<$input> and writes the compressed data to
Packit d03632
C<$output>.
Packit d03632
Packit d03632
The C<$input> and C<$output> parameters can be either scalars or scalar
Packit d03632
references.
Packit d03632
Packit d03632
When finished, C<$input> will be completely processed (assuming there
Packit d03632
were no errors). If the deflation was successful it writes the deflated
Packit d03632
data to C<$output> and returns a status value of C<Z_OK>.
Packit d03632
Packit d03632
On error, it returns a I<zlib> error code.
Packit d03632
Packit d03632
If the C<AppendOutput> option is set to true in the constructor for
Packit d03632
the C<$d> object, the compressed data will be appended to C<$output>. If
Packit d03632
it is false, C<$output> will be truncated before any compressed data is
Packit d03632
written to it.
Packit d03632
Packit d03632
B<Note>: This method will not necessarily write compressed data to
Packit d03632
C<$output> every time it is called. So do not assume that there has been
Packit d03632
an error if the contents of C<$output> is empty on returning from
Packit d03632
this method. As long as the return code from the method is C<Z_OK>,
Packit d03632
the deflate has succeeded.
Packit d03632
Packit d03632
=head2 B<$status = $d-E<gt>flush($output [, $flush_type]) >
Packit d03632
Packit d03632
Typically used to finish the deflation. Any pending output will be
Packit d03632
written to C<$output>.
Packit d03632
Packit d03632
Returns C<Z_OK> if successful.
Packit d03632
Packit d03632
Note that flushing can seriously degrade the compression ratio, so it
Packit d03632
should only be used to terminate a decompression (using C<Z_FINISH>) or
Packit d03632
when you want to create a I<full flush point> (using C<Z_FULL_FLUSH>).
Packit d03632
Packit d03632
By default the C<flush_type> used is C<Z_FINISH>. Other valid values
Packit d03632
for C<flush_type> are C<Z_NO_FLUSH>, C<Z_PARTIAL_FLUSH>, C<Z_SYNC_FLUSH>
Packit d03632
and C<Z_FULL_FLUSH>. It is strongly recommended that you only set the
Packit d03632
C<flush_type> parameter if you fully understand the implications of
Packit d03632
what it does. See the C<zlib> documentation for details.
Packit d03632
Packit d03632
If the C<AppendOutput> option is set to true in the constructor for
Packit d03632
the C<$d> object, the compressed data will be appended to C<$output>. If
Packit d03632
it is false, C<$output> will be truncated before any compressed data is
Packit d03632
written to it.
Packit d03632
Packit d03632
=head2 B<$status = $d-E<gt>deflateReset() >
Packit d03632
Packit d03632
This method will reset the deflation object C<$d>. It can be used when you
Packit d03632
are compressing multiple data streams and want to use the same object to
Packit d03632
compress each of them. It should only be used once the previous data stream
Packit d03632
has been flushed successfully, i.e. a call to C<< $d->flush(Z_FINISH) >> has
Packit d03632
returned C<Z_OK>.
Packit d03632
Packit d03632
Returns C<Z_OK> if successful.
Packit d03632
Packit d03632
=head2 B<$status = $d-E<gt>deflateParams([OPT])>
Packit d03632
Packit d03632
Change settings for the deflate object C<$d>.
Packit d03632
Packit d03632
The list of the valid options is shown below. Options not specified
Packit d03632
will remain unchanged.
Packit d03632
Packit d03632
=over 5
Packit d03632
Packit d03632
=item B<-Level>
Packit d03632
Packit d03632
Defines the compression level. Valid values are 0 through 9,
Packit d03632
C<Z_NO_COMPRESSION>, C<Z_BEST_SPEED>, C<Z_BEST_COMPRESSION>, and
Packit d03632
C<Z_DEFAULT_COMPRESSION>.
Packit d03632
Packit d03632
=item B<-Strategy>
Packit d03632
Packit d03632
Defines the strategy used to tune the compression. The valid values are
Packit d03632
C<Z_DEFAULT_STRATEGY>, C<Z_FILTERED> and C<Z_HUFFMAN_ONLY>.
Packit d03632
Packit d03632
=item B<-BufSize>
Packit d03632
Packit d03632
Sets the initial size for the output buffer used by the C<$d-E<gt>deflate>
Packit d03632
and C<$d-E<gt>flush> methods. If the buffer has to be
Packit d03632
reallocated to increase the size, it will grow in increments of
Packit d03632
C<Bufsize>.
Packit d03632
Packit d03632
=back
Packit d03632
Packit d03632
=head2 B<$status = $d-E<gt>deflateTune($good_length, $max_lazy, $nice_length, $max_chain)>
Packit d03632
Packit d03632
Tune the internal settings for the deflate object C<$d>. This option is
Packit d03632
only available if you are running zlib 1.2.2.3 or better.
Packit d03632
Packit d03632
Refer to the documentation in zlib.h for instructions on how to fly
Packit d03632
C<deflateTune>.
Packit d03632
Packit d03632
=head2 B<$d-E<gt>dict_adler()>
Packit d03632
Packit d03632
Returns the adler32 value for the dictionary.
Packit d03632
Packit d03632
=head2 B<$d-E<gt>crc32()>
Packit d03632
Packit d03632
Returns the crc32 value for the uncompressed data to date.
Packit d03632
Packit d03632
If the C<CRC32> option is not enabled in the constructor for this object,
Packit d03632
this method will always return 0;
Packit d03632
Packit d03632
=head2 B<$d-E<gt>adler32()>
Packit d03632
Packit d03632
Returns the adler32 value for the uncompressed data to date.
Packit d03632
Packit d03632
=head2 B<$d-E<gt>msg()>
Packit d03632
Packit d03632
Returns the last error message generated by zlib.
Packit d03632
Packit d03632
=head2 B<$d-E<gt>total_in()>
Packit d03632
Packit d03632
Returns the total number of bytes uncompressed bytes input to deflate.
Packit d03632
Packit d03632
=head2 B<$d-E<gt>total_out()>
Packit d03632
Packit d03632
Returns the total number of compressed bytes output from deflate.
Packit d03632
Packit d03632
=head2 B<$d-E<gt>get_Strategy()>
Packit d03632
Packit d03632
Returns the deflation strategy currently used. Valid values are
Packit d03632
C<Z_DEFAULT_STRATEGY>, C<Z_FILTERED> and C<Z_HUFFMAN_ONLY>.
Packit d03632
Packit d03632
=head2 B<$d-E<gt>get_Level()>
Packit d03632
Packit d03632
Returns the compression level being used.
Packit d03632
Packit d03632
=head2 B<$d-E<gt>get_BufSize()>
Packit d03632
Packit d03632
Returns the buffer size used to carry out the compression.
Packit d03632
Packit d03632
=head2 Example
Packit d03632
Packit d03632
Here is a trivial example of using C<deflate>. It simply reads standard
Packit d03632
input, deflates it and writes it to standard output.
Packit d03632
Packit d03632
    use strict ;
Packit d03632
    use warnings ;
Packit d03632
Packit d03632
    use Compress::Raw::Zlib ;
Packit d03632
Packit d03632
    binmode STDIN;
Packit d03632
    binmode STDOUT;
Packit d03632
    my $x = new Compress::Raw::Zlib::Deflate
Packit d03632
       or die "Cannot create a deflation stream\n" ;
Packit d03632
Packit d03632
    my ($output, $status) ;
Packit d03632
    while (<>)
Packit d03632
    {
Packit d03632
        $status = $x->deflate($_, $output) ;
Packit d03632
    
Packit d03632
        $status == Z_OK
Packit d03632
            or die "deflation failed\n" ;
Packit d03632
    
Packit d03632
        print $output ;
Packit d03632
    }
Packit d03632
    
Packit d03632
    $status = $x->flush($output) ;
Packit d03632
    
Packit d03632
    $status == Z_OK
Packit d03632
        or die "deflation failed\n" ;
Packit d03632
    
Packit d03632
    print $output ;
Packit d03632
Packit d03632
=head1 Compress::Raw::Zlib::Inflate
Packit d03632
Packit d03632
This section defines an interface that allows in-memory uncompression using
Packit d03632
the I<inflate> interface provided by zlib.
Packit d03632
Packit d03632
Here is a definition of the interface:
Packit d03632
Packit d03632
=head2 B< ($i, $status) = new Compress::Raw::Zlib::Inflate( [OPT] ) >
Packit d03632
Packit d03632
Initialises an inflation object.
Packit d03632
Packit d03632
In a list context it returns the inflation object, C<$i>, and the
Packit d03632
I<zlib> status code (C<$status>). In a scalar context it returns the
Packit d03632
inflation object only.
Packit d03632
Packit d03632
If successful, C<$i> will hold the inflation object and C<$status> will
Packit d03632
be C<Z_OK>.
Packit d03632
Packit d03632
If not successful, C<$i> will be I<undef> and C<$status> will hold the
Packit d03632
I<zlib> error code.
Packit d03632
Packit d03632
The function optionally takes a number of named options specified as
Packit d03632
C<< -Name => value >> pairs. This allows individual options to be
Packit d03632
tailored without having to specify them all in the parameter list.
Packit d03632
Packit d03632
For backward compatibility, it is also possible to pass the parameters
Packit d03632
as a reference to a hash containing the C<< name=>value >> pairs.
Packit d03632
Packit d03632
Here is a list of the valid options:
Packit d03632
Packit d03632
=over 5
Packit d03632
Packit d03632
=item B<-WindowBits>
Packit d03632
Packit d03632
To uncompress an RFC 1950 data stream, set C<WindowBits> to a positive
Packit d03632
number between 8 and 15.
Packit d03632
Packit d03632
To uncompress an RFC 1951 data stream, set C<WindowBits> to C<-MAX_WBITS>.
Packit d03632
Packit d03632
To uncompress an RFC 1952 data stream (i.e. gzip), set C<WindowBits> to
Packit d03632
C<WANT_GZIP>.
Packit d03632
Packit d03632
To auto-detect and uncompress an RFC 1950 or RFC 1952 data stream (i.e.
Packit d03632
gzip), set C<WindowBits> to C<WANT_GZIP_OR_ZLIB>.
Packit d03632
Packit d03632
For a full definition of the meaning and valid values for C<WindowBits>
Packit d03632
refer to the I<zlib> documentation for I<inflateInit2>.
Packit d03632
Packit d03632
Defaults to C<MAX_WBITS>.
Packit d03632
Packit d03632
=item B<-Bufsize>
Packit d03632
Packit d03632
Sets the initial size for the output buffer used by the C<$i-E<gt>inflate>
Packit d03632
method. If the output buffer in this method has to be reallocated to
Packit d03632
increase the size, it will grow in increments of C<Bufsize>.
Packit d03632
Packit d03632
Default is 4096.
Packit d03632
Packit d03632
=item B<-Dictionary>
Packit d03632
Packit d03632
The default is no dictionary.
Packit d03632
Packit d03632
=item B<-AppendOutput>
Packit d03632
Packit d03632
This option controls how data is written to the output buffer by the
Packit d03632
C<$i-E<gt>inflate> method.
Packit d03632
Packit d03632
If the option is set to false, the output buffer in the C<$i-E<gt>inflate>
Packit d03632
method will be truncated before uncompressed data is written to it.
Packit d03632
Packit d03632
If the option is set to true, uncompressed data will be appended to the
Packit d03632
output buffer by the C<$i-E<gt>inflate> method.
Packit d03632
Packit d03632
This option defaults to false.
Packit d03632
Packit d03632
=item B<-CRC32>
Packit d03632
Packit d03632
If set to true, a crc32 checksum of the uncompressed data will be
Packit d03632
calculated. Use the C<$i-E<gt>crc32> method to retrieve this value.
Packit d03632
Packit d03632
This option defaults to false.
Packit d03632
Packit d03632
=item B<-ADLER32>
Packit d03632
Packit d03632
If set to true, an adler32 checksum of the uncompressed data will be
Packit d03632
calculated. Use the C<$i-E<gt>adler32> method to retrieve this value.
Packit d03632
Packit d03632
This option defaults to false.
Packit d03632
Packit d03632
=item B<-ConsumeInput>
Packit d03632
Packit d03632
If set to true, this option will remove compressed data from the input
Packit d03632
buffer of the C<< $i->inflate >> method as the inflate progresses.
Packit d03632
Packit d03632
This option can be useful when you are processing compressed data that is
Packit d03632
embedded in another file/buffer. In this case the data that immediately
Packit d03632
follows the compressed stream will be left in the input buffer.
Packit d03632
Packit d03632
This option defaults to true.
Packit d03632
Packit d03632
=item B<-LimitOutput>
Packit d03632
Packit d03632
The C<LimitOutput> option changes the behavior of the C<< $i->inflate >>
Packit d03632
method so that the amount of memory used by the output buffer can be
Packit d03632
limited.
Packit d03632
Packit d03632
When C<LimitOutput> is used the size of the output buffer used will either
Packit d03632
be the value of the C<Bufsize> option or the amount of memory already
Packit d03632
allocated to C<$output>, whichever is larger. Predicting the output size
Packit d03632
available is tricky, so don't rely on getting an exact output buffer size.
Packit d03632
Packit d03632
When C<LimitOutout> is not specified C<< $i->inflate >> will use as much
Packit d03632
memory as it takes to write all the uncompressed data it creates by
Packit d03632
uncompressing the input buffer.
Packit d03632
Packit d03632
If C<LimitOutput> is enabled, the C<ConsumeInput> option will also be
Packit d03632
enabled.
Packit d03632
Packit d03632
This option defaults to false.
Packit d03632
Packit d03632
See L</The LimitOutput option> for a discussion on why C<LimitOutput> is
Packit d03632
needed and how to use it.
Packit d03632
Packit d03632
=back
Packit d03632
Packit d03632
Here is an example of using an optional parameter to override the default
Packit d03632
buffer size.
Packit d03632
Packit d03632
    my ($i, $status) = new Compress::Raw::Zlib::Inflate( -Bufsize => 300 ) ;
Packit d03632
Packit d03632
=head2 B< $status = $i-E<gt>inflate($input, $output [,$eof]) >
Packit d03632
Packit d03632
Inflates the complete contents of C<$input> and writes the uncompressed
Packit d03632
data to C<$output>. The C<$input> and C<$output> parameters can either be
Packit d03632
scalars or scalar references.
Packit d03632
Packit d03632
Returns C<Z_OK> if successful and C<Z_STREAM_END> if the end of the
Packit d03632
compressed data has been successfully reached.
Packit d03632
Packit d03632
If not successful C<$status> will hold the I<zlib> error code.
Packit d03632
Packit d03632
If the C<ConsumeInput> option has been set to true when the
Packit d03632
C<Compress::Raw::Zlib::Inflate> object is created, the C<$input> parameter
Packit d03632
is modified by C<inflate>. On completion it will contain what remains
Packit d03632
of the input buffer after inflation. In practice, this means that when
Packit d03632
the return status is C<Z_OK> the C<$input> parameter will contain an
Packit d03632
empty string, and when the return status is C<Z_STREAM_END> the C<$input>
Packit d03632
parameter will contains what (if anything) was stored in the input buffer
Packit d03632
after the deflated data stream.
Packit d03632
Packit d03632
This feature is useful when processing a file format that encapsulates
Packit d03632
a compressed data stream (e.g. gzip, zip) and there is useful data
Packit d03632
immediately after the deflation stream.
Packit d03632
Packit d03632
If the C<AppendOutput> option is set to true in the constructor for
Packit d03632
this object, the uncompressed data will be appended to C<$output>. If
Packit d03632
it is false, C<$output> will be truncated before any uncompressed data
Packit d03632
is written to it.
Packit d03632
Packit d03632
The C<$eof> parameter needs a bit of explanation.
Packit d03632
Packit d03632
Prior to version 1.2.0, zlib assumed that there was at least one trailing
Packit d03632
byte immediately after the compressed data stream when it was carrying out
Packit d03632
decompression. This normally isn't a problem because the majority of zlib
Packit d03632
applications guarantee that there will be data directly after the
Packit d03632
compressed data stream.  For example, both gzip (RFC 1950) and zip both
Packit d03632
define trailing data that follows the compressed data stream.
Packit d03632
Packit d03632
The C<$eof> parameter only needs to be used if B<all> of the following
Packit d03632
conditions apply
Packit d03632
Packit d03632
=over 5
Packit d03632
Packit d03632
=item 1
Packit d03632
Packit d03632
You are either using a copy of zlib that is older than version 1.2.0 or you
Packit d03632
want your application code to be able to run with as many different
Packit d03632
versions of zlib as possible.
Packit d03632
Packit d03632
=item 2
Packit d03632
Packit d03632
You have set the C<WindowBits> parameter to C<-MAX_WBITS> in the constructor
Packit d03632
for this object, i.e. you are uncompressing a raw deflated data stream
Packit d03632
(RFC 1951).
Packit d03632
Packit d03632
=item 3
Packit d03632
Packit d03632
There is no data immediately after the compressed data stream.
Packit d03632
Packit d03632
=back
Packit d03632
Packit d03632
If B<all> of these are the case, then you need to set the C<$eof> parameter
Packit d03632
to true on the final call (and only the final call) to C<$i-E<gt>inflate>.
Packit d03632
Packit d03632
If you have built this module with zlib >= 1.2.0, the C<$eof> parameter is
Packit d03632
ignored. You can still set it if you want, but it won't be used behind the
Packit d03632
scenes.
Packit d03632
Packit d03632
=head2 B<$status = $i-E<gt>inflateSync($input)>
Packit d03632
Packit d03632
This method can be used to attempt to recover good data from a compressed
Packit d03632
data stream that is partially corrupt.
Packit d03632
It scans C<$input> until it reaches either a I<full flush point> or the
Packit d03632
end of the buffer.
Packit d03632
Packit d03632
If a I<full flush point> is found, C<Z_OK> is returned and C<$input>
Packit d03632
will be have all data up to the flush point removed. This data can then be
Packit d03632
passed to the C<$i-E<gt>inflate> method to be uncompressed.
Packit d03632
Packit d03632
Any other return code means that a flush point was not found. If more
Packit d03632
data is available, C<inflateSync> can be called repeatedly with more
Packit d03632
compressed data until the flush point is found.
Packit d03632
Packit d03632
Note I<full flush points> are not present by default in compressed
Packit d03632
data streams. They must have been added explicitly when the data stream
Packit d03632
was created by calling C<Compress::Deflate::flush>  with C<Z_FULL_FLUSH>.
Packit d03632
Packit d03632
=head2 B<$status = $i-E<gt>inflateReset() >
Packit d03632
Packit d03632
This method will reset the inflation object C<$i>. It can be used when you
Packit d03632
are uncompressing multiple data streams and want to use the same object to
Packit d03632
uncompress each of them.
Packit d03632
Packit d03632
Returns C<Z_OK> if successful.
Packit d03632
Packit d03632
=head2 B<$i-E<gt>dict_adler()>
Packit d03632
Packit d03632
Returns the adler32 value for the dictionary.
Packit d03632
Packit d03632
=head2 B<$i-E<gt>crc32()>
Packit d03632
Packit d03632
Returns the crc32 value for the uncompressed data to date.
Packit d03632
Packit d03632
If the C<CRC32> option is not enabled in the constructor for this object,
Packit d03632
this method will always return 0;
Packit d03632
Packit d03632
=head2 B<$i-E<gt>adler32()>
Packit d03632
Packit d03632
Returns the adler32 value for the uncompressed data to date.
Packit d03632
Packit d03632
If the C<ADLER32> option is not enabled in the constructor for this object,
Packit d03632
this method will always return 0;
Packit d03632
Packit d03632
=head2 B<$i-E<gt>msg()>
Packit d03632
Packit d03632
Returns the last error message generated by zlib.
Packit d03632
Packit d03632
=head2 B<$i-E<gt>total_in()>
Packit d03632
Packit d03632
Returns the total number of bytes compressed bytes input to inflate.
Packit d03632
Packit d03632
=head2 B<$i-E<gt>total_out()>
Packit d03632
Packit d03632
Returns the total number of uncompressed bytes output from inflate.
Packit d03632
Packit d03632
=head2 B<$d-E<gt>get_BufSize()>
Packit d03632
Packit d03632
Returns the buffer size used to carry out the decompression.
Packit d03632
Packit d03632
=head2 Examples
Packit d03632
Packit d03632
Here is an example of using C<inflate>.
Packit d03632
Packit d03632
    use strict ;
Packit d03632
    use warnings ;
Packit d03632
    
Packit d03632
    use Compress::Raw::Zlib;
Packit d03632
    
Packit d03632
    my $x = new Compress::Raw::Zlib::Inflate()
Packit d03632
       or die "Cannot create a inflation stream\n" ;
Packit d03632
    
Packit d03632
    my $input = '' ;
Packit d03632
    binmode STDIN;
Packit d03632
    binmode STDOUT;
Packit d03632
    
Packit d03632
    my ($output, $status) ;
Packit d03632
    while (read(STDIN, $input, 4096))
Packit d03632
    {
Packit d03632
        $status = $x->inflate($input, $output) ;
Packit d03632
    
Packit d03632
        print $output ;
Packit d03632
    
Packit d03632
        last if $status != Z_OK ;
Packit d03632
    }
Packit d03632
    
Packit d03632
    die "inflation failed\n"
Packit d03632
        unless $status == Z_STREAM_END ;
Packit d03632
Packit d03632
The next example show how to use the C<LimitOutput> option. Notice the use
Packit d03632
of two nested loops in this case. The outer loop reads the data from the
Packit d03632
input source - STDIN and the inner loop repeatedly calls C<inflate> until
Packit d03632
C<$input> is exhausted, we get an error, or the end of the stream is
Packit d03632
reached. One point worth remembering is by using the C<LimitOutput> option
Packit d03632
you also get C<ConsumeInput> set as well - this makes the code below much
Packit d03632
simpler.
Packit d03632
Packit d03632
    use strict ;
Packit d03632
    use warnings ;
Packit d03632
    
Packit d03632
    use Compress::Raw::Zlib;
Packit d03632
    
Packit d03632
    my $x = new Compress::Raw::Zlib::Inflate(LimitOutput => 1)
Packit d03632
       or die "Cannot create a inflation stream\n" ;
Packit d03632
    
Packit d03632
    my $input = '' ;
Packit d03632
    binmode STDIN;
Packit d03632
    binmode STDOUT;
Packit d03632
    
Packit d03632
    my ($output, $status) ;
Packit d03632
Packit d03632
  OUTER:
Packit d03632
    while (read(STDIN, $input, 4096))
Packit d03632
    {
Packit d03632
        do
Packit d03632
        {
Packit d03632
            $status = $x->inflate($input, $output) ;
Packit d03632
Packit d03632
            print $output ;
Packit d03632
Packit d03632
            last OUTER
Packit d03632
                unless $status == Z_OK || $status == Z_BUF_ERROR ;
Packit d03632
        }
Packit d03632
        while ($status == Z_OK && length $input);
Packit d03632
    }
Packit d03632
    
Packit d03632
    die "inflation failed\n"
Packit d03632
        unless $status == Z_STREAM_END ;
Packit d03632
Packit d03632
=head1 CHECKSUM FUNCTIONS
Packit d03632
Packit d03632
Two functions are provided by I<zlib> to calculate checksums. For the
Packit d03632
Perl interface, the order of the two parameters in both functions has
Packit d03632
been reversed. This allows both running checksums and one off
Packit d03632
calculations to be done.
Packit d03632
Packit d03632
    $crc = adler32($buffer [,$crc]) ;
Packit d03632
    $crc = crc32($buffer [,$crc]) ;
Packit d03632
Packit d03632
The buffer parameters can either be a scalar or a scalar reference.
Packit d03632
Packit d03632
If the $crc parameters is C<undef>, the crc value will be reset.
Packit d03632
Packit d03632
If you have built this module with zlib 1.2.3 or better, two more
Packit d03632
CRC-related functions are available.
Packit d03632
Packit d03632
    $crc = crc32_combine($crc1, $crc2, $len2);
Packit d03632
    $adler = adler32_combine($adler1, $adler2, $len2);
Packit d03632
Packit d03632
These functions allow checksums to be merged.
Packit d03632
Refer to the I<zlib> documentation for more details.
Packit d03632
Packit d03632
=head1 Misc
Packit d03632
Packit d03632
=head2 my $version = Compress::Raw::Zlib::zlib_version();
Packit d03632
Packit d03632
Returns the version of the zlib library.
Packit d03632
Packit d03632
=head2  my $flags = Compress::Raw::Zlib::zlibCompileFlags();
Packit d03632
Packit d03632
Returns the flags indicating compile-time options that were used to build
Packit d03632
the zlib library. See the zlib documentation for a description of the flags
Packit d03632
returned by C<zlibCompileFlags>.
Packit d03632
Packit d03632
Note that when the zlib sources are built along with this module the
Packit d03632
C<sprintf> flags (bits 24, 25 and 26) should be ignored.
Packit d03632
Packit d03632
If you are using zlib 1.2.0 or older, C<zlibCompileFlags> will return 0.
Packit d03632
Packit d03632
=head1 The LimitOutput option.
Packit d03632
Packit d03632
By default C<< $i->inflate($input, $output) >> will uncompress I<all> data
Packit d03632
in C<$input> and write I<all> of the uncompressed data it has generated to
Packit d03632
C<$output>. This makes the interface to C<inflate> much simpler - if the
Packit d03632
method has uncompressed C<$input> successfully I<all> compressed data in
Packit d03632
C<$input> will have been dealt with. So if you are reading from an input
Packit d03632
source and uncompressing as you go the code will look something like this
Packit d03632
Packit d03632
    use strict ;
Packit d03632
    use warnings ;
Packit d03632
    
Packit d03632
    use Compress::Raw::Zlib;
Packit d03632
    
Packit d03632
    my $x = new Compress::Raw::Zlib::Inflate()
Packit d03632
       or die "Cannot create a inflation stream\n" ;
Packit d03632
    
Packit d03632
    my $input = '' ;
Packit d03632
    
Packit d03632
    my ($output, $status) ;
Packit d03632
    while (read(STDIN, $input, 4096))
Packit d03632
    {
Packit d03632
        $status = $x->inflate($input, $output) ;
Packit d03632
    
Packit d03632
        print $output ;
Packit d03632
    
Packit d03632
        last if $status != Z_OK ;
Packit d03632
    }
Packit d03632
    
Packit d03632
    die "inflation failed\n"
Packit d03632
        unless $status == Z_STREAM_END ;
Packit d03632
Packit d03632
The points to note are
Packit d03632
Packit d03632
=over 5
Packit d03632
Packit d03632
=item *
Packit d03632
Packit d03632
The main processing loop in the code handles reading of compressed data
Packit d03632
from STDIN.
Packit d03632
Packit d03632
=item *
Packit d03632
Packit d03632
The status code returned from C<inflate> will only trigger termination of
Packit d03632
the main processing loop if it isn't C<Z_OK>. When C<LimitOutput> has not
Packit d03632
been used the C<Z_OK> status means that the end of the compressed
Packit d03632
data stream has been reached or there has been an error in uncompression.
Packit d03632
Packit d03632
=item *
Packit d03632
Packit d03632
After the call to C<inflate> I<all> of the uncompressed data in C<$input>
Packit d03632
will have been processed. This means the subsequent call to C<read> can
Packit d03632
overwrite it's contents without any problem.
Packit d03632
Packit d03632
=back
Packit d03632
Packit d03632
For most use-cases the behavior described above is acceptable (this module
Packit d03632
and it's predecessor, C<Compress::Zlib>, have used it for over 10 years
Packit d03632
without an issue), but in a few very specific use-cases the amount of
Packit d03632
memory required for C<$output> can prohibitively large. For example, if the
Packit d03632
compressed data stream contains the same pattern repeated thousands of
Packit d03632
times, a relatively small compressed data stream can uncompress into
Packit d03632
hundreds of megabytes.  Remember C<inflate> will keep allocating memory
Packit d03632
until I<all> the uncompressed data has been written to the output buffer -
Packit d03632
the size of C<$output> is unbounded.
Packit d03632
Packit d03632
The C<LimitOutput> option is designed to help with this use-case.
Packit d03632
Packit d03632
The main difference in your code when using C<LimitOutput> is having to
Packit d03632
deal with cases where the C<$input> parameter still contains some
Packit d03632
uncompressed data that C<inflate> hasn't processed yet. The status code
Packit d03632
returned from C<inflate> will be C<Z_OK> if uncompression took place and
Packit d03632
C<Z_BUF_ERROR> if the output buffer is full.
Packit d03632
Packit d03632
Below is typical code that shows how to use C<LimitOutput>.
Packit d03632
Packit d03632
    use strict ;
Packit d03632
    use warnings ;
Packit d03632
    
Packit d03632
    use Compress::Raw::Zlib;
Packit d03632
    
Packit d03632
    my $x = new Compress::Raw::Zlib::Inflate(LimitOutput => 1)
Packit d03632
       or die "Cannot create a inflation stream\n" ;
Packit d03632
    
Packit d03632
    my $input = '' ;
Packit d03632
    binmode STDIN;
Packit d03632
    binmode STDOUT;
Packit d03632
    
Packit d03632
    my ($output, $status) ;
Packit d03632
Packit d03632
  OUTER:
Packit d03632
    while (read(STDIN, $input, 4096))
Packit d03632
    {
Packit d03632
        do
Packit d03632
        {
Packit d03632
            $status = $x->inflate($input, $output) ;
Packit d03632
Packit d03632
            print $output ;
Packit d03632
Packit d03632
            last OUTER
Packit d03632
                unless $status == Z_OK || $status == Z_BUF_ERROR ;
Packit d03632
        }
Packit d03632
        while ($status == Z_OK && length $input);
Packit d03632
    }
Packit d03632
    
Packit d03632
    die "inflation failed\n"
Packit d03632
        unless $status == Z_STREAM_END ;
Packit d03632
Packit d03632
Points to note this time:
Packit d03632
Packit d03632
=over 5
Packit d03632
Packit d03632
=item *
Packit d03632
Packit d03632
There are now two nested loops in the code: the outer loop for reading the
Packit d03632
compressed data from STDIN, as before; and the inner loop to carry out the
Packit d03632
uncompression.
Packit d03632
Packit d03632
=item *
Packit d03632
Packit d03632
There are two exit points from the inner uncompression loop.
Packit d03632
Packit d03632
Firstly when C<inflate> has returned a status other than C<Z_OK> or
Packit d03632
C<Z_BUF_ERROR>.  This means that either the end of the compressed data
Packit d03632
stream has been reached (C<Z_STREAM_END>) or there is an error in the
Packit d03632
compressed data. In either of these cases there is no point in continuing
Packit d03632
with reading the compressed data, so both loops are terminated.
Packit d03632
Packit d03632
The second exit point tests if there is any data left in the input buffer,
Packit d03632
C<$input> - remember that the C<ConsumeInput> option is automatically
Packit d03632
enabled when C<LimitOutput> is used.  When the input buffer has been
Packit d03632
exhausted, the outer loop can run again and overwrite a now empty
Packit d03632
C<$input>.
Packit d03632
Packit d03632
=back
Packit d03632
Packit d03632
=head1 ACCESSING ZIP FILES
Packit d03632
Packit d03632
Although it is possible (with some effort on your part) to use this module
Packit d03632
to access .zip files, there are other perl modules available that will do
Packit d03632
all the hard work for you. Check out C<Archive::Zip>,
Packit d03632
C<Archive::Zip::SimpleZip>, C<IO::Compress::Zip> and
Packit d03632
C<IO::Uncompress::Unzip>.
Packit d03632
Packit d03632
=head1 FAQ
Packit d03632
Packit d03632
=head2 Compatibility with Unix compress/uncompress.
Packit d03632
Packit d03632
This module is not compatible with Unix C<compress>.
Packit d03632
Packit d03632
If you have the C<uncompress> program available, you can use this to read
Packit d03632
compressed files
Packit d03632
Packit d03632
    open F, "uncompress -c $filename |";
Packit d03632
    while (<F>)
Packit d03632
    {
Packit d03632
        ...
Packit d03632
Packit d03632
Alternatively, if you have the C<gunzip> program available, you can use
Packit d03632
this to read compressed files
Packit d03632
Packit d03632
    open F, "gunzip -c $filename |";
Packit d03632
    while (<F>)
Packit d03632
    {
Packit d03632
        ...
Packit d03632
Packit d03632
and this to write compress files, if you have the C<compress> program
Packit d03632
available
Packit d03632
Packit d03632
    open F, "| compress -c $filename ";
Packit d03632
    print F "data";
Packit d03632
    ...
Packit d03632
    close F ;
Packit d03632
Packit d03632
=head2 Accessing .tar.Z files
Packit d03632
Packit d03632
See previous FAQ item.
Packit d03632
Packit d03632
If the C<Archive::Tar> module is installed and either the C<uncompress> or
Packit d03632
C<gunzip> programs are available, you can use one of these workarounds to
Packit d03632
read C<.tar.Z> files.
Packit d03632
Packit d03632
Firstly with C<uncompress>
Packit d03632
Packit d03632
    use strict;
Packit d03632
    use warnings;
Packit d03632
    use Archive::Tar;
Packit d03632
Packit d03632
    open F, "uncompress -c $filename |";
Packit d03632
    my $tar = Archive::Tar->new(*F);
Packit d03632
    ...
Packit d03632
Packit d03632
and this with C<gunzip>
Packit d03632
Packit d03632
    use strict;
Packit d03632
    use warnings;
Packit d03632
    use Archive::Tar;
Packit d03632
Packit d03632
    open F, "gunzip -c $filename |";
Packit d03632
    my $tar = Archive::Tar->new(*F);
Packit d03632
    ...
Packit d03632
Packit d03632
Similarly, if the C<compress> program is available, you can use this to
Packit d03632
write a C<.tar.Z> file
Packit d03632
Packit d03632
    use strict;
Packit d03632
    use warnings;
Packit d03632
    use Archive::Tar;
Packit d03632
    use IO::File;
Packit d03632
Packit d03632
    my $fh = new IO::File "| compress -c >$filename";
Packit d03632
    my $tar = Archive::Tar->new();
Packit d03632
    ...
Packit d03632
    $tar->write($fh);
Packit d03632
    $fh->close ;
Packit d03632
Packit d03632
=head2 Zlib Library Version Support
Packit d03632
Packit d03632
By default C<Compress::Raw::Zlib> will build with a private copy of version
Packit d03632
1.2.5 of the zlib library. (See the F<README> file for details of
Packit d03632
how to override this behaviour)
Packit d03632
Packit d03632
If you decide to use a different version of the zlib library, you need to be
Packit d03632
aware of the following issues
Packit d03632
Packit d03632
=over 5
Packit d03632
Packit d03632
=item *
Packit d03632
Packit d03632
First off, you must have zlib 1.0.5 or better.
Packit d03632
Packit d03632
=item *
Packit d03632
Packit d03632
You need to have zlib 1.2.1 or better if you want to use the C<-Merge>
Packit d03632
option with C<IO::Compress::Gzip>, C<IO::Compress::Deflate> and
Packit d03632
C<IO::Compress::RawDeflate>.
Packit d03632
Packit d03632
=back
Packit d03632
Packit d03632
=head1 CONSTANTS
Packit d03632
Packit d03632
All the I<zlib> constants are automatically imported when you make use
Packit d03632
of I<Compress::Raw::Zlib>.
Packit d03632
Packit d03632
=head1 SEE ALSO
Packit d03632
Packit d03632
L<Compress::Zlib>, L<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>
Packit d03632
Packit d03632
L<IO::Compress::FAQ|IO::Compress::FAQ>
Packit d03632
Packit d03632
L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,
Packit d03632
L<Archive::Tar|Archive::Tar>,
Packit d03632
L<IO::Zlib|IO::Zlib>
Packit d03632
Packit d03632
For RFC 1950, 1951 and 1952 see
Packit d03632
L<http://www.faqs.org/rfcs/rfc1950.html>,
Packit d03632
L<http://www.faqs.org/rfcs/rfc1951.html> and
Packit d03632
L<http://www.faqs.org/rfcs/rfc1952.html>
Packit d03632
Packit d03632
The I<zlib> compression library was written by Jean-loup Gailly
Packit d03632
C<gzip@prep.ai.mit.edu> and Mark Adler C<madler@alumni.caltech.edu>.
Packit d03632
Packit d03632
The primary site for the I<zlib> compression library is
Packit d03632
L<http://www.zlib.org>.
Packit d03632
Packit d03632
The primary site for gzip is L<http://www.gzip.org>.
Packit d03632
Packit d03632
=head1 AUTHOR
Packit d03632
Packit d03632
This module was written by Paul Marquess, C<pmqs@cpan.org>.
Packit d03632
Packit d03632
=head1 MODIFICATION HISTORY
Packit d03632
Packit d03632
See the Changes file.
Packit d03632
Packit d03632
=head1 COPYRIGHT AND LICENSE
Packit d03632
Packit d03632
Copyright (c) 2005-2018 Paul Marquess. All rights reserved.
Packit d03632
Packit d03632
This program is free software; you can redistribute it and/or
Packit d03632
modify it under the same terms as Perl itself.
Packit d03632