2002-02-18 20:03:45 -05:00
|
|
|
#!/usr/bin/env perl
|
2010-01-08 10:54:07 -05:00
|
|
|
#***************************************************************************
|
|
|
|
# _ _ ____ _
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
#
|
2011-12-17 17:47:22 -05:00
|
|
|
# Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2010-01-08 10:54:07 -05:00
|
|
|
#
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
# you should have received as part of this distribution. The terms
|
|
|
|
# are also available at http://curl.haxx.se/docs/copyright.html.
|
|
|
|
#
|
|
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
|
|
#
|
|
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
# KIND, either express or implied.
|
|
|
|
#
|
|
|
|
#***************************************************************************
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
@INC=(@INC, $ENV{'srcdir'}, '.');
|
|
|
|
}
|
2000-11-13 03:02:02 -05:00
|
|
|
|
2002-02-18 20:03:45 -05:00
|
|
|
use strict;
|
2010-01-08 10:54:07 -05:00
|
|
|
use warnings;
|
2000-11-13 03:02:02 -05:00
|
|
|
|
2010-01-08 10:54:07 -05:00
|
|
|
use serverhelp qw(
|
|
|
|
server_pidfilename
|
|
|
|
server_logfilename
|
|
|
|
);
|
2000-11-13 03:02:02 -05:00
|
|
|
|
2010-01-08 10:54:07 -05:00
|
|
|
my $verbose = 0; # set to 1 for debugging
|
|
|
|
my $port = 8990; # just a default
|
|
|
|
my $ipvnum = 4; # default IP version of http server
|
|
|
|
my $idnum = 1; # dafault http server instance number
|
|
|
|
my $proto = 'http'; # protocol the http server speaks
|
|
|
|
my $pidfile; # http server pid file
|
|
|
|
my $logfile; # http server log file
|
2011-12-17 17:47:22 -05:00
|
|
|
my $connect; # IP to connect to on CONNECT
|
2010-01-08 10:54:07 -05:00
|
|
|
my $srcdir;
|
2006-04-10 09:09:56 -04:00
|
|
|
my $fork;
|
2010-08-24 18:47:45 -04:00
|
|
|
my $gopher = 0;
|
2010-01-07 20:48:54 -05:00
|
|
|
|
|
|
|
my $flags = "";
|
2010-01-08 10:54:07 -05:00
|
|
|
my $path = '.';
|
|
|
|
my $logdir = $path .'/log';
|
2010-01-07 20:48:54 -05:00
|
|
|
|
2010-01-08 10:54:07 -05:00
|
|
|
while(@ARGV) {
|
|
|
|
if($ARGV[0] eq '--pidfile') {
|
|
|
|
if($ARGV[1]) {
|
|
|
|
$pidfile = $ARGV[1];
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
2000-11-16 04:06:18 -05:00
|
|
|
}
|
2010-01-08 10:54:07 -05:00
|
|
|
elsif($ARGV[0] eq '--logfile') {
|
|
|
|
if($ARGV[1]) {
|
|
|
|
$logfile = $ARGV[1];
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
2004-02-12 09:40:08 -05:00
|
|
|
}
|
2010-01-08 10:54:07 -05:00
|
|
|
elsif($ARGV[0] eq '--srcdir') {
|
|
|
|
if($ARGV[1]) {
|
|
|
|
$srcdir = $ARGV[1];
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
2004-12-14 16:52:16 -05:00
|
|
|
}
|
2010-01-08 10:54:07 -05:00
|
|
|
elsif($ARGV[0] eq '--ipv4') {
|
|
|
|
$ipvnum = 4;
|
|
|
|
}
|
|
|
|
elsif($ARGV[0] eq '--ipv6') {
|
|
|
|
$ipvnum = 6;
|
|
|
|
}
|
2010-08-24 18:47:45 -04:00
|
|
|
elsif($ARGV[0] eq '--gopher') {
|
|
|
|
$gopher = 1;
|
|
|
|
}
|
2010-01-08 10:54:07 -05:00
|
|
|
elsif($ARGV[0] eq '--port') {
|
|
|
|
if($ARGV[1] =~ /^(\d+)$/) {
|
|
|
|
$port = $1;
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
2006-04-10 09:09:56 -04:00
|
|
|
}
|
2011-12-17 17:47:22 -05:00
|
|
|
elsif($ARGV[0] eq '--connect') {
|
|
|
|
if($ARGV[1]) {
|
|
|
|
$connect = $ARGV[1];
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
|
|
|
}
|
2010-01-08 10:54:07 -05:00
|
|
|
elsif($ARGV[0] eq '--id') {
|
|
|
|
if($ARGV[1] =~ /^(\d+)$/) {
|
|
|
|
$idnum = $1 if($1 > 0);
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
2000-11-16 04:06:18 -05:00
|
|
|
}
|
2010-01-08 10:54:07 -05:00
|
|
|
elsif($ARGV[0] eq '--verbose') {
|
|
|
|
$verbose = 1;
|
2004-12-11 16:41:00 -05:00
|
|
|
}
|
2010-01-08 10:54:07 -05:00
|
|
|
elsif($ARGV[0] eq '--fork') {
|
|
|
|
$fork = $ARGV[0];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print STDERR "\nWarning: httpserver.pl unknown parameter: $ARGV[0]\n";
|
|
|
|
}
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$srcdir) {
|
|
|
|
$srcdir = $ENV{'srcdir'} || '.';
|
|
|
|
}
|
|
|
|
if(!$pidfile) {
|
|
|
|
$pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
|
|
|
|
}
|
|
|
|
if(!$logfile) {
|
|
|
|
$logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
|
|
|
|
}
|
2000-11-13 11:06:16 -05:00
|
|
|
|
2012-01-04 13:28:22 -05:00
|
|
|
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
|
2010-08-24 18:47:45 -04:00
|
|
|
$flags .= "--gopher " if($gopher);
|
2010-01-07 20:48:54 -05:00
|
|
|
$flags .= "--fork " if(defined($fork));
|
2011-12-17 17:47:22 -05:00
|
|
|
$flags .= "--connect $connect " if($connect);
|
2010-01-08 10:54:07 -05:00
|
|
|
$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
|
2010-01-07 20:48:54 -05:00
|
|
|
|
2011-12-17 17:47:22 -05:00
|
|
|
if($verbose) {
|
|
|
|
print STDERR "RUN: server/sws $flags\n";
|
|
|
|
}
|
|
|
|
|
2010-01-07 20:48:54 -05:00
|
|
|
exec("server/sws $flags");
|