summaryrefslogtreecommitdiff
path: root/fml/lib
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-02-12 14:48:10 +0000
committerfukachan <fukachan>2001-02-12 14:48:10 +0000
commitcc3c5801ca3b1ecaa57d75d9dcb070e7a6e4b176 (patch)
tree6e2e634185907ab61255500bc9a508f3853b2486 /fml/lib
parent1bae97a38f1fcdff7c8c5c0d4ca940802470dec1 (diff)
downloadfml8-cc3c5801ca3b1ecaa57d75d9dcb070e7a6e4b176.tar.gz
fml8-cc3c5801ca3b1ecaa57d75d9dcb070e7a6e4b176.tar.bz2
fml8-cc3c5801ca3b1ecaa57d75d9dcb070e7a6e4b176.zip
MailingList::Messages
clean up documentations fix get_content_type() check more whether $self is defined or not
Diffstat (limited to 'fml/lib')
-rw-r--r--fml/lib/MailingList/Messages.pm57
1 files changed, 35 insertions, 22 deletions
diff --git a/fml/lib/MailingList/Messages.pm b/fml/lib/MailingList/Messages.pm
index 559ef100..1469972e 100644
--- a/fml/lib/MailingList/Messages.pm
+++ b/fml/lib/MailingList/Messages.pm
@@ -730,17 +730,25 @@ return the message size.
return this message has empty content or not.
-=head2 C<set_log_function()>
-
-internal use. set CODE REFERENCE to the log function
-
=cut
+ my $total = 0;
sub size
{
my ($self) = @_;
- my $c = $self->{ content };
- length($$c);
+ my $rc = $self->{ content };
+ my $pb = $self->{ offset_begin };
+ my $pe = $self->{ offset_end };
+
+ if ((defined $pe) && (defined $pb)) {
+ if ($pe - $pb > 0) {
+ $total += ($pe - $pb);
+ return ($pe - $pb);
+ }
+ }
+ else {
+ defined $rc ? length($$rc) : 0;
+ }
}
@@ -748,11 +756,11 @@ sub is_empty
{
my ($self) = @_;
my $size = $self->size;
- my $c = $self->{ content };
+ my $rc = $self->{ content };
if ($size == 0) { return 1;}
if ($size <= 8) {
- if ($$c =~ /^\s*$/) { return 1;}
+ if ($$rc =~ /^\s*$/) { return 1;}
}
# false
@@ -760,13 +768,6 @@ sub is_empty
}
-sub set_log_function
-{
- my ($self, $fp) = @_;
- $self->{ _log_function } = $fp; # log function pointer
-}
-
-
sub get_content_type
{
my ($self) = @_;
@@ -799,11 +800,7 @@ where $body is the mail body (string).
sub get_content_header
{
my ($self, $size) = @_;
- my $content = $self->{ content };
- my $pos = index($$content, "\n\n", $self->{ offset_begin });
- my $len = $pos - $self->{ offset_begin };
-
- substr($$content, $self->{ offset_begin }, $len);
+ return defined $self->{ header } ? $self->{ header } : undef;
}
@@ -814,9 +811,11 @@ sub get_content_body
my $base_content_type = $self->{ base_content_type };
my ($pos, $pos_begin, $msglen);
+ # if the content is undef, do nothing.
+ return undef unless $content;
+
if ($base_content_type =~ /multipart/i) {
- $pos = index($$content, "\n\n", $self->{ offset_begin });
- $pos_begin = $pos + 2;
+ $pos_begin = $self->{ offset_begin };
$msglen = $self->{ offset_end } - $pos_begin;
}
else {
@@ -871,6 +870,20 @@ For example,
C<get_content_reference()>
returns the reference to the content of the message.
+=head2 C<set_log_function()>
+
+internal use. set CODE REFERENCE to the log function
+
+=cut
+
+sub set_log_function
+{
+ my ($self, $fp) = @_;
+ $self->{ _log_function } = $fp; # log function pointer
+}
+
+
+
=head1 APPENDIX (RFC2046 Appendix A)
Appendix A -- Collected Grammar