| 1 | package IO::Uncompress::Bunzip2 ; | ||||||||||
| 2 | |||||||||||
| 3 | 87 | ▶ | use strict ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 87 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 87 | ▶ | use bytes; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 87 | ▶ | use IO::Compress::Base::Common 2.225 qw(:Status ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 87 | ▶ | use IO::Uncompress::Base 2.225 ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 87 | ▶ | use IO::Uncompress::Adapter::Bunzip2 2.225 ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 87 | require Exporter ; | |||||||||
| 13 | 87 | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $Bunzip2Error); | |||||||||
| 14 | |||||||||||
| 15 | 87 | $VERSION = '2.225'; | |||||||||
| 16 | 87 | $Bunzip2Error = ''; | |||||||||
| 17 | |||||||||||
| 18 | 87 | @ISA = qw(IO::Uncompress::Base Exporter); | |||||||||
| 19 | 87 | @EXPORT_OK = qw( $Bunzip2Error bunzip2 ) ; | |||||||||
| 20 | #%EXPORT_TAGS = %IO::Uncompress::Base::EXPORT_TAGS ; | ||||||||||
| 21 | 0 | ▶ | $EXPORT_TAGS{all} = [ defined $EXPORT_TAGS{all} ? @{ $EXPORT_TAGS{all} } : (), @EXPORT_OK ] ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | #Exporter::export_ok_tags('all'); | ||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | sub new | ||||||||||
| 26 | 514 | ▶ | { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 27 | 514 | my $class = shift ; | |||||||||
| 28 | 514 | my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$Bunzip2Error); | |||||||||
| 29 | |||||||||||
| 30 | 514 | $obj->_create(undef, 0, @_); | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | sub bunzip2 | ||||||||||
| 34 | 66 | ▶ | { | ||||||||
|
Subroutine
bunzip2: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 35 | 66 | my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$Bunzip2Error); | |||||||||
| 36 | 66 | return $obj->_inf(@_); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | sub getExtraParams | ||||||||||
| 40 | 563 | ▶ | { | ||||||||
|
Subroutine
getExtraParams: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 41 | return ( | ||||||||||
| 42 | 563 | '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 | 569 | ▶ | { | ||||||||
|
Subroutine
ckParams: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 50 | 569 | my $self = shift ; | |||||||||
| 51 | 569 | my $got = shift ; | |||||||||
| 52 | |||||||||||
| 53 | 569 | return 1; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | sub mkUncomp | ||||||||||
| 57 | 568 | ▶ | { | ||||||||
|
Subroutine
mkUncomp: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 58 | 568 | my $self = shift ; | |||||||||
| 59 | 568 | my $got = shift ; | |||||||||
| 60 | |||||||||||
| 61 | 568 | ▶ | my $magic = $self->ckMagic() | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | or return 0; | ||||||||||
| 63 | |||||||||||
| 64 | 516 | ▶ | *$self->{Info} = $self->readHeader($magic) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | or return undef ; | ||||||||||
| 66 | |||||||||||
| 67 | 516 | my $Small = $got->getValue('small'); | |||||||||
| 68 | 516 | my $Verbosity = $got->getValue('verbosity'); | |||||||||
| 69 | |||||||||||
| 70 | 516 | my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::Bunzip2::mkUncompObject( | |||||||||
| 71 | $Small, $Verbosity); | ||||||||||
| 72 | |||||||||||
| 73 | 516 | ▶ | return $self->saveErrorString(undef, $errstr, $errno) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | if ! defined $obj; | ||||||||||
| 75 | |||||||||||
| 76 | 516 | *$self->{Uncomp} = $obj; | |||||||||
| 77 | |||||||||||
| 78 | 516 | return 1; | |||||||||
| 79 | |||||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | |||||||||||
| 83 | sub ckMagic | ||||||||||
| 84 | 1177 | ▶ | { | ||||||||
|
Subroutine
ckMagic: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 85 | 1177 | my $self = shift; | |||||||||
| 86 | |||||||||||
| 87 | 1177 | my $magic ; | |||||||||
| 88 | 1177 | $self->smartReadExact(\$magic, 4); | |||||||||
| 89 | |||||||||||
| 90 | 1177 | *$self->{HeaderPending} = $magic ; | |||||||||
| 91 | |||||||||||
| 92 | 1177 | ▶ | return $self->HeaderError("Header size is " . | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | 4 . " bytes") | ||||||||||
| 94 | if length $magic != 4; | ||||||||||
| 95 | |||||||||||
| 96 | 1141 | ▶ | return $self->HeaderError("Bad Magic.") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 97 | if ! isBzip2Magic($magic) ; | ||||||||||
| 98 | |||||||||||
| 99 | |||||||||||
| 100 | 1074 | *$self->{Type} = 'bzip2'; | |||||||||
| 101 | 1074 | return $magic; | |||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | sub readHeader | ||||||||||
| 105 | 1074 | ▶ | { | ||||||||
|
Subroutine
readHeader: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 106 | 1074 | my $self = shift; | |||||||||
| 107 | 1074 | my $magic = shift ; | |||||||||
| 108 | |||||||||||
| 109 | 1074 | $self->pushBack($magic); | |||||||||
| 110 | 1074 | *$self->{HeaderPending} = ''; | |||||||||
| 111 | |||||||||||
| 112 | |||||||||||
| 113 | return { | ||||||||||
| 114 | 1074 | 'Type' => 'bzip2', | |||||||||
| 115 | 'FingerprintLength' => 4, | ||||||||||
| 116 | 'HeaderLength' => 4, | ||||||||||
| 117 | 'TrailerLength' => 0, | ||||||||||
| 118 | 'Header' => '$magic' | ||||||||||
| 119 | }; | ||||||||||
| 120 | |||||||||||
| 121 | } | ||||||||||
| 122 | |||||||||||
| 123 | sub chkTrailer | ||||||||||
| 124 | 1070 | ▶ | { | ||||||||
|
Subroutine
chkTrailer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 125 | 1070 | return STATUS_OK; | |||||||||
| 126 | } | ||||||||||
| 127 | |||||||||||
| 128 | |||||||||||
| 129 | |||||||||||
| 130 | sub isBzip2Magic | ||||||||||
| 131 | 1141 | ▶ | { | ||||||||
|
Subroutine
isBzip2Magic: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 132 | 1141 | my $buffer = shift ; | |||||||||
| 133 | |||||||||||
| 134 | # ASCII: B Z h 0 9 | ||||||||||
| 135 | 1141 | return $buffer =~ qr/^\x42\x5A\x68[\x30-\x39]$/; | |||||||||
| 136 | } | ||||||||||
| 137 | |||||||||||
| 138 | 87 | 1 ; | |||||||||
| 139 | |||||||||||
| 140 | __END__ | ||||||||||