home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / GhostScript / !GhostScr / 6_01 / lib / gs_epsf.ps < prev    next >
Text File  |  2000-03-09  |  2KB  |  62 lines

  1. %    Copyright (C) 1989, 1996 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % $Id: gs_epsf.ps,v 1.1 2000/03/09 08:40:39 lpd Exp $
  16. % Allow the interpreter to recognize MS-DOS EPSF file headers, and skip to
  17. % the PostScript section of the file.
  18.  
  19. /.runnoepsf /run load def
  20. /.epsfheader <C5D0D3C6> def
  21. /run
  22.  { dup type /filetype ne { (r) file } if
  23.         % Check for MS-DOS EPSF file (see Red Book p. 729).
  24.    true exch 0 1 3
  25.     {        % Stack: true file index
  26.       1 index read dup { pop dup .epsfheader 3 index get eq } if
  27.        { pop pop }    % if matched, don't need the character
  28.        {    % unread characters (wasn't EPSF)
  29.      2 index exch unread     % unread mismatch character
  30.      dup {   % loop unreading backwards in .epsfheader
  31.        1 sub dup .epsfheader exch get 2 index exch unread
  32.      } repeat pop
  33.      exch not exch exit    % change true to false
  34.        }
  35.       ifelse
  36.     }
  37.    for exch    % Stack: file true/false
  38.     {        % This block is executed if the file is MS-DOS EPSF.
  39.         % Build up the little-endian byte offset and length.
  40.       2
  41.     { 1 0 4
  42.        { 2 index read not { pop exit } if % if EOF, let error happen
  43.          2 index mul add exch 256 mul exch
  44.        }
  45.       repeat exch pop exch
  46.     }
  47.       repeat
  48.         % Stack: offset length file
  49.         % Use flushfile to skip quickly to the start of the
  50.         % PostScript section.
  51.       dup 4 -1 roll 12 sub () /SubFileDecode filter flushfile
  52.         % Now interpret the PostScript.
  53.       exch () /SubFileDecode filter cvx .runexec
  54.     }
  55.     { .runnoepsf
  56.     }
  57.    ifelse
  58.  } odef
  59.