| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# $Id$ |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# file::base64 Brik |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
package Metabrik::File::Base64; |
|
7
|
1
|
|
|
1
|
|
832
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
833
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
|
13
|
|
|
|
|
|
|
return { |
|
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
|
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
|
16
|
|
|
|
|
|
|
author => 'GomoR ', |
|
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
|
18
|
|
|
|
|
|
|
attributes => { |
|
19
|
|
|
|
|
|
|
encoding => [ qw(utf8|ascii) ], |
|
20
|
|
|
|
|
|
|
}, |
|
21
|
|
|
|
|
|
|
attributes_default => { |
|
22
|
|
|
|
|
|
|
encoding => 'ascii', |
|
23
|
|
|
|
|
|
|
}, |
|
24
|
|
|
|
|
|
|
commands => { |
|
25
|
|
|
|
|
|
|
decode => [ qw(input output) ], |
|
26
|
|
|
|
|
|
|
decode_from_string => [ qw(input_string output) ], |
|
27
|
|
|
|
|
|
|
encode => [ qw(input output) ], |
|
28
|
|
|
|
|
|
|
encode_from_string => [ qw(input_string output) ], |
|
29
|
|
|
|
|
|
|
}, |
|
30
|
|
|
|
|
|
|
require_modules => { |
|
31
|
|
|
|
|
|
|
'Metabrik::File::Raw' => [ ], |
|
32
|
|
|
|
|
|
|
'Metabrik::String::Base64' => [ ], |
|
33
|
|
|
|
|
|
|
}, |
|
34
|
|
|
|
|
|
|
}; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub decode { |
|
38
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
39
|
0
|
|
|
|
|
|
my ($input, $output) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('decode', $input) or return; |
|
42
|
0
|
0
|
|
|
|
|
$self->brik_help_run_file_not_found('decode', $input) or return; |
|
43
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('decode', $output) or return; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
my $fr_in = Metabrik::File::Raw->new_from_brik_init($self) or return; |
|
46
|
0
|
|
|
|
|
|
$fr_in->encoding($self->encoding); |
|
47
|
0
|
0
|
|
|
|
|
my $string = $fr_in->read($input) or return; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
my $sb = Metabrik::String::Base64->new_from_brik_init($self) or return; |
|
50
|
0
|
0
|
|
|
|
|
my $decoded = $sb->decode($string) or return; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
my $fr_out = Metabrik::File::Raw->new_from_brik_init($self) or return; |
|
53
|
0
|
|
|
|
|
|
$fr_out->encoding($self->encoding); |
|
54
|
0
|
|
|
|
|
|
$fr_out->overwrite(1); |
|
55
|
0
|
|
|
|
|
|
$fr_out->append(0); |
|
56
|
0
|
0
|
|
|
|
|
$fr_out->write($decoded, $output) or return; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $output; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub decode_from_string { |
|
62
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
63
|
0
|
|
|
|
|
|
my ($input_string, $output) = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('decode_from_string', $input_string,) or return; |
|
66
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('decode_from_string', $output) or return; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
my $sb = Metabrik::String::Base64->new_from_brik_init($self) or return; |
|
69
|
0
|
0
|
|
|
|
|
my $decoded = $sb->decode($input_string) or return; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
my $fr = Metabrik::File::Raw->new_from_brik_init($self) or return; |
|
72
|
0
|
|
|
|
|
|
$fr->encoding($self->encoding); |
|
73
|
0
|
|
|
|
|
|
$fr->overwrite(1); |
|
74
|
0
|
|
|
|
|
|
$fr->append(0); |
|
75
|
0
|
0
|
|
|
|
|
$fr->write($decoded, $output) or return; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return $output; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub encode { |
|
81
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
82
|
0
|
|
|
|
|
|
my ($input, $output) = @_; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('encode', $input) or return; |
|
85
|
0
|
0
|
|
|
|
|
$self->brik_help_run_file_not_found('encode', $input) or return; |
|
86
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('encode', $output) or return; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
my $fr_in = Metabrik::File::Raw->new_from_brik_init($self) or return; |
|
89
|
0
|
|
|
|
|
|
$fr_in->encoding($self->encoding); |
|
90
|
0
|
0
|
|
|
|
|
my $string = $fr_in->read($input) or return; |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
my $sb = Metabrik::String::Base64->new_from_brik_init($self) or return; |
|
93
|
0
|
0
|
|
|
|
|
my $encoded = $sb->encode($string) or return; |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
my $fr_out = Metabrik::File::Raw->new_from_brik_init($self) or return; |
|
96
|
0
|
|
|
|
|
|
$fr_out->encoding($self->encoding); |
|
97
|
0
|
|
|
|
|
|
$fr_out->overwrite(1); |
|
98
|
0
|
|
|
|
|
|
$fr_out->append(0); |
|
99
|
0
|
0
|
|
|
|
|
$fr_out->write($encoded, $output) or return; |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return $output; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub encode_from_string { |
|
105
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
106
|
0
|
|
|
|
|
|
my ($input_string, $output) = @_; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('encode_from_string', $input_string) or return; |
|
109
|
0
|
0
|
|
|
|
|
$self->brik_help_run_file_not_found('encode_from_string', $input_string) or return; |
|
110
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('encode_from_string', $output) or return; |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
my $sb = Metabrik::String::Base64->new_from_brik_init($self) or return; |
|
113
|
0
|
0
|
|
|
|
|
my $encoded = $sb->encode($input_string) or return; |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
my $fr = Metabrik::File::Raw->new_from_brik_init($self) or return; |
|
116
|
0
|
|
|
|
|
|
$fr->encoding($self->encoding); |
|
117
|
0
|
|
|
|
|
|
$fr->overwrite(1); |
|
118
|
0
|
|
|
|
|
|
$fr->append(0); |
|
119
|
0
|
0
|
|
|
|
|
$fr->write($encoded, $output) or return; |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
return $output; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__ |