1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#-*- perl -*-
#
# Copyright (C) 2000,2001,2002,2003 Ken'ichi Fukamachi
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
# $FML: Parse.pm,v 1.28 2002/12/18 04:34:41 fukachan Exp $
#
package FML::Parse;
use strict;
use Carp;
use FML::Header;
use Mail::Message;
use FML::Config;
use FML::Log qw(Log LogWarn LogError);
=head1 NAME
FML::Parse - parse the incoming message
=head1 SYNOPSIS
$msg = new FML::Parse $curproc, \*STDIN;
=head1 DESCRIPTION
FML::Parse parses the incoming message. C<new()> analyses the data
injected from STDIN channel, by default, and split it to a set of mail
header and body. C<new()> returns a C<Mail::Message> object.
=head1 METHODS
=item new( $curproc, [$fd] )
C<$fd> is the file handle.
Normally C<$fd> is the handle for STDIN channel.
=cut
# Descriptions: parse message read from file handle $fd
# Arguments: OBJ($self) OBJ($curproc) HANDLE($fd)
# Side Effects: none
# Return Value: OBJ
sub new
{
my ($self, $curproc, $fd) = @_;
my $me = {};
bless $me, $self;
return $me->_parse($curproc, $fd);
}
# Descriptions: parse message read from file handle $fd
# Arguments: OBJ($self) OBJ($curproc) HANDLE($fd)
# Side Effects: none
# Return Value: OBJ
sub _parse
{
my ($self, $curproc, $fd) = @_;
use Mail::Message;
my $msg = Mail::Message->parse( {
fd => $fd,
header_class => 'FML::Header',
});
# log information
my $header_size = $msg->whole_message_header_size();
my $body_size = $msg->whole_message_body_size();
Log("read header=$header_size body=$body_size");
if (defined $msg->envelope_sender()) {
my $pcb = $curproc->{ pcb };
if (defined $pcb) {
$pcb->set('credential', 'unix-from', $msg->envelope_sender());
}
else {
LogError("parse: pcb not defined");
}
}
return $msg;
}
=head1 SEE ALSO
L<Mail::Message>,
L<Mail::Header>,
L<FML::Header>,
L<FML::Config>,
L<FML::Log>
=head1 CODING STYLE
See C<http://www.fml.org/software/FNF/> on fml coding style guide.
=head1 AUTHOR
Ken'ichi Fukamachi
=head1 COPYRIGHT
Copyright (C) 2000,2001,2002,2003 Ken'ichi Fukamachi
All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.
=head1 HISTORY
FML::Parse first appeared in fml8 mailing list driver package.
See C<http://www.fml.org/> for more details.
=cut
1;
|