diff options
| author | fukachan <fukachan> | 2001-01-29 03:10:47 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-01-29 03:10:47 +0000 |
| commit | c6e709a215faee2be11e4340adede225b9ca0d73 (patch) | |
| tree | e883b761a5bac98081d4acf296204557e206e38f /fml/libexec/process_switch | |
| parent | e7843ef8abdfbf859df47f62508337a880459870 (diff) | |
| download | fml8-c6e709a215faee2be11e4340adede225b9ca0d73.tar.gz fml8-c6e709a215faee2be11e4340adede225b9ca0d73.tar.bz2 fml8-c6e709a215faee2be11e4340adede225b9ca0d73.zip | |
renamed from fml to process_switch
Diffstat (limited to 'fml/libexec/process_switch')
| -rwxr-xr-x | fml/libexec/process_switch | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/fml/libexec/process_switch b/fml/libexec/process_switch new file mode 100755 index 00000000..292e424d --- /dev/null +++ b/fml/libexec/process_switch @@ -0,0 +1,139 @@ +#!/usr/local/bin/perl -w +#-*- perl -*- +# +# Copyright (C) 2000 Ken'ichi Fukamachi +# All rights reserved. +# +# $FML$ +# + +package FML; + +use vars qw($debug); +use strict; +use Carp; + + +# Descriptions: top level process switch +# 1. initialize processes and load configurations from *.cf +# switch to each process according with $0 and @ARGV. +# 2. parse the incoming message(mail) +# 3. start the main transaction +# lock, execute main routine, unlock +# 4. inform error messages, clean up and more ... +# Arguments: $args +# XXX non OO interface +# Side Effects: process running :-) +# Return Value: none +sub main::ProcessSwitch +{ + my ($args) = @_; + + # Firstly, create process + # $pkg is a package name, for exampl,e "FML::Process::Distribute". + my $pkg = _package_we_use($args); + croak("$args->{ myname } is unknown program\n") unless ($pkg); + + eval qq{ require $pkg; }; # XXX require() needs bare words. + croak($@) if $@; + $pkg->import(); # fake to use() method. + my $process = $pkg->new($args); # create a new process object + + # e.g. parse the incoming message (e.g. STDIN) + $process->prepare($args); + + # validate the request e.g. permit post from the sender ... + $process->verify_request($args); + + # start main transaction + $process->run($args); + + # closing the process + $process->finish($args); +} + + +# Descriptions: determine package we need and require() it if needed. +# Arguments: $args +# XXX non OO interface +# Side Effects: +# Return Value: FML::Process::SOMETHING process object +sub _package_we_use +{ + my ($args) = @_; + my $name = $args->{ myname }; + my $pkg = ''; + + if ($name eq 'fml.pl' || $name eq 'distribute' || $name eq 'fmlwrapper') { + $pkg = 'FML::Process::Distribute'; + } + elsif (( $name eq 'fml.pl' && $args->{ options }->{ ctladdr }) || + $name eq 'command') { + $pkg = 'FML::Process::Command'; + } + elsif ($name eq 'fmlserv') { + $pkg = 'FML::Process::ListServer'; + } + elsif ($name eq 'fmlconf' || $name eq 'makefml') { + $pkg = 'FML::Process::Configure'; + } + elsif ($name eq 'fmlticket') { + $pkg = 'FML::Process::TicketSystem'; + } + elsif ($name eq 'mead') { + $pkg = 'FML::Process::MailErrorAnalyzer'; + } + else { + return ''; + } + + return $pkg; +} + + + +=head1 NAME + +fml -- net/fml switch programs + +=head1 SYNOPSIS + + fml + +=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; |
