aboutsummaryrefslogtreecommitdiff
path: root/lp/spooler
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-08-31 02:15:26 +0000
committerrsc <devnull@localhost>2005-08-31 02:15:26 +0000
commit6174642093bdcef4116ae78dbdf4f2e608494258 (patch)
treeb916d25347295ee15b35434b92011b31fd76862c /lp/spooler
parent9f1d53a09bdd8f99e9f81a344c7fa6b5161e1359 (diff)
downloadplan9port-6174642093bdcef4116ae78dbdf4f2e608494258.tar.gz
plan9port-6174642093bdcef4116ae78dbdf4f2e608494258.tar.bz2
plan9port-6174642093bdcef4116ae78dbdf4f2e608494258.zip
Initial lp.
Diffstat (limited to 'lp/spooler')
-rwxr-xr-xlp/spooler/generic48
-rwxr-xr-xlp/spooler/lpdspool15
-rwxr-xr-xlp/spooler/nospool21
3 files changed, 84 insertions, 0 deletions
diff --git a/lp/spooler/generic b/lp/spooler/generic
new file mode 100755
index 00000000..83ee13ff
--- /dev/null
+++ b/lp/spooler/generic
@@ -0,0 +1,48 @@
+#!/usr/local/plan9/bin/rc
+# fn sigexit { rm -f $LPSPOOL/$LPDEST/.$pid.* $LPSPOOL/$LPDEST/$pid.* $LPSPOOL/$LPDEST }
+if (! ~ $DEBUG '') flag x +
+
+echo $THIS_HOST $DEST_HOST
+if (~ $THIS_HOST $DEST_HOST) {
+ if (! test -d $LPSPOOL/$LPDEST) {
+ mkdir $LPSPOOL/$LPDEST
+ chmod 777 $LPSPOOL/$LPDEST >[2]/dev/null
+ chmod +t $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
+ lpinput $j lpsub process $LPPROC >$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 {
+ {
+ echo -d^$LPDEST -pnoproc -M^$LPMACHID -u^$LPUSERID
+ lpinput $j lpsub process $LPPROC
+ } | lpsend.rc $DEST_HOST
+ rval=$status
+ }
+ }
+ if not {
+ echo $j cannot be opened >[1=2]
+ }
+}
diff --git a/lp/spooler/lpdspool b/lp/spooler/lpdspool
new file mode 100755
index 00000000..3f14eaed
--- /dev/null
+++ b/lp/spooler/lpdspool
@@ -0,0 +1,15 @@
+#!/usr/local/plan9/bin/rc
+
+if (! ~ $DEBUG '') flag x +
+
+if (~ $#* 0) *=''
+
+for (j in $*) {
+ if (~ $j '' || test -f $j) {
+ lpinput $j lpsub process $LPPROC |
+ 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/lp/spooler/nospool b/lp/spooler/nospool
new file mode 100755
index 00000000..4d019983
--- /dev/null
+++ b/lp/spooler/nospool
@@ -0,0 +1,21 @@
+#!/usr/local/plan9/bin/rc
+if (! ~ $DEBUG '') flag x +
+
+if (~ $LPCLASS *sendEOT*) SENDEOT=1
+if not SENDEOT=0
+
+if (~ $OUTDEV -) OUTDEV=/dev/stdout
+if (~ $#* 0) {
+ if (! ~ $DEBUG '') echo input file is stdin >[1=2]
+ lpsub process $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]
+ lpsub process $LPPROC < $i > $OUTDEV
+ if (~ $SENDEOT 1) echo -n `{ascii -t 4} > $OUTDEV
+ }
+}
+exit ''