| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | package IO::Uncompress::Base ; | 
| 3 |  |  |  |  |  |  |  | 
| 4 | 84 |  |  | 84 |  | 585 | use strict ; | 
|  | 84 |  |  |  |  | 159 |  | 
|  | 84 |  |  |  |  | 2632 |  | 
| 5 | 84 |  |  | 84 |  | 409 | use warnings; | 
|  | 84 |  |  |  |  | 148 |  | 
|  | 84 |  |  |  |  | 2280 |  | 
| 6 | 84 |  |  | 84 |  | 407 | use bytes; | 
|  | 84 |  |  |  |  | 200 |  | 
|  | 84 |  |  |  |  | 431 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | our (@ISA, $VERSION, @EXPORT_OK, %EXPORT_TAGS); | 
| 9 |  |  |  |  |  |  | @ISA    = qw(IO::File Exporter); | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | $VERSION = '2.205'; | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 84 |  |  | 84 |  | 6678 | use constant G_EOF => 0 ; | 
|  | 84 |  |  |  |  | 224 |  | 
|  | 84 |  |  |  |  | 5663 |  | 
| 15 | 84 |  |  | 84 |  | 559 | use constant G_ERR => -1 ; | 
|  | 84 |  |  |  |  | 241 |  | 
|  | 84 |  |  |  |  | 4891 |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 | 84 |  |  | 84 |  | 608 | use IO::Compress::Base::Common 2.205 ; | 
|  | 84 |  |  |  |  | 1524 |  | 
|  | 84 |  |  |  |  | 14098 |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 84 |  |  | 84 |  | 17082 | use IO::File ; | 
|  | 84 |  |  |  |  | 101815 |  | 
|  | 84 |  |  |  |  | 11053 |  | 
| 20 | 84 |  |  | 84 |  | 629 | use Symbol; | 
|  | 84 |  |  |  |  | 177 |  | 
|  | 84 |  |  |  |  | 4352 |  | 
| 21 | 84 |  |  | 84 |  | 494 | use Scalar::Util (); | 
|  | 84 |  |  |  |  | 174 |  | 
|  | 84 |  |  |  |  | 1529 |  | 
| 22 | 84 |  |  | 84 |  | 462 | use List::Util (); | 
|  | 84 |  |  |  |  | 155 |  | 
|  | 84 |  |  |  |  | 1461 |  | 
| 23 | 84 |  |  | 84 |  | 411 | use Carp ; | 
|  | 84 |  |  |  |  | 191 |  | 
|  | 84 |  |  |  |  | 33341 |  | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | %EXPORT_TAGS = ( ); | 
| 26 |  |  |  |  |  |  | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sub smartRead | 
| 29 |  |  |  |  |  |  | { | 
| 30 | 44316 |  |  | 44316 | 0 | 61446 | my $self = $_[0]; | 
| 31 | 44316 |  |  |  |  | 56764 | my $out = $_[1]; | 
| 32 | 44316 |  |  |  |  | 58608 | my $size = $_[2]; | 
| 33 | 44316 |  |  |  |  | 63859 | $$out = "" ; | 
| 34 |  |  |  |  |  |  |  | 
| 35 | 44316 |  |  |  |  | 55549 | my $offset = 0 ; | 
| 36 | 44316 |  |  |  |  | 55192 | my $status = 1; | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 44316 | 100 |  |  |  | 84387 | if (defined *$self->{InputLength}) { | 
| 40 |  |  |  |  |  |  | return 0 | 
| 41 | 441 | 100 |  |  |  | 1077 | if *$self->{InputLengthRemaining} <= 0 ; | 
| 42 | 268 |  |  |  |  | 749 | $size = List::Util::min($size, *$self->{InputLengthRemaining}); | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  |  | 
| 45 | 44143 | 100 |  |  |  | 81299 | if ( length *$self->{Prime} ) { | 
| 46 | 14164 |  |  |  |  | 26377 | $$out = substr(*$self->{Prime}, 0, $size) ; | 
| 47 | 14164 |  |  |  |  | 24648 | substr(*$self->{Prime}, 0, $size) =  '' ; | 
| 48 | 14164 | 100 |  |  |  | 25433 | if (length $$out == $size) { | 
| 49 |  |  |  |  |  |  | *$self->{InputLengthRemaining} -= length $$out | 
| 50 | 11870 | 100 |  |  |  | 20603 | if defined *$self->{InputLength}; | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 11870 |  |  |  |  | 32157 | return length $$out ; | 
| 53 |  |  |  |  |  |  | } | 
| 54 | 2294 |  |  |  |  | 3261 | $offset = length $$out ; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 32273 |  |  |  |  | 46221 | my $get_size = $size - $offset ; | 
| 58 |  |  |  |  |  |  |  | 
| 59 | 32273 | 100 |  |  |  | 65738 | if (defined *$self->{FH}) { | 
|  |  | 50 |  |  |  |  |  | 
| 60 | 15871 | 100 |  |  |  | 26234 | if ($offset) { | 
| 61 |  |  |  |  |  |  | # Not using this | 
| 62 |  |  |  |  |  |  | # | 
| 63 |  |  |  |  |  |  | #  *$self->{FH}->read($$out, $get_size, $offset); | 
| 64 |  |  |  |  |  |  | # | 
| 65 |  |  |  |  |  |  | # because the filehandle may not support the offset parameter | 
| 66 |  |  |  |  |  |  | # An example is Net::FTP | 
| 67 | 2294 |  |  |  |  | 3446 | my $tmp = ''; | 
| 68 | 2294 |  |  |  |  | 7445 | $status = *$self->{FH}->read($tmp, $get_size) ; | 
| 69 | 2294 | 100 | 66 |  |  | 30730 | substr($$out, $offset) = $tmp | 
| 70 |  |  |  |  |  |  | if defined $status && $status > 0 ; | 
| 71 |  |  |  |  |  |  | } | 
| 72 |  |  |  |  |  |  | else | 
| 73 | 13577 |  |  |  |  | 36722 | { $status = *$self->{FH}->read($$out, $get_size) } | 
| 74 |  |  |  |  |  |  | } | 
| 75 |  |  |  |  |  |  | elsif (defined *$self->{InputEvent}) { | 
| 76 | 0 |  |  |  |  | 0 | my $got = 1 ; | 
| 77 | 0 |  |  |  |  | 0 | while (length $$out < $size) { | 
| 78 |  |  |  |  |  |  | last | 
| 79 | 0 | 0 |  |  |  | 0 | if ($got = *$self->{InputEvent}->($$out, $get_size)) <= 0; | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  |  | 
| 82 | 0 | 0 |  |  |  | 0 | if (length $$out > $size ) { | 
| 83 | 0 |  |  |  |  | 0 | *$self->{Prime} = substr($$out, $size, length($$out)); | 
| 84 | 0 |  |  |  |  | 0 | substr($$out, $size, length($$out)) =  ''; | 
| 85 |  |  |  |  |  |  | } | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 0 | 0 |  |  |  | 0 | *$self->{EventEof} = 1 if $got <= 0 ; | 
| 88 |  |  |  |  |  |  | } | 
| 89 |  |  |  |  |  |  | else { | 
| 90 | 84 |  |  | 84 |  | 678 | no warnings 'uninitialized'; | 
|  | 84 |  |  |  |  | 183 |  | 
|  | 84 |  |  |  |  | 164270 |  | 
| 91 | 16402 |  |  |  |  | 23095 | my $buf = *$self->{Buffer} ; | 
| 92 | 16402 | 50 |  |  |  | 28869 | $$buf = '' unless defined $$buf ; | 
| 93 | 16402 |  |  |  |  | 33132 | substr($$out, $offset) = substr($$buf, *$self->{BufferOffset}, $get_size); | 
| 94 | 16402 | 50 |  |  |  | 27775 | if (*$self->{ConsumeInput}) | 
| 95 | 0 |  |  |  |  | 0 | { substr($$buf, 0, $get_size) = '' } | 
| 96 |  |  |  |  |  |  | else | 
| 97 | 16402 |  |  |  |  | 27472 | { *$self->{BufferOffset} += length($$out) - $offset } | 
| 98 |  |  |  |  |  |  | } | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | *$self->{InputLengthRemaining} -= length($$out) #- $offset | 
| 101 | 32273 | 100 |  |  |  | 186261 | if defined *$self->{InputLength}; | 
| 102 |  |  |  |  |  |  |  | 
| 103 | 32273 | 50 |  |  |  | 57659 | if (! defined $status) { | 
| 104 | 0 |  |  |  |  | 0 | $self->saveStatus($!) ; | 
| 105 | 0 |  |  |  |  | 0 | return STATUS_ERROR; | 
| 106 |  |  |  |  |  |  | } | 
| 107 |  |  |  |  |  |  |  | 
| 108 | 32273 | 50 |  |  |  | 93674 | $self->saveStatus(length $$out < 0 ? STATUS_ERROR : STATUS_OK) ; | 
| 109 |  |  |  |  |  |  |  | 
| 110 | 32273 |  |  |  |  | 72281 | return length $$out; | 
| 111 |  |  |  |  |  |  | } | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | sub pushBack | 
| 114 |  |  |  |  |  |  | { | 
| 115 | 11591 |  |  | 11591 | 0 | 17239 | my $self = shift ; | 
| 116 |  |  |  |  |  |  |  | 
| 117 | 11591 | 100 | 66 |  |  | 42376 | return if ! defined $_[0] || length $_[0] == 0 ; | 
| 118 |  |  |  |  |  |  |  | 
| 119 | 8321 | 100 | 66 |  |  | 26463 | if (defined *$self->{FH} || defined *$self->{InputEvent} ) { | 
| 120 | 4510 |  |  |  |  | 11787 | *$self->{Prime} = $_[0] . *$self->{Prime} ; | 
| 121 | 4510 |  |  |  |  | 9988 | *$self->{InputLengthRemaining} += length($_[0]); | 
| 122 |  |  |  |  |  |  | } | 
| 123 |  |  |  |  |  |  | else { | 
| 124 | 3811 |  |  |  |  | 7128 | my $len = length $_[0]; | 
| 125 |  |  |  |  |  |  |  | 
| 126 | 3811 | 50 |  |  |  | 7645 | if($len > *$self->{BufferOffset}) { | 
| 127 | 0 |  |  |  |  | 0 | *$self->{Prime} = substr($_[0], 0, $len - *$self->{BufferOffset}) . *$self->{Prime} ; | 
| 128 | 0 |  |  |  |  | 0 | *$self->{InputLengthRemaining} = *$self->{InputLength}; | 
| 129 | 0 |  |  |  |  | 0 | *$self->{BufferOffset} = 0 | 
| 130 |  |  |  |  |  |  | } | 
| 131 |  |  |  |  |  |  | else { | 
| 132 | 3811 |  |  |  |  | 6288 | *$self->{InputLengthRemaining} += length($_[0]); | 
| 133 | 3811 |  |  |  |  | 7572 | *$self->{BufferOffset} -= length($_[0]) ; | 
| 134 |  |  |  |  |  |  | } | 
| 135 |  |  |  |  |  |  | } | 
| 136 |  |  |  |  |  |  | } | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | sub smartSeek | 
| 139 |  |  |  |  |  |  | { | 
| 140 | 120 |  |  | 120 | 0 | 174 | my $self   = shift ; | 
| 141 | 120 |  |  |  |  | 160 | my $offset = shift ; | 
| 142 | 120 |  |  |  |  | 186 | my $truncate = shift; | 
| 143 | 120 |  | 50 |  |  | 331 | my $position = shift || SEEK_SET; | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | # TODO -- need to take prime into account | 
| 146 | 120 |  |  |  |  | 239 | *$self->{Prime} = ''; | 
| 147 | 120 | 100 |  |  |  | 251 | if (defined *$self->{FH}) | 
| 148 | 72 |  |  |  |  | 288 | { *$self->{FH}->seek($offset, $position) } | 
| 149 |  |  |  |  |  |  | else { | 
| 150 | 48 | 50 |  |  |  | 131 | if ($position == SEEK_END) { | 
|  |  | 50 |  |  |  |  |  | 
| 151 | 0 |  |  |  |  | 0 | *$self->{BufferOffset} = length(${ *$self->{Buffer} }) + $offset ; | 
|  | 0 |  |  |  |  | 0 |  | 
| 152 |  |  |  |  |  |  | } | 
| 153 |  |  |  |  |  |  | elsif ($position == SEEK_CUR) { | 
| 154 | 0 |  |  |  |  | 0 | *$self->{BufferOffset} += $offset ; | 
| 155 |  |  |  |  |  |  | } | 
| 156 |  |  |  |  |  |  | else { | 
| 157 | 48 |  |  |  |  | 91 | *$self->{BufferOffset} = $offset ; | 
| 158 |  |  |  |  |  |  | } | 
| 159 |  |  |  |  |  |  |  | 
| 160 | 48 | 50 |  |  |  | 116 | substr(${ *$self->{Buffer} }, *$self->{BufferOffset}) = '' | 
|  | 0 |  |  |  |  | 0 |  | 
| 161 |  |  |  |  |  |  | if $truncate; | 
| 162 | 48 |  |  |  |  | 248 | return 1; | 
| 163 |  |  |  |  |  |  | } | 
| 164 |  |  |  |  |  |  | } | 
| 165 |  |  |  |  |  |  |  | 
| 166 |  |  |  |  |  |  | sub smartTell | 
| 167 |  |  |  |  |  |  | { | 
| 168 | 0 |  |  | 0 | 0 | 0 | my $self   = shift ; | 
| 169 |  |  |  |  |  |  |  | 
| 170 | 0 | 0 |  |  |  | 0 | if (defined *$self->{FH}) | 
| 171 | 0 |  |  |  |  | 0 | { return *$self->{FH}->tell() } | 
| 172 |  |  |  |  |  |  | else | 
| 173 | 0 |  |  |  |  | 0 | { return *$self->{BufferOffset} } | 
| 174 |  |  |  |  |  |  | } | 
| 175 |  |  |  |  |  |  |  | 
| 176 |  |  |  |  |  |  | sub smartWrite | 
| 177 |  |  |  |  |  |  | { | 
| 178 | 60 |  |  | 60 | 0 | 755 | my $self   = shift ; | 
| 179 | 60 |  |  |  |  | 113 | my $out_data = shift ; | 
| 180 |  |  |  |  |  |  |  | 
| 181 | 60 | 100 |  |  |  | 157 | if (defined *$self->{FH}) { | 
| 182 |  |  |  |  |  |  | # flush needed for 5.8.0 | 
| 183 |  |  |  |  |  |  | defined *$self->{FH}->write($out_data, length $out_data) && | 
| 184 | 36 | 50 |  |  |  | 139 | defined *$self->{FH}->flush() ; | 
| 185 |  |  |  |  |  |  | } | 
| 186 |  |  |  |  |  |  | else { | 
| 187 | 24 |  |  |  |  | 46 | my $buf = *$self->{Buffer} ; | 
| 188 | 24 |  |  |  |  | 55 | substr($$buf, *$self->{BufferOffset}, length $out_data) = $out_data ; | 
| 189 | 24 |  |  |  |  | 57 | *$self->{BufferOffset} += length($out_data) ; | 
| 190 | 24 |  |  |  |  | 78 | return 1; | 
| 191 |  |  |  |  |  |  | } | 
| 192 |  |  |  |  |  |  | } | 
| 193 |  |  |  |  |  |  |  | 
| 194 |  |  |  |  |  |  | sub smartReadExact | 
| 195 |  |  |  |  |  |  | { | 
| 196 | 23380 |  |  | 23380 | 0 | 43195 | return $_[0]->smartRead($_[1], $_[2]) == $_[2]; | 
| 197 |  |  |  |  |  |  | } | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  | sub smartEof | 
| 200 |  |  |  |  |  |  | { | 
| 201 | 14891 |  |  | 14891 | 0 | 26625 | my ($self) = $_[0]; | 
| 202 | 14891 |  |  |  |  | 45335 | local $.; | 
| 203 |  |  |  |  |  |  |  | 
| 204 | 14891 | 100 | 66 |  |  | 58770 | return 0 if length *$self->{Prime} || *$self->{PushMode}; | 
| 205 |  |  |  |  |  |  |  | 
| 206 | 13413 | 100 |  |  |  | 31523 | if (defined *$self->{FH}) | 
|  |  | 50 |  |  |  |  |  | 
| 207 |  |  |  |  |  |  | { | 
| 208 |  |  |  |  |  |  | # Could use | 
| 209 |  |  |  |  |  |  | # | 
| 210 |  |  |  |  |  |  | #  *$self->{FH}->eof() | 
| 211 |  |  |  |  |  |  | # | 
| 212 |  |  |  |  |  |  | # here, but this can cause trouble if | 
| 213 |  |  |  |  |  |  | # the filehandle is itself a tied handle, but it uses sysread. | 
| 214 |  |  |  |  |  |  | # Then we get into mixing buffered & non-buffered IO, | 
| 215 |  |  |  |  |  |  | # which will cause trouble | 
| 216 |  |  |  |  |  |  |  | 
| 217 | 7305 |  |  |  |  | 14601 | my $info = $self->getErrInfo(); | 
| 218 |  |  |  |  |  |  |  | 
| 219 | 7305 |  |  |  |  | 12195 | my $buffer = ''; | 
| 220 | 7305 |  |  |  |  | 15438 | my $status = $self->smartRead(\$buffer, 1); | 
| 221 | 7305 | 100 |  |  |  | 15621 | $self->pushBack($buffer) if length $buffer; | 
| 222 | 7305 |  |  |  |  | 16943 | $self->setErrInfo($info); | 
| 223 |  |  |  |  |  |  |  | 
| 224 | 7305 |  |  |  |  | 43482 | return $status == 0 ; | 
| 225 |  |  |  |  |  |  | } | 
| 226 |  |  |  |  |  |  | elsif (defined *$self->{InputEvent}) | 
| 227 | 0 |  |  |  |  | 0 | { *$self->{EventEof} } | 
| 228 |  |  |  |  |  |  | else | 
| 229 | 6108 |  |  |  |  | 8731 | { *$self->{BufferOffset} >= length(${ *$self->{Buffer} }) } | 
|  | 6108 |  |  |  |  | 30397 |  | 
| 230 |  |  |  |  |  |  | } | 
| 231 |  |  |  |  |  |  |  | 
| 232 |  |  |  |  |  |  | sub clearError | 
| 233 |  |  |  |  |  |  | { | 
| 234 | 273 |  |  | 273 | 0 | 513 | my $self   = shift ; | 
| 235 |  |  |  |  |  |  |  | 
| 236 | 273 |  |  |  |  | 528 | *$self->{ErrorNo}  =  0 ; | 
| 237 | 273 |  |  |  |  | 419 | ${ *$self->{Error} } = '' ; | 
|  | 273 |  |  |  |  | 618 |  | 
| 238 |  |  |  |  |  |  | } | 
| 239 |  |  |  |  |  |  |  | 
| 240 |  |  |  |  |  |  | sub getErrInfo | 
| 241 |  |  |  |  |  |  | { | 
| 242 | 7305 |  |  | 7305 | 0 | 10722 | my $self   = shift ; | 
| 243 |  |  |  |  |  |  |  | 
| 244 | 7305 |  |  |  |  | 11269 | return [ *$self->{ErrorNo}, ${ *$self->{Error} } ] ; | 
|  | 7305 |  |  |  |  | 21143 |  | 
| 245 |  |  |  |  |  |  | } | 
| 246 |  |  |  |  |  |  |  | 
| 247 |  |  |  |  |  |  | sub setErrInfo | 
| 248 |  |  |  |  |  |  | { | 
| 249 | 7305 |  |  | 7305 | 0 | 10256 | my $self   = shift ; | 
| 250 | 7305 |  |  |  |  | 9757 | my $ref    = shift; | 
| 251 |  |  |  |  |  |  |  | 
| 252 | 7305 |  |  |  |  | 12182 | *$self->{ErrorNo}  =  $ref->[0] ; | 
| 253 | 7305 |  |  |  |  | 10847 | ${ *$self->{Error} } = $ref->[1] ; | 
|  | 7305 |  |  |  |  | 14525 |  | 
| 254 |  |  |  |  |  |  | } | 
| 255 |  |  |  |  |  |  |  | 
| 256 |  |  |  |  |  |  | sub saveStatus | 
| 257 |  |  |  |  |  |  | { | 
| 258 | 43485 |  |  | 43485 | 0 | 61595 | my $self   = shift ; | 
| 259 | 43485 |  |  |  |  | 63709 | my $errno = shift() + 0 ; | 
| 260 |  |  |  |  |  |  |  | 
| 261 | 43485 |  |  |  |  | 65845 | *$self->{ErrorNo}  = $errno; | 
| 262 | 43485 |  |  |  |  | 56122 | ${ *$self->{Error} } = '' ; | 
|  | 43485 |  |  |  |  | 75891 |  | 
| 263 |  |  |  |  |  |  |  | 
| 264 | 43485 |  |  |  |  | 79733 | return *$self->{ErrorNo} ; | 
| 265 |  |  |  |  |  |  | } | 
| 266 |  |  |  |  |  |  |  | 
| 267 |  |  |  |  |  |  |  | 
| 268 |  |  |  |  |  |  | sub saveErrorString | 
| 269 |  |  |  |  |  |  | { | 
| 270 | 3415 |  |  | 3415 | 0 | 6034 | my $self   = shift ; | 
| 271 | 3415 |  |  |  |  | 4724 | my $retval = shift ; | 
| 272 |  |  |  |  |  |  |  | 
| 273 | 3415 |  |  |  |  | 4658 | ${ *$self->{Error} } = shift ; | 
|  | 3415 |  |  |  |  | 7277 |  | 
| 274 | 3415 | 100 |  |  |  | 8770 | *$self->{ErrorNo} = @_ ? shift() + 0 : STATUS_ERROR ; | 
| 275 |  |  |  |  |  |  |  | 
| 276 | 3415 |  |  |  |  | 10315 | return $retval; | 
| 277 |  |  |  |  |  |  | } | 
| 278 |  |  |  |  |  |  |  | 
| 279 |  |  |  |  |  |  | sub croakError | 
| 280 |  |  |  |  |  |  | { | 
| 281 | 95 |  |  | 95 | 0 | 227 | my $self   = shift ; | 
| 282 | 95 |  |  |  |  | 389 | $self->saveErrorString(0, $_[0]); | 
| 283 | 95 |  |  |  |  | 15273 | croak $_[0]; | 
| 284 |  |  |  |  |  |  | } | 
| 285 |  |  |  |  |  |  |  | 
| 286 |  |  |  |  |  |  |  | 
| 287 |  |  |  |  |  |  | sub closeError | 
| 288 |  |  |  |  |  |  | { | 
| 289 | 18 |  |  | 18 | 0 | 36 | my $self = shift ; | 
| 290 | 18 |  |  |  |  | 28 | my $retval = shift ; | 
| 291 |  |  |  |  |  |  |  | 
| 292 | 18 |  |  |  |  | 44 | my $errno = *$self->{ErrorNo}; | 
| 293 | 18 |  |  |  |  | 28 | my $error = ${ *$self->{Error} }; | 
|  | 18 |  |  |  |  | 43 |  | 
| 294 |  |  |  |  |  |  |  | 
| 295 | 18 |  |  |  |  | 66 | $self->close(); | 
| 296 |  |  |  |  |  |  |  | 
| 297 | 18 |  |  |  |  | 43 | *$self->{ErrorNo} = $errno ; | 
| 298 | 18 |  |  |  |  | 38 | ${ *$self->{Error} } = $error ; | 
|  | 18 |  |  |  |  | 47 |  | 
| 299 |  |  |  |  |  |  |  | 
| 300 | 18 |  |  |  |  | 64 | return $retval; | 
| 301 |  |  |  |  |  |  | } | 
| 302 |  |  |  |  |  |  |  | 
| 303 |  |  |  |  |  |  | sub error | 
| 304 |  |  |  |  |  |  | { | 
| 305 | 2109 |  |  | 2109 | 1 | 260851 | my $self   = shift ; | 
| 306 | 2109 |  |  |  |  | 3221 | return ${ *$self->{Error} } ; | 
|  | 2109 |  |  |  |  | 8271 |  | 
| 307 |  |  |  |  |  |  | } | 
| 308 |  |  |  |  |  |  |  | 
| 309 |  |  |  |  |  |  | sub errorNo | 
| 310 |  |  |  |  |  |  | { | 
| 311 | 171 |  |  | 171 | 0 | 258 | my $self   = shift ; | 
| 312 | 171 |  |  |  |  | 595 | return *$self->{ErrorNo}; | 
| 313 |  |  |  |  |  |  | } | 
| 314 |  |  |  |  |  |  |  | 
| 315 |  |  |  |  |  |  | sub HeaderError | 
| 316 |  |  |  |  |  |  | { | 
| 317 | 2058 |  |  | 2058 | 0 | 3877 | my ($self) = shift; | 
| 318 | 2058 |  |  |  |  | 5932 | return $self->saveErrorString(undef, "Header Error: $_[0]", STATUS_ERROR); | 
| 319 |  |  |  |  |  |  | } | 
| 320 |  |  |  |  |  |  |  | 
| 321 |  |  |  |  |  |  | sub TrailerError | 
| 322 |  |  |  |  |  |  | { | 
| 323 | 18 |  |  | 18 | 0 | 42 | my ($self) = shift; | 
| 324 | 18 |  |  |  |  | 72 | return $self->saveErrorString(G_ERR, "Trailer Error: $_[0]", STATUS_ERROR); | 
| 325 |  |  |  |  |  |  | } | 
| 326 |  |  |  |  |  |  |  | 
| 327 |  |  |  |  |  |  | sub TruncatedHeader | 
| 328 |  |  |  |  |  |  | { | 
| 329 | 16 |  |  | 16 | 0 | 31 | my ($self) = shift; | 
| 330 | 16 |  |  |  |  | 49 | return $self->HeaderError("Truncated in $_[0] Section"); | 
| 331 |  |  |  |  |  |  | } | 
| 332 |  |  |  |  |  |  |  | 
| 333 |  |  |  |  |  |  | sub TruncatedTrailer | 
| 334 |  |  |  |  |  |  | { | 
| 335 | 0 |  |  | 0 | 0 | 0 | my ($self) = shift; | 
| 336 | 0 |  |  |  |  | 0 | return $self->TrailerError("Truncated in $_[0] Section"); | 
| 337 |  |  |  |  |  |  | } | 
| 338 |  |  |  |  |  |  |  | 
| 339 |  |  |  |  |  |  | sub postCheckParams | 
| 340 |  |  |  |  |  |  | { | 
| 341 | 3500 |  |  | 3500 | 0 | 7420 | return 1; | 
| 342 |  |  |  |  |  |  | } | 
| 343 |  |  |  |  |  |  |  | 
| 344 |  |  |  |  |  |  | sub checkParams | 
| 345 |  |  |  |  |  |  | { | 
| 346 | 3532 |  |  | 3532 | 0 | 5541 | my $self = shift ; | 
| 347 | 3532 |  |  |  |  | 5298 | my $class = shift ; | 
| 348 |  |  |  |  |  |  |  | 
| 349 | 3532 |  | 33 |  |  | 11772 | my $got = shift || IO::Compress::Base::Parameters::new(); | 
| 350 |  |  |  |  |  |  |  | 
| 351 | 3532 |  |  |  |  | 22391 | my $Valid = { | 
| 352 |  |  |  |  |  |  | 'blocksize'     => [IO::Compress::Base::Common::Parse_unsigned, 16 * 1024], | 
| 353 |  |  |  |  |  |  | 'autoclose'     => [IO::Compress::Base::Common::Parse_boolean,  0], | 
| 354 |  |  |  |  |  |  | 'strict'        => [IO::Compress::Base::Common::Parse_boolean,  0], | 
| 355 |  |  |  |  |  |  | 'append'        => [IO::Compress::Base::Common::Parse_boolean,  0], | 
| 356 |  |  |  |  |  |  | 'prime'         => [IO::Compress::Base::Common::Parse_any,      undef], | 
| 357 |  |  |  |  |  |  | 'multistream'   => [IO::Compress::Base::Common::Parse_boolean,  0], | 
| 358 |  |  |  |  |  |  | 'transparent'   => [IO::Compress::Base::Common::Parse_any,      1], | 
| 359 |  |  |  |  |  |  | 'scan'          => [IO::Compress::Base::Common::Parse_boolean,  0], | 
| 360 |  |  |  |  |  |  | 'inputlength'   => [IO::Compress::Base::Common::Parse_unsigned, undef], | 
| 361 |  |  |  |  |  |  | 'binmodeout'    => [IO::Compress::Base::Common::Parse_boolean,  0], | 
| 362 |  |  |  |  |  |  | #'decode'        => [IO::Compress::Base::Common::Parse_any,      undef], | 
| 363 |  |  |  |  |  |  |  | 
| 364 |  |  |  |  |  |  | #'consumeinput'  => [IO::Compress::Base::Common::Parse_boolean,  0], | 
| 365 |  |  |  |  |  |  |  | 
| 366 |  |  |  |  |  |  | $self->getExtraParams(), | 
| 367 |  |  |  |  |  |  |  | 
| 368 |  |  |  |  |  |  | #'Todo - Revert to ordinary file on end Z_STREAM_END'=> 0, | 
| 369 |  |  |  |  |  |  | # ContinueAfterEof | 
| 370 |  |  |  |  |  |  | } ; | 
| 371 |  |  |  |  |  |  |  | 
| 372 |  |  |  |  |  |  | $Valid->{trailingdata} = [IO::Compress::Base::Common::Parse_writable_scalar, undef] | 
| 373 | 3532 | 100 |  |  |  | 12042 | if  *$self->{OneShot} ; | 
| 374 |  |  |  |  |  |  |  | 
| 375 | 3532 | 100 |  |  |  | 11292 | $got->parse($Valid, @_ ) | 
| 376 |  |  |  |  |  |  | or $self->croakError("${class}: " . $got->getError()) ; | 
| 377 |  |  |  |  |  |  |  | 
| 378 | 3500 | 50 |  |  |  | 9538 | $self->postCheckParams($got) | 
| 379 |  |  |  |  |  |  | or $self->croakError("${class}: " . $self->error()) ; | 
| 380 |  |  |  |  |  |  |  | 
| 381 | 3500 |  |  |  |  | 19675 | return $got; | 
| 382 |  |  |  |  |  |  | } | 
| 383 |  |  |  |  |  |  |  | 
| 384 |  |  |  |  |  |  | sub _create | 
| 385 |  |  |  |  |  |  | { | 
| 386 | 3647 |  |  | 3647 |  | 6181 | my $obj = shift; | 
| 387 | 3647 |  |  |  |  | 5481 | my $got = shift; | 
| 388 | 3647 |  |  |  |  | 5765 | my $append_mode = shift ; | 
| 389 |  |  |  |  |  |  |  | 
| 390 | 3647 |  |  |  |  | 6475 | my $class = ref $obj; | 
| 391 | 3647 | 50 | 66 |  |  | 8685 | $obj->croakError("$class: Missing Input parameter") | 
| 392 |  |  |  |  |  |  | if ! @_ && ! $got ; | 
| 393 |  |  |  |  |  |  |  | 
| 394 | 3642 |  |  |  |  | 5676 | my $inValue = shift ; | 
| 395 |  |  |  |  |  |  |  | 
| 396 | 3642 |  |  |  |  | 6764 | *$obj->{OneShot} = 0 ; | 
| 397 |  |  |  |  |  |  |  | 
| 398 | 3642 | 100 |  |  |  | 7805 | if (! $got) | 
| 399 |  |  |  |  |  |  | { | 
| 400 | 2964 | 50 |  |  |  | 7570 | $got = $obj->checkParams($class, undef, @_) | 
| 401 |  |  |  |  |  |  | or return undef ; | 
| 402 |  |  |  |  |  |  | } | 
| 403 |  |  |  |  |  |  |  | 
| 404 | 3630 |  |  |  |  | 10085 | my $inType  = whatIsInput($inValue, 1); | 
| 405 |  |  |  |  |  |  |  | 
| 406 | 3630 | 50 |  |  |  | 10117 | $obj->ckInputParam($class, $inValue, 1) | 
| 407 |  |  |  |  |  |  | or return undef ; | 
| 408 |  |  |  |  |  |  |  | 
| 409 | 3625 |  |  |  |  | 8103 | *$obj->{InNew} = 1; | 
| 410 |  |  |  |  |  |  |  | 
| 411 |  |  |  |  |  |  | $obj->ckParams($got) | 
| 412 | 3625 | 50 |  |  |  | 11222 | or $obj->croakError("${class}: " . *$obj->{Error}); | 
| 413 |  |  |  |  |  |  |  | 
| 414 | 3625 | 100 | 66 |  |  | 12888 | if ($inType eq 'buffer' || $inType eq 'code') { | 
| 415 | 1450 |  |  |  |  | 3278 | *$obj->{Buffer} = $inValue ; | 
| 416 | 1450 | 50 |  |  |  | 3301 | *$obj->{InputEvent} = $inValue | 
| 417 |  |  |  |  |  |  | if $inType eq 'code' ; | 
| 418 |  |  |  |  |  |  | } | 
| 419 |  |  |  |  |  |  | else { | 
| 420 | 2175 | 100 |  |  |  | 5677 | if ($inType eq 'handle') { | 
| 421 | 468 |  |  |  |  | 1193 | *$obj->{FH} = $inValue ; | 
| 422 | 468 |  |  |  |  | 982 | *$obj->{Handle} = 1 ; | 
| 423 |  |  |  |  |  |  |  | 
| 424 |  |  |  |  |  |  | # Need to rewind for Scan | 
| 425 | 468 | 100 |  |  |  | 1205 | *$obj->{FH}->seek(0, SEEK_SET) | 
| 426 |  |  |  |  |  |  | if $got->getValue('scan'); | 
| 427 |  |  |  |  |  |  | } | 
| 428 |  |  |  |  |  |  | else { | 
| 429 | 84 |  |  | 84 |  | 713 | no warnings ; | 
|  | 84 |  |  |  |  | 247 |  | 
|  | 84 |  |  |  |  | 446925 |  | 
| 430 | 1707 |  |  |  |  | 3031 | my $mode = '<'; | 
| 431 | 1707 | 100 |  |  |  | 4203 | $mode = '+<' if $got->getValue('scan'); | 
| 432 | 1707 |  |  |  |  | 4387 | *$obj->{StdIO} = ($inValue eq '-'); | 
| 433 | 1707 | 100 |  |  |  | 10012 | *$obj->{FH} = IO::File->new( "$mode $inValue" ) | 
| 434 |  |  |  |  |  |  | or return $obj->saveErrorString(undef, "cannot open file '$inValue': $!", $!) ; | 
| 435 |  |  |  |  |  |  | } | 
| 436 |  |  |  |  |  |  |  | 
| 437 | 2170 |  |  |  |  | 148543 | *$obj->{LineNo} = $. = 0; | 
| 438 | 2170 |  |  |  |  | 8737 | setBinModeInput(*$obj->{FH}) ; | 
| 439 |  |  |  |  |  |  |  | 
| 440 | 2170 |  |  |  |  | 4248 | my $buff = "" ; | 
| 441 | 2170 |  |  |  |  | 5853 | *$obj->{Buffer} = \$buff ; | 
| 442 |  |  |  |  |  |  | } | 
| 443 |  |  |  |  |  |  |  | 
| 444 |  |  |  |  |  |  | #    if ($got->getValue('decode')) { | 
| 445 |  |  |  |  |  |  | #        my $want_encoding = $got->getValue('decode'); | 
| 446 |  |  |  |  |  |  | #        *$obj->{Encoding} = IO::Compress::Base::Common::getEncoding($obj, $class, $want_encoding); | 
| 447 |  |  |  |  |  |  | #    } | 
| 448 |  |  |  |  |  |  | #    else { | 
| 449 |  |  |  |  |  |  | #        *$obj->{Encoding} = undef; | 
| 450 |  |  |  |  |  |  | #    } | 
| 451 |  |  |  |  |  |  |  | 
| 452 | 3620 | 100 |  |  |  | 10182 | *$obj->{InputLength}       = $got->parsed('inputlength') | 
| 453 |  |  |  |  |  |  | ? $got->getValue('inputlength') | 
| 454 |  |  |  |  |  |  | : undef ; | 
| 455 | 3620 |  |  |  |  | 8694 | *$obj->{InputLengthRemaining} = $got->getValue('inputlength'); | 
| 456 | 3620 |  |  |  |  | 7148 | *$obj->{BufferOffset}      = 0 ; | 
| 457 | 3620 |  |  |  |  | 7952 | *$obj->{AutoClose}         = $got->getValue('autoclose'); | 
| 458 | 3620 |  |  |  |  | 7735 | *$obj->{Strict}            = $got->getValue('strict'); | 
| 459 | 3620 |  |  |  |  | 7575 | *$obj->{BlockSize}         = $got->getValue('blocksize'); | 
| 460 | 3620 |  |  |  |  | 7419 | *$obj->{Append}            = $got->getValue('append'); | 
| 461 | 3620 |  | 100 |  |  | 11237 | *$obj->{AppendOutput}      = $append_mode || $got->getValue('append'); | 
| 462 | 3620 |  |  |  |  | 7649 | *$obj->{ConsumeInput}      = $got->getValue('consumeinput'); | 
| 463 | 3620 |  |  |  |  | 7801 | *$obj->{Transparent}       = $got->getValue('transparent'); | 
| 464 | 3620 |  |  |  |  | 7817 | *$obj->{MultiStream}       = $got->getValue('multistream'); | 
| 465 |  |  |  |  |  |  |  | 
| 466 |  |  |  |  |  |  | # TODO - move these two into RawDeflate | 
| 467 | 3620 |  |  |  |  | 7280 | *$obj->{Scan}              = $got->getValue('scan'); | 
| 468 | 3620 |  | 100 |  |  | 7459 | *$obj->{ParseExtra}        = $got->getValue('parseextra') | 
| 469 |  |  |  |  |  |  | || $got->getValue('strict')  ; | 
| 470 | 3620 |  |  |  |  | 7711 | *$obj->{Type}              = ''; | 
| 471 | 3620 |  | 50 |  |  | 7610 | *$obj->{Prime}             = $got->getValue('prime') || '' ; | 
| 472 | 3620 |  |  |  |  | 6847 | *$obj->{Pending}           = ''; | 
| 473 | 3620 |  |  |  |  | 5925 | *$obj->{Plain}             = 0; | 
| 474 | 3620 |  |  |  |  | 6151 | *$obj->{PlainBytesRead}    = 0; | 
| 475 | 3620 |  |  |  |  | 6995 | *$obj->{InflatedBytesRead} = 0; | 
| 476 | 3620 |  |  |  |  | 15830 | *$obj->{UnCompSize}        = U64->new; | 
| 477 | 3620 |  |  |  |  | 9060 | *$obj->{CompSize}          = U64->new; | 
| 478 | 3620 |  |  |  |  | 7137 | *$obj->{TotalInflatedBytesRead} = 0; | 
| 479 | 3620 |  |  |  |  | 8716 | *$obj->{NewStream}         = 0 ; | 
| 480 | 3620 |  |  |  |  | 6013 | *$obj->{EventEof}          = 0 ; | 
| 481 | 3620 |  |  |  |  | 6752 | *$obj->{ClassName}         = $class ; | 
| 482 | 3620 |  |  |  |  | 8187 | *$obj->{Params}            = $got ; | 
| 483 |  |  |  |  |  |  |  | 
| 484 | 3620 | 50 |  |  |  | 7939 | if (*$obj->{ConsumeInput}) { | 
| 485 | 0 |  |  |  |  | 0 | *$obj->{InNew} = 0; | 
| 486 | 0 |  |  |  |  | 0 | *$obj->{Closed} = 0; | 
| 487 | 0 |  |  |  |  | 0 | return $obj | 
| 488 |  |  |  |  |  |  | } | 
| 489 |  |  |  |  |  |  |  | 
| 490 | 3620 |  |  |  |  | 11571 | my $status = $obj->mkUncomp($got); | 
| 491 |  |  |  |  |  |  |  | 
| 492 |  |  |  |  |  |  | return undef | 
| 493 | 3619 | 100 |  |  |  | 8788 | unless defined $status; | 
| 494 |  |  |  |  |  |  |  | 
| 495 | 3592 |  |  |  |  | 6381 | *$obj->{InNew} = 0; | 
| 496 | 3592 |  |  |  |  | 5719 | *$obj->{Closed} = 0; | 
| 497 |  |  |  |  |  |  |  | 
| 498 |  |  |  |  |  |  | return $obj | 
| 499 | 3592 | 50 |  |  |  | 7742 | if *$obj->{Pause} ; | 
| 500 |  |  |  |  |  |  |  | 
| 501 | 3592 | 100 |  |  |  | 7053 | if ($status) { | 
| 502 |  |  |  |  |  |  | # Need to try uncompressing to catch the case | 
| 503 |  |  |  |  |  |  | # where the compressed file uncompresses to an | 
| 504 |  |  |  |  |  |  | # empty string - so eof is set immediately. | 
| 505 |  |  |  |  |  |  |  | 
| 506 | 3291 |  |  |  |  | 5295 | my $out_buffer = ''; | 
| 507 |  |  |  |  |  |  |  | 
| 508 | 3291 |  |  |  |  | 8968 | $status = $obj->read(\$out_buffer); | 
| 509 |  |  |  |  |  |  |  | 
| 510 | 3291 | 100 |  |  |  | 7347 | if ($status < 0) { | 
| 511 | 6 |  |  |  |  | 30 | *$obj->{ReadStatus} = [ $status, $obj->error(), $obj->errorNo() ]; | 
| 512 |  |  |  |  |  |  | } | 
| 513 |  |  |  |  |  |  |  | 
| 514 | 3291 | 100 |  |  |  | 10142 | $obj->ungetc($out_buffer) | 
| 515 |  |  |  |  |  |  | if length $out_buffer; | 
| 516 |  |  |  |  |  |  | } | 
| 517 |  |  |  |  |  |  | else { | 
| 518 |  |  |  |  |  |  | return undef | 
| 519 | 301 | 100 |  |  |  | 1018 | unless *$obj->{Transparent}; | 
| 520 |  |  |  |  |  |  |  | 
| 521 | 270 |  |  |  |  | 1070 | $obj->clearError(); | 
| 522 | 270 |  |  |  |  | 593 | *$obj->{Type} = 'plain'; | 
| 523 | 270 |  |  |  |  | 508 | *$obj->{Plain} = 1; | 
| 524 | 270 |  |  |  |  | 718 | $obj->pushBack(*$obj->{HeaderPending})  ; | 
| 525 |  |  |  |  |  |  | } | 
| 526 |  |  |  |  |  |  |  | 
| 527 | 3561 |  |  |  |  | 5322 | push @{ *$obj->{InfoList} }, *$obj->{Info} ; | 
|  | 3561 |  |  |  |  | 11031 |  | 
| 528 |  |  |  |  |  |  |  | 
| 529 | 3561 |  |  |  |  | 9447 | $obj->saveStatus(STATUS_OK) ; | 
| 530 | 3561 |  |  |  |  | 5866 | *$obj->{InNew} = 0; | 
| 531 | 3561 |  |  |  |  | 5695 | *$obj->{Closed} = 0; | 
| 532 |  |  |  |  |  |  |  | 
| 533 | 3561 |  |  |  |  | 12408 | return $obj; | 
| 534 |  |  |  |  |  |  | } | 
| 535 |  |  |  |  |  |  |  | 
| 536 |  |  |  |  |  |  | sub ckInputParam | 
| 537 |  |  |  |  |  |  | { | 
| 538 | 3630 |  |  | 3630 | 0 | 6394 | my $self = shift ; | 
| 539 | 3630 |  |  |  |  | 5553 | my $from = shift ; | 
| 540 | 3630 |  |  |  |  | 8116 | my $inType = whatIsInput($_[0], $_[1]); | 
| 541 |  |  |  |  |  |  |  | 
| 542 | 3630 | 100 |  |  |  | 8362 | $self->croakError("$from: input parameter not a filename, filehandle, array ref or scalar ref") | 
| 543 |  |  |  |  |  |  | if ! $inType ; | 
| 544 |  |  |  |  |  |  |  | 
| 545 |  |  |  |  |  |  | #    if ($inType  eq 'filename' ) | 
| 546 |  |  |  |  |  |  | #    { | 
| 547 |  |  |  |  |  |  | #        return $self->saveErrorString(1, "$from: input filename is undef or null string", STATUS_ERROR) | 
| 548 |  |  |  |  |  |  | #            if ! defined $_[0] || $_[0] eq ''  ; | 
| 549 |  |  |  |  |  |  | # | 
| 550 |  |  |  |  |  |  | #        if ($_[0] ne '-' && ! -e $_[0] ) | 
| 551 |  |  |  |  |  |  | #        { | 
| 552 |  |  |  |  |  |  | #            return $self->saveErrorString(1, | 
| 553 |  |  |  |  |  |  | #                            "input file '$_[0]' does not exist", STATUS_ERROR); | 
| 554 |  |  |  |  |  |  | #        } | 
| 555 |  |  |  |  |  |  | #    } | 
| 556 |  |  |  |  |  |  |  | 
| 557 | 3625 |  |  |  |  | 8401 | return 1; | 
| 558 |  |  |  |  |  |  | } | 
| 559 |  |  |  |  |  |  |  | 
| 560 |  |  |  |  |  |  |  | 
| 561 |  |  |  |  |  |  | sub _inf | 
| 562 |  |  |  |  |  |  | { | 
| 563 | 728 |  |  | 728 |  | 1298 | my $obj = shift ; | 
| 564 |  |  |  |  |  |  |  | 
| 565 | 728 |  |  |  |  | 2052 | my $class = (caller)[0] ; | 
| 566 | 728 |  |  |  |  | 4879 | my $name = (caller(1))[3] ; | 
| 567 |  |  |  |  |  |  |  | 
| 568 | 728 | 100 |  |  |  | 2420 | $obj->croakError("$name: expected at least 1 parameters\n") | 
| 569 |  |  |  |  |  |  | unless @_ >= 1 ; | 
| 570 |  |  |  |  |  |  |  | 
| 571 | 718 |  |  |  |  | 1311 | my $input = shift ; | 
| 572 | 718 |  |  |  |  | 1085 | my $haveOut = @_ ; | 
| 573 | 718 |  |  |  |  | 1075 | my $output = shift ; | 
| 574 |  |  |  |  |  |  |  | 
| 575 |  |  |  |  |  |  |  | 
| 576 | 718 | 100 |  |  |  | 5017 | my $x = IO::Compress::Base::Validator->new($class, *$obj->{Error}, $name, $input, $output) | 
| 577 |  |  |  |  |  |  | or return undef ; | 
| 578 |  |  |  |  |  |  |  | 
| 579 | 568 | 50 | 33 |  |  | 2608 | push @_, $output if $haveOut && $x->{Hash}; | 
| 580 |  |  |  |  |  |  |  | 
| 581 | 568 |  |  |  |  | 1476 | *$obj->{OneShot} = 1 ; | 
| 582 |  |  |  |  |  |  |  | 
| 583 | 568 | 50 |  |  |  | 2035 | my $got = $obj->checkParams($name, undef, @_) | 
| 584 |  |  |  |  |  |  | or return undef ; | 
| 585 |  |  |  |  |  |  |  | 
| 586 | 548 | 100 |  |  |  | 1756 | if ($got->parsed('trailingdata')) | 
| 587 |  |  |  |  |  |  | { | 
| 588 |  |  |  |  |  |  | #        my $value = $got->valueRef('TrailingData'); | 
| 589 |  |  |  |  |  |  | #        warn "TD $value "; | 
| 590 |  |  |  |  |  |  | #        #$value = $$value; | 
| 591 |  |  |  |  |  |  | ##                warn "TD $value $$value "; | 
| 592 |  |  |  |  |  |  | # | 
| 593 |  |  |  |  |  |  | #        return retErr($obj, "Parameter 'TrailingData' not writable") | 
| 594 |  |  |  |  |  |  | #            if readonly $$value ; | 
| 595 |  |  |  |  |  |  | # | 
| 596 |  |  |  |  |  |  | #        if (ref $$value) | 
| 597 |  |  |  |  |  |  | #        { | 
| 598 |  |  |  |  |  |  | #            return retErr($obj,"Parameter 'TrailingData' not a scalar reference") | 
| 599 |  |  |  |  |  |  | #                if ref $$value ne 'SCALAR' ; | 
| 600 |  |  |  |  |  |  | # | 
| 601 |  |  |  |  |  |  | #            *$obj->{TrailingData} = $$value ; | 
| 602 |  |  |  |  |  |  | #        } | 
| 603 |  |  |  |  |  |  | #        else | 
| 604 |  |  |  |  |  |  | #        { | 
| 605 |  |  |  |  |  |  | #            return retErr($obj,"Parameter 'TrailingData' not a scalar") | 
| 606 |  |  |  |  |  |  | #                if ref $value ne 'SCALAR' ; | 
| 607 |  |  |  |  |  |  | # | 
| 608 |  |  |  |  |  |  | #            *$obj->{TrailingData} = $value ; | 
| 609 |  |  |  |  |  |  | #        } | 
| 610 |  |  |  |  |  |  |  | 
| 611 | 10 |  |  |  |  | 67 | *$obj->{TrailingData} = $got->getValue('trailingdata'); | 
| 612 |  |  |  |  |  |  | } | 
| 613 |  |  |  |  |  |  |  | 
| 614 | 548 |  |  |  |  | 1485 | *$obj->{MultiStream} = $got->getValue('multistream'); | 
| 615 | 548 |  |  |  |  | 1860 | $got->setValue('multistream', 0); | 
| 616 |  |  |  |  |  |  |  | 
| 617 | 548 |  |  |  |  | 1646 | $x->{Got} = $got ; | 
| 618 |  |  |  |  |  |  |  | 
| 619 |  |  |  |  |  |  | #    if ($x->{Hash}) | 
| 620 |  |  |  |  |  |  | #    { | 
| 621 |  |  |  |  |  |  | #        while (my($k, $v) = each %$input) | 
| 622 |  |  |  |  |  |  | #        { | 
| 623 |  |  |  |  |  |  | #            $v = \$input->{$k} | 
| 624 |  |  |  |  |  |  | #                unless defined $v ; | 
| 625 |  |  |  |  |  |  | # | 
| 626 |  |  |  |  |  |  | #            $obj->_singleTarget($x, $k, $v, @_) | 
| 627 |  |  |  |  |  |  | #                or return undef ; | 
| 628 |  |  |  |  |  |  | #        } | 
| 629 |  |  |  |  |  |  | # | 
| 630 |  |  |  |  |  |  | #        return keys %$input ; | 
| 631 |  |  |  |  |  |  | #    } | 
| 632 |  |  |  |  |  |  |  | 
| 633 | 548 | 100 |  |  |  | 1355 | if ($x->{GlobMap}) | 
| 634 |  |  |  |  |  |  | { | 
| 635 | 10 |  |  |  |  | 36 | $x->{oneInput} = 1 ; | 
| 636 | 10 |  |  |  |  | 23 | foreach my $pair (@{ $x->{Pairs} }) | 
|  | 10 |  |  |  |  | 41 |  | 
| 637 |  |  |  |  |  |  | { | 
| 638 | 30 |  |  |  |  | 80 | my ($from, $to) = @$pair ; | 
| 639 | 30 | 50 |  |  |  | 96 | $obj->_singleTarget($x, $from, $to, @_) | 
| 640 |  |  |  |  |  |  | or return undef ; | 
| 641 |  |  |  |  |  |  | } | 
| 642 |  |  |  |  |  |  |  | 
| 643 | 10 |  |  |  |  | 43 | return scalar @{ $x->{Pairs} } ; | 
|  | 10 |  |  |  |  | 165 |  | 
| 644 |  |  |  |  |  |  | } | 
| 645 |  |  |  |  |  |  |  | 
| 646 | 538 | 100 |  |  |  | 1337 | if (! $x->{oneOutput} ) | 
| 647 |  |  |  |  |  |  | { | 
| 648 |  |  |  |  |  |  | my $inFile = ($x->{inType} eq 'filenames' | 
| 649 | 40 |  | 66 |  |  | 262 | || $x->{inType} eq 'filename'); | 
| 650 |  |  |  |  |  |  |  | 
| 651 | 40 | 100 |  |  |  | 152 | $x->{inType} = $inFile ? 'filename' : 'buffer'; | 
| 652 |  |  |  |  |  |  |  | 
| 653 | 40 | 100 |  |  |  | 161 | foreach my $in ($x->{oneInput} ? $input : @$input) | 
| 654 |  |  |  |  |  |  | { | 
| 655 | 70 |  |  |  |  | 114 | my $out ; | 
| 656 | 70 |  |  |  |  | 132 | $x->{oneInput} = 1 ; | 
| 657 |  |  |  |  |  |  |  | 
| 658 | 70 | 50 |  |  |  | 212 | $obj->_singleTarget($x, $in, $output, @_) | 
| 659 |  |  |  |  |  |  | or return undef ; | 
| 660 |  |  |  |  |  |  | } | 
| 661 |  |  |  |  |  |  |  | 
| 662 | 40 |  |  |  |  | 441 | return 1 ; | 
| 663 |  |  |  |  |  |  | } | 
| 664 |  |  |  |  |  |  |  | 
| 665 |  |  |  |  |  |  | # finally the 1 to 1 and n to 1 | 
| 666 | 498 |  |  |  |  | 1702 | return $obj->_singleTarget($x, $input, $output, @_); | 
| 667 |  |  |  |  |  |  |  | 
| 668 | 0 |  |  |  |  | 0 | croak "should not be here" ; | 
| 669 |  |  |  |  |  |  | } | 
| 670 |  |  |  |  |  |  |  | 
| 671 |  |  |  |  |  |  | sub retErr | 
| 672 |  |  |  |  |  |  | { | 
| 673 | 10 |  |  | 10 | 0 | 703 | my $x = shift ; | 
| 674 | 10 |  |  |  |  | 21 | my $string = shift ; | 
| 675 |  |  |  |  |  |  |  | 
| 676 | 10 |  |  |  |  | 22 | ${ $x->{Error} } = $string ; | 
|  | 10 |  |  |  |  | 25 |  | 
| 677 |  |  |  |  |  |  |  | 
| 678 | 10 |  |  |  |  | 113 | return undef ; | 
| 679 |  |  |  |  |  |  | } | 
| 680 |  |  |  |  |  |  |  | 
| 681 |  |  |  |  |  |  | sub _singleTarget | 
| 682 |  |  |  |  |  |  | { | 
| 683 | 598 |  |  | 598 |  | 1020 | my $self      = shift ; | 
| 684 | 598 |  |  |  |  | 851 | my $x         = shift ; | 
| 685 | 598 |  |  |  |  | 1265 | my $input     = shift; | 
| 686 | 598 |  |  |  |  | 896 | my $output    = shift; | 
| 687 |  |  |  |  |  |  |  | 
| 688 | 598 |  |  |  |  | 1133 | my $buff = ''; | 
| 689 | 598 |  |  |  |  | 1228 | $x->{buff} = \$buff ; | 
| 690 |  |  |  |  |  |  |  | 
| 691 | 598 |  |  |  |  | 915 | my $fh ; | 
| 692 | 598 | 100 |  |  |  | 2276 | if ($x->{outType} eq 'filename') { | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
| 693 | 130 |  |  |  |  | 256 | my $mode = '>' ; | 
| 694 |  |  |  |  |  |  | $mode = '>>' | 
| 695 | 130 | 100 |  |  |  | 418 | if $x->{Got}->getValue('append') ; | 
| 696 | 130 | 100 |  |  |  | 848 | $x->{fh} = IO::File->new( "$mode $output" ) | 
| 697 |  |  |  |  |  |  | or return retErr($x, "cannot open file '$output': $!") ; | 
| 698 | 120 |  |  |  |  | 13099 | binmode $x->{fh} ; | 
| 699 |  |  |  |  |  |  |  | 
| 700 |  |  |  |  |  |  | } | 
| 701 |  |  |  |  |  |  |  | 
| 702 |  |  |  |  |  |  | elsif ($x->{outType} eq 'handle') { | 
| 703 | 85 |  |  |  |  | 258 | $x->{fh} = $output; | 
| 704 | 85 |  |  |  |  | 292 | binmode $x->{fh} ; | 
| 705 | 85 | 100 |  |  |  | 235 | if ($x->{Got}->getValue('append')) { | 
| 706 | 30 | 50 |  |  |  | 392 | seek($x->{fh}, 0, SEEK_END) | 
| 707 |  |  |  |  |  |  | or return retErr($x, "Cannot seek to end of output filehandle: $!") ; | 
| 708 |  |  |  |  |  |  | } | 
| 709 |  |  |  |  |  |  | } | 
| 710 |  |  |  |  |  |  |  | 
| 711 |  |  |  |  |  |  |  | 
| 712 |  |  |  |  |  |  | elsif ($x->{outType} eq 'buffer' ) | 
| 713 |  |  |  |  |  |  | { | 
| 714 |  |  |  |  |  |  | $$output = '' | 
| 715 | 313 | 100 |  |  |  | 917 | unless $x->{Got}->getValue('append'); | 
| 716 | 313 |  |  |  |  | 737 | $x->{buff} = $output ; | 
| 717 |  |  |  |  |  |  | } | 
| 718 |  |  |  |  |  |  |  | 
| 719 | 588 | 100 |  |  |  | 1443 | if ($x->{oneInput}) | 
| 720 |  |  |  |  |  |  | { | 
| 721 | 528 | 100 |  |  |  | 1519 | defined $self->_rd2($x, $input, $output) | 
| 722 |  |  |  |  |  |  | or return undef; | 
| 723 |  |  |  |  |  |  | } | 
| 724 |  |  |  |  |  |  | else | 
| 725 |  |  |  |  |  |  | { | 
| 726 | 60 | 50 |  |  |  | 214 | for my $element ( ($x->{inType} eq 'hash') ? keys %$input : @$input) | 
| 727 |  |  |  |  |  |  | { | 
| 728 | 150 | 50 |  |  |  | 434 | defined $self->_rd2($x, $element, $output) | 
| 729 |  |  |  |  |  |  | or return undef ; | 
| 730 |  |  |  |  |  |  | } | 
| 731 |  |  |  |  |  |  | } | 
| 732 |  |  |  |  |  |  |  | 
| 733 |  |  |  |  |  |  |  | 
| 734 | 556 | 100 | 66 |  |  | 3591 | if ( ($x->{outType} eq 'filename' && $output ne '-') || | 
|  |  |  | 100 |  |  |  |  | 
|  |  |  | 100 |  |  |  |  | 
| 735 |  |  |  |  |  |  | ($x->{outType} eq 'handle' && $x->{Got}->getValue('autoclose'))) { | 
| 736 |  |  |  |  |  |  | $x->{fh}->close() | 
| 737 | 190 | 50 |  |  |  | 636 | or return retErr($x, $!); | 
| 738 | 190 |  |  |  |  | 9234 | delete $x->{fh}; | 
| 739 |  |  |  |  |  |  | } | 
| 740 |  |  |  |  |  |  |  | 
| 741 | 556 |  |  |  |  | 5705 | return 1 ; | 
| 742 |  |  |  |  |  |  | } | 
| 743 |  |  |  |  |  |  |  | 
| 744 |  |  |  |  |  |  | sub _rd2 | 
| 745 |  |  |  |  |  |  | { | 
| 746 | 678 |  |  | 678 |  | 1098 | my $self      = shift ; | 
| 747 | 678 |  |  |  |  | 1337 | my $x         = shift ; | 
| 748 | 678 |  |  |  |  | 1002 | my $input     = shift; | 
| 749 | 678 |  |  |  |  | 953 | my $output    = shift; | 
| 750 |  |  |  |  |  |  |  | 
| 751 | 678 |  |  |  |  | 2102 | my $z = IO::Compress::Base::Common::createSelfTiedObject($x->{Class}, *$self->{Error}); | 
| 752 |  |  |  |  |  |  |  | 
| 753 | 678 | 100 |  |  |  | 2173 | $z->_create($x->{Got}, 1, $input, @_) | 
| 754 |  |  |  |  |  |  | or return undef ; | 
| 755 |  |  |  |  |  |  |  | 
| 756 | 664 |  |  |  |  | 958 | my $status ; | 
| 757 | 664 |  |  |  |  | 1252 | my $fh = $x->{fh}; | 
| 758 |  |  |  |  |  |  |  | 
| 759 | 664 |  |  |  |  | 1057 | while (1) { | 
| 760 |  |  |  |  |  |  |  | 
| 761 | 682 |  |  |  |  | 1572 | while (($status = $z->read($x->{buff})) > 0) { | 
| 762 | 728 | 100 |  |  |  | 1954 | if ($fh) { | 
| 763 | 265 |  |  |  |  | 869 | local $\; | 
| 764 | 265 | 50 |  |  |  | 446 | print $fh ${ $x->{buff} } | 
|  | 265 |  |  |  |  | 2185 |  | 
| 765 |  |  |  |  |  |  | or return $z->saveErrorString(undef, "Error writing to output file: $!", $!); | 
| 766 | 265 |  |  |  |  | 540 | ${ $x->{buff} } = '' ; | 
|  | 265 |  |  |  |  | 920 |  | 
| 767 |  |  |  |  |  |  | } | 
| 768 |  |  |  |  |  |  | } | 
| 769 |  |  |  |  |  |  |  | 
| 770 | 682 | 100 |  |  |  | 1859 | if (! $x->{oneOutput} ) { | 
| 771 | 100 |  |  |  |  | 240 | my $ot = $x->{outType} ; | 
| 772 |  |  |  |  |  |  |  | 
| 773 | 100 | 100 |  |  |  | 324 | if ($ot eq 'array') | 
|  |  | 50 |  |  |  |  |  | 
| 774 | 70 |  |  |  |  | 164 | { push @$output, $x->{buff} } | 
| 775 |  |  |  |  |  |  | elsif ($ot eq 'hash') | 
| 776 | 0 |  |  |  |  | 0 | { $output->{$input} = $x->{buff} } | 
| 777 |  |  |  |  |  |  |  | 
| 778 | 100 |  |  |  |  | 168 | my $buff = ''; | 
| 779 | 100 |  |  |  |  | 221 | $x->{buff} = \$buff; | 
| 780 |  |  |  |  |  |  | } | 
| 781 |  |  |  |  |  |  |  | 
| 782 | 682 | 100 | 100 |  |  | 2603 | last if $status < 0 || $z->smartEof(); | 
| 783 |  |  |  |  |  |  |  | 
| 784 |  |  |  |  |  |  | last | 
| 785 | 56 | 100 |  |  |  | 215 | unless *$self->{MultiStream}; | 
| 786 |  |  |  |  |  |  |  | 
| 787 | 18 |  |  |  |  | 114 | $status = $z->nextStream(); | 
| 788 |  |  |  |  |  |  |  | 
| 789 |  |  |  |  |  |  | last | 
| 790 | 18 | 50 |  |  |  | 56 | unless $status == 1 ; | 
| 791 |  |  |  |  |  |  | } | 
| 792 |  |  |  |  |  |  |  | 
| 793 | 664 | 100 |  |  |  | 1687 | return $z->closeError(undef) | 
| 794 |  |  |  |  |  |  | if $status < 0 ; | 
| 795 |  |  |  |  |  |  |  | 
| 796 | 10 |  |  |  |  | 26 | ${ *$self->{TrailingData} } = $z->trailingData() | 
| 797 | 646 | 100 |  |  |  | 1546 | if defined *$self->{TrailingData} ; | 
| 798 |  |  |  |  |  |  |  | 
| 799 | 646 | 50 |  |  |  | 1832 | $z->close() | 
| 800 |  |  |  |  |  |  | or return undef ; | 
| 801 |  |  |  |  |  |  |  | 
| 802 | 646 |  |  |  |  | 1936 | return 1 ; | 
| 803 |  |  |  |  |  |  | } | 
| 804 |  |  |  |  |  |  |  | 
| 805 |  |  |  |  |  |  | sub TIEHANDLE | 
| 806 |  |  |  |  |  |  | { | 
| 807 | 4375 | 50 |  | 4375 |  | 20847 | return $_[0] if ref($_[0]); | 
| 808 | 0 |  |  |  |  | 0 | die "OOPS\n" ; | 
| 809 |  |  |  |  |  |  |  | 
| 810 |  |  |  |  |  |  | } | 
| 811 |  |  |  |  |  |  |  | 
| 812 |  |  |  |  |  |  | sub UNTIE | 
| 813 |  |  |  |  |  |  | { | 
| 814 | 3580 |  |  | 3580 |  | 10065 | my $self = shift ; | 
| 815 |  |  |  |  |  |  | } | 
| 816 |  |  |  |  |  |  |  | 
| 817 |  |  |  |  |  |  |  | 
| 818 |  |  |  |  |  |  | sub getHeaderInfo | 
| 819 |  |  |  |  |  |  | { | 
| 820 | 235 |  |  | 235 | 0 | 8792 | my $self = shift ; | 
| 821 | 235 | 100 |  |  |  | 808 | wantarray ? @{ *$self->{InfoList} } : *$self->{Info}; | 
|  | 90 |  |  |  |  | 344 |  | 
| 822 |  |  |  |  |  |  | } | 
| 823 |  |  |  |  |  |  |  | 
| 824 |  |  |  |  |  |  | sub readBlock | 
| 825 |  |  |  |  |  |  | { | 
| 826 | 4827 |  |  | 4827 | 0 | 7175 | my $self = shift ; | 
| 827 | 4827 |  |  |  |  | 6670 | my $buff = shift ; | 
| 828 | 4827 |  |  |  |  | 6672 | my $size = shift ; | 
| 829 |  |  |  |  |  |  |  | 
| 830 | 4827 | 100 |  |  |  | 9924 | if (defined *$self->{CompressedInputLength}) { | 
| 831 | 101 | 100 |  |  |  | 255 | if (*$self->{CompressedInputLengthRemaining} == 0) { | 
| 832 | 22 |  |  |  |  | 56 | delete *$self->{CompressedInputLength}; | 
| 833 | 22 |  |  |  |  | 57 | *$self->{CompressedInputLengthDone} = 1; | 
| 834 | 22 |  |  |  |  | 54 | return STATUS_OK ; | 
| 835 |  |  |  |  |  |  | } | 
| 836 | 79 |  |  |  |  | 270 | $size = List::Util::min($size, *$self->{CompressedInputLengthRemaining} ); | 
| 837 | 79 |  |  |  |  | 142 | *$self->{CompressedInputLengthRemaining} -= $size ; | 
| 838 |  |  |  |  |  |  | } | 
| 839 |  |  |  |  |  |  |  | 
| 840 | 4805 |  |  |  |  | 12136 | my $status = $self->smartRead($buff, $size) ; | 
| 841 | 4805 | 50 |  |  |  | 10244 | return $self->saveErrorString(STATUS_ERROR, "Error Reading Data: $!", $!) | 
| 842 |  |  |  |  |  |  | if $status == STATUS_ERROR  ; | 
| 843 |  |  |  |  |  |  |  | 
| 844 | 4805 | 100 |  |  |  | 9725 | if ($status == 0 ) { | 
| 845 | 12 |  |  |  |  | 57 | *$self->{Closed} = 1 ; | 
| 846 | 12 |  |  |  |  | 30 | *$self->{EndStream} = 1 ; | 
| 847 | 12 |  |  |  |  | 41 | return $self->saveErrorString(STATUS_ERROR, "unexpected end of file", STATUS_ERROR); | 
| 848 |  |  |  |  |  |  | } | 
| 849 |  |  |  |  |  |  |  | 
| 850 | 4793 |  |  |  |  | 7802 | return STATUS_OK; | 
| 851 |  |  |  |  |  |  | } | 
| 852 |  |  |  |  |  |  |  | 
| 853 |  |  |  |  |  |  | sub postBlockChk | 
| 854 |  |  |  |  |  |  | { | 
| 855 | 4811 |  |  | 4811 | 0 | 10422 | return STATUS_OK; | 
| 856 |  |  |  |  |  |  | } | 
| 857 |  |  |  |  |  |  |  | 
| 858 |  |  |  |  |  |  | sub _raw_read | 
| 859 |  |  |  |  |  |  | { | 
| 860 |  |  |  |  |  |  | # return codes | 
| 861 |  |  |  |  |  |  | # >0 - ok, number of bytes read | 
| 862 |  |  |  |  |  |  | # =0 - ok, eof | 
| 863 |  |  |  |  |  |  | # <0 - not ok | 
| 864 |  |  |  |  |  |  |  | 
| 865 | 6544 |  |  | 6544 |  | 10525 | my $self = shift ; | 
| 866 |  |  |  |  |  |  |  | 
| 867 | 6544 | 50 |  |  |  | 13621 | return G_EOF if *$self->{Closed} ; | 
| 868 | 6544 | 50 |  |  |  | 12906 | return G_EOF if *$self->{EndStream} ; | 
| 869 |  |  |  |  |  |  |  | 
| 870 | 6544 |  |  |  |  | 9500 | my $buffer = shift ; | 
| 871 | 6544 |  |  |  |  | 8994 | my $scan_mode = shift ; | 
| 872 |  |  |  |  |  |  |  | 
| 873 | 6544 | 100 |  |  |  | 13257 | if (*$self->{Plain}) { | 
| 874 | 541 |  |  |  |  | 851 | my $tmp_buff ; | 
| 875 | 541 |  |  |  |  | 1498 | my $len = $self->smartRead(\$tmp_buff, *$self->{BlockSize}) ; | 
| 876 |  |  |  |  |  |  |  | 
| 877 | 541 | 50 |  |  |  | 1550 | return $self->saveErrorString(G_ERR, "Error reading data: $!", $!) | 
| 878 |  |  |  |  |  |  | if $len == STATUS_ERROR ; | 
| 879 |  |  |  |  |  |  |  | 
| 880 | 541 | 100 |  |  |  | 1223 | if ($len == 0 ) { | 
| 881 | 260 |  |  |  |  | 595 | *$self->{EndStream} = 1 ; | 
| 882 |  |  |  |  |  |  | } | 
| 883 |  |  |  |  |  |  | else { | 
| 884 | 281 |  |  |  |  | 537 | *$self->{PlainBytesRead} += $len ; | 
| 885 | 281 |  |  |  |  | 1623 | $$buffer .= $tmp_buff; | 
| 886 |  |  |  |  |  |  | } | 
| 887 |  |  |  |  |  |  |  | 
| 888 | 541 |  |  |  |  | 1593 | return $len ; | 
| 889 |  |  |  |  |  |  | } | 
| 890 |  |  |  |  |  |  |  | 
| 891 | 6003 | 100 |  |  |  | 11608 | if (*$self->{NewStream}) { | 
| 892 |  |  |  |  |  |  |  | 
| 893 | 1176 | 50 |  |  |  | 2492 | $self->gotoNextStream() > 0 | 
| 894 |  |  |  |  |  |  | or return G_ERR; | 
| 895 |  |  |  |  |  |  |  | 
| 896 |  |  |  |  |  |  | # For the headers that actually uncompressed data, put the | 
| 897 |  |  |  |  |  |  | # uncompressed data into the output buffer. | 
| 898 | 1176 |  |  |  |  | 2653 | $$buffer .=  *$self->{Pending} ; | 
| 899 | 1176 |  |  |  |  | 1977 | my $len = length  *$self->{Pending} ; | 
| 900 | 1176 |  |  |  |  | 1937 | *$self->{Pending} = ''; | 
| 901 | 1176 |  |  |  |  | 3075 | return $len; | 
| 902 |  |  |  |  |  |  | } | 
| 903 |  |  |  |  |  |  |  | 
| 904 | 4827 |  |  |  |  | 7467 | my $temp_buf = ''; | 
| 905 | 4827 |  |  |  |  | 6587 | my $outSize = 0; | 
| 906 | 4827 |  |  |  |  | 11582 | my $status = $self->readBlock(\$temp_buf, *$self->{BlockSize}, $outSize) ; | 
| 907 |  |  |  |  |  |  |  | 
| 908 | 4827 | 100 |  |  |  | 9371 | return G_ERR | 
| 909 |  |  |  |  |  |  | if $status == STATUS_ERROR  ; | 
| 910 |  |  |  |  |  |  |  | 
| 911 | 4815 |  |  |  |  | 6808 | my $buf_len = 0; | 
| 912 | 4815 | 50 |  |  |  | 9412 | if ($status == STATUS_OK) { | 
| 913 | 4815 |  |  |  |  | 6855 | my $beforeC_len = length $temp_buf; | 
| 914 | 4815 | 50 |  |  |  | 10143 | my $before_len = defined $$buffer ? length $$buffer : 0 ; | 
| 915 |  |  |  |  |  |  | $status = *$self->{Uncomp}->uncompr(\$temp_buf, $buffer, | 
| 916 |  |  |  |  |  |  | defined *$self->{CompressedInputLengthDone} || | 
| 917 | 4815 |  | 100 |  |  | 17329 | $self->smartEof(), $outSize); | 
| 918 |  |  |  |  |  |  |  | 
| 919 |  |  |  |  |  |  | # Remember the input buffer if it wasn't consumed completely | 
| 920 | 4815 | 50 |  |  |  | 33322 | $self->pushBack($temp_buf) if *$self->{Uncomp}{ConsumesInput}; | 
| 921 |  |  |  |  |  |  |  | 
| 922 |  |  |  |  |  |  | return $self->saveErrorString(G_ERR, *$self->{Uncomp}{Error}, *$self->{Uncomp}{ErrorNo}) | 
| 923 | 4815 | 100 |  |  |  | 9560 | if $self->saveStatus($status) == STATUS_ERROR; | 
| 924 |  |  |  |  |  |  |  | 
| 925 | 4811 | 50 |  |  |  | 10880 | $self->postBlockChk($buffer, $before_len) == STATUS_OK | 
| 926 |  |  |  |  |  |  | or return G_ERR; | 
| 927 |  |  |  |  |  |  |  | 
| 928 | 4811 | 50 |  |  |  | 11257 | $buf_len = defined $$buffer ? length($$buffer) - $before_len : 0; | 
| 929 |  |  |  |  |  |  |  | 
| 930 | 4811 |  |  |  |  | 19564 | *$self->{CompSize}->add($beforeC_len - length $temp_buf) ; | 
| 931 |  |  |  |  |  |  |  | 
| 932 | 4811 |  |  |  |  | 8449 | *$self->{InflatedBytesRead} += $buf_len ; | 
| 933 | 4811 |  |  |  |  | 7201 | *$self->{TotalInflatedBytesRead} += $buf_len ; | 
| 934 | 4811 |  |  |  |  | 12856 | *$self->{UnCompSize}->add($buf_len) ; | 
| 935 |  |  |  |  |  |  |  | 
| 936 | 4811 |  |  |  |  | 11552 | $self->filterUncompressed($buffer, $before_len); | 
| 937 |  |  |  |  |  |  |  | 
| 938 |  |  |  |  |  |  | #        if (*$self->{Encoding}) { | 
| 939 |  |  |  |  |  |  | #            use Encode ; | 
| 940 |  |  |  |  |  |  | #            *$self->{PendingDecode} .= substr($$buffer, $before_len) ; | 
| 941 |  |  |  |  |  |  | #            my $got = *$self->{Encoding}->decode(*$self->{PendingDecode}, Encode::FB_QUIET) ; | 
| 942 |  |  |  |  |  |  | #            substr($$buffer, $before_len) = $got; | 
| 943 |  |  |  |  |  |  | #        } | 
| 944 |  |  |  |  |  |  | } | 
| 945 |  |  |  |  |  |  |  | 
| 946 | 4811 | 100 |  |  |  | 9810 | if ($status == STATUS_ENDSTREAM) { | 
| 947 |  |  |  |  |  |  |  | 
| 948 | 3968 |  |  |  |  | 7314 | *$self->{EndStream} = 1 ; | 
| 949 |  |  |  |  |  |  |  | 
| 950 | 3968 |  |  |  |  | 5512 | my $trailer; | 
| 951 | 3968 |  |  |  |  | 6924 | my $trailer_size = *$self->{Info}{TrailerLength} ; | 
| 952 | 3968 |  |  |  |  | 5430 | my $got = 0; | 
| 953 | 3968 | 100 |  |  |  | 8141 | if (*$self->{Info}{TrailerLength}) | 
| 954 |  |  |  |  |  |  | { | 
| 955 | 2824 |  |  |  |  | 5976 | $got = $self->smartRead(\$trailer, $trailer_size) ; | 
| 956 |  |  |  |  |  |  | } | 
| 957 |  |  |  |  |  |  |  | 
| 958 | 3968 | 100 |  |  |  | 8759 | if ($got == $trailer_size) { | 
| 959 | 3924 | 100 |  |  |  | 11454 | $self->chkTrailer($trailer) == STATUS_OK | 
| 960 |  |  |  |  |  |  | or return G_ERR; | 
| 961 |  |  |  |  |  |  | } | 
| 962 |  |  |  |  |  |  | else { | 
| 963 |  |  |  |  |  |  | return $self->TrailerError("trailer truncated. Expected " . | 
| 964 |  |  |  |  |  |  | "$trailer_size bytes, got $got") | 
| 965 | 44 | 100 |  |  |  | 169 | if *$self->{Strict}; | 
| 966 | 32 |  |  |  |  | 72 | $self->pushBack($trailer)  ; | 
| 967 |  |  |  |  |  |  | } | 
| 968 |  |  |  |  |  |  |  | 
| 969 |  |  |  |  |  |  | # TODO - if want file pointer, do it here | 
| 970 |  |  |  |  |  |  |  | 
| 971 | 3950 | 100 |  |  |  | 8536 | if (! $self->smartEof()) { | 
| 972 | 1378 |  |  |  |  | 2772 | *$self->{NewStream} = 1 ; | 
| 973 |  |  |  |  |  |  |  | 
| 974 | 1378 | 100 |  |  |  | 3094 | if (*$self->{MultiStream}) { | 
| 975 | 942 |  |  |  |  | 1767 | *$self->{EndStream} = 0 ; | 
| 976 | 942 |  |  |  |  | 3603 | return $buf_len ; | 
| 977 |  |  |  |  |  |  | } | 
| 978 |  |  |  |  |  |  | } | 
| 979 |  |  |  |  |  |  |  | 
| 980 |  |  |  |  |  |  | } | 
| 981 |  |  |  |  |  |  |  | 
| 982 |  |  |  |  |  |  |  | 
| 983 |  |  |  |  |  |  | # return the number of uncompressed bytes read | 
| 984 | 3851 |  |  |  |  | 13216 | return $buf_len ; | 
| 985 |  |  |  |  |  |  | } | 
| 986 |  |  |  |  |  |  |  | 
| 987 |  |  |  |  |  |  | sub reset | 
| 988 |  |  |  |  |  |  | { | 
| 989 | 1773 |  |  | 1773 | 0 | 2610 | my $self = shift ; | 
| 990 |  |  |  |  |  |  |  | 
| 991 | 1773 |  |  |  |  | 5419 | return *$self->{Uncomp}->reset(); | 
| 992 |  |  |  |  |  |  | } | 
| 993 |  |  |  |  |  |  |  | 
| 994 |  |  |  |  |  |  | sub filterUncompressed | 
| 995 |  |  |  | 3591 | 0 |  | { | 
| 996 |  |  |  |  |  |  | } | 
| 997 |  |  |  |  |  |  |  | 
| 998 |  |  |  |  |  |  | #sub isEndStream | 
| 999 |  |  |  |  |  |  | #{ | 
| 1000 |  |  |  |  |  |  | #    my $self = shift ; | 
| 1001 |  |  |  |  |  |  | #    return *$self->{NewStream} || | 
| 1002 |  |  |  |  |  |  | #           *$self->{EndStream} ; | 
| 1003 |  |  |  |  |  |  | #} | 
| 1004 |  |  |  |  |  |  |  | 
| 1005 |  |  |  |  |  |  | sub nextStream | 
| 1006 |  |  |  |  |  |  | { | 
| 1007 | 598 |  |  | 598 | 0 | 52205 | my $self = shift ; | 
| 1008 |  |  |  |  |  |  |  | 
| 1009 |  |  |  |  |  |  | # An uncompressed file cannot have a next stream, so | 
| 1010 |  |  |  |  |  |  | # return immediately. | 
| 1011 |  |  |  |  |  |  | return 0 | 
| 1012 | 598 | 100 |  |  |  | 1863 | if *$self->{Plain} ; | 
| 1013 |  |  |  |  |  |  |  | 
| 1014 | 597 |  |  |  |  | 1315 | my $status = $self->gotoNextStream(); | 
| 1015 | 597 | 100 |  |  |  | 1772 | $status == 1 | 
| 1016 |  |  |  |  |  |  | or return $status ; | 
| 1017 |  |  |  |  |  |  |  | 
| 1018 |  |  |  |  |  |  | *$self->{Pending} = '' | 
| 1019 | 406 | 50 | 66 |  |  | 2619 | if $self !~ /IO::Uncompress::RawInflate/ && ! *$self->{MultiStream}; | 
| 1020 |  |  |  |  |  |  |  | 
| 1021 | 406 |  |  |  |  | 830 | *$self->{TotalInflatedBytesRead} = 0 ; | 
| 1022 | 406 |  |  |  |  | 1179 | *$self->{LineNo} = $. = 0; | 
| 1023 |  |  |  |  |  |  |  | 
| 1024 | 406 |  |  |  |  | 1435 | return 1; | 
| 1025 |  |  |  |  |  |  | } | 
| 1026 |  |  |  |  |  |  |  | 
| 1027 |  |  |  |  |  |  | sub gotoNextStream | 
| 1028 |  |  |  |  |  |  | { | 
| 1029 | 1773 |  |  | 1773 | 0 | 2792 | my $self = shift ; | 
| 1030 |  |  |  |  |  |  |  | 
| 1031 | 1773 | 100 |  |  |  | 3950 | if (! *$self->{NewStream}) { | 
| 1032 | 271 |  |  |  |  | 517 | my $status = 1; | 
| 1033 | 271 |  |  |  |  | 419 | my $buffer ; | 
| 1034 |  |  |  |  |  |  |  | 
| 1035 |  |  |  |  |  |  | # TODO - make this more efficient if know the offset for the end of | 
| 1036 |  |  |  |  |  |  | # the stream and seekable | 
| 1037 | 271 |  |  |  |  | 995 | $status = $self->read($buffer) | 
| 1038 |  |  |  |  |  |  | while $status > 0 ; | 
| 1039 |  |  |  |  |  |  |  | 
| 1040 | 271 | 50 |  |  |  | 769 | return $status | 
| 1041 |  |  |  |  |  |  | if $status < 0; | 
| 1042 |  |  |  |  |  |  | } | 
| 1043 |  |  |  |  |  |  |  | 
| 1044 | 1773 |  |  |  |  | 2795 | *$self->{NewStream} = 0 ; | 
| 1045 | 1773 |  |  |  |  | 2686 | *$self->{EndStream} = 0 ; | 
| 1046 | 1773 |  |  |  |  | 3041 | *$self->{CompressedInputLengthDone} = undef ; | 
| 1047 | 1773 |  |  |  |  | 2744 | *$self->{CompressedInputLength} = undef ; | 
| 1048 | 1773 |  |  |  |  | 4266 | $self->reset(); | 
| 1049 | 1773 |  |  |  |  | 5879 | *$self->{UnCompSize}->reset(); | 
| 1050 | 1773 |  |  |  |  | 4585 | *$self->{CompSize}->reset(); | 
| 1051 |  |  |  |  |  |  |  | 
| 1052 | 1773 |  |  |  |  | 4311 | my $magic = $self->ckMagic(); | 
| 1053 |  |  |  |  |  |  |  | 
| 1054 | 1773 | 100 |  |  |  | 4205 | if ( ! defined $magic) { | 
| 1055 | 194 | 100 | 100 |  |  | 788 | if (! *$self->{Transparent} || $self->eof()) | 
| 1056 |  |  |  |  |  |  | { | 
| 1057 | 191 |  |  |  |  | 366 | *$self->{EndStream} = 1 ; | 
| 1058 | 191 |  |  |  |  | 423 | return 0; | 
| 1059 |  |  |  |  |  |  | } | 
| 1060 |  |  |  |  |  |  |  | 
| 1061 |  |  |  |  |  |  | # Not EOF, so Transparent mode kicks in now for trailing data | 
| 1062 |  |  |  |  |  |  | # Reset member name in case anyone calls getHeaderInfo()->{Name} | 
| 1063 | 3 |  |  |  |  | 11 | *$self->{Info} = { Name => undef, Type  => 'plain' }; | 
| 1064 |  |  |  |  |  |  |  | 
| 1065 | 3 |  |  |  |  | 11 | $self->clearError(); | 
| 1066 | 3 |  |  |  |  | 9 | *$self->{Type} = 'plain'; | 
| 1067 | 3 |  |  |  |  | 6 | *$self->{Plain} = 1; | 
| 1068 | 3 |  |  |  |  | 8 | $self->pushBack(*$self->{HeaderPending})  ; | 
| 1069 |  |  |  |  |  |  | } | 
| 1070 |  |  |  |  |  |  | else | 
| 1071 |  |  |  |  |  |  | { | 
| 1072 | 1579 |  |  |  |  | 3920 | *$self->{Info} = $self->readHeader($magic); | 
| 1073 |  |  |  |  |  |  |  | 
| 1074 | 1579 | 50 |  |  |  | 4716 | if ( ! defined *$self->{Info} ) { | 
| 1075 | 0 |  |  |  |  | 0 | *$self->{EndStream} = 1 ; | 
| 1076 | 0 |  |  |  |  | 0 | return -1; | 
| 1077 |  |  |  |  |  |  | } | 
| 1078 |  |  |  |  |  |  | } | 
| 1079 |  |  |  |  |  |  |  | 
| 1080 | 1582 |  |  |  |  | 2274 | push @{ *$self->{InfoList} }, *$self->{Info} ; | 
|  | 1582 |  |  |  |  | 3593 |  | 
| 1081 |  |  |  |  |  |  |  | 
| 1082 | 1582 |  |  |  |  | 4920 | return 1; | 
| 1083 |  |  |  |  |  |  | } | 
| 1084 |  |  |  |  |  |  |  | 
| 1085 |  |  |  |  |  |  | sub streamCount | 
| 1086 |  |  |  |  |  |  | { | 
| 1087 | 1260 |  |  | 1260 | 0 | 2845 | my $self = shift ; | 
| 1088 | 1260 | 50 |  |  |  | 3940 | return 1 if ! defined *$self->{InfoList}; | 
| 1089 | 1260 |  |  |  |  | 1863 | return scalar @{ *$self->{InfoList} }  ; | 
|  | 1260 |  |  |  |  | 6000 |  | 
| 1090 |  |  |  |  |  |  | } | 
| 1091 |  |  |  |  |  |  |  | 
| 1092 |  |  |  |  |  |  | sub read | 
| 1093 |  |  |  |  |  |  | { | 
| 1094 |  |  |  |  |  |  | # return codes | 
| 1095 |  |  |  |  |  |  | # >0 - ok, number of bytes read | 
| 1096 |  |  |  |  |  |  | # =0 - ok, eof | 
| 1097 |  |  |  |  |  |  | # <0 - not ok | 
| 1098 |  |  |  |  |  |  |  | 
| 1099 | 332741 |  |  | 332741 | 0 | 1161652 | my $self = shift ; | 
| 1100 |  |  |  |  |  |  |  | 
| 1101 | 332741 | 100 |  |  |  | 637236 | if (defined *$self->{ReadStatus} ) { | 
| 1102 | 6 |  |  |  |  | 16 | my $status = *$self->{ReadStatus}[0]; | 
| 1103 | 6 |  |  |  |  | 10 | $self->saveErrorString( @{ *$self->{ReadStatus} } ); | 
|  | 6 |  |  |  |  | 23 |  | 
| 1104 | 6 |  |  |  |  | 21 | delete  *$self->{ReadStatus} ; | 
| 1105 | 6 |  |  |  |  | 17 | return $status ; | 
| 1106 |  |  |  |  |  |  | } | 
| 1107 |  |  |  |  |  |  |  | 
| 1108 | 332735 | 100 |  |  |  | 550028 | return G_EOF if *$self->{Closed} ; | 
| 1109 |  |  |  |  |  |  |  | 
| 1110 | 332725 |  |  |  |  | 404634 | my $buffer ; | 
| 1111 |  |  |  |  |  |  |  | 
| 1112 | 332725 | 100 |  |  |  | 529321 | if (ref $_[0] ) { | 
| 1113 |  |  |  |  |  |  | $self->croakError(*$self->{ClassName} . "::read: buffer parameter is read-only") | 
| 1114 | 4695 | 50 |  |  |  | 6449 | if Scalar::Util::readonly(${ $_[0] }); | 
|  | 4695 |  |  |  |  | 15898 |  | 
| 1115 |  |  |  |  |  |  |  | 
| 1116 | 4695 | 50 |  |  |  | 11540 | $self->croakError(*$self->{ClassName} . "::read: not a scalar reference $_[0]" ) | 
| 1117 |  |  |  |  |  |  | unless ref $_[0] eq 'SCALAR' ; | 
| 1118 | 4695 |  |  |  |  | 7717 | $buffer = $_[0] ; | 
| 1119 |  |  |  |  |  |  | } | 
| 1120 |  |  |  |  |  |  | else { | 
| 1121 | 328030 | 100 |  |  |  | 650313 | $self->croakError(*$self->{ClassName} . "::read: buffer parameter is read-only") | 
| 1122 |  |  |  |  |  |  | if Scalar::Util::readonly($_[0]); | 
| 1123 |  |  |  |  |  |  |  | 
| 1124 | 328025 |  |  |  |  | 452515 | $buffer = \$_[0] ; | 
| 1125 |  |  |  |  |  |  | } | 
| 1126 |  |  |  |  |  |  |  | 
| 1127 | 332720 |  |  |  |  | 479560 | my $length = $_[1] ; | 
| 1128 | 332720 |  | 100 |  |  | 790692 | my $offset = $_[2] || 0; | 
| 1129 |  |  |  |  |  |  |  | 
| 1130 | 332720 | 100 |  |  |  | 647831 | if (! *$self->{AppendOutput}) { | 
|  |  | 100 |  |  |  |  |  | 
| 1131 | 161620 | 100 |  |  |  | 232475 | if (! $offset) { | 
| 1132 |  |  |  |  |  |  |  | 
| 1133 | 161585 |  |  |  |  | 233723 | $$buffer = '' ; | 
| 1134 |  |  |  |  |  |  | } | 
| 1135 |  |  |  |  |  |  | else { | 
| 1136 | 35 | 100 |  |  |  | 112 | if ($offset > length($$buffer)) { | 
| 1137 | 10 |  |  |  |  | 56 | $$buffer .= "\x00" x ($offset - length($$buffer)); | 
| 1138 |  |  |  |  |  |  | } | 
| 1139 |  |  |  |  |  |  | else { | 
| 1140 | 25 |  |  |  |  | 118 | substr($$buffer, $offset) = ''; | 
| 1141 |  |  |  |  |  |  | } | 
| 1142 |  |  |  |  |  |  | } | 
| 1143 |  |  |  |  |  |  | } | 
| 1144 |  |  |  |  |  |  | elsif (! defined $$buffer) { | 
| 1145 | 2208 |  |  |  |  | 3704 | $$buffer = '' ; | 
| 1146 |  |  |  |  |  |  | } | 
| 1147 |  |  |  |  |  |  |  | 
| 1148 | 332720 | 100 | 100 |  |  | 609022 | return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ; | 
| 1149 |  |  |  |  |  |  |  | 
| 1150 |  |  |  |  |  |  | # the core read will return 0 if asked for 0 bytes | 
| 1151 | 329446 | 100 | 100 |  |  | 864734 | return 0 if defined $length && $length == 0 ; | 
| 1152 |  |  |  |  |  |  |  | 
| 1153 | 329426 |  | 100 |  |  | 550109 | $length = $length || 0; | 
| 1154 |  |  |  |  |  |  |  | 
| 1155 | 329426 | 100 |  |  |  | 529994 | $self->croakError(*$self->{ClassName} . "::read: length parameter is negative") | 
| 1156 |  |  |  |  |  |  | if $length < 0 ; | 
| 1157 |  |  |  |  |  |  |  | 
| 1158 |  |  |  |  |  |  | # Short-circuit if this is a simple read, with no length | 
| 1159 |  |  |  |  |  |  | # or offset specified. | 
| 1160 | 329421 | 100 | 66 |  |  | 581531 | unless ( $length || $offset) { | 
| 1161 | 7002 | 100 |  |  |  | 15309 | if (length *$self->{Pending}) { | 
| 1162 | 3401 |  |  |  |  | 7538 | $$buffer .= *$self->{Pending} ; | 
| 1163 | 3401 |  |  |  |  | 6191 | my $len = length *$self->{Pending}; | 
| 1164 | 3401 |  |  |  |  | 5687 | *$self->{Pending} = '' ; | 
| 1165 | 3401 |  |  |  |  | 9240 | return $len ; | 
| 1166 |  |  |  |  |  |  | } | 
| 1167 |  |  |  |  |  |  | else { | 
| 1168 | 3601 |  |  |  |  | 5215 | my $len = 0; | 
| 1169 |  |  |  |  |  |  | $len = $self->_raw_read($buffer) | 
| 1170 | 3601 |  | 100 |  |  | 17385 | while ! *$self->{EndStream} && $len == 0 ; | 
| 1171 | 3601 |  |  |  |  | 8381 | return $len ; | 
| 1172 |  |  |  |  |  |  | } | 
| 1173 |  |  |  |  |  |  | } | 
| 1174 |  |  |  |  |  |  |  | 
| 1175 |  |  |  |  |  |  | # Need to jump through more hoops - either length or offset | 
| 1176 |  |  |  |  |  |  | # or both are specified. | 
| 1177 | 322419 |  |  |  |  | 779772 | my $out_buffer = *$self->{Pending} ; | 
| 1178 | 322419 |  |  |  |  | 466099 | *$self->{Pending} = ''; | 
| 1179 |  |  |  |  |  |  |  | 
| 1180 |  |  |  |  |  |  |  | 
| 1181 | 322419 |  | 100 |  |  | 831425 | while (! *$self->{EndStream} && length($out_buffer) < $length) | 
| 1182 |  |  |  |  |  |  | { | 
| 1183 | 2494 |  |  |  |  | 6155 | my $buf_len = $self->_raw_read(\$out_buffer); | 
| 1184 | 2494 | 50 |  |  |  | 10376 | return $buf_len | 
| 1185 |  |  |  |  |  |  | if $buf_len < 0 ; | 
| 1186 |  |  |  |  |  |  | } | 
| 1187 |  |  |  |  |  |  |  | 
| 1188 | 322419 | 100 |  |  |  | 538070 | $length = length $out_buffer | 
| 1189 |  |  |  |  |  |  | if length($out_buffer) < $length ; | 
| 1190 |  |  |  |  |  |  |  | 
| 1191 | 322419 | 100 |  |  |  | 515634 | return 0 | 
| 1192 |  |  |  |  |  |  | if $length == 0 ; | 
| 1193 |  |  |  |  |  |  |  | 
| 1194 | 322309 | 50 |  |  |  | 525838 | $$buffer = '' | 
| 1195 |  |  |  |  |  |  | if ! defined $$buffer; | 
| 1196 |  |  |  |  |  |  |  | 
| 1197 |  |  |  |  |  |  | $offset = length $$buffer | 
| 1198 | 322309 | 100 |  |  |  | 553560 | if *$self->{AppendOutput} ; | 
| 1199 |  |  |  |  |  |  |  | 
| 1200 | 322309 |  |  |  |  | 501940 | *$self->{Pending} = $out_buffer; | 
| 1201 | 322309 |  |  |  |  | 486100 | $out_buffer = \*$self->{Pending} ; | 
| 1202 |  |  |  |  |  |  |  | 
| 1203 | 322309 |  |  |  |  | 557063 | substr($$buffer, $offset) = substr($$out_buffer, 0, $length) ; | 
| 1204 | 322309 |  |  |  |  | 455865 | substr($$out_buffer, 0, $length) =  '' ; | 
| 1205 |  |  |  |  |  |  |  | 
| 1206 | 322309 |  |  |  |  | 661086 | return $length ; | 
| 1207 |  |  |  |  |  |  | } | 
| 1208 |  |  |  |  |  |  |  | 
| 1209 |  |  |  |  |  |  | sub _getline | 
| 1210 |  |  |  |  |  |  | { | 
| 1211 | 1480 |  |  | 1480 |  | 2182 | my $self = shift ; | 
| 1212 | 1480 |  |  |  |  | 1956 | my $status = 0 ; | 
| 1213 |  |  |  |  |  |  |  | 
| 1214 |  |  |  |  |  |  | # Slurp Mode | 
| 1215 | 1480 | 100 |  |  |  | 3208 | if ( ! defined $/ ) { | 
| 1216 | 55 |  |  |  |  | 85 | my $data ; | 
| 1217 | 55 |  |  |  |  | 210 | 1 while ($status = $self->read($data)) > 0 ; | 
| 1218 | 55 |  |  |  |  | 176 | return ($status, \$data); | 
| 1219 |  |  |  |  |  |  | } | 
| 1220 |  |  |  |  |  |  |  | 
| 1221 |  |  |  |  |  |  | # Record Mode | 
| 1222 | 1425 | 50 | 66 |  |  | 3431 | if ( ref $/ eq 'SCALAR' && ${$/} =~ /^\d+$/ && ${$/} > 0) { | 
|  | 85 |  | 66 |  |  | 429 |  | 
|  | 85 |  |  |  |  | 244 |  | 
| 1223 | 85 |  |  |  |  | 115 | my $reclen = ${$/} ; | 
|  | 85 |  |  |  |  | 161 |  | 
| 1224 | 85 |  |  |  |  | 122 | my $data ; | 
| 1225 | 85 |  |  |  |  | 151 | $status = $self->read($data, $reclen) ; | 
| 1226 | 85 |  |  |  |  | 233 | return ($status, \$data); | 
| 1227 |  |  |  |  |  |  | } | 
| 1228 |  |  |  |  |  |  |  | 
| 1229 |  |  |  |  |  |  | # Paragraph Mode | 
| 1230 | 1340 | 100 |  |  |  | 2755 | if ( ! length $/ ) { | 
| 1231 | 60 |  |  |  |  | 103 | my $paragraph ; | 
| 1232 | 60 |  |  |  |  | 147 | while (($status = $self->read($paragraph)) > 0 ) { | 
| 1233 | 50 | 50 |  |  |  | 384 | if ($paragraph =~ s/^(.*?\n\n+)//s) { | 
| 1234 | 50 |  |  |  |  | 141 | *$self->{Pending}  = $paragraph ; | 
| 1235 | 50 |  |  |  |  | 131 | my $par = $1 ; | 
| 1236 | 50 |  |  |  |  | 167 | return (1, \$par); | 
| 1237 |  |  |  |  |  |  | } | 
| 1238 |  |  |  |  |  |  | } | 
| 1239 | 10 |  |  |  |  | 64 | return ($status, \$paragraph); | 
| 1240 |  |  |  |  |  |  | } | 
| 1241 |  |  |  |  |  |  |  | 
| 1242 |  |  |  |  |  |  | # $/ isn't empty, or a reference, so it's Line Mode. | 
| 1243 |  |  |  |  |  |  | { | 
| 1244 | 1280 |  |  |  |  | 1761 | my $line ; | 
|  | 1280 |  |  |  |  | 1656 |  | 
| 1245 | 1280 |  |  |  |  | 2157 | my $p = \*$self->{Pending}  ; | 
| 1246 | 1280 |  |  |  |  | 2574 | while (($status = $self->read($line)) > 0 ) { | 
| 1247 | 1275 |  |  |  |  | 3462 | my $offset = index($line, $/); | 
| 1248 | 1275 | 100 |  |  |  | 3063 | if ($offset >= 0) { | 
| 1249 | 1242 |  |  |  |  | 2820 | my $l = substr($line, 0, $offset + length $/ ); | 
| 1250 | 1242 |  |  |  |  | 2400 | substr($line, 0, $offset + length $/) = ''; | 
| 1251 | 1242 |  |  |  |  | 1980 | $$p = $line; | 
| 1252 | 1242 |  |  |  |  | 3388 | return (1, \$l); | 
| 1253 |  |  |  |  |  |  | } | 
| 1254 |  |  |  |  |  |  | } | 
| 1255 |  |  |  |  |  |  |  | 
| 1256 | 38 |  |  |  |  | 143 | return ($status, \$line); | 
| 1257 |  |  |  |  |  |  | } | 
| 1258 |  |  |  |  |  |  | } | 
| 1259 |  |  |  |  |  |  |  | 
| 1260 |  |  |  |  |  |  | sub getline | 
| 1261 |  |  |  |  |  |  | { | 
| 1262 | 2035 |  |  | 2035 | 1 | 108083 | my $self = shift; | 
| 1263 |  |  |  |  |  |  |  | 
| 1264 | 2035 | 50 |  |  |  | 4914 | if (defined *$self->{ReadStatus} ) { | 
| 1265 | 0 |  |  |  |  | 0 | $self->saveErrorString( @{ *$self->{ReadStatus} } ); | 
|  | 0 |  |  |  |  | 0 |  | 
| 1266 | 0 |  |  |  |  | 0 | delete  *$self->{ReadStatus} ; | 
| 1267 | 0 |  |  |  |  | 0 | return undef; | 
| 1268 |  |  |  |  |  |  | } | 
| 1269 |  |  |  |  |  |  |  | 
| 1270 |  |  |  |  |  |  | return undef | 
| 1271 | 2035 | 100 | 100 |  |  | 9393 | if *$self->{Closed} || (!length *$self->{Pending} && *$self->{EndStream}) ; | 
|  |  |  | 66 |  |  |  |  | 
| 1272 |  |  |  |  |  |  |  | 
| 1273 | 1480 |  |  |  |  | 2436 | my $current_append = *$self->{AppendOutput} ; | 
| 1274 | 1480 |  |  |  |  | 2308 | *$self->{AppendOutput} = 1; | 
| 1275 |  |  |  |  |  |  |  | 
| 1276 | 1480 |  |  |  |  | 2889 | my ($status, $lineref) = $self->_getline(); | 
| 1277 | 1480 |  |  |  |  | 2682 | *$self->{AppendOutput} = $current_append; | 
| 1278 |  |  |  |  |  |  |  | 
| 1279 |  |  |  |  |  |  | return undef | 
| 1280 | 1480 | 100 | 66 |  |  | 4923 | if $status < 0 || length $$lineref == 0 ; | 
| 1281 |  |  |  |  |  |  |  | 
| 1282 | 1452 |  |  |  |  | 2974 | $. = ++ *$self->{LineNo} ; | 
| 1283 |  |  |  |  |  |  |  | 
| 1284 | 1452 |  |  |  |  | 4206 | return $$lineref ; | 
| 1285 |  |  |  |  |  |  | } | 
| 1286 |  |  |  |  |  |  |  | 
| 1287 |  |  |  |  |  |  | sub getlines | 
| 1288 |  |  |  |  |  |  | { | 
| 1289 | 110 |  |  | 110 | 1 | 341 | my $self = shift; | 
| 1290 |  |  |  |  |  |  | $self->croakError(*$self->{ClassName} . | 
| 1291 | 110 | 50 |  |  |  | 280 | "::getlines: called in scalar context\n") unless wantarray; | 
| 1292 | 110 |  |  |  |  | 201 | my($line, @lines); | 
| 1293 | 110 |  |  |  |  | 308 | push(@lines, $line) | 
| 1294 |  |  |  |  |  |  | while defined($line = $self->getline); | 
| 1295 | 110 |  |  |  |  | 563 | return @lines; | 
| 1296 |  |  |  |  |  |  | } | 
| 1297 |  |  |  |  |  |  |  | 
| 1298 |  |  |  |  |  |  | sub READLINE | 
| 1299 |  |  |  |  |  |  | { | 
| 1300 | 159 | 100 |  | 159 |  | 2330 | goto &getlines if wantarray; | 
| 1301 | 129 |  |  |  |  | 574 | goto &getline; | 
| 1302 |  |  |  |  |  |  | } | 
| 1303 |  |  |  |  |  |  |  | 
| 1304 |  |  |  |  |  |  | sub getc | 
| 1305 |  |  |  |  |  |  | { | 
| 1306 | 105 |  |  | 105 | 0 | 6761 | my $self = shift; | 
| 1307 | 105 |  |  |  |  | 341 | my $buf; | 
| 1308 | 105 | 100 |  |  |  | 268 | return $buf if $self->read($buf, 1); | 
| 1309 | 45 |  |  |  |  | 193 | return undef; | 
| 1310 |  |  |  |  |  |  | } | 
| 1311 |  |  |  |  |  |  |  | 
| 1312 |  |  |  |  |  |  | sub ungetc | 
| 1313 |  |  |  |  |  |  | { | 
| 1314 | 2921 |  |  | 2921 | 1 | 15852 | my $self = shift; | 
| 1315 | 2921 | 50 |  |  |  | 6848 | *$self->{Pending} = ""  unless defined *$self->{Pending} ; | 
| 1316 | 2921 |  |  |  |  | 9307 | *$self->{Pending} = $_[0] . *$self->{Pending} ; | 
| 1317 |  |  |  |  |  |  | } | 
| 1318 |  |  |  |  |  |  |  | 
| 1319 |  |  |  |  |  |  |  | 
| 1320 |  |  |  |  |  |  | sub trailingData | 
| 1321 |  |  |  |  |  |  | { | 
| 1322 | 34 |  |  | 34 | 0 | 8603 | my $self = shift ; | 
| 1323 |  |  |  |  |  |  |  | 
| 1324 | 34 | 100 | 66 |  |  | 246 | if (defined *$self->{FH} || defined *$self->{InputEvent} ) { | 
| 1325 | 24 |  |  |  |  | 143 | return *$self->{Prime} ; | 
| 1326 |  |  |  |  |  |  | } | 
| 1327 |  |  |  |  |  |  | else { | 
| 1328 | 10 |  |  |  |  | 51 | my $buf = *$self->{Buffer} ; | 
| 1329 | 10 |  |  |  |  | 35 | my $offset = *$self->{BufferOffset} ; | 
| 1330 | 10 |  |  |  |  | 53 | return substr($$buf, $offset) ; | 
| 1331 |  |  |  |  |  |  | } | 
| 1332 |  |  |  |  |  |  | } | 
| 1333 |  |  |  |  |  |  |  | 
| 1334 |  |  |  |  |  |  |  | 
| 1335 |  |  |  |  |  |  | sub eof | 
| 1336 |  |  |  |  |  |  | { | 
| 1337 | 2652 |  |  | 2652 | 0 | 34963 | my $self = shift ; | 
| 1338 |  |  |  |  |  |  |  | 
| 1339 |  |  |  |  |  |  | return (*$self->{Closed} || | 
| 1340 |  |  |  |  |  |  | (!length *$self->{Pending} | 
| 1341 | 2652 |  | 66 |  |  | 16393 | && ( $self->smartEof() || *$self->{EndStream}))) ; | 
| 1342 |  |  |  |  |  |  | } | 
| 1343 |  |  |  |  |  |  |  | 
| 1344 |  |  |  |  |  |  | sub tell | 
| 1345 |  |  |  |  |  |  | { | 
| 1346 | 1133 |  |  | 1133 | 1 | 16030 | my $self = shift ; | 
| 1347 |  |  |  |  |  |  |  | 
| 1348 | 1133 |  |  |  |  | 1725 | my $in ; | 
| 1349 | 1133 | 100 |  |  |  | 3196 | if (*$self->{Plain}) { | 
| 1350 | 250 |  |  |  |  | 577 | $in = *$self->{PlainBytesRead} ; | 
| 1351 |  |  |  |  |  |  | } | 
| 1352 |  |  |  |  |  |  | else { | 
| 1353 | 883 |  |  |  |  | 1573 | $in = *$self->{TotalInflatedBytesRead} ; | 
| 1354 |  |  |  |  |  |  | } | 
| 1355 |  |  |  |  |  |  |  | 
| 1356 | 1133 |  |  |  |  | 1962 | my $pending = length *$self->{Pending} ; | 
| 1357 |  |  |  |  |  |  |  | 
| 1358 | 1133 | 100 |  |  |  | 2760 | return 0 if $pending > $in ; | 
| 1359 | 1097 |  |  |  |  | 4357 | return $in - $pending ; | 
| 1360 |  |  |  |  |  |  | } | 
| 1361 |  |  |  |  |  |  |  | 
| 1362 |  |  |  |  |  |  | sub close | 
| 1363 |  |  |  |  |  |  | { | 
| 1364 |  |  |  |  |  |  | # todo - what to do if close is called before the end of the gzip file | 
| 1365 |  |  |  |  |  |  | #        do we remember any trailing data? | 
| 1366 | 6310 |  |  | 6310 | 0 | 25214 | my $self = shift ; | 
| 1367 |  |  |  |  |  |  |  | 
| 1368 | 6310 | 100 |  |  |  | 65186 | return 1 if *$self->{Closed} ; | 
| 1369 |  |  |  |  |  |  |  | 
| 1370 | 3580 | 50 |  |  |  | 17156 | untie *$self | 
| 1371 |  |  |  |  |  |  | if $] >= 5.008 ; | 
| 1372 |  |  |  |  |  |  |  | 
| 1373 | 3580 |  |  |  |  | 6026 | my $status = 1 ; | 
| 1374 |  |  |  |  |  |  |  | 
| 1375 | 3580 | 100 |  |  |  | 9534 | if (defined *$self->{FH}) { | 
| 1376 | 2129 | 100 | 100 |  |  | 12075 | if ((! *$self->{Handle} || *$self->{AutoClose}) && ! *$self->{StdIO}) { | 
|  |  |  | 66 |  |  |  |  | 
| 1377 | 1941 |  |  |  |  | 5091 | local $.; | 
| 1378 | 1941 |  |  |  |  | 3769 | $! = 0 ; | 
| 1379 | 1941 |  |  |  |  | 6518 | $status = *$self->{FH}->close(); | 
| 1380 |  |  |  |  |  |  | return $self->saveErrorString(0, $!, $!) | 
| 1381 | 1941 | 50 | 33 |  |  | 46925 | if !*$self->{InNew} && $self->saveStatus($!) != 0 ; | 
| 1382 |  |  |  |  |  |  | } | 
| 1383 | 2129 |  |  |  |  | 8334 | delete *$self->{FH} ; | 
| 1384 | 2129 |  |  |  |  | 4130 | $! = 0 ; | 
| 1385 |  |  |  |  |  |  | } | 
| 1386 | 3580 |  |  |  |  | 6133 | *$self->{Closed} = 1 ; | 
| 1387 |  |  |  |  |  |  |  | 
| 1388 | 3580 |  |  |  |  | 44860 | return 1; | 
| 1389 |  |  |  |  |  |  | } | 
| 1390 |  |  |  |  |  |  |  | 
| 1391 |  |  |  |  |  |  | sub DESTROY | 
| 1392 |  |  |  |  |  |  | { | 
| 1393 | 4375 |  |  | 4375 |  | 493301 | my $self = shift ; | 
| 1394 | 4375 |  |  |  |  | 28044 | local ($., $@, $!, $^E, $?); | 
| 1395 |  |  |  |  |  |  |  | 
| 1396 | 4375 |  |  |  |  | 11272 | $self->close() ; | 
| 1397 |  |  |  |  |  |  | } | 
| 1398 |  |  |  |  |  |  |  | 
| 1399 |  |  |  |  |  |  | sub seek | 
| 1400 |  |  |  |  |  |  | { | 
| 1401 | 106 |  |  | 106 | 1 | 13308 | my $self     = shift ; | 
| 1402 | 106 |  |  |  |  | 181 | my $position = shift; | 
| 1403 | 106 |  |  |  |  | 160 | my $whence   = shift ; | 
| 1404 |  |  |  |  |  |  |  | 
| 1405 | 106 |  |  |  |  | 250 | my $here = $self->tell() ; | 
| 1406 | 106 |  |  |  |  | 188 | my $target = 0 ; | 
| 1407 |  |  |  |  |  |  |  | 
| 1408 |  |  |  |  |  |  |  | 
| 1409 | 106 | 100 |  |  |  | 353 | if ($whence == SEEK_SET) { | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
| 1410 | 21 |  |  |  |  | 41 | $target = $position ; | 
| 1411 |  |  |  |  |  |  | } | 
| 1412 |  |  |  |  |  |  | elsif ($whence == SEEK_CUR) { | 
| 1413 | 63 |  |  |  |  | 119 | $target = $here + $position ; | 
| 1414 |  |  |  |  |  |  | } | 
| 1415 |  |  |  |  |  |  | elsif ($whence == SEEK_END) { | 
| 1416 | 11 |  |  |  |  | 48 | $target = $position ; | 
| 1417 | 11 |  |  |  |  | 100 | $self->croakError(*$self->{ClassName} . "::seek: SEEK_END not allowed") ; | 
| 1418 |  |  |  |  |  |  | } | 
| 1419 |  |  |  |  |  |  | else { | 
| 1420 | 11 |  |  |  |  | 183 | $self->croakError(*$self->{ClassName} ."::seek: unknown value, $whence, for whence parameter"); | 
| 1421 |  |  |  |  |  |  | } | 
| 1422 |  |  |  |  |  |  |  | 
| 1423 |  |  |  |  |  |  | # short circuit if seeking to current offset | 
| 1424 | 84 | 100 |  |  |  | 233 | if ($target == $here) { | 
| 1425 |  |  |  |  |  |  | # On ordinary filehandles, seeking to the current | 
| 1426 |  |  |  |  |  |  | # position also clears the EOF condition, so we | 
| 1427 |  |  |  |  |  |  | # emulate this behavior locally while simultaneously | 
| 1428 |  |  |  |  |  |  | # cascading it to the underlying filehandle | 
| 1429 | 26 | 100 |  |  |  | 151 | if (*$self->{Plain}) { | 
| 1430 | 10 |  |  |  |  | 41 | *$self->{EndStream} = 0; | 
| 1431 | 10 | 100 |  |  |  | 97 | seek(*$self->{FH},0,1) if *$self->{FH}; | 
| 1432 |  |  |  |  |  |  | } | 
| 1433 | 26 |  |  |  |  | 129 | return 1; | 
| 1434 |  |  |  |  |  |  | } | 
| 1435 |  |  |  |  |  |  |  | 
| 1436 |  |  |  |  |  |  | # Outlaw any attempt to seek backwards | 
| 1437 | 58 | 100 |  |  |  | 233 | $self->croakError( *$self->{ClassName} ."::seek: cannot seek backwards") | 
| 1438 |  |  |  |  |  |  | if $target < $here ; | 
| 1439 |  |  |  |  |  |  |  | 
| 1440 |  |  |  |  |  |  | # Walk the file to the new offset | 
| 1441 | 47 |  |  |  |  | 93 | my $offset = $target - $here ; | 
| 1442 |  |  |  |  |  |  |  | 
| 1443 | 47 |  |  |  |  | 70 | my $got; | 
| 1444 | 47 |  |  |  |  | 242 | while (($got = $self->read(my $buffer, List::Util::min($offset, *$self->{BlockSize})) ) > 0) | 
| 1445 |  |  |  |  |  |  | { | 
| 1446 | 47 |  |  |  |  | 79 | $offset -= $got; | 
| 1447 | 47 | 50 |  |  |  | 153 | last if $offset == 0 ; | 
| 1448 |  |  |  |  |  |  | } | 
| 1449 |  |  |  |  |  |  |  | 
| 1450 | 47 |  |  |  |  | 111 | $here = $self->tell() ; | 
| 1451 | 47 | 50 |  |  |  | 272 | return $offset == 0 ? 1 : 0 ; | 
| 1452 |  |  |  |  |  |  | } | 
| 1453 |  |  |  |  |  |  |  | 
| 1454 |  |  |  |  |  |  | sub fileno | 
| 1455 |  |  |  |  |  |  | { | 
| 1456 | 35 |  |  | 35 | 0 | 1288 | my $self = shift ; | 
| 1457 |  |  |  |  |  |  | return defined *$self->{FH} | 
| 1458 |  |  |  |  |  |  | ? fileno *$self->{FH} | 
| 1459 | 35 | 100 |  |  |  | 278 | : undef ; | 
| 1460 |  |  |  |  |  |  | } | 
| 1461 |  |  |  |  |  |  |  | 
| 1462 |  |  |  |  |  |  | sub binmode | 
| 1463 |  |  |  |  |  |  | { | 
| 1464 | 5 |  |  | 5 | 1 | 24 | 1; | 
| 1465 |  |  |  |  |  |  | #    my $self     = shift ; | 
| 1466 |  |  |  |  |  |  | #    return defined *$self->{FH} | 
| 1467 |  |  |  |  |  |  | #            ? binmode *$self->{FH} | 
| 1468 |  |  |  |  |  |  | #            : 1 ; | 
| 1469 |  |  |  |  |  |  | } | 
| 1470 |  |  |  |  |  |  |  | 
| 1471 |  |  |  |  |  |  | sub opened | 
| 1472 |  |  |  |  |  |  | { | 
| 1473 | 10 |  |  | 10 | 1 | 26 | my $self     = shift ; | 
| 1474 | 10 |  |  |  |  | 50 | return ! *$self->{Closed} ; | 
| 1475 |  |  |  |  |  |  | } | 
| 1476 |  |  |  |  |  |  |  | 
| 1477 |  |  |  |  |  |  | sub autoflush | 
| 1478 |  |  |  |  |  |  | { | 
| 1479 | 10 |  |  | 10 | 0 | 26 | my $self     = shift ; | 
| 1480 |  |  |  |  |  |  | return defined *$self->{FH} | 
| 1481 | 10 | 50 |  |  |  | 67 | ? *$self->{FH}->autoflush(@_) | 
| 1482 |  |  |  |  |  |  | : undef ; | 
| 1483 |  |  |  |  |  |  | } | 
| 1484 |  |  |  |  |  |  |  | 
| 1485 |  |  |  |  |  |  | sub input_line_number | 
| 1486 |  |  |  |  |  |  | { | 
| 1487 | 80 |  |  | 80 | 0 | 29657 | my $self = shift ; | 
| 1488 | 80 |  |  |  |  | 217 | my $last = *$self->{LineNo}; | 
| 1489 | 80 | 50 |  |  |  | 215 | $. = *$self->{LineNo} = $_[1] if @_ ; | 
| 1490 | 80 |  |  |  |  | 439 | return $last; | 
| 1491 |  |  |  |  |  |  | } | 
| 1492 |  |  |  |  |  |  |  | 
| 1493 |  |  |  |  |  |  | sub _notAvailable | 
| 1494 |  |  |  |  |  |  | { | 
| 1495 | 504 |  |  | 504 |  | 777 | my $name = shift ; | 
| 1496 | 504 |  |  | 25 |  | 1370 | return sub { croak "$name Not Available: File opened only for intput" ; } ; | 
|  | 25 |  |  |  |  | 9616 |  | 
| 1497 |  |  |  |  |  |  | } | 
| 1498 |  |  |  |  |  |  |  | 
| 1499 |  |  |  |  |  |  | { | 
| 1500 | 84 |  |  | 84 |  | 802 | no warnings 'once'; | 
|  | 84 |  |  |  |  | 217 |  | 
|  | 84 |  |  |  |  | 16623 |  | 
| 1501 |  |  |  |  |  |  |  | 
| 1502 |  |  |  |  |  |  | *BINMODE  = \&binmode; | 
| 1503 |  |  |  |  |  |  | *SEEK     = \&seek; | 
| 1504 |  |  |  |  |  |  | *READ     = \&read; | 
| 1505 |  |  |  |  |  |  | *sysread  = \&read; | 
| 1506 |  |  |  |  |  |  | *TELL     = \&tell; | 
| 1507 |  |  |  |  |  |  | *EOF      = \&eof; | 
| 1508 |  |  |  |  |  |  |  | 
| 1509 |  |  |  |  |  |  | *FILENO   = \&fileno; | 
| 1510 |  |  |  |  |  |  | *CLOSE    = \&close; | 
| 1511 |  |  |  |  |  |  |  | 
| 1512 |  |  |  |  |  |  | *print    = _notAvailable('print'); | 
| 1513 |  |  |  |  |  |  | *PRINT    = _notAvailable('print'); | 
| 1514 |  |  |  |  |  |  | *printf   = _notAvailable('printf'); | 
| 1515 |  |  |  |  |  |  | *PRINTF   = _notAvailable('printf'); | 
| 1516 |  |  |  |  |  |  | *write    = _notAvailable('write'); | 
| 1517 |  |  |  |  |  |  | *WRITE    = _notAvailable('write'); | 
| 1518 |  |  |  |  |  |  |  | 
| 1519 |  |  |  |  |  |  | #*sysread  = \&read; | 
| 1520 |  |  |  |  |  |  | #*syswrite = \&_notAvailable; | 
| 1521 |  |  |  |  |  |  | } | 
| 1522 |  |  |  |  |  |  |  | 
| 1523 |  |  |  |  |  |  |  | 
| 1524 |  |  |  |  |  |  |  | 
| 1525 |  |  |  |  |  |  | package IO::Uncompress::Base ; | 
| 1526 |  |  |  |  |  |  |  | 
| 1527 |  |  |  |  |  |  |  | 
| 1528 |  |  |  |  |  |  | 1 ; | 
| 1529 |  |  |  |  |  |  | __END__ |