home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / GhostScript / !GhostScr / 6_01 / lib / gs_statd.ps < prev    next >
Text File  |  2000-03-09  |  13KB  |  359 lines

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