diff options
| author | fukachan <fukachan> | 2001-10-10 10:08:06 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-10-10 10:08:06 +0000 |
| commit | 6dbf79f4f8b4473e8eb7da4e75e2dcce6780ed39 (patch) | |
| tree | 687cb9c5fe4636a9166c6a11e5ef56d405c866f5 /fml/lib/FML/Command/User | |
| parent | 6f3e0dd06672c507fd53ae910d4ef2aeb66490e7 (diff) | |
| download | fml8-6dbf79f4f8b4473e8eb7da4e75e2dcce6780ed39.tar.gz fml8-6dbf79f4f8b4473e8eb7da4e75e2dcce6780ed39.tar.bz2 fml8-6dbf79f4f8b4473e8eb7da4e75e2dcce6780ed39.zip | |
make command get,mget,help work
Diffstat (limited to 'fml/lib/FML/Command/User')
| -rw-r--r-- | fml/lib/FML/Command/User/get.pm | 68 | ||||
| -rw-r--r-- | fml/lib/FML/Command/User/help.pm | 23 |
2 files changed, 83 insertions, 8 deletions
diff --git a/fml/lib/FML/Command/User/get.pm b/fml/lib/FML/Command/User/get.pm index 8b48267a..fd3d917f 100644 --- a/fml/lib/FML/Command/User/get.pm +++ b/fml/lib/FML/Command/User/get.pm @@ -1,10 +1,10 @@ #-*- perl -*- -f# +# # Copyright (C) 2001 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: get.pm,v 1.1.1.1 2001/08/26 05:43:10 fukachan Exp $ +# $FML: get.pm,v 1.2 2001/08/26 07:59:03 fukachan Exp $ # package FML::Command::User::get; @@ -14,6 +14,7 @@ use Carp; use ErrorStatus; use FML::Command::Utils; +use FML::Log qw(Log LogWarn LogError); @ISA = qw(FML::Command::Utils ErrorStatus); =head1 NAME @@ -35,10 +36,65 @@ not yet implemented sub process { - my ($self) = @_; - my ($type) = ref($self) || $self; - my $me = {}; - return bless $me, $type; + my ($self, $curproc, $optargs) = @_; + my $config = $curproc->{ config }; + my $member_map = $config->{ primary_member_map }; + my $recipient_map = $config->{ primary_recipient_map }; + my $options = $optargs->{ options }; + my $address = $optargs->{ address } || $options->[ 0 ]; + + my $command = $optargs->{ command }; + my $ml_name = $config->{ ml_name }; + my $spool_dir = $config->{ spool_dir }; + my $charset = $config->{ template_file_charset }; + + # command buffer = get 1 + # command buffer = get 1,2,3 + # command buffer = get last:3 + my (@files) = split(/\s+/, $optargs->{ command }); + for my $fn (@files) { + my $filelist = _is_valid_argument($fn); + if (defined $filelist) { + for my $fn (@$filelist) { + my $file = "$spool_dir/$fn"; + if (-f $file) { + Log("send back article $fn"); + $curproc->reply_message( { + type => "message/rfc822; charset=$charset", + path => $file, + filename => $fn, + disposition => "$ml_name ML article $fn", + }); + } + else { + Log("no such file: $file"); + } + } + } + } +} + + +sub _is_valid_argument +{ + my ($fn) = @_; + + if ($fn =~ /^\d+$/) { + return [ $fn ]; + } + elsif ($fn =~ /^[\d,]+$/) { + my (@fn) = split(/,/, $fn); + return \@fn; + } + elsif ($fn =~ /^(\d+)\-(\d+)$/) { + my ($first, $last) = ($1, $2); + my (@fn); + for ($first .. $last) { push(@fn, $_);} + return \@fn; + } + else { + return undef; + } } diff --git a/fml/lib/FML/Command/User/help.pm b/fml/lib/FML/Command/User/help.pm index 587eccbe..6c17b541 100644 --- a/fml/lib/FML/Command/User/help.pm +++ b/fml/lib/FML/Command/User/help.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: help.pm,v 1.2 2001/08/26 07:58:39 fukachan Exp $ +# $FML: help.pm,v 1.1 2001/10/08 15:54:42 fukachan Exp $ # package FML::Command::User::help; @@ -40,10 +40,29 @@ sub process my $config = $curproc->{ config }; my $member_map = $config->{ primary_member_map }; my $recipient_map = $config->{ primary_recipient_map }; + my $charset = $config->{ template_file_charset }; + my $help_file = $config->{ help_file }; my $options = $optargs->{ options }; my $address = $optargs->{ address } || $options->[ 0 ]; - $curproc->reply_message("help message (dummy ;-)"); + # *** template substitution *** + # 1. in Japanese case, convert kanji code: iso-2022-jp -> euc + # 2. expand variables: $ml_name -> elena + # 3. back kanji code: euc -> iso-2022-jp + # 4. return the new created template + my $help_template = $curproc->expand_variables_in_file( $help_file ); + + if (-f $help_file) { + $curproc->reply_message( { + type => "text/plain; charset=$charset", + path => $help_template, + filename => "help", + disposition => "help", + }); + } + else { + croak("no help file ($help_file)\n"); + } } |
