Finish (unpublished) parameterized actions

This commit is contained in:
Tom Eastep 2010-12-21 12:29:52 -08:00
parent 6263689c3e
commit ac42fddbce
2 changed files with 31 additions and 4 deletions

View File

@ -96,6 +96,8 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
close_file
push_open
pop_open
add_params
del_params
read_a_line
validate_level
which
@ -1781,6 +1783,29 @@ sub embedded_perl( $ ) {
}
}
#
# Add parameters
#
sub add_params( $ ) {
my $params = shift;
my @params = split /,/, $params;
for ( my $i = 1; $i <= @params; $i++ ) {
$params{$i} = $params[$i];
}
}
sub del_params( $ ) {
my $params = shift;
my @params = split /,/, $params;
for ( my $i = 1; $i <= @params; $i++ ) {
delete $params{$i};
}
}
#
# Read a line from the current include stack.
#
@ -1857,7 +1882,7 @@ sub read_a_line(;$) {
# Expand Shell Variables using %params and %ENV
#
# $1 $2 $3 - $4
while ( $currentline =~ m( ^(.*?) \$({)? ([a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
while ( $currentline =~ m( ^(.*?) \$({)? (\w+) (?(2)}) (.*)$ )x ) {
unless ( exists $params{$3} ) {
#

View File

@ -342,8 +342,8 @@ sub process_actions1() {
#
# Generate chain for non-builtin action invocation
#
sub process_action3( $$$$$ ) {
my ( $chainref, $wholeaction, $action, $level, $tag ) = @_;
sub process_action3( $$$$$$ ) {
my ( $chainref, $wholeaction, $action, $level, $tag, $param ) = @_;
my $actionfile = find_file "action.$action";
my $format = 1;
@ -353,6 +353,8 @@ sub process_action3( $$$$$ ) {
open_file $actionfile;
add_params( $param );
while ( read_a_line ) {
my ($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers );
@ -550,7 +552,7 @@ sub process_actions3 () {
$level = '' if $level =~ /none!?/;
$builtinops{$action}->($chainref, $level, $tag, $param );
} else {
process_action3 $chainref, $wholeaction, $action, $level, $tag;
process_action3 $chainref, $wholeaction, $action, $level, $tag, $param;
}
}
}