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

  1. %    Copyright (C) 2000 Aladdin Enterprises.  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_frsd.ps,v 1.6.2.1 2003/12/12 22:07:58 giles Exp $
  14. % Implementation of ReusableStreamDecode filter.
  15. % This file must be loaded after gs_lev2.ps and gs_res.ps.
  16.  
  17. level2dict begin
  18.  
  19. % ------ ReusableStreamDecode filter ------ %
  20.  
  21. /.reusablestreamdecode {    % <source> <dict> .reusablestreamdecode <file>
  22.                 % <source> .reusablestreamdecode <file>
  23.         % Collect the filter parameters.
  24.   dup type /dicttype eq { 2 copy } { dup 0 dict } ifelse
  25.   dup .rsdparams
  26.         % Construct the filter pipeline.
  27.         % The very first filter should use the value of CloseSource
  28.         % from the RSD dictionary; all the others should have
  29.         % CloseSource = true.
  30.         % Stack: source dict filters parms
  31.   2 index /CloseSource .knownget not { false } if 5 -1 roll
  32.         % Stack: dict filters parms CloseSource source
  33.   0 1 5 index length 1 sub {
  34.     4 index 1 index get
  35.         % Stack: dict filters parms CloseSource source index filtname
  36.     4 index null eq {
  37.       0 dict
  38.     } {
  39.       4 index 2 index get dup null eq { pop } if
  40.     } ifelse
  41.     3 -1 roll pop exch filter
  42.     exch pop true exch        % set CloseSource for further filters
  43.   } for
  44.         % If AsyncRead is true, try to create the filter directly.
  45.         % Stack: dict filters parms CloseSource source
  46.   4 index /AsyncRead .knownget not { false } if {
  47.     1 index { .reusablestream } .internalstopped
  48.   } {
  49.     null true
  50.   } ifelse {
  51.     pop
  52.         % No luck.  Read the entire contents of the stream now.
  53.     dup type /filetype ne {
  54.         % Make a stream from a procedure or string data source.
  55.       0 () .subfiledecode
  56.     } if
  57.     10 dict exch {
  58.         % Stack: dict filters parms CloseSource contdict file
  59.       dup 64000 string readstring
  60.       3 index dup length 4 -1 roll put not { exit } if
  61.     } loop pop
  62.         % Concatenate the contents into one big string.
  63.         % Stack: dict filters parms CloseSource contdict
  64.     0 1 index { length exch pop add } forall
  65.     .bigstring exch {
  66.         % Stack: dict filters parms CloseSource string index substring
  67.       exch 64000 mul exch 2 index 3 1 roll putinterval
  68.     } forall
  69.         % Now create the stream on the string.
  70.     1 index .reusablestream
  71.   } if
  72.         % We created the stream successfully: clean up.
  73.   4 { exch pop } repeat
  74.   1 index type /dicttype eq { exch pop } if exch pop
  75. } odef
  76.  
  77. filterdict /ReusableStreamDecode /.reusablestreamdecode load put
  78.  
  79. end            % level2dict
  80.