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

use strict;
use warnings;
use bytes;

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

use Compress::Raw::Bzip2  2.204 ;

our ($VERSION);
$VERSION = '2.204';

sub mkCompObject
{
    my $BlockSize100K = shift ;
    my $WorkFactor = shift ;
    my $Verbosity  = shift ;

    $BlockSize100K = 1 if ! defined $BlockSize100K ;
    $WorkFactor    = 0 if ! defined $WorkFactor ;
    $Verbosity     = 0 if ! defined $Verbosity ;

    my ($def, $status) = Compress::Raw::Bzip2-&gt;new(1, $BlockSize100K,
                                                 $WorkFactor, $Verbosity);

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

    return bless {'Def'        =&gt; $def,
                  'Error'      =&gt; '',
                  'ErrorNo'    =&gt; 0,
                 }  ;
}

sub compr
{
    my $self = shift ;

    my $def   = $self-&gt;{Def};

    my $status = $def-&gt;bzdeflate($_[0], $_[1]) ;
    $self-&gt;{ErrorNo} = $status;

    if ($status != BZ_RUN_OK)
    {
        $self-&gt;{Error} = "Deflate Error: $status";
        return STATUS_ERROR;
    }

    return STATUS_OK;
}

sub flush
{
    my $self = shift ;

    my $def   = $self-&gt;{Def};

    my $status = $def-&gt;bzflush($_[0]);
    $self-&gt;{ErrorNo} = $status;

    if ($status != BZ_RUN_OK)
    {
        $self-&gt;{Error} = "Deflate Error: $status";
        return STATUS_ERROR;
    }

    return STATUS_OK;

}

sub close
{
    my $self = shift ;

    my $def   = $self-&gt;{Def};

    my $status = $def-&gt;bzclose($_[0]);
    $self-&gt;{ErrorNo} = $status;

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

    return STATUS_OK;

}


sub reset
{
    my $self = shift ;

    my $outer = $self-&gt;{Outer};

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

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

    $self-&gt;{Def} = $def;

    return STATUS_OK;
}

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

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

#sub total_out
#{
#    my $self = shift ;
#    0;
#}
#

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


1;

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