Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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