#!/usr/local/bin/perl 

#
# Copyright (c) 2002-2004 Eric Wallengren
# This file is part of the Continuous Automated Build and Integration
# Environment (CABIE)
#
# CABIE is distributed under the terms of the GNU General Public
# License version 2 or any later version.  See the file COPYING for copying
# permission or http://www.gnu.org.
#
# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
# IMPLIED, without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  ANY USE IS AT YOUR OWN RISK.
#
# Permission to modify the code and to distribute modified code is granted,
# provided the above notices are retained, and a notice that the code was
# modified is included with the above copyright notice.
#

#
# use packages...
#
use Sys::Hostname;

BEGIN {push @INC, "lib";}

my $POSIX = 1;
my $osname;

my $hostname = hostname();

if ("" =~ /MSWin32/ ) {
    $POSIX = 1;
    $osname = "winsys";
} else {
    $osname = "unixsys";
}

require "$hostname.pm";
require "$osname.pm";

use CGI qw(:all);

my $config = new $hostname;

my $cgibin     = $config->CGIBIN;
my $logo       = $config->LOGOICON;

my $basename;
my $jobname;
my $port;

print("Content-Type: text/html\n\n");

$HtmlRequest = $ENV{"REQUEST_URI"};

_processHtmlRequest($HtmlRequest);

$ENV{"BLDSERVER"} = "$Server:$port";

print <<EOF;
<html><title>Build log for job $jobname</title>
<head></head>
<body bgcolor=#f0f0f0>
EOF

@info = `./log2html.pl -b build -j $jobname -e $jobname.errors -S $server -P $port -r 60`;

foreach $line (@info) {
   print "$line";
}

print <<EOF;
<pre>
</body></html>
EOF

sub _processHtmlRequest() {

    ($basename, $server, $port, $jobname, $type) = split(/\?/,$_[0]);
    $Server = lc($server);

}
