aboutsummaryrefslogtreecommitdiff
path: root/lp/spooler/generic
blob: 83ee13ffec9d8864646184cc7021187cceb58392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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]
	}
}