summaryrefslogtreecommitdiff
path: root/fml/lib/Mail
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-10-20 07:44:13 +0000
committerfukachan <fukachan>2001-10-20 07:44:13 +0000
commit55fbf5277ac4e29b45c651d27b3579ed70ce2028 (patch)
treec49d00f8fe686737f95ef9d0c9c0fd90eb2c6d08 /fml/lib/Mail
parente98e75629925f3766167f60882736c3af61c1137 (diff)
downloadfml8-55fbf5277ac4e29b45c651d27b3579ed70ce2028.tar.gz
fml8-55fbf5277ac4e29b45c651d27b3579ed70ce2028.tar.bz2
fml8-55fbf5277ac4e29b45c651d27b3579ed70ce2028.zip
bug fix: $InComingMessage should not local scope. modify it to SCALAR REF
bug fix: data_in_body_part() returns whole data not the first 512 bytes bug if $size is specified as argument, return the first $size bytes. feature: get_data_type_list() returns ARRAY of xxx/yyy by default for other method use. If under $debug mdoe, it shows verbose output.
Diffstat (limited to 'fml/lib/Mail')
-rw-r--r--fml/lib/Mail/Message.pm47
1 files changed, 31 insertions, 16 deletions
diff --git a/fml/lib/Mail/Message.pm b/fml/lib/Mail/Message.pm
index 51528daf..498a9c95 100644
--- a/fml/lib/Mail/Message.pm
+++ b/fml/lib/Mail/Message.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Message.pm,v 1.28 2001/09/23 12:18:13 fukachan Exp $
+# $FML: Message.pm,v 1.29 2001/09/23 14:28:17 fukachan Exp $
#
package Mail::Message;
@@ -237,6 +237,10 @@ sub new
my ($self, $args) = @_;
my ($type) = ref($self) || $self;
my $me = {};
+ my $data = '';
+
+ # alloc memory area to hold the whole message.
+ $InComingMessage = \$data;
bless $me, $type;
@@ -459,7 +463,7 @@ sub parse
$ref_body->prev_message( $me );
# return information
- $result->{ body_size } = length($InComingMessage);
+ $result->{ body_size } = length($$InComingMessage);
$me->{ data_info } = $result;
# return the object
@@ -483,19 +487,19 @@ sub _parse
if (($p = index($buf, "\n\n", 0)) > 0) {
$header = substr($buf, 0, $p + 1);
$header_size = $p + 1;
- $InComingMessage = substr($buf, $p + 2);
+ $$InComingMessage = substr($buf, $p + 2);
last;
}
}
- # extract mail body and put it to $InComingMessage
+ # extract mail body and put it to $$InComingMessage
while ($p = sysread($fd, $_, 1024)) {
$total_buffer_size += $p;
- $InComingMessage .= $_;
+ $$InComingMessage .= $_;
}
# read the message (mail body) from the incoming mail
- my $body_size = length($InComingMessage);
+ my $body_size = length($$InComingMessage);
if ($debug > 2) {
print STDERR " (debug) header_size: $header_size\n";
@@ -572,7 +576,7 @@ sub _build_body_object
return new Mail::Message {
boundary => $self->_header_mime_boundary($result->{ header }),
data_type => $self->_header_data_type($result->{ header }),
- data => \$InComingMessage,
+ data => $InComingMessage,
};
}
@@ -1725,7 +1729,7 @@ sub data
}
-=head2 C<header_in_body_part($size)>
+=head2 C<header_in_body_part()>
return header in the message content.
It is not mail header but header for each message such as
@@ -1733,8 +1737,10 @@ mime header information of one part in a multipart.
=head2 C<data_in_body_part($size)>
-get body part in the message content,
-which is the whole mail (plain text) or a part of multipart.
+get body part in the message content, which is the whole mail (plain
+text) or body part of a block of multipart.
+
+If C<$size> is specified, return the first $size bytes in the body.
=cut
@@ -1773,9 +1779,12 @@ sub data_in_body_part
$msglen = length($$data);
}
- $size ||= 512;
- if ($msglen < $size) { $size = $msglen;}
- return substr($$data, $pos_begin, $size);
+ if (defined $size) {
+ return substr($$data, $pos_begin, $size);
+ }
+ else {
+ return substr($$data, $pos_begin, $msglen);
+ }
}
@@ -1848,14 +1857,20 @@ This is defined for debug and removed in the future.
# Return Value: none
sub get_data_type_list
{
- my ($msg) = @_;
+ my ($msg, $args) = @_;
my ($m, @buf, $i);
+ my $debug = defined $args->{ debug } ? 1 : 0;
for ($i = 0, $m = $msg; defined $m ; $m = $m->{ 'next' }) {
$i++;
my $data = $m->{'data'};
- push(@buf, sprintf("type[%2d]: %-25s | %s",
- $i, $m->{'data_type'}, $m->{'base_data_type'}));
+ if ($debug) {
+ push(@buf, sprintf("type[%2d]: %-25s | %s",
+ $i, $m->{'data_type'}, $m->{'base_data_type'}));
+ }
+ else {
+ push(@buf, $m->{'data_type'});
+ }
}
\@buf;
}