#!/usr/local/bin/perl -w

###########################################################################
### $Id: //depot/personal/ryan/main/src/wham/cgi-bin/blurb.pl#2 $
###########################################################################
### Generates a brief summary of an email simimlar to what biff does
###########################################################################
my( $BINDIR, $LIBDIR, $CGIDIR);

use FindBin '$RealBin';                             # locate libraries
BEGIN {
$BINDIR="/usr/local/wham/bin";
$LIBDIR="/usr/local/wham/lib";
$CGIDIR="/usr/local/wham/cgi-bin";
}

use lib "$LIBDIR";
use strict;

$|=1;

my( $line, %header, $key, $val, $count);

while( defined( $line = <>))
{
	if( $line =~ /^(\S*):\s*(.*)/) {
		($key,$val) = (ucfirst(lc($1)),$2);
		$header{$key} = $val if( $key =~/From|To|Cc|Subject|Message-id/);
	} elsif( $line =~ /^\s*$/) {
		last;
	}
}

if( defined( $header{Subject})
	&& $header{Subject} eq "DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA"
	&& $header{From} =~ /MAILER-DAEMON@/)
{
	exit;
}

foreach $key ("From", "To", "Cc", "Subject", "Message-id")
{
	print "$key: $header{$key}\n" if( defined($header{$key}));
}
print "\n";
for( $count=0; defined( $line = <>); $count++)
{
	print $line;
	last if( $count>2);
}

print "-------------------------\n";

exit 0;
