#!/bin/tcsh

#Mail processor 
#This is called when mail comes in.  First argument must be the username
#that the mail is addressed to.
#Use wrapper.c if you need this to be setuid

setenv DIR /home/ghio/alpha
setenv HOSTNAME "alpha.c2.org"

if ( $1 == alias ) then
wait:
if ( -r $DIR/pid ) then
sleep 60
goto wait
#Maybe a ps would be better?
endif
echo $$>$DIR/pid
cat >$DIR/in-raw-msg
$DIR/anonserv
rm $DIR/pid
else
if ( $1 == help || $1 == info || $1 == remailer-help || $1 == remailer-info ) then
cat >$DIR/temp$$
/usr/lib/sendmail `$DIR/getfrom <$DIR/temp$$` <$DIR/nymhelp
rm $DIR/temp$$
else
echo $1 >>$DIR/log
echo "Received: by $HOSTNAME for $1@$HOSTNAME" >$DIR/temp$$
/bin/echo -n " " >>$DIR/temp$$
cat >>$DIR/temp$$
cat $DIR/temp$$ >$DIR/in.queue/`date +%S%M%j%H`$$
rm $DIR/temp$$
endif
