
# Alpha Microsystems Diablo 630 printer interface
# Copyright (C) 1984 By Alpha Microsystems, Irvine CA.
#

stty 1200 cread onlcr ixon ixany -raw opost -parenb cs8 tab3 0<&1
bname=$0
reqid=$1
usrid=$2
title=$3
hdr=
if [ -n "$title" ]
then
	hdr=-h
fi
copies=$4
page=
lns=-l66
lines=6
pitch=10
width=80
for i in $5
do
	case "$i" in
		w132 | -w132)	# paper width
		width=132
		;;
		sp | -sp)	# proportional spacing
		pitch=p
		;;
		s12 | -s12)	# 12 cpi
		pitch=10
		;;
		s15 | -s15)	# 15 cpi
		pitch=15
		;;
		l8 | -l8)	# 8 lines per inch
		lines=8
		lns=-l88
		;;
		p | -p)		# paginate printout
		page=p
		;;
	esac
done
shift; shift; shift; shift; shift
files="$*"
if [ X$width = X80 ]
then
	x="*******************************************************************************"
else
	x="***********************************************************************************************************************************"
fi
i=1
while [ $i -le $copies ]
do
	for file in $files
	do
#		echo "\033\015P\c"	# reset
		case "$pitch" in
			10)
			echo "\033\037\015\c"
			;;
			p)
			echo "\033P\c"
			;;
			12)
			echo "\033\037\013\c"
			;;
			15)
			echo "\033\037\011\c"
			;;
		esac
		case "$lines" in
			6)
			echo "\033\036\0211\c"
			;;
			8)
			echo "\033\036\007\c"
			;;
		esac
		echo "$x\n$x\n$x\n\c"
		banner "$usrid"
		echo "\nFilename: $file\n\c"
		user= `grep "^$usrid:" /etc/passwd | line | cut -d: -f5`
		if [ -n "$user" ]
		then
			echo "User: $user\n\c"
		fi
		echo "Request id: $reqid	Printer: `basename $bname`\n\c"
		date
		echo "\n\c"
		if [ -n "$title" ]
		then
			banner "$title"
		else
			banner `basename $file`
		fi
		echo "\014\c"
		if [ X$page = Xp ]
		then
			newform -i -l$width <"$file" | pr -r $lns $hdr "$title" 2>&1
		else
			newform -i -l$width <"$file" | cat 2>&1
		fi
	done
	i=`expr $i + 1`
done
exit 0
