diff options
| author | fukachan <fukachan> | 2004-04-22 12:48:19 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-04-22 12:48:19 +0000 |
| commit | eec5d3647cbe17b281689dc0ab9bb5bf14baa1e2 (patch) | |
| tree | 76568d7f464792c54a8a28cb2bbd1629c00ec812 /fml/lib/FML/Process | |
| parent | 5e11684f92fc8fbbeb9a6831c180f513e2d5df8f (diff) | |
| download | fml8-eec5d3647cbe17b281689dc0ab9bb5bf14baa1e2.tar.gz fml8-eec5d3647cbe17b281689dc0ab9bb5bf14baa1e2.tar.bz2 fml8-eec5d3647cbe17b281689dc0ab9bb5bf14baa1e2.zip | |
command_context_init() returns empty HASH_REF where it includes valid
command as the first valid argument.
define command_context_set_normal_stop(), command_context_get_normal_stop().
Diffstat (limited to 'fml/lib/FML/Process')
| -rw-r--r-- | fml/lib/FML/Process/State.pm | 66 |
1 files changed, 59 insertions, 7 deletions
diff --git a/fml/lib/FML/Process/State.pm b/fml/lib/FML/Process/State.pm index 3b3e025c..c8ba0bd2 100644 --- a/fml/lib/FML/Process/State.pm +++ b/fml/lib/FML/Process/State.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: State.pm,v 1.5 2004/03/14 10:29:51 fukachan Exp $ +# $FML: State.pm,v 1.6 2004/04/17 11:37:56 fukachan Exp $ # package FML::Process::State; @@ -190,7 +190,7 @@ sub command_context_init my ($curproc, $orig_command) = @_; # Example: if orig_command = "# help", comname = "help" - my $cleanstr = _command_string_clean_up($orig_command); + my $cleanstr = $curproc->_command_string_clean_up($orig_command); my $context = $curproc->_build_command_context_template($cleanstr); # save original string, set the command mode be "user" by default. @@ -204,7 +204,29 @@ sub command_context_init my $ml_name = $curproc->ml_name(); $curproc->command_context_set_ml_name($ml_name); - return $context; + # check if command is valid. + my $found = 0; + my $name = $context->{ comname } || ''; + if ($name) { + my $config = $curproc->config(); + + LIST: + for my $list (qw(anonymous_command_mail_allowed_commands + user_command_mail_allowed_commands)) { + if ($config->has_attribute($list, $name)) { + $found = 1; + last LIST; + } + } + } + + # if valid, return the current context (HASH_REF). + if ($found) { + return $context; + } + else { + return {}; + } } @@ -242,13 +264,16 @@ sub _build_command_context_template # Descriptions: remove the superflous string before the actual command. -# Arguments: STR($buf) +# Arguments: OBJ($curproc) STR($buf) # Side Effects: none # Return Value: STR sub _command_string_clean_up { - my ($buf) = @_; - $buf =~ s/^\W+//o; + my ($curproc, $buf) = @_; + my $config = $curproc->config(); + my $confirm_prefix = $config->{ confirm_command_prefix }; + + $buf =~ s/^\W+$confirm_prefix/$confirm_prefix/; return $buf; } @@ -279,7 +304,8 @@ sub command_context_get_ml_name } -# Descriptions: declare no more further command processing needed. +# Descriptions: declare no more further command processing needed +# due to critical error. # Arguments: OBJ($curproc) # Side Effects: update pcb. # Return Value: NUM @@ -305,6 +331,32 @@ sub command_context_get_stop_process } +# Descriptions: declare no more further command processing needed. +# Arguments: OBJ($curproc) +# Side Effects: update pcb. +# Return Value: NUM +sub command_context_set_normal_stop +{ + my ($curproc) = @_; + my $pcb = $curproc->pcb(); + + $pcb->set("process_command", "normal_stop", 1); +} + + +# Descriptions: we stop here or not ? +# Arguments: OBJ($curproc) +# Side Effects: none +# Return Value: NUM +sub command_context_get_normal_stop +{ + my ($curproc) = @_; + my $pcb = $curproc->pcb(); + + return( $pcb->get("process_command", "normal_stop") || 0 ); +} + + # Descriptions: set "we need to send back confirmation". # usually, this flag means we send back the original message. # hence, this flag is universal over plural ML's. |
