$value= 1 unless length($value) ;
if ($name=~ /^(LOCAL_HOST|DOCUMENT_ROOT|USER_DIR|DEBUG|debug)$/) {
eval "\$$name= \$value" ;
#$$name= $value ; # this doesn't work, because of initial my()
}
} elsif ($opt eq '?') {
&usage ;
# End command-line option processing on "--"
} elsif ($opt eq '-') {
return ;
} else {
print STDERR
"Illegal option-- '$opt'. Enter \"$0 -?\" for help.\n" ;
exit ;
}
}
if ($file_check and $full_http_check) {
print STDERR "You cannot use both the -f and the -h options.\n" ;
exit ;
}
}
# Read appropriate values from the given file, typically srm.conf. If a
# directory is named, default to filename "srm.conf".
# Note that opening "-" will open STDIN.
sub read_srm_conf {
my($fname)= @_ ;
local(*SRM) ;
# default to srm.conf if only a directory is named
if (-d $fname) {
$fname=~ s#/$## ;
$fname.= "/srm.conf" ;
}
# Clear old values
$DOCUMENT_ROOT= $USER_DIR= '' ;
@DIRECTORY_INDEX= @CGI_EXTENSIONS= @SHTML_EXTENSIONS= () ;
%ALIAS= %ALIAS_MATCH= %SCRIPT_ALIAS= %SCRIPT_ALIAS_MATCH= () ;
open(SRM, "<$fname") || die "Can't open $fname: $!" ;
while (<SRM>) {
s/#.*// ;
next unless /\S/ ;
my($name, @param)= /(\S+)/g ;
if ($name eq 'DocumentRoot') {
$DOCUMENT_ROOT= $param[0] ;
} elsif ($name eq 'UserDir') {
$USER_DIR= $param[0] ;
} elsif ($name eq 'DirectoryIndex') {
@DIRECTORY_INDEX= @param ;
} elsif ($name eq 'Alias') {
$ALIAS{$param[0]}= $param[1] ;
} elsif ($name eq 'AliasMatch') {
$ALIAS_MATCH{$param[0]}= $param[1] ;
} elsif ($name eq 'ScriptAlias') {
$SCRIPT_ALIAS{$param[0]}= $param[1] ;
} elsif ($name eq 'ScriptAliasMatch') {
$SCRIPT_ALIAS_MATCH{$param[0]}= $param[1] ;
} elsif ($name eq 'AddHandler') {
if ($param[0] eq 'cgi-script') {
push(@CGI_EXTENSIONS, $param[1]) ;
} elsif ($param[0] eq 'server-parsed') {
push(@SHTML_EXTENSIONS, $param[1]) ;
}
}
}
close(SRM) ;
}
# Make any final settings to global variables, after the hard-coded values
# and command-line options have been processed.
# Most non-user-configurable globals are also set here.
sub adjust_all_globals {
# Standardize $USER_DIR to never have trailing slash
$USER_DIR=~ s#/$## ;
# If no $LOCAL_HOST set, try to read it from first URL in list, or
# use the string 'localhost' if that URL contains no hostname.
unless (length($LOCAL_HOST)) {
$LOCAL_HOST= (&parse_url($ARGV[0]))[1] || 'localhost' ;
print STDERR "LOCAL_HOST set to \"\L$LOCAL_HOST\E\"\n" ;
=4= |