line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# string::gzip Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::String::Compress; |
7
|
1
|
|
|
1
|
|
659
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik::System::Package); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
526
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable gzip gunzip unzip uncompress) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
data => [ qw($data) ], |
20
|
|
|
|
|
|
|
memory_limit => [ qw(integer) ], |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
attributes_default => { |
23
|
|
|
|
|
|
|
memory_limit => '1_000_000_000', # XXX: to implement |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
commands => { |
26
|
|
|
|
|
|
|
install => [ ], # Inherited |
27
|
|
|
|
|
|
|
gunzip => [ qw($data) ], |
28
|
|
|
|
|
|
|
gzip => [ qw($data) ], |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
require_modules => { |
31
|
|
|
|
|
|
|
'Gzip::Faster' => [ ], |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
need_packages => { |
34
|
|
|
|
|
|
|
ubuntu => [ qw(libz-dev) ], |
35
|
|
|
|
|
|
|
debian => [ qw(libz-dev) ], |
36
|
|
|
|
|
|
|
kali => [ qw(libz-dev) ], |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub gunzip { |
42
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
my ($data) = @_; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('gunzip', $data) or return; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if (! length($data)) { |
48
|
0
|
|
|
|
|
|
return $self->log->error("gunzip: empty data, nothing to decompress"); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$self->log->debug("gunzip: length[".length($data)."]"); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$self->log->debug("gunzip: starting"); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $plain = Gzip::Faster::gunzip($data); |
56
|
0
|
0
|
|
|
|
|
if (! defined($plain)) { |
57
|
0
|
|
|
|
|
|
return $self->log->error("gunzip: error"); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$self->log->debug("gunzip: finished"); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$self->log->debug("gunzip: length[".length($plain)."]"); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return \$plain; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub gzip { |
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
my ($data) = @_; |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('gzip', $data) or return; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
if (! length($data)) { |
74
|
0
|
|
|
|
|
|
return $self->log->error("gzip: empty data, nothing to compress"); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $gzipped = Gzip::Faster::gzip($data); |
78
|
0
|
0
|
|
|
|
|
if (! defined($gzipped)) { |
79
|
0
|
|
|
|
|
|
return $self->log->error("gzip: error"); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return \$gzipped; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |