Filename | /usr/lib/perl/5.10/IO/Uncompress/RawInflate.pm |
Statements | Executed 32 statements in 1.93ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 8.54ms | 9.99ms | BEGIN@11 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 986µs | 1.51ms | BEGIN@12 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 28µs | 414µs | BEGIN@8 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 19µs | 23µs | BEGIN@4 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 17µs | 220µs | BEGIN@9 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 12µs | 16µs | BEGIN@6 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 12µs | 25µs | BEGIN@5 | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | _isRaw | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | _isRawx | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | chkTrailer | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | ckMagic | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | ckParams | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | createDeflate | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | getExtraParams | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | inflateSync | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | mkUncomp | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | new | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | rawinflate | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | readHeader | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | scan | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | zap | IO::Uncompress::RawInflate::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package IO::Uncompress::RawInflate ; | ||||
2 | # for RFC1951 | ||||
3 | |||||
4 | 3 | 28µs | 2 | 27µs | # spent 23µs (19+4) within IO::Uncompress::RawInflate::BEGIN@4 which was called:
# once (19µs+4µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 4 # spent 23µs making 1 call to IO::Uncompress::RawInflate::BEGIN@4
# spent 4µs making 1 call to strict::import |
5 | 3 | 41µs | 2 | 39µs | # spent 25µs (12+14) within IO::Uncompress::RawInflate::BEGIN@5 which was called:
# once (12µs+14µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 5 # spent 25µs making 1 call to IO::Uncompress::RawInflate::BEGIN@5
# spent 14µs making 1 call to warnings::import |
6 | 3 | 47µs | 2 | 19µs | # spent 16µs (12+4) within IO::Uncompress::RawInflate::BEGIN@6 which was called:
# once (12µs+4µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 6 # spent 16µs making 1 call to IO::Uncompress::RawInflate::BEGIN@6
# spent 4µs making 1 call to bytes::import |
7 | |||||
8 | 3 | 74µs | 3 | 800µs | # spent 414µs (28+386) within IO::Uncompress::RawInflate::BEGIN@8 which was called:
# once (28µs+386µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 8 # spent 414µs making 1 call to IO::Uncompress::RawInflate::BEGIN@8
# spent 366µs making 1 call to Exporter::import
# spent 20µs making 1 call to UNIVERSAL::VERSION |
9 | 3 | 62µs | 3 | 422µs | # spent 220µs (17+202) within IO::Uncompress::RawInflate::BEGIN@9 which was called:
# once (17µs+202µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 9 # spent 220µs making 1 call to IO::Uncompress::RawInflate::BEGIN@9
# spent 186µs making 1 call to Exporter::import
# spent 16µs making 1 call to UNIVERSAL::VERSION |
10 | |||||
11 | 3 | 234µs | 3 | 10.1ms | # spent 9.99ms (8.54+1.45) within IO::Uncompress::RawInflate::BEGIN@11 which was called:
# once (8.54ms+1.45ms) by IO::Uncompress::Gunzip::BEGIN@12 at line 11 # spent 9.99ms making 1 call to IO::Uncompress::RawInflate::BEGIN@11
# spent 63µs making 1 call to Exporter::import
# spent 29µs making 1 call to UNIVERSAL::VERSION |
12 | 3 | 1.39ms | 2 | 1.52ms | # spent 1.51ms (986µs+522µs) within IO::Uncompress::RawInflate::BEGIN@12 which was called:
# once (986µs+522µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 12 # spent 1.51ms making 1 call to IO::Uncompress::RawInflate::BEGIN@12
# spent 16µs making 1 call to UNIVERSAL::VERSION |
13 | |||||
14 | 1 | 1µs | require Exporter ; | ||
15 | 1 | 1µs | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $RawInflateError); | ||
16 | |||||
17 | 1 | 900ns | $VERSION = '2.020'; | ||
18 | 1 | 300ns | $RawInflateError = ''; | ||
19 | |||||
20 | 1 | 24µs | @ISA = qw( Exporter IO::Uncompress::Base ); | ||
21 | 1 | 1µs | @EXPORT_OK = qw( $RawInflateError rawinflate ) ; | ||
22 | 1 | 500ns | %DEFLATE_CONSTANTS = (); | ||
23 | 1 | 2µs | %EXPORT_TAGS = %IO::Uncompress::Base::EXPORT_TAGS ; | ||
24 | 1 | 2µs | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | ||
25 | 1 | 4µs | 1 | 29µs | Exporter::export_ok_tags('all'); # spent 29µs making 1 call to Exporter::export_ok_tags |
26 | |||||
27 | #{ | ||||
28 | # # Execute at runtime | ||||
29 | # my %bad; | ||||
30 | # for my $module (qw(Compress::Raw::Zlib IO::Compress::Base::Common IO::Uncompress::Base IO::Uncompress::Adapter::Inflate)) | ||||
31 | # { | ||||
32 | # my $ver = ${ $module . "::VERSION"} ; | ||||
33 | # | ||||
34 | # $bad{$module} = $ver | ||||
35 | # if $ver ne $VERSION; | ||||
36 | # } | ||||
37 | # | ||||
38 | # if (keys %bad) | ||||
39 | # { | ||||
40 | # my $string = join "\n", map { "$_ $bad{$_}" } keys %bad; | ||||
41 | # die caller(0)[0] . "needs version $VERSION mismatch\n$string\n"; | ||||
42 | # } | ||||
43 | #} | ||||
44 | |||||
45 | sub new | ||||
46 | { | ||||
47 | my $class = shift ; | ||||
48 | my $obj = createSelfTiedObject($class, \$RawInflateError); | ||||
49 | $obj->_create(undef, 0, @_); | ||||
50 | } | ||||
51 | |||||
52 | sub rawinflate | ||||
53 | { | ||||
54 | my $obj = createSelfTiedObject(undef, \$RawInflateError); | ||||
55 | return $obj->_inf(@_); | ||||
56 | } | ||||
57 | |||||
58 | sub getExtraParams | ||||
59 | { | ||||
60 | return (); | ||||
61 | } | ||||
62 | |||||
63 | sub ckParams | ||||
64 | { | ||||
65 | my $self = shift ; | ||||
66 | my $got = shift ; | ||||
67 | |||||
68 | return 1; | ||||
69 | } | ||||
70 | |||||
71 | sub mkUncomp | ||||
72 | { | ||||
73 | my $self = shift ; | ||||
74 | my $got = shift ; | ||||
75 | |||||
76 | my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::Inflate::mkUncompObject( | ||||
77 | $got->value('CRC32'), | ||||
78 | $got->value('ADLER32'), | ||||
79 | $got->value('Scan'), | ||||
80 | ); | ||||
81 | |||||
82 | return $self->saveErrorString(undef, $errstr, $errno) | ||||
83 | if ! defined $obj; | ||||
84 | |||||
85 | *$self->{Uncomp} = $obj; | ||||
86 | |||||
87 | my $magic = $self->ckMagic() | ||||
88 | or return 0; | ||||
89 | |||||
90 | *$self->{Info} = $self->readHeader($magic) | ||||
91 | or return undef ; | ||||
92 | |||||
93 | return 1; | ||||
94 | |||||
95 | } | ||||
96 | |||||
97 | |||||
98 | sub ckMagic | ||||
99 | { | ||||
100 | my $self = shift; | ||||
101 | |||||
102 | return $self->_isRaw() ; | ||||
103 | } | ||||
104 | |||||
105 | sub readHeader | ||||
106 | { | ||||
107 | my $self = shift; | ||||
108 | my $magic = shift ; | ||||
109 | |||||
110 | return { | ||||
111 | 'Type' => 'rfc1951', | ||||
112 | 'FingerprintLength' => 0, | ||||
113 | 'HeaderLength' => 0, | ||||
114 | 'TrailerLength' => 0, | ||||
115 | 'Header' => '' | ||||
116 | }; | ||||
117 | } | ||||
118 | |||||
119 | sub chkTrailer | ||||
120 | { | ||||
121 | return STATUS_OK ; | ||||
122 | } | ||||
123 | |||||
124 | sub _isRaw | ||||
125 | { | ||||
126 | my $self = shift ; | ||||
127 | |||||
128 | my $got = $self->_isRawx(@_); | ||||
129 | |||||
130 | if ($got) { | ||||
131 | *$self->{Pending} = *$self->{HeaderPending} ; | ||||
132 | } | ||||
133 | else { | ||||
134 | $self->pushBack(*$self->{HeaderPending}); | ||||
135 | *$self->{Uncomp}->reset(); | ||||
136 | } | ||||
137 | *$self->{HeaderPending} = ''; | ||||
138 | |||||
139 | return $got ; | ||||
140 | } | ||||
141 | |||||
142 | sub _isRawx | ||||
143 | { | ||||
144 | my $self = shift ; | ||||
145 | my $magic = shift ; | ||||
146 | |||||
147 | $magic = '' unless defined $magic ; | ||||
148 | |||||
149 | my $buffer = ''; | ||||
150 | |||||
151 | $self->smartRead(\$buffer, *$self->{BlockSize}) >= 0 | ||||
152 | or return $self->saveErrorString(undef, "No data to read"); | ||||
153 | |||||
154 | my $temp_buf = $magic . $buffer ; | ||||
155 | *$self->{HeaderPending} = $temp_buf ; | ||||
156 | $buffer = ''; | ||||
157 | my $status = *$self->{Uncomp}->uncompr(\$temp_buf, \$buffer, $self->smartEof()) ; | ||||
158 | |||||
159 | return $self->saveErrorString(undef, *$self->{Uncomp}{Error}, STATUS_ERROR) | ||||
160 | if $status == STATUS_ERROR; | ||||
161 | |||||
162 | $self->pushBack($temp_buf) ; | ||||
163 | |||||
164 | return $self->saveErrorString(undef, "unexpected end of file", STATUS_ERROR) | ||||
165 | if $self->smartEof() && $status != STATUS_ENDSTREAM; | ||||
166 | |||||
167 | #my $buf_len = *$self->{Uncomp}->uncompressedBytes(); | ||||
168 | my $buf_len = length $buffer; | ||||
169 | |||||
170 | if ($status == STATUS_ENDSTREAM) { | ||||
171 | if (*$self->{MultiStream} | ||||
172 | && (length $temp_buf || ! $self->smartEof())){ | ||||
173 | *$self->{NewStream} = 1 ; | ||||
174 | *$self->{EndStream} = 0 ; | ||||
175 | } | ||||
176 | else { | ||||
177 | *$self->{EndStream} = 1 ; | ||||
178 | } | ||||
179 | } | ||||
180 | *$self->{HeaderPending} = $buffer ; | ||||
181 | *$self->{InflatedBytesRead} = $buf_len ; | ||||
182 | *$self->{TotalInflatedBytesRead} += $buf_len ; | ||||
183 | *$self->{Type} = 'rfc1951'; | ||||
184 | |||||
185 | $self->saveStatus(STATUS_OK); | ||||
186 | |||||
187 | return { | ||||
188 | 'Type' => 'rfc1951', | ||||
189 | 'HeaderLength' => 0, | ||||
190 | 'TrailerLength' => 0, | ||||
191 | 'Header' => '' | ||||
192 | }; | ||||
193 | } | ||||
194 | |||||
195 | |||||
196 | sub inflateSync | ||||
197 | { | ||||
198 | my $self = shift ; | ||||
199 | |||||
200 | # inflateSync is a no-op in Plain mode | ||||
201 | return 1 | ||||
202 | if *$self->{Plain} ; | ||||
203 | |||||
204 | return 0 if *$self->{Closed} ; | ||||
205 | #return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ; | ||||
206 | return 0 if ! length *$self->{Pending} && *$self->{EndStream} ; | ||||
207 | |||||
208 | # Disable CRC check | ||||
209 | *$self->{Strict} = 0 ; | ||||
210 | |||||
211 | my $status ; | ||||
212 | while (1) | ||||
213 | { | ||||
214 | my $temp_buf ; | ||||
215 | |||||
216 | if (length *$self->{Pending} ) | ||||
217 | { | ||||
218 | $temp_buf = *$self->{Pending} ; | ||||
219 | *$self->{Pending} = ''; | ||||
220 | } | ||||
221 | else | ||||
222 | { | ||||
223 | $status = $self->smartRead(\$temp_buf, *$self->{BlockSize}) ; | ||||
224 | return $self->saveErrorString(0, "Error Reading Data") | ||||
225 | if $status < 0 ; | ||||
226 | |||||
227 | if ($status == 0 ) { | ||||
228 | *$self->{EndStream} = 1 ; | ||||
229 | return $self->saveErrorString(0, "unexpected end of file", STATUS_ERROR); | ||||
230 | } | ||||
231 | } | ||||
232 | |||||
233 | $status = *$self->{Uncomp}->sync($temp_buf) ; | ||||
234 | |||||
235 | if ($status == STATUS_OK) | ||||
236 | { | ||||
237 | *$self->{Pending} .= $temp_buf ; | ||||
238 | return 1 ; | ||||
239 | } | ||||
240 | |||||
241 | last unless $status == STATUS_ERROR ; | ||||
242 | } | ||||
243 | |||||
244 | return 0; | ||||
245 | } | ||||
246 | |||||
247 | #sub performScan | ||||
248 | #{ | ||||
249 | # my $self = shift ; | ||||
250 | # | ||||
251 | # my $status ; | ||||
252 | # my $end_offset = 0; | ||||
253 | # | ||||
254 | # $status = $self->scan() | ||||
255 | # #or return $self->saveErrorString(undef, "Error Scanning: $$error_ref", $self->errorNo) ; | ||||
256 | # or return $self->saveErrorString(G_ERR, "Error Scanning: $status") | ||||
257 | # | ||||
258 | # $status = $self->zap($end_offset) | ||||
259 | # or return $self->saveErrorString(G_ERR, "Error Zapping: $status"); | ||||
260 | # #or return $self->saveErrorString(undef, "Error Zapping: $$error_ref", $self->errorNo) ; | ||||
261 | # | ||||
262 | # #(*$obj->{Deflate}, $status) = $inf->createDeflate(); | ||||
263 | # | ||||
264 | ## *$obj->{Header} = *$inf->{Info}{Header}; | ||||
265 | ## *$obj->{UnCompSize_32bit} = | ||||
266 | ## *$obj->{BytesWritten} = *$inf->{UnCompSize_32bit} ; | ||||
267 | ## *$obj->{CompSize_32bit} = *$inf->{CompSize_32bit} ; | ||||
268 | # | ||||
269 | # | ||||
270 | ## if ( $outType eq 'buffer') | ||||
271 | ## { substr( ${ *$self->{Buffer} }, $end_offset) = '' } | ||||
272 | ## elsif ($outType eq 'handle' || $outType eq 'filename') { | ||||
273 | ## *$self->{FH} = *$inf->{FH} ; | ||||
274 | ## delete *$inf->{FH}; | ||||
275 | ## *$obj->{FH}->flush() ; | ||||
276 | ## *$obj->{Handle} = 1 if $outType eq 'handle'; | ||||
277 | ## | ||||
278 | ## #seek(*$obj->{FH}, $end_offset, SEEK_SET) | ||||
279 | ## *$obj->{FH}->seek($end_offset, SEEK_SET) | ||||
280 | ## or return $obj->saveErrorString(undef, $!, $!) ; | ||||
281 | ## } | ||||
282 | # | ||||
283 | #} | ||||
284 | |||||
285 | sub scan | ||||
286 | { | ||||
287 | my $self = shift ; | ||||
288 | |||||
289 | return 1 if *$self->{Closed} ; | ||||
290 | return 1 if !length *$self->{Pending} && *$self->{EndStream} ; | ||||
291 | |||||
292 | my $buffer = '' ; | ||||
293 | my $len = 0; | ||||
294 | |||||
295 | $len = $self->_raw_read(\$buffer, 1) | ||||
296 | while ! *$self->{EndStream} && $len >= 0 ; | ||||
297 | |||||
298 | #return $len if $len < 0 ? $len : 0 ; | ||||
299 | return $len < 0 ? 0 : 1 ; | ||||
300 | } | ||||
301 | |||||
302 | sub zap | ||||
303 | { | ||||
304 | my $self = shift ; | ||||
305 | |||||
306 | my $headerLength = *$self->{Info}{HeaderLength}; | ||||
307 | my $block_offset = $headerLength + *$self->{Uncomp}->getLastBlockOffset(); | ||||
308 | $_[0] = $headerLength + *$self->{Uncomp}->getEndOffset(); | ||||
309 | #printf "# End $_[0], headerlen $headerLength \n";; | ||||
310 | #printf "# block_offset $block_offset %x\n", $block_offset; | ||||
311 | my $byte ; | ||||
312 | ( $self->smartSeek($block_offset) && | ||||
313 | $self->smartRead(\$byte, 1) ) | ||||
314 | or return $self->saveErrorString(0, $!, $!); | ||||
315 | |||||
316 | #printf "#byte is %x\n", unpack('C*',$byte); | ||||
317 | *$self->{Uncomp}->resetLastBlockByte($byte); | ||||
318 | #printf "#to byte is %x\n", unpack('C*',$byte); | ||||
319 | |||||
320 | ( $self->smartSeek($block_offset) && | ||||
321 | $self->smartWrite($byte) ) | ||||
322 | or return $self->saveErrorString(0, $!, $!); | ||||
323 | |||||
324 | #$self->smartSeek($end_offset, 1); | ||||
325 | |||||
326 | return 1 ; | ||||
327 | } | ||||
328 | |||||
329 | sub createDeflate | ||||
330 | { | ||||
331 | my $self = shift ; | ||||
332 | my ($def, $status) = *$self->{Uncomp}->createDeflateStream( | ||||
333 | -AppendOutput => 1, | ||||
334 | -WindowBits => - MAX_WBITS, | ||||
335 | -CRC32 => *$self->{Params}->value('CRC32'), | ||||
336 | -ADLER32 => *$self->{Params}->value('ADLER32'), | ||||
337 | ); | ||||
338 | |||||
339 | return wantarray ? ($status, $def) : $def ; | ||||
340 | } | ||||
341 | |||||
342 | |||||
343 | 1 | 10µs | 1; | ||
344 | |||||
345 | __END__ |