
#
# Create the SEARCH database
#
$sara_data = "SEARCH";
&init_sara_data();
#
# Read the data base, after resetting the in-core data structures.
#
print CLIENT <<EOF;
<HTML>
<HEAD>
<TITLE>SARA Search Build</TITLE>
<LINK REV="made" HREF="mailto:sara\@arc.com">
</HEAD>
<BODY>
<H1><IMG SRC=$HTML_ROOT/images/sara.gif> SARA Search Build</H1>
The following hosts (databases) have been included in the <B><I>SEARCH</I></B>
database:
<UL><UL>
<P>
EOF
$host_data = "";
unlink ("results/SEARCH/facts");
unlink ("results/SEARCH/all-hosts");
open (FACTS,">results/SEARCH/facts");
open (HOSTS,">results/SEARCH/all-hosts");
$sara_data = "SEARCH";
$xml_file  = "results/SEARCH/xml";
$csv_file  = "results/SEARCH/csv";
$htm_file  = "results/SEARCH/htm";
for ($i=1;$i<=1000;$i++) {
  $A="A$i";
  if ( $$A ) {
    ($_hostname, $_directory) = split(/\|/, $$A);
    $_directory =~ s/XxX//;
    $host_data .= "$_hostname ($_directory)<BR>";
    open (DB,"results/$_directory/all-hosts");
    while(<DB>) {
      chop;
      if (/^$_hostname/i) {
print HOSTS <<EOF;
$_
EOF
      }
    }
    close(DB);
    open (DB,"results/$_directory/facts");
    while (<DB>) {
      chop;
      if (/$_hostname/i) {
print FACTS <<EOF;
$_
EOF
      }
    }
    close(DB);
  } else {
  break;
  }
}
close(FACTS);
close(HOSTS);
&read_sara_data();
&save_xml($xml_file);
&save_csv($csv_file);
&save_htm($htm_file);
print CLIENT <<EOF;
<UL><UL>
$host_data
</UL></UL>
</UL></UL>
<P>
<p><hr>
<a href=$HTML_SERVER> Back to the SARA start page </a>
| <a href=$HTML_SERVER/running/sara_report_form.pl>Go Reporting and Analysis page</a>
</BODY>
</HTML>
EOF
1;
