GIF89a;
EcchiShell v1.0
/
/
proc/
self/
root/
usr/
share/
perl5/
_create(undef, 0, @_);
}
sub rawinflate
{
my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$RawInflateError);
return $obj->_inf(@_);
}
sub getExtraParams
{
return ();
}
sub ckParams
{
my $self = shift ;
my $got = shift ;
return 1;
}
sub mkUncomp
{
my $self = shift ;
my $got = shift ;
my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::Inflate::mkUncompObject(
$got->getValue('crc32'),
$got->getValue('adler32'),
$got->getValue('scan'),
);
return $self->saveErrorString(undef, $errstr, $errno)
if ! defined $obj;
*$self->{Uncomp} = $obj;
my $magic = $self->ckMagic()
or return 0;
*$self->{Info} = $self->readHeader($magic)
or return undef ;
return 1;
}
sub ckMagic
{
my $self = shift;
return $self->_isRaw() ;
}
sub readHeader
{
my $self = shift;
my $magic = shift ;
return {
'Type' => 'rfc1951',
'FingerprintLength' => 0,
'HeaderLength' => 0,
'TrailerLength' => 0,
'Header' => ''
};
}
sub chkTrailer
{
return STATUS_OK ;
}
sub _isRaw
{
my $self = shift ;
my $got = $self->_isRawx(@_);
if ($got) {
*$self->{Pending} = *$self->{HeaderPending} ;
}
else {
$self->pushBack(*$self->{HeaderPending});
*$self->{Uncomp}->reset();
}
*$self->{HeaderPending} = '';
return $got ;
}
sub _isRawx
{
my $self = shift ;
my $magic = shift ;
$magic = '' unless defined $magic ;
my $buffer = '';
$self->smartRead(\$buffer, *$self->{BlockSize}) >= 0
or return $self->saveErrorString(undef, "No data to read");
my $temp_buf = $magic . $buffer ;
*$self->{HeaderPending} = $temp_buf ;
$buffer = '';
my $status = *$self->{Uncomp}->uncompr(\$temp_buf, \$buffer, $self->smartEof()) ;
return $self->saveErrorString(undef, *$self->{Uncomp}{Error}, STATUS_ERROR)
if $status == STATUS_ERROR;
$self->pushBack($temp_buf) ;
return $self->saveErrorString(undef, "unexpected end of file", STATUS_ERROR)
if $self->smartEof() && $status != STATUS_ENDSTREAM;
#my $buf_len = *$self->{Uncomp}->uncompressedBytes();
my $buf_len = length $buffer;
if ($status == STATUS_ENDSTREAM) {
if (*$self->{MultiStream}
&& (length $temp_buf || ! $self->smartEof())){
*$self->{NewStream} = 1 ;
*$self->{EndStream} = 0 ;
}
else {
*$self->{EndStream} = 1 ;
}
}
*$self->{HeaderPending} = $buffer ;
*$self->{InflatedBytesRead} = $buf_len ;
*$self->{TotalInflatedBytesRead} += $buf_len ;
*$self->{Type} = 'rfc1951';
$self->saveStatus(STATUS_OK);
return {
'Type' => 'rfc1951',
'HeaderLength' => 0,
'TrailerLength' => 0,
'Header' => ''
};
}
sub inflateSync
{
my $self = shift ;
# inflateSync is a no-op in Plain mode
return 1
if *$self->{Plain} ;
return 0 if *$self->{Closed} ;
#return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ;
return 0 if ! length *$self->{Pending} && *$self->{EndStream} ;
# Disable CRC check
*$self->{Strict} = 0 ;
my $status ;
while (1)
{
my $temp_buf ;
if (length *$self->{Pending} )
{
$temp_buf = *$self->{Pending} ;
*$self->{Pending} = '';
}
else
{
$status = $self->smartRead(\$temp_buf, *$self->{BlockSize}) ;
return $self->saveErrorString(0, "Error Reading Data")
if $status < 0 ;
if ($status == 0 ) {
*$self->{EndStream} = 1 ;
return $self->saveErrorString(0, "unexpected end of file", STATUS_ERROR);
}
}
$status = *$self->{Uncomp}->sync($temp_buf) ;
if ($status == STATUS_OK)
{
*$self->{Pending} .= $temp_buf ;
return 1 ;
}
last unless $status == STATUS_ERROR ;
}
return 0;
}
#sub performScan
#{
# my $self = shift ;
#
# my $status ;
# my $end_offset = 0;
#
# $status = $self->scan()
# #or return $self->saveErrorString(undef, "Error Scanning: $$error_ref", $self->errorNo) ;
# or return $self->saveErrorString(G_ERR, "Error Scanning: $status")
#
# $status = $self->zap($end_offset)
# or return $self->saveErrorString(G_ERR, "Error Zapping: $status");
# #or return $self->saveErrorString(undef, "Error Zapping: $$error_ref", $self->errorNo) ;
#
# #(*$obj->{Deflate}, $status) = $inf->createDeflate();
#
## *$obj->{Header} = *$inf->{Info}{Header};
## *$obj->{UnCompSize_32bit} =
## *$obj->{BytesWritten} = *$inf->{UnCompSize_32bit} ;
## *$obj->{CompSize_32bit} = *$inf->{CompSize_32bit} ;
#
#
## if ( $outType eq 'buffer')
## { substr( ${ *$self->{Buffer} }, $end_offset) = '' }
## elsif ($outType eq 'handle' || $outType eq 'filename') {
## *$self->{FH} = *$inf->{FH} ;
## delete *$inf->{FH};
## *$obj->{FH}->flush() ;
## *$obj->{Handle} = 1 if $outType eq 'handle';
##
## #seek(*$obj->{FH}, $end_offset, SEEK_SET)
## *$obj->{FH}->seek($end_offset, SEEK_SET)
## or return $obj->saveErrorString(undef, $!, $!) ;
## }
#
#}
sub scan
{
my $self = shift ;
return 1 if *$self->{Closed} ;
return 1 if !length *$self->{Pending} && *$self->{EndStream} ;
my $buffer = '' ;
my $len = 0;
$len = $self->_raw_read(\$buffer, 1)
while ! *$self->{EndStream} && $len >= 0 ;
#return $len if $len < 0 ? $len : 0 ;
return $len < 0 ? 0 : 1 ;
}
sub zap
{
my $self = shift ;
my $headerLength = *$self->{Info}{HeaderLength};
my $block_offset = $headerLength + *$self->{Uncomp}->getLastBlockOffset();
$_[0] = $headerLength + *$self->{Uncomp}->getEndOffset();
#printf "# End $_[0], headerlen $headerLength \n";;
#printf "# block_offset $block_offset %x\n", $block_offset;
my $byte ;
( $self->smartSeek($block_offset) &&
$self->smartRead(\$byte, 1) )
or return $self->saveErrorString(0, $!, $!);
#printf "#byte is %x\n", unpack('C*',$byte);
*$self->{Uncomp}->resetLastBlockByte($byte);
#printf "#to byte is %x\n", unpack('C*',$byte);
( $self->smartSeek($block_offset) &&
$self->smartWrite($byte) )
or return $self->saveErrorString(0, $!, $!);
#$self->smartSeek($end_offset, 1);
return 1 ;
}
sub createDeflate
{
my $self = shift ;
my ($def, $status) = *$self->{Uncomp}->createDeflateStream(
-AppendOutput => 1,
-WindowBits => - MAX_WBITS,
-CRC32 => *$self->{Params}->getValue('crc32'),
-ADLER32 => *$self->{Params}->getValue('adler32'),
);
return wantarray ? ($status, $def) : $def ;
}
1;
__END__
=head1 NAME
IO::Uncompress::RawInflate - Read RFC 1951 files/buffers
=head1 SYNOPSIS
use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
my $status = rawinflate $input => $output [,OPTS]
or die "rawinflate failed: $RawInflateError\n";
my $z = new IO::Uncompress::RawInflate $input [OPTS]
or die "rawinflate failed: $RawInflateError\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()
$RawInflateError ;
# 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 1951.
For writing RFC 1951 files/buffers, see the companion module IO::Compress::RawDeflate.
=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::RawInflate qw(rawinflate $RawInflateError) ;
rawinflate $input_filename_or_reference => $output_filename_or_reference [,OPTS]
or die "rawinflate failed: $RawInflateError\n";
The functional interface needs Perl5.005 or better.
=head2 rawinflate $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