generic 4.0 KB

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