| 1 | package IO::Uncompress::Adapter::Lzf; | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use bytes; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use IO::Compress::Base::Common 2.217 qw(:Status); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use Compress::LZF ; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||
| 10 | 11 | our ($VERSION, @ISA); | |||||||||||||||||||||||||||||
| 11 | 11 | $VERSION = '2.217'; | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||
| 14 | sub mkUncompObject | ||||||||||||||||||||||||||||||
| 15 | { | ||||||||||||||||||||||||||||||
| 16 | 956 | ▶ | return bless { | ||||||||||||||||||||||||||||
|
Subroutine
mkUncompObject: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 17 | 'CompBytes' => 0, | ||||||||||||||||||||||||||||||
| 18 | 'UnCompBytes' => 0, | ||||||||||||||||||||||||||||||
| 19 | 'Error' => '', | ||||||||||||||||||||||||||||||
| 20 | 'ErrorNo' => 0, | ||||||||||||||||||||||||||||||
| 21 | 'Identity' => 0, | ||||||||||||||||||||||||||||||
| 22 | 'USize' => 0, | ||||||||||||||||||||||||||||||
| 23 | 'ConsumesInput' => 0, | ||||||||||||||||||||||||||||||
| 24 | } ; | ||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||
| 27 | sub setIdentity | ||||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||||
| 29 | 774 | ▶ | my $self = shift ; | ||||||||||||||||||||||||||||
|
Subroutine
setIdentity: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 30 | 774 | $self->{Identity} = 1 ; | |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||
| 33 | sub setUSize | ||||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||||
| 35 | 166 | ▶ | my $self = shift ; | ||||||||||||||||||||||||||||
|
Subroutine
setUSize: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 36 | 166 | my $size = shift ; | |||||||||||||||||||||||||||||
| 37 | 166 | $self->{USize} = $size ; | |||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||
| 40 | sub mk_c_lzf_header_length | ||||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||||
| 42 | 166 | ▶ | my $usize = shift ; | ||||||||||||||||||||||||||||
|
Subroutine
mk_c_lzf_header_length: called CC=7 SCAR=28.8
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 43 | 166 | my @dst; | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||
| 45 | 166 | ▶ | if ($usize <= 0x7f) | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||
| 47 | 22 | push @dst, $usize; | |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||
| 49 | elsif ($usize <= 0x7ff) | ||||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||||
| 51 | 116 | push @dst, (( $usize >> 6) | 0xc0); | |||||||||||||||||||||||||||||
| 52 | 116 | push @dst, (( $usize & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||
| 54 | elsif ($usize <= 0xffff) | ||||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||||
| 56 | 28 | push @dst, (( $usize >> 12) | 0xe0); | |||||||||||||||||||||||||||||
| 57 | 28 | push @dst, ((($usize >> 6) & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 58 | 28 | push @dst, (( $usize & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||
| 60 | elsif ($usize <= 0x1fffff) | ||||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||||
| 62 | 0 | push @dst, (( $usize >> 18) | 0xf0); | |||||||||||||||||||||||||||||
| 63 | 0 | push @dst, ((($usize >> 12) & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 64 | 0 | push @dst, ((($usize >> 6) & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 65 | 0 | push @dst, (( $usize & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||
| 67 | elsif ($usize <= 0x3ffffff) | ||||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||||
| 69 | 0 | push @dst, (( $usize >> 24) | 0xf8); | |||||||||||||||||||||||||||||
| 70 | 0 | push @dst, ((($usize >> 18) & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 71 | 0 | push @dst, ((($usize >> 12) & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 72 | 0 | push @dst, ((($usize >> 6) & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 73 | 0 | push @dst, (( $usize & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||
| 75 | elsif ($usize <= 0x7fffffff) | ||||||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||||
| 77 | 0 | push @dst, (( $usize >> 30) | 0xfc); | |||||||||||||||||||||||||||||
| 78 | 0 | push @dst, ((($usize >> 24) & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 79 | 0 | push @dst, ((($usize >> 18) & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 80 | 0 | push @dst, ((($usize >> 12) & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 81 | 0 | push @dst, ((($usize >> 6) & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 82 | 0 | push @dst, (( $usize & 0x3f) | 0x80); | |||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||
| 84 | else | ||||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||||
| 86 | 0 | die("compress can only compress up to 0x7fffffffL bytes"); | |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||
| 90 | 166 | return pack ("C*", @dst); | |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||
| 93 | sub uncompr | ||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||
| 95 | 352 | ▶ | my $self = shift ; | ||||||||||||||||||||||||||||
|
Subroutine
uncompr: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 96 | 352 | my $from = shift ; | |||||||||||||||||||||||||||||
| 97 | 352 | my $to = shift ; | |||||||||||||||||||||||||||||
| 98 | 352 | my $eof = shift ; | |||||||||||||||||||||||||||||
| 99 | 352 | my $outSize = shift ; | |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||
| 101 | 352 | ▶ | return STATUS_OK | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 102 | unless length $$from; | ||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||
| 104 | 279 | $self->{CompBytes} += length $$from; | |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||
| 106 | 279 | ▶ | if (length $$from == $outSize) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 107 | 0 | $self->{UnCompBytes} += length $$from; | |||||||||||||||||||||||||||||
| 108 | 0 | $$to .= $$from; | |||||||||||||||||||||||||||||
| 109 | 0 | return STATUS_OK; | |||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||
| 113 | #$$to .= Compress::Lzf::my_decompress($from, $outSize); | ||||||||||||||||||||||||||||||
| 114 | 279 | $@ = ''; | |||||||||||||||||||||||||||||
| 115 | 279 | ▶ | if ($self->{Identity} ) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 116 | 113 | { $$to .= $$from } | |||||||||||||||||||||||||||||
| 117 | else { | ||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||
| 119 | 166 | my $hdr = mk_c_lzf_header_length($self->{USize}); | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||
| 121 | # Compress::LZF::decompress croaks if the compressed data is | ||||||||||||||||||||||||||||||
| 122 | # corrupt. | ||||||||||||||||||||||||||||||
| 123 | 166 | eval { $$to .= Compress::LZF::decompress($hdr . $$from) } ; | |||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||
| 126 | 279 | $self->{Identity} = 0 ; | |||||||||||||||||||||||||||||
| 127 | 279 | $self->{ErrorNo} = 0; | |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||
| 129 | 279 | ▶ | if ($@ || ! defined $to) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$@ or not defined $to
MC/DC50%1/2
$@ or not defined $to
$@
not defined $to
Truth table66%2/3
A or not(B)
A= $@B= not defined $to
| |||||||||||||||||||||||||||||||
| 130 | 2 | $self->{Error} = "error uncompressing"; | |||||||||||||||||||||||||||||
| 131 | 2 | ▶ | $self->{Error} .= " - " . $@ | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 132 | if $@; | ||||||||||||||||||||||||||||||
| 133 | 2 | $self->{ErrorNo} = 1; | |||||||||||||||||||||||||||||
| 134 | 2 | return STATUS_ERROR; | |||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||
| 137 | 277 | $self->{UnCompBytes} += length $$to; | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||
| 139 | 277 | return STATUS_OK ; | |||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||
| 142 | sub reset | ||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | return STATUS_OK ; | ||||||||||||||||||||||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||
| 147 | #sub count | ||||||||||||||||||||||||||||||
| 148 | #{ | ||||||||||||||||||||||||||||||
| 149 | # my $self = shift ; | ||||||||||||||||||||||||||||||
| 150 | # $self->{UnCompBytes}; | ||||||||||||||||||||||||||||||
| 151 | #} | ||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||
| 153 | sub compressedBytes | ||||||||||||||||||||||||||||||
| 154 | { | ||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | my $self = shift ; | ||||||||||||||||||||||||||||
|
Subroutine
compressedBytes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 156 | 0 | $self->{CompBytes}; | |||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||
| 159 | sub uncompressedBytes | ||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my $self = shift ; | ||||||||||||||||||||||||||||
|
Subroutine
uncompressedBytes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 162 | 0 | $self->{UnCompBytes}; | |||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||
| 165 | sub crc32 | ||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | my $self = shift ; | ||||||||||||||||||||||||||||
|
Subroutine
crc32: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 168 | #$self->{Inf}->crc32(); | ||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||
| 171 | sub adler32 | ||||||||||||||||||||||||||||||
| 172 | { | ||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my $self = shift ; | ||||||||||||||||||||||||||||
|
Subroutine
adler32: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 174 | #$self->{Inf}->adler32(); | ||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||
| 177 | sub sync | ||||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | my $self = shift ; | ||||||||||||||||||||||||||||
|
Subroutine
sync: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 180 | #( $self->{Inf}->inflateSync(@_) == BZ_OK) | ||||||||||||||||||||||||||||||
| 181 | # ? STATUS_OK | ||||||||||||||||||||||||||||||
| 182 | # : STATUS_ERROR ; | ||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||
| 185 | 11 | 1; | |||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||
| 187 | __END__ | ||||||||||||||||||||||||||||||