generic 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 PNG
  82. switch ($LPCLASS) {
  83. case *post*
  84. $proc/pngpost <$temp
  85. case *gs!*
  86. $proc/pngpost <$temp | $proc/gspipe
  87. case *gsijs!*
  88. $proc/pngpost <$temp | $proc/gspipeijs
  89. }
  90. case ccitt-g31
  91. switch ($LPCLASS) {
  92. case *post*
  93. $proc/g3post <$temp
  94. case *gs!*
  95. $proc/g3post <$temp | $proc/gspipe
  96. case *gsijs!*
  97. $proc/g3post <$temp | $proc/gspipeijs
  98. }
  99. case bitmap
  100. # bitmap for research UNIX compatibility, does not work on Plan 9.
  101. switch ($LPCLASS) {
  102. case *post*
  103. $proc/bpost <$temp
  104. case *mhcc*
  105. $proc/bpost <$temp | $proc/mhcc
  106. case *
  107. echo $type(2) file is improper for $LPDEST >[1=2]
  108. }
  109. case tex
  110. mv $temp $temp.dvi
  111. temp=$temp.dvi
  112. switch ($LPCLASS) {
  113. case *post*
  114. $proc/dvipost $temp
  115. case *gs!*
  116. $proc/dvipost $temp | $proc/gspipe
  117. case *gsijs!*
  118. $proc/dvipost $temp | $proc/gspipeijs
  119. case *
  120. echo $type(2) file is improper for $LPDEST >[1=2]
  121. }
  122. case postscript
  123. switch ($LPCLASS) {
  124. case *post*
  125. $proc/post <$temp
  126. case *gs!*
  127. $proc/post <$temp | $proc/gspipe
  128. case *gsijs!*
  129. $proc/post <$temp | $proc/gspipeijs
  130. case *
  131. echo $type(2) file is improper for $LPDEST >[1=2]
  132. }
  133. case HPJCL
  134. switch ($LPCLASS) {
  135. case *HPJCL*
  136. $proc/noproc <$temp
  137. case *
  138. echo $type(2) file is improper for $LPDEST >[1=2]
  139. }
  140. case daisy
  141. switch ($LPDEST) {
  142. case *
  143. echo $type(2) file is improper for $LPDEST >[1=2]
  144. }
  145. case tiff
  146. switch ($LPCLASS) {
  147. case *post*
  148. $proc/tiffpost $temp
  149. case *gs!*
  150. $proc/tiffpost $temp | $proc/gspipe
  151. case *gsijs!*
  152. $proc/tiffpost $temp | $proc/gspipeijs
  153. case *
  154. echo Unrecognized class of line printer for $LPDEST >[1=2]
  155. }
  156. case PDF
  157. switch ($LPCLASS) {
  158. case *pdf*
  159. # if (~ $LPCLASS *duplex* && ~ $LPCLASS *HPJCL*)
  160. # echo -n '&l1S' # HP JCL: duplex on
  161. if (~ $LPCLASS *duplex* && ~ $LPCLASS *HPJCL*) {
  162. echo '%-12345X@PJL DEFAULT DUPLEX=ON' # HP PJL
  163. echo '%-12345X'
  164. echo '%-12345X@PJL DEFAULT PS:MBT=ON' # `memory boost'
  165. echo '%-12345X'
  166. }
  167. cat $temp # pass pdf unaltered to pdf printer
  168. case *post*
  169. $proc/pdfpost $temp
  170. case *gs!*
  171. $proc/pdfgs $temp
  172. case *gsijs!*
  173. $proc/pdfgsijs $temp
  174. case *
  175. echo Unrecognized class of line printer for $LPDEST >[1=2]
  176. }
  177. case empty
  178. echo file is empty >[1=2]
  179. case cannot
  180. echo cannot open file >[1=2]
  181. case English short extended alef limbo [Aa]scii assembler c latin rc sh \
  182. as mail email message/rfc822 manual
  183. switch ($LPCLASS) {
  184. case *post*
  185. $proc/ppost <$temp
  186. case *gs!*
  187. $proc/ppost <$temp | $proc/gspipe
  188. case *gsijs!*
  189. $proc/ppost <$temp | $proc/gspipeijs
  190. case *canon*
  191. $proc/can $* <$temp
  192. case *
  193. echo Unrecognized class of line printer for $LPDEST >[1=2]
  194. }
  195. case *
  196. echo $type(2) file is improper for $LPDEST >[1=2]
  197. }
  198. wait
  199. rv=$status
  200. rm -f $temp
  201. # exit $rv
  202. exit