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 | |
---|
17 | sttyopts="XCODEX" |
---|
18 | SPOOLDIR=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 | |
---|
26 | prog=$0 |
---|
27 | pr=`basename $prog` |
---|
28 | printdev=/dev/$pr |
---|
29 | printer=$pr |
---|
30 | cwd=`pwd` |
---|
31 | ptime=`date` |
---|
32 | log=$SPOOLDIR/transcript/${pr}-log |
---|
33 | if [ ! -w "$log" ] ; then |
---|
34 | disable -r"can't access log file $log" $pr 1>/dev/console 2>&1 |
---|
35 | exit 1 |
---|
36 | fi |
---|
37 | # set these however you want, set psrv to null if you don't want reversal |
---|
38 | PSLIBDIR=XPSLIBDIRX |
---|
39 | PSCOMM=XPSCOMMX |
---|
40 | send=$PSLIBDIR/$PSCOMM |
---|
41 | banner=$PSLIBDIR/psbanner |
---|
42 | docman=$PSLIBDIR/psdman |
---|
43 | BANNERPRO=$PSLIBDIR/banner.pro |
---|
44 | VERBOSELOG=XVERBOSELOGX |
---|
45 | BANNERFIRST=XBANNERFIRSTX |
---|
46 | BANNERLAST=XBANNERLASTX |
---|
47 | REVERSE=XREVERSEX |
---|
48 | PSTEMPDIR=XPSTEMPDIRX |
---|
49 | export VERBOSELOG BANNERPRO BANNERFIRST BANNERLAST PSTEMPDIR REVERSE PSLIBDIR |
---|
50 | |
---|
51 | # printer-specific options file (can change any of the above) |
---|
52 | test -r ./transcript/${pr}.opt && . ./transcript/${pr}.opt |
---|
53 | |
---|
54 | if [ "$sttyopts" = "" ] |
---|
55 | then |
---|
56 | dostty=FALSE |
---|
57 | else |
---|
58 | dostty=TRUE |
---|
59 | fi |
---|
60 | |
---|
61 | # parse command line options (cannonical) |
---|
62 | seqid=$1 |
---|
63 | name=$2 |
---|
64 | title="$3" |
---|
65 | copies=$4 |
---|
66 | options="$5" |
---|
67 | shift; shift; shift; shift; shift |
---|
68 | files="$*" |
---|
69 | if [ -z "$title" ] ; then |
---|
70 | title=`basename $1` |
---|
71 | fi |
---|
72 | # parse TranScript-specific user options with getopt |
---|
73 | set -- `getopt hmr "$options"` |
---|
74 | if [ $? != 0 ] ; then |
---|
75 | echo $pr: $seqid bad user options $options |
---|
76 | exit 2 |
---|
77 | fi |
---|
78 | Hflag= Mflag= Rflag= |
---|
79 | for i in $* |
---|
80 | do 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 |
---|
86 | done |
---|
87 | |
---|
88 | # set up to send the job |
---|
89 | if [ ! -x $send ] ; then |
---|
90 | disable -r"can't execute $send filter" $pr |
---|
91 | exit 1 |
---|
92 | fi |
---|
93 | |
---|
94 | # add args to $send now |
---|
95 | send="$send -P $printer -n $name" |
---|
96 | |
---|
97 | echo $pr: $seqid $name "$title" start - $ptime |
---|
98 | |
---|
99 | # create banner page |
---|
100 | if [ -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 |
---|
112 | fi |
---|
113 | |
---|
114 | # print banner page first ? |
---|
115 | if [ -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 |
---|
125 | fi |
---|
126 | |
---|
127 | # set up to mail job output if user flag set |
---|
128 | if [ -n "$Mflag" ] ; then |
---|
129 | JOBOUTPUT=${PSTEMPDIR}/outtmp.$$ |
---|
130 | export JOBOUTPUT |
---|
131 | fi |
---|
132 | |
---|
133 | # now process the print files |
---|
134 | for f in $files |
---|
135 | do |
---|
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 | |
---|
156 | done |
---|
157 | |
---|
158 | # print banner page last ? |
---|
159 | if [ -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 |
---|
169 | fi |
---|
170 | |
---|
171 | # mail user the job ouput if flag set |
---|
172 | if [ -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 |
---|
178 | fi |
---|
179 | |
---|
180 | echo $pr: $seqid end - `date` |
---|
181 | |
---|
182 | # clean up |
---|
183 | rm -f $bannerf |
---|