diff options
| author | fukachan <fukachan> | 2002-06-30 14:27:47 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2002-06-30 14:27:47 +0000 |
| commit | 5ced694843e57240df7d44e5dcdc0adc20074de1 (patch) | |
| tree | c27ddbf85954631f4518ef99223c5f06ce60923f | |
| parent | abb9a19264611d3606159fb91f9235fd78824824 (diff) | |
| download | fml8-5ced694843e57240df7d44e5dcdc0adc20074de1.tar.gz fml8-5ced694843e57240df7d44e5dcdc0adc20074de1.tar.bz2 fml8-5ced694843e57240df7d44e5dcdc0adc20074de1.zip | |
fix comments. white spaces. FNF-ify.
| -rw-r--r-- | fml/lib/FML/Article.pm | 45 | ||||
| -rw-r--r-- | fml/lib/FML/Command.pm | 27 | ||||
| -rw-r--r-- | fml/lib/FML/Credential.pm | 49 | ||||
| -rw-r--r-- | fml/lib/Mail/Bounce/Postfix19991231.pm | 4 | ||||
| -rw-r--r-- | fml/lib/Tie/JournaledFile.pm | 11 |
5 files changed, 98 insertions, 38 deletions
diff --git a/fml/lib/FML/Article.pm b/fml/lib/FML/Article.pm index 05ad4bfd..828e89ad 100644 --- a/fml/lib/FML/Article.pm +++ b/fml/lib/FML/Article.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: Article.pm,v 1.39 2002/04/22 04:59:53 fukachan Exp $ +# $FML: Article.pm,v 1.40 2002/06/01 03:01:52 fukachan Exp $ # package FML::Article; @@ -17,22 +17,38 @@ use FML::Log qw(Log LogWarn LogError); =head1 NAME -FML::Article - manipulate ML article +FML::Article - manipulate an ML article and related information =head1 SYNOPSIS - use FML::Article; - $article = new FML::Article $curproc; - $header = $article->{ header }; - $body = $article->{ body }; + use FML::Article; + $article = new FML::Article $curproc; + + # get sequence number + my $id = $article->increment_id; + + # spool in the article before delivery + $article->spool_in($id); + + my $article_file = $article->filepath($article_id); =head1 DESCRIPTION C<$article> object is just a container which holds C<header> and C<body> object as hash keys. -The C<header> is an C<FML::Header> object +The C<header> is an C<FML::Header> object, +the C<body> is a C<Mail::Message> object and -the C<body> is a C<Mail::Message> object. +the C<message> is the whole of chains. + +new() sets up the $curproc as + + my $dupmsg = $curproc->{'incoming_message'}->{ message }->dup_header; + $curproc->{ article }->{ message } = $dupmsg; + $curproc->{ article }->{ header } = $dupmsg->whole_message_header; + $curproc->{ article }->{ body } = $dupmsg->whole_message_body; + +This is the basic structure of the article object. =head1 METHODS @@ -55,7 +71,7 @@ sub new my $me = {}; if (defined $curproc->{'incoming_message'}->{ message }) { - _setup_article_template($curproc); + _setup_article_template($curproc); } $me->{ curproc } = $curproc; @@ -241,7 +257,7 @@ sub _filepath use Mail::Message::Spool; my $spool = new Mail::Message::Spool; - my $args = { + my $args = { base_dir => $spool_dir, id => $id, use_subdir => $use_subdir, @@ -259,7 +275,7 @@ sub _filepath } -=head2 speculate_max_id($spool_dir) +=head2 speculate_max_id([$spool_dir]) scan the spool_dir and get max number among files in it It must be the max (latest) article number in its folder. @@ -275,6 +291,11 @@ max (latest) article number in its folder. sub speculate_max_id { my ($curproc, $spool_dir) = @_; + my $config = $curproc->{ config }; + + unless (defined $spool_dir) { + $spool_dir = $config->{ spool_dir }; + } use DirHandle; my $dh = new DirHandle $spool_dir; @@ -298,7 +319,7 @@ sub speculate_max_id =head1 SEE ALSO L<FML::Header>, -L<MailingList::Messsages>, +L<Mail::Message>, L<File::Sequence> =head1 AUTHOR diff --git a/fml/lib/FML/Command.pm b/fml/lib/FML/Command.pm index c35a4922..f658a76c 100644 --- a/fml/lib/FML/Command.pm +++ b/fml/lib/FML/Command.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: Command.pm,v 1.24 2002/04/07 05:08:23 fukachan Exp $ +# $FML: Command.pm,v 1.25 2002/04/07 05:35:08 fukachan Exp $ # package FML::Command; @@ -16,7 +16,7 @@ use FML::Log qw(Log LogWarn LogError); =head1 NAME -FML::Command - fml commands dispacher +FML::Command - fml command dispatcher =head1 SYNOPSIS @@ -28,8 +28,9 @@ FML::Command - fml commands dispacher C<FML::Command> is a wrapper and dispathcer for fml commands. AUTOLOAD() picks up the command request and dispatches -C<FML::Command::User::somoting> for the request. -Also, C<FML::Command::Admin::somoting> for the admin command request. +C<FML::Command::User::somoting> suitable for the request. +Also, C<FML::Command::Admin::somoting> for the admin command request +and makefml commands. =head1 METHODS @@ -64,6 +65,8 @@ sub DESTROY { ;} rewrite the specified buffer $rbuf (STR_REF). $rbuf is rewritten as a result. +For example, this function is used to hide the password in the $rbuf +buffer. =cut @@ -77,8 +80,9 @@ sub rewrite_prompt my ($self, $curproc, $command_args, $rbuf) = @_; my $command = undef; my $comname = $command_args->{ comname }; - my $mode = $command_args->{'command_mode'} =~ /admin/i ? 'Admin' : 'User'; - my $pkg = "FML::Command::${mode}::${comname}"; + my $mode = + $command_args->{'command_mode'} =~ /admin/i ? 'Admin' : 'User'; + my $pkg = "FML::Command::${mode}::${comname}"; eval qq{ use $pkg; \$command = new $pkg;}; unless ($@) { @@ -92,7 +96,7 @@ sub rewrite_prompt =head2 C<AUTOLOAD()> the command dispatcher. -It hooks up the C<command> request and loads the module +It hooks up the C<command> request and loads the module in C<FML::Command::command>. =cut @@ -109,7 +113,8 @@ sub AUTOLOAD # we need to ignore DESTROY() return if $AUTOLOAD =~ /DESTROY/; - # mode + # user mode by default + # XXX IMPORTANT: user mode if the given mode is invalid. my $mode = 'User'; if (defined $command_args->{ command_mode }) { $mode = @@ -141,6 +146,12 @@ sub AUTOLOAD $need_lock = 0 if $command_args->{ override_need_no_lock }; } } + else { + LogError("${pkg} has no need_lock method"); + $curproc->reply_message("Error: invalid command definition\n"); + $curproc->reply_message(" need_lock() is undefined\n"); + $curproc->reply_message(" Please contact the maintainer\n"); + } # run the actual process if ($command->can('process')) { diff --git a/fml/lib/FML/Credential.pm b/fml/lib/FML/Credential.pm index 7d2f2619..97f1cbc3 100644 --- a/fml/lib/FML/Credential.pm +++ b/fml/lib/FML/Credential.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: Credential.pm,v 1.24 2002/05/28 13:36:18 fukachan Exp $ +# $FML: Credential.pm,v 1.25 2002/06/01 05:02:31 fukachan Exp $ # package FML::Credential; @@ -73,7 +73,7 @@ sub DESTROY {} =head2 C<is_same_address($addr1, $addr2 [, $level])> -return 1 (same ) or 0 (different). +return 1 (same) or 0 (different). It returns 1 if C<$addr1> and C<$addr2> looks same within some ambiguity. The ambiguity is defined by the following rules: @@ -114,13 +114,15 @@ sub is_same_address my ($self, $xaddr, $yaddr, $max_level) = @_; my ($xuser, $xdomain) = split(/\@/, $xaddr); my ($yuser, $ydomain) = split(/\@/, $yaddr); - my $level = 0; + my $level = 0; + + # the max recursive level in comparison $max_level = $max_level || $self->{ _max_level } || 3; - # rule 1 + # rule 1: case sensitive if ($xuser ne $yuser) { return 0;} - # rule 2 + # rule 2: case insensitive if ("\L$xdomain\E" eq "\L$ydomain\E") { return 1;} # rule 3: compare a.b.c.d.jp in reverse order @@ -156,8 +158,9 @@ sub is_member my ($self, $curproc, $args) = @_; my $config = $curproc->{ config }; my $member_maps = $config->get_as_array_ref('member_maps'); - my $address = $args->{ address } || $curproc->{'credential'}->{'sender'}; - my $status = 0; + my $address = (defined $args->{ address } ? + $args->{ address } : + $curproc->{'credential'}->{'sender'}); $self->_is_member($curproc, $args, { address => $address, @@ -175,7 +178,9 @@ sub is_privileged_member my ($self, $curproc, $args) = @_; my $config = $curproc->{ config }; my $member_maps = $config->get_as_array_ref('admin_member_maps'); - my $address = $args->{ address } || $curproc->{'credential'}->{'sender'}; + my $address = (defined $args->{ address } ? + $args->{ address } : + $curproc->{'credential'}->{'sender'}); $self->_is_member($curproc, $args, { address => $address, @@ -191,11 +196,16 @@ sub is_privileged_member sub _is_member { my ($self, $curproc, $args, $optargs) = @_; + my $status = 0; + my $user = ''; + my $domain = ''; + + # cheap sanity + return 0 unless defined $optargs->{ member_maps }; + return 0 unless defined $optargs->{ address }; + my $member_maps = $optargs->{ member_maps }; my $address = $optargs->{ address }; - my $status = 0; - my $user = ''; - my $domain = ''; if (defined $address) { ($user, $domain) = split(/\@/, $address); @@ -325,7 +335,13 @@ return the number of C<level>. sub set_compare_level { my ($self, $level) = @_; - $self->{ _max_level } = $level; + + if ($level =~ /^\d+$/) { + $self->{ _max_level } = $level; + } + else { + croak("set_compare_level: invalid input ($level)"); + } } @@ -364,6 +380,7 @@ sub get return $self->{ $key }; } else { + warn("Credential::get: invalid input { key=$key }"); return ''; } } @@ -376,7 +393,13 @@ sub get sub set { my ($self, $key, $value) = @_; - $self->{ $key } = $value; + + if (defined $value) { + $self->{ $key } = $value; + } + else { + croak("set: invalid input { $key => $value }"); + } } diff --git a/fml/lib/Mail/Bounce/Postfix19991231.pm b/fml/lib/Mail/Bounce/Postfix19991231.pm index f4b2de00..abc9e2de 100644 --- a/fml/lib/Mail/Bounce/Postfix19991231.pm +++ b/fml/lib/Mail/Bounce/Postfix19991231.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: Postfix19991231.pm,v 1.16 2002/02/01 12:04:01 fukachan Exp $ +# $FML: Postfix19991231.pm,v 1.17 2002/05/21 08:37:16 fukachan Exp $ # @@ -87,7 +87,7 @@ sub _analyze_plaintext my $m = $msg->{ next }; do { if (defined $m) { - my $num = $m->num_paragraph; + my $num = $m->num_paragraph; for ( my $i = 0; $i < $num ; $i++ ) { my $data = $m->nth_paragraph( $i + 1 ); diff --git a/fml/lib/Tie/JournaledFile.pm b/fml/lib/Tie/JournaledFile.pm index 7744f097..f16f8a4e 100644 --- a/fml/lib/Tie/JournaledFile.pm +++ b/fml/lib/Tie/JournaledFile.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: JournaledFile.pm,v 1.14 2002/02/02 08:04:55 fukachan Exp $ +# $FML: JournaledFile.pm,v 1.15 2002/06/01 03:01:56 fukachan Exp $ # package Tie::JournaledFile; @@ -109,8 +109,8 @@ sub new sub TIEHASH { my ($self, $args) = @_; - my ($type) = ref($self) || $self; $args->{ 'last_match' } = 1; + new($self, $args); } @@ -122,6 +122,7 @@ sub TIEHASH sub FETCH { my ($self, $key) = @_; + $self->_fetch($key, 'scalar'); } @@ -133,6 +134,7 @@ sub FETCH sub STORE { my ($self, $key, $value) = @_; + $self->_store($key, $value); } @@ -183,7 +185,10 @@ sub NEXTKEY # duplicated (already returned key) if (defined $self->{ '_key_negative_cache' }->{ $key }) { - print STDERR " File.NEXTKEY: $key (dup, ignored)\n" if $debug; + if ($debug) { + print STDERR " File.NEXTKEY: $key (dup, ignored)\n"; + } + next LOOP; } else { |
