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