星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gs_frsd.ps 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. % $Id: gs_frsd.ps 8954 2008-08-08 04:22:38Z ray $
  16. % Implementation of ReusableStreamDecode filter.
  17. % This file must be loaded after gs_lev2.ps and gs_res.ps.
  18. level2dict begin
  19. % ------ ReusableStreamDecode filter ------ %
  20. /.reusablestreamdecode { % <source> <dict> .reusablestreamdecode <file>
  21. % <source> .reusablestreamdecode <file>
  22. % Collect the filter parameters.
  23. dup type /dicttype eq { 2 copy } { dup 0 dict } ifelse
  24. dup .rsdparams
  25. % Construct the filter pipeline.
  26. % The very first filter should use the value of CloseSource
  27. % from the RSD dictionary; all the others should have
  28. % CloseSource = true.
  29. % Stack: source dict filters parms
  30. 2 index /CloseSource .knownget not { //false } if 5 -1 roll
  31. % Stack: dict filters parms CloseSource source
  32. 0 1 5 index length 1 sub {
  33. 4 index 1 index get
  34. % Stack: dict filters parms CloseSource source index filtname
  35. 4 index //null eq {
  36. 0 dict
  37. } {
  38. 4 index 2 index get dup //null eq { pop } if
  39. } ifelse
  40. 3 -1 roll pop exch filter
  41. exch pop //true exch % set CloseSource for further filters
  42. } for
  43. % If AsyncRead is true, try to create the filter directly.
  44. % Stack: dict filters parms CloseSource source
  45. 4 index /AsyncRead .knownget not { //false } if {
  46. 1 index { .reusablestream } .internalstopped
  47. } {
  48. //null //true
  49. } ifelse {
  50. pop
  51. % No luck. Read the entire contents of the stream now.
  52. dup type /filetype ne {
  53. % Make a stream from a procedure or string data source.
  54. 0 () .subfiledecode
  55. } if
  56. % We must allocate the string in the same VM space as its
  57. % source, since the reusable stream must be allocated there.
  58. .currentglobal 1 index gcheck .setglobal exch
  59. currentpacking //false setpacking exch
  60. % Stack: dict filters parms CloseSource oldglobal oldpacking file
  61. [ exch { dup 40000 string readstring not { exit } if exch } loop
  62. exch pop
  63. ]
  64. % Stack: dict filters parms CloseSource oldglobal oldpacking [()...]
  65. 3 1 roll setpacking setglobal
  66. % Stack: dict filters parms CloseSource [()...]
  67. 1 index .reusablestream
  68. } if
  69. % We created the stream successfully: clean up.
  70. 4 { exch pop } repeat
  71. 1 index type /dicttype eq { exch pop } if exch pop
  72. } odef
  73. filterdict /ReusableStreamDecode /.reusablestreamdecode load put
  74. end % level2dict