line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Lite::Processor::Chain; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
84
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
60
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use Mail::Lite::Constants; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
171
|
|
7
|
2
|
|
|
2
|
|
11
|
use Smart::Comments -ENV; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
20
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1050
|
use Data::Dumper; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
857
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub process { |
13
|
72
|
|
|
72
|
0
|
155
|
my $args_ref = shift; |
14
|
|
|
|
|
|
|
|
15
|
72
|
|
|
|
|
181
|
my $input_ref = $args_ref->{input }; |
16
|
72
|
|
|
|
|
181
|
my $rule_ref = $args_ref->{rule }; |
17
|
72
|
|
|
|
|
130
|
my $all_rules = $args_ref->{rules }; |
18
|
|
|
|
|
|
|
|
19
|
72
|
|
|
|
|
142
|
my $rule_name = $rule_ref->{id}; |
20
|
|
|
|
|
|
|
|
21
|
72
|
|
|
|
|
317
|
my $processor_obj = new Mail::Lite::Processor; |
22
|
|
|
|
|
|
|
|
23
|
72
|
|
|
|
|
177
|
$processor_obj->{chained} = 1; |
24
|
|
|
|
|
|
|
|
25
|
72
|
|
|
|
|
1054
|
my $regexp = qr/^_$rule_name\.(.*)/; |
26
|
72
|
|
|
|
|
208
|
my @rules; |
27
|
|
|
|
|
|
|
|
28
|
72
|
|
|
|
|
113
|
foreach my $rule (@{ $all_rules }) { |
|
72
|
|
|
|
|
180
|
|
29
|
2420
|
100
|
|
|
|
12587
|
next unless $rule->{id} =~ $regexp; |
30
|
323
|
|
|
|
|
2343
|
push @rules, { %$rule, id => $rule_name.'.'.$1 }; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
72
|
|
|
|
|
240
|
$processor_obj->{rules} = \@rules; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#warn Dumper($processor_obj); |
36
|
|
|
|
|
|
|
|
37
|
72
|
|
|
|
|
127
|
my @output; |
38
|
|
|
|
|
|
|
|
39
|
72
|
100
|
|
|
|
343
|
ref $input_ref eq 'ARRAY' |
40
|
|
|
|
|
|
|
or $input_ref = [ $input_ref ]; |
41
|
|
|
|
|
|
|
|
42
|
72
|
|
|
|
|
149
|
foreach my $message (@$input_ref) { |
43
|
|
|
|
|
|
|
my $handler_sub = sub { |
44
|
|
|
|
|
|
|
### @_ |
45
|
232
|
|
|
232
|
|
429
|
my $rule_id = shift; |
46
|
232
|
|
|
|
|
409
|
my $result = shift->[0]; |
47
|
|
|
|
|
|
|
|
48
|
232
|
|
|
|
|
611
|
my $param = { |
49
|
|
|
|
|
|
|
rule_id => $rule_id, |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
232
|
50
|
|
|
|
1210
|
if ( ref $result eq 'HASH' ) { |
53
|
232
|
|
|
|
|
1932
|
%$param = (%$result, %$param); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
0
|
|
|
|
|
0
|
$param->{result} = $result; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
232
|
|
|
|
|
4018
|
push @output, $param; |
60
|
233
|
|
|
|
|
1636
|
}; |
61
|
|
|
|
|
|
|
|
62
|
233
|
|
|
|
|
1041
|
$processor_obj->process( |
63
|
|
|
|
|
|
|
message => $message, |
64
|
|
|
|
|
|
|
handler => $handler_sub, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
72
|
|
|
|
|
300
|
${ $args_ref->{ output } } = \@output; |
|
72
|
|
|
|
|
323
|
|
69
|
|
|
|
|
|
|
|
70
|
72
|
50
|
66
|
|
|
705
|
return ! exists $rule_ref->{last} || $rule_ref->{last} ? STOP_RULE : OK; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |