| 1 | package IO::Compress::Adapter::Lzf ; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use IO::Compress::Base::Common 2.225 qw(:Status); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use Compress::LZF ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 10 | our ($VERSION); | |||||||||||||||||||||||||||
| 11 | 10 | $VERSION = '2.225'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use constant SIGNATURE => 'ZV'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub mkCompObject | ||||||||||||||||||||||||||||
| 16 | 221 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
mkCompObject: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 221 | my $blocksize = shift ; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 221 | return bless { | |||||||||||||||||||||||||||
| 20 | 'Buffer' => '', | ||||||||||||||||||||||||||||
| 21 | 'BlockSize' => $blocksize, | ||||||||||||||||||||||||||||
| 22 | #'CRC' => ! $minimal, | ||||||||||||||||||||||||||||
| 23 | 'Error' => '', | ||||||||||||||||||||||||||||
| 24 | 'ErrorNo' => 0, | ||||||||||||||||||||||||||||
| 25 | 'CompBytes' => 0, | ||||||||||||||||||||||||||||
| 26 | 'UnCompBytes'=> 0, | ||||||||||||||||||||||||||||
| 27 | } ; | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | sub compr | ||||||||||||||||||||||||||||
| 31 | 227 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
compr: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 227 | my $self = shift ; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 227 | $self->{Buffer} .= ${ $_[0] } ; | |||||||||||||||||||||||||||
| 35 | return $self->writeBlock(\$_[1], 0) | ||||||||||||||||||||||||||||
| 36 | 227 | ▶ | if length $self->{Buffer} >= $self->{BlockSize} ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 227 | return STATUS_OK; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | sub flush | ||||||||||||||||||||||||||||
| 43 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
flush: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 4 | my $self = shift ; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | return STATUS_OK | ||||||||||||||||||||||||||||
| 47 | 4 | ▶ | unless length $self->{Buffer}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 4 | return $self->writeBlock(\$_[0], 1); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub close | ||||||||||||||||||||||||||||
| 53 | 220 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
close: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 220 | my $self = shift ; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | return STATUS_OK | ||||||||||||||||||||||||||||
| 57 | 220 | ▶ | unless length $self->{Buffer}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 148 | return $self->writeBlock(\$_[0], 1); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub writeBlock | ||||||||||||||||||||||||||||
| 63 | 152 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
writeBlock: called CC=4 SCAR=16.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 152 | my $self = shift; | |||||||||||||||||||||||||||
| 65 | 152 | my $flush = $_[1] ; | |||||||||||||||||||||||||||
| 66 | 152 | my $blockSize = $self->{BlockSize} ; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 152 | ▶ | while (length $self->{Buffer} >= $blockSize) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | my $buff = substr($self->{Buffer}, 0, $blockSize); | |||||||||||||||||||||||||||
| 70 | 0 | substr($self->{Buffer}, 0, $blockSize) = ''; | |||||||||||||||||||||||||||
| 71 | 0 | $self->writeOneBlock(\$buff, $_[0]); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 152 | ▶ | if ($flush && length $self->{Buffer} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$flush and length $self->{"Buffer"}
MC/DC0%0/2
$flush and length $self->{"Buffer"}
$flush
length $self->{"Buffer"}
Truth table33%1/3
A and B
A= $flushB= length $self->{"Buffer"}
| |||||||||||||||||||||||||||||
| 75 | 152 | $self->writeOneBlock(\$self->{Buffer}, $_[0]); | |||||||||||||||||||||||||||
| 76 | 152 | $self->{Buffer} = ''; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 152 | return STATUS_OK; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | sub writeOneBlock | ||||||||||||||||||||||||||||
| 83 | 152 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
writeOneBlock: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 84 | 152 | my $self = shift; | |||||||||||||||||||||||||||
| 85 | 152 | my $buff = shift; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 152 | my $cmp ; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 152 | eval { $cmp = Compress::LZF::compress($$buff) }; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 152 | ▶ | return STATUS_ERROR | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ or not defined $cmp
MC/DC0%0/2
$@ or not defined $cmp
$@
not defined $cmp
Truth table33%1/3
A or not(B)
A= $@B= not defined $cmp
| |||||||||||||||||||||||||||||
| 92 | if $@ || ! defined $cmp; | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 152 | ${ $_[0] } .= SIGNATURE ; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | #$self->{UnCompBytes} += length $self->{Buffer} ; | ||||||||||||||||||||||||||||
| 97 | 152 | $self->{UnCompBytes} += length $$buff ; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | # Remove the Compress::LZF header | ||||||||||||||||||||||||||||
| 100 | 152 | substr($cmp, 0, c_lzf_header_length($cmp)) = ''; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | #if (length($cmp) >= length($self->{Buffer})) | ||||||||||||||||||||||||||||
| 103 | 152 | ▶ | if (length($cmp) >= length $$buff) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||
| 105 | 67 | ${ $_[0] } .= pack("Cn", 0, length($$buff)); | |||||||||||||||||||||||||||
| 106 | 67 | ${ $_[0] } .= $$buff; | |||||||||||||||||||||||||||
| 107 | 67 | $self->{CompBytes} += length $$buff; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | else { | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 85 | ${ $_[0] } .= pack("Cnn", 1, length($cmp), length($$buff)); | |||||||||||||||||||||||||||
| 112 | 85 | ${ $_[0] } .= $cmp; | |||||||||||||||||||||||||||
| 113 | 85 | $self->{CompBytes} += length $cmp; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | #$self->{Buffer} = ''; | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 152 | return STATUS_OK; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | sub c_lzf_header_length | ||||||||||||||||||||||||||||
| 121 | 152 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
c_lzf_header_length: called CC=8 SCAR=27.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 122 | 152 | my $firstByte = unpack ("C", substr($_[0], 0, 1)); | |||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 152 | ▶ | return 1 if $firstByte == 0 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 85 | ▶ | return 1 unless $firstByte & 0x80 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | 73 | ▶ | return 2 unless $firstByte & 0x20 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 28 | ▶ | return 3 unless $firstByte & 0x10 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | return 4 unless $firstByte & 0x08 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return 5 unless $firstByte & 0x04 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | return 6 unless $firstByte & 0x02 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | return undef; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | sub reset | ||||||||||||||||||||||||||||
| 136 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 137 | 0 | return STATUS_OK; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | sub compressedBytes | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
compressedBytes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 142 | 0 | my $self = shift ; | |||||||||||||||||||||||||||
| 143 | 0 | $self->{CompBytes}; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | sub uncompressedBytes | ||||||||||||||||||||||||||||
| 147 | 220 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
uncompressedBytes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 148 | 220 | my $self = shift ; | |||||||||||||||||||||||||||
| 149 | 220 | $self->{UnCompBytes}; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 10 | 1; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | __END__ | ||||||||||||||||||||||||||||