1
0

generic 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. 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. case UTF; $LPLIB/process/tr2post < $TMPFILE
  19. }
  20. case *gs!*; switch ($FILETYPE(5)) {
  21. # Latin1 is for compatibility with old research UNIX systems, doesn't work on Plan 9
  22. case Latin1 post; tcs -s -f utf -t latin1 < $TMPFILE |$LPLIB/process/dpost |$LPLIB/process/gspipe
  23. case UTF; $LPLIB/process/tr2post < $TMPFILE |$LPLIB/process/gspipe
  24. }
  25. case *; echo $FILETYPE(2) -T$FILETYPE(5) output is improper for $LPDEST >[1=2]
  26. }
  27. case special;
  28. switch ($FILETYPE(4)) {
  29. case '#b'; switch ($LPCLASS) {
  30. case *post*; $LPLIB/process/p9bitpost < $TMPFILE
  31. case *gs!*; $LPLIB/process/p9bitpost < $TMPFILE |$LPLIB/process/gspipe
  32. }
  33. case *; echo $FILETYPE file is improper for $LPDEST >[1=2]
  34. }
  35. case Compressed plan old; # type is really 'Compressed image' or 'plan 9 image'
  36. # or 'old plan 9 image'
  37. switch ($LPCLASS) {
  38. case *post*; $LPLIB/process/p9bitpost < $TMPFILE
  39. case *gs!*; $LPLIB/process/p9bitpost < $TMPFILE |$LPLIB/process/gspipe
  40. }
  41. case jpeg;
  42. switch ($LPCLASS) {
  43. case *post*; $LPLIB/process/jpgpost < $TMPFILE
  44. case *gs!*; $LPLIB/process/jpgpost < $TMPFILE |$LPLIB/process/gspipe
  45. }
  46. case GIF;
  47. switch ($LPCLASS) {
  48. case *post*; $LPLIB/process/gifpost < $TMPFILE
  49. case *gs!*; $LPLIB/process/gifpost < $TMPFILE |$LPLIB/process/gspipe
  50. }
  51. case ccitt-g31;
  52. switch ($LPCLASS) {
  53. case *post*; $LPLIB/process/g3post < $TMPFILE
  54. case *gs!*; $LPLIB/process/g3post < $TMPFILE |$LPLIB/process/gspipe
  55. }
  56. # bitmap for research UNIX compatibility, does not work on Plan 9.
  57. case bitmap;
  58. switch ($LPCLASS) {
  59. case *post*; $LPLIB/process/bpost < $TMPFILE
  60. case *mhcc*; $LPLIB/process/bpost < $TMPFILE | $LPLIB/process/mhcc
  61. case *; echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
  62. }
  63. case tex;
  64. mv $TMPFILE $TMPFILE.dvi
  65. TMPFILE=$TMPFILE.dvi
  66. switch ($LPCLASS) {
  67. case *post*; $LPLIB/process/dvipost $TMPFILE
  68. case *gs!*; $LPLIB/process/dvipost $TMPFILE |$LPLIB/process/gspipe
  69. case *; echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
  70. }
  71. case postscript;
  72. switch ($LPCLASS) {
  73. case *post*; $LPLIB/process/post < $TMPFILE
  74. case *gs!*; $LPLIB/process/post < $TMPFILE |$LPLIB/process/gspipe
  75. case *; echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
  76. }
  77. case HPJCL;
  78. switch ($LPCLASS) {
  79. case *HPJCL*; $LPLIB/process/noproc < $TMPFILE
  80. case *; echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
  81. }
  82. case daisy;
  83. switch ($LPDEST) {
  84. case *; echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
  85. }
  86. case English short extended alef limbo [Aa]scii assembler c latin rc sh as mail email message/rfc822;
  87. switch ($LPCLASS) {
  88. case *post*; $LPLIB/process/ppost < $TMPFILE
  89. case *gs!*; $LPLIB/process/ppost < $TMPFILE |$LPLIB/process/gspipe
  90. case *canon*; $LPLIB/process/can $* < $TMPFILE
  91. case *; echo Unrecognized class of line printer for $LPDEST >[1=2]
  92. }
  93. case tiff;
  94. switch ($LPCLASS) {
  95. case *post*; $LPLIB/process/tiffpost $TMPFILE
  96. case *gs!*; $LPLIB/process/tiffpost $TMPFILE |$LPLIB/process/gspipe
  97. case *; echo Unrecognized class of line printer for $LPDEST >[1=2]
  98. }
  99. case PDF;
  100. switch ($LPCLASS) {
  101. case *post*; $LPLIB/process/pdfpost $TMPFILE
  102. case *gs!*; $LPLIB/process/pdfgs $TMPFILE
  103. case *; echo Unrecognized class of line printer for $LPDEST >[1=2]
  104. }
  105. case empty;
  106. echo file is empty >[1=2]
  107. case cannot;
  108. echo cannot open file >[1=2]
  109. case *;
  110. echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
  111. }
  112. wait
  113. rv=$status
  114. rm -f $TMPFILE
  115. #exit $status
  116. exit