Streamline PERL in action.Drop and action.Reject

- Rename read_action_param => get_action_params
- Allow it to accept a list of indexes and to return a list

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2011-06-22 06:53:15 -07:00
parent bbf853bd1d
commit b43bee2c62
3 changed files with 11 additions and 11 deletions

View File

@ -52,7 +52,7 @@ our @EXPORT = qw(
progress_message2
progress_message3
supplied
read_action_param
get_action_params
set_action_param
);
@ -1840,11 +1840,15 @@ sub default_action_params {
}
}
sub read_action_param( $ ) {
my $i = shift;
sub get_action_params {
my @values;
fatal_error "Parameter numbers must be numeric" unless $i =~ /^\d+$/;
$actparms{$i};
for ( @_ ) {
fatal_error "Parameter numbers must be numeric" unless $_ =~ /^\d+$/;
push @values, $actparms{$_};
}
@values;
}
sub set_action_param( $$ ) {

View File

@ -35,11 +35,9 @@ FORMAT 2
BEGIN PERL
use Shorewall::Config;
my $p1 = read_action_param(1);
my ($p1, $p2, $p3 ) = get_action_params(1, 2, 3);
if ( defined $p1 && $p1 eq 'audit' ) {
my ( $p2, $p3 ) = ( read_action_param(2) , read_action_param(3) );
set_action_param( 2, 'A_REJECT') unless defined $p2;
set_action_param( 3, 'A_DROP') unless defined $p3;
};

View File

@ -31,11 +31,9 @@ FORMAT 2
BEGIN PERL
use Shorewall::Config;
my $p1 = read_action_param(1);
my ( $p1, $p2, $p3 ) = get_action_params(1, 2, 3);
if ( defined $p1 && $p1 eq 'audit' ) {
my ( $p2, $p3 ) = ( read_action_param(2) , read_action_param(3) );
set_action_param( 2, 'A_REJECT') unless defined $p2;
set_action_param( 3, 'A_REJECT') unless defined $p3;
};