home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / servis / ovladace / drivers / CPPLW9xNTgb.exe / CPP_L / Driver / GS_CMDL.PS < prev    next >
Encoding:
Text File  |  1995-11-15  |  4.4 KB  |  169 lines

  1. %    Copyright (C) 1994 Aladdin Enterprises.  All rights reserved.
  2. %    Licensed to Zenographics Inc. (Irvine, California) by Artifex Software Inc.
  3. %    under the OEM Agreement of December 21st, 1993.
  4.  
  5. % Parse and execute the command line.
  6. % C code handles the following switches: -h/-? -I -M -v
  7.  
  8. /cmddict 50 dict def
  9. cmddict begin
  10.  
  11. % ---------------- Utility procedures ---------------- %
  12.  
  13. % Get the next argument from the parsed argument list.
  14. /nextarg        % - nextarg <arg> true
  15.             % - nextarg false
  16.  { argv length 0 eq
  17.     { false }
  18.     { argv dup 0 get exch dup length 1 sub 1 exch getinterval /argv exch def }
  19.    ifelse
  20.  } bind def
  21.  
  22. % Run a file, under job control if implemented.
  23. /runjob            % <file> runjob -
  24.  { end        % cmddict
  25.    /startjob where { pop false () startjob pop }
  26.    run
  27.    //cmddict begin
  28.  } bind def
  29. /runfilejob        % <filename> runfilejob -
  30.  { findlibfile { exch pop } { (r) file } runjob
  31.  } bind def
  32.  
  33. % Expand arguments.  Free variables: expand@.
  34. /expandarg        % <string> expandarg <args...>
  35.  { dup () eq
  36.     { pop
  37.     }
  38.     { dup dup (--) eq exch (-+) eq or
  39.        { pop /expand@ false def
  40.        }
  41.        { expand@ { (@) anchorsearch } { false } ifelse
  42.       { pop findlibfile
  43.          { exch pop }
  44.          { (r) file }        % let the error happen
  45.         expandargfile
  46.       }
  47.      if
  48.        }
  49.       ifelse
  50.     }
  51.  } bind def
  52. /expandargfile        % <file> expandargfile <args...>
  53.  { [ exch cvlit
  54.     { token not { exit } if
  55.       dup type /stringtype ne { =string cvs dup length string copy } if
  56.       expandarg
  57.     }
  58.    /exec cvx
  59.    ] cvx loop
  60.  } bind def
  61.  
  62. % ---------------- Recognized switches ---------------- %
  63.  
  64. % Switches with arguments are defined as <x>;
  65. % switches without arguments are defined as -<x>.
  66.  
  67. % Switches without arguments
  68. /--
  69.  { nextarg not
  70.     { (-- and -+ require a file name.\n) print flush }
  71.     { systemdict /ARGUMENTS argv put /argv [] def runjob }
  72.    ifelse
  73.  } bind def
  74. /-+ /-- load def
  75. /-@ /-- load def
  76. /-A { (@) Z } bind def
  77. /-c
  78.  {  { argv length 0 eq { exit } if
  79.       argv 0 get (-) anchorsearch { pop pop exit } if
  80.       pop nextarg token
  81.        { exch pop            % Probably should check for empty.
  82.      end exec //cmddict begin
  83.        }
  84.       if
  85.     }
  86.    loop
  87.  } bind def
  88. /-e { (#) Z } bind def
  89. /-E /-e load def
  90. /-f { } def
  91. /-q { systemdict /QUIET true put } bind def
  92.  
  93. % Switches with arguments
  94. /d
  95.  { (=) search not { (#) search not { () exch dup } if } if
  96.    exch pop cvn dup where
  97.     { pop (Redefining ) print print ( is not allowed.\n) print flush pop }
  98.     { exch token
  99.        { exch pop }        % Probably should check for empty.
  100.        { true }
  101.       ifelse
  102.       systemdict 3 1 roll put
  103.     }
  104.    ifelse
  105.  } bind def
  106. /D /d load def
  107. /f { dup length 0 ne { runfilejob } if } bind def
  108. /g
  109.  { (x) search { cvi pop exch cvi } { cvi dup } ifelse
  110.    systemdict begin /DEVICEHEIGHT exch def /DEVICEWIDTH exch def end
  111.  } bind def
  112. /r
  113.  { (x) search { cvr pop exch cvr } { cvr dup } ifelse
  114.    systemdict begin /DEVICEYRESOLUTION exch def /DEVICEXRESOLUTION exch def end
  115.  } bind def
  116. /s
  117.  { (=) search not { (#) search not { () exch dup } if } if
  118.    exch pop cvn dup where { pop dup load } { () } ifelse
  119.    type /stringtype ne
  120.     { (Redefining ) print print ( is not allowed.\n) print flush pop }
  121.     { exch systemdict 3 1 roll put }
  122.    ifelse
  123.  } bind def
  124. /S /s load def
  125. /Z { true .setdebug } bind def
  126.  
  127. % ---------------- Main program ---------------- %
  128.  
  129. % We process the command line in two passes.  In the first pass,
  130. % we read and expand any @-files as necessary.  The second pass
  131. % does the real work.
  132.  
  133. /cmdstart
  134.  { //cmddict begin
  135.    /expand@ true def
  136.    [
  137.         % Process the GS_OPTIONS environment variable.
  138.    (GS_OPTIONS) getenv { 0 () /SubFileDecode filter expandargfile } if
  139.         % Process the actual command line.
  140.    .getargv { expandarg } forall
  141.    ] readonly /argv exch def
  142.         % Now interpret the commands.
  143.     { nextarg not { exit } if
  144.       dup 0 get (-) 0 get eq
  145.        { dup length 1 eq
  146.       { pop (%stdin) (r) file runjob
  147.       }
  148.       { dup length 2 gt
  149.          { dup dup length 2 sub 2 exch getinterval exch 1 1 getinterval }
  150.         if currentdict .knownget
  151.          { exec
  152.          }
  153.          { (Ignoring unknown switch ) print
  154.            dup length 1 eq { (-) print print } if print
  155.            (\n) print flush
  156.          }
  157.         ifelse
  158.       }
  159.      ifelse
  160.        }
  161.        { runfilejob
  162.        }
  163.       ifelse
  164.     }
  165.    loop end
  166.  } bind def
  167.  
  168. end        % cmddict
  169.