use warnings;
use strict;
use HoTTProxy::UI;
# We need the path to the present executable. Under Win32 this is pretty
# positive using the Win32::GetFullPathName. Under Linux and the like,
# it looks like $ENV{'PWD'} will get us what we want - suggestions?
my $path;
my %HoTTProxyAdminConfig; # Will hold any configurable settings
my $HoTTProxyAdminVersion = '0.24.0.0';
print STDERR "\nHoTTProxy Admin Daemon $HoTTProxyAdminVersion - (c) 2005 Brian A. Blakley\n\n";
if ($^O eq 'MSWin32') {
$path = Win32::GetFullPathName( $0 );
($path) = $path =~ m/^(.*\\)/; # e.g. C:\data\programming\Perl\HoTTProxy (with trailing slash)
} else {
$path = $ENV{'PWD'};
if (not $path =~ m/\/$/) { # if the path doesn't end with a frontslash, make it so
$path .= '/';
}
}
loadConfig('HoTTProxy_Admin.conf');
my $server = HoTTProxy::UI->new();
$server->port($HoTTProxyAdminConfig{'AdminPort'});
$server->basepath($path);
$server->wwwpath($path . 'www');
$server->run();
sub loadConfig {
my $configFile = shift;
if (not open (CONFIG,"$path/$configFile")) {
die "Cannot open config file $configFile.\nError: $!\nEnding.\n";
}
while (<CONFIG>) {
chomp $_;
if ($_ =~ m/^#/) { # if the line starts with a # character
# do nothing, this is a comment line
} elsif ($_) {
my ($name,$value) = $_ =~ m/^([^=]*) = (.*)$/; # e.g. AdminPort = 8085
$HoTTProxyAdminConfig{$name} = $value;
}
}
close CONFIG;
if (not $HoTTProxyAdminConfig{'AdminPort'}) {
$HoTTProxyAdminConfig{'AdminPort'} = 8085; # Default to 8085 if not specified
}
}
=1=
THE END |