<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package IO::Uncompress::Adapter::Identity;

use warnings;
use strict;
use bytes;

use IO::Compress::Base::Common  2.074 qw(:Status);
use IO::Compress::Zip::Constants ;

our ($VERSION);

$VERSION = '2.074';

use Compress::Raw::Zlib  2.074 ();

sub mkUncompObject
{
    my $streaming = shift;
    my $zip64 = shift;

    my $crc32 = 1; #shift ;
    my $adler32 = shift;

    bless { 'CompSize'   =&gt; new U64 , # 0,
            'UnCompSize' =&gt; 0,
            'wantCRC32'  =&gt; $crc32,
            'CRC32'      =&gt; Compress::Raw::Zlib::crc32(''),
            'wantADLER32'=&gt; $adler32,
            'ADLER32'    =&gt; Compress::Raw::Zlib::adler32(''),
            'ConsumesInput' =&gt; 1,
            'Streaming'  =&gt; $streaming,
            'Zip64'      =&gt; $zip64,
            'DataHdrSize'  =&gt; $zip64 ? 24 :  16,
            'Pending'   =&gt; '',

          } ;
}


sub uncompr
{
    my $self = shift;
    my $in = $_[0];
    my $eof = $_[2];

    my $len = length $$in;
    my $remainder = '';

    if (defined $$in &amp;&amp; $len) {

        if ($self-&gt;{Streaming}) {

            if (length $self-&gt;{Pending}) {
                $$in = $self-&gt;{Pending} . $$in ;
                $len = length $$in;
                $self-&gt;{Pending} = '';
            }

            my $ind = index($$in, "\x50\x4b\x07\x08");

            if ($ind &lt; 0) {
                $len = length $$in;
                if ($len &gt;= 3 &amp;&amp; substr($$in, -3) eq "\x50\x4b\x07") {
                    $ind = $len - 3 ;
                }
                elsif ($len &gt;= 2 &amp;&amp; substr($$in, -2) eq "\x50\x4b") {
                    $ind = $len - 2 ;
                }
                elsif ($len &gt;= 1 &amp;&amp; substr($$in, -1) eq "\x50") {
                    $ind = $len - 1 ;
                }
            }
           
            if ($ind &gt;= 0) {
                $remainder = substr($$in, $ind) ;
                substr($$in, $ind) = '' ;
            }
        }

        if (length $remainder &amp;&amp; length $remainder &lt; $self-&gt;{DataHdrSize}) {
            $self-&gt;{Pending} = $remainder ;
            $remainder = '';
        }
        elsif (length $remainder &gt;= $self-&gt;{DataHdrSize}) {
            my $crc = unpack "V", substr($remainder, 4);
            if ($crc == Compress::Raw::Zlib::crc32($$in,  $self-&gt;{CRC32})) {
                my ($l1, $l2) ;

                if ($self-&gt;{Zip64}) {
                    $l1 = U64::newUnpack_V64(substr($remainder, 8));
                    $l2 = U64::newUnpack_V64(substr($remainder, 16));
                }
                else {
                    $l1 = U64::newUnpack_V32(substr($remainder, 8));
                    $l2 = U64::newUnpack_V32(substr($remainder, 12));
                }
                    
                my $newLen = $self-&gt;{CompSize}-&gt;clone();
                $newLen-&gt;add(length $$in);
                if ($l1-&gt;equal($l2) &amp;&amp; $l1-&gt;equal($newLen) ) {
                    $eof = 1;
                }
                else {
                    $$in .= substr($remainder, 0, 4) ;
                    $remainder       = substr($remainder, 4);
                    #$self-&gt;{Pending} = substr($remainder, 4);
                    #$remainder = '';
                    $eof = 0;
                }
            }
            else {
                $$in .= substr($remainder, 0, 4) ;
                $remainder       = substr($remainder, 4);
                #$self-&gt;{Pending} = substr($remainder, 4);
                #$remainder = '';
                $eof = 0;
            }
        }

        if (length $$in) {
            $self-&gt;{CompSize}-&gt;add(length $$in) ;

            $self-&gt;{CRC32} = Compress::Raw::Zlib::crc32($$in,  $self-&gt;{CRC32})
                if $self-&gt;{wantCRC32};

            $self-&gt;{ADLER32} = Compress::Zlib::adler32($$in,  $self-&gt;{ADLER32})
                if $self-&gt;{wantADLER32};
        }

        ${ $_[1] } .= $$in;
        $$in  = $remainder;
    }

    return STATUS_ENDSTREAM if $eof;
    return STATUS_OK ;
}

sub reset
{
    my $self = shift;

    $self-&gt;{CompSize}   = 0;
    $self-&gt;{UnCompSize} = 0;
    $self-&gt;{CRC32}      = Compress::Raw::Zlib::crc32('');
    $self-&gt;{ADLER32}    = Compress::Raw::Zlib::adler32('');      

    return STATUS_OK ;
}

#sub count
#{
#    my $self = shift ;
#    return $self-&gt;{UnCompSize} ;
#}

sub compressedBytes
{
    my $self = shift ;
    return $self-&gt;{CompSize} ;
}

sub uncompressedBytes
{
    my $self = shift ;
    return $self-&gt;{CompSize} ;
}

sub sync
{
    return STATUS_OK ;
}

sub crc32
{
    my $self = shift ;
    return $self-&gt;{CRC32};
}

sub adler32
{
    my $self = shift ;
    return $self-&gt;{ADLER32};
}


1;

__END__
</pre></body></html>