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