
$SOLVERS        = "$ENV{SERVER_SOLVERS}"; 
$ADMIN_SOLVERS  = "$ENV{SERVER_ADMIN_SOLVERS}"; 
$MESSAGES       = "$ADMIN_SOLVERS/ADMIN:HELP";
$NSS = 0;  # no such solver flag
$HELP = "";

if (-f "help.type") {
  chomp($TYPE = `cat help.type`); 
}

if ($TYPE) {
  $TYPE = "\U$TYPE";
  $TYPE =~ s/\s//g;
  if ($TYPE =~ /^ADMIN:.*/) {
    $SOLVER_LIB = $ADMIN_SOLVERS;
  } else {
    $SOLVER_LIB = $SOLVERS;
  }
  if (-f "$SOLVER_LIB/$TYPE/email-help") {
    $HELP = `cat $SOLVER_LIB/$TYPE/email-help`;
    chomp($TEMPLATE = `$^X $ENV{SERVER_BIN}/make-solver-template.pl $TYPE`);
    $HELP .= $TEMPLATE;
  } else {
    $HELP = "\"$TYPE\" e-mail help is not available.\nCheck your solver type and token against the list below.\n";
    $NSS = 1;
  }
} else {
    $NSS = 1;
}
if($NSS == 1) {
    chomp(@LIST = `cat $ENV{SERVER_VAR}/lib/solver_list $ENV{SERVER_LIB}/admin_list`);
    open (ABSTRACT, ">abstracts");
    foreach (@LIST) {
	s/.*=(.*)/$1/;
	unless ($_ eq "HELP") {
	    $_ =~ /(.+):(.+)/;
	    $TYPE   = $1;
	    $SOLVER = $2; 
	    if ($TYPE eq "ADMIN") {
		chomp($TITLE = `cat $ADMIN_SOLVERS/$_/TITLE`);  
	    } else {
		chomp($TITLE = `cat $SOLVERS/$_/TITLE`);  
	    }
	    write ABSTRACT;
	}
    }
    close(ABSTRACT);
    $ABSTRACTS = `cat abstracts`;
    $HELP = $HELP.`cat $MESSAGES/general_help_1.txt`.$ABSTRACTS.`cat $MESSAGES/general_help_2.txt`;
}				 
				
$SERVER_INTERFACES = "";
if ($ENV{SERVER_WWW_READY}) {
  $SERVER_INTERFACES .= "    WWW:             <SERVER_WWW_URL>\n";
}
if ($ENV{SERVER_CORBA_READY}) {
  $SERVER_INTERFACES .= "    Corba:           See <SERVER_FTP_URL>\n";
}
if ($ENV{KESTREL_INSTALL}) {
  $SERVER_INTERFACES .= "    Kestrel:         See <SERVER_WWW_URL>/kestrel.html\n";
}

$HELP =~ s/<SERVER_INTERFACES>/$SERVER_INTERFACES/g;
$HELP =~ s/<SERVER_NAME>/$ENV{SERVER_NAME}/g;
$HELP =~ s/<SERVER_COMMENTS>/$ENV{SERVER_COMMENTS}/g;
$HELP =~ s/<SERVER_FTP_URL>/$ENV{SERVER_FTP_URL}/g;
$HELP =~ s/<SERVER_WWW_URL>/$ENV{SERVER_WWW_URL}/g;
$HELP =~ s/<SERVER_USER>/$ENV{SERVER_USER}/g;
$HELP =~ s/<SERVER_HOSTNAME>/$ENV{SERVER_HOSTNAME}/g;
$HELP =~ s/<SERVER_EMAIL>/$ENV{SERVER_EMAIL}/g;

open(RESULTS,'>>job.results');
print RESULTS $HELP;
close(RESULTS);

format ABSTRACT =
   @<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$TYPE, $SOLVER, $TITLE
.







