Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

244 lines
5.4 KiB

  1. BEGIN {
  2. model=ARGV[1]
  3. ARGV[1]=""
  4. rate=ARGV[2]
  5. ARGV[2]=""
  6. options=ARGV[3]
  7. ARGV[3]=""
  8. custom=(ARGV[4] == "." ? "" : ARGV[4])
  9. ARGV[4]=""
  10. print "*%"
  11. print "*% Copyright (c) 1997 - 2000 Microsoft Corporation"
  12. print "*% All Rights Reserved."
  13. print "*%"
  14. }
  15. /^\*GPDFileVersion/ { print "*CodePage: 1252" }
  16. /^\*ModelName/ { gsub(/LIPS/, model) }
  17. /^\*PrinterType/ {
  18. if (color ~ /color/)
  19. print "*PrinterType: SERIAL"
  20. else
  21. print "*PrinterType: PAGE"
  22. print "*PrintRate: " rate
  23. print "*PrintRateUnit: PPM"
  24. next
  25. }
  26. /\*Feature.*Duplex/ {
  27. if (options ~ /G/) {
  28. print "*Feature: DuplexUnit"
  29. print "{"
  30. print " *FeatureType: PRINTER_PROPERTY"
  31. print " *rcNameID: 325"
  32. print " *DefaultOption: NotInstalled"
  33. print " *Option: NotInstalled"
  34. print " {"
  35. print " *rcNameID: 326"
  36. print " *DisabledFeatures: LIST(Duplex)"
  37. print " *Constraints: LIST(Duplex.VERTICAL, Duplex.HORIZONTAL)"
  38. print " }"
  39. print " *Option: Installed"
  40. print " {"
  41. print " *rcNameID: 327"
  42. print " }"
  43. print "}"
  44. } else if (options !~ /D/) {
  45. print "*Feature: DuplexUnit"
  46. print "{"
  47. print " *FeatureType: PRINTER_PROPERTY"
  48. print " *rcNameID: 292"
  49. print " *DefaultOption: NotInstalled"
  50. print " *Option: NotInstalled"
  51. print " {"
  52. print " *rcNameID: 291"
  53. print " *DisabledFeatures: LIST(Duplex)"
  54. print " *Constraints: LIST(Duplex.VERTICAL, Duplex.HORIZONTAL)"
  55. print " }"
  56. print " *Option: Installed"
  57. print " {"
  58. print " *rcNameID: 290"
  59. print " }"
  60. print "}"
  61. }
  62. }
  63. /\*Feature/ {
  64. feature=$2
  65. if (feature ~ /InputBin/ && custom) {
  66. putcustom(custom, feature)
  67. skipblock=1
  68. next
  69. }
  70. }
  71. /\*Command.*CmdSendBlockData/ {
  72. print " *Command: CmdSendBlockData"
  73. print " {"
  74. print " *CallbackID: 7"
  75. print " *Params: LIST(NumOfDataBytes, RasterDataHeightInPixels, RasterDataWidthInBytes)"
  76. print " }"
  77. next
  78. }
  79. /\*Command.*CmdStartDoc/ { gsub(/StartDoc/, "StartJob") }
  80. /\*Command.*CmdStartPage/ {
  81. print "*Command: CmdStartDoc"
  82. print "{"
  83. print " *Order: DOC_SETUP.6"
  84. print " *CallbackID: 130"
  85. print "}"
  86. }
  87. /\*Command.*CmdSetSimpleRotation/ {
  88. print "*Command: CmdSetSimpleRotation"
  89. print "{"
  90. print " *CallbackID: 4"
  91. print " *Params: LIST(PrintDirInCCDegrees)"
  92. print "}"
  93. next
  94. }
  95. /\*Command.*CmdCopies/ {
  96. if (options ~ /C/) {
  97. print "*Command: CmdCopies"
  98. print "{"
  99. print " *Order: JOB_SETUP.10"
  100. print " *CallbackID: 465"
  101. print " *Params: LIST(NumOfCopies)"
  102. print "}"
  103. skipblock=1
  104. }
  105. }
  106. /\*Command.*Cmd.Move/ {
  107. print $1 " " $2
  108. print $3
  109. print " " $4 " " $5
  110. if ($2 ~ /CmdXMoveAbsolute/)
  111. p="DestX"
  112. else if ($2 ~ /CmdXMoveRelRight/)
  113. p="DestXRel"
  114. else if ($2 ~ /CmdYMoveAbsolute/)
  115. p="DestY"
  116. else if ($2 ~ /CmdYMoveRelDown/)
  117. p="DestYRel"
  118. else {
  119. print "*Error: unrecognized command name"
  120. p="???"
  121. }
  122. print " *Params: LIST(" p ")"
  123. print $6
  124. next
  125. }
  126. /\*Command/ { command=$2 }
  127. /\*Order/ {
  128. if (feature ~ /(Resolution|PrintQuality|ImageControl|PrintDensity)/)
  129. gsub(/DOC_SETUP/, "JOB_SETUP")
  130. else if (command ~ /CmdStartJob/)
  131. gsub(/DOC_SETUP../, "JOB_SETUP.12")
  132. }
  133. /\*Cmd/ {
  134. if (command ~ /CmdCopies/)
  135. gsub(/%d/, "%d[1,255]")
  136. }
  137. /\*rcNameID:.[0-9]/ {
  138. if ($2 >= 283)
  139. gsub(/[0-9][0-9][0-9]/, $2 - 5)
  140. }
  141. /\*rcCartridgeNameID/ {
  142. if ($2 ~ /278/)
  143. gsub(/278/, "293")
  144. else if ($2 ~ /279/)
  145. gsub(/279/, "294")
  146. else if ($2 ~ /280/)
  147. gsub(/280/, "295")
  148. else if ($2 ~ /281/)
  149. gsub(/281/, "296")
  150. else if ($2 ~ /282/)
  151. gsub(/282/, "319")
  152. else
  153. print "*Error: unrecognized font ID"
  154. }
  155. /\*MinFontID/ || /\*MaxFontID/ || /\*MaxNumDownFonts/ || /\*FontFormat/ {
  156. gsub(/\*/, "*% ")
  157. }
  158. /\*CallbackID: (40|41)$/ {
  159. print
  160. print " *Params: LIST(PhysPaperWidth, PhysPaperLength)"
  161. next
  162. }
  163. /\*MasterUnits/ {
  164. print
  165. gsub(/[(,]/, " ")
  166. mu=$3
  167. next
  168. }
  169. /^}$/ {
  170. feature=""
  171. command=""
  172. if (skipblock) {
  173. skipblock=0
  174. next
  175. }
  176. }
  177. /\*Option/ { if (feature ~ /PaperSize/) option=$2 }
  178. /\*case/ { if (feature ~ /PaperSize/) case=$2 }
  179. /\*Command:.*CmdSelect/ {
  180. if (feature ~ /PaperSize/ && option ~ /CUSTOMSIZE/) {
  181. if (mu == 1200)
  182. m = 240
  183. else if (mu == 600)
  184. m = 120;
  185. else
  186. m = 72;
  187. print " *CustCursorOriginX: %d{" m "}"
  188. if (case ~ /PORTRAIT/)
  189. print " *CustCursorOriginY: %d{" m "}"
  190. else
  191. print " *CustCursorOriginY: %d{PhysPaperLength - " m "}"
  192. print " *CustPrintableOriginX: %d{" m "}"
  193. print " *CustPrintableOriginY: %d{" m "}"
  194. print " *CustPrintableSizeX: %d{PhysPaperWidth - " m * 2 "}"
  195. print " *CustPrintableSizeY: %d{PhysPaperLength - " m * 2 "}"
  196. }
  197. }
  198. /\*% Error/ { next }
  199. {
  200. if (!skipblock)
  201. print
  202. }
  203. END {
  204. if (options ~ /N/)
  205. putfile("nottfs.txt")
  206. else
  207. putfile("gpdadd.txt")
  208. if (options ~ /L/)
  209. putfile("collate.txt")
  210. if (custom)
  211. putcustom(custom, "END")
  212. }
  213. #
  214. # functions
  215. #
  216. function putfile(file) {
  217. while (getline < file > 0) {
  218. if ($0 !~ /^;/)
  219. print
  220. }
  221. close(file)
  222. }
  223. function putcustom(file, name, found) {
  224. found=0
  225. while (getline < file > 0) {
  226. if ($1 ~ /@@/ && $2 ~ name) {
  227. found=1
  228. break
  229. }
  230. }
  231. if (found) while (getline < file > 0) {
  232. if ($1 ~ /@@/)
  233. break
  234. else if ($0 !~ /^;/)
  235. print
  236. }
  237. close(file)
  238. }