line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dicom::DCMTK::DCMQRSCP::Config; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
5
|
|
|
5
|
|
27896
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
132
|
|
5
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
166
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Modules. |
8
|
5
|
|
|
5
|
|
3850
|
use Class::Utils qw(set_params); |
|
5
|
|
|
|
|
142513
|
|
|
5
|
|
|
|
|
111
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Version. |
11
|
|
|
|
|
|
|
our $VERSION = 0.03; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Constructor. |
14
|
|
|
|
|
|
|
sub new { |
15
|
8
|
|
|
8
|
1
|
6648
|
my ($class, @params) = @_; |
16
|
8
|
|
|
|
|
18
|
my $self = bless {}, $class; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Defaults. |
19
|
8
|
|
|
|
|
27
|
$self->_default; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Comment. |
22
|
8
|
|
|
|
|
13
|
$self->{'comment'} = 1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Process params. |
25
|
8
|
|
|
|
|
31
|
set_params($self, @params); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Object. |
28
|
6
|
|
|
|
|
148
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Parse configuration. |
32
|
|
|
|
|
|
|
sub parse { |
33
|
3
|
|
|
3
|
1
|
1667468
|
my ($self, $data) = @_; |
34
|
3
|
|
|
|
|
25
|
$self->_default; |
35
|
3
|
|
|
|
|
11
|
my $stay = 0; |
36
|
3
|
|
|
|
|
49
|
foreach my $line (split m/\n/ms, $data) { |
37
|
47
|
100
|
100
|
|
|
447
|
if ($line =~ m/^\s*#/ms || $line =~ m/^\s*$/ms) { |
38
|
10
|
|
|
|
|
27
|
next; |
39
|
|
|
|
|
|
|
} |
40
|
37
|
100
|
100
|
|
|
857
|
if (($stay == 0 || $stay == 1) |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
41
|
|
|
|
|
|
|
&& $line =~ m/^\s*(\w+)\s*=\s*"?(\w+)"?\s*$/ms) { |
42
|
|
|
|
|
|
|
|
43
|
11
|
|
|
|
|
22
|
$stay = 1; |
44
|
11
|
|
|
|
|
71
|
$self->{'global'}->{$1} = $2; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Begin of host table. |
47
|
|
|
|
|
|
|
} elsif ($stay == 1 |
48
|
|
|
|
|
|
|
&& $line =~ m/^\s*HostTable\s+BEGIN\s*$/ms) { |
49
|
|
|
|
|
|
|
|
50
|
3
|
|
|
|
|
10
|
$stay = 2; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# End of host table. |
53
|
|
|
|
|
|
|
} elsif ($stay == 2 |
54
|
|
|
|
|
|
|
&& $line =~ m/^\s*HostTable\s+END\s*$/ms) { |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
|
|
10
|
$stay = 1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Host in host table. |
59
|
|
|
|
|
|
|
} elsif ($stay == 2 |
60
|
|
|
|
|
|
|
&& $line =~ m/^\s*(\w+)\s*=\s*\(([\d\.\w\s,]+)\)\s*$/ms) { |
61
|
|
|
|
|
|
|
|
62
|
6
|
|
|
|
|
91
|
$self->{'host_table'}->{$1} = [split m/\s*,\s*/ms, $2]; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Symbolic names in host table. |
65
|
|
|
|
|
|
|
} elsif ($stay == 2 |
66
|
|
|
|
|
|
|
&& $line =~ m/^\s*(\w+)\s*=\s*([\w\s,]+)\s*$/ms) { |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
14
|
$self->{'host_table_symb'}->{$1} |
69
|
|
|
|
|
|
|
= [split m/\s*,\s*/ms, $2]; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Begin of AE table. |
72
|
|
|
|
|
|
|
} elsif ($stay == 1 && $line =~ m/^\s*AETable\s+BEGIN\s*$/ms) { |
73
|
3
|
|
|
|
|
9
|
$stay = 3; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# End of AE table |
76
|
|
|
|
|
|
|
} elsif ($stay == 3 && $line =~ m/^\s*AETable\s+END\s*$/ms) { |
77
|
3
|
|
|
|
|
11
|
$stay = 1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# AE item. |
80
|
|
|
|
|
|
|
} elsif ($stay == 3 |
81
|
|
|
|
|
|
|
&& $line =~ m/^\s*(\w+)\s+([\/\w]+)\s+(\w+)\s+\(([^)]+)\)\s+(.*)$/ms) { |
82
|
|
|
|
|
|
|
|
83
|
4
|
|
|
|
|
33
|
my ($maxStudies, $maxBytesPerStudy) |
84
|
|
|
|
|
|
|
= split m/\s*,\s*/ms, $4; |
85
|
4
|
|
|
|
|
62
|
$self->{'ae_table'}->{$1} = { |
86
|
|
|
|
|
|
|
'StorageArea' => $2, |
87
|
|
|
|
|
|
|
'Access' => $3, |
88
|
|
|
|
|
|
|
'Quota' => { |
89
|
|
|
|
|
|
|
'maxStudies' => $maxStudies, |
90
|
|
|
|
|
|
|
'maxBytesPerStudy' => $maxBytesPerStudy, |
91
|
|
|
|
|
|
|
}, |
92
|
|
|
|
|
|
|
'Peers' => $5, |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Begin of vendor table |
96
|
|
|
|
|
|
|
} elsif ($stay == 1 |
97
|
|
|
|
|
|
|
&& $line =~ m/^\s*VendorTable\s+BEGIN\s*$/ms) { |
98
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
4
|
$stay = 4; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# End of vendor table. |
102
|
|
|
|
|
|
|
} elsif ($stay == 4 |
103
|
|
|
|
|
|
|
&& $line =~ m/^\s*VendorTable\s+END\s*$/ms) { |
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
4
|
$stay = 1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Item in vendor table. |
108
|
|
|
|
|
|
|
} elsif ($stay == 4 |
109
|
|
|
|
|
|
|
&& $line =~ m/^\s*"([^"]+)"\s*=\s*(\w+)\s*$/ms) { |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
7
|
$self->{'vendor_table'}->{$2} = $1; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
3
|
|
|
|
|
21
|
return; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# Serialize to configuration. |
118
|
|
|
|
|
|
|
sub serialize { |
119
|
4
|
|
|
4
|
1
|
36
|
my $self = shift; |
120
|
4
|
|
|
|
|
6
|
my @data; |
121
|
4
|
|
|
|
|
12
|
$self->_serialize_global(\@data); |
122
|
4
|
|
|
|
|
10
|
$self->_serialize_hosts(\@data); |
123
|
4
|
|
|
|
|
10
|
$self->_serialize_vendors(\@data); |
124
|
4
|
|
|
|
|
11
|
$self->_serialize_ae(\@data); |
125
|
4
|
|
|
|
|
30
|
return join "\n", @data; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Set variables to defaults. |
129
|
|
|
|
|
|
|
sub _default { |
130
|
11
|
|
|
11
|
|
24
|
my $self = shift; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# AE table. |
133
|
11
|
|
|
|
|
47
|
$self->{'ae_table'} = {}; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# Global parameters. |
136
|
11
|
|
|
|
|
86
|
$self->{'global'} = { |
137
|
|
|
|
|
|
|
'NetworkTCPPort' => undef, |
138
|
|
|
|
|
|
|
'MaxPDUSize' => undef, |
139
|
|
|
|
|
|
|
'MaxAssociations' => undef, |
140
|
|
|
|
|
|
|
'UserName' => undef, |
141
|
|
|
|
|
|
|
'GroupName' => undef, |
142
|
|
|
|
|
|
|
}; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# Host table. |
145
|
11
|
|
|
|
|
36
|
$self->{'host_table'} = {}; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# Host table symbolic names. |
148
|
11
|
|
|
|
|
32
|
$self->{'host_table_symb'} = {}; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# Vendor table. |
151
|
11
|
|
|
|
|
25
|
$self->{'vendor_table'} = {}; |
152
|
|
|
|
|
|
|
|
153
|
11
|
|
|
|
|
25
|
return; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# Serialize AE titles. |
157
|
|
|
|
|
|
|
sub _serialize_ae { |
158
|
4
|
|
|
4
|
|
5
|
my ($self, $data_ar) = @_; |
159
|
4
|
50
|
|
|
|
11
|
if (! keys %{$self->{'ae_table'}}) { |
|
4
|
|
|
|
|
12
|
|
160
|
0
|
|
|
|
|
0
|
return; |
161
|
|
|
|
|
|
|
} |
162
|
4
|
100
|
|
|
|
10
|
if ($self->{'comment'}) { |
163
|
3
|
50
|
|
|
|
3
|
if (@{$data_ar}) { |
|
3
|
|
|
|
|
7
|
|
164
|
3
|
|
|
|
|
3
|
push @{$data_ar}, ''; |
|
3
|
|
|
|
|
6
|
|
165
|
|
|
|
|
|
|
} |
166
|
3
|
|
|
|
|
4
|
push @{$data_ar}, '# AE Table.'; |
|
3
|
|
|
|
|
10
|
|
167
|
|
|
|
|
|
|
} |
168
|
4
|
|
|
|
|
5
|
push @{$data_ar}, 'AETable BEGIN'; |
|
4
|
|
|
|
|
7
|
|
169
|
4
|
|
|
|
|
5
|
foreach my $key (sort keys %{$self->{'ae_table'}}) { |
|
4
|
|
|
|
|
12
|
|
170
|
5
|
|
|
|
|
8
|
my $storage_area = $self->{'ae_table'}->{$key}->{'StorageArea'}; |
171
|
5
|
|
|
|
|
9
|
my $access = $self->{'ae_table'}->{$key}->{'Access'}; |
172
|
5
|
|
|
|
|
7
|
my $peers = $self->{'ae_table'}->{$key}->{'Peers'}; |
173
|
|
|
|
|
|
|
my $max_studies = $self->{'ae_table'}->{$key}->{'Quota'} |
174
|
5
|
|
|
|
|
7
|
->{'maxStudies'}; |
175
|
|
|
|
|
|
|
my $max_bytes_per_study = $self->{'ae_table'}->{$key} |
176
|
5
|
|
|
|
|
10
|
->{'Quota'}->{'maxBytesPerStudy'}; |
177
|
5
|
|
|
|
|
6
|
push @{$data_ar}, "$key $storage_area $access ". |
|
5
|
|
|
|
|
23
|
|
178
|
|
|
|
|
|
|
"($max_studies, $max_bytes_per_study) $peers"; |
179
|
|
|
|
|
|
|
} |
180
|
4
|
|
|
|
|
5
|
push @{$data_ar}, 'AETable END'; |
|
4
|
|
|
|
|
8
|
|
181
|
4
|
|
|
|
|
6
|
return; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# Serialize global parameters. |
185
|
|
|
|
|
|
|
sub _serialize_global { |
186
|
4
|
|
|
4
|
|
7
|
my ($self, $data_ar) = @_; |
187
|
4
|
100
|
|
|
|
5
|
if (! map { defined $self->{'global'}->{$_} ? $_ : () } |
|
20
|
50
|
|
|
|
56
|
|
188
|
4
|
|
|
|
|
14
|
keys %{$self->{'global'}}) { |
189
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
0
|
return; |
191
|
|
|
|
|
|
|
} |
192
|
4
|
100
|
|
|
|
14
|
if ($self->{'comment'}) { |
193
|
3
|
50
|
|
|
|
4
|
if (@{$data_ar}) { |
|
3
|
|
|
|
|
9
|
|
194
|
0
|
|
|
|
|
0
|
push @{$data_ar}, ''; |
|
0
|
|
|
|
|
0
|
|
195
|
|
|
|
|
|
|
} |
196
|
3
|
|
|
|
|
5
|
push @{$data_ar}, '# Global Configuration Parameters.'; |
|
3
|
|
|
|
|
7
|
|
197
|
|
|
|
|
|
|
} |
198
|
4
|
|
|
|
|
5
|
foreach my $key (sort keys %{$self->{'global'}}) { |
|
4
|
|
|
|
|
21
|
|
199
|
20
|
100
|
|
|
|
48
|
if (! defined $self->{'global'}->{$key}) { |
200
|
6
|
|
|
|
|
11
|
next; |
201
|
|
|
|
|
|
|
} |
202
|
14
|
|
|
|
|
17
|
my $value = $self->{'global'}->{$key}; |
203
|
14
|
100
|
|
|
|
51
|
if ($value !~ m/^\d+$/ms) { |
204
|
2
|
|
|
|
|
5
|
$value = '"'.$value.'"'; |
205
|
|
|
|
|
|
|
} |
206
|
14
|
|
|
|
|
15
|
push @{$data_ar}, $key.' = '.$value; |
|
14
|
|
|
|
|
44
|
|
207
|
|
|
|
|
|
|
} |
208
|
4
|
|
|
|
|
9
|
return; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# Serialize hosts table. |
212
|
|
|
|
|
|
|
sub _serialize_hosts { |
213
|
4
|
|
|
4
|
|
6
|
my ($self, $data_ar) = @_; |
214
|
4
|
50
|
|
|
|
5
|
if (! keys %{$self->{'host_table'}}) { |
|
4
|
|
|
|
|
13
|
|
215
|
0
|
|
|
|
|
0
|
return; |
216
|
|
|
|
|
|
|
} |
217
|
4
|
100
|
|
|
|
11
|
if ($self->{'comment'}) { |
218
|
3
|
50
|
|
|
|
4
|
if (@{$data_ar}) { |
|
3
|
|
|
|
|
7
|
|
219
|
3
|
|
|
|
|
4
|
push @{$data_ar}, ''; |
|
3
|
|
|
|
|
6
|
|
220
|
|
|
|
|
|
|
} |
221
|
3
|
|
|
|
|
4
|
push @{$data_ar}, '# Host Table.'; |
|
3
|
|
|
|
|
6
|
|
222
|
|
|
|
|
|
|
} |
223
|
4
|
|
|
|
|
4
|
push @{$data_ar}, 'HostTable BEGIN'; |
|
4
|
|
|
|
|
6
|
|
224
|
4
|
|
|
|
|
26
|
foreach my $key (sort keys %{$self->{'host_table'}}) { |
|
4
|
|
|
|
|
11
|
|
225
|
7
|
|
|
|
|
8
|
my ($ae, $host, $port) = @{$self->{'host_table'}->{$key}}; |
|
7
|
|
|
|
|
14
|
|
226
|
7
|
|
|
|
|
9
|
push @{$data_ar}, "$key = ($ae, $host, $port)"; |
|
7
|
|
|
|
|
30
|
|
227
|
|
|
|
|
|
|
} |
228
|
4
|
|
|
|
|
6
|
foreach my $key (sort keys %{$self->{'host_table_symb'}}) { |
|
4
|
|
|
|
|
10
|
|
229
|
1
|
|
|
|
|
3
|
push @{$data_ar}, "$key = ". |
230
|
1
|
|
|
|
|
2
|
(join ", ", @{$self->{'host_table_symb'}->{$key}}); |
|
1
|
|
|
|
|
5
|
|
231
|
|
|
|
|
|
|
} |
232
|
4
|
|
|
|
|
5
|
push @{$data_ar}, 'HostTable END'; |
|
4
|
|
|
|
|
6
|
|
233
|
4
|
|
|
|
|
7
|
return; |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
# Serialize vendors table. |
237
|
|
|
|
|
|
|
sub _serialize_vendors { |
238
|
4
|
|
|
4
|
|
6
|
my ($self, $data_ar) = @_; |
239
|
4
|
100
|
|
|
|
4
|
if (! keys %{$self->{'vendor_table'}}) { |
|
4
|
|
|
|
|
26
|
|
240
|
3
|
|
|
|
|
6
|
return; |
241
|
|
|
|
|
|
|
} |
242
|
1
|
50
|
|
|
|
4
|
if ($self->{'comment'}) { |
243
|
1
|
50
|
|
|
|
2
|
if (@{$data_ar}) { |
|
1
|
|
|
|
|
4
|
|
244
|
1
|
|
|
|
|
2
|
push @{$data_ar}, ''; |
|
1
|
|
|
|
|
2
|
|
245
|
|
|
|
|
|
|
} |
246
|
1
|
|
|
|
|
2
|
push @{$data_ar}, '# Vendor Table.'; |
|
1
|
|
|
|
|
3
|
|
247
|
|
|
|
|
|
|
} |
248
|
1
|
|
|
|
|
1
|
push @{$data_ar}, 'VendorTable BEGIN'; |
|
1
|
|
|
|
|
2
|
|
249
|
1
|
|
|
|
|
2
|
foreach my $key (sort keys %{$self->{'vendor_table'}}) { |
|
1
|
|
|
|
|
3
|
|
250
|
1
|
|
|
|
|
2
|
my $desc = '"'.$self->{'vendor_table'}->{$key}.'"'; |
251
|
1
|
|
|
|
|
2
|
push @{$data_ar}, "$desc = $key"; |
|
1
|
|
|
|
|
4
|
|
252
|
|
|
|
|
|
|
} |
253
|
1
|
|
|
|
|
2
|
push @{$data_ar}, 'VendorTable END'; |
|
1
|
|
|
|
|
2
|
|
254
|
1
|
|
|
|
|
2
|
return; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
1; |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
__END__ |