2 |
- |
1 |
#!/bin/rc
|
|
|
2 |
# fn sigexit { rm -f $LPSPOOL/$LPDEST/.$pid.* $LPSPOOL/$LPDEST/$pid.* $LPSPOOL/$LPDEST }
|
|
|
3 |
if (! ~ $DEBUG '') flag x +
|
|
|
4 |
|
|
|
5 |
if (~ $THIS_HOST $DEST_HOST) {
|
|
|
6 |
if (! test -d $LPSPOOL/$LPDEST) {
|
|
|
7 |
mkdir $LPSPOOL/$LPDEST
|
|
|
8 |
chmod 777 $LPSPOOL/$LPDEST >[2]/dev/null
|
|
|
9 |
}
|
|
|
10 |
}
|
|
|
11 |
# Process and enqueue files to be printed
|
|
|
12 |
# take arguments as input files
|
|
|
13 |
i=0
|
|
|
14 |
if (~ $#* 0) *=''
|
|
|
15 |
for (j in $*) {
|
|
|
16 |
i= `{echo $i + 1|hoc}
|
|
|
17 |
|
|
|
18 |
# check access to the file so that you know that a failure in the
|
|
|
19 |
# processing is a drastic error which will cause an exit from lp.
|
|
|
20 |
|
|
|
21 |
if (~ $j '' || test -f $j) {
|
|
|
22 |
if (~ $THIS_HOST $DEST_HOST) {
|
|
|
23 |
echo $LPMACHID $LPUSERID $pid.$i 0 > $LPSPOOL/$LPDEST/.$pid.$i^id
|
|
|
24 |
if (~ $j '') @{bind -b $LPLIB/process /bin; $LPPROC} >$LPSPOOL/$LPDEST/.$pid.$i
|
|
|
25 |
if not @{bind -b $LPLIB/process /bin; $LPPROC} <$j >$LPSPOOL/$LPDEST/.$pid.$i
|
|
|
26 |
if (~ $status '') {
|
|
|
27 |
mv $LPSPOOL/$LPDEST/.$pid.$i $LPSPOOL/$LPDEST/$pid.$i
|
|
|
28 |
mv $LPSPOOL/$LPDEST/.$pid.$i^id $LPSPOOL/$LPDEST/$pid.$i^id
|
|
|
29 |
}
|
|
|
30 |
if not {
|
|
|
31 |
rval='preprocessing failed'
|
|
|
32 |
rm -f $LPSPOOL/$LPDEST/.$pid.$i $LPSPOOL/queue/$LPDEST/.$pid.$i^id
|
|
|
33 |
exit $rval
|
|
|
34 |
}
|
|
|
35 |
}
|
|
|
36 |
if not {
|
|
|
37 |
switch ($j) {
|
|
|
38 |
case ''; @{ {echo -d^$LPDEST -pnoproc -M^$LPMACHID -u^$LPUSERID; bind -b $LPLIB/process /bin; $LPPROC} | lpsend.rc $DEST_HOST}
|
|
|
39 |
case *; @{ {echo -d^$LPDEST -pnoproc -M^$LPMACHID -u^$LPUSERID; bind -b $LPLIB/process /bin; $LPPROC} < $j | lpsend.rc $DEST_HOST}
|
|
|
40 |
}
|
|
|
41 |
rval=$status
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
if not {
|
|
|
45 |
echo $j cannot be opened >[1=2]
|
|
|
46 |
}
|
|
|
47 |
}
|