Replace 'edit' by 'validate' in compiler parameter handling logic

This commit is contained in:
Tom Eastep 2009-07-22 10:43:53 -07:00
parent 264126e9f5
commit 45fffc7261

View File

@ -541,31 +541,31 @@ sub compiler {
$export = 0; $export = 0;
$test = 0; $test = 0;
sub edit_boolean( $ ) { sub validate_boolean( $ ) {
my $val = numeric_value( shift ); my $val = numeric_value( shift );
defined($val) && ($val >= 0) && ($val < 2); defined($val) && ($val >= 0) && ($val < 2);
} }
sub edit_verbosity( $ ) { sub validate_verbosity( $ ) {
my $val = numeric_value( shift ); my $val = numeric_value( shift );
defined($val) && ($val >= MIN_VERBOSITY) && ($val <= MAX_VERBOSITY); defined($val) && ($val >= MIN_VERBOSITY) && ($val <= MAX_VERBOSITY);
} }
sub edit_family( $ ) { sub validate_family( $ ) {
my $val = numeric_value( shift ); my $val = numeric_value( shift );
defined($val) && ($val == F_IPV4 || $val == F_IPV6); defined($val) && ($val == F_IPV4 || $val == F_IPV6);
} }
my %parms = ( object => { store => \$objectfile }, my %parms = ( object => { store => \$objectfile },
directory => { store => \$directory }, directory => { store => \$directory },
family => { store => \$family , edit => \&edit_family } , family => { store => \$family , validate => \&validate_family } ,
verbosity => { store => \$verbosity , edit => \&edit_verbosity } , verbosity => { store => \$verbosity , validate => \&validate_verbosity } ,
timestamp => { store => \$timestamp, edit => \&edit_boolean } , timestamp => { store => \$timestamp, validate => \&validate_boolean } ,
debug => { store => \$debug, edit => \&edit_boolean } , debug => { store => \$debug, validate => \&validate_boolean } ,
export => { store => \$export , edit => \&edit_boolean } , export => { store => \$export , validate => \&validate_boolean } ,
chains => { store => \$chains }, chains => { store => \$chains },
log => { store => \$log }, log => { store => \$log },
log_verbosity => { store => \$log_verbosity, edit => \&edit_verbosity } , log_verbosity => { store => \$log_verbosity, validate => \&validate_verbosity } ,
test => { store => \$test }, test => { store => \$test },
); );
# #
@ -574,8 +574,8 @@ sub compiler {
while ( defined ( my $name = shift ) ) { while ( defined ( my $name = shift ) ) {
fatal_error "Unknown parameter ($name)" unless my $ref = $parms{$name}; fatal_error "Unknown parameter ($name)" unless my $ref = $parms{$name};
fatal_error "Undefined value supplied for parameter $name" unless defined ( my $val = shift ) ; fatal_error "Undefined value supplied for parameter $name" unless defined ( my $val = shift ) ;
if ( $ref->{edit} ) { if ( $ref->{validate} ) {
fatal_error "Invalid value ( $val ) supplied for parameter $name" unless $ref->{edit}->($val); fatal_error "Invalid value ( $val ) supplied for parameter $name" unless $ref->{validate}->($val);
} }
${$ref->{store}} = $val; ${$ref->{store}} = $val;