#
# address: mail address specification
#

REVISION_ID='@(#)address	3.6 (motonori/WIDE) 2/26/94'

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

# allocate grobal class/macro characters
_ALLOC_MODE=normal
_ALLOC_TYPE=pair
_ALLOC_DIR=down
_ALLOC_PREF=S
_ALLOC_USAGE='from address/local users [address]'
. $MASTERDIR/$CHARALLOC
_LU_CHAR=$_ALLOC_CHAR	# class for local users
_FA_CHAR=$_ALLOC_CHAR	# macro for from address

#|# user names which require host.domain
#|##LOCAL_USERS='user1 user2 ...'

CLASS=
case "$LOCAL_USERS" in
"") ;;
/*)     # file definition
	CLASS="F$_LU_CHAR$LOCAL_USERS" ;;
*)      # definition in .cf
	exec << EoF
$LOCAL_USERS
EoF
	CLASS=`sed 's/^/C'$_LU_CHAR' /'` ;;
esac

HDRLOCALUSERS="C$_LU_CHAR root daemon news usenet\\
C$_LU_CHAR postmaster MAILER-DAEMON\\
$CLASS"

LOCALFROM='R$='$_LU_CHAR'			$@$1<@$j>			show exposed names'

#|# default from-address (can be $j, $m or another generic address)
#|#FROM_ADDRESS='$j'
#|##FROM_ADDRESS='$m'

: ${FROM_ADDRESS='$j'}
HDRFROMADDR=D$_FA_CHAR$FROM_ADDRESS

GENERALFROM='R$+			$@$1<@$'$_FA_CHAR'>			user w/o host'

#|# apply FROM_ADDRESS for receipients (yes/no)
#|#RECEIPIENT_GENERIC=no

: ${RECEIPIENT_GENERIC=no}
if [ "$RECEIPIENT_GENERIC" != no ]
then
LOCALRECEIPIENTRULE='R$+			$@$1<@$'$_FA_CHAR'>			user w/o host'
else
LOCALRECEIPIENTRULE='R$+			$@$1<@$j>			user w/o host'
fi

#|# rewrite address which has official name already into generic form
#|# (yes/lower/no)
#|#REWRITE_GENERIC_FROM=no
#|#REWRITE_GENERIC_TO=no

: ${REWRITE_GENERIC_FROM=no}
case "$REWRITE_GENERIC_FROM" in
	yes)
S11GENERICREWRITE='\
R$='$_LU_CHAR'<@$j>		$@$1<@$j>			exposed user as is\
R$*<@$j>		$@$1<@$'$_FA_CHAR'>			rewrite to generic form'
	;;
	lower)
S11GENERICREWRITE='\
R$='$_LU_CHAR'<@$*$m>		$@$1<@$2$m>			exposed user as is\
R$*<@$*$m>		$@$1<@$'$_FA_CHAR'>			rewrite to generic form'
	;;
esac

: ${REWRITE_GENERIC_TO=no}
if [ "$REWRITE_GENERIC_TO" != no ]
then
	if [ "$RECEIPIENT_GENERIC" = no ]
	then
		echo 'address: RECEIPIENT_GENERIC should be yes when REWRITE_GENERIC_TO is used.' 1>&2
	fi
fi
case "$REWRITE_GENERIC_TO" in
	yes)
S21GENERICREWRITE='\
R$='$_LU_CHAR'<@$j>		$@$1<@$j>			exposed user as is\
R$*<@$j>		$@$1<@$'$_FA_CHAR'>			rewrite to generic form'
	;;
	lower)
S21GENERICREWRITE='\
R$='$_LU_CHAR'<@$*$m>		$@$1<@$2$m>			exposed user as is\
R$*<@$*$m>		$@$1<@$'$_FA_CHAR'>			rewrite to generic form'
	;;
esac

#|# rewrite local address of recipient on relay mailer (generic/strip/no)
#|#REWRITE_LOCAL_ON_RELAY=no

: ${REWRITE_LOCAL_ON_RELAY=no}
case "$REWRITE_LOCAL_ON_RELAY" in
	generic)
S29RELAYRULE='\
# rewrite local address\
S29\
\
R$='$_LU_CHAR'<@$j>		$@$1<@$j>			exposed user as is\
R$*<@$j>		$@$1<@$'$_FA_CHAR'>			rewrite to generic form'
	;;
	strip)
S29RELAYRULE='\
# rewrite local address\
S29\
\
R$='$_LU_CHAR'<@$j>		$@$1<@$j>			exposed user as is\
R$*<@$j>		$@$1				strip off local address'
	;;
esac
