generic (3103B)
1 #!/usr/local/plan9/bin/rc 2 # Tries to determine what type of file you are printing and do the correct 3 # thing with it. 4 # It currently knows about images, troff intermediate, and ascii files. 5 TMPFILE=/tmp/lp$pid 6 fn sigexit { rm -f $TMPFILE; } 7 if (! ~ $DEBUG '') flag x + 8 if (~ $LPCLASS *nohead*) NOHEAD=1 9 if (~ $LPCLASS *duplex*) DUPLEX=1 10 cat >$TMPFILE 11 FILETYPE=`{file $TMPFILE} 12 switch ($FILETYPE(2)) { 13 case troff; 14 switch ($LPCLASS) { 15 case *Latin1* *post* *opost*; switch ($FILETYPE(5)) { 16 # Latin1 is for compatibility with old research UNIX systems, doesn't work on Plan 9 17 case Latin1 post; tcs -s -f utf -t latin1 < $TMPFILE |$LPLIB/process/dpost 18 19 case UTF; $LPLIB/process/tr2post < $TMPFILE 20 } 21 22 case *; echo $FILETYPE(2) -T$FILETYPE(5) output is improper for $LPDEST >[1=2] 23 } 24 case special; 25 switch ($FILETYPE(4)) { 26 case '#b'; switch ($LPCLASS) { 27 case *post*; $LPLIB/process/p9bitpost < $TMPFILE 28 } 29 30 case *; echo $FILETYPE file is improper for $LPDEST >[1=2] 31 } 32 case Compressed plan old; # type is really 'Compressed image' or 'plan 9 image' 33 # or 'old plan 9 image' 34 switch ($LPCLASS) { 35 case *post*; $LPLIB/process/p9bitpost < $TMPFILE 36 } 37 case jpeg; 38 switch ($LPCLASS) { 39 case *post*; $LPLIB/process/jpgpost < $TMPFILE 40 } 41 42 case GIF; 43 switch ($LPCLASS) { 44 case *post*; $LPLIB/process/gifpost < $TMPFILE 45 } 46 47 case ccitt-g31; 48 switch ($LPCLASS) { 49 case *post*; $LPLIB/process/g3post < $TMPFILE 50 } 51 52 # bitmap for research UNIX compatibility, does not work on Plan 9. 53 case bitmap; 54 switch ($LPCLASS) { 55 case *post*; $LPLIB/process/bpost < $TMPFILE 56 case *mhcc*; $LPLIB/process/bpost < $TMPFILE | $LPLIB/process/mhcc 57 case *; echo $FILETYPE(2) file is improper for $LPDEST >[1=2] 58 } 59 case tex; 60 mv $TMPFILE $TMPFILE.dvi 61 TMPFILE=$TMPFILE.dvi 62 switch ($LPCLASS) { 63 case *post*; $LPLIB/process/dvipost $TMPFILE 64 case *; echo $FILETYPE(2) file is improper for $LPDEST >[1=2] 65 } 66 case postscript; 67 switch ($LPCLASS) { 68 case *post*; $LPLIB/process/post < $TMPFILE 69 case *; echo $FILETYPE(2) file is improper for $LPDEST >[1=2] 70 } 71 case HPJCL; 72 switch ($LPCLASS) { 73 case *HPJCL*; $LPLIB/process/noproc < $TMPFILE 74 case *; echo $FILETYPE(2) file is improper for $LPDEST >[1=2] 75 } 76 case daisy; 77 switch ($LPDEST) { 78 case *; echo $FILETYPE(2) file is improper for $LPDEST >[1=2] 79 } 80 case English short extended alef limbo [Aa]scii ASCII assembler c latin rc sh as mail email message/rfc822; 81 switch ($LPCLASS) { 82 case *post*; $LPLIB/process/ppost < $TMPFILE 83 case *canon*; $LPLIB/process/can $* < $TMPFILE 84 case *; echo Unrecognized class of line printer for $LPDEST >[1=2] 85 } 86 87 case tiff; 88 switch ($LPCLASS) { 89 case *post*; $LPLIB/process/tiffpost $TMPFILE 90 case *; echo Unrecognized class of line printer for $LPDEST >[1=2] 91 } 92 case PDF; 93 switch ($LPCLASS) { 94 case *post*; $LPLIB/process/pdfpost $TMPFILE 95 case *; echo Unrecognized class of line printer for $LPDEST >[1=2] 96 } 97 case empty; 98 echo file is empty >[1=2] 99 case cannot; 100 echo cannot open file >[1=2] 101 case *; 102 echo $FILETYPE(2) file is improper for $LPDEST >[1=2] 103 } 104 wait 105 rv=$status 106 rm -f $TMPFILE 107 #exit $status 108 exit