#
# llp:
#	replacement for "lp" command, providing proximity-driven
#	intelliegnt departmental printer job routing.
#
#	Written by Leor Zolman, 9/91
#
# Usage:
#	llp [-formtype] ...
#		invokes "lp", translating formtype into appropriate "-d" clause.
#
#	If $SOFTCOPY is set to Y in the current environment, and the file
#	$SOFTDIR/Soft.status consists of "B" or "F", then output is written to
#	a file whose name is specified by the contents of $SOFTDIR/Softfile.
#	If $SOFTDIR/Soft.status is "B", then output is also sent to "lp".
#

PTRDIR=/u/leor/docs/Cols/SA/Printers			# Printer control directory
CODECHAR=L										# for restricting selections
WHAT="Paper"

SOFTDIR=$HOME/.Soft							# user's Soft-copy config dir
SOFTSTAT=$SOFTDIR/Soft.status				# file containing soft-copy status
SOFTFILE=$SOFTDIR/Soft.file					# file containing name of the file
											# 	to append soft-copy output to
#
# Process command line, handle intializations and special-case mappings:
#

. $PTRDIR/initmap.sh

#
# Map $ptype and $DEPT into appropriate lp text in $lpopts:
#

. $PTRDIR/proxmap.sh

[ $DEBUG = Y ] && exit

#
# Support "Soft-copy" feature, to allow Sys Admin's to generate file output
# in place of printed output for testing and saving paper. 
# 

if [ "$SOFTCOPY" = Y ]; then
	read SOFTCODE < $SOFTSTAT
	read SOFTNAME < $SOFTFILE
	case "$SOFTCODE" in
		B)	if [ $# -eq 0 ]; then
				exec tee -a $SOFTNAME | lp $lpopts
			else
				exec cat $* | tee -a $SOFTNAME | lp $lpopts
			fi;;
		F)	exec cat $* >> $SOFTNAME;;
	esac
fi

#
# If Soft copy is disabled, just go to printer:
#

if [ $# -eq 0 ]; then
	exec lp $lpopts -
else
	exec lp $lpopts $*
fi
