"Fossies" - the Fresh Open Source Software Archive

Member "IO-Compress-2.093/lib/IO/Uncompress/Adapter/Inflate.pm" (7 Dec 2019, 3278 Bytes) of package /linux/privat/IO-Compress-2.093.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Inflate.pm" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.092_vs_2.093.

    1 package IO::Uncompress::Adapter::Inflate;
    2 
    3 use strict;
    4 use warnings;
    5 use bytes;
    6 
    7 use IO::Compress::Base::Common  2.093 qw(:Status);
    8 use Compress::Raw::Zlib  2.093 qw(Z_OK Z_BUF_ERROR Z_STREAM_END Z_FINISH MAX_WBITS);
    9 
   10 our ($VERSION);
   11 $VERSION = '2.093';
   12 
   13 
   14 
   15 sub mkUncompObject
   16 {
   17     my $crc32   = shift || 1;
   18     my $adler32 = shift || 1;
   19     my $scan    = shift || 0;
   20 
   21     my $inflate ;
   22     my $status ;
   23 
   24     if ($scan)
   25     {
   26         ($inflate, $status) = new Compress::Raw::Zlib::InflateScan
   27                                     #LimitOutput  => 1,
   28                                     CRC32        => $crc32,
   29                                     ADLER32      => $adler32,
   30                                     WindowBits   => - MAX_WBITS ;
   31     }
   32     else
   33     {
   34         ($inflate, $status) = new Compress::Raw::Zlib::Inflate
   35                                     AppendOutput => 1,
   36                                     LimitOutput  => 1,
   37                                     CRC32        => $crc32,
   38                                     ADLER32      => $adler32,
   39                                     WindowBits   => - MAX_WBITS ;
   40     }
   41 
   42     return (undef, "Could not create Inflation object: $status", $status) 
   43         if $status != Z_OK ;
   44 
   45     return bless {'Inf'        => $inflate,
   46                   'CompSize'   => 0,
   47                   'UnCompSize' => 0,
   48                   'Error'      => '',
   49                   'ConsumesInput' => 1,
   50                  } ;     
   51     
   52 }
   53 
   54 sub uncompr
   55 {
   56     my $self = shift ;
   57     my $from = shift ;
   58     my $to   = shift ;
   59     my $eof  = shift ;
   60 
   61     my $inf   = $self->{Inf};
   62 
   63     my $status = $inf->inflate($from, $to, $eof);
   64     $self->{ErrorNo} = $status;
   65     if ($status != Z_OK && $status != Z_STREAM_END && $status != Z_BUF_ERROR)
   66     {
   67         $self->{Error} = "Inflation Error: $status";
   68         return STATUS_ERROR;
   69     }
   70             
   71     return STATUS_OK        if $status == Z_BUF_ERROR ; # ???
   72     return STATUS_OK        if $status == Z_OK ;
   73     return STATUS_ENDSTREAM if $status == Z_STREAM_END ;
   74     return STATUS_ERROR ;
   75 }
   76 
   77 sub reset
   78 {
   79     my $self = shift ;
   80     $self->{Inf}->inflateReset();
   81 
   82     return STATUS_OK ;
   83 }
   84 
   85 #sub count
   86 #{
   87 #    my $self = shift ;
   88 #    $self->{Inf}->inflateCount();
   89 #}
   90 
   91 sub crc32
   92 {
   93     my $self = shift ;
   94     $self->{Inf}->crc32();
   95 }
   96 
   97 sub compressedBytes
   98 {
   99     my $self = shift ;
  100     $self->{Inf}->compressedBytes();
  101 }
  102 
  103 sub uncompressedBytes
  104 {
  105     my $self = shift ;
  106     $self->{Inf}->uncompressedBytes();
  107 }
  108 
  109 sub adler32
  110 {
  111     my $self = shift ;
  112     $self->{Inf}->adler32();
  113 }
  114 
  115 sub sync
  116 {
  117     my $self = shift ;
  118     ( $self->{Inf}->inflateSync(@_) == Z_OK) 
  119             ? STATUS_OK 
  120             : STATUS_ERROR ;
  121 }
  122 
  123 
  124 sub getLastBlockOffset
  125 {
  126     my $self = shift ;
  127     $self->{Inf}->getLastBlockOffset();
  128 }
  129 
  130 sub getEndOffset
  131 {
  132     my $self = shift ;
  133     $self->{Inf}->getEndOffset();
  134 }
  135 
  136 sub resetLastBlockByte
  137 {
  138     my $self = shift ;
  139     $self->{Inf}->resetLastBlockByte(@_);
  140 }
  141 
  142 sub createDeflateStream
  143 {
  144     my $self = shift ;
  145     my $deflate = $self->{Inf}->createDeflateStream(@_);
  146     return bless {'Def'        => $deflate,
  147                   'CompSize'   => 0,
  148                   'UnCompSize' => 0,
  149                   'Error'      => '',
  150                  }, 'IO::Compress::Adapter::Deflate';
  151 }
  152 
  153 1;
  154 
  155 
  156 __END__
  157