#
# initmap.sh: implementation-dependent departmental mappings
#	"Sourced" by llp, getptr and gethead.
#

DEBUG=N				# set to Y to display diagnostic info

###########################################################################
# The following section may contain code to modify the $DEPT variable
# in its symbolic form, before it is converted to a numeric dept. ID:
#

# if user's .profile does not initialize DEPT, use mktg as the default:
[ $DEPT = "" ] && DEPT=mktg

# If one department shares another's printers, fold the two onto one:
[ $DEPT = per ] && DEPT=mktg		# Periodicals uses Mktg's printers

# Allow definition of DEPTP to override a user's "natural" department:
[ "$DEPTP" != "" ] && DEPT=$DEPTP
#
###########################################################################

#
# Process command line printer/paper selectors:
#

if [ $# -eq 0 ]; then
	ptype=P
else
	ptype="`echo "$1" | tr -d "-" | tr '[a-z]' '[A-Z]'`"
	shift
	[ $DEBUG = Y ] && echo "ptype set to: $ptype"
fi

if grep ":$ptype:" $PTRDIR/paper.map >/dev/null
then
	:
else
	echo "$0: Unknown $WHAT type: $ptype"
	exit 1
fi

#
# Now map department name into dept. number ($DEPT), description ($DEPTDESC)
#

if tmp=`grep "[^\011 ]$DEPT," $PTRDIR/dept.map`
then
	DEPT=`echo $tmp | cut -f1 -d, `
	DEPTDESC="`echo $tmp | cut -f2 -d\\\"`"
else
	echo "Error: unknown Department name $DEPT specified." >&2
fi
