summaryrefslogtreecommitdiff
path: root/sys/lib/lp
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 16:53:33 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 16:53:33 +0300
commite463eb40363ff4c68b1d903f4e0cdd0ac1c5977f (patch)
treed5e9f57c28f026cb21de3bd77cc10cd7f64aaa85 /sys/lib/lp
parentb41b9034225ab3e49980d9de55c141011b6383b0 (diff)
Import sources from 2011-03-30 iso image - sys/lib
Diffstat (limited to 'sys/lib/lp')
-rwxr-xr-xsys/lib/lp/bin/UNLOCK3
-rwxr-xr-xsys/lib/lp/bin/kill_xerox-45124
-rwxr-xr-xsys/lib/lp/bin/lpscratch2
-rwxr-xr-xsys/lib/lp/bin/lpsend.rc18
-rwxr-xr-xsys/lib/lp/bin/true2
-rwxr-xr-xsys/lib/lp/daemon/appletalk2
-rwxr-xr-xsys/lib/lp/daemon/dkcat2
-rwxr-xr-xsys/lib/lp/daemon/dumb3
-rwxr-xr-xsys/lib/lp/daemon/generic137
-rwxr-xr-xsys/lib/lp/daemon/hp7
-rwxr-xr-xsys/lib/lp/daemon/justsend2
-rwxr-xr-xsys/lib/lp/daemon/lpd-tek3
-rwxr-xr-xsys/lib/lp/daemon/lpddaemon3
-rwxr-xr-xsys/lib/lp/daemon/lpdpost2
-rwxr-xr-xsys/lib/lp/daemon/lps2
-rwxr-xr-xsys/lib/lp/daemon/pcclone3
-rwxr-xr-xsys/lib/lp/daemon/post3
-rwxr-xr-xsys/lib/lp/daemon/post.warn40
-rwxr-xr-xsys/lib/lp/daemon/tcppost6
-rwxr-xr-xsys/lib/lp/daemon/tektronix3
-rwxr-xr-xsys/lib/lp/daemon/xante3
-rwxr-xr-xsys/lib/lp/daemon/xerox3
-rwxr-xr-xsys/lib/lp/daemon/xerox-45173
-rwxr-xr-xsys/lib/lp/daemon/xerox-N323
-rwxr-xr-xsys/lib/lp/devices72
-rwxr-xr-xsys/lib/lp/kill/generic29
-rwxr-xr-xsys/lib/lp/kill/xerox5
-rwxr-xr-xsys/lib/lp/kill/xerox-45126
-rwxr-xr-xsys/lib/lp/kill/xerox-45176
-rwxr-xr-xsys/lib/lp/process/dpost82
-rwxr-xr-xsys/lib/lp/process/dvipost120
-rwxr-xr-xsys/lib/lp/process/g3post84
-rwxr-xr-xsys/lib/lp/process/generic218
-rwxr-xr-xsys/lib/lp/process/gifpost84
-rwxr-xr-xsys/lib/lp/process/gspipe24
-rwxr-xr-xsys/lib/lp/process/gspipeijs35
-rwxr-xr-xsys/lib/lp/process/hpost148
-rwxr-xr-xsys/lib/lp/process/jpgpost84
-rwxr-xr-xsys/lib/lp/process/noproc3
-rwxr-xr-xsys/lib/lp/process/p9bitpost83
-rwxr-xr-xsys/lib/lp/process/pdfgs71
-rwxr-xr-xsys/lib/lp/process/pdfgsijs63
-rwxr-xr-xsys/lib/lp/process/pdfpost76
-rwxr-xr-xsys/lib/lp/process/pngpost84
-rwxr-xr-xsys/lib/lp/process/post68
-rwxr-xr-xsys/lib/lp/process/ppost99
-rwxr-xr-xsys/lib/lp/process/psextract60
-rwxr-xr-xsys/lib/lp/process/testpost74
-rwxr-xr-xsys/lib/lp/process/tiffpost85
-rwxr-xr-xsys/lib/lp/process/tr2post86
-rwxr-xr-xsys/lib/lp/sched/FIFO2
-rwxr-xr-xsys/lib/lp/spooler/generic47
-rwxr-xr-xsys/lib/lp/spooler/lpdspool14
-rwxr-xr-xsys/lib/lp/spooler/lpdspool+fonts16
-rwxr-xr-xsys/lib/lp/spooler/mhcc52
-rwxr-xr-xsys/lib/lp/spooler/nospool21
-rwxr-xr-xsys/lib/lp/spooler/nt14
-rwxr-xr-xsys/lib/lp/spooler/nt-tekphaser35014
-rwxr-xr-xsys/lib/lp/spooler/pcclone14
-rwxr-xr-xsys/lib/lp/spooler/pcclone.new22
-rwxr-xr-xsys/lib/lp/spooler/ps63030
-rwxr-xr-xsys/lib/lp/stat/generic27
-rwxr-xr-xsys/lib/lp/stat/hp30
-rwxr-xr-xsys/lib/lp/stat/lpd11
-rwxr-xr-xsys/lib/lp/stat/mhcc3
-rwxr-xr-xsys/lib/lp/stat/tektronix29
-rwxr-xr-xsys/lib/lp/stat/xante29
-rwxr-xr-xsys/lib/lp/stat/xerox29
-rwxr-xr-xsys/lib/lp/stat/xerox-451229
-rwxr-xr-xsys/lib/lp/stat/xerox-451729
-rwxr-xr-xsys/lib/lp/stat/xerox-N3230
71 files changed, 2600 insertions, 0 deletions
diff --git a/sys/lib/lp/bin/UNLOCK b/sys/lib/lp/bin/UNLOCK
new file mode 100755
index 000000000..8d54345ea
--- /dev/null
+++ b/sys/lib/lp/bin/UNLOCK
@@ -0,0 +1,3 @@
+#!/bin/rc
+
+rm -f $1/LOCK
diff --git a/sys/lib/lp/bin/kill_xerox-4512 b/sys/lib/lp/bin/kill_xerox-4512
new file mode 100755
index 000000000..4479d550d
--- /dev/null
+++ b/sys/lib/lp/bin/kill_xerox-4512
@@ -0,0 +1,4 @@
+#!/bin/rc
+
+if (~ $#* 0) exits 'no argument'
+/$cputype/bin/aux/lpdsend -dPORT1 -k $1 $OUTDEV
diff --git a/sys/lib/lp/bin/lpscratch b/sys/lib/lp/bin/lpscratch
new file mode 100755
index 000000000..e11ddc624
--- /dev/null
+++ b/sys/lib/lp/bin/lpscratch
@@ -0,0 +1,2 @@
+#!/bin/rc
+LPSCRATCH=/sys/lib/lp
diff --git a/sys/lib/lp/bin/lpsend.rc b/sys/lib/lp/bin/lpsend.rc
new file mode 100755
index 000000000..74806cded
--- /dev/null
+++ b/sys/lib/lp/bin/lpsend.rc
@@ -0,0 +1,18 @@
+#!/bin/rc
+if (! ~ $DEBUG '') { flag x + }
+if (test -e /net/tcp/clone) {
+ dialstring=`{ndb/query sys $1 dom}
+ network=tcp
+ if (~ $#dialstring 0 || ! ~ $dialstring '') {
+ dialstring=$1
+ }
+ if(lpsend $network^!^$dialstring^!printer) exit ''
+ rv='tcp failed'
+}
+if not rv='no tcp'
+
+
+if (! ~ $dialstring '')
+ exit 'lpsend: no dialstring'
+if not
+ exit 'lpsend: '^$rv
diff --git a/sys/lib/lp/bin/true b/sys/lib/lp/bin/true
new file mode 100755
index 000000000..daa0ab9ff
--- /dev/null
+++ b/sys/lib/lp/bin/true
@@ -0,0 +1,2 @@
+#!/bin/rc
+exit ''
diff --git a/sys/lib/lp/daemon/appletalk b/sys/lib/lp/daemon/appletalk
new file mode 100755
index 000000000..481bd5dec
--- /dev/null
+++ b/sys/lib/lp/daemon/appletalk
@@ -0,0 +1,2 @@
+#!/bin/rc
+generic '/usr/lib/laserwriter/psf -d -P$LPDEST -h$SCHEDLINE(1) -n$SCHEDLINE(2) < $LPDEST/$FILE(1) >[2]$LPSPOOL/log/$LPDEST^.st' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5}| lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/dkcat b/sys/lib/lp/daemon/dkcat
new file mode 100755
index 000000000..8a8848cfa
--- /dev/null
+++ b/sys/lib/lp/daemon/dkcat
@@ -0,0 +1,2 @@
+#!/bin/rc
+generic '/lib/postscript/bin/$cputype/dkcat -s$PRINTLOG $OUTDEV $LPDEST/$FILE(1)' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/dumb b/sys/lib/lp/daemon/dumb
new file mode 100755
index 000000000..8d15feee7
--- /dev/null
+++ b/sys/lib/lp/daemon/dumb
@@ -0,0 +1,3 @@
+#!/bin/rc
+
+generic 'cat $LPDEST/$FILE(1)>$OUTDEV' 'cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE;sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/generic b/sys/lib/lp/daemon/generic
new file mode 100755
index 000000000..aa760c2ba
--- /dev/null
+++ b/sys/lib/lp/daemon/generic
@@ -0,0 +1,137 @@
+#!/bin/rc
+rfork s
+
+if (! ~ $DEBUG '') flag x +
+
+LPDELAY=60
+
+if (! ~ $#* 2 && ! ~ $#* 3) {
+ echo 'usage generic local_cmd _remote_cmd [ success_cmd ]' >[1=2]
+ exit 'argument count'
+}
+LOCAL_CMD=$1
+REMOTE_CMD=$2
+SUCCESS_CMD=$3
+
+# we don't want to make a LOCK file unless we are at the destination
+# let the spooler take care of moving it there
+# this is necessary for clients and servers that share the
+# same name space
+if (! ~ $THIS_HOST $DEST_HOST || ! LOCK $LPSPOOL/$LPDEST/LOCK $sysname $pid) exit ''
+
+cd $LPSPOOL
+
+MAXTRY=2
+PRINTLOG=$LPLOGDIR/$LPDEST^.st
+
+fn schedule{
+ FILE=`{
+ @{
+ rfork n
+ bind -b $LPLIB/sched /bin
+ $SCHED $LPDEST
+ }
+ }
+}
+
+while (schedule; ! ~ $#FILE 0) {
+ SCHEDLINE=`{cat $LPDEST/$FILE(1)^id}
+ LSLINE=`{ls -l $LPDEST/$FILE(1)}
+ if (! test -s $LPDEST/.seqno) {
+ echo 0 > $LPDEST/.seqno
+ }
+ if not {
+ LPSEQNO = `{cat $LPDEST/.seqno | awk '{seqno = $1 + 1; if (seqno > 999) seqno = 0; print seqno}'}
+ echo $LPSEQNO > $LPDEST/.seqno
+ }
+ STARTIME=`{date}
+ if (! test -s $LPDEST/$FILE(1)) {
+ echo $SCHEDLINE(2)$SCHEDLINE(4)' '$SCHEDLINE(3) $SCHEDLINE(5)' ! '$LSLINE(6) $STARTIME(4) >> $LPLOG
+ rm -f $LPDEST/$FILE $LPDEST/$FILE^id
+ }
+ if not {
+ if (~ $THIS_HOST $DEST_HOST) {
+ if (test -f $LPLIB/perm/$LPDEST && grep -s $SCHEDLINE(2) $LPLIB/perm/$LPDEST) {
+ echo you are not allowed to use printer $LPDEST | mail $SCHEDLINE(2)
+ rm -f $LPDEST/$FILE(1) $LPDEST/$FILE(1)^id
+ }
+ if not {
+ > $PRINTLOG
+ STARTIME=`{date}
+ eval $LOCAL_CMD
+ rv=$status
+ ENDTIME=`{date}
+ status=$rv
+ if () {
+ echo $SCHEDLINE(1)^$SCHEDLINE(3)' '$SCHEDLINE(2)' '$SCHEDLINE(4)' + '$LSLINE(6)' '$STARTIME(4)' '$ENDTIME(4)
+ eval $SUCCESS_CMD
+ rm -f $LPDEST/$FILE(1) $LPDEST/$FILE(1)^id
+ }
+ if not {
+ echo $SCHEDLINE(1)^$SCHEDLINE(3)' '$SCHEDLINE(2)' '$SCHEDLINE(4)' - '$LSLINE(6)' '$STARTIME(4)' '$ENDTIME(4)' status='$rv
+ THISTRY=`{echo $SCHEDLINE(4) + 1|hoc}
+ echo $SCHEDLINE(1) $SCHEDLINE(2) $SCHEDLINE(3) $THISTRY >$LPDEST/$FILE(1)^id
+ if (test $THISTRY -ge $MAXTRY) {
+ if (test -d $LPLIB/prob/$LPDEST) {
+ cp $LPDEST/$FILE(1) $LPLIB/prob/$LPDEST
+ cp $LPDEST/$FILE(1)^id $LPLIB/prob/$LPDEST
+ cp $PRINTLOG $LPLIB/prob/$LPDEST/$FILE(1)^log
+ }
+ upasname=daemon
+ mail $SCHEDLINE(2) <<endmail1
+ rm -f $LPDEST/$FILE(1) $LPDEST/$FILE(1)^id
+ }
+ if not {
+ touch $LPDEST/$FILE(1)
+ sleep $LPDELAY
+ }
+ }
+ }
+ }
+ if not {
+# we don't want to be here
+# trap '' 13 # temp hack: ignore SIGPIPE
+ STARTIME=`{date}
+ eval $REMOTE_CMD
+ rv=$status
+ ENDTIME=`{date}
+ if (~ $rv '') {
+ echo $SCHEDLINE(1)^$SCHEDLINE(3)' '$SCHEDLINE(2)' '$SCHEDLINE(4)' + '$LSLINE(6)' '$STARTIME(4)' '$ENDTIME(4)
+ rm -f $LPDEST/$FILE(1) $LPDEST/$FILE(1)^id
+ }
+ if not {
+ echo $SCHEDLINE(1)^$SCHEDLINE(3)' '$SCHEDLINE(2)' '$SCHEDLINE(4)' - '$LSLINE(6)' '$STARTIME(4)' '$ENDTIME(4)
+ echo status $rv from '$REMOTE_CMD'
+ THISTRY=`{echo $SCHEDLINE(4) + 1|hoc}
+ echo $SCHEDLINE(1) $SCHEDLINE(2) $SCHEDLINE(3) $THISTRY >$LPDEST/$FILE(1)^id
+ if (~ $THISTRY $MAXTRY) {
+ upasname=daemon
+ mail $SCHEDLINE(2) <<endmail2
+ }
+ if not {
+ touch $LPDEST/$FILE(1)
+ sleep $LPDELAY
+
+ # this is here to deal with running out of
+ # Datakit channels or other stupid problems
+ # backoff connection attempts but not too long
+ LPDELAY=`{echo $LPDELAY '*' 2|hoc}
+ if (test $LPDELAY -gt 960)
+ LPDELAY=60
+ }
+ }
+ }
+ }
+}
+Your job has failed to print on $LPDEST after $MAXTRY attempt(s).
+If the directory $LPLIB/prob/$LPDEST exists on $DEST_HOST,
+the file has been put there along with the printer log file.
+ Your friendly printer daemon
+endmail1
+Your job has failed to print on $LPDEST after $MAXTRY attempt(s).
+There is a problem in sending the job to $DEST_HOST,
+but I'll keep trying. Have a nice day.
+ Your enthusiastic printer daemon
+endmail2
+UNLOCK $LPSPOOL/$LPDEST
+rm $LPSPOOL/$LPDEST >[2]/dev/null
diff --git a/sys/lib/lp/daemon/hp b/sys/lib/lp/daemon/hp
new file mode 100755
index 000000000..5dd870cd7
--- /dev/null
+++ b/sys/lib/lp/daemon/hp
@@ -0,0 +1,7 @@
+#!/bin/rc
+# daemon/hp
+# The destination is set to PS for the Tektronix printer, no other printer cares
+generic 'aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ < $LPDEST/$FILE(1) |
+ aux/lpdsend -dPS -H$LPMACHID -P$LPUSERID $OUTDEV >[2]$PRINTLOG' \
+ '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} \
+ $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/justsend b/sys/lib/lp/daemon/justsend
new file mode 100755
index 000000000..fc4624ae7
--- /dev/null
+++ b/sys/lib/lp/daemon/justsend
@@ -0,0 +1,2 @@
+#!/bin/rc
+generic '/$cputype/bin/aux/lpdsend -d$LPDEST -H$LPMACHID -P$LPUSERID $OUTDEV >[2] $PRINTLOG' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/lpd-tek b/sys/lib/lp/daemon/lpd-tek
new file mode 100755
index 000000000..c8d3479dc
--- /dev/null
+++ b/sys/lib/lp/daemon/lpd-tek
@@ -0,0 +1,3 @@
+#!/bin/rc
+# The destination is set to PS for the Tektronix printer, no other printer cares
+generic 'aux/download -f -H/sys/lib/postscript/font -mfontmap -ptekphaser350 < $LPDEST/$FILE(1) | aux/lpdsend -d$LPDEST -H$LPMACHID -P$LPUSERID $OUTDEV >[2] $PRINTLOG' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/lpddaemon b/sys/lib/lp/daemon/lpddaemon
new file mode 100755
index 000000000..9c2cf3d47
--- /dev/null
+++ b/sys/lib/lp/daemon/lpddaemon
@@ -0,0 +1,3 @@
+#!/bin/rc
+# The destination is set to PS for the Tektronix printer, no other printer cares
+generic '/sys/lib/postscript/bin/$cputype/download -f -H/sys/lib/postscript/font -mfontmap -plw+ < $LPDEST/$FILE(1) | /$cputype/bin/aux/lpdsend -dPS -H$LPMACHID -P$LPUSERID $OUTDEV >[2] $PRINTLOG' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/lpdpost b/sys/lib/lp/daemon/lpdpost
new file mode 100755
index 000000000..fc29c99eb
--- /dev/null
+++ b/sys/lib/lp/daemon/lpdpost
@@ -0,0 +1,2 @@
+#!/bin/rc
+generic '/sys/lib/postscript/bin/$cputype/download -f -H/sys/lib/postscript/font -mfontmap -plw+ < $LPDEST/$FILE(1) | /$cputype/bin/aux/lpdsend -d$LPDEST -H$LPMACHID -P$LPUSERID $OUTDEV >[2] $PRINTLOG' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/lps b/sys/lib/lp/daemon/lps
new file mode 100755
index 000000000..cd445c206
--- /dev/null
+++ b/sys/lib/lp/daemon/lps
@@ -0,0 +1,2 @@
+#!/bin/rc
+generic '/lib/postscript/bin/$cputype/lpif -T -P$LPDEST -N$LPDEST -h$SCHEDLINE(1) -n$SCHEDLINE(2) < $LPDEST/$FILE(1) >[2]/dev/null' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5}| lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/pcclone b/sys/lib/lp/daemon/pcclone
new file mode 100755
index 000000000..5871daaa7
--- /dev/null
+++ b/sys/lib/lp/daemon/pcclone
@@ -0,0 +1,3 @@
+#!/bin/rc
+
+generic 'aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ < $LPDEST/$FILE(1) >$OUTDEV >[2]$PRINTLOG;echo -n `{ascii -t 4} > $OUTDEV' 'aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ < $LPDEST/$FILE(1) >$OUTDEV >[2]$PRINTLOG;echo -n `{ascii -t 4} > $OUTDEV' ''
diff --git a/sys/lib/lp/daemon/post b/sys/lib/lp/daemon/post
new file mode 100755
index 000000000..44c21e074
--- /dev/null
+++ b/sys/lib/lp/daemon/post
@@ -0,0 +1,3 @@
+#!/bin/rc
+
+generic '/lib/postscript/bin/$cputype/postio -R2 -B4096 -l$OUTDEV -b$SPEED -L$PRINTLOG $LPDEST/$FILE(1)' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/post.warn b/sys/lib/lp/daemon/post.warn
new file mode 100755
index 000000000..5afad685c
--- /dev/null
+++ b/sys/lib/lp/daemon/post.warn
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+trap "" 1 2
+
+cd $LPSPOOL/queue
+
+POSTIOLOG="$LPSPOOL/log/${LPDEST}.st"
+MAILLOG=/usr/spool/mail/mail.log
+export MAILLOG POSTIOLOG
+case "$THIS_HOST" in
+"$DEST_HOST")
+ ( trap "exit 0" 15
+ while true
+ do
+ error=`tail -2 $POSTIOLOG | grep PrinterError`
+ case "$error" in
+ "") sleep 40
+ ;;
+ *)
+ set "" `cat $LPSPOOL/queue/$LPDEST/*id | sort -u`; shift
+ while [ "$1" != "" ]
+ do
+ echo "delivered $2 From nopaper (vwho)" >> /n/$1/$MAILLOG
+ shift 2
+ done
+ sleep 200 # give someone a chance to fix it
+ ;;
+ esac
+ done ) &
+ WARN=$!
+ ;;
+esac
+
+generic 'eval /usr/bin/postscript/postio -R2 -B4096 -l$OUTDEV -b$SPEED -L$PRINTLOG $LPDEST/$FILE' 'eval echo -d"$LPDEST" -pnoproc -M"$1" -u"$2" | cat - $LPDEST/$FILE | lpsend "$DEST_HOST"' 'eval grep -l $2 $LPDEST/*id | grep -v $LPDEST/${FILE}id > /dev/null 2>&1; case $? in 0) echo "delivered $2 From applemore (vwho)" >> /n/$1/$MAILLOG;; *) echo "delivered $2 From appledone (vwho)" >> /n/$1/$MAILLOG;esac'
+
+
+case "$THIS_HOST" in
+"$DEST_HOST")
+ kill -9 $WARN;;
+esac
diff --git a/sys/lib/lp/daemon/tcppost b/sys/lib/lp/daemon/tcppost
new file mode 100755
index 000000000..fbc41bb09
--- /dev/null
+++ b/sys/lib/lp/daemon/tcppost
@@ -0,0 +1,6 @@
+#!/bin/rc
+# daemon/tcppost
+generic 'aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ <$LPDEST/$FILE(1) |
+ aux/tcpostio -b$SPEED $OUTDEV >[2]$PRINTLOG' \
+ '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} \
+ $LPDEST/$FILE(1); sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/tektronix b/sys/lib/lp/daemon/tektronix
new file mode 100755
index 000000000..53c29be85
--- /dev/null
+++ b/sys/lib/lp/daemon/tektronix
@@ -0,0 +1,3 @@
+#!/bin/rc
+# The destination is set to PS for the Tektronix printer, no other printer cares
+generic 'aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ < $LPDEST/$FILE(1) | aux/lpdsend -dPS -H$LPMACHID -P$LPUSERID $OUTDEV >[2] $PRINTLOG' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/xante b/sys/lib/lp/daemon/xante
new file mode 100755
index 000000000..53c29be85
--- /dev/null
+++ b/sys/lib/lp/daemon/xante
@@ -0,0 +1,3 @@
+#!/bin/rc
+# The destination is set to PS for the Tektronix printer, no other printer cares
+generic 'aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ < $LPDEST/$FILE(1) | aux/lpdsend -dPS -H$LPMACHID -P$LPUSERID $OUTDEV >[2] $PRINTLOG' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/xerox b/sys/lib/lp/daemon/xerox
new file mode 100755
index 000000000..99e11c704
--- /dev/null
+++ b/sys/lib/lp/daemon/xerox
@@ -0,0 +1,3 @@
+#!/bin/rc
+# The destination is set to 'ps' for the Xerox printer
+generic 'aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ < $FILE | aux/lpdsend -dps -H$LPMACHID -P$LPUSERID $OUTDEV >[2] $PRINTLOG' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/xerox-4517 b/sys/lib/lp/daemon/xerox-4517
new file mode 100755
index 000000000..41f57f6a7
--- /dev/null
+++ b/sys/lib/lp/daemon/xerox-4517
@@ -0,0 +1,3 @@
+#!/bin/rc
+# The destination is set to 'ps' for the Xerox printer
+generic 'aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ < $FILE | aux/lpdsend -dPASSTHRU -H$LPMACHID -P$LPUSERID $OUTDEV >[2] $PRINTLOG' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/daemon/xerox-N32 b/sys/lib/lp/daemon/xerox-N32
new file mode 100755
index 000000000..30cc0843e
--- /dev/null
+++ b/sys/lib/lp/daemon/xerox-N32
@@ -0,0 +1,3 @@
+#!/bin/rc
+# The destination is set to 'RAW' for the Xerox N32 printer
+generic 'aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ < $LPDEST/$FILE(1) | aux/lpdsend -dRAW -H$LPMACHID -P$LPUSERID $OUTDEV >[2] $PRINTLOG' '{cat <{echo -d$LPDEST -pnoproc -M$SCHEDLINE(1) -u$SCHEDLINE(2)} $LPDEST/$FILE(1);sleep 5} | lpsend.rc $DEST_HOST' ''
diff --git a/sys/lib/lp/devices b/sys/lib/lp/devices
new file mode 100755
index 000000000..4e5e3e86d
--- /dev/null
+++ b/sys/lib/lp/devices
@@ -0,0 +1,72 @@
+# Here is a sample printer devices file where some of the printers have
+# been commented out.
+#
+# device_name loc dest_host phys_dev_name speed class def_proc spooler stat kill daemon sched
+#
+# HP LaserJet 9050 MFP duplex Postscript 3, PDF 1.3 on Ethernet
+# mh2c548d-1 2c-548d mh2c548-1.mh.lucent.com mh2c548-1.mh.lucent.com - post2+1200dpi+duplex generic lpdspool+fonts lpd generic hp
+# target for PDF files, bypassing Postscript: no -o, -c, -n; doesn't add fonts.
+# +pdf needs +HPJCL for duplex printing.
+# mh2c548d-1-pdf 2c-548d mh2c548-1.mh.lucent.com mh2c548-1.mh.lucent.com - pdf+1200dpi+duplex+HPJCL generic lpdspool lpd generic hp
+# HP LaserJet 5550 duplex Colour
+# mh2c548d-2c 2c-548d mh2c548-2c.mh.lucent.com mh2c548-2c.mh.lucent.com - post+600dpi+duplex+color generic lpdspool+fonts lpd generic hp
+#
+# HP LaserJet 4M connected to serial port on an Annex terminal server.
+# 2c254 2C-254 rice tcp!annex!7035 19200 post+600dpi generic generic generic generic tcppost
+#
+# HP LaserJet 4M connected to Ethernet via a JetDirect card.
+# The speed field is used to set the bufffer size in the tcpostio program run from tcppost.
+# 2c307 2C-307 alice tcp!mh2c307!9100 81920 post+600dpi generic generic generic generic tcppost
+#
+# HP LaserJet 4M connected to serial port on a Cisco terminal server.
+# 2t4 2T-402 pyxis tcp!ts!4010 19200 post+600dpi generic generic generic generic tcppost
+#
+# HP LaserJet 4Si/MX connected to Ethernet via a JetDirect card.
+# This printer has a duplexing option.
+# See /sys/lib/postscript/prologues/hpsimx.ps for a fix to make it default
+# to the large paper tray at postion 1.
+# fn 2C-501 helix tcp!fn!9100 81920 post2+600dpi+duplex generic generic generic generic tcppost
+#
+# Tektronix Phaser 200i connected to Ethernet.
+# Using Xinet K-Talk software from a UNIX host. This software is not recommended.
+# We do not want to waste stock on the color printer so we do not print header pages.
+# peacock 2C-501 cetus peacock - post2+300dpi+nohead+color generic generic generic generic appletalk
+#
+# Any PostScript printer connected to the LPT1 port on my 486 pc running Plan 9 as a terminal.
+pcclone - - /dev/lpt1data - post+nohead generic pcclone - - - -
+#
+# QMS-410 connected to the serial port of an NCD terminal.
+# math34 2T-102 rice tcp!math34!87 9600 post+600dpi generic generic generic generic tcppost
+#
+# QMS-410 connected to the serial port of an AT&T 630/730 terminal
+# ps630 printer-on-630 - - - post+300dpi+nohead generic ps630 - - - -
+#
+# Xante Accel-a-Writer-8200. 1200dpi printer that uses a BSD lpr print daemon protocol
+# psu 2C-501 cetus psu - post+1200dpi generic generic xante generic lpddaemon
+#
+# 'stdout' sends the output to the standard output of the lp command.
+# if the 'phys_dev_name' field is set to a file or device, the output will go to it instead.
+# if '+sendEOT' is added to the 'class' field, an EOT character will be sent at the end of the output.
+#
+stdout - - - - post+nohead generic nospool - - - -
+#
+# sends the output to the standard output of the lp command.
+# used for generating output suitable for 100 dpi.
+100dpi - - - - post+100dpi+nohead generic nospool - - - -
+#
+# same as above for generating output suitable for 300 dpi.
+300dpi - - - - post+300dpi+nohead generic nospool - - - -
+#
+# same as above for generating output suitable for 600 dpi.
+#
+600dpi - - - - post+600dpi+nohead generic nospool - - - -
+#
+# same as above for generating output suitable for Linotronics phototypesetter.
+1270dpi - - - - post+lino+nohead generic nospool - - - -
+
+# 600dpi postscript printer named vogon via BSD LPD printer queue on alice
+vogon printer-room alice vogon - post+600dpi generic lpdspool lpd - -
+
+# HP DeskJet and Canon BJC-240
+hpdeskjet - - /dev/lpt1data - gs!cdj670+nohead generic nospool - - - -
+canonbjc240l - - /dev/lpt1data - gs!bjc600+nohead generic nospool - - - -
diff --git a/sys/lib/lp/kill/generic b/sys/lib/lp/kill/generic
new file mode 100755
index 000000000..e28f268b6
--- /dev/null
+++ b/sys/lib/lp/kill/generic
@@ -0,0 +1,29 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+cd $LPSPOOL
+if (~ $#* 0) KILLARGS=`{sed 1q};
+if not KILLARGS=$*;
+
+if (test -d $LPDEST) {
+ for (i in $KILLARGS) {
+ for (j in `{bind -b $LPLIB/sched /bin;$SCHED $LPDEST}) {
+ if (test -r $LPDEST/$j^id) {
+ STATLINE=`{cat $LPDEST/$j^id}
+ if (~ $STATLINE(1)^$STATLINE(3) $i)
+ if (rm $LPDEST/$j $LPDEST/$j^id >/dev/null >[1=2])
+ echo $i removed from $LPDEST queue on $THIS_HOST
+ }
+ }
+ }
+}
+if (! ~ $THIS_HOST $DEST_HOST) {
+ @{echo -d$LPDEST -k;echo $KILLARGS;sleep 7} | lpsend.rc $DEST_HOST
+}; if not {
+ if (! ~ $KILLCMD '') {
+ for (i in $KILLARGS) {
+ $KILLCMD $i;
+ }
+ }
+}
+exit ''
diff --git a/sys/lib/lp/kill/xerox b/sys/lib/lp/kill/xerox
new file mode 100755
index 000000000..d44dfa634
--- /dev/null
+++ b/sys/lib/lp/kill/xerox
@@ -0,0 +1,5 @@
+#!/bin/rc
+KILL_CMD=/$cputype/bin/aux/lpdsend -d$LPDEST -k
+
+$LPSPOOL/kill/generic $*
+exit
diff --git a/sys/lib/lp/kill/xerox-4512 b/sys/lib/lp/kill/xerox-4512
new file mode 100755
index 000000000..d24eb9409
--- /dev/null
+++ b/sys/lib/lp/kill/xerox-4512
@@ -0,0 +1,6 @@
+#!/bin/rc
+
+cd $LPSPOOL
+KILLCMD=$LPLIB/bin/kill_xerox-4512
+
+exec generic $*
diff --git a/sys/lib/lp/kill/xerox-4517 b/sys/lib/lp/kill/xerox-4517
new file mode 100755
index 000000000..d24eb9409
--- /dev/null
+++ b/sys/lib/lp/kill/xerox-4517
@@ -0,0 +1,6 @@
+#!/bin/rc
+
+cd $LPSPOOL
+KILLCMD=$LPLIB/bin/kill_xerox-4512
+
+exec generic $*
diff --git a/sys/lib/lp/process/dpost b/sys/lib/lp/process/dpost
new file mode 100755
index 000000000..7eda42bb8
--- /dev/null
+++ b/sys/lib/lp/process/dpost
@@ -0,0 +1,82 @@
+#!/bin/rc
+if (~ $DEBUG 1) flag x +
+# convert troff output to PostScript
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature';
+}
+if (! ~ $PATCH '' -P*)
+ PATCH=-P''''$PATCH'''';
+switch ($LAND) {
+case -p*;
+case ''; LAND=-pp
+case 1; LAND=-pl
+}
+if (! ~ $COPIES '' -c*) COPIES=-c^$COPIES
+if (! ~ $MAG '' -m*) MAG=-m^$MAG
+if (! ~ $NPAG '' -n*) NPAG=-n^$NPAG
+if (! ~ $XOFF '' -x*) XOFF=-x^$XOFF
+if (! ~ $YOFF '' -y*) YOFF=-y^$YOFF
+eval /$cputype/bin/aux/dpost -e2 -w0.5 $XOFF $YOFF $COPIES $MAG $NPAG $LAND $OLIST $PATCH | $LPLIB/process/hpost
+exit
diff --git a/sys/lib/lp/process/dvipost b/sys/lib/lp/process/dvipost
new file mode 100755
index 000000000..faa8a036d
--- /dev/null
+++ b/sys/lib/lp/process/dvipost
@@ -0,0 +1,120 @@
+#!/bin/rc
+if (~ $DEBUG 1) flag x +
+# convert Tex dvi to PostScript
+PATCH='%!PS-Adobe-2.0'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ switch ($LPCLASS) {
+ case *post2*;
+ switch ($i) {
+ case 0; PATCH=$PATCH'
+systemdict/languagelevel known {languagelevel 2 eq {true (0) startjob dup not
+{/exitserver errordict/invalidaccess get exec}if}{false}ifelse}{false}ifelse
+{
+ currentpagedevice/InputAttributes get {0 get} stopped
+ {pop pop} {2 dict dup /InputAttributes 1 dict dup
+ /Priority[0] put put dup /TraySwitch false put setpagedevice} ifelse
+ false (0) startjob pop
+} if'
+ case 1; PATCH=$PATCH'
+systemdict/languagelevel known {languagelevel 2 eq {true (0) startjob dup not
+{/exitserver errordict/invalidaccess get exec}if}{false}ifelse}{false}ifelse
+{
+ currentpagedevice/InputAttributes get {1 get} stopped
+ {pop pop} {2 dict dup /InputAttributes 1 dict dup
+ /Priority[1] put put dup /TraySwitch false put setpagedevice} ifelse
+ false (0) startjob pop
+} if'
+ }
+ case *; PATCH=$PATCH'
+statusdict begin $i setpapertray end'
+ }
+ case 11x17 ledger; PATCH=$PATCH'
+statusdict begin '$i'tray end'
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+if (! ~ $#LAND 0 && ~ $LAND 1)
+ LAND='-tlandscape'
+if (~ $LPCLASS *reverse*) {
+ switch ($REVERSE) {
+ case '';
+ REVFLAG=1
+ case 1;
+ REVFLAG=''
+ }
+}
+switch ($LPCLASS) {
+case *post100*;
+ DPI='-Z -D100'
+case *600dpi*;
+ DPI='-Z -D600'
+case *1200dpi*;
+ DPI='-Z -D1200'
+case *;
+ DPI=''
+}
+if (! ~ $COPIES '' -c*) COPIES=-c^$COPIES
+if (! ~ $OLIST '' '='*) OLIST=`{echo $OLIST | sed 's/-o/=/' | sed 's/-/:/g' }
+switch ($REVFLAG) {
+case 1;
+ echo $PATCH
+ switch ($OLIST) {
+ case '';
+ eval dvips -q -f $DPI -r $LAND $COPIES $1
+ case *;
+ DVIFILE=/tmp/dv$pid.dvi
+ dviselect -s $OLIST $1 > $DVIFILE
+ eval dvips -q -f $DPI -r $LAND $COPIES $DVIFILE
+ rm -f $DVIFILE
+ }
+ $LPLIB/process/hpost </dev/null
+case '';
+ $LPLIB/process/hpost </dev/null
+ echo $PATCH
+ switch ($OLIST) {
+ case '';
+ eval dvips -q -f $DPI $LAND $COPIES $1
+ case *;
+ DVIFILE=/tmp/dv$pid.dvi
+ dviselect -s $OLIST $1 > $DVIFILE
+ eval dvips -q -f $DPI $LAND $COPIES $DVIFILE
+ rm -f $DVIFILE
+ }
+}
+exit
diff --git a/sys/lib/lp/process/g3post b/sys/lib/lp/process/g3post
new file mode 100755
index 000000000..baf14ccf3
--- /dev/null
+++ b/sys/lib/lp/process/g3post
@@ -0,0 +1,84 @@
+#!/bin/rc
+# convert CCITT G3 Fax format to PostScript
+if (! ~ $DEBUG '') flag x +
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << '$i' << /MediaType (tray'$i') >> >>
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp'
+if (! ~ $PATCH '' -P*)
+ PATCH=-P$PATCH;
+
+if (~ $MAG '') MAG=1
+if (~ $MAG [.0-9]*) MAG=-m^$MAG^,^`{echo $MAG '*' 2 | hoc}
+
+if (! ~ $LAND '') LAND=-L
+if not LAND=()
+
+/$cputype/bin/aux/g3p9bit |
+ /$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH |
+ $LPLIB/process/hpost
+exit
diff --git a/sys/lib/lp/process/generic b/sys/lib/lp/process/generic
new file mode 100755
index 000000000..0188bc0f4
--- /dev/null
+++ b/sys/lib/lp/process/generic
@@ -0,0 +1,218 @@
+#!/bin/rc
+# Tries to determine what type of file you are printing and do the correct
+# thing with it.
+# It currently knows about images, troff intermediate, and ascii files.
+rfork e
+temp=/tmp/lp$pid
+fn sigexit { rm -f $temp }
+proc=$LPLIB/process
+
+if (! ~ $DEBUG '')
+ flag x +
+cat >$temp
+
+type=`{file $temp}
+switch ($type(2)) {
+case troff
+ switch ($LPCLASS) {
+ case *Latin1* *post* *opost*
+ switch ($type(5)) {
+ # Latin1 is for compatibility with old research UNIX systems,
+ # doesn't work on Plan 9
+ case Latin1 post
+ tcs -s -f utf -t latin1 <$temp | $proc/dpost
+ case UTF
+ $proc/tr2post <$temp
+ }
+ case *gs!* *gsijs!*
+ switch ($type(5)) {
+ # Latin1 is for compatibility with old research UNIX systems,
+ # doesn't work on Plan 9
+ case Latin1 post
+ tcs -s -f utf -t latin1 <$temp | $proc/dpost |
+ $proc/gspipe
+ case UTF
+ $proc/tr2post <$temp | $proc/gspipe
+ }
+ case *
+ echo $type(2) -T$type(5) output is improper for $LPDEST >[1=2]
+ }
+case special
+ switch ($type(4)) {
+ case '#b'
+ switch ($LPCLASS) {
+ case *post*
+ $proc/p9bitpost <$temp
+ case *gs!*
+ $proc/p9bitpost <$temp | $proc/gspipe
+ case *gsijs!*
+ $proc/p9bitpost <$temp | $proc/gspipeijs
+ }
+ case *
+ echo $type file is improper for $LPDEST >[1=2]
+ }
+case Compressed plan old subfont
+ # type is really 'Compressed image' or 'plan 9 image' or
+ # 'old plan 9 image'
+ # 'subfont' is to cope with a bug in png (writing wrong length),
+ # 6 may 2008
+ switch ($LPCLASS) {
+ case *post*
+ $proc/p9bitpost <$temp
+ case *gs!*
+ $proc/p9bitpost <$temp | $proc/gspipe
+ case *gsijs!*
+ $proc/p9bitpost <$temp | $proc/gspipeijs
+ }
+case jpeg
+ switch ($LPCLASS) {
+ case *post*
+ $proc/jpgpost <$temp
+ case *gs!*
+ $proc/jpgpost <$temp | $proc/gspipe
+ case *gsijs!*
+ $proc/jpgpost <$temp | $proc/gspipeijs
+ }
+case GIF
+ switch ($LPCLASS) {
+ case *post*
+ $proc/gifpost <$temp
+ case *gs!*
+ $proc/gifpost <$temp | $proc/gspipe
+ case *gsijs!*
+ $proc/gifpost <$temp | $proc/gspipeijs
+ }
+case PNG
+ switch ($LPCLASS) {
+ case *post*
+ $proc/pngpost <$temp
+ case *gs!*
+ $proc/pngpost <$temp | $proc/gspipe
+ case *gsijs!*
+ $proc/pngpost <$temp | $proc/gspipeijs
+ }
+case ccitt-g31
+ switch ($LPCLASS) {
+ case *post*
+ $proc/g3post <$temp
+ case *gs!*
+ $proc/g3post <$temp | $proc/gspipe
+ case *gsijs!*
+ $proc/g3post <$temp | $proc/gspipeijs
+ }
+case bitmap
+ # bitmap for research UNIX compatibility, does not work on Plan 9.
+ switch ($LPCLASS) {
+ case *post*
+ $proc/bpost <$temp
+ case *mhcc*
+ $proc/bpost <$temp | $proc/mhcc
+ case *
+ echo $type(2) file is improper for $LPDEST >[1=2]
+ }
+case tex
+ mv $temp $temp.dvi
+ temp=$temp.dvi
+ switch ($LPCLASS) {
+ case *post*
+ $proc/dvipost $temp
+ case *gs!*
+ $proc/dvipost $temp | $proc/gspipe
+ case *gsijs!*
+ $proc/dvipost $temp | $proc/gspipeijs
+ case *
+ echo $type(2) file is improper for $LPDEST >[1=2]
+ }
+case postscript
+ switch ($LPCLASS) {
+ case *post*
+ $proc/post <$temp
+ case *gs!*
+ $proc/post <$temp | $proc/gspipe
+ case *gsijs!*
+ $proc/post <$temp | $proc/gspipeijs
+ case *
+ echo $type(2) file is improper for $LPDEST >[1=2]
+ }
+case HPJCL HP
+ switch ($LPCLASS) {
+ case *HPJCL*
+ $proc/noproc <$temp
+ case *
+ echo $type(2) file is improper for $LPDEST >[1=2]
+ }
+case daisy
+ switch ($LPDEST) {
+ case *
+ echo $type(2) file is improper for $LPDEST >[1=2]
+ }
+case tiff
+ switch ($LPCLASS) {
+ case *post*
+ $proc/tiffpost $temp
+ case *gs!*
+ $proc/tiffpost $temp | $proc/gspipe
+ case *gsijs!*
+ $proc/tiffpost $temp | $proc/gspipeijs
+ case *
+ echo Unrecognized class of line printer for $LPDEST >[1=2]
+ }
+case PDF
+ switch ($LPCLASS) {
+ case *pdf*
+# if (~ $LPCLASS *duplex* && ~ $LPCLASS *HPJCL*)
+# echo -n '&l1S' # HP JCL: duplex on
+ if (~ $LPCLASS *duplex* && ~ $LPCLASS *HPJCL*) {
+ echo '%-12345X@PJL DEFAULT DUPLEX=ON' # HP PJL
+ echo '%-12345X'
+ echo '%-12345X@PJL DEFAULT PS:MBT=ON' # `memory boost'
+ echo '%-12345X'
+ }
+ cat $temp # pass pdf unaltered to pdf printer
+ case *post*
+ $proc/pdfpost $temp
+ case *gs!*
+ $proc/pdfgs $temp
+ case *gsijs!*
+ $proc/pdfgsijs $temp
+ case *
+ echo Unrecognized class of line printer for $LPDEST >[1=2]
+ }
+case microsoft # office document
+ switch ($LPCLASS) {
+ case *post*
+ doc2ps $temp | $proc/post
+ case *gs!*
+ doc2ps $temp | $proc/post | $proc/gspipe
+ case *gsijs!*
+ doc2ps $temp | $proc/post | $proc/gspipeijs
+ case *
+ echo $type(2) file is improper for $LPDEST >[1=2]
+ }
+case empty
+ echo file is empty >[1=2]
+case cannot
+ echo cannot open file >[1=2]
+case English short extended alef limbo [Aa]scii assembler c latin rc sh \
+ as mail email message/rfc822 manual HTML
+ switch ($LPCLASS) {
+ case *post*
+ $proc/ppost <$temp
+ case *gs!*
+ $proc/ppost <$temp | $proc/gspipe
+ case *gsijs!*
+ $proc/ppost <$temp | $proc/gspipeijs
+ case *canon*
+ $proc/can $* <$temp
+ case *
+ echo Unrecognized class of line printer for $LPDEST >[1=2]
+ }
+case *
+ echo $type(2) file is improper for $LPDEST >[1=2]
+}
+
+wait
+rv=$status
+rm -f $temp
+# exit $rv
+exit
diff --git a/sys/lib/lp/process/gifpost b/sys/lib/lp/process/gifpost
new file mode 100755
index 000000000..f5069d5ed
--- /dev/null
+++ b/sys/lib/lp/process/gifpost
@@ -0,0 +1,84 @@
+#!/bin/rc
+# convert GIF format to PostScript
+if (! ~ $DEBUG '') flag x +
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << '$i' << /MediaType (tray'$i') >> >>
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp'
+if (! ~ $PATCH '' -P*)
+ PATCH=-P$PATCH;
+
+if (~ $MAG '') MAG=1
+if (~ $MAG [.0-9]*) MAG=-m^$MAG
+
+if (! ~ $LAND '') LAND=-L
+if not LAND=()
+
+/$cputype/bin/gif -t |
+ /$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH |
+ $LPLIB/process/hpost
+exit
diff --git a/sys/lib/lp/process/gspipe b/sys/lib/lp/process/gspipe
new file mode 100755
index 000000000..d0b909408
--- /dev/null
+++ b/sys/lib/lp/process/gspipe
@@ -0,0 +1,24 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+# usage: gspipe [dev]
+# assumes postscript on stdin
+
+switch($#*) {
+case 0
+ GSDEVICE=`{echo $LPCLASS | sed 's/(.*\+)?gs!([^+]*)(\+.*)?/\2/'}
+case 1
+ GSDEVICE=$1
+case *
+ echo 'usage: gspipe [dev]' >[1=2]
+ exit gspipe
+}
+
+GSTMPFILE=/tmp/gsp^$pid
+GSOPT=('-sDEVICE='^$GSDEVICE '-sOUTPUTFILE='$GSTMPFILE -dSAFER -dNOPAUSE -dQUIET -dBATCH)
+
+gs $GSOPT - >/dev/null
+
+cat $GSTMPFILE
+rm -f $GSTMPFILE
+exit ''
diff --git a/sys/lib/lp/process/gspipeijs b/sys/lib/lp/process/gspipeijs
new file mode 100755
index 000000000..b7cf158ad
--- /dev/null
+++ b/sys/lib/lp/process/gspipeijs
@@ -0,0 +1,35 @@
+#!/bin/rc
+# extended to IJS driver by K.Okamoto
+# duble-sided printing for PSC 2550 printer
+#
+if (! ~ $DEBUG '') flag x +
+
+# usage: gspipeijs [dev]
+# assumes postscript on stdin
+
+switch($#*) {
+case 0
+ MODEL=`{echo $LPCLASS | sed 's/(.*\+)?gsijs!([^+]*)(\+.*)?/\2/'}
+ NUMBER=`{echo $LPCLASS | sed 's/(.*\+)?gsijs!([^+]*)\+(.*)?/\3/'}
+case 1
+ IJS=$1
+case *
+ echo 'usage: gspipeijs [dev]' >[1=2]
+ exit gspipeijs
+}
+
+GSTMPFILE=/tmp/gsp$pid
+
+switch($NUMBER) {
+case 2100
+ GSOPT=(-q -sDEVICE'='ijs -sIjsServer'='hpijs -sDeviceManufacturer'='HP '-sDeviceModel='"$MODEL^' '^$NUMBER" -r600 -sOutputFile'='^$GSTMPFILE -sPAPERSIZE'='a4 -dIjsUseOutputFD -dSAFER -dNOPAUSE -DBATCH)
+case 2500
+ GSOPT=(-q -sDEVICE'='ijs -sIjsServer'='hpijs -sDeviceManufacturer'='HP '-sDeviceModel='"$MODEL^' '^$NUMBER" -r600 -sOutputFile'='^$GSTMPFILE -dDuplex'='true -sPAPERSIZE'='a4 -dIjsUseOutputFD -dSAFER -dNOPAUSE -DBATCH)
+}
+
+gs $GSOPT -
+
+cat $GSTMPFILE
+rm $GSTMPFILE
+
+exit
diff --git a/sys/lib/lp/process/hpost b/sys/lib/lp/process/hpost
new file mode 100755
index 000000000..21a52b36c
--- /dev/null
+++ b/sys/lib/lp/process/hpost
@@ -0,0 +1,148 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+REVFLAG=''
+if (~ $LPCLASS *reverse*) {
+ switch ($REVERSE) {
+ case '';
+ REVFLAG=1
+ case 1;
+ REVFLAG=''
+ }
+}
+if (! ~ $REVFLAG '')
+ postreverse
+
+if (~ $NOHEAD '') {
+ DATE=`{date}
+ face='FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
+ facedom=`{awk '{ if(match("'$LPMACHID'", $1)) {print $2; exit}}' /lib/face/.machinelist}
+ if (~ $#facedom 0) facedom=$LPMACHID
+
+ facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' /lib/face/48x48x8/.dict}
+ facedepth=8
+
+ if (~ $#facefile 0) {
+ facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' /lib/face/48x48x4/.dict}
+ facedepth=4
+ }
+ if (~ $#facefile 0) {
+ facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' /lib/face/48x48x2/.dict}
+ facedepth=2
+ }
+
+ if (~ $#facefile 0) {
+ facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' /lib/face/48x48x1/.dict}
+ facedepth=1
+ }
+
+ if (~ $#facefile 0) {facefile=u/unknown.1; facedepth=1}
+ facefile=/lib/face/48x48x$facedepth/$facefile
+
+ if (! ~ $#facefile 0 1)
+ facefile=$facefile(1)
+
+ if (~ $#facefile 0 || ! test -f $facefile ) {facefile=/lib/face/48x48x2/u/unknown.1; facedepth=2}
+ if (test -r $facefile ) {
+ switch($facedepth){
+ case 1 2
+ face=`{cat $facefile |
+ sed -e 's/0x//g' -e 's/, *//g' |
+ tr 0123456789abcdef fedcba9876543210 };
+ case 4 8
+ face=`{iconv -u -c k4 $facefile |
+ dd -bs 60 -skip 1 >[2]/dev/null |
+ xd -b | sed 's/^[^ ]+ //;s/ //g' }
+ facedepth=8
+ }
+ }
+}
+
+# We have to make sure the face information is set before rc sees the HERE file
+# so the cat has to be in a separate if statement. This is an rc bug.
+if (~ $NOHEAD '') cat <<EOF
+%!PS-Adobe-2.0 div 112 page header - research!pg
+/banner {
+ /saveobj save def
+ erasepage initgraphics
+ /#copies 1 def
+ /inch {72 mul} bind def
+ /pageborder {
+ 25 747 moveto
+ 590 747 lineto
+ 590 25 lineto
+ 25 25 lineto
+ closepath
+ 2 setlinewidth
+ 0 setgray
+ stroke
+ } def
+
+ /topborder {
+ 25 773 moveto
+ 590 773 lineto
+ 590 747 lineto
+ 25 747 lineto
+ closepath
+ 2 setlinewidth
+ 0 setgray
+ stroke
+ } def
+
+ /toptext {
+ 120 756 moveto
+ /Courier-Bold findfont 14 scalefont setfont
+ ($LPUSERID $DATE) show
+ } def
+
+ /prface {
+ gsave
+ translate rotate scale
+ setgray
+ 48 48 $facedepth [48 0 0 -48 0 48] {<$face>} image
+ grestore
+ } def
+EOF
+if (~ $NOHEAD '') switch ($LPCLASS) {
+case *hp4simx*;
+ echo '
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+if (~ $NOHEAD '') cat <<EOF
+ statusdict /setduplexmode known {statusdict begin false setduplexmode end} if
+ statusdict begin /manualfeed false def end
+ pageborder
+ topborder
+ toptext
+ 0 14 14 0 94 752 prface
+ .3 180 180 -90 3.0 inch 10.2 inch prface
+ showpage
+ saveobj
+ restore
+} bind def
+banner
+EOF
+
+if (~ $REVFLAG '') cat
+exit ''
diff --git a/sys/lib/lp/process/jpgpost b/sys/lib/lp/process/jpgpost
new file mode 100755
index 000000000..f05aa9e94
--- /dev/null
+++ b/sys/lib/lp/process/jpgpost
@@ -0,0 +1,84 @@
+#!/bin/rc
+# convert JPG to PostScript
+if (! ~ $DEBUG '') flag x +
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << '$i' << /MediaType (tray'$i') >> >>
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp'
+if (! ~ $PATCH '' -P*)
+ PATCH=-P$PATCH;
+
+if (~ $MAG '') MAG=1
+if (~ $MAG [.0-9]*) MAG=-m^$MAG
+
+if (! ~ $LAND '') LAND=-L
+if not LAND=()
+
+/$cputype/bin/jpg -t9 |
+ /$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH -p 32 26.17 |
+ $LPLIB/process/hpost
+exit
diff --git a/sys/lib/lp/process/noproc b/sys/lib/lp/process/noproc
new file mode 100755
index 000000000..3b98aaa18
--- /dev/null
+++ b/sys/lib/lp/process/noproc
@@ -0,0 +1,3 @@
+#!/bin/rc
+# No processing, copy file from input to output
+cat
diff --git a/sys/lib/lp/process/p9bitpost b/sys/lib/lp/process/p9bitpost
new file mode 100755
index 000000000..460e60e7c
--- /dev/null
+++ b/sys/lib/lp/process/p9bitpost
@@ -0,0 +1,83 @@
+#!/bin/rc
+# convert plan 9 image to PostScript
+if (~ $DEBUG 1) flag x +
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << '$i' << /MediaType (tray'$i') >> >>
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp'
+if (! ~ $PATCH '' -P*)
+ PATCH=-P$PATCH;
+if (! ~ $LAND '') LAND=-L
+if not LAND=()
+# if (! ~ $COPIES '' -c*) COPIES=-c^$COPIES
+if (! ~ $MAG '') MAG=-m^$MAG
+if (~ $MAG '') MAG=()
+# if (! ~ $NPAG '' -n*) NPAG=-n^$NPAG
+# if (! ~ $XOFF '' -x*) XOFF=-x^$XOFF
+# if (! ~ $YOFF '' -y*) YOFF=-y^$YOFF
+/$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH | $LPLIB/process/hpost
+exit
diff --git a/sys/lib/lp/process/pdfgs b/sys/lib/lp/process/pdfgs
new file mode 100755
index 000000000..42a213aeb
--- /dev/null
+++ b/sys/lib/lp/process/pdfgs
@@ -0,0 +1,71 @@
+#!/bin/rc
+# pdfgs pdffile [gsdev] - generate PS from PDF
+#
+# we don't go through postscript, because to
+# get to postscript, we send the pdf through gs!
+# much easier to just go directly.
+
+switch($#*) {
+case 2
+ GSDEVICE=$2
+case 1
+ GSDEVICE=`{echo $LPCLASS | sed 's/(.*\+)?gs!([^+]*)(\+.*)?/\2/'}
+case *
+ echo 'usage: pdfgs pdffile [gsdev]' >[1=2]
+ exit usage
+}
+
+GSTMPFILE=/tmp/pdf^$pid
+GSOPT=('-sDEVICE='$GSDEVICE '-sOutputFile='^$GSTMPFILE -dSAFER -dNOPAUSE \
+ -dQUIET -dBATCH -dNOPAUSE)
+
+# ps level 1 is extremely verbose and tends to run our
+# printers out of memory when printing images.
+if(~ $GSDEVICE pswrite && ~ $LPCLASS *post2*)
+ GSOPT=($GSOPT '-dLanguageLevel=2')
+if not if(~ $GSDEVICE pswrite)
+ GSOPT=($GSOPT '-dLanguageLevel=1')
+
+if(~ $OLIST '')
+ gs $GSOPT $1
+if not {
+ PGLIST=`{echo $OLIST | sed 's/-o//;s/,/ /g;s/ / /g' | tr -cd '0-9 -'}
+ GSPGLIST=()
+ for(i in $PGLIST){
+ switch($i){
+ case -*
+ GSPGLIST=($GSPGLIST `{seq 1 `{echo $i|tr -d '-'}})
+ case *-
+ # BUG assume 100 >= number of pages
+ GSPGLIST=($GSPGLIST `{seq `{echo $i|tr -d '-'} 100})
+ case *-*
+ GSPGLIST=($GSPGLIST `{seq `{echo $i|tr '-' ' '}})
+ case *
+ GSPGLIST=($GSPGLIST $i)
+ }
+ }
+ GSPGLIST=$"GSPGLIST
+ echo '
+ /Page null def
+ /Page# 0 def
+ /PDFSave null def
+ /DSCPageCount 0 def
+ /DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage} def
+ GS_PDF_ProcSet begin
+ pdfdict begin
+ ('^$1^') (r) file pdfopen begin
+ /npage pdfpagecount def
+ ['^$GSPGLIST^']
+ {
+ dup dup
+ 1 ge exch npage le and
+ { DoPDFPage }
+ { pop }
+ ifelse
+ } forall
+ ' | gs $GSOPT - >/dev/null >[2=1]
+}
+
+cat $GSTMPFILE
+rm -f $GSTMPFILE
+exit ''
diff --git a/sys/lib/lp/process/pdfgsijs b/sys/lib/lp/process/pdfgsijs
new file mode 100755
index 000000000..7f3554a0f
--- /dev/null
+++ b/sys/lib/lp/process/pdfgsijs
@@ -0,0 +1,63 @@
+#!/bin/rc
+
+# usage: pdfgsijs pdffile
+
+gs -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE=pswrite' -d'LanguageLevel=2' -s'OutputFile=/tmp/pdf2ps.ps' $1
+
+MODEL=`{echo $LPCLASS | sed 's/(.*\+)?gsijs!([^+]*)(\+.*)?/\2/'}
+NUMBER=`{echo $LPCLASS | sed 's/(.*\+)?gsijs!([^+]*)\+(.*)?/\3/'}
+
+GSTMPFILE=/tmp/pdf^$pid
+
+switch($NUMBER) {
+case 2100
+ GSOPT=(-q -sDEVICE'='ijs -sIjsServer'='hpijs -sDeviceManufacturer'='HP '-sDeviceModel='"$MODEL^' '^$NUMBER" -r600 -sOutputFile'='^$GSTMPFILE -sPAPERSIZE'='a4 -dIjsUseOutputFD -dSAFER -dNOPAUSE -dBATCH)
+case 2500
+ GSOPT=(-q -sDEVICE'='ijs -sIjsServer'='hpijs -sDeviceManufacturer'='HP '-sDeviceModel='"$MODEL^' '^$NUMBER" -r600 -sOutputFile'='^$GSTMPFILE -dDuplex'='true -sPAPERSIZE'='a4 -dIjsUseOutputFD -dSAFER -dNOPAUSE -DBATCH)
+}
+
+
+if(~ $OLIST '')
+ gs $GSOPT /tmp/pdf2ps.ps
+if not {
+ PGLIST=`{echo $OLIST | sed 's/-o//;s/,/ /g;s/ / /g' | tr -cd '0-9 -'}
+ GSPGLIST=()
+ for(i in $PGLIST){
+ switch($i){
+ case -*
+ GSPGLIST=($GSPGLIST `{seq 1 `{echo $i|tr -d '-'}})
+ case *-
+ # BUG assume 100 >= number of pages
+ GSPGLIST=($GSPGLIST `{seq `{echo $i|tr -d '-'} 100})
+ case *-*
+ GSPGLIST=($GSPGLIST `{seq `{echo $i|tr '-' ' '}})
+ case *
+ GSPGLIST=($GSPGLIST $i)
+ }
+ }
+ GSPGLIST=$"GSPGLIST
+ echo '
+ /Page null def
+ /Page# 0 def
+ /PDFSave null def
+ /DSCPageCount 0 def
+ /DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage} def
+ GS_PDF_ProcSet begin
+ pdfdict begin
+ ('^$1^') (r) file pdfopen begin
+ /npage pdfpagecount def
+ ['^$GSPGLIST^']
+ {
+ dup dup
+ 1 ge exch npage le and
+ { DoPDFPage }
+ { pop }
+ ifelse
+ } forall
+ ' | gs $GSOPT - >/dev/null >[2=1]
+}
+
+cat $GSTMPFILE
+rm -f $GSTMPFILE
+rm -f /tmp/pdf2ps.ps
+exit ''
diff --git a/sys/lib/lp/process/pdfpost b/sys/lib/lp/process/pdfpost
new file mode 100755
index 000000000..af924e492
--- /dev/null
+++ b/sys/lib/lp/process/pdfpost
@@ -0,0 +1,76 @@
+#!/bin/rc
+# convert PDF output to PostScript
+if (! ~ $DEBUG '') flag x +
+PATCH='%!PS
+%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp
+'
+echo $PATCH
+
+pdfgs $1 pswrite | $LPLIB/process/hpost
+exit ''
diff --git a/sys/lib/lp/process/pngpost b/sys/lib/lp/process/pngpost
new file mode 100755
index 000000000..cdbe9aaf8
--- /dev/null
+++ b/sys/lib/lp/process/pngpost
@@ -0,0 +1,84 @@
+#!/bin/rc
+# convert PNG format to PostScript
+if (! ~ $DEBUG '') flag x +
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << '$i' << /MediaType (tray'$i') >> >>
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp'
+if (! ~ $PATCH '' -P*)
+ PATCH=-P$PATCH;
+
+if (~ $MAG '') MAG=1
+if (~ $MAG [.0-9]*) MAG=-m^$MAG
+
+if (! ~ $LAND '') LAND=-L
+if not LAND=()
+
+/$cputype/bin/png -9t |
+ /$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH |
+ $LPLIB/process/hpost
+exit
diff --git a/sys/lib/lp/process/post b/sys/lib/lp/process/post
new file mode 100755
index 000000000..26510ef72
--- /dev/null
+++ b/sys/lib/lp/process/post
@@ -0,0 +1,68 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+PATCH='%!PS
+%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << '$i' << /MediaType (tray'$i') >> >>
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' ignored >[1=2]
+ }
+}
+#if (! ~ $#DUPLEX 0) {
+# if (~ $DUPLEX 1 )
+# PATCH=$PATCH'
+#statusdict /setduplexmode known {statusdict begin true setduplexmode end} if';
+# if (~ $DUPLEX 0 )
+# PATCH=$PATCH'
+#statusdict /setduplexmode known {statusdict begin false setduplexmode end} if';
+#}
+PATCH=$PATCH'
+%%EndPatch from lp
+'
+
+{ echo $PATCH; psextract } | $LPLIB/process/hpost
+
diff --git a/sys/lib/lp/process/ppost b/sys/lib/lp/process/ppost
new file mode 100755
index 000000000..25af23ace
--- /dev/null
+++ b/sys/lib/lp/process/ppost
@@ -0,0 +1,99 @@
+#!/bin/rc
+# converts a regular text file to PostScript
+if (! ~ $DEBUG '') flag x +
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << '$i' << /MediaType (tray'$i') >> >>
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp
+'
+if (! ~ $PATCH '' -P*)
+ PATCH=-P''''$PATCH'''';
+switch ($LAND) {
+case -p*;
+case ''; LAND=-pp
+case 1; LAND=-pl
+}
+if (! ~ $COPIES '' -c*) COPIES=-c^$COPIES
+switch ($FONT) {
+case ''; FONT=-f'Courier'
+case -f*;
+case *; FONT=-f$FONT
+}
+switch ($POINT) {
+case ''; POINT=-s10
+case -s*;
+case *; POINT=-s$POINT
+}
+if (! ~ $LINES '' -l*) LINES=-l^$LINES;
+if (! ~ $MAG '' -m*) MAG=-m^$MAG;
+if (! ~ $NPAG '' -n*) NPAG=-n^$NPAG;
+if (! ~ $XOFF '' -x*) XOFF=-x`{echo $XOFF + .4|hoc};
+if not XOFF=-x.4
+if (! ~ $YOFF '' -y*) YOFF=-y^$YOFF;
+eval /$cputype/bin/aux/text2post $FONT $XOFF $YOFF $COPIES $LINES $MAG $NPAG $POINT $LAND $OLIST $PATCH | $LPLIB/process/hpost
+# eval /$cputype/bin/aux/postprint -EUTF $FONT $XOFF $YOFF $COPIES $LINES $MAG $NPAG $POINT $LAND $OLIST $PATCH | $LPLIB/process/hpost
+exit
diff --git a/sys/lib/lp/process/psextract b/sys/lib/lp/process/psextract
new file mode 100755
index 000000000..ba7804bd1
--- /dev/null
+++ b/sys/lib/lp/process/psextract
@@ -0,0 +1,60 @@
+#!/bin/rc
+
+# extract pages $OLIST from postscript on stdin
+
+if(~ $OLIST '')
+ exec cat
+
+awk '
+BEGIN {
+ x=ENVIRON["OLIST"];
+ gsub(/^-o/, "", x);
+ na = split(x, a, ",");
+ header = 1;
+ goodpage = 0;
+}
+
+header || goodpage {
+ print
+}
+
+/^%%EndSetup[ ]*$/ { header = 0; next }
+
+/^%%Page:/ {
+ header = 0;
+ p=$2+0;
+ goodpage = 0;
+ for(i=1; i<=na; i++){
+ if(aa=match(a[i], "-")){
+ low=substr(a[i], 1, RSTART);
+ high=substr(a[i], RSTART+RLENGTH);
+ if(low == "")
+ low = 0;
+ else
+ low = low+0;
+ if(high == "")
+ high = 100000;
+ else
+ high = high+0;
+ if(low <= p && p <= high){
+ goodpage = 1;
+ break;
+ }
+ }else{
+ if(a[i] == p){
+ goodpage = 1;
+ break;
+ }
+ }
+ }
+}
+
+/^%%EndPage[ ]*$/ {
+ goodpage = 0;
+}
+
+/^%%Trailer[ ]*$/ {
+ goodpage = 1;
+}
+
+'
diff --git a/sys/lib/lp/process/testpost b/sys/lib/lp/process/testpost
new file mode 100755
index 000000000..5bfd43c94
--- /dev/null
+++ b/sys/lib/lp/process/testpost
@@ -0,0 +1,74 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputSlot
+[{
+ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ (<<) cvx exec
+ /ManualFeed true
+ (>>) cvx exec setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+} stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputSlot
+[{
+ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << '$i' << /MediaType (tray'$i') >> >>
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+} stopped cleartomark
+%%EndFeature'
+ case 11x17 ledger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputMedia
+[{
+ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ (<<) cvx exec
+ /MediaType '$i'
+ (>>) cvx exec setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+} stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' ignored >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp
+'
+
+echo $PATCH; cat
diff --git a/sys/lib/lp/process/tiffpost b/sys/lib/lp/process/tiffpost
new file mode 100755
index 000000000..85c032912
--- /dev/null
+++ b/sys/lib/lp/process/tiffpost
@@ -0,0 +1,85 @@
+#!/bin/rc
+# convert TIFF format to PostScript
+if (! ~ $DEBUG '') flag x +
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << '$i' << /MediaType (tray'$i') >> >>
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp'
+if (! ~ $PATCH '' -P*)
+ PATCH=-P$PATCH;
+
+if (~ $MAG '') MAG=1
+if (~ $MAG [.0-9]*) MAG=-m^$MAG
+
+if (! ~ $LAND '') LAND=-L
+if not LAND=()
+
+fb/tiff2pic $1 |
+ fb/3to1 rgbv |
+ fb/pcp -tplan9 |
+ /$cputype/bin/aux/p9bitpost $MAG $LAND $PATCH |
+ $LPLIB/process/hpost
diff --git a/sys/lib/lp/process/tr2post b/sys/lib/lp/process/tr2post
new file mode 100755
index 000000000..2d41cec3e
--- /dev/null
+++ b/sys/lib/lp/process/tr2post
@@ -0,0 +1,86 @@
+#!/bin/rc
+if (~ $DEBUG 1) flag x +
+# convert troff output to PostScript
+PATCH='%%Patch from lp'
+switch ($LPCLASS) {
+case *hp4simx*;
+ PATCH=$PATCH'
+%% set the default papertray to be the lower tray for HP4siMX printers
+ statusdict begin defaultpapertray end 1 ne {
+ statusdict begin
+ 1 setdefaultpapertray
+ end
+ } if'
+}
+for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
+ switch ($i) {
+ case -P*;
+ case man manual manualfeed;
+ PATCH=$PATCH'
+%%BeginFeature: *Select ManualFeed
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /ManualFeed true >> setpagedevice
+ } {statusdict begin /manualfeed true def end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case simplex;
+ DUPLEX=0
+ case [0-9];
+ PATCH=$PATCH'
+%%BeginFeature: *Select InputTray
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << '$i' << /MediaType (tray'$i') >> >>
+ << /MediaType (tray'$i') >> setpagedevice
+ } {statusdict begin '$i' setpapertray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case 11x17 [Ll]edger;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Ledger
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /PageSize [792 1224] >> setpagedevice
+ } {statusdict begin '$i'tray end} ifelse
+ } stopped cleartomark
+%%EndFeature'
+ case transparency vg viewgraph;
+ PATCH=$PATCH'
+%%BeginFeature: *Select Transparency
+[{ << /MediaType (Transparency) >> setpagedevice
+ } stopped cleartomark
+%%EndFeature'
+ case *;
+ echo illegal option ''''-i $i'''' >[1=2]
+ }
+}
+if (! ~ $#DUPLEX 0) {
+ switch ($DUPLEX) {
+ case 0;
+ DUPLEX=false
+ case 1;
+ DUPLEX=true
+ }
+ PATCH=$PATCH'
+%%BeginFeature: *Set DuplexMode
+[{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
+ << /Duplex '$DUPLEX' >> setpagedevice
+ } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
+ } stopped cleartomark
+%%EndFeature'
+}
+PATCH=$PATCH'
+%%EndPatch from lp
+'
+if (! ~ $PATCH '' -P*)
+ PATCH=-P''''$PATCH'''';
+switch ($LAND) {
+case -p*;
+case ''; LAND=-pp
+case 1; LAND=-pl
+}
+if (! ~ $COPIES '' -c*) COPIES=-c^$COPIES
+if (! ~ $MAG '' -m*) MAG=-m^$MAG
+if (! ~ $NPAG '' -n*) NPAG=-n^$NPAG
+if (! ~ $XOFF '' -x*) XOFF=-x^$XOFF
+if (! ~ $YOFF '' -y*) YOFF=-y^$YOFF
+eval /$cputype/bin/aux/tr2post $XOFF $YOFF $COPIES $MAG $NPAG $LAND $OLIST $PATCH | $LPLIB/process/hpost
+exit
diff --git a/sys/lib/lp/sched/FIFO b/sys/lib/lp/sched/FIFO
new file mode 100755
index 000000000..b700e1bc4
--- /dev/null
+++ b/sys/lib/lp/sched/FIFO
@@ -0,0 +1,2 @@
+#!/bin/rc
+ls -ptr $* | sed -n -e '/^[0-9][0-9]*\.[1-9][0-9]*$/p'
diff --git a/sys/lib/lp/spooler/generic b/sys/lib/lp/spooler/generic
new file mode 100755
index 000000000..d6487f7de
--- /dev/null
+++ b/sys/lib/lp/spooler/generic
@@ -0,0 +1,47 @@
+#!/bin/rc
+# fn sigexit { rm -f $LPSPOOL/$LPDEST/.$pid.* $LPSPOOL/$LPDEST/$pid.* $LPSPOOL/$LPDEST }
+if (! ~ $DEBUG '') flag x +
+
+if (~ $THIS_HOST $DEST_HOST) {
+ if (! test -d $LPSPOOL/$LPDEST) {
+ mkdir $LPSPOOL/$LPDEST
+ chmod 777 $LPSPOOL/$LPDEST >[2]/dev/null
+ }
+}
+# Process and enqueue files to be printed
+# take arguments as input files
+i=0
+if (~ $#* 0) *=''
+for (j in $*) {
+ i= `{echo $i + 1|hoc}
+
+# check access to the file so that you know that a failure in the
+# processing is a drastic error which will cause an exit from lp.
+
+ if (~ $j '' || test -f $j) {
+ if (~ $THIS_HOST $DEST_HOST) {
+ echo $LPMACHID $LPUSERID $pid.$i 0 > $LPSPOOL/$LPDEST/.$pid.$i^id
+ if (~ $j '') @{bind -b $LPLIB/process /bin; $LPPROC} >$LPSPOOL/$LPDEST/.$pid.$i
+ if not @{bind -b $LPLIB/process /bin; $LPPROC} <$j >$LPSPOOL/$LPDEST/.$pid.$i
+ if (~ $status '') {
+ mv $LPSPOOL/$LPDEST/.$pid.$i $LPSPOOL/$LPDEST/$pid.$i
+ mv $LPSPOOL/$LPDEST/.$pid.$i^id $LPSPOOL/$LPDEST/$pid.$i^id
+ }
+ if not {
+ rval='preprocessing failed'
+ rm -f $LPSPOOL/$LPDEST/.$pid.$i $LPSPOOL/queue/$LPDEST/.$pid.$i^id
+ exit $rval
+ }
+ }
+ if not {
+ switch ($j) {
+ case ''; @{ {echo -d^$LPDEST -pnoproc -M^$LPMACHID -u^$LPUSERID; bind -b $LPLIB/process /bin; $LPPROC} | lpsend.rc $DEST_HOST}
+ case *; @{ {echo -d^$LPDEST -pnoproc -M^$LPMACHID -u^$LPUSERID; bind -b $LPLIB/process /bin; $LPPROC} < $j | lpsend.rc $DEST_HOST}
+ }
+ rval=$status
+ }
+ }
+ if not {
+ echo $j cannot be opened >[1=2]
+ }
+}
diff --git a/sys/lib/lp/spooler/lpdspool b/sys/lib/lp/spooler/lpdspool
new file mode 100755
index 000000000..cf8ad8c89
--- /dev/null
+++ b/sys/lib/lp/spooler/lpdspool
@@ -0,0 +1,14 @@
+#!/bin/rc
+
+if (! ~ $DEBUG '') flag x +
+
+if (~ $#* 0) *='/fd/0'
+
+for (j in $*) {
+ if (~ $j '/fd/0' || test -f $j) {
+ @{bind -b $LPLIB/process /bin; $LPPROC} < $j | /$cputype/bin/aux/lpdsend -d$OUTDEV -tf -H$LPMACHID -P$LPUSERID $DEST_HOST >[2]$LPLOGDIR/$LPDEST^.st
+ }
+ if not {
+ echo $j cannot be opened >[1=2]
+ }
+}
diff --git a/sys/lib/lp/spooler/lpdspool+fonts b/sys/lib/lp/spooler/lpdspool+fonts
new file mode 100755
index 000000000..a10a5824c
--- /dev/null
+++ b/sys/lib/lp/spooler/lpdspool+fonts
@@ -0,0 +1,16 @@
+#!/bin/rc
+
+if (! ~ $DEBUG '') flag x +
+
+if (~ $#* 0) *='/fd/0'
+
+for (j in $*) {
+ if (~ $j '/fd/0' || test -f $j) {
+ @{bind -b $LPLIB/process /bin; $LPPROC} < $j |
+ aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ |
+ /$cputype/bin/aux/lpdsend -d$OUTDEV -tf -H$LPMACHID -P$LPUSERID $DEST_HOST >[2]$LPLOGDIR/$LPDEST^.st
+ }
+ if not {
+ echo $j cannot be opened >[1=2]
+ }
+}
diff --git a/sys/lib/lp/spooler/mhcc b/sys/lib/lp/spooler/mhcc
new file mode 100755
index 000000000..6f68709af
--- /dev/null
+++ b/sys/lib/lp/spooler/mhcc
@@ -0,0 +1,52 @@
+#!/bin/rc
+# send PostScript jobs to the spooler in the MHCC
+# Request is made for bin and account numbers for each file (for typing pool).
+
+if (! ~ $DEBUG '') flag x +
+FONTLIST=lw+
+if (test -r /sys/lib/postscript/font/$LPDEST) FONTLIST=$LPDEST
+
+switch ($LPCLASS) {
+case *duplex*; DUPLEX=-s2
+case ''; DUPLEX=''
+}
+HOLE=''
+STAPLE='-KSTAPLES\ n'
+TRAY=''
+
+if (~ $IBIN vg view viewgr*;) $VGS=-fvg
+if (~ $IBIN *hole*) HOLE=-fhole
+if (~ $IBIN *staple*) STAPLE=''
+if (~ $IBIN *simplex*) DUPLEX=''
+if (~ $IBIN *11x17* *ledger*) TRAY='-KTRAY\ 11x17tray'
+
+if (~ $LAND '' -pport) LAND=-pport
+if not LAND=-pland
+i=0
+if (~ $#* 0) *=''
+for (j) {
+ i=`{echo $i + 1 | hoc}
+# check access to the file so that you know that a failure in the
+# processing is a drastic error which will cause an exit from lp.
+
+ if (~ $j '' || test -f $j) {
+ while (~ $#ACCOUNT 0 || ~ $ACCOUNT '' *0000) {
+ echo -n 'account=' >/dev/cons
+ ACCOUNT = (`{read</dev/cons})
+ }
+ while (~ $#BIN 0 || ~ $BIN '' *000) {
+ echo -n 'bin=' >/dev/cons
+ BIN = (`{read</dev/cons})
+ }
+ switch ($j) {
+ case ''; @{ bind -b $LPLIB/process /bin; $LPPROC } |
+ /sys/lib/postscript/bin/$cputype/download -f -H/sys/lib/postscript/font -mfontmap -p$FONTLIST |
+ {echo -K'ACCTNUM\ '$ACCOUNT -K'BIN\ '$BIN -d$LPDEST -c$COPIES -lpostscript $VGS $HOLE $STAPLE $DUPLEX $LAND $TRAY -u$LPUSERID -j$LPMACHID$pid.$i
+ cat} | lpsend.rc $DEST_HOST
+ case *; @{ bind -b $LPLIB/process /bin; $LPPROC } < $j |
+ /sys/lib/postscript/bin/$cputype/download -f -H/sys/lib/postscript/font -mfontmap -p$FONTLIST |
+ {echo -K'ACCTNUM\ '$ACCOUNT -K'BIN\ '$BIN -d$LPDEST -c$COPIES -lpostscript $VGS $HOLE $STAPLE $DUPLEX $LAND $TRAY -u$LPUSERID -j$LPMACHID$pid.$i
+ cat $j} | lpsend.rc $DEST_HOST
+ }
+ }
+}
diff --git a/sys/lib/lp/spooler/nospool b/sys/lib/lp/spooler/nospool
new file mode 100755
index 000000000..820e474e9
--- /dev/null
+++ b/sys/lib/lp/spooler/nospool
@@ -0,0 +1,21 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+if (~ $LPCLASS *sendEOT*) SENDEOT=1
+if not SENDEOT=0
+
+if (~ $OUTDEV -) OUTDEV=/fd/1
+if (~ $#* 0) {
+ if (! ~ $DEBUG '') echo input file is stdin >[1=2]
+ @{bind -b $LPLIB/process /bin; $LPPROC} > $OUTDEV
+ if (~ $SENDEOT 1) echo -n `{ascii -t 4} > $OUTDEV
+}
+if not {
+ if (! ~ $DEBUG '') echo input files $* >[1=2]
+ for (i in $*) {
+ if (! ~ $DEBUG '') echo processing $i >[1=2]
+ @{bind -b $LPLIB/process /bin; $LPPROC} < $i > $OUTDEV
+ if (~ $SENDEOT 1) echo -n `{ascii -t 4} > $OUTDEV
+ }
+}
+exit ''
diff --git a/sys/lib/lp/spooler/nt b/sys/lib/lp/spooler/nt
new file mode 100755
index 000000000..32ce54485
--- /dev/null
+++ b/sys/lib/lp/spooler/nt
@@ -0,0 +1,14 @@
+#!/bin/rc
+
+if (! ~ $DEBUG '') flag x +
+
+if (~ $#* 0) *='/fd/0'
+
+for (j in $*) {
+ if (~ $j '/fd/0' || test -f $j) {
+ @{bind -b $LPLIB/process /bin; $LPPROC} < $j | /$cputype/bin/aux/lpdsend -d$OUTDEV -H$LPMACHID -P$LPUSERID $DEST_HOST >[2]$LPLOGDIR/$LPDEST^.st
+ }
+ if not {
+ echo $j cannot be opened >[1=2]
+ }
+}
diff --git a/sys/lib/lp/spooler/nt-tekphaser350 b/sys/lib/lp/spooler/nt-tekphaser350
new file mode 100755
index 000000000..bce4b082d
--- /dev/null
+++ b/sys/lib/lp/spooler/nt-tekphaser350
@@ -0,0 +1,14 @@
+#!/bin/rc
+
+if (! ~ $DEBUG '') flag x +
+
+if (~ $#* 0) *='/fd/0'
+
+for (j in $*) {
+ if (~ $j '/fd/0' || test -f $j) {
+ @{bind -b $LPLIB/process /bin; $LPPROC} < $j | aux/download -f -H/sys/lib/postscript/font -mfontmap -ptekphaser350 | /$cputype/bin/aux/lpdsend -d$OUTDEV -H$LPMACHID -P$LPUSERID $DEST_HOST >[2]$LPLOGDIR/$LPDEST^.st
+ }
+ if not {
+ echo $j cannot be opened >[1=2]
+ }
+}
diff --git a/sys/lib/lp/spooler/pcclone b/sys/lib/lp/spooler/pcclone
new file mode 100755
index 000000000..888f18ba5
--- /dev/null
+++ b/sys/lib/lp/spooler/pcclone
@@ -0,0 +1,14 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+if (~ $OUTDEV -) OUTDEV=/fd/1
+if (~ $#* 0) {
+ @{bind -b $LPLIB/process /bin; $LPPROC} | aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ > $OUTDEV
+ if (! ~ $LPDEST stdout) echo -n `{ascii -t 4} > $OUTDEV
+}
+if not {
+ for (i in $*) {
+ @{bind -b $LPLIB/process /bin; $LPPROC} < $i | aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ > $OUTDEV
+ if (! ~ $LPDEST stdout) echo -n `{ascii -t 4} > $OUTDEV
+ }
+}
+exit ''
diff --git a/sys/lib/lp/spooler/pcclone.new b/sys/lib/lp/spooler/pcclone.new
new file mode 100755
index 000000000..57591ee48
--- /dev/null
+++ b/sys/lib/lp/spooler/pcclone.new
@@ -0,0 +1,22 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+if (~ $OUTDEV -) OUTDEV=/fd/1
+
+# make a place for pc's to spool files that is private
+ramfs
+mkdir /tmp/log /tmp/prob /tmp/queue
+bind -b /tmp/log $LPLIB/log
+bind -b /tmp/prob $LPLIB/prob
+bind -b /tmp/queue $LPLIB/queue
+
+if (~ $#* 0) {
+ @{bind -b $LPLIB/process /bin; $LPPROC} | aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ > $OUTDEV
+ if (! ~ $LPDEST stdout) echo -n `{ascii -t 4} > $OUTDEV
+}
+if not {
+ for (i in $*) {
+ @{bind -b $LPLIB/process /bin; $LPPROC} < $i | aux/download -f -H/sys/lib/postscript/font -mfontmap -plw+ > $OUTDEV
+ if (! ~ $LPDEST stdout) echo -n `{ascii -t 4} > $OUTDEV
+ }
+}
+exit ''
diff --git a/sys/lib/lp/spooler/ps630 b/sys/lib/lp/spooler/ps630
new file mode 100755
index 000000000..7e22d213e
--- /dev/null
+++ b/sys/lib/lp/spooler/ps630
@@ -0,0 +1,30 @@
+#!/bin/rc
+fn sigexit {echo -n '';exit 1}
+# Send output to the printer port on an AT&T 630/730 terminal
+# Process and enqueue files to be printed
+# take arguments as input files
+i=0
+if (~ $#* 0) *=''
+for (j in $*) {
+ i= `{echo $i + 1|hoc}
+
+# check access to the file so that you know that a failure in the
+# processing is a drastic error which will cause an exit from lp.
+
+ if (~ $j '' || test -f $j) {
+ switch ($j) {
+ case ''; @{
+ echo -n ''; sleep 1
+ bind -b $LPLIB/process /bin
+ $LPPROC
+ echo -n ''
+ }
+ case *; @{
+ echo -n ''; sleep 1
+ bind -b $LPLIB/process /bin
+ $LPPROC
+ echo -n ''
+ } <$j
+ }
+ }
+}
diff --git a/sys/lib/lp/stat/generic b/sys/lib/lp/stat/generic
new file mode 100755
index 000000000..e36a807bc
--- /dev/null
+++ b/sys/lib/lp/stat/generic
@@ -0,0 +1,27 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+if (~ $THIS_HOST $DEST_HOST) {
+ if (test -f $LPLIB/log/$LPDEST^.st) {
+ echo status:
+ tail -3 $LPLIB/log/$LPDEST^.st
+ }
+ cd $LPSPOOL
+ if (test -d $LPDEST) {
+ once=''
+ for (i in `{bind -b $LPLIB/sched /bin;$SCHED $LPDEST}) {
+ if (~ $once '') {
+ echo
+ echo queue on $THIS_HOST:
+ echo 'job user try size'
+ once=1
+ }
+ STATLINE=`{cat $LPDEST/$i^id}
+ LSLINE=`{ls -l $LPDEST/$i}
+ echo $STATLINE(1)^$STATLINE(3)' '$STATLINE(2)' '$STATLINE(4)' '$LSLINE(6)
+ }
+ }
+}
+if not {
+ { echo -d$LPDEST -q; sleep 5 } | lpsend.rc $DEST_HOST
+}
diff --git a/sys/lib/lp/stat/hp b/sys/lib/lp/stat/hp
new file mode 100755
index 000000000..f2855ab4a
--- /dev/null
+++ b/sys/lib/lp/stat/hp
@@ -0,0 +1,30 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+if (~ $THIS_HOST $DEST_HOST) {
+ if (test -f $LPLIB/log/$LPDEST^.st) {
+ echo job transmission status:
+ tail -3 $LPLIB/log/$LPDEST^.st
+ }
+ cd $LPSPOOL
+ if (test -d $LPDEST) {
+ once=''
+ for (i in `{bind -b $LPLIB/sched /bin;$SCHED $LPDEST}) {
+ if (~ $once '') {
+ echo
+ echo queue on $THIS_HOST:
+ echo 'job user try size'
+ once=1
+ }
+ STATLINE=`{cat $LPDEST/$i^id}
+ LSLINE=`{ls -l $LPDEST/$i}
+ echo $STATLINE(1)^$STATLINE(3)' '$STATLINE(2)' '$STATLINE(4)' '$LSLINE(6)
+ }
+ }
+ echo
+ echo 'checking the printers queue (type DELETE to abort):'
+ /$cputype/bin/aux/lpdsend -dRAW -q $OUTDEV
+}
+if not {
+ { echo -d$LPDEST -q; sleep 5 } | lpsend.rc $DEST_HOST
+}
diff --git a/sys/lib/lp/stat/lpd b/sys/lib/lp/stat/lpd
new file mode 100755
index 000000000..f746b393f
--- /dev/null
+++ b/sys/lib/lp/stat/lpd
@@ -0,0 +1,11 @@
+#!/bin/rc
+
+if (! ~ $DEBUG '') flag x +
+
+echo transmission log:
+if (test -r $LPLIB/log/$LPDEST^.st) {
+ tail -3 $LPLIB/log/$LPDEST^.st
+ echo
+}
+echo printer queue:
+/$cputype/bin/aux/lpdsend -q -d$OUTDEV $DEST_HOST
diff --git a/sys/lib/lp/stat/mhcc b/sys/lib/lp/stat/mhcc
new file mode 100755
index 000000000..1fe2d23b5
--- /dev/null
+++ b/sys/lib/lp/stat/mhcc
@@ -0,0 +1,3 @@
+#!/bin/rc
+
+{sleep 5;echo prtq;sleep 5} | telnet mhserva >[2]/dev/null | tr -d '\015' | sed '1,9d'
diff --git a/sys/lib/lp/stat/tektronix b/sys/lib/lp/stat/tektronix
new file mode 100755
index 000000000..75ae5eed3
--- /dev/null
+++ b/sys/lib/lp/stat/tektronix
@@ -0,0 +1,29 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+if (~ $THIS_HOST $DEST_HOST) {
+ echo printers queue:
+ /$cputype/bin/aux/lpdsend -dPS -q $OUTDEV
+ if (test -f $LPLIB/log/$LPDEST^.st) {
+ echo status:
+ tail -3 $LPLIB/log/$LPDEST^.st
+ }
+ cd $LPSPOOL
+ if (test -d $LPDEST) {
+ once=''
+ for (i in `{bind -b $LPLIB/sched /bin;$SCHED $LPDEST}) {
+ if (~ $once '') {
+ echo
+ echo queue on $THIS_HOST:
+ echo 'job user try size'
+ once=1
+ }
+ STATLINE=`{cat $LPDEST/$i^id}
+ LSLINE=`{ls -l $LPDEST/$i}
+ echo $STATLINE(1)^$STATLINE(3)' '$STATLINE(2)' '$STATLINE(4)' '$LSLINE(6)
+ }
+ }
+}
+if not {
+ { echo -d$LPDEST -q; sleep 5 } | lpsend.rc $DEST_HOST
+}
diff --git a/sys/lib/lp/stat/xante b/sys/lib/lp/stat/xante
new file mode 100755
index 000000000..75ae5eed3
--- /dev/null
+++ b/sys/lib/lp/stat/xante
@@ -0,0 +1,29 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+if (~ $THIS_HOST $DEST_HOST) {
+ echo printers queue:
+ /$cputype/bin/aux/lpdsend -dPS -q $OUTDEV
+ if (test -f $LPLIB/log/$LPDEST^.st) {
+ echo status:
+ tail -3 $LPLIB/log/$LPDEST^.st
+ }
+ cd $LPSPOOL
+ if (test -d $LPDEST) {
+ once=''
+ for (i in `{bind -b $LPLIB/sched /bin;$SCHED $LPDEST}) {
+ if (~ $once '') {
+ echo
+ echo queue on $THIS_HOST:
+ echo 'job user try size'
+ once=1
+ }
+ STATLINE=`{cat $LPDEST/$i^id}
+ LSLINE=`{ls -l $LPDEST/$i}
+ echo $STATLINE(1)^$STATLINE(3)' '$STATLINE(2)' '$STATLINE(4)' '$LSLINE(6)
+ }
+ }
+}
+if not {
+ { echo -d$LPDEST -q; sleep 5 } | lpsend.rc $DEST_HOST
+}
diff --git a/sys/lib/lp/stat/xerox b/sys/lib/lp/stat/xerox
new file mode 100755
index 000000000..4bf56c197
--- /dev/null
+++ b/sys/lib/lp/stat/xerox
@@ -0,0 +1,29 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+if (~ $THIS_HOST $DEST_HOST) {
+ echo printers queue:
+ /$cputype/bin/aux/lpdsend -dps -q $OUTDEV
+ if (test -f $LPLIB/log/$LPDEST^.st) {
+ echo status:
+ tail -3 $LPLIB/log/$LPDEST^.st
+ }
+ cd $LPSPOOL
+ if (test -d $LPDEST) {
+ once=''
+ for (i in `{bind -b $LPLIB/sched /bin;$SCHED $LPDEST}) {
+ if (~ $once '') {
+ echo
+ echo queue on $THIS_HOST:
+ echo 'job user try size'
+ once=1
+ }
+ STATLINE=`{cat $LPDEST/$i^id}
+ LSLINE=`{ls -l $LPDEST/$i}
+ echo $STATLINE(1)^$STATLINE(3)' '$STATLINE(2)' '$STATLINE(4)' '$LSLINE(6)
+ }
+ }
+}
+if not {
+ { echo -d$LPDEST -q; sleep 5 } | lpsend.rc $DEST_HOST
+}
diff --git a/sys/lib/lp/stat/xerox-4512 b/sys/lib/lp/stat/xerox-4512
new file mode 100755
index 000000000..0c8fd8e79
--- /dev/null
+++ b/sys/lib/lp/stat/xerox-4512
@@ -0,0 +1,29 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+if (~ $THIS_HOST $DEST_HOST) {
+ echo printers queue:
+ /$cputype/bin/aux/lpdsend -dPORT1 -q $OUTDEV
+ if (test -f $LPLIB/log/$LPDEST^.st) {
+ echo status:
+ tail -3 $LPLIB/log/$LPDEST^.st
+ }
+ cd $LPSPOOL
+ if (test -d $LPDEST) {
+ once=''
+ for (i in `{bind -b $LPLIB/sched /bin;$SCHED $LPDEST}) {
+ if (~ $once '') {
+ echo
+ echo queue on $THIS_HOST:
+ echo 'job user try size'
+ once=1
+ }
+ STATLINE=`{cat $LPDEST/$i^id}
+ LSLINE=`{ls -l $LPDEST/$i}
+ echo $STATLINE(1)^$STATLINE(3)' '$STATLINE(2)' '$STATLINE(4)' '$LSLINE(6)
+ }
+ }
+}
+if not {
+ { echo -d$LPDEST -q; sleep 5 } | lpsend.rc $DEST_HOST
+}
diff --git a/sys/lib/lp/stat/xerox-4517 b/sys/lib/lp/stat/xerox-4517
new file mode 100755
index 000000000..14655fa0f
--- /dev/null
+++ b/sys/lib/lp/stat/xerox-4517
@@ -0,0 +1,29 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+if (~ $THIS_HOST $DEST_HOST) {
+ echo printers queue:
+ /$cputype/bin/aux/lpdsend -dPASSTHRU -q $OUTDEV
+ if (test -f $LPLIB/log/$LPDEST^.st) {
+ echo status:
+ tail -3 $LPLIB/log/$LPDEST^.st
+ }
+ cd $LPSPOOL
+ if (test -d $LPDEST) {
+ once=''
+ for (i in `{bind -b $LPLIB/sched /bin;$SCHED $LPDEST}) {
+ if (~ $once '') {
+ echo
+ echo queue on $THIS_HOST:
+ echo 'job user try size'
+ once=1
+ }
+ STATLINE=`{cat $LPDEST/$i^id}
+ LSLINE=`{ls -l $LPDEST/$i}
+ echo $STATLINE(1)^$STATLINE(3)' '$STATLINE(2)' '$STATLINE(4)' '$LSLINE(6)
+ }
+ }
+}
+if not {
+ { echo -d$LPDEST -q; sleep 5 } | lpsend.rc $DEST_HOST
+}
diff --git a/sys/lib/lp/stat/xerox-N32 b/sys/lib/lp/stat/xerox-N32
new file mode 100755
index 000000000..f2855ab4a
--- /dev/null
+++ b/sys/lib/lp/stat/xerox-N32
@@ -0,0 +1,30 @@
+#!/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+if (~ $THIS_HOST $DEST_HOST) {
+ if (test -f $LPLIB/log/$LPDEST^.st) {
+ echo job transmission status:
+ tail -3 $LPLIB/log/$LPDEST^.st
+ }
+ cd $LPSPOOL
+ if (test -d $LPDEST) {
+ once=''
+ for (i in `{bind -b $LPLIB/sched /bin;$SCHED $LPDEST}) {
+ if (~ $once '') {
+ echo
+ echo queue on $THIS_HOST:
+ echo 'job user try size'
+ once=1
+ }
+ STATLINE=`{cat $LPDEST/$i^id}
+ LSLINE=`{ls -l $LPDEST/$i}
+ echo $STATLINE(1)^$STATLINE(3)' '$STATLINE(2)' '$STATLINE(4)' '$LSLINE(6)
+ }
+ }
+ echo
+ echo 'checking the printers queue (type DELETE to abort):'
+ /$cputype/bin/aux/lpdsend -dRAW -q $OUTDEV
+}
+if not {
+ { echo -d$LPDEST -q; sleep 5 } | lpsend.rc $DEST_HOST
+}