}
# skip orig name
if ($flags & GZIP_FLG_FNAME)
{
my $name_end = index ($$string, GZIP_NULL_BYTE);
return Z_DATA_ERROR()
if $name_end == -1 ;
substr($$string, 0, $name_end + 1) = '';
}
# skip comment
if ($flags & GZIP_FLG_FCOMMENT)
{
my $comment_end = index ($$string, GZIP_NULL_BYTE);
return Z_DATA_ERROR()
if $comment_end == -1 ;
substr($$string, 0, $comment_end + 1) = '';
}
# skip header crc
if ($flags & GZIP_FLG_FHCRC)
{
return Z_DATA_ERROR()
if length ($$string) < GZIP_FHCRC_SIZE ;
substr($$string, 0, GZIP_FHCRC_SIZE) = '';
}
return Z_OK();
}
sub memGunzip($)
{
# if the buffer isn't a reference, make it one
my $string = (ref $_[0] ? $_[0] : \$_[0]);
$] >= 5.008 and (utf8::downgrade($$string, 1)
or croak "Wide character in memGunzip");
_removeGzipHeader($string) == Z_OK()
or return undef;
my $bufsize = length $$string > 4096 ? length $$string : 4096 ;
my $x = new Compress::Raw::Zlib::Inflate({-WindowBits => - MAX_WBITS(),
-Bufsize => $bufsize})
or return undef;
my $output = "" ;
my $status = $x->inflate($string, $output);
return undef
unless $status == Z_STREAM_END();
if (length $$string >= 8)
{
my ($crc, $len) = unpack ("VV", substr($$string, 0, 8));
substr($$string, 0, 8) = '';
return undef
unless $len == length($output) and
$crc == crc32($output);
}
else
{
$$string = '';
}
return $output;
}
# Autoload methods go after __END__, and are processed by the autosplit program.
1;
__END__
=head1 NAME
Compress::Zlib - Interface to zlib compression library
=head1 SYNOPSIS
use Compress::Zlib ;
($d, $status) = deflateInit( [OPT] ) ;
$status = $d->deflate($input, $output) ;
$status = $d->flush([$flush_type]) ;
$d->deflateParams(OPTS) ;
$d->deflateTune(OPTS) ;
$d->dict_adler() ;
$d->crc32() ;
$d->adler32() ;
$d->total_in() ;
$d->total_out() ;
$d->msg() ;
$d->get_Strategy();
$d->get_Level();
$d->get_BufSize();
($i, $status) = inflateInit( [OPT] ) ;
$status = $i->inflate($input, $output [, $eof]) ;
=6= |