#
# specialfrom: generate rules to apply special address for specific users
#

REVISION_ID='@(#)specialfrom	3.7 (motonori/WIDE) 2/26/94'

#|# special address for sending
#|##SPECIAL_FROM='special.address'
#|# special users who should use the special address
#|##SPECIAL_USERS='user1 user2 ...'
#|##SPECIAL_USERS='/etc/sendmail.specialusers'
#|# accept special address only for defined users (yes/no)
#|#ACCEPT_SPECIAL=no
#|# perform special address rewriting (yes/no)
#|#SPECIAL_FROM_REWRITE=no

if [ "$SPECIAL_FROM" ]
then

	if [ "$REVISION_ID_LIST" ]
	then
		REVISION_ID_LIST="$REVISION_ID_LIST\\
# $REVISION_ID"
	else
		REVISION_ID_LIST="# $REVISION_ID"
	fi

	# allocate class/macro character pair
	_ALLOC_MODE=normal
	_ALLOC_TYPE=pair
	_ALLOC_DIR=down
	_ALLOC_PREF=Q
	_ALLOC_USAGE='special users/address [specialfrom]'
	. $MASTERDIR/$CHARALLOC
	_SA_CHAR=$_ALLOC_CHAR

	MACRO="D$_SA_CHAR$SPECIAL_FROM"
	CLASS=
        case "$SPECIAL_USERS" in
        /*)     # file definition
                CLASS="F$_SA_CHAR$SPECIAL_USERS" ;;
        "") ;;
        *)      # definition in .cf
		exec << EoF
$SPECIAL_USERS
EoF
		CLASS=`sed 's/^/C'$_SA_CHAR' /'` ;;
        esac
	if [ "$CLASS" = "" ]
	then
		CLASS='#C'$_SA_CHAR' specialusers'
	fi

HDRSPECIALFROM="\\
# special domain name and users\\
$MACRO\\
$CLASS"

S11SPECIALFROM='R$='$_SA_CHAR'			$@$1<@$'$_SA_CHAR'>			special users'
S21SPECIALFROM='R$='$_SA_CHAR'			$@$1<@$'$_SA_CHAR'>			special users'

        : ${ACCEPT_SPECIAL=no}
	if [ "$ACCEPT_SPECIAL" != no ]
	then

SPECIALFROMRULE='\
# special domain to be recognized as local\
R$='$_SA_CHAR'<@$'$_SA_CHAR'>		$1'

	fi

        : ${SPECIAL_FROM_REWRITE=no}
	if [ "$SPECIAL_FROM_REWRITE" != no ]
	then

S11SPECIALREWRITE='R$='$_SA_CHAR'<@$j>		$@$1<@$'$_SA_CHAR'>			rewrite to special addr'
S21SPECIALREWRITE='R$='$_SA_CHAR'<@$j>		$@$1<@$'$_SA_CHAR'>			rewrite to special addr'

	fi

fi
