line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sisimai::Mail::Memory; |
2
|
4
|
|
|
4
|
|
69069
|
use feature ':5.10'; |
|
4
|
|
|
|
|
38
|
|
|
4
|
|
|
|
|
457
|
|
3
|
4
|
|
|
4
|
|
26
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
87
|
|
4
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
206
|
|
5
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
6
|
4
|
|
|
|
|
40
|
'new' => 0, |
7
|
|
|
|
|
|
|
'ro' => [ |
8
|
|
|
|
|
|
|
'path', # [String] Fixed string "" |
9
|
|
|
|
|
|
|
'size', # [Integer] data size |
10
|
|
|
|
|
|
|
], |
11
|
|
|
|
|
|
|
'rw' => [ |
12
|
|
|
|
|
|
|
'payload', # [Array] entire bounce mail message |
13
|
|
|
|
|
|
|
'offset', # [Integer] Index of "data" |
14
|
|
|
|
|
|
|
] |
15
|
4
|
|
|
4
|
|
476
|
); |
|
4
|
|
|
|
|
1244
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
|
|
|
|
|
|
# Constructor of Sisimai::Mail::Memory |
19
|
|
|
|
|
|
|
# @param [String] argv1 Entire email string |
20
|
|
|
|
|
|
|
# @return [Sisimai::Mail::Memory] Object |
21
|
|
|
|
|
|
|
# [Undef] is not a valid email text |
22
|
7
|
|
|
7
|
1
|
2346
|
my $class = shift; |
23
|
7
|
|
100
|
|
|
30
|
my $argv1 = shift // return undef; |
24
|
6
|
|
100
|
|
|
38
|
my $param = { |
25
|
|
|
|
|
|
|
'payload' => [], |
26
|
|
|
|
|
|
|
'path' => '', |
27
|
|
|
|
|
|
|
'size' => length $$argv1 || 0, |
28
|
|
|
|
|
|
|
'offset' => 0, |
29
|
|
|
|
|
|
|
}; |
30
|
6
|
100
|
|
|
|
25
|
return undef unless $param->{'size'}; |
31
|
|
|
|
|
|
|
|
32
|
5
|
100
|
50
|
|
|
31
|
if( (substr($$argv1, 0, 5) || '') eq 'From ') { |
33
|
|
|
|
|
|
|
# UNIX mbox |
34
|
3
|
|
|
|
|
609
|
$param->{'payload'} = [split(/^From /m, $$argv1)]; |
35
|
3
|
|
|
|
|
13
|
shift @{ $param->{'payload'} }; |
|
3
|
|
|
|
|
9
|
|
36
|
3
|
|
|
|
|
6
|
$_ = 'From '.$_ for @{ $param->{'payload'} }; |
|
3
|
|
|
|
|
131
|
|
37
|
|
|
|
|
|
|
} else { |
38
|
2
|
|
|
|
|
9
|
$param->{'payload'} = [$$argv1]; |
39
|
|
|
|
|
|
|
} |
40
|
5
|
|
|
|
|
21
|
return bless($param, __PACKAGE__); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub read { |
44
|
|
|
|
|
|
|
# Memory reader, works as a iterator. |
45
|
|
|
|
|
|
|
# @return [String] Contents of a bounce mail |
46
|
42
|
|
|
42
|
1
|
65475
|
my $self = shift; |
47
|
42
|
100
|
|
|
|
56
|
return undef unless scalar @{ $self->{'payload'} }; |
|
42
|
|
|
|
|
126
|
|
48
|
|
|
|
|
|
|
|
49
|
39
|
|
|
|
|
60
|
$self->{'offset'} += 1; |
50
|
39
|
|
|
|
|
40
|
return shift @{ $self->{'payload'} }; |
|
39
|
|
|
|
|
110
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |