home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / servis / ovladace / drivers / CPPLW9xNTgb.exe / CPP_L / Driver / GS_LEV2.PS < prev    next >
Encoding:
Text File  |  1995-11-15  |  9.0 KB  |  299 lines

  1. %    Copyright (C) 1990, 1995 Aladdin Enterprises.  All rights reserved.
  2. %    Licensed to Zenographics Inc. (Irvine, California) by Artifex Software Inc.
  3. %    under the OEM Agreement of December 21st, 1993.
  4.  
  5. % Initialization file for Level 2 functions.
  6. % When this is run, systemdict is still writable,
  7. % but (almost) everything defined here goes into level2dict.
  8.  
  9. level2dict begin
  10.  
  11. % ------ Miscellaneous ------ %
  12.  
  13. (<<) cvn /mark load def
  14. (>>) cvn /.dicttomark load odef
  15. /currentsystemparams { mark .currentsystemparams .dicttomark } odef
  16. /currentuserparams { mark .currentuserparams .dicttomark } odef
  17. /deviceinfo { currentdevice getdeviceprops .dicttomark } odef
  18. /languagelevel 2 def
  19. /realtime /usertime load def
  20. % When running in Level 2 mode, this interpreter is supposed to be
  21. % compatible with PostScript version 2010 (I think).
  22. /version (2010) def
  23.  
  24. % If binary tokens are supported by this interpreter,
  25. % set an appropriate default binary object format.
  26. /setobjectformat where
  27.  { pop
  28.    currentsystemparams dup
  29.    /RealFormat get (IEEE) eq { 1 } { 3 } ifelse
  30.    exch /ByteOrder get { 1 add } if
  31.    setobjectformat
  32.  } if
  33.  
  34. % ------ Virtual memory ------ %
  35.  
  36. /currentglobal /currentshared load def
  37. /gcheck /scheck load def
  38. /setglobal /setshared load def
  39. % We can make the global dictionaries very small, because they auto-expand.
  40. /globaldict currentdict /shareddict .knownget not { 4 dict } if def
  41. /GlobalFontDirectory SharedFontDirectory def
  42.  
  43. % ------ IODevices ------ %
  44.  
  45. /.getdevparams where
  46.  { pop /currentdevparams { .getdevparams .dicttomark } odef
  47.  } if
  48. /.putdevparams where
  49.  { pop /setdevparams { mark { } forall counttomark 2 add -1 roll .putdevparams } odef
  50.  } if
  51.  
  52. % ------ Job control ------ %
  53.  
  54. serverdict begin
  55.  
  56. % We could protect the job information better, but we aren't attempting
  57. % (currently) to protect ourselves against maliciousness.
  58.  
  59. /.jobsave null def        % top-level save object
  60. /.jobsavelevel 0 def        % save depth of job (0 if .jobsave is null,
  61.                 % 1 otherwise)
  62. /.adminjob true def        % status of current unencapsulated job
  63.  
  64. /exitserver
  65.  { true exch startjob not { /exitserver /invalidaccess signalerror } if
  66.  } bind def
  67.  
  68. end        % serverdict
  69.  
  70. %**************** The definition of startjob is not complete yet, since
  71. % it doesn't clear the exec stack, doesn't reset stdin/stdout,
  72. % doesn't run the job under its own control, and doesn't reset
  73. % other aspects of the interpreter.
  74. /startjob
  75.  { vmstatus pop pop serverdict /.jobsavelevel get eq
  76.    1 index .checkpassword 0 gt and
  77.     { .checkpassword count 2 roll count 2 sub { pop } repeat
  78.       cleardictstack
  79.       serverdict /.jobsave get dup null eq { pop } { restore } ifelse
  80.       exch
  81.        {    % unencapsulated job
  82.      serverdict /.jobsave null put
  83.      serverdict /.jobsavelevel 0 put
  84.      serverdict /.adminjob 3 -1 roll 1 gt put
  85.        }
  86.        {    % encapsulated job
  87.      serverdict /.jobsave save put
  88.      serverdict /.jobsavelevel 1 put
  89.      userdict /quit /stop load put
  90.      pop
  91.        }
  92.       ifelse true
  93.     }
  94.     { pop pop false
  95.     }
  96.    ifelse
  97.  } odef
  98.  
  99. systemdict begin
  100. /quit
  101.  { //systemdict /serverdict get /.jobsave get null eq
  102.     { //quit }
  103.     { //systemdict /quit get /invalidaccess signalerror }
  104.    ifelse
  105.  } bind odef
  106. end
  107.  
  108. % ------ Compatibility ------ %
  109.  
  110. % In Level 2 mode, the following replace the definitions that gs_statd.ps
  111. % installs in statusdict and serverdict.
  112. % Note that statusdict must be allocated in local VM.
  113. % We don't bother with many of these yet, and the ones defined in terms
  114. % of currentsystemparams are cavalier about allocating a dictionary
  115. % in order to retrieve a single element from it....
  116.  
  117. /.dict1 { exch mark 3 1 roll .dicttomark } bind def
  118.  
  119. currentglobal false setglobal 25 dict exch setglobal begin
  120. currentsystemparams
  121.  
  122. /buildtime 1 index /BuildTime get def
  123. /byteorder 1 index /ByteOrder get def
  124. /checkpassword { .checkpassword 0 gt } bind def
  125. /defaulttimeouts
  126.  { currentsystemparams dup
  127.    /JobTimeout .knownget not { 0 } if
  128.    exch /WaitTimeout .knownget not { 0 } if
  129.    currentpagedevice /ManualFeedTimeout .knownget not { 0 } if
  130.  } bind def
  131. dup /DoStartPage known
  132.  { /dostartpage { currentsystemparams /DoStartPage get } bind def
  133.    /setdostartpage { /DoStartPage .dict1 setsystemparams } bind def
  134.  } if
  135. dup /StartupMode known
  136.  { /dosysstart { currentsystemparams /StartupMode get 0 ne } bind def
  137.    /setdosysstart { { 1 } { 0 } ifelse /StartupMode .dict1 setsystemparams } bind def
  138.  } if
  139. %****** Setting jobname is supposed to set userparams.JobName, too.
  140. /jobname { currentuserparams /JobName get } bind def
  141. /jobtimeout { currentuserparams /JobTimeout get } bind def
  142. %manualfeed
  143. %manualfeedtimeout
  144. /margins
  145.  { currentpagedevice /Margins .knownget { exch } { [0 0] } ifelse
  146.  } bind def
  147. %pagecount
  148. %pagestackorder
  149. /printername
  150.  { currentsystemparams /PrinterName .knownget not { () } if exch copy
  151.  } bind def
  152. %/ramsize { currentsystemparams /RamSize get } bind def
  153. /realformat 1 index /RealFormat get def
  154.  
  155. /.setpagedevice where
  156.  { pop
  157.    /setdefaulttimeouts
  158.     { exch mark /ManualFeedTimeout 3 -1 roll
  159.       /Policies mark /ManualFeedTimeout 1 .dicttomark
  160.       .dicttomark setpagedevice
  161.       /WaitTimeout exch mark /JobTimeout 5 2 roll .dicttomark setsystemparams
  162.     } bind def
  163.    /setmargins
  164.     { exch 2 array astore /Margins .dict1 setpagedevice
  165.     } bind def
  166.  }
  167. if
  168. %setpagestackorder
  169. dup /PrinterName known
  170.  { /setprintername { /PrinterName .dict1 setsystemparams } bind def
  171.  } if
  172. currentuserparams /WaitTimeout known
  173.  { /waittimeout { currentuserparams /WaitTimeout get } bind def
  174.  } if
  175.  
  176. /.setpagedevice where
  177.  { pop 
  178.    /.setpagesize { 2 array astore /PageSize .dict1 setpagedevice } bind def
  179.    /setduplexmode { /Duplex .dict1 setpagedevice } bind def
  180.    /setpageparams
  181.     {    % We don't actually set the orientation yet.
  182.     %currentpagedevice /Orientation known not { pop 0 } if
  183.       mark /PageSize 6 -2 roll
  184.       4 index ORIENT1 { 1 } { 0 } ifelse ne { exch } if 2 array astore
  185.       /Orientation 5 -1 roll
  186.     pop pop %
  187.       /Margins counttomark 2 add -1 roll 0 2 array astore
  188.       .dicttomark setpagedevice
  189.     } bind def
  190.    /setresolution
  191.     { dup 2 array astore /HWResolution .dict1 setpagedevice
  192.     } bind def
  193.  }
  194. if
  195.  
  196. pop        % currentsystemparams
  197.  
  198. % Flag the current dictionary so it will be swapped when we
  199. % change language levels.  (See zmisc2.c for more information.)
  200. /statusdict currentdict def
  201.  
  202. currentdict end
  203. /statusdict exch def
  204.  
  205. % ------ Color spaces ------ %
  206.  
  207. % Define the setcolorspace procedures.
  208. /colorspacedict mark
  209.   /DeviceGray { pop 0 setgray } bind
  210.   /DeviceRGB { pop 0 0 0 setrgbcolor } bind
  211.   /setcmykcolor where
  212.    { pop /DeviceCMYK { pop 0 0 0 1 setcmykcolor } bind
  213.    } if
  214.   /.setcieaspace where
  215.    { pop /CIEBasedA { NOCIE { pop 0 setgray } { 1 get .setcieaspace } ifelse } bind
  216.    } if
  217.   /.setcieabcspace where
  218.    { pop /CIEBasedABC { NOCIE { pop 0 0 0 setrgbcolor } { 1 get .setcieabcspace } ifelse } bind
  219.    } if
  220.   /.setseparationspace where
  221.    { pop /Separation { dup 2 get setcolorspace .setseparationspace } bind
  222.    } if
  223.   /.setindexedspace where
  224.    { pop /Indexed { dup 1 get setcolorspace .setindexedspace } bind
  225.    } if
  226.   /.setpatternspace where
  227.    { pop /Pattern
  228.       { dup length 1 gt { dup 1 get setcolorspace } if
  229.         .setpatternspace
  230.       } bind
  231.    } if
  232. .dicttomark def
  233.  
  234. /.devcs [/DeviceGray /DeviceRGB /DeviceCMYK] readonly def
  235. /currentcolorspace
  236.  { .currentcolorspace dup type /integertype eq
  237.     { //.devcs exch 1 getinterval
  238.     } if
  239.  } odef
  240. currentdict /.devcs undef
  241.  
  242. /setcolorspace
  243.  { dup type /nametype eq { 1 array astore } if
  244.    dup //colorspacedict 1 index 0 get get exec
  245.    .setcolorspace
  246.  } odef
  247.  
  248. % Initialize the CIE rendering dictionary if necessary.
  249. % The most common CIE files seem to assume the "calibrated RGB color space"
  250. % described on p. 189 of the PostScript Language Reference Manual,
  251. % 2nd Edition; we simply invert this transformation back to RGB.
  252. /setcolorrendering where
  253.  { pop mark
  254.    /ColorRenderingType 1
  255.    /MatrixABC
  256.     [ 3.24063 -0.96893  0.05571
  257.      -1.53721  1.87576 -0.20402
  258.      -0.49863  0.04152  1.05700
  259.     ]
  260.    /EncodeABC [{0 max 0.45 exp} bind dup dup]
  261.    /WhitePoint [0.9505 1 1.0890]
  262.    /TransformPQR [ { 4 { exch pop } repeat } dup dup ]
  263.    .dicttomark setcolorrendering
  264.  } if
  265.  
  266. % ------ Painting ------ %
  267.  
  268. % A straightforward definition of execform that doesn't actually
  269. % do any caching.
  270. /execform
  271.  { dup /Implementation known not
  272.     { dup /FormType get 1 ne { /rangecheck signalerror } if
  273.       dup /Implementation null put readonly
  274.     } if
  275.    gsave dup /Matrix get concat
  276.    dup /BBox get aload pop
  277.    exch 3 index sub exch 2 index sub rectclip
  278.    dup /PaintProc get exec
  279.    grestore
  280.  } odef
  281.  
  282. /makepattern
  283.  { currentglobal
  284.     { false setglobal .buildpattern true setglobal }
  285.     { .buildpattern }
  286.    ifelse
  287.    exch dup length 1 add dict copy
  288.    dup /Implementation 4 -1 roll put
  289.    readonly
  290.  } odef
  291.  
  292. /setpattern
  293.  { currentcolorspace 0 get /Pattern ne
  294.     { [ /Pattern currentcolorspace ] setcolorspace } if
  295.    setcolor
  296.  } odef
  297.  
  298. end                % level2dict
  299.