#!/bin/sh

PATH=/bin:/usr/bin:/sbin:/usr/sbin

tmpdir=/tmp/amavis-test.$$

/bin/rm -f amavis.log debug

from="${USER:-amavis-test}@${HOST:-`hostname`}"
to="$from"

if [ -f ./amavisd-test ]; then
  AMAVIS="../amavis/amavis"
  SCRIPT="./amavisd-test"
  xhdr=`sed -n 's/^$X_HEADER_TAG = "\([^"]*\).*$/\1/p' ./amavisd.conf`:
else
  AMAVIS="./amavis-test"
  SCRIPT="$AMAVIS"
  xhdr=`sed -n 's/^$X_HEADER_TAG = "\([^"]*\).*$/\1/p' ${SCRIPT}`:
fi

mta=`sed -n 's/^# MTA: //p' ${SCRIPT} |head -1`

# for testing, only the number of cmd line args is of importance
case $mta in
  [Cc]ourier) args=
           break
           ;;
  [Ee]xim) args="-f $from -d $to"
        break
        ;;
  libmilter) args="$tmpdir $from $to"
             /bin/rm -rf $tmpdir
             (umask 077 && mkdir $tmpdir) || exit 1
             break
             ;;
  postfix) args="$from $to"
           break
           ;;
  sendmail)
            args="$from $to arg3 arg4"
            break
            ;;
  *) echo "$mta currently not supported by test suite!"
     exit 1
     ;;
esac

