<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::Bunzip2;

use strict;
use warnings;
use bytes;

use IO::Compress::Base::Common 2.060 qw(:Status);

use Compress::Raw::Bzip2 2.060 ;

our ($VERSION, @ISA);
$VERSION = '2.060';

sub mkUncompObject
{
    my $small     = shift || 0;
    my $verbosity = shift || 0;

    my ($inflate, $status) = new Compress::Raw::Bunzip2(1, 1, $small, $verbosity, 1);

    return (undef, "Could not create Inflation object: $status", $status)
        if $status != BZ_OK ;

    return bless {'Inf'           =&gt; $inflate,
                  'CompSize'      =&gt; 0,
                  'UnCompSize'    =&gt; 0,
                  'Error'         =&gt; '',
                  'ConsumesInput' =&gt; 1,
                 }  ;     
    
}

sub uncompr
{
    my $self = shift ;
    my $from = shift ;
    my $to   = shift ;
    my $eof  = shift ;

    my $inf   = $self-&gt;{Inf};

    my $status = $inf-&gt;bzinflate($from, $to);
    $self-&gt;{ErrorNo} = $status;

    if ($status != BZ_OK &amp;&amp; $status != BZ_STREAM_END )
    {
        $self-&gt;{Error} = "Inflation Error: $status";
        return STATUS_ERROR;
    }

    
    return STATUS_OK        if $status == BZ_OK ;
    return STATUS_ENDSTREAM if $status == BZ_STREAM_END ;
    return STATUS_ERROR ;
}


sub reset
{
    my $self = shift ;

    my ($inf, $status) = new Compress::Raw::Bunzip2();
    $self-&gt;{ErrorNo} = ($status == BZ_OK) ? 0 : $status ;

    if ($status != BZ_OK)
    {
        $self-&gt;{Error} = "Cannot create Inflate object: $status"; 
        return STATUS_ERROR;
    }

    $self-&gt;{Inf} = $inf;

    return STATUS_OK ;
}

sub compressedBytes
{
    my $self = shift ;
    $self-&gt;{Inf}-&gt;compressedBytes();
}

sub uncompressedBytes
{
    my $self = shift ;
    $self-&gt;{Inf}-&gt;uncompressedBytes();
}

sub crc32
{
    my $self = shift ;
    #$self-&gt;{Inf}-&gt;crc32();
}

sub adler32
{
    my $self = shift ;
    #$self-&gt;{Inf}-&gt;adler32();
}

sub sync
{
    my $self = shift ;
    #( $self-&gt;{Inf}-&gt;inflateSync(@_) == BZ_OK) 
    #        ? STATUS_OK 
    #        : STATUS_ERROR ;
}


1;

__END__

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