mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-25 12:13:29 +02:00
A more uniform way of handling $max_format
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
6c1369a5a8
commit
e4e61c4193
@ -1918,7 +1918,7 @@ sub do_open_file( $ ) {
|
|||||||
$currentfilename = $fname;
|
$currentfilename = $fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub open_file( $ ) {
|
sub open_file( $;$ ) {
|
||||||
my $fname = find_file $_[0];
|
my $fname = find_file $_[0];
|
||||||
|
|
||||||
assert( ! defined $currentfile );
|
assert( ! defined $currentfile );
|
||||||
@ -1926,6 +1926,7 @@ sub open_file( $ ) {
|
|||||||
if ( -f $fname && -s _ ) {
|
if ( -f $fname && -s _ ) {
|
||||||
$first_entry = 0;
|
$first_entry = 0;
|
||||||
$file_format = 1;
|
$file_format = 1;
|
||||||
|
$max_format = supplied $_[1] ? $_[1] : 1;
|
||||||
do_open_file $fname;;
|
do_open_file $fname;;
|
||||||
} else {
|
} else {
|
||||||
$ifstack = @ifstack;
|
$ifstack = @ifstack;
|
||||||
@ -2463,9 +2464,7 @@ sub push_open( $;$ ) {
|
|||||||
push @openstack, \@a;
|
push @openstack, \@a;
|
||||||
@includestack = ();
|
@includestack = ();
|
||||||
$currentfile = undef;
|
$currentfile = undef;
|
||||||
open_file( $file );
|
open_file( $file , $max );
|
||||||
$max_format = supplied $max ? $max : 1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub pop_open() {
|
sub pop_open() {
|
||||||
@ -2509,11 +2508,10 @@ sub shorewall {
|
|||||||
# until we get back to the caller of read_a_line(), we could issue error messages about parsing and
|
# until we get back to the caller of read_a_line(), we could issue error messages about parsing and
|
||||||
# running scripts in the file before we'd even indicated that we are processing it.
|
# running scripts in the file before we'd even indicated that we are processing it.
|
||||||
#
|
#
|
||||||
sub first_entry( $;$ ) {
|
sub first_entry( $ ) {
|
||||||
( $first_entry, my $max ) = @_;
|
$first_entry = shift;
|
||||||
my $reftype = reftype $first_entry;
|
my $reftype = reftype $first_entry;
|
||||||
assert( $reftype eq 'CODE' ) if $reftype;
|
assert( $reftype eq 'CODE' ) if $reftype;
|
||||||
$max_format = supplied $max ? $max : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub read_a_line($);
|
sub read_a_line($);
|
||||||
|
@ -213,7 +213,7 @@ sub setup_conntrack() {
|
|||||||
|
|
||||||
for my $name ( qw/notrack conntrack/ ) {
|
for my $name ( qw/notrack conntrack/ ) {
|
||||||
|
|
||||||
my $fn = open_file( $name );
|
my $fn = open_file( $name, 3 );
|
||||||
|
|
||||||
if ( $fn ) {
|
if ( $fn ) {
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ sub setup_conntrack() {
|
|||||||
|
|
||||||
my $empty = 1;
|
my $empty = 1;
|
||||||
|
|
||||||
first_entry( "$doing $fn..." , 3 );
|
first_entry( "$doing $fn..." );
|
||||||
|
|
||||||
while ( read_a_line( NORMAL_READ ) ) {
|
while ( read_a_line( NORMAL_READ ) ) {
|
||||||
my ( $source, $dest, $proto, $ports, $sports, $user, $switch );
|
my ( $source, $dest, $proto, $ports, $sports, $user, $switch );
|
||||||
|
@ -2412,9 +2412,9 @@ sub setup_tc() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( my $fn = open_file 'tcrules' ) {
|
if ( my $fn = open_file( 'tcrules' , 2 ) ) {
|
||||||
|
|
||||||
first_entry "$doing $fn...", 2;
|
first_entry "$doing $fn...";
|
||||||
|
|
||||||
process_tc_rule while read_a_line( NORMAL_READ );
|
process_tc_rule while read_a_line( NORMAL_READ );
|
||||||
|
|
||||||
|
@ -1311,8 +1311,8 @@ sub validate_interfaces_file( $ ) {
|
|||||||
my @ifaces;
|
my @ifaces;
|
||||||
my $nextinum = 1;
|
my $nextinum = 1;
|
||||||
|
|
||||||
if ( my $fn = open_file 'interfaces' ) {
|
if ( my $fn = open_file 'interfaces', 2 ) {
|
||||||
first_entry "$doing $fn..." , 2;
|
first_entry "$doing $fn...";
|
||||||
push @ifaces, process_interface( $nextinum++, $export ) while read_a_line( NORMAL_READ );
|
push @ifaces, process_interface( $nextinum++, $export ) while read_a_line( NORMAL_READ );
|
||||||
} else {
|
} else {
|
||||||
fatal_error q(The 'interfaces' file does not exist or has zero size);
|
fatal_error q(The 'interfaces' file does not exist or has zero size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user