gs_statd.ps 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. % Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This file is part of AFPL Ghostscript.
  4. %
  5. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  6. % distributor accepts any responsibility for the consequences of using it, or
  7. % for whether it serves any particular purpose or works at all, unless he or
  8. % she says so in writing. Refer to the Aladdin Free Public License (the
  9. % "License") for full details.
  10. %
  11. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  12. % in a plain ASCII text file named PUBLIC. The License grants you the right
  13. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14. % conditions described in the License. Among other things, the License
  15. % requires that the copyright notice and this notice be preserved on all
  16. % copies.
  17. % $Id: gs_statd.ps,v 1.5 2001/05/30 21:14:35 rayjj Exp $
  18. % This file provides statusdict, serverdict, and assorted LaserWriter
  19. % operators, mostly for the benefit of poorly designed PostScript programs
  20. % that 'know' they are running on a LaserWriter.
  21. systemdict begin
  22. % We make statusdict a little larger for Level 2 stuff.
  23. % Note that it must be allocated in local VM.
  24. .currentglobal false .setglobal
  25. /statusdict 89 dict .forcedef % statusdict is local, sys'dict global
  26. % To support the Level 2 job control features,
  27. % serverdict must also be in local VM.
  28. /serverdict 10 dict .forcedef % serverdict is local, sys'dict global
  29. .setglobal
  30. end
  31. % Define various paper formats. The Adobe documentation defines only these:
  32. % 11x17, a3, a4, a4small, b5, ledger, legal, letter, lettersmall, note.
  33. % These procedures are also accessed as data structures during initialization,
  34. % so the page dimensions must be the first two elements of the procedure.
  35. /.setpagesize { /statusdict .systemvar begin .setpagesize end } bind def
  36. userdict begin
  37. % Page sizes defined by Adobe documentation
  38. /11x17 {792 1224 //.setpagesize exec} bind def % 11x17 portrait
  39. /a3 {842 1190 //.setpagesize exec} bind def
  40. /a4 {595 842 //.setpagesize exec} bind def
  41. % a4small should be a4 with an ImagingBBox of [25 25 570 817].
  42. /a4small /a4 load def
  43. % b5 see below.
  44. /ledger {1224 792 //.setpagesize exec} bind def % 11x17 landscape
  45. /legal {612 1008 //.setpagesize exec} bind def
  46. /letter {612 792 //.setpagesize exec} bind def
  47. % lettersmall should be letter with an ImagingBBox of [25 25 587 767].
  48. /lettersmall /letter load def
  49. % note should be letter (or some other size) with the ImagingBBox
  50. % shrunk by 25 units on all 4 sides.
  51. /note /letter load def
  52. % End of Adobe-defined page sizes
  53. STRICT { (%END SIZES) .skipeof } if
  54. % Other page sizes
  55. % ISO standard paper sizes
  56. /a0 {2380 3368 //.setpagesize exec} bind def
  57. /a1 {1684 2380 //.setpagesize exec} bind def
  58. /a2 {1190 1684 //.setpagesize exec} bind def
  59. % /a3 {842 1190 //.setpagesize exec} bind def % defined by Adobe
  60. % /a4 {595 842 //.setpagesize exec} bind def % defined by Adobe
  61. /a5 {421 595 //.setpagesize exec} bind def
  62. /a6 {297 421 //.setpagesize exec} bind def
  63. /a7 {210 297 //.setpagesize exec} bind def
  64. /a8 {148 210 //.setpagesize exec} bind def
  65. /a9 {105 148 //.setpagesize exec} bind def
  66. /a10 {74 105 //.setpagesize exec} bind def
  67. % ISO and JIS B sizes are different....
  68. /isob0 {2836 4008 //.setpagesize exec} bind def
  69. /b0 /isob0 load def
  70. /isob1 {2004 2836 //.setpagesize exec} bind def
  71. /b1 /isob1 load def
  72. /isob2 {1418 2004 //.setpagesize exec} bind def
  73. /b2 /isob2 load def
  74. /isob3 {1002 1418 //.setpagesize exec} bind def
  75. /b3 /isob3 load def
  76. /isob4 {709 1002 //.setpagesize exec} bind def
  77. /b4 /isob4 load def
  78. /isob5 {501 709 //.setpagesize exec} bind def
  79. /b5 /isob5 load def
  80. /isob6 {354 501 //.setpagesize exec} bind def
  81. /b6 /isob6 load def
  82. /jisb0 {2916 4128 //.setpagesize exec} bind def
  83. /jisb1 {2064 2916 //.setpagesize exec} bind def
  84. /jisb2 {1458 2064 //.setpagesize exec} bind def
  85. /jisb3 {1032 1458 //.setpagesize exec} bind def
  86. /jisb4 {729 1032 //.setpagesize exec} bind def
  87. /jisb5 {516 729 //.setpagesize exec} bind def
  88. /jisb6 {363 516 //.setpagesize exec} bind def
  89. /c0 {2600 3677 //.setpagesize exec} bind def
  90. /c1 {1837 2600 //.setpagesize exec} bind def
  91. /c2 {1298 1837 //.setpagesize exec} bind def
  92. /c3 {918 1298 //.setpagesize exec} bind def
  93. /c4 {649 918 //.setpagesize exec} bind def
  94. /c5 {459 649 //.setpagesize exec} bind def
  95. /c6 {323 459 //.setpagesize exec} bind def
  96. % U.S. CAD standard paper sizes
  97. /archE {2592 3456 //.setpagesize exec} bind def
  98. /archD {1728 2592 //.setpagesize exec} bind def
  99. /archC {1296 1728 //.setpagesize exec} bind def
  100. /archB {864 1296 //.setpagesize exec} bind def
  101. /archA {648 864 //.setpagesize exec} bind def
  102. % Other paper sizes
  103. /flsa {612 936 //.setpagesize exec} bind def % U.S. foolscap
  104. /flse {612 936 //.setpagesize exec} bind def % European foolscap
  105. /halfletter {396 612 //.setpagesize exec} bind def
  106. % /tabloid {792 1224 //.setpagesize exec} bind def % 11x17 portrait
  107. % /csheet {1224 1584 //.setpagesize exec} bind def % ANSI C 17x22
  108. % /dsheet {1584 2448 //.setpagesize exec} bind def % ANSI D 22x34
  109. % /esheet {2448 3168 //.setpagesize exec} bind def % ANSI E 34x44
  110. %END SIZES
  111. end
  112. currentdict /.setpagesize .undef
  113. statusdict begin
  114. % Define the pagetype values for the known page formats.
  115. % The values for all but letter and note are arbitrary.
  116. /.pagetypenames
  117. { /letter /note %do not change this line, needed by 'setpagetype'
  118. /legal /lettersmall
  119. /11x17 /ledger
  120. /a4small /a3 /a4
  121. STRICT { (%END SIZES) .skipeof } if
  122. /a0 /a1 /a2 /a5 /a6 /a7 /a8 /a9 /a10
  123. /archA /archB /archC /archD /archE
  124. /b0 /b1 /b2 /b3 /b4 /b5 /b6
  125. /c0 /c1 /c2 /c3 /c4 /c5 /c6
  126. /flsa /flse /halfletter
  127. /isob0 /isob1 /isob2 /isob3 /isob4 /isob5 /isob6
  128. /jisb0 /jisb1 /jisb2 /jisb3 /jisb4 /jisb5 /jisb6
  129. %END SIZES
  130. } cvlit readonly def
  131. %%%%%% The following items were suggested by a user as useful.
  132. % Permanent definitions
  133. /ramsize 4194304 def
  134. /hardwareiomode 0 def
  135. /sethardwareiomode {pop} bind def
  136. /softwareiomode 0 def
  137. /setsoftwareiomode {pop} bind def
  138. /dosysstart false def
  139. /setdosysstart {pop} bind def
  140. /allowjobreset true def
  141. /setallowjobreset {pop} bind def
  142. /defaultpaperfamily 0 def
  143. /setdefaultpaperfamily {pop} bind def
  144. /defaultpapertray 0 def
  145. /setdefaultpapertray {pop} bind def
  146. /defaulttrayswitch false def
  147. /setdefaulttrayswitch {pop} bind def
  148. % Tray and format selection
  149. /11x17tray {/11x17 .uservar exec} bind def
  150. /a3tray {/a3 .uservar exec} bind def
  151. /a4tray {/a4 .uservar exec} bind def
  152. /a5tray {/a5 .uservar exec} bind def
  153. /a6tray {/a6 .uservar exec} bind def
  154. /b4tray {/b4 .uservar exec} bind def
  155. /b5tray {/b5 .uservar exec} bind def
  156. /flsatray {/flsa .uservar exec} bind def
  157. /flsetray {/flse .uservar exec} bind def
  158. /halflettertray {/halfletter .uservar exec} bind def
  159. /ledgertray {/ledger .uservar exec} bind def
  160. /legaltray {/legal .uservar exec} bind def
  161. /lettertray {/letter .uservar exec} bind def
  162. % Per-job parameters
  163. /paperfamily 0 def % 0 is US, 1 is European
  164. /papertray 1 def
  165. /setpapertray {statusdict exch /papertray exch put} bind def
  166. /trayswitch false def % paperout feeds from another tray
  167. % We don't implement the (undocumented by Adobe) papersize 'operator',
  168. % because it's very awkward to make it interact properly with all the
  169. % different ways of setting the paper size.
  170. %/papersize {/letter true} bind def % <name of paper size>, <short-edge-first-p>
  171. /appletalktype (LaserWriter) def
  172. %%%%%% The following items are defined in the PostScript Language
  173. %%%%%% Reference Manual, First Edition, and subsequent 'compatibility'
  174. %%%%%% documentation from Adobe.
  175. /checkpassword {statusdict begin .password eq end} bind def
  176. /defaulttimeouts {statusdict begin .timeouts aload pop end} bind def
  177. /diskonline {
  178. false (%disk*%) { pop not exit } 100 string /IODevice resourceforall
  179. } bind def
  180. %/dostartpage
  181. /eescratch {pop 0} bind def
  182. /idlefonts {statusdict begin mark .idlefonts aload pop end} bind def
  183. /jobname () def
  184. %/jobtimeout
  185. /manualfeed false def
  186. /manualfeedtimeout 60 def
  187. /margins {statusdict begin .topmargin .leftmargin end} bind def
  188. /pagecount {4711} bind def
  189. /pagestackorder {false} bind def
  190. /pagetype 0 def
  191. /prefeed false def
  192. /printererror {pop pop} bind def
  193. /printername {statusdict /.printername get exch copy} bind def
  194. /processcolors /processcolors load def % defined in systemdict
  195. /product product def % product is defined in systemdict
  196. /revision revision def % revision is defined in systemdict
  197. /sccbatch {pop 9600 0} bind def
  198. /sccinteractive {pop 9600 0} bind def
  199. /setdefaulttimeouts {statusdict begin .timeouts astore pop end} bind def
  200. /setdostartpage {statusdict exch /dostartpage exch put} bind def
  201. /setduplexmode {mark /Duplex 3 -1 roll currentdevice putdeviceprops} bind def
  202. /seteescratch {pop pop} bind def
  203. /setidlefonts {] statusdict exch /.idlefonts exch put} bind def
  204. /setjobtimeout {statusdict exch /jobtimeout exch put} bind def
  205. /setmargins
  206. { statusdict begin
  207. /.leftmargin exch def /.topmargin exch def
  208. end
  209. } bind def
  210. % The following compatibility operators are only documented by Adobe in a
  211. % supplement to the Red Book.
  212. %
  213. % - pagemargin <offset>
  214. % - pageparams <width> <height> <offset> <orientation>
  215. % <width> <height> <orientation> setpage -
  216. % <offset> setpagemargin -
  217. % <width> <height> <offset> <orientation> setpageparams -
  218. %
  219. % width and height are in default units (and if orientation is odd, are
  220. % exchanged!). offset is the x margin, also in default units.
  221. % Unfortunately, because orientation is relative to the device paper feed,
  222. % it does not have a consistent meaning in terms of image orientation.
  223. % We follow the convention that ORIENT1 determines the orientation value
  224. % that means portait: false means 0, true means 1.
  225. /pagemargin { 0 } bind def
  226. /pageparams
  227. { currentdevice 1 dict dup /.MediaSize dup put .getdeviceparams
  228. exch pop exch pop aload pop 0 ORIENT1 { 1 } { 0 } ifelse
  229. } bind def
  230. /setpage
  231. { ORIENT1 { 1 } { 0 } ifelse ne {exch} if
  232. statusdict /.setpagesize get exec
  233. } bind def
  234. /setpagemargin {pop} bind def % can't do better without setpagedevice
  235. /setpageparams
  236. { exch pop ORIENT1 { 1 } { 0 } ifelse ne {exch} if
  237. statusdict /.setpagesize get exec
  238. } bind def
  239. /setpagetype
  240. { statusdict begin
  241. % The Adobe documentation only defines setpagetype
  242. % (a Level 1 operator) as accepting the values 0 and 1,
  243. % so we do too.
  244. dup .pagetypenames 0 2 getinterval exch get //systemdict exch get exec
  245. /pagetype exch def
  246. end
  247. } bind def
  248. /setpassword
  249. {exch checkpassword
  250. {statusdict exch /.password exch put true}
  251. {pop false}
  252. ifelse} bind def
  253. /setprintername
  254. {dup length string copy statusdict exch /.printername exch put} bind def
  255. % setresolution is not documented by Adobe, but some applications
  256. % use it anyway, without testing whether or not it is present.
  257. %
  258. % <pixels_per_inch> setresolution -
  259. %
  260. % sets the resolution of the device.
  261. /setresolution
  262. { mark /HWResolution [ 4 -1 roll dup ] currentdevice putdeviceprops pop
  263. initmatrix erasepage
  264. } bind def
  265. /setsccbatch {pop pop pop} bind def
  266. /setsccinteractive {pop pop pop} bind def
  267. /settumble {pop} bind def
  268. /waittimeout 300 def
  269. %%%%%% End of documented items.
  270. /.setpagesize
  271. { mark /HWSize [
  272. 4 index 4 index matrix defaultmatrix dtransform
  273. abs ceiling cvi exch abs ceiling cvi exch
  274. ] currentdevice putdeviceprops pop pop pop
  275. initmatrix initclip erasepage
  276. } bind def
  277. /.password 0 def
  278. /.timeouts [0 60 30] def
  279. true setdostartpage
  280. mark setidlefonts
  281. 0 setjobtimeout
  282. 0 0 setmargins
  283. product setprintername
  284. end % statusdict
  285. %%%%%% The following documented compatibility "operators" are in systemdict,
  286. %%%%%% not in statusdict.
  287. systemdict begin
  288. .currentglobal true .setglobal
  289. /devforall { % <pattern> <proc> <scratch> devforall -
  290. exch {
  291. 1 index currentdevparams
  292. /Type .knownget { /FileSystem eq } { false } ifelse
  293. { exec } { pop pop } ifelse
  294. } /exec load 3 packedarray cvx exch
  295. (*) 3 1 roll /IODevice resourceforall
  296. } odef
  297. /devstatus { % <(%disk*%)> devstatus <searchable> <writable>
  298. % <hasNames> <mounted> <removable> <searchOrder>
  299. % <freePages> <size> true
  300. % <string> devstatus false
  301. dup length 5 ge {
  302. dup 0 5 getinterval (%disk) eq {
  303. dup /IODevice resourcestatus {
  304. pop pop dup currentdevparams
  305. dup /Searchable get
  306. exch dup /Writeable get
  307. exch dup /HasNames get
  308. exch dup /Mounted get
  309. exch dup /Removable get
  310. exch dup /SearchOrder get
  311. exch dup /Free get
  312. exch /LogicalSize get
  313. 9 -1 roll pop true
  314. } {
  315. pop false
  316. } ifelse
  317. } {
  318. pop false
  319. } ifelse
  320. } {
  321. pop false
  322. } ifelse
  323. } odef
  324. .setglobal end % systemdict
  325. % The following contents of serverdict are a complete guess,
  326. % based on some observed LaserWriter boilerplate.
  327. serverdict begin
  328. /execjob { } bind def
  329. % The Red Book implies that something like the following is
  330. % an appropriate definition of exitserver.
  331. /exitserver { clear stop } bind def
  332. % However, this interacts badly with our standard error handler,
  333. % so we override it with the following less appropriate definition.
  334. /exitserver { 0 ne { clear cleardictstack } if } bind def
  335. /setrealdevice { } bind def
  336. end % serverdict