dvipost 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/rc
  2. if (~ $DEBUG 1) flag x +
  3. # convert Tex dvi to PostScript
  4. PATCH='%!PS-Adobe-2.0'
  5. switch ($LPCLASS) {
  6. case *hp4simx*;
  7. PATCH=$PATCH'
  8. %% set the default papertray to be the lower tray for HP4siMX printers
  9. statusdict begin defaultpapertray end 1 ne {
  10. statusdict begin
  11. 1 setdefaultpapertray
  12. end
  13. } if'
  14. }
  15. for (i in `{echo $IBIN|awk -F, '{ n=split($0, a, ","); for (i=1;i<=n;i++) print a[i]; }'}) {
  16. switch ($i) {
  17. case man manual manualfeed;
  18. PATCH=$PATCH'
  19. %%BeginFeature: *Select ManualFeed
  20. [{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
  21. << /ManualFeed true >> setpagedevice
  22. } {statusdict begin /manualfeed true def end} ifelse
  23. } stopped cleartomark
  24. %%EndFeature'
  25. case simplex;
  26. DUPLEX=0
  27. case [0-9];
  28. switch ($LPCLASS) {
  29. case *post2*;
  30. switch ($i) {
  31. case 0; PATCH=$PATCH'
  32. systemdict/languagelevel known {languagelevel 2 eq {true (0) startjob dup not
  33. {/exitserver errordict/invalidaccess get exec}if}{false}ifelse}{false}ifelse
  34. {
  35. currentpagedevice/InputAttributes get {0 get} stopped
  36. {pop pop} {2 dict dup /InputAttributes 1 dict dup
  37. /Priority[0] put put dup /TraySwitch false put setpagedevice} ifelse
  38. false (0) startjob pop
  39. } if'
  40. case 1; PATCH=$PATCH'
  41. systemdict/languagelevel known {languagelevel 2 eq {true (0) startjob dup not
  42. {/exitserver errordict/invalidaccess get exec}if}{false}ifelse}{false}ifelse
  43. {
  44. currentpagedevice/InputAttributes get {1 get} stopped
  45. {pop pop} {2 dict dup /InputAttributes 1 dict dup
  46. /Priority[1] put put dup /TraySwitch false put setpagedevice} ifelse
  47. false (0) startjob pop
  48. } if'
  49. }
  50. case *; PATCH=$PATCH'
  51. statusdict begin $i setpapertray end'
  52. }
  53. case 11x17 ledger; PATCH=$PATCH'
  54. statusdict begin '$i'tray end'
  55. }
  56. }
  57. if (! ~ $#DUPLEX 0) {
  58. switch ($DUPLEX) {
  59. case 0;
  60. DUPLEX=false
  61. case 1;
  62. DUPLEX=true
  63. }
  64. PATCH=$PATCH'
  65. %%BeginFeature: *Set DuplexMode
  66. [{ systemdict /languagelevel known {languagelevel 1 gt product (HP LaserJet 4Si) ne and} if {
  67. << /Duplex '$DUPLEX' >> setpagedevice
  68. } {statusdict /setduplexmode known {statusdict begin '$DUPLEX' setduplexmode end} if} ifelse
  69. } stopped cleartomark
  70. %%EndFeature'
  71. }
  72. if (! ~ $#LAND 0 && ~ $LAND 1)
  73. LAND='-tlandscape'
  74. if (~ $LPCLASS *reverse*) {
  75. switch ($REVERSE) {
  76. case '';
  77. REVFLAG=1
  78. case 1;
  79. REVFLAG=''
  80. }
  81. }
  82. switch ($LPCLASS) {
  83. case *post100*;
  84. DPI='-Z -D100'
  85. case *600dpi*;
  86. DPI='-Z -D600'
  87. case *1200dpi*;
  88. DPI='-Z -D1200'
  89. case *;
  90. DPI=''
  91. }
  92. if (! ~ $COPIES '' -c*) COPIES=-c^$COPIES
  93. if (! ~ $OLIST '' '='*) OLIST=`{echo $OLIST | sed 's/-o/=/' | sed 's/-/:/g' }
  94. switch ($REVFLAG) {
  95. case 1;
  96. echo $PATCH
  97. switch ($OLIST) {
  98. case '';
  99. eval dvips -q -f $DPI -r $LAND $COPIES $1
  100. case *;
  101. DVIFILE=/tmp/dv$pid.dvi
  102. dviselect -s $OLIST $1 > $DVIFILE
  103. eval dvips -q -f $DPI -r $LAND $COPIES $DVIFILE
  104. rm -f $DVIFILE
  105. }
  106. $LPLIB/process/hpost </dev/null
  107. case '';
  108. $LPLIB/process/hpost </dev/null
  109. echo $PATCH
  110. switch ($OLIST) {
  111. case '';
  112. eval dvips -q -f $DPI $LAND $COPIES $1
  113. case *;
  114. DVIFILE=/tmp/dv$pid.dvi
  115. dviselect -s $OLIST $1 > $DVIFILE
  116. eval dvips -q -f $DPI $LAND $COPIES $DVIFILE
  117. rm -f $DVIFILE
  118. }
  119. }
  120. exit