| 1 | package IO::Compress::Gzip ; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 33 | ▶ | use strict ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 33 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 33 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 33 | require Exporter ; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 33 | ▶ | use IO::Compress::RawDeflate 2.225 () ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 33 | ▶ | use IO::Compress::Adapter::Deflate 2.225 ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 33 | ▶ | use IO::Compress::Base::Common 2.225 qw(:Status ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 33 | ▶ | use IO::Compress::Gzip::Constants 2.225 ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 33 | ▶ | use IO::Compress::Zlib::Extra 2.225 ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | BEGIN | ||||||||||||||||||||||||||||
| 17 | 33 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||
| 18 | 33 | ▶ | if (defined &utf8::downgrade ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 33 | { *noUTF8 = \&utf8::downgrade } | |||||||||||||||||||||||||||
| 20 | else | ||||||||||||||||||||||||||||
| 21 | 0 | ▶ | { *noUTF8 = sub {} } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 33 | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $GzipError); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 33 | $VERSION = '2.225'; | |||||||||||||||||||||||||||
| 27 | 33 | $GzipError = '' ; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 33 | @ISA = qw(IO::Compress::RawDeflate Exporter); | |||||||||||||||||||||||||||
| 30 | 33 | @EXPORT_OK = qw( $GzipError gzip ) ; | |||||||||||||||||||||||||||
| 31 | 33 | %EXPORT_TAGS = %IO::Compress::RawDeflate::DEFLATE_CONSTANTS ; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 33 | ▶ | $EXPORT_TAGS{all} = [ defined $EXPORT_TAGS{all} ? @{ $EXPORT_TAGS{all} } : (), @EXPORT_OK ] ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 33 | Exporter::export_ok_tags('all'); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub new | ||||||||||||||||||||||||||||
| 37 | 322 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 322 | my $class = shift ; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 322 | my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$GzipError); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 322 | $obj->_create(undef, @_); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | sub gzip | ||||||||||||||||||||||||||||
| 47 | 162 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
gzip: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | 162 | my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$GzipError); | |||||||||||||||||||||||||||
| 49 | 162 | return $obj->_def(@_); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | #sub newHeader | ||||||||||||||||||||||||||||
| 53 | #{ | ||||||||||||||||||||||||||||
| 54 | # my $self = shift ; | ||||||||||||||||||||||||||||
| 55 | # #return GZIP_MINIMUM_HEADER ; | ||||||||||||||||||||||||||||
| 56 | # return $self->mkHeader(*$self->{Got}); | ||||||||||||||||||||||||||||
| 57 | #} | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub getExtraParams | ||||||||||||||||||||||||||||
| 60 | 487 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getExtraParams: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 487 | my $self = shift ; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | return ( | ||||||||||||||||||||||||||||
| 64 | # zlib behaviour | ||||||||||||||||||||||||||||
| 65 | 487 | $self->getZlibParams(), | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # Gzip header fields | ||||||||||||||||||||||||||||
| 68 | 'minimal' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||||||||||||||||||||||||||
| 69 | 'comment' => [IO::Compress::Base::Common::Parse_any, undef], | ||||||||||||||||||||||||||||
| 70 | 'name' => [IO::Compress::Base::Common::Parse_any, undef], | ||||||||||||||||||||||||||||
| 71 | 'time' => [IO::Compress::Base::Common::Parse_any, undef], | ||||||||||||||||||||||||||||
| 72 | 'textflag' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||||||||||||||||||||||||||
| 73 | 'headercrc' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||||||||||||||||||||||||||
| 74 | 'os_code' => [IO::Compress::Base::Common::Parse_unsigned, $Compress::Raw::Zlib::gzip_os_code], | ||||||||||||||||||||||||||||
| 75 | 'extrafield'=> [IO::Compress::Base::Common::Parse_any, undef], | ||||||||||||||||||||||||||||
| 76 | 'extraflags'=> [IO::Compress::Base::Common::Parse_any, undef], | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | sub ckParams | ||||||||||||||||||||||||||||
| 83 | 483 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
ckParams: called CC=23 SCAR=31.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 84 | 483 | my $self = shift ; | |||||||||||||||||||||||||||
| 85 | 483 | my $got = shift ; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | # gzip always needs crc32 | ||||||||||||||||||||||||||||
| 88 | 483 | $got->setValue('crc32' => 1); | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 483 | ▶ | return 1 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | if $got->getValue('merge') ; | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 454 | my $strict = $got->getValue('strict') ; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||
| 97 | 454 | ▶ | if (! $got->parsed('time') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | # Modification time defaults to now. | ||||||||||||||||||||||||||||
| 99 | 388 | $got->setValue(time => time) ; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | # Check that the Name & Comment don't have embedded NULLs | ||||||||||||||||||||||||||||
| 103 | # Also check that they only contain ISO 8859-1 chars. | ||||||||||||||||||||||||||||
| 104 | 454 | ▶ | if ($got->parsed('name') && defined $got->getValue('name')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$got->parsed("name") and defined $got->getValue("name")
MC/DC100%2/2
$got->parsed("name") and defined $got->getValue("name")
$got->parsed("name")
defined $got->getValue("name")
Truth table100%3/3
A and B
A= $got->parsed("name")B= defined $got->getValue("name")
| |||||||||||||||||||||||||||||
| 105 | 89 | my $name = $got->getValue('name'); | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 89 | ▶ | return $self->saveErrorString(undef, "Null Character found in Name", | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$strict and $name =~ /\x00/
MC/DC100%2/2
$strict and $name =~ /\x00/
$strict
$name =~ /\x00/
Truth table100%3/3
A and B
A= $strictB= $name =~ /\x00/
| |||||||||||||||||||||||||||||
| 108 | Z_DATA_ERROR) | ||||||||||||||||||||||||||||
| 109 | if $strict && $name =~ /\x00/ ; | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 87 | ▶ | return $self->saveErrorString(undef, "Non ISO 8859-1 Character found in Name", | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$strict and $name =~ /$IO::Compress::Gzip::GZIP_FNAME_INVALID_CHAR_RE/o
MC/DC100%2/2
$strict and $name =~ /$IO::Compress::Gzip::GZIP_FNAME_INVALID_CHAR_RE/o
$strict
$name =~ /$IO::Compress::Gzip::GZIP_FNAME_INVALID_CHAR_RE/o
Truth table100%3/3
A and B
A= $strictB= $name =~ /$IO::Compress::Gzip::GZIP_FNAME_INVALID_CHAR_RE/o
| |||||||||||||||||||||||||||||
| 112 | Z_DATA_ERROR) | ||||||||||||||||||||||||||||
| 113 | if $strict && $name =~ /$GZIP_FNAME_INVALID_CHAR_RE/o ; | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 451 | ▶ | if ($got->parsed('comment') && defined $got->getValue('comment')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$got->parsed("comment") and defined $got->getValue("comment")
MC/DC100%2/2
$got->parsed("comment") and defined $got->getValue("comment")
$got->parsed("comment")
defined $got->getValue("comment")
Truth table100%3/3
A and B
A= $got->parsed("comment")B= defined $got->getValue("comment")
| |||||||||||||||||||||||||||||
| 117 | 39 | my $comment = $got->getValue('comment'); | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 39 | ▶ | return $self->saveErrorString(undef, "Null Character found in Comment", | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$strict and $comment =~ /\x00/
MC/DC100%2/2
$strict and $comment =~ /\x00/
$strict
$comment =~ /\x00/
Truth table100%3/3
A and B
A= $strictB= $comment =~ /\x00/
| |||||||||||||||||||||||||||||
| 120 | Z_DATA_ERROR) | ||||||||||||||||||||||||||||
| 121 | if $strict && $comment =~ /\x00/ ; | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 37 | ▶ | return $self->saveErrorString(undef, "Non ISO 8859-1 Character found in Comment", | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$strict and $comment =~ /$IO::Compress::Gzip::GZIP_FCOMMENT_INVALID_CHAR_RE/o
MC/DC100%2/2
$strict and $comment =~ /$IO::Compress::Gzip::GZIP_FCOMMENT_INVALID_CHAR_RE/o
$strict
$comment =~ /$IO::Compress::Gzip::GZIP_FCOMMENT_INVALID_CHAR_RE/o
Truth table100%3/3
A and B
A= $strictB= $comment =~ /$IO::Compress::Gzip::GZIP_FCOMMENT_INVALID_CHAR_RE/o
| |||||||||||||||||||||||||||||
| 124 | Z_DATA_ERROR) | ||||||||||||||||||||||||||||
| 125 | if $strict && $comment =~ /$GZIP_FCOMMENT_INVALID_CHAR_RE/o; | ||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 448 | ▶ | if ($got->parsed('os_code') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 6 | my $value = $got->getValue('os_code'); | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 6 | ▶ | return $self->saveErrorString(undef, "OS_Code must be between 0 and 255, got '$value'") | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$value < 0 or $value > 255
MC/DC50%1/2
$value < 0 or $value > 255
$value < 0
$value > 255
Truth table66%2/3
A or B
A= $value < 0B= $value > 255
| |||||||||||||||||||||||||||||
| 132 | if $value < 0 || $value > 255 ; | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | # gzip only supports Deflate at present | ||||||||||||||||||||||||||||
| 137 | 447 | $got->setValue('method' => Z_DEFLATED) ; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 447 | ▶ | if ( ! $got->parsed('extraflags')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 446 | ▶ | $got->setValue('extraflags' => 2) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | if $got->getValue('level') == Z_BEST_COMPRESSION ; | ||||||||||||||||||||||||||||
| 142 | 446 | ▶ | $got->setValue('extraflags' => 4) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | if $got->getValue('level') == Z_BEST_SPEED ; | ||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 447 | my $data = $got->getValue('extrafield') ; | |||||||||||||||||||||||||||
| 147 | 447 | ▶ | if (defined $data) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 82 | my $bad = IO::Compress::Zlib::Extra::parseExtraField($data, $strict, 1) ; | |||||||||||||||||||||||||||
| 149 | 82 | ▶ | return $self->saveErrorString(undef, "Error with ExtraField Parameter: $bad", Z_DATA_ERROR) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | if $bad ; | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 62 | $got->setValue('extrafield' => $data) ; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 427 | return 1; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub mkTrailer | ||||||||||||||||||||||||||||
| 160 | 449 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
mkTrailer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 161 | 449 | my $self = shift ; | |||||||||||||||||||||||||||
| 162 | return pack("V V", *$self->{Compress}->crc32(), | ||||||||||||||||||||||||||||
| 163 | 449 | *$self->{UnCompSize}->get32bit()); | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | sub getInverseClass | ||||||||||||||||||||||||||||
| 167 | 25 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getInverseClass: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 168 | 33 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 169 | 25 | return ('IO::Uncompress::Gunzip', | |||||||||||||||||||||||||||
| 170 | \$IO::Uncompress::Gunzip::GunzipError); | ||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | sub getFileInfo | ||||||||||||||||||||||||||||
| 174 | 110 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getFileInfo: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 175 | 110 | my $self = shift ; | |||||||||||||||||||||||||||
| 176 | 110 | my $params = shift; | |||||||||||||||||||||||||||
| 177 | 110 | my $filename = shift ; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 110 | ▶ | return if IO::Compress::Base::Common::isaScalar($filename); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 66 | my $defaultTime = (stat($filename))[9] ; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 66 | ▶ | $params->setValue('name' => $filename) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | if ! $params->parsed('name') ; | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 66 | ▶ | $params->setValue('time' => $defaultTime) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | if ! $params->parsed('time') ; | ||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | sub mkHeader | ||||||||||||||||||||||||||||
| 192 | 429 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
mkHeader: called CC=15 SCAR=27.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 193 | 429 | my $self = shift ; | |||||||||||||||||||||||||||
| 194 | 429 | my $param = shift ; | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | # short-circuit if a minimal header is requested. | ||||||||||||||||||||||||||||
| 197 | 429 | ▶ | return GZIP_MINIMUM_HEADER if $param->getValue('minimal') ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | # METHOD | ||||||||||||||||||||||||||||
| 200 | 392 | my $method = $param->valueOrDefault('method', GZIP_CM_DEFLATED) ; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | # FLAGS | ||||||||||||||||||||||||||||
| 203 | 392 | my $flags = GZIP_FLG_DEFAULT ; | |||||||||||||||||||||||||||
| 204 | 392 | ▶ | $flags |= GZIP_FLG_FTEXT if $param->getValue('textflag') ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 392 | ▶ | $flags |= GZIP_FLG_FHCRC if $param->getValue('headercrc') ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 392 | ▶ | $flags |= GZIP_FLG_FEXTRA if $param->wantValue('extrafield') ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 392 | ▶ | $flags |= GZIP_FLG_FNAME if $param->wantValue('name') ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 392 | ▶ | $flags |= GZIP_FLG_FCOMMENT if $param->wantValue('comment') ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | # MTIME | ||||||||||||||||||||||||||||
| 211 | 392 | my $time = $param->valueOrDefault('time', GZIP_MTIME_DEFAULT) ; | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | # EXTRA FLAGS | ||||||||||||||||||||||||||||
| 214 | 392 | my $extra_flags = $param->valueOrDefault('extraflags', GZIP_XFL_DEFAULT); | |||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | # OS CODE | ||||||||||||||||||||||||||||
| 217 | 392 | my $os_code = $param->valueOrDefault('os_code', GZIP_OS_DEFAULT) ; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 392 | my $out = pack("C4 V C C", | |||||||||||||||||||||||||||
| 221 | GZIP_ID1, # ID1 | ||||||||||||||||||||||||||||
| 222 | GZIP_ID2, # ID2 | ||||||||||||||||||||||||||||
| 223 | $method, # Compression Method | ||||||||||||||||||||||||||||
| 224 | $flags, # Flags | ||||||||||||||||||||||||||||
| 225 | $time, # Modification Time | ||||||||||||||||||||||||||||
| 226 | $extra_flags, # Extra Flags | ||||||||||||||||||||||||||||
| 227 | $os_code, # Operating System Code | ||||||||||||||||||||||||||||
| 228 | ) ; | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | # EXTRA | ||||||||||||||||||||||||||||
| 231 | 392 | ▶ | if ($flags & GZIP_FLG_FEXTRA) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 62 | my $extra = $param->getValue('extrafield') ; | |||||||||||||||||||||||||||
| 233 | 62 | $out .= pack("v", length $extra) . $extra ; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | # NAME | ||||||||||||||||||||||||||||
| 237 | 392 | ▶ | if ($flags & GZIP_FLG_FNAME) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 95 | my $name .= $param->getValue('name') ; | |||||||||||||||||||||||||||
| 239 | 95 | $name =~ s/\x00.*$//; | |||||||||||||||||||||||||||
| 240 | 95 | $out .= $name ; | |||||||||||||||||||||||||||
| 241 | # Terminate the filename with NULL unless it already is | ||||||||||||||||||||||||||||
| 242 | 95 | ▶ | $out .= GZIP_NULL_BYTE | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not length $name or substr($name, 1, -1) ne "\0"
MC/DC0%0/2
not length $name or substr($name, 1, -1) ne "\0"
not length $name
substr($name, 1, -1) ne "\0"
Truth table66%2/3
not(A) or B
A= not length $nameB= substr($name, 1, -1) ne "\0"
| |||||||||||||||||||||||||||||
| 243 | if !length $name or | ||||||||||||||||||||||||||||
| 244 | substr($name, 1, -1) ne GZIP_NULL_BYTE ; | ||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | # COMMENT | ||||||||||||||||||||||||||||
| 248 | 392 | ▶ | if ($flags & GZIP_FLG_FCOMMENT) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 55 | my $comment .= $param->getValue('comment') ; | |||||||||||||||||||||||||||
| 250 | 55 | $comment =~ s/\x00.*$//; | |||||||||||||||||||||||||||
| 251 | 55 | $out .= $comment ; | |||||||||||||||||||||||||||
| 252 | # Terminate the comment with NULL unless it already is | ||||||||||||||||||||||||||||
| 253 | 55 | ▶ | $out .= GZIP_NULL_BYTE | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not length $comment or substr($comment, 1, -1) ne "\0"
MC/DC0%0/2
not length $comment or substr($comment, 1, -1) ne "\0"
not length $comment
substr($comment, 1, -1) ne "\0"
Truth table66%2/3
not(A) or B
A= not length $commentB= substr($comment, 1, -1) ne "\0"
| |||||||||||||||||||||||||||||
| 254 | if ! length $comment or | ||||||||||||||||||||||||||||
| 255 | substr($comment, 1, -1) ne GZIP_NULL_BYTE; | ||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | # HEADER CRC | ||||||||||||||||||||||||||||
| 259 | 392 | ▶ | $out .= pack("v", Compress::Raw::Zlib::crc32($out) & 0x00FF ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 260 | if $param->getValue('headercrc') ; | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 392 | noUTF8($out); | |||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 392 | return $out ; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | sub mkFinalTrailer | ||||||||||||||||||||||||||||
| 268 | 418 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
mkFinalTrailer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 269 | 418 | return ''; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 33 | 1; | |||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | __END__ | ||||||||||||||||||||||||||||