Don't require functions called from Shorewall::Compiler::compiler to know the current indentation.

Also, add an optional 'times' parameter to push_indent() and pop_indent().

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-11-30 07:49:42 -08:00
parent 87e205208d
commit 53fd0e7c8c
5 changed files with 42 additions and 36 deletions

View File

@ -7484,7 +7484,6 @@ sub create_stop_load( $ ) {
sub initialize_switches() {
if ( keys %switches ) {
push_indent; push_indent;
emit( 'if [ $COMMAND = start ]; then' );
push_indent;
while ( my ( $switch, $setting ) = each %switches ) {
@ -7493,7 +7492,6 @@ sub initialize_switches() {
}
pop_indent;
emit "fi\n";
pop_indent; pop_indent;
}
}

View File

@ -459,10 +459,10 @@ sub generate_script_3($) {
fatal_error "$iptables_save_file does not exist"
fi
EOF
pop_indent;
push_indent;
setup_load_distribution;
setup_forwarding( $family , 1 );
push_indent;
pop_indent;
my $config_dir = $globals{CONFIGDIR};
@ -473,8 +473,10 @@ else
if [ \$COMMAND = refresh ]; then
chainlist_reload
EOF
push_indent(2);
setup_load_distribution;
setup_forwarding( $family , 0 );
pop_indent(2);
emit( ' run_refreshed_exit' ,
' do_iptables -N shorewall' ,
@ -482,13 +484,17 @@ EOF
' else' ,
' setup_netfilter' );
push_indent(2);
setup_load_distribution;
pop_indent(2);
emit<<"EOF";
conditionally_flush_conntrack
EOF
push_indent(2);
initialize_switches;
setup_forwarding( $family , 0 );
pop_indent(2);
emit<<"EOF";
run_start_exit

View File

@ -1489,7 +1489,10 @@ sub progress_message3 {
#
# Push/Pop Indent
#
sub push_indent() {
sub push_indent(;$) {
my $times = shift || 1;
while ( $times-- ) {
if ( $indent2 ) {
$indent2 = '';
$indent = $indent1 = $indent1 . "\t";
@ -1498,8 +1501,12 @@ sub push_indent() {
$indent = $indent1 . $indent2;
}
}
}
sub pop_indent() {
sub pop_indent(;$) {
my $times = shift || 1;
while ( $times-- ) {
if ( $indent2 ) {
$indent2 = '';
$indent = $indent1;
@ -1509,6 +1516,7 @@ sub pop_indent() {
$indent = $indent1 . $indent2;
}
}
}
#
# Create the temporary script file -- the passed file name is the name of the final file.

View File

@ -251,9 +251,6 @@ sub setup_forwarding( $$ ) {
if ( @$interfaces ) {
progress_message2 "$doing Interface forwarding..." if $first;
push_indent;
push_indent;
save_progress_message 'Setting up IPv6 Interface Forwarding...';
for my $interface ( @$interfaces ) {
@ -270,9 +267,6 @@ sub setup_forwarding( $$ ) {
" error_message \"WARNING: Cannot set IPv6 forwarding on $interface\"" ) unless $optional;
emit "fi\n";
}
pop_indent;
pop_indent;
}
}
}