#!/usr/bin/perl
#
# 

require 'perl/misc.pl';

sub text_output {

local($facts) = @_;

if (open(FACTS,"< $facts")) {
  $text_output=();
  while(<FACTS>) {
      &saint_split($_);
      if ($status eq 'a' || $status eq 'n') {
	if ($severity eq 'i') {
	  ($text = "$service_output\n") =~ s/NMAP // if ($text =~ /used nmap/);
	  $text_output{$target}{'Information'}{$text} = 1;
        } elsif ($severity eq 'g') {
	  if ($text_output{$target}{'Services'} !~ / $text/) {
	    $text_output{$target}{'Services'}{$text} = 1;
	  }
	} elsif ($severity =~ /^z/) {
	  $text_output{$target}{'Potential Problems'}{$text} = 1;
	} elsif ($severity =~ /^y/) {
	  $text_output{$target}{'Areas of Concern'}{$text} = 1;
	} elsif ($trusted =~ /ANY/) {
	  $text_output{$target}{'Critical Problems'}{$text} = 1;
	}
      }
  }
  close(FACTS);
  for $target (sort keys %text_output) {
    print "\n$target:\n";
    for $severity ('Information', 'Critical Problems', 'Areas of Concern',
		   'Potential Problems', 'Services') {
      if (exists($text_output{$target}{$severity})) {
        print "   $severity:\n";
	for $text (sort keys %{$text_output{$target}{$severity}}) {
          print "      $text";
	}
      }
    }
  }
} else {
  print "No results found.\n"
}

}
