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

use strict;
use warnings;
use bytes;

use IO::Compress::Base::Common 2.212 qw(:Status);
use Compress::Raw::Zlib  2.212 qw( !crc32 !adler32 ) ;

require Exporter;
our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, @EXPORT, %DEFLATE_CONSTANTS);

$VERSION = '2.212';
@ISA = qw(Exporter);
@EXPORT_OK = @Compress::Raw::Zlib::DEFLATE_CONSTANTS;
%EXPORT_TAGS = %Compress::Raw::Zlib::DEFLATE_CONSTANTS;
@EXPORT = @EXPORT_OK;
%DEFLATE_CONSTANTS = %EXPORT_TAGS ;

sub mkCompObject
{
    my $crc32    = shift ;
    my $adler32  = shift ;
    my $level    = shift ;
    my $strategy = shift ;

    my ($def, $status) = Compress::Raw::Zlib::Deflate-&gt;new(
                                -AppendOutput   =&gt; 1,
                                -CRC32          =&gt; $crc32,
                                -ADLER32        =&gt; $adler32,
                                -Level          =&gt; $level,
                                -Strategy       =&gt; $strategy,
                                -WindowBits     =&gt; - MAX_WBITS);

    return (undef, "Cannot create Deflate object: $status", $status)
        if $status != Z_OK;

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

sub mkCompObject1
{
    my $crc32    = shift ;
    my $adler32  = shift ;
    my $level    = shift ;
    my $strategy = shift ;

    my ($def, $status) = Compress::Raw::Zlib::Deflate-&gt;new(
                                -AppendOutput   =&gt; 1,
                                -CRC32          =&gt; $crc32,
                                -ADLER32        =&gt; $adler32,
                                -Level          =&gt; $level,
                                -Strategy       =&gt; $strategy,
                                -WindowBits     =&gt; MAX_WBITS);

    return (undef, "Cannot create Deflate object: $status", $status)
        if $status != Z_OK;

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

sub compr
{
    my $self = shift ;

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

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

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

    return STATUS_OK;
}

sub flush
{
    my $self = shift ;

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

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

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

    return STATUS_OK;
}

sub close
{
    my $self = shift ;

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

    $def-&gt;flush($_[0], Z_FINISH)
        if defined $def ;
}

sub reset
{
    my $self = shift ;

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

    my $status = $def-&gt;deflateReset() ;
    $self-&gt;{ErrorNo} = $status;
    if ($status != Z_OK)
    {
        $self-&gt;{Error} = "Deflate Error: $status";
        return STATUS_ERROR;
    }

    return STATUS_OK;
}

sub deflateParams
{
    my $self = shift ;

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

    my $status = $def-&gt;deflateParams(@_);
    $self-&gt;{ErrorNo} = $status;
    if ($status != Z_OK)
    {
        $self-&gt;{Error} = "deflateParams Error: $status";
        return STATUS_ERROR;
    }

    return STATUS_OK;
}



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

sub compressedBytes
{
    my $self = shift ;

    $self-&gt;{Def}-&gt;compressedBytes();
}

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




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>