mirror of
https://gitlab.com/shorewall/code.git
synced 2025-03-25 14:06:40 +01:00
Reimplement object_enable/disable
Signed-off-by: Tom Eastep <teastep@shorewall.net> git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@9824 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
b6053d8577
commit
0744df13d6
@ -640,6 +640,7 @@ sub compiler {
|
|||||||
setup_notrack;
|
setup_notrack;
|
||||||
|
|
||||||
unless ( $command eq 'check' ) {
|
unless ( $command eq 'check' ) {
|
||||||
|
enable_object;
|
||||||
#
|
#
|
||||||
# Place Header in the object
|
# Place Header in the object
|
||||||
#
|
#
|
||||||
@ -682,6 +683,7 @@ sub compiler {
|
|||||||
unless ( $command eq 'check' ) {
|
unless ( $command eq 'check' ) {
|
||||||
pop_indent;
|
pop_indent;
|
||||||
emit '}';
|
emit '}';
|
||||||
|
disable_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -689,6 +691,8 @@ sub compiler {
|
|||||||
# (Writes the setup_routing_and_traffic_shaping() function to the compiled script)
|
# (Writes the setup_routing_and_traffic_shaping() function to the compiled script)
|
||||||
#
|
#
|
||||||
unless ( $command eq 'check' ) {
|
unless ( $command eq 'check' ) {
|
||||||
|
enable_object;
|
||||||
|
|
||||||
emit( "\n#",
|
emit( "\n#",
|
||||||
'# Setup routing and traffic shaping',
|
'# Setup routing and traffic shaping',
|
||||||
'#',
|
'#',
|
||||||
@ -709,6 +713,7 @@ sub compiler {
|
|||||||
unless ( $command eq 'check' ) {
|
unless ( $command eq 'check' ) {
|
||||||
pop_indent;
|
pop_indent;
|
||||||
emit "}\n";
|
emit "}\n";
|
||||||
|
disable_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -781,6 +786,7 @@ sub compiler {
|
|||||||
progress_message3 "Shorewall6 configuration verified";
|
progress_message3 "Shorewall6 configuration verified";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
enable_object;
|
||||||
#
|
#
|
||||||
# I N I T I A L I Z E
|
# I N I T I A L I Z E
|
||||||
# (Writes the initialize() function to the compiled script)
|
# (Writes the initialize() function to the compiled script)
|
||||||
@ -810,6 +816,8 @@ sub compiler {
|
|||||||
copy $globals{SHAREDIRPL} . 'prog.footer6';
|
copy $globals{SHAREDIRPL} . 'prog.footer6';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disable_object;
|
||||||
#
|
#
|
||||||
# Close, rename and secure the object
|
# Close, rename and secure the object
|
||||||
#
|
#
|
||||||
|
@ -56,6 +56,8 @@ our @EXPORT_OK = qw( $shorewall_dir initialize read_a_line1 set_config_path shor
|
|||||||
|
|
||||||
our %EXPORT_TAGS = ( internal => [ qw( create_temp_object
|
our %EXPORT_TAGS = ( internal => [ qw( create_temp_object
|
||||||
finalize_object
|
finalize_object
|
||||||
|
enable_object
|
||||||
|
disable_object
|
||||||
numeric_value
|
numeric_value
|
||||||
numeric_value1
|
numeric_value1
|
||||||
in_hex
|
in_hex
|
||||||
@ -145,6 +147,10 @@ our $timestamp;
|
|||||||
#
|
#
|
||||||
our $object;
|
our $object;
|
||||||
#
|
#
|
||||||
|
# When 'true', writes to the object are enabled. Used to catch code emission between functions
|
||||||
|
#
|
||||||
|
our $object_enabled;
|
||||||
|
#
|
||||||
# True, if last line emitted is blank
|
# True, if last line emitted is blank
|
||||||
#
|
#
|
||||||
our $lastlineblank;
|
our $lastlineblank;
|
||||||
@ -296,6 +302,7 @@ sub initialize( $ ) {
|
|||||||
$log_verbose = -1; # Verbosity of log.
|
$log_verbose = -1; # Verbosity of log.
|
||||||
$timestamp = ''; # If true, we are to timestamp each progress message
|
$timestamp = ''; # If true, we are to timestamp each progress message
|
||||||
$object = 0; # Object (script) file Handle Reference
|
$object = 0; # Object (script) file Handle Reference
|
||||||
|
$object_enabled = 0; # Object (script) file Handle Reference
|
||||||
$lastlineblank = 0; # Avoid extra blank lines in the output
|
$lastlineblank = 0; # Avoid extra blank lines in the output
|
||||||
$indent1 = ''; # Current indentation tabs
|
$indent1 = ''; # Current indentation tabs
|
||||||
$indent2 = ''; # Current indentation spaces
|
$indent2 = ''; # Current indentation spaces
|
||||||
@ -757,6 +764,8 @@ sub in_hex8( $ ) {
|
|||||||
# Replaces leading spaces with tabs as appropriate and suppresses consecutive blank lines.
|
# Replaces leading spaces with tabs as appropriate and suppresses consecutive blank lines.
|
||||||
#
|
#
|
||||||
sub emit {
|
sub emit {
|
||||||
|
assert( $object_enabled );
|
||||||
|
|
||||||
if ( $object ) {
|
if ( $object ) {
|
||||||
#
|
#
|
||||||
# 'compile' as opposed to 'check'
|
# 'compile' as opposed to 'check'
|
||||||
@ -781,6 +790,8 @@ sub emit {
|
|||||||
# Write passed message to the object with newline but no indentation.
|
# Write passed message to the object with newline but no indentation.
|
||||||
#
|
#
|
||||||
sub emit_unindented( $ ) {
|
sub emit_unindented( $ ) {
|
||||||
|
assert( $object_enabled );
|
||||||
|
|
||||||
print $object "$_[0]\n" if $object;
|
print $object "$_[0]\n" if $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -972,6 +983,8 @@ sub pop_indent() {
|
|||||||
# Functions for copying files into the object
|
# Functions for copying files into the object
|
||||||
#
|
#
|
||||||
sub copy( $ ) {
|
sub copy( $ ) {
|
||||||
|
assert( $object_enabled );
|
||||||
|
|
||||||
if ( $object ) {
|
if ( $object ) {
|
||||||
my $file = $_[0];
|
my $file = $_[0];
|
||||||
|
|
||||||
@ -1002,6 +1015,8 @@ sub copy( $ ) {
|
|||||||
# This one handles line continuation and 'here documents'
|
# This one handles line continuation and 'here documents'
|
||||||
|
|
||||||
sub copy1( $ ) {
|
sub copy1( $ ) {
|
||||||
|
assert( $object_enabled );
|
||||||
|
|
||||||
if ( $object ) {
|
if ( $object ) {
|
||||||
my $file = $_[0];
|
my $file = $_[0];
|
||||||
|
|
||||||
@ -1112,6 +1127,20 @@ sub finalize_aux_config() {
|
|||||||
progress_message3 "Shorewall configuration compiled to $file";
|
progress_message3 "Shorewall configuration compiled to $file";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Enable writes to the object file
|
||||||
|
#
|
||||||
|
sub enable_object() {
|
||||||
|
$object_enabled = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Diusable writes to the object file
|
||||||
|
#
|
||||||
|
sub disable_object() {
|
||||||
|
$object_enabled = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Set $config{CONFIG_PATH}
|
# Set $config{CONFIG_PATH}
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user