| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package IO::Uncompress::Bunzip2 ; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 83 |  |  | 83 |  | 5858 | use strict ; | 
|  | 83 |  |  |  |  | 191 |  | 
|  | 83 |  |  |  |  | 2482 |  | 
| 4 | 83 |  |  | 83 |  | 449 | use warnings; | 
|  | 83 |  |  |  |  | 209 |  | 
|  | 83 |  |  |  |  | 2027 |  | 
| 5 | 83 |  |  | 83 |  | 444 | use bytes; | 
|  | 83 |  |  |  |  | 225 |  | 
|  | 83 |  |  |  |  | 481 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 83 |  |  | 83 |  | 2778 | use IO::Compress::Base::Common 2.205 qw(:Status ); | 
|  | 83 |  |  |  |  | 1507 |  | 
|  | 83 |  |  |  |  | 10676 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 83 |  |  | 83 |  | 5281 | use IO::Uncompress::Base 2.205 ; | 
|  | 83 |  |  |  |  | 1407 |  | 
|  | 83 |  |  |  |  | 4155 |  | 
| 10 | 83 |  |  | 83 |  | 4399 | use IO::Uncompress::Adapter::Bunzip2 2.205 ; | 
|  | 83 |  |  |  |  | 1511 |  | 
|  | 83 |  |  |  |  | 57179 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | require Exporter ; | 
| 13 |  |  |  |  |  |  | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $Bunzip2Error); | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | $VERSION = '2.205'; | 
| 16 |  |  |  |  |  |  | $Bunzip2Error = ''; | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | @ISA    = qw(IO::Uncompress::Base Exporter); | 
| 19 |  |  |  |  |  |  | @EXPORT_OK = qw( $Bunzip2Error bunzip2 ) ; | 
| 20 |  |  |  |  |  |  | #%EXPORT_TAGS = %IO::Uncompress::Base::EXPORT_TAGS ; | 
| 21 |  |  |  |  |  |  | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | 
| 22 |  |  |  |  |  |  | #Exporter::export_ok_tags('all'); | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | sub new | 
| 26 |  |  |  |  |  |  | { | 
| 27 | 508 |  |  | 508 | 1 | 64009 | my $class = shift ; | 
| 28 | 508 |  |  |  |  | 1617 | my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$Bunzip2Error); | 
| 29 |  |  |  |  |  |  |  | 
| 30 | 508 |  |  |  |  | 1808 | $obj->_create(undef, 0, @_); | 
| 31 |  |  |  |  |  |  | } | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | sub bunzip2 | 
| 34 |  |  |  |  |  |  | { | 
| 35 | 66 |  |  | 66 | 1 | 59797 | my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$Bunzip2Error); | 
| 36 | 66 |  |  |  |  | 241 | return $obj->_inf(@_); | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | sub getExtraParams | 
| 40 |  |  |  |  |  |  | { | 
| 41 |  |  |  |  |  |  | return ( | 
| 42 | 557 |  |  | 557 | 0 | 4647 | 'verbosity'     => [IO::Compress::Base::Common::Parse_boolean,   0], | 
| 43 |  |  |  |  |  |  | 'small'         => [IO::Compress::Base::Common::Parse_boolean,   0], | 
| 44 |  |  |  |  |  |  | ); | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | sub ckParams | 
| 49 |  |  |  |  |  |  | { | 
| 50 | 563 |  |  | 563 | 0 | 863 | my $self = shift ; | 
| 51 | 563 |  |  |  |  | 787 | my $got = shift ; | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 563 |  |  |  |  | 1312 | return 1; | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | sub mkUncomp | 
| 57 |  |  |  |  |  |  | { | 
| 58 | 562 |  |  | 562 | 0 | 907 | my $self = shift ; | 
| 59 | 562 |  |  |  |  | 806 | my $got = shift ; | 
| 60 |  |  |  |  |  |  |  | 
| 61 | 562 | 100 |  |  |  | 1189 | my $magic = $self->ckMagic() | 
| 62 |  |  |  |  |  |  | or return 0; | 
| 63 |  |  |  |  |  |  |  | 
| 64 | 510 | 50 |  |  |  | 1359 | *$self->{Info} = $self->readHeader($magic) | 
| 65 |  |  |  |  |  |  | or return undef ; | 
| 66 |  |  |  |  |  |  |  | 
| 67 | 510 |  |  |  |  | 1580 | my $Small     = $got->getValue('small'); | 
| 68 | 510 |  |  |  |  | 1150 | my $Verbosity = $got->getValue('verbosity'); | 
| 69 |  |  |  |  |  |  |  | 
| 70 | 510 |  |  |  |  | 1399 | my ($obj, $errstr, $errno) =  IO::Uncompress::Adapter::Bunzip2::mkUncompObject( | 
| 71 |  |  |  |  |  |  | $Small, $Verbosity); | 
| 72 |  |  |  |  |  |  |  | 
| 73 | 510 | 50 |  |  |  | 1267 | return $self->saveErrorString(undef, $errstr, $errno) | 
| 74 |  |  |  |  |  |  | if ! defined $obj; | 
| 75 |  |  |  |  |  |  |  | 
| 76 | 510 |  |  |  |  | 1033 | *$self->{Uncomp} = $obj; | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 510 |  |  |  |  | 1267 | return 1; | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | sub ckMagic | 
| 84 |  |  |  |  |  |  | { | 
| 85 | 1171 |  |  | 1171 | 0 | 1927 | my $self = shift; | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 1171 |  |  |  |  | 1692 | my $magic ; | 
| 88 | 1171 |  |  |  |  | 3703 | $self->smartReadExact(\$magic, 4); | 
| 89 |  |  |  |  |  |  |  | 
| 90 | 1171 |  |  |  |  | 2839 | *$self->{HeaderPending} = $magic ; | 
| 91 |  |  |  |  |  |  |  | 
| 92 | 1171 | 100 |  |  |  | 2832 | return $self->HeaderError("Header size is " . | 
| 93 |  |  |  |  |  |  | 4 . " bytes") | 
| 94 |  |  |  |  |  |  | if length $magic != 4; | 
| 95 |  |  |  |  |  |  |  | 
| 96 | 1135 | 100 |  |  |  | 2260 | return $self->HeaderError("Bad Magic.") | 
| 97 |  |  |  |  |  |  | if ! isBzip2Magic($magic) ; | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  |  | 
| 100 | 1068 |  |  |  |  | 2854 | *$self->{Type} = 'bzip2'; | 
| 101 | 1068 |  |  |  |  | 2923 | return $magic; | 
| 102 |  |  |  |  |  |  | } | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | sub readHeader | 
| 105 |  |  |  |  |  |  | { | 
| 106 | 1068 |  |  | 1068 | 0 | 1622 | my $self = shift; | 
| 107 | 1068 |  |  |  |  | 1779 | my $magic = shift ; | 
| 108 |  |  |  |  |  |  |  | 
| 109 | 1068 |  |  |  |  | 2968 | $self->pushBack($magic); | 
| 110 | 1068 |  |  |  |  | 1951 | *$self->{HeaderPending} = ''; | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | return { | 
| 114 | 1068 |  |  |  |  | 6284 | 'Type'              => 'bzip2', | 
| 115 |  |  |  |  |  |  | 'FingerprintLength' => 4, | 
| 116 |  |  |  |  |  |  | 'HeaderLength'      => 4, | 
| 117 |  |  |  |  |  |  | 'TrailerLength'     => 0, | 
| 118 |  |  |  |  |  |  | 'Header'            => '$magic' | 
| 119 |  |  |  |  |  |  | }; | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | } | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | sub chkTrailer | 
| 124 |  |  |  |  |  |  | { | 
| 125 | 1064 |  |  | 1064 | 0 | 2656 | return STATUS_OK; | 
| 126 |  |  |  |  |  |  | } | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | sub isBzip2Magic | 
| 131 |  |  |  |  |  |  | { | 
| 132 | 1135 |  |  | 1135 | 0 | 2188 | my $buffer = shift ; | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | # ASCII:  B   Z   h    0    9 | 
| 135 | 1135 |  |  |  |  | 12803 | return $buffer =~ qr/^\x42\x5A\x68[\x30-\x39]$/; | 
| 136 |  |  |  |  |  |  | } | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | 1 ; | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | __END__ |