summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-10-10 10:08:06 +0000
committerfukachan <fukachan>2001-10-10 10:08:06 +0000
commit6dbf79f4f8b4473e8eb7da4e75e2dcce6780ed39 (patch)
tree687cb9c5fe4636a9166c6a11e5ef56d405c866f5
parent6f3e0dd06672c507fd53ae910d4ef2aeb66490e7 (diff)
downloadfml8-6dbf79f4f8b4473e8eb7da4e75e2dcce6780ed39.tar.gz
fml8-6dbf79f4f8b4473e8eb7da4e75e2dcce6780ed39.tar.bz2
fml8-6dbf79f4f8b4473e8eb7da4e75e2dcce6780ed39.zip
make command get,mget,help work
-rw-r--r--fml/lib/FML/Command/User/get.pm68
-rw-r--r--fml/lib/FML/Command/User/help.pm23
-rw-r--r--fml/lib/FML/Process/Command.pm6
3 files changed, 88 insertions, 9 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");
+ }
}
diff --git a/fml/lib/FML/Process/Command.pm b/fml/lib/FML/Process/Command.pm
index 69d9fb3a..4e9f1225 100644
--- a/fml/lib/FML/Process/Command.pm
+++ b/fml/lib/FML/Process/Command.pm
@@ -4,7 +4,7 @@
# Copyright (C) 2000,2001 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: Command.pm,v 1.11 2001/10/08 20:30:06 fukachan Exp $
+# $FML: Command.pm,v 1.12 2001/10/10 03:12:51 fukachan Exp $
#
package FML::Process::Command;
@@ -136,6 +136,9 @@ sub _evaluate_command
my $argv = $config->{ main_cf }->{ ARGV };
my $body = $curproc->{ incoming_message }->{ body }->data_in_body_part;
my @body = split(/\n/, $body);
+ my $prompt = $config->{ command_prompt } || '>>>';
+
+ $curproc->reply_message("result for your command requests follows:\n");
COMMAND:
for my $command (@body) {
@@ -160,6 +163,7 @@ sub _evaluate_command
use FML::Command;
my $obj = new FML::Command;
if (defined $obj) {
+ $curproc->reply_message("$prompt $command");
eval q{
$obj->$comname($curproc, $optargs);
};