# iPAX286 lp interface for dumb serial line printer
#
#ident	"@(#)	1.2"
#
#

x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
printer=`basename $0`
copies=$4
if [ $printer != dumb -a $printer != other ]	#parallel?
then
	if [ $printer = `echo $printer|cut -dR -f1` ]  #fails if R is last char
	then
		stty  ixon 0<&1
	else
		stty -opost ixon 0<&1		#raw output 
	fi
fi

if [ X${BANNER:+yes} = Xyes ]
then
	echo "$x\n$x\n$x\n$x\n"
	banner "$2"
	echo "\n"
	user=`grep "^$2:" /etc/passwd | line | cut -d: -f5`
	if [ -n "$user" ]
	then
		echo "User: $user\n"
	else
		echo "\n"
	fi
	echo "Request id: $1    Printer: $printer\n"
	date
	echo "\n"
	if [ -n "$3" ]
	then
		banner $3
	fi
	echo "Print Options:  \n"
	echo "		Copies="$copies"\n"
fi  
shift; shift; shift; shift; shift
files="$*"
i=1
while [ $i -le $copies ]
do
	for file in $files
	do
		cat "$file" 2>&1
		echo "\014\c"
	done
	i=`expr $i + 1`
done
echo "$x\n$x\n$x\n$x\n"
exit 0
