line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Connector::Proxy::Config::Std |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Proxy class for reading Config::Std configuration |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Written by Scott Hardin and Martin Bartosch for the OpenXPKI project 2012 |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use strict; |
9
|
2
|
|
|
2
|
|
255741
|
use warnings; |
|
2
|
|
|
|
|
22
|
|
|
2
|
|
|
|
|
50
|
|
10
|
2
|
|
|
2
|
|
9
|
use English; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
39
|
|
11
|
2
|
|
|
2
|
|
8
|
use Config::Std; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
12
|
2
|
|
|
2
|
|
1651
|
use Data::Dumper; |
|
2
|
|
|
|
|
32653
|
|
|
2
|
|
|
|
|
10
|
|
13
|
2
|
|
|
2
|
|
1183
|
|
|
2
|
|
|
|
|
11652
|
|
|
2
|
|
|
|
|
107
|
|
14
|
|
|
|
|
|
|
use Moose; |
15
|
2
|
|
|
2
|
|
899
|
extends 'Connector::Proxy'; |
|
2
|
|
|
|
|
777758
|
|
|
2
|
|
|
|
|
11
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
17
|
my $config; |
20
|
|
|
|
|
|
|
read_config($self->LOCATION(), $config); |
21
|
2
|
|
|
|
|
12
|
$self->_config($config); |
22
|
2
|
|
|
|
|
56
|
} |
23
|
2
|
|
|
|
|
4396
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $self = shift; |
26
|
|
|
|
|
|
|
my @path = $self->_build_path_with_prefix( shift ); |
27
|
|
|
|
|
|
|
|
28
|
22
|
|
|
22
|
1
|
44
|
# Config::Std does not allow nested data structures, emulate that |
29
|
22
|
|
|
|
|
53
|
# by separating last element from path and using that as key |
30
|
|
|
|
|
|
|
# in the section defined by the remaining prefix |
31
|
|
|
|
|
|
|
my $key = pop @path; |
32
|
|
|
|
|
|
|
my $section = $self->_build_section_name_from_path( @path); |
33
|
|
|
|
|
|
|
|
34
|
22
|
|
|
|
|
42
|
return $self->_config()->{$section}->{$key}; |
35
|
22
|
|
|
|
|
81
|
} |
36
|
|
|
|
|
|
|
|
37
|
22
|
|
|
|
|
402
|
|
38
|
|
|
|
|
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
my @path = $self->_build_path_with_prefix( shift ); |
40
|
|
|
|
|
|
|
my $fullpath = $self->_build_section_name_from_path( @path); |
41
|
|
|
|
|
|
|
return $self->_config()->{$fullpath}; |
42
|
3
|
|
|
3
|
|
6
|
} |
43
|
3
|
|
|
|
|
7
|
|
44
|
3
|
|
|
|
|
9
|
|
45
|
3
|
|
|
|
|
69
|
|
46
|
|
|
|
|
|
|
my $self = shift; |
47
|
|
|
|
|
|
|
my $node = $self->get( shift ); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
if (!defined $node) { |
50
|
|
|
|
|
|
|
return 0; |
51
|
1
|
|
|
1
|
1
|
7
|
} |
52
|
1
|
|
|
|
|
3
|
|
53
|
|
|
|
|
|
|
if (ref $node ne "ARRAY") { |
54
|
1
|
50
|
|
|
|
6
|
die "requested path looks not like a list"; |
55
|
0
|
|
|
|
|
0
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return scalar @{$node}; |
58
|
1
|
50
|
|
|
|
9
|
} |
59
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
2
|
my $self = shift; |
|
1
|
|
|
|
|
5
|
|
63
|
|
|
|
|
|
|
my $path = shift; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# List is similar to scalar, the last path item is a hash key |
66
|
|
|
|
|
|
|
# in the section of the remaining prefix |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
1
|
1
|
3
|
my $node = $self->get( $path ); |
69
|
1
|
|
|
|
|
2
|
|
70
|
|
|
|
|
|
|
if (!defined $node) { |
71
|
|
|
|
|
|
|
return $self->_node_not_exists( $path ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
3
|
if (ref $node ne "ARRAY") { |
75
|
|
|
|
|
|
|
die "requested path looks not like a hash"; |
76
|
1
|
50
|
|
|
|
6
|
} |
77
|
0
|
|
|
|
|
0
|
return @{$node}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
1
|
50
|
|
|
|
4
|
|
81
|
0
|
|
|
|
|
0
|
|
82
|
|
|
|
|
|
|
my $self = shift; |
83
|
1
|
|
|
|
|
2
|
my $node = $self->_get_node( shift ); |
|
1
|
|
|
|
|
4
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
if (!defined $node) { |
86
|
|
|
|
|
|
|
return @{[]}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
1
|
1
|
3
|
if (ref $node ne "HASH") { |
90
|
1
|
|
|
|
|
4
|
die "requested path looks not like a hash"; |
91
|
|
|
|
|
|
|
} |
92
|
1
|
50
|
|
|
|
10
|
return keys (%{$node}); |
93
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
1
|
50
|
|
|
|
6
|
my $self = shift; |
97
|
0
|
|
|
|
|
0
|
my $path = shift; |
98
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
1
|
my $node = $self->_get_node( $path ); |
|
1
|
|
|
|
|
5
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
if (!defined $node) { |
102
|
|
|
|
|
|
|
return $self->_node_not_exists($path); |
103
|
|
|
|
|
|
|
} |
104
|
2
|
|
|
2
|
1
|
583
|
|
105
|
2
|
|
|
|
|
5
|
if (ref $node ne "HASH") { |
106
|
|
|
|
|
|
|
die "requested path looks not like a hash"; |
107
|
2
|
|
|
|
|
4
|
} |
108
|
|
|
|
|
|
|
return $node; |
109
|
2
|
50
|
|
|
|
13
|
} |
110
|
0
|
|
|
|
|
0
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
2
|
50
|
|
|
|
7
|
my $self = shift; |
114
|
0
|
|
|
|
|
0
|
my $origin = shift; |
115
|
|
|
|
|
|
|
|
116
|
2
|
|
|
|
|
11
|
my @path = $self->_build_path_with_prefix( $origin ); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# We dont have a real tree, so we look if there is a config entry |
119
|
|
|
|
|
|
|
# that has the full path as key |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my $section = $self->_build_section_name_from_path( @path ); |
122
|
20
|
|
|
20
|
1
|
29
|
|
123
|
20
|
|
|
|
|
27
|
# As top node iteration is not supported we report a connector |
124
|
|
|
|
|
|
|
if (!$section) { |
125
|
20
|
|
|
|
|
48
|
return { 'TYPE' => 'connector'}; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# This is either a hash or undef |
129
|
|
|
|
|
|
|
my $node = $self->_config()->{$section}; |
130
|
20
|
|
|
|
|
44
|
my $meta; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# Array and scalar exist one level above |
133
|
20
|
100
|
|
|
|
39
|
if (!defined $node) { |
134
|
1
|
|
|
|
|
7
|
|
135
|
|
|
|
|
|
|
my $key = pop @path; |
136
|
|
|
|
|
|
|
$section = $self->_build_section_name_from_path( @path ); |
137
|
|
|
|
|
|
|
$node = $self->_config()->{$section}->{$key}; |
138
|
19
|
|
|
|
|
343
|
|
139
|
19
|
|
|
|
|
29
|
if (!defined $node) { |
140
|
|
|
|
|
|
|
return $self->_node_not_exists( \@path ); |
141
|
|
|
|
|
|
|
} |
142
|
19
|
100
|
|
|
|
47
|
if (ref $node eq '') { |
|
|
50
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$meta = {TYPE => "scalar", VALUE => $node }; |
144
|
14
|
|
|
|
|
26
|
} elsif (ref $node eq "SCALAR") { |
145
|
14
|
|
|
|
|
26
|
# I guess thats not supported |
146
|
14
|
|
|
|
|
249
|
$meta = {TYPE => "reference", VALUE => $$node }; |
147
|
|
|
|
|
|
|
} elsif (ref $node eq "ARRAY") { |
148
|
14
|
100
|
|
|
|
35
|
$meta = {TYPE => "list", VALUE => $node }; |
149
|
6
|
|
|
|
|
35
|
} else { |
150
|
|
|
|
|
|
|
die "Unsupported node type"; |
151
|
8
|
100
|
|
|
|
19
|
} |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
152
|
7
|
|
|
|
|
21
|
} elsif (ref $node eq "HASH") { |
153
|
|
|
|
|
|
|
$meta = {TYPE => "hash" }; |
154
|
|
|
|
|
|
|
} else { |
155
|
0
|
|
|
|
|
0
|
die "Unsupported node type"; |
156
|
|
|
|
|
|
|
} |
157
|
1
|
|
|
|
|
4
|
return $meta; |
158
|
|
|
|
|
|
|
} |
159
|
0
|
|
|
|
|
0
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
my $self = shift; |
162
|
5
|
|
|
|
|
11
|
|
163
|
|
|
|
|
|
|
my @path = $self->_build_path_with_prefix( shift ); |
164
|
0
|
|
|
|
|
0
|
|
165
|
|
|
|
|
|
|
# No path always exists |
166
|
13
|
|
|
|
|
43
|
if (!@path) { |
167
|
|
|
|
|
|
|
return 1; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# Test if it is a section |
171
|
4
|
|
|
4
|
1
|
7
|
my $section = $self->_build_section_name_from_path( @path ); |
172
|
|
|
|
|
|
|
if ($self->_config()->{$section}) { |
173
|
4
|
|
|
|
|
13
|
return 1; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
4
|
50
|
|
|
|
11
|
# Test if it is a node |
177
|
0
|
|
|
|
|
0
|
my $key = pop @path; |
178
|
|
|
|
|
|
|
$section = $self->_build_section_name_from_path( @path ); |
179
|
|
|
|
|
|
|
if (defined $self->_config()->{$section}->{$key}) { |
180
|
|
|
|
|
|
|
return 1; |
181
|
4
|
|
|
|
|
12
|
} |
182
|
4
|
100
|
|
|
|
90
|
|
183
|
1
|
|
|
|
|
5
|
return 0; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
3
|
|
|
|
|
8
|
# might be refined to use a section delimiter different from connector |
188
|
3
|
|
|
|
|
8
|
|
189
|
3
|
100
|
|
|
|
60
|
my $self = shift; |
190
|
2
|
|
|
|
|
22
|
return join( $self->DELIMITER() , @_ ); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
1
|
|
|
|
|
9
|
no Moose; |
194
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
1; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 Name |
199
|
|
|
|
|
|
|
|
200
|
66
|
|
|
66
|
|
86
|
Connector::Proxy::Config::Std |
201
|
66
|
|
|
|
|
1372
|
|
202
|
|
|
|
|
|
|
=head1 Description |