# Copyright (c) 1991, Andrew Rosen.
# All rights reserved.
#
# This  software is supplied free of charge.  This software, or any part
# of it,  may  not  be  redistributed or otherwise made available to, or
# used  by,  any  other  person  without the inclusion of this copyright
# notice.  This software may not be used to make a profit in any way.
#
# This  software  is provided with absolutely no warranty, to the extent
# permitted  by  applicable  state law.  In no event, unless required by
# applicable law,  will the author(s) of this software be liable for any
# damages caused by this software.


## Get real address message was sent from
ggrep '^From: ' ${file} | ggrep -s '<'
if ( ${status} == 0 ) then
  # From: has angle brackets, real address is in there
  ggrep '^From: ' ${file} | cut -d'<' -f2 | cut -d'>' -f1 >! address
else
  # No angle brackets, should be "address (Real Name)" or just "address"
  # Either case we just keep what's before the first space
  ggrep '^From: ' ${file} | sed 's/From: //g' | cut -d' ' -f1 >! address
endif

ggrep -s -f ${reject} address
if ( ${status} == 0 ) then
  set quit = yes
  exit 0
endif

set raddress = `head -1 address`

ggrep '^ACS-Name: ' ${file} >! name
if ( ${status} == 0 ) then
  set name = "(`head -1 name | cut -f2- -d' '`)"
else
  set name
endif

set address = `echo ${raddress} ${name}`
echo "Message is from ${address}"
