generic 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #!/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. rfork e
  6. temp=/tmp/lp$pid
  7. fn sigexit { rm -f $temp }
  8. proc=$LPLIB/process
  9. if (! ~ $DEBUG '')
  10. flag x +
  11. cat >$temp
  12. type=`{file $temp}
  13. switch ($type(2)) {
  14. case troff
  15. switch ($LPCLASS) {
  16. case *Latin1* *post* *opost*
  17. switch ($type(5)) {
  18. # Latin1 is for compatibility with old research UNIX systems,
  19. # doesn't work on Plan 9
  20. case Latin1 post
  21. tcs -s -f utf -t latin1 <$temp | $proc/dpost
  22. case UTF
  23. $proc/tr2post <$temp
  24. }
  25. case *gs!* *gsijs!*
  26. switch ($type(5)) {
  27. # Latin1 is for compatibility with old research UNIX systems,
  28. # doesn't work on Plan 9
  29. case Latin1 post
  30. tcs -s -f utf -t latin1 <$temp | $proc/dpost |
  31. $proc/gspipe
  32. case UTF
  33. $proc/tr2post <$temp | $proc/gspipe
  34. }
  35. case *
  36. echo $type(2) -T$type(5) output is improper for $LPDEST >[1=2]
  37. }
  38. case special
  39. switch ($type(4)) {
  40. case '#b'
  41. switch ($LPCLASS) {
  42. case *post*
  43. $proc/p9bitpost <$temp
  44. case *gs!*
  45. $proc/p9bitpost <$temp | $proc/gspipe
  46. case *gsijs!*
  47. $proc/p9bitpost <$temp | $proc/gspipeijs
  48. }
  49. case *
  50. echo $type file is improper for $LPDEST >[1=2]
  51. }
  52. case Compressed plan old
  53. # type is really 'Compressed image' or 'plan 9 image' or
  54. # 'old plan 9 image'
  55. switch ($LPCLASS) {
  56. case *post*
  57. $proc/p9bitpost <$temp
  58. case *gs!*
  59. $proc/p9bitpost <$temp | $proc/gspipe
  60. case *gsijs!*
  61. $proc/p9bitpost <$temp | $proc/gspipeijs
  62. }
  63. case jpeg
  64. switch ($LPCLASS) {
  65. case *post*
  66. $proc/jpgpost <$temp
  67. case *gs!*
  68. $proc/jpgpost <$temp | $proc/gspipe
  69. case *gsijs!*
  70. $proc/jpgpost <$temp | $proc/gspipeijs
  71. }
  72. case GIF
  73. switch ($LPCLASS) {
  74. case *post*
  75. $proc/gifpost <$temp
  76. case *gs!*
  77. $proc/gifpost <$temp | $proc/gspipe
  78. case *gsijs!*
  79. $proc/gifpost <$temp | $proc/gspipeijs
  80. }
  81. case ccitt-g31;
  82. switch ($LPCLASS) {
  83. case *post*
  84. $proc/g3post <$temp
  85. case *gs!*
  86. $proc/g3post <$temp | $proc/gspipe
  87. case *gsijs!*
  88. $proc/g3post <$temp | $proc/gspipeijs
  89. }
  90. case bitmap
  91. # bitmap for research UNIX compatibility, does not work on Plan 9.
  92. switch ($LPCLASS) {
  93. case *post*
  94. $proc/bpost <$temp
  95. case *mhcc*
  96. $proc/bpost <$temp | $proc/mhcc
  97. case *
  98. echo $type(2) file is improper for $LPDEST >[1=2]
  99. }
  100. case tex
  101. mv $temp $temp.dvi
  102. temp=$temp.dvi
  103. switch ($LPCLASS) {
  104. case *post*
  105. $proc/dvipost $temp
  106. case *gs!*
  107. $proc/dvipost $temp | $proc/gspipe
  108. case *gsijs!*
  109. $proc/dvipost $temp | $proc/gspipeijs
  110. case *
  111. echo $type(2) file is improper for $LPDEST >[1=2]
  112. }
  113. case postscript
  114. switch ($LPCLASS) {
  115. case *post*
  116. $proc/post <$temp
  117. case *gs!*
  118. $proc/post <$temp | $proc/gspipe
  119. case *gsijs!*
  120. $proc/post <$temp | $proc/gspipeijs
  121. case *
  122. echo $type(2) file is improper for $LPDEST >[1=2]
  123. }
  124. case HPJCL
  125. switch ($LPCLASS) {
  126. case *HPJCL*
  127. $proc/noproc <$temp
  128. case *
  129. echo $type(2) file is improper for $LPDEST >[1=2]
  130. }
  131. case daisy
  132. switch ($LPDEST) {
  133. case *
  134. echo $type(2) file is improper for $LPDEST >[1=2]
  135. }
  136. case tiff
  137. switch ($LPCLASS) {
  138. case *post*
  139. $proc/tiffpost $temp
  140. case *gs!*
  141. $proc/tiffpost $temp | $proc/gspipe
  142. case *gsijs!*
  143. $proc/tiffpost $temp | $proc/gspipeijs
  144. case *
  145. echo Unrecognized class of line printer for $LPDEST >[1=2]
  146. }
  147. case PDF
  148. switch ($LPCLASS) {
  149. case *pdf*
  150. # if (~ $LPCLASS *duplex* && ~ $LPCLASS *HPJCL*)
  151. # echo -n '&l1S' # HP JCL: duplex on
  152. if (~ $LPCLASS *duplex* && ~ $LPCLASS *HPJCL*) {
  153. echo '%-12345X@PJL DEFAULT DUPLEX=ON' # HP PJL
  154. echo '%-12345X'
  155. echo '%-12345X@PJL DEFAULT PS:MBT=ON' # `memory boost'
  156. echo '%-12345X'
  157. }
  158. cat $temp # pass pdf unaltered to pdf printer
  159. case *post*
  160. $proc/pdfpost $temp
  161. case *gs!*
  162. $proc/pdfgs $temp
  163. case *gsijs!*
  164. $proc/pdfgsijs $temp
  165. case *
  166. echo Unrecognized class of line printer for $LPDEST >[1=2]
  167. }
  168. case empty
  169. echo file is empty >[1=2]
  170. case cannot
  171. echo cannot open file >[1=2]
  172. case English short extended alef limbo [Aa]scii assembler c latin rc sh \
  173. as mail email message/rfc822 manual
  174. switch ($LPCLASS) {
  175. case *post*
  176. $proc/ppost <$temp
  177. case *gs!*
  178. $proc/ppost <$temp | $proc/gspipe
  179. case *gsijs!*
  180. $proc/ppost <$temp | $proc/gspipeijs
  181. case *canon*
  182. $proc/can $* <$temp
  183. case *
  184. echo Unrecognized class of line printer for $LPDEST >[1=2]
  185. }
  186. case *
  187. echo $type(2) file is improper for $LPDEST >[1=2]
  188. }
  189. wait
  190. rv=$status
  191. rm -f $temp
  192. # exit $rv
  193. exit