GIF89a;
EcchiShell v1.0
/
/
proc/
self/
root/
usr/
share/
perl5/
_create(undef, 0, @_);
}
sub inflate
{
my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$InflateError);
return $obj->_inf(@_);
}
sub getExtraParams
{
return ();
}
sub ckParams
{
my $self = shift ;
my $got = shift ;
# gunzip always needs adler32
$got->setValue('adler32' => 1);
return 1;
}
sub ckMagic
{
my $self = shift;
my $magic ;
$self->smartReadExact(\$magic, ZLIB_HEADER_SIZE);
*$self->{HeaderPending} = $magic ;
return $self->HeaderError("Header size is " .
ZLIB_HEADER_SIZE . " bytes")
if length $magic != ZLIB_HEADER_SIZE;
#return $self->HeaderError("CRC mismatch.")
return undef
if ! $self->isZlibMagic($magic) ;
*$self->{Type} = 'rfc1950';
return $magic;
}
sub readHeader
{
my $self = shift;
my $magic = shift ;
return $self->_readDeflateHeader($magic) ;
}
sub chkTrailer
{
my $self = shift;
my $trailer = shift;
my $ADLER32 = unpack("N", $trailer) ;
*$self->{Info}{ADLER32} = $ADLER32;
return $self->TrailerError("CRC mismatch")
if *$self->{Strict} && $ADLER32 != *$self->{Uncomp}->adler32() ;
return STATUS_OK;
}
sub isZlibMagic
{
my $self = shift;
my $buffer = shift ;
return 0
if length $buffer < ZLIB_HEADER_SIZE ;
my $hdr = unpack("n", $buffer) ;
#return 0 if $hdr % 31 != 0 ;
return $self->HeaderError("CRC mismatch.")
if $hdr % 31 != 0 ;
my ($CMF, $FLG) = unpack "C C", $buffer;
my $cm = bits($CMF, ZLIB_CMF_CM_OFFSET, ZLIB_CMF_CM_BITS) ;
# Only Deflate supported
return $self->HeaderError("Not Deflate (CM is $cm)")
if $cm != ZLIB_CMF_CM_DEFLATED ;
# Max window value is 7 for Deflate.
my $cinfo = bits($CMF, ZLIB_CMF_CINFO_OFFSET, ZLIB_CMF_CINFO_BITS) ;
return $self->HeaderError("CINFO > " . ZLIB_CMF_CINFO_MAX .
" (CINFO is $cinfo)")
if $cinfo > ZLIB_CMF_CINFO_MAX ;
return 1;
}
sub bits
{
my $data = shift ;
my $offset = shift ;
my $mask = shift ;
($data >> $offset ) & $mask & 0xFF ;
}
sub _readDeflateHeader
{
my ($self, $buffer) = @_ ;
# if (! $buffer) {
# $self->smartReadExact(\$buffer, ZLIB_HEADER_SIZE);
#
# *$self->{HeaderPending} = $buffer ;
#
# return $self->HeaderError("Header size is " .
# ZLIB_HEADER_SIZE . " bytes")
# if length $buffer != ZLIB_HEADER_SIZE;
#
# return $self->HeaderError("CRC mismatch.")
# if ! isZlibMagic($buffer) ;
# }
my ($CMF, $FLG) = unpack "C C", $buffer;
my $FDICT = bits($FLG, ZLIB_FLG_FDICT_OFFSET, ZLIB_FLG_FDICT_BITS ),
my $cm = bits($CMF, ZLIB_CMF_CM_OFFSET, ZLIB_CMF_CM_BITS) ;
$cm == ZLIB_CMF_CM_DEFLATED
or return $self->HeaderError("Not Deflate (CM is $cm)") ;
my $DICTID;
if ($FDICT) {
$self->smartReadExact(\$buffer, ZLIB_FDICT_SIZE)
or return $self->TruncatedHeader("FDICT");
$DICTID = unpack("N", $buffer) ;
}
*$self->{Type} = 'rfc1950';
return {
'Type' => 'rfc1950',
'FingerprintLength' => ZLIB_HEADER_SIZE,
'HeaderLength' => ZLIB_HEADER_SIZE,
'TrailerLength' => ZLIB_TRAILER_SIZE,
'Header' => $buffer,
CMF => $CMF ,
CM => bits($CMF, ZLIB_CMF_CM_OFFSET, ZLIB_CMF_CM_BITS ),
CINFO => bits($CMF, ZLIB_CMF_CINFO_OFFSET, ZLIB_CMF_CINFO_BITS ),
FLG => $FLG ,
FCHECK => bits($FLG, ZLIB_FLG_FCHECK_OFFSET, ZLIB_FLG_FCHECK_BITS),
FDICT => bits($FLG, ZLIB_FLG_FDICT_OFFSET, ZLIB_FLG_FDICT_BITS ),
FLEVEL => bits($FLG, ZLIB_FLG_LEVEL_OFFSET, ZLIB_FLG_LEVEL_BITS ),
DICTID => $DICTID ,
};
}
1 ;
__END__
=head1 NAME
IO::Uncompress::Inflate - Read RFC 1950 files/buffers
=head1 SYNOPSIS
use IO::Uncompress::Inflate qw(inflate $InflateError) ;
my $status = inflate $input => $output [,OPTS]
or die "inflate failed: $InflateError\n";
my $z = new IO::Uncompress::Inflate $input [OPTS]
or die "inflate failed: $InflateError\n";
$status = $z->read($buffer)
$status = $z->read($buffer, $length)
$status = $z->read($buffer, $length, $offset)
$line = $z->getline()
$char = $z->getc()
$char = $z->ungetc()
$char = $z->opened()
$status = $z->inflateSync()
$data = $z->trailingData()
$status = $z->nextStream()
$data = $z->getHeaderInfo()
$z->tell()
$z->seek($position, $whence)
$z->binmode()
$z->fileno()
$z->eof()
$z->close()
$InflateError ;
# IO::File mode
<$z>
read($z, $buffer);
read($z, $buffer, $length);
read($z, $buffer, $length, $offset);
tell($z)
seek($z, $position, $whence)
binmode($z)
fileno($z)
eof($z)
close($z)
=head1 DESCRIPTION
This module provides a Perl interface that allows the reading of
files/buffers that conform to RFC 1950.
For writing RFC 1950 files/buffers, see the companion module IO::Compress::Deflate.
=head1 Functional Interface
A top-level function, C, is provided to carry out
"one-shot" uncompression between buffers and/or files. For finer
control over the uncompression process, see the L"OO Interface">
section.
use IO::Uncompress::Inflate qw(inflate $InflateError) ;
inflate $input_filename_or_reference => $output_filename_or_reference [,OPTS]
or die "inflate failed: $InflateError\n";
The functional interface needs Perl5.005 or better.
=head2 inflate $input_filename_or_reference => $output_filename_or_reference [, OPTS]
C expects at least two parameters,
C<$input_filename_or_reference> and C<$output_filename_or_reference>.
=head3 The C<$input_filename_or_reference> parameter
The parameter, C<$input_filename_or_reference>, is used to define the
source of the compressed data.
It can take one of the following forms:
=over 5
=item A filename
If the <$input_filename_or_reference> parameter is a simple scalar, it is
assumed to be a filename. This file will be opened for reading and the
input data will be read from it.
=item A filehandle
If the C<$input_filename_or_reference> parameter is a filehandle, the input
data will be read from it. The string '-' can be used as an alias for
standard input.
=item A scalar reference
If C<$input_filename_or_reference> is a scalar reference, the input data
will be read from C<$$input_filename_or_reference>.
=item An array reference
If C<$input_filename_or_reference> is an array reference, each element in
the array must be a filename.
The input data will be read from each file in turn.
The complete array will be walked to ensure that it only
contains valid filenames before any data is uncompressed.
=item An Input FileGlob string
If C<$input_filename_or_reference> is a string that is delimited by the
characters "<" and ">" C will assume that it is an
I. The input is the list of files that match the
fileglob.
See L for more details.
=back
If the C<$input_filename_or_reference> parameter is any other type,
C will be returned.
=head3 The C<$output_filename_or_reference> parameter
The parameter C<$output_filename_or_reference> is used to control the
destination of the uncompressed data. This parameter can take one of
these forms.
=over 5
=item A filename
If the C<$output_filename_or_reference> parameter is a simple scalar, it is
assumed to be a filename. This file will be opened for writing and the
uncompressed data will be written to it.
=item A filehandle
If the C<$output_filename_or_reference> parameter is a filehandle, the
uncompressed data will be written to it. The string '-' can be used as
an alias for standard output.
=item A scalar reference
If C<$output_filename_or_reference> is a scalar reference, the
uncompressed data will be stored in C<$$output_filename_or_reference>.
=item An Array Reference
If C<$output_filename_or_reference> is an array reference,
the uncompressed data will be pushed onto the array.
=item An Output FileGlob
If C<$output_filename_or_reference> is a string that is delimited by the
characters "<" and ">" C will assume that it is an
I