#!/bin/sh
#
# PC-Xview MS-DOS print spooler access routine
# Copyright (C) 1988, 1989 by Graphic Software Systems, Inc.
# All rights reserved
#
# $Header: /xqa2/build/xview/RCS/pcxprint,v 1.12 1990/10/10 17:13:51 gened Exp $
# $Locker:  $
#
trap 'rm /tmp/pcpr$$; exit' 2
pc=`echo $DISPLAY | sed 's/:.*$//'`

case $# in
0)      echo "Usage: $0" '[-cdqt] [filenames..]  # -h for help';;
*)      case $1 in
            -c) shift;rsh $pc print /C $@ ;;
            -d) rsh $pc 'del *.XPR';;
            -q) rsh $pc print ;;
            -t) rsh $pc print /T ;;
            -h | -help) 
		   echo "Usage: $0" '[-cdqt] [filenames..]';
                   echo '	-c:    cancel listed files in print queue';
                   echo '	-d:    delete scratch files';
                   echo '	-q:    display print queue';
                   echo '	-t:    delete all files in the print queue';
		   ;;
            -*) echo unknown flag \'$1\';;
            *)  
		for i in $@; do
		    if test ! \( -f $i -a -r $i -a -s $i \) ; then
			echo "file not found: $i"
			exit 1
		    fi
		done
		pr -w80 $@ > /tmp/pcpr$$;
                tftp $pc << EOF > /dev/null;
                put /tmp/pcpr$$ pcp$$.XPR
                quit
EOF
                rm /tmp/pcpr$$
		sleep 3			# due to weak Excelan code
                rsh $pc 'print' pcp$$.XPR ;;
       esac
esac
