1
0

gs_statd.ps 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. % Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This software is provided AS-IS with no warranty, either express or
  4. % implied.
  5. %
  6. % This software is distributed under license and may not be copied,
  7. % modified or distributed except as expressly authorized under the terms
  8. % of the license contained in the file LICENSE in this distribution.
  9. %
  10. % For more information about licensing, please refer to
  11. % http://www.ghostscript.com/licensing/. For information on
  12. % commercial licensing, go to http://www.artifex.com/licensing/ or
  13. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  14. % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  15. % $Id: gs_statd.ps,v 1.14 2003/12/17 09:45:58 ray Exp $
  16. % This file provides statusdict, serverdict, and assorted LaserWriter
  17. % operators, mostly for the benefit of poorly designed PostScript programs
  18. % that 'know' they are running on a LaserWriter.
  19. systemdict begin
  20. % We make statusdict a little larger for Level 2 stuff.
  21. % Note that it must be allocated in local VM.
  22. .currentglobal false .setglobal
  23. /statusdict 89 dict .forcedef % statusdict is local, sys'dict global
  24. % To support the Level 2 job control features,
  25. % serverdict must also be in local VM.
  26. /serverdict 10 dict .forcedef % serverdict is local, sys'dict global
  27. .setglobal
  28. end
  29. % Define various paper formats. The Adobe documentation defines only these:
  30. % 11x17, a3, a4, a4small, b5, ledger, legal, letter, lettersmall, note.
  31. % These procedures are also accessed as data structures during initialization,
  32. % so the page dimensions must be the first two elements of the procedure.
  33. /.setpagesize { /statusdict .systemvar begin .setpagesize end } bind def
  34. userdict begin
  35. % Page sizes defined by Adobe documentation
  36. % Note: these executable arrays should all begin with two
  37. % integers which are the width and height (see gs_setpd.ps).
  38. /11x17 {792 1224 //.setpagesize exec} bind def % 11x17 portrait
  39. /a3 {842 1191 //.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 {2384 3370 //.setpagesize exec} bind def
  57. /a1 {1684 2384 //.setpagesize exec} bind def
  58. /a2 {1191 1684 //.setpagesize exec} bind def
  59. % /a3 {842 1191 //.setpagesize exec} bind def % defined by Adobe
  60. % /a4 {595 842 //.setpagesize exec} bind def % defined by Adobe
  61. /a5 {420 595 //.setpagesize exec} bind def
  62. /a6 {297 420 //.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 {73 105 //.setpagesize exec} bind def
  67. % ISO and JIS B sizes are different....
  68. /isob0 {2835 4008 //.setpagesize exec} bind def
  69. /b0 /isob0 load def
  70. /isob1 {2004 2835 //.setpagesize exec} bind def
  71. /b1 /isob1 load def
  72. /isob2 {1417 2004 //.setpagesize exec} bind def
  73. /b2 /isob2 load def
  74. /isob3 {1001 1417 //.setpagesize exec} bind def
  75. /b3 /isob3 load def
  76. /isob4 {709 1001 //.setpagesize exec} bind def
  77. /b4 /isob4 load def
  78. /isob5 {499 709 //.setpagesize exec} bind def
  79. /b5 /isob5 load def
  80. /isob6 {354 499 //.setpagesize exec} bind def
  81. /b6 /isob6 load def
  82. /jisb0 {2920 4127 //.setpagesize exec} bind def
  83. /jisb1 {2064 2920 //.setpagesize exec} bind def
  84. /jisb2 {1460 2064 //.setpagesize exec} bind def
  85. /jisb3 {1032 1460 //.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 {2599 3677 //.setpagesize exec} bind def
  90. /c1 {1837 2599 //.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. % minimum of a4 and letter (a4 width, letter length)
  107. /pa4 {595 792 //.setpagesize exec} bind def
  108. % /tabloid {792 1224 //.setpagesize exec} bind def % 11x17 portrait
  109. % /csheet {1224 1584 //.setpagesize exec} bind def % ANSI C 17x22
  110. % /dsheet {1584 2448 //.setpagesize exec} bind def % ANSI D 22x34
  111. % /esheet {2448 3168 //.setpagesize exec} bind def % ANSI E 34x44
  112. %END SIZES
  113. end
  114. currentdict /.setpagesize .undef
  115. statusdict begin
  116. % Define the pagetype values for the known page formats.
  117. % The values for all but letter and note are arbitrary.
  118. /.pagetypenames
  119. [ /letter /note %do not change this line, needed by 'setpagetype'
  120. /legal /lettersmall
  121. /11x17 /ledger
  122. /a4small /a3 /a4
  123. STRICT { (%END SIZES) .skipeof } if
  124. /a0 /a1 /a2 /a5 /a6 /a7 /a8 /a9 /a10
  125. /archA /archB /archC /archD /archE
  126. /b0 /b1 /b2 /b3 /b4 /b5 /b6
  127. /c0 /c1 /c2 /c3 /c4 /c5 /c6
  128. /flsa /flse /halfletter
  129. /isob0 /isob1 /isob2 /isob3 /isob4 /isob5 /isob6
  130. /jisb0 /jisb1 /jisb2 /jisb3 /jisb4 /jisb5 /jisb6
  131. /pa4
  132. %END SIZES
  133. ] cvlit readonly def
  134. %%%%%% The following items were suggested by a user as useful.
  135. % Permanent definitions
  136. /ramsize 4194304 def
  137. /hardwareiomode 0 def
  138. /sethardwareiomode {pop} bind def
  139. /softwareiomode 0 def
  140. /setsoftwareiomode {pop} bind def
  141. /dosysstart false def
  142. /setdosysstart {pop} bind def
  143. /allowjobreset true def
  144. /setallowjobreset {pop} bind def
  145. /defaultpaperfamily 0 def
  146. /setdefaultpaperfamily {pop} bind def
  147. /defaultpapertray 0 def
  148. /setdefaultpapertray {pop} bind def
  149. /defaulttrayswitch false def
  150. /setdefaulttrayswitch {pop} bind def
  151. % Tray and format selection
  152. /11x17tray {/11x17 .uservar exec} bind def
  153. /a3tray {/a3 .uservar exec} bind def
  154. /a4tray {/a4 .uservar exec} bind def
  155. /a5tray {/a5 .uservar exec} bind def
  156. /a6tray {/a6 .uservar exec} bind def
  157. /b4tray {/b4 .uservar exec} bind def
  158. /b5tray {/b5 .uservar exec} bind def
  159. /flsatray {/flsa .uservar exec} bind def
  160. /flsetray {/flse .uservar exec} bind def
  161. /halflettertray {/halfletter .uservar exec} bind def
  162. /ledgertray {/ledger .uservar exec} bind def
  163. /legaltray {/legal .uservar exec} bind def
  164. /lettertray {/letter .uservar exec} bind def
  165. % Per-job parameters
  166. /paperfamily 0 def % 0 is US, 1 is European
  167. /papertray 1 def
  168. /setpapertray {statusdict exch /papertray exch put} bind def
  169. /trayswitch false def % paperout feeds from another tray
  170. % We don't implement the (undocumented by Adobe) papersize 'operator',
  171. % because it's very awkward to make it interact properly with all the
  172. % different ways of setting the paper size.
  173. %/papersize {/letter true} bind def % <name of paper size>, <short-edge-first-p>
  174. /appletalktype (LaserWriter) def
  175. %%%%%% The following items are defined in the PostScript Language
  176. %%%%%% Reference Manual, First Edition, and subsequent 'compatibility'
  177. %%%%%% documentation from Adobe.
  178. /checkpassword {statusdict begin .password eq end} bind def
  179. /defaulttimeouts {statusdict begin .timeouts aload pop end} bind def
  180. /diskonline {
  181. false (%disk*%) { pop not exit } 8192 string /IODevice resourceforall
  182. } bind def
  183. /diskstatus {10240 2097152 } bind odef % - diskstatus <free> <total> (in 1024 byte pages)
  184. %/dostartpage
  185. /eescratch {pop 0} bind def
  186. /idlefonts {statusdict begin mark .idlefonts aload pop end} bind def
  187. /jobname () def
  188. %/jobtimeout
  189. /manualfeed false def
  190. /manualfeedtimeout 60 def
  191. /margins {statusdict begin .topmargin .leftmargin end} bind def
  192. /pagecount {4711} bind def
  193. /pagestackorder {false} bind def
  194. /pagetype 0 def
  195. /prefeed false def
  196. /printererror {pop pop} bind def
  197. /printername {statusdict /.printername get exch copy} bind def
  198. /processcolors /processcolors load def % defined in systemdict
  199. /product product def % product is defined in systemdict
  200. /revision revision def % revision is defined in systemdict
  201. /sccbatch {pop 9600 0} bind def
  202. /sccinteractive {pop 9600 0} bind def
  203. /setdefaulttimeouts {statusdict begin .timeouts astore pop end} bind def
  204. /setdostartpage {statusdict exch /dostartpage exch put} bind def
  205. /setduplexmode {mark /Duplex 3 -1 roll currentdevice putdeviceprops} bind def
  206. /seteescratch {pop pop} bind def
  207. /setidlefonts {] statusdict exch /.idlefonts exch put} bind def
  208. /setjobtimeout {statusdict exch /jobtimeout exch put} bind def
  209. /setmargins
  210. { statusdict begin
  211. /.leftmargin exch def /.topmargin exch def
  212. end
  213. } bind def
  214. % The following compatibility operators are only documented by Adobe in a
  215. % supplement to the Red Book.
  216. %
  217. % - pagemargin <offset>
  218. % - pageparams <width> <height> <offset> <orientation>
  219. % <width> <height> <orientation> setpage -
  220. % <offset> setpagemargin -
  221. % <width> <height> <offset> <orientation> setpageparams -
  222. %
  223. % width and height are in default units (and if orientation is odd, are
  224. % exchanged!). offset is the x margin, also in default units.
  225. % Unfortunately, because orientation is relative to the device paper feed,
  226. % it does not have a consistent meaning in terms of image orientation.
  227. % We follow the convention that ORIENT1 determines the orientation value
  228. % that means portait: false means 0, true means 1.
  229. /pagemargin { 0 } bind def
  230. /pageparams
  231. { currentdevice 1 dict dup /.MediaSize dup put .getdeviceparams
  232. exch pop exch pop aload pop 0 ORIENT1 { 1 } { 0 } ifelse
  233. } bind def
  234. /setpage
  235. { ORIENT1 { 1 } { 0 } ifelse ne {exch} if
  236. statusdict /.setpagesize get exec
  237. } bind def
  238. /setpagemargin {pop} bind def % can't do better without setpagedevice
  239. /setpageparams
  240. { exch pop ORIENT1 { 1 } { 0 } ifelse ne {exch} if
  241. statusdict /.setpagesize get exec
  242. } bind def
  243. /setpagetype
  244. { statusdict begin
  245. % The Adobe documentation only defines setpagetype
  246. % (a Level 1 operator) as accepting the values 0 and 1,
  247. % so we do too.
  248. dup .pagetypenames 0 2 getinterval exch get
  249. //systemdict /userdict get exch get cvx exec
  250. /pagetype exch def
  251. end
  252. } bind def
  253. /setpassword
  254. {exch checkpassword
  255. {statusdict exch /.password exch put true}
  256. {pop false}
  257. ifelse} bind def
  258. /setprintername
  259. {dup length string copy statusdict exch /.printername exch put} bind def
  260. % setresolution is not documented by Adobe, but some applications
  261. % use it anyway, without testing whether or not it is present.
  262. %
  263. % <pixels_per_inch> setresolution -
  264. %
  265. % sets the resolution of the device.
  266. /setresolution
  267. { mark /HWResolution [ 4 -1 roll dup ] currentdevice putdeviceprops pop
  268. initmatrix erasepage
  269. } bind def
  270. /setsccbatch {pop pop pop} bind def
  271. /setsccinteractive {pop pop pop} bind def
  272. /settumble {pop} bind def
  273. /waittimeout 300 def
  274. %%%%%% End of documented items.
  275. /.setpagesize
  276. { mark /HWSize [
  277. 4 index 4 index matrix defaultmatrix dtransform
  278. abs ceiling cvi exch abs ceiling cvi exch
  279. ] currentdevice putdeviceprops pop pop pop
  280. initmatrix initclip erasepage
  281. } bind def
  282. /.password 0 def
  283. /.timeouts [0 60 30] def
  284. true setdostartpage
  285. mark setidlefonts
  286. 0 setjobtimeout
  287. 0 0 setmargins
  288. product setprintername
  289. end % statusdict
  290. %%%%%% The following documented compatibility "operators" are in systemdict,
  291. %%%%%% not in statusdict.
  292. systemdict begin
  293. .currentglobal true .setglobal
  294. /devformat true def
  295. /devforall { % <pattern> <proc> <scratch> devforall -
  296. exch {
  297. 1 index currentdevparams
  298. /Type .knownget { /FileSystem eq } { false } ifelse
  299. { exec } { pop pop } ifelse
  300. } /exec load 3 packedarray cvx exch
  301. (*) 3 1 roll /IODevice resourceforall
  302. } odef
  303. /devstatus { % <(%disk*%)> devstatus <searchable> <writable>
  304. % <hasNames> <mounted> <removable> <searchOrder>
  305. % <freePages> <size> true
  306. % <string> devstatus false
  307. dup length 5 ge {
  308. dup 0 5 getinterval (%disk) eq {
  309. dup /IODevice resourcestatus {
  310. pop pop dup currentdevparams
  311. dup /Searchable get
  312. exch dup /Writeable get
  313. exch dup /HasNames get
  314. exch dup /Mounted get
  315. exch dup /Removable get
  316. exch dup /SearchOrder get
  317. exch dup /Free get
  318. exch /LogicalSize get
  319. 9 -1 roll pop true
  320. } {
  321. pop false
  322. } ifelse
  323. } {
  324. pop false
  325. } ifelse
  326. } {
  327. pop false
  328. } ifelse
  329. } odef
  330. .setglobal end % systemdict
  331. % The following contents of serverdict are a complete guess,
  332. % based on some observed LaserWriter boilerplate.
  333. serverdict begin
  334. /execjob { } bind def
  335. % The Red Book implies that something like the following is
  336. % an appropriate definition of exitserver.
  337. /exitserver { clear stop } bind def
  338. % However, this interacts badly with our standard error handler,
  339. % so we override it with the following less appropriate definition.
  340. /exitserver { 0 ne { clear cleardictstack } if } bind def
  341. /setrealdevice { } bind def
  342. end % serverdict