summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Process/Command.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-02-12 13:35:17 +0000
committerfukachan <fukachan>2001-02-12 13:35:17 +0000
commit761844e0279ee614f709d3df8135f3c3e5afc5ff (patch)
tree905075c518dbcc3932cf2f36aad7a1c5b85eca2b /fml/lib/FML/Process/Command.pm
parentace4941b4c7f66f7c83ec21ce19e02df3f96c858 (diff)
downloadfml8-761844e0279ee614f709d3df8135f3c3e5afc5ff.tar.gz
fml8-761844e0279ee614f709d3df8135f3c3e5afc5ff.tar.bz2
fml8-761844e0279ee614f709d3df8135f3c3e5afc5ff.zip
add command prototype
Diffstat (limited to 'fml/lib/FML/Process/Command.pm')
-rw-r--r--fml/lib/FML/Process/Command.pm126
1 files changed, 126 insertions, 0 deletions
diff --git a/fml/lib/FML/Process/Command.pm b/fml/lib/FML/Process/Command.pm
new file mode 100644
index 00000000..999688a8
--- /dev/null
+++ b/fml/lib/FML/Process/Command.pm
@@ -0,0 +1,126 @@
+#!/usr/local/bin/perl -w
+#-*- perl -*-
+#
+# Copyright (C) 2000 Ken'ichi Fukamachi
+# All rights reserved.
+#
+# $FML$
+#
+
+package FML::Process::Command;
+
+use vars qw($debug @ISA @EXPORT @EXPORT_OK);
+use strict;
+use Carp;
+
+use FML::Process::Kernel;
+use FML::Log qw(Log);
+use FML::Config;
+
+require Exporter;
+@ISA = qw(FML::Process::Kernel Exporter);
+
+
+sub new
+{
+ my ($self, $args) = @_;
+ my $type = ref($self) || $self;
+ my $curproc = new FML::Process::Kernel $args;
+ return bless $curproc, $type;
+}
+
+
+sub prepare
+{
+ my ($self, $args) = @_;
+ $self->SUPER::prepare($args);
+}
+
+
+sub verify_request
+{
+ my ($curproc, $args) = @_;
+ $curproc->verify_sender_credential();
+}
+
+sub run
+{
+ my ($curproc, $args) = @_;
+
+ $curproc->lock();
+ {
+ # user credential
+ my $cred = $curproc->{ credential };
+
+ # Q: the mail sender is a ML member?
+ if ($cred->is_member) {
+ _evaluate_command( $curproc );
+ }
+ }
+ $curproc->unlock();
+}
+
+
+sub finish
+{
+ my ($curproc, $args) = @_;
+
+ $curproc->inform_reply_messages();
+}
+
+
+sub _evaluate_command
+{
+ my ( $curproc ) = @_;
+ my $body = $curproc->{ incoming_message }->{ body }->get_content_body;
+ my @body = split(/\n/, $body);
+
+ for (@body) { Log($_);}
+}
+
+
+=head1 NAME
+
+distribute -- fml5 article distributer program.
+
+=head1 SYNOPSIS
+
+ distribute [-d] config.cf
+
+=head1 DESCRIPTION
+
+libexec/fml.pl, the wrapper, executes this program. For example, The
+incoming mail to elena@fml.org kicks off libexec/distribute via
+libexec/fml.pl, whereas mail to elena-ctl@fml.org kicks off
+libexec/command finally.
+
+ incoming_message =>
+ elena@fml.org => fml.pl => libexec/distribute
+ elena-ctl@fml.org => fml.pl => libexec/command
+ elena-admin@fml.org => forwarded to administrator(s)
+ OR
+ => libexec/mead
+
+C<-d>
+ debug on.
+
+=head1 FLOW AROUND COMPONENTS
+
+ | <=> FML::BaseSystem
+ | load configuration files
+ | start logging service
+ |
+ | STDIN => FML::Parse
+ | $CurProc->{'incoming_message'} <=
+ | $CurProc->{'credential'}
+ |
+ | (lock)
+ | prepare article
+ | $CurProc->{'article'} is spooled in.
+ | $CurProc->{'article'} <=> Service::SMTP
+ | (unlock)
+ V
+
+=cut
+
+1;