line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IO::Uncompress::Adapter::Lzf; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
155607
|
use strict; |
|
11
|
|
|
|
|
46
|
|
|
11
|
|
|
|
|
268
|
|
4
|
11
|
|
|
11
|
|
48
|
use warnings; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
235
|
|
5
|
11
|
|
|
11
|
|
45
|
use bytes; |
|
11
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
44
|
|
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
315
|
use IO::Compress::Base::Common 2.204 qw(:Status); |
|
11
|
|
|
|
|
176
|
|
|
11
|
|
|
|
|
1108
|
|
8
|
11
|
|
|
11
|
|
1327
|
use Compress::LZF ; |
|
11
|
|
|
|
|
1147
|
|
|
11
|
|
|
|
|
7132
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our ($VERSION, @ISA); |
11
|
|
|
|
|
|
|
$VERSION = '2.204'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub mkUncompObject |
15
|
|
|
|
|
|
|
{ |
16
|
956
|
|
|
956
|
0
|
4666
|
return bless { |
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
|
|
|
774
|
0
|
1030
|
my $self = shift ; |
30
|
774
|
|
|
|
|
1417
|
$self->{Identity} = 1 ; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub setUSize |
34
|
|
|
|
|
|
|
{ |
35
|
166
|
|
|
166
|
0
|
248
|
my $self = shift ; |
36
|
166
|
|
|
|
|
213
|
my $size = shift ; |
37
|
166
|
|
|
|
|
362
|
$self->{USize} = $size ; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub mk_c_lzf_header_length |
41
|
|
|
|
|
|
|
{ |
42
|
166
|
|
|
166
|
0
|
224
|
my $usize = shift ; |
43
|
166
|
|
|
|
|
210
|
my @dst; |
44
|
|
|
|
|
|
|
|
45
|
166
|
100
|
|
|
|
384
|
if ($usize <= 0x7f) |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
46
|
|
|
|
|
|
|
{ |
47
|
22
|
|
|
|
|
43
|
push @dst, $usize; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif ($usize <= 0x7ff) |
50
|
|
|
|
|
|
|
{ |
51
|
116
|
|
|
|
|
214
|
push @dst, (( $usize >> 6) | 0xc0); |
52
|
116
|
|
|
|
|
164
|
push @dst, (( $usize & 0x3f) | 0x80); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif ($usize <= 0xffff) |
55
|
|
|
|
|
|
|
{ |
56
|
28
|
|
|
|
|
63
|
push @dst, (( $usize >> 12) | 0xe0); |
57
|
28
|
|
|
|
|
67
|
push @dst, ((($usize >> 6) & 0x3f) | 0x80); |
58
|
28
|
|
|
|
|
60
|
push @dst, (( $usize & 0x3f) | 0x80); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
elsif ($usize <= 0x1fffff) |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
|
|
0
|
push @dst, (( $usize >> 18) | 0xf0); |
63
|
0
|
|
|
|
|
0
|
push @dst, ((($usize >> 12) & 0x3f) | 0x80); |
64
|
0
|
|
|
|
|
0
|
push @dst, ((($usize >> 6) & 0x3f) | 0x80); |
65
|
0
|
|
|
|
|
0
|
push @dst, (( $usize & 0x3f) | 0x80); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
elsif ($usize <= 0x3ffffff) |
68
|
|
|
|
|
|
|
{ |
69
|
0
|
|
|
|
|
0
|
push @dst, (( $usize >> 24) | 0xf8); |
70
|
0
|
|
|
|
|
0
|
push @dst, ((($usize >> 18) & 0x3f) | 0x80); |
71
|
0
|
|
|
|
|
0
|
push @dst, ((($usize >> 12) & 0x3f) | 0x80); |
72
|
0
|
|
|
|
|
0
|
push @dst, ((($usize >> 6) & 0x3f) | 0x80); |
73
|
0
|
|
|
|
|
0
|
push @dst, (( $usize & 0x3f) | 0x80); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
elsif ($usize <= 0x7fffffff) |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
|
|
0
|
push @dst, (( $usize >> 30) | 0xfc); |
78
|
0
|
|
|
|
|
0
|
push @dst, ((($usize >> 24) & 0x3f) | 0x80); |
79
|
0
|
|
|
|
|
0
|
push @dst, ((($usize >> 18) & 0x3f) | 0x80); |
80
|
0
|
|
|
|
|
0
|
push @dst, ((($usize >> 12) & 0x3f) | 0x80); |
81
|
0
|
|
|
|
|
0
|
push @dst, ((($usize >> 6) & 0x3f) | 0x80); |
82
|
0
|
|
|
|
|
0
|
push @dst, (( $usize & 0x3f) | 0x80); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
|
|
0
|
die("compress can only compress up to 0x7fffffffL bytes"); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
166
|
|
|
|
|
563
|
return pack ("C*", @dst); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub uncompr |
94
|
|
|
|
|
|
|
{ |
95
|
352
|
|
|
352
|
0
|
15700
|
my $self = shift ; |
96
|
352
|
|
|
|
|
472
|
my $from = shift ; |
97
|
352
|
|
|
|
|
460
|
my $to = shift ; |
98
|
352
|
|
|
|
|
503
|
my $eof = shift ; |
99
|
352
|
|
|
|
|
428
|
my $outSize = shift ; |
100
|
|
|
|
|
|
|
|
101
|
352
|
100
|
|
|
|
728
|
return STATUS_OK |
102
|
|
|
|
|
|
|
unless length $$from; |
103
|
|
|
|
|
|
|
|
104
|
279
|
|
|
|
|
435
|
$self->{CompBytes} += length $$from; |
105
|
|
|
|
|
|
|
|
106
|
279
|
50
|
|
|
|
527
|
if (length $$from == $outSize) { |
107
|
0
|
|
|
|
|
0
|
$self->{UnCompBytes} += length $$from; |
108
|
0
|
|
|
|
|
0
|
$$to .= $$from; |
109
|
0
|
|
|
|
|
0
|
return STATUS_OK; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#$$to .= Compress::Lzf::my_decompress($from, $outSize); |
114
|
279
|
|
|
|
|
432
|
$@ = ''; |
115
|
279
|
100
|
|
|
|
492
|
if ($self->{Identity} ) |
116
|
113
|
|
|
|
|
200
|
{ $$to .= $$from } |
117
|
|
|
|
|
|
|
else { |
118
|
|
|
|
|
|
|
|
119
|
166
|
|
|
|
|
304
|
my $hdr = mk_c_lzf_header_length($self->{USize}); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# Compress::LZF::decompress croaks if the compressed data is |
122
|
|
|
|
|
|
|
# corrupt. |
123
|
166
|
|
|
|
|
281
|
eval { $$to .= Compress::LZF::decompress($hdr . $$from) } ; |
|
166
|
|
|
|
|
870
|
|
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
279
|
|
|
|
|
550
|
$self->{Identity} = 0 ; |
127
|
279
|
|
|
|
|
382
|
$self->{ErrorNo} = 0; |
128
|
|
|
|
|
|
|
|
129
|
279
|
100
|
66
|
|
|
1021
|
if ($@ || ! defined $to) { |
130
|
2
|
|
|
|
|
3
|
$self->{Error} = "error uncompressing"; |
131
|
2
|
50
|
|
|
|
6
|
$self->{Error} .= " - " . $@ |
132
|
|
|
|
|
|
|
if $@; |
133
|
2
|
|
|
|
|
4
|
$self->{ErrorNo} = 1; |
134
|
2
|
|
|
|
|
5
|
return STATUS_ERROR; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
277
|
|
|
|
|
494
|
$self->{UnCompBytes} += length $$to; |
138
|
|
|
|
|
|
|
|
139
|
277
|
|
|
|
|
501
|
return STATUS_OK ; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub reset |
143
|
|
|
|
|
|
|
{ |
144
|
0
|
|
|
0
|
0
|
|
return STATUS_OK ; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
#sub count |
148
|
|
|
|
|
|
|
#{ |
149
|
|
|
|
|
|
|
# my $self = shift ; |
150
|
|
|
|
|
|
|
# $self->{UnCompBytes}; |
151
|
|
|
|
|
|
|
#} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub compressedBytes |
154
|
|
|
|
|
|
|
{ |
155
|
0
|
|
|
0
|
0
|
|
my $self = shift ; |
156
|
0
|
|
|
|
|
|
$self->{CompBytes}; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub uncompressedBytes |
160
|
|
|
|
|
|
|
{ |
161
|
0
|
|
|
0
|
0
|
|
my $self = shift ; |
162
|
0
|
|
|
|
|
|
$self->{UnCompBytes}; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub crc32 |
166
|
|
|
|
|
|
|
{ |
167
|
0
|
|
|
0
|
0
|
|
my $self = shift ; |
168
|
|
|
|
|
|
|
#$self->{Inf}->crc32(); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub adler32 |
172
|
|
|
|
|
|
|
{ |
173
|
0
|
|
|
0
|
0
|
|
my $self = shift ; |
174
|
|
|
|
|
|
|
#$self->{Inf}->adler32(); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub sync |
178
|
|
|
|
|
|
|
{ |
179
|
0
|
|
|
0
|
0
|
|
my $self = shift ; |
180
|
|
|
|
|
|
|
#( $self->{Inf}->inflateSync(@_) == BZ_OK) |
181
|
|
|
|
|
|
|
# ? STATUS_OK |
182
|
|
|
|
|
|
|
# : STATUS_ERROR ; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
1; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
__END__ |