home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / gs_resst.ps < prev    next >
Text File  |  2003-12-13  |  6KB  |  157 lines

  1. %    Copyright (C) 2000 artofcode LLC.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_resst.ps,v 1.2.2.1 2003/12/12 22:07:58 giles Exp $
  14. % Redefine generic category with static resource table.
  15.  
  16. languagelevel 2 .setlanguagelevel
  17.  
  18. 15 dict begin    % a temporary dictionary for local binding.
  19.  
  20. /sep (/) def %  The %static%  device uses platform independent paths.
  21.  
  22. /tempstring 8192 string def
  23.  
  24. /IsMyRecord      % <raw_record> IsMyRecord <raw_record> bool
  25. { dup type /dicttype eq { dup /StaticFilePos known } { false } ifelse
  26. } bind def
  27.  
  28. /append_string    % <scratch> <index> <string> append_string <scratch> <index> 
  29. {
  30.    dup length 3 index 3 index 2 index getinterval   % (scratch) index (string) l (scr_substr)
  31.    3 2 roll exch copy pop add                       % (scratch) index'
  32. } bind def
  33.  
  34. /StaticResourceRecordVirtualMethods 4 dict begin
  35.  
  36.   /GetFilePath    % <scratch> <Name> <record> GetFilePath <filepath>
  37.   { pop exch                                                % /Name (scratch)
  38.     (%static%) dup length exch 2 index copy pop             % /Name (scratch) l
  39.     //sep //append_string exec                              % /Name (scratch) l
  40.     Category //tempstring cvs //append_string exec          % /Name (scratch) l
  41.     //sep //append_string exec                              % /Name (scratch) l
  42.     3 2 roll //tempstring cvs                               % (scratch) l (Name)
  43.     //append_string exec                                    % (scratch) l
  44.     0 exch getinterval                                      % (path)
  45.   } bind def
  46.  
  47.   /MakeInstance   % <Name> <record> MakeInstance <Name> <Instance> <size>
  48.   {
  49.     begin
  50.       STRESDEBUG { (Loading a static resource ) print dup = } if
  51.       8192 string 2 index 2 index //GetFilePath exec
  52.       (r) file run
  53.       STRESDEBUG { (Completed loading the static resource ) print dup = } if
  54.       StaticFileEnd StaticFilePos sub
  55.     end
  56.     1 index Category findresource
  57.     exch
  58.   } bind def
  59.  
  60.   /GetSize        % <Name> <record> GetSize <size>
  61.   {
  62.     % WARNING : this retrives file sise rather than VM size
  63.     begin
  64.     pop
  65.     StaticFileEnd StaticFilePos sub
  66.     end
  67.   } bind def
  68.  
  69.   /IsActive       % <record> IsActive <bool>
  70.   { pop true
  71.   } bind def
  72.  
  73. currentdict end def
  74.  
  75. mark
  76. /MappedCategoryRedefiner /ProcSet findresource begin
  77.  
  78. /.StaticResourcesBeg % <end_string> <no_of_resources> <category_name> .StaticResourcesBeg <category_name>
  79. %     Puts .map dictionary to dstack.
  80. {
  81.   STRESDEBUG { (Starting static resources for category ) print dup = } if
  82.   dup /Category resourcestatus {
  83.     pop pop exch dict begin exch pop
  84.   } {
  85.     STRESDEBUG { (Skipping the resources because the category isn't defined.) = } if
  86.     pop pop .skipeof
  87.   } ifelse
  88. } bind
  89.  
  90. /.StaticResourcesEnd % <category_name> .StaticResourcesEnd -
  91. %     Removes .map dictionary from dstack.
  92. {
  93.   STRESDEBUG { (Completting static resources for category ) print dup = } if
  94.   currentdict end dup                                      % /CatName <map> <map>
  95.   systemdict /.io_static_root .knownget not {
  96.     10 dict                                                % /CatName <map> <map> <dir>
  97.     % Save it for garbager and for debug purpose :
  98.     dup systemdict exch /.io_static_root exch put          % /CatName <map> <map> <dir>
  99.     dup .setup_io_static                                   % /CatName <map> <map> <dir>
  100.   } if                                                     % /CatName <map> <map> <dir>
  101.   exch 3 index exch put                                    % /CatName <map>
  102.   14 dict begin
  103.     /.map exch def                                         % /CatName
  104.     /CategoryName exch def                                 %
  105.     /IsMapFileOptional true def
  106.     /VerifyMap  { pop } bind def
  107.     /PreprocessRecord  % <map> <Name> <raw_record> PreprocessRecord <map> <Name> <record> <bool>
  108.     { //IsMyRecord exec dup {
  109.         pop dup /RecordVirtualMethods //StaticResourceRecordVirtualMethods put
  110.         true
  111.       } if
  112.     } bind def
  113.   currentdict end
  114.   //Redefine exec
  115. } bind
  116.  
  117. end  % MappedCategoryRedefiner
  118. end  % the temporary dictionary for local binding.
  119.  
  120. /.BeginResource  % <instance_name> BeginResource <instance_name> 
  121. %     Puts a record dictionary to dstack.
  122. {
  123.   STRESDEBUG { (Static resource ) print dup =string cvs print } if
  124.   currentfile fileposition
  125.   currentfile =string readline pop dup length 0 exch 10 .min getinterval (%% Replace) ne {
  126.     % We are in COMPILE_INITS=1 .
  127.     4 dict begin
  128.     /StaticFilePos exch def    
  129.   } {
  130.     % We are in COMPILE_INITS=0 .
  131.     pop
  132.   } ifelse
  133.   (%END_RESOURCE) .skipeof
  134. } bind
  135.  
  136. /.EndResource  % <instance_name> EndResource -
  137. %     Removes a record dictionary from dstack.
  138. {
  139.   currentdict /StaticFilePos known {
  140.     /StaticFileEnd currentfile fileposition
  141.     (.EndResource) length sub
  142.     def
  143.     STRESDEBUG { ( from position ) print StaticFilePos =string cvs print ( to position ) print StaticFileEnd = } if
  144.     currentdict end def
  145.   } {
  146.     pop
  147.     STRESDEBUG { ( ignored with COMPILE_INITS=0. ) = } if
  148.   } ifelse
  149. } bind
  150.  
  151. .dicttomark /StaticCategoryRedefiner exch /ProcSet defineresource pop
  152.  
  153. .setlanguagelevel
  154.