source: trunk/third/transcript/lib/psint.sysv @ 9090

Revision 9090, 4.3 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r9089, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1
2# System V line printer spooler model for PostScript/TranScript printer
3# Copyright (c) 1985,1987,1991,1992 Adobe Systems Incorporated. All Rights
4# Reserved. 
5# GOVERNMENT END USERS: See Notice file in TranScript library directory
6# -- probably /usr/lib/ps/Notice
7# RCSID: $Header: /afs/dev.mit.edu/source/repository/third/transcript/lib/psint.sysv,v 1.1.1.1 1996-10-07 20:25:32 ghudson Exp $
8
9# stty options are:
10#       stty cs8 9600 cread -clocal -ignbrk brkint -parmrk \
11#       inpck -istrip -inlcr -igncr -icrnl -iuclc ixon -ixany ixoff \
12#       -opost -isig -icanon -xcase
13#       -echo -echoe -echok -echonl min \^a time \^d
14#
15# on 3B2 Sys Vr2v2 this is "1412:0:4bd:0:7f:1c:23:40:1:4:0:0"
16
17sttyopts="XCODEX"
18SPOOLDIR=XSPOOLDIRX
19
20# establish basics
21# the log files is also our stdout and stderr file (set up with lpadmin)
22#       argv[0] is interface/PRINTERNAME
23#       cwd is the spooler directory (/usr/spool/lp)
24#       our environment gives us fairly little info though lots is passed in
25
26prog=$0
27pr=`basename $prog`
28printdev=/dev/$pr
29printer=$pr
30cwd=`pwd`
31ptime=`date`
32log=$SPOOLDIR/transcript/${pr}-log
33if [ ! -w "$log" ] ; then
34        disable -r"can't access log file $log" $pr 1>/dev/console 2>&1
35        exit 1
36fi
37# set these however you want, set psrv to null if you don't want reversal
38PSLIBDIR=XPSLIBDIRX
39PSCOMM=XPSCOMMX
40send=$PSLIBDIR/$PSCOMM
41banner=$PSLIBDIR/psbanner
42docman=$PSLIBDIR/psdman
43BANNERPRO=$PSLIBDIR/banner.pro
44VERBOSELOG=XVERBOSELOGX
45BANNERFIRST=XBANNERFIRSTX
46BANNERLAST=XBANNERLASTX
47REVERSE=XREVERSEX
48PSTEMPDIR=XPSTEMPDIRX
49export VERBOSELOG BANNERPRO BANNERFIRST BANNERLAST PSTEMPDIR REVERSE PSLIBDIR
50
51# printer-specific options file (can change any of the above)
52test -r ./transcript/${pr}.opt && . ./transcript/${pr}.opt
53
54if [ "$sttyopts" = "" ]
55then
56    dostty=FALSE
57else
58    dostty=TRUE
59fi
60
61# parse command line options (cannonical)
62seqid=$1
63name=$2
64title="$3"
65copies=$4
66options="$5"
67shift; shift; shift; shift; shift
68files="$*"
69if [ -z "$title" ] ; then
70        title=`basename $1`
71fi
72# parse TranScript-specific user options with getopt
73set -- `getopt hmr "$options"`
74if [ $? != 0 ] ; then
75        echo $pr: $seqid bad user options $options
76        exit 2
77fi
78Hflag= Mflag= Rflag=
79for i in $*
80do      case $i in
81        -h|h)   Hflag=$i; shift;;       # no banner page
82        -m|m)   Mflag=$i; shift;;       # mail stream output if any
83        -r|r)   Rflag=$i; shift;;       # never reverse
84        --)     shift ;;
85        esac
86done
87
88# set up to send the job
89if [ ! -x $send ] ; then
90        disable -r"can't execute $send filter" $pr
91        exit 1
92fi
93
94# add args to $send now
95send="$send -P $printer -n $name"
96
97echo $pr: $seqid $name "$title" start - $ptime
98
99# create banner page
100if [ -z "$Hflag" -a \( "$BANNERFIRST" = "1" -o "$BANNERLAST" = "1" \) ] ; then
101        if [ ! -x $banner ] ; then
102            disable -r"can't exec $banner program" $pr
103            exit 1
104        fi
105        bannerf=$PSTEMPDIR/bantmp.$$
106#       trap "rm -f $bannerf" 1 2 3 15
107        if [ ! -r $BANNERPRO ] ; then
108                disable -r"can't access banner prolog" $pr
109                exit 1
110        fi
111        $banner $pr $seqid $name "$title" "$ptime" >$bannerf
112fi
113
114# print banner page first ?
115if [ -z "$Hflag" -a "$BANNERFIRST" = "1" ] ; then
116    if [ $dostty = "TRUE" ]
117    then
118        (stty $sttyopts <&1
119        $send <$bannerf
120        ) 1>$printdev 2>>$log 3<$printdev
121    else
122        ($send <$bannerf
123        ) 1>$printdev 2>>$log 3<$printdev
124    fi
125fi
126
127# set up to mail job output if user flag set
128if [ -n "$Mflag" ] ; then
129        JOBOUTPUT=${PSTEMPDIR}/outtmp.$$
130        export JOBOUTPUT
131fi
132
133# now process the print files
134for f in $files
135do
136        echo $pr: $seqid `basename $f` - `date`
137        cop=$copies
138        # print all the copies, reversing as necessary
139    if [ $dostty = "TRUE" ]
140    then
141        while [ $cop -ge 1 ]
142        do      (stty $sttyopts <&1
143                $docman -P $printer <$f | $send
144                ) 1>$printdev 2>>$log 3<$printdev
145                cop=`expr $cop - 1`
146        done
147    else
148        while [ $cop -ge 1 ]
149        do      (
150                $docman -P $printer <$f | $send
151                ) 1>$printdev 2>>$log 3<$printdev
152                cop=`expr $cop - 1`
153        done
154    fi
155
156done
157
158# print banner page last ?
159if [ -z "$Hflag" -a "$BANNERLAST" = "1" ] ; then
160    if [ $dostty = "TRUE" ]
161    then
162        (stty $sttyopts <&1
163        $send <$bannerf
164        ) 1>$printdev 2>>$log 3<$printdev
165    else
166        ($send <$bannerf
167        ) 1>$printdev 2>>$log 3<$printdev
168    fi
169fi
170
171# mail user the job ouput if flag set
172if [ -n "$Mflag" ] ; then
173        if [ -s "$JOBOUTPUT" ] ; then
174                (echo Subject: output from PostScript print job $seqid follows
175                cat $JOBOUTPUT ) | mail $name
176        fi
177        rm -f $JOBOUTPUT
178fi
179
180echo $pr: $seqid end - `date`
181
182# clean up
183rm -f $bannerf
Note: See TracBrowser for help on using the repository browser.