#!/usr/local/bin/perl
#
# @(#)nph-test-cgi.pl	1.2 96/08/02 Scott Atwood
#
# Copyright (c) 1995 Sun Microsystems, Inc.  All Rights reserved
# Permission to use, copy, modify, and distribute this software
# and its documentation for NON-COMMERCIAL purposes and without
# fee is hereby granted provided that this copyright notice
# appears in all copies. Please refer to the file copyright.html
# for further important copyright and licensing information.
#
# SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
# THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
# ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
# DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.

require ("ctime.pl");

if(!($ENV{SERVER_PROTOCOL} eq "HTTP/0.9")) {
$Date = &ctime(time);
chop($Date);
($day, $month, $date, $time, $year) = split(/[ \n\r\t]+/,$Date);
($hour, $min, $sec) = split(/:/, $time);
$time = sprintf("%.2d:%.2d:%.2d", $hour, $min, $sec);
$Date = sprintf("%s, %.2d %s %d %s GMT", $day, $date, $month, $year, $time);
print <<EOM;
HTTP/1.0 200 OK
Server: $ENV{SERVER_SOFTWARE}
X-Bogus-Header: Bogosity
Content-type: text/html
Date: $Date

EOM
}
print <<EOM;
<html>
<head><title>CGI Test</title></head>
<body>
<h1>CGI Test</h1>
<pre>
EOM

print "argc is " . ($#ARGV + 1) . "\n\n";

print "argv is\n";

for($i = 0; $i<($#ARGV+1); $i++) {
	print $ARGV[$i] . "\n";
}

print "\n";

foreach $key (sort keys %ENV) {

	print("$key: $ENV{$key}\n");

}

print <<EOM;
</pre>
</body>
</html>
EOM

close OUT;
