home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / sharewar / dos / inne / gs300ini / gs_btokn.ps < prev    next >
Encoding:
Text File  |  1994-08-02  |  9.6 KB  |  281 lines

  1. %    Copyright (C) 1994 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. % Initialization file for binary tokens.
  16. % When this is run, systemdict is still writable,
  17. % but everything defined here goes into level2dict.
  18.  
  19. % Define whether or not to allow writing dictionaries.
  20. /WRITEDICTS true def
  21.  
  22. level2dict begin
  23.  
  24. % Initialization for the system name table.
  25.  
  26. mark
  27. % 0
  28.     /abs /add /aload /anchorsearch /and
  29.     /arc /arcn /arct /arcto /array
  30.     /ashow /astore /awidthshow /begin /bind
  31.     /bitshift /ceiling /charpath /clear /cleartomark
  32. % 20
  33.     /clip /clippath /closepath /concat /concatmatrix
  34.     /copy /count /counttomark /currentcmykcolor /currentdash
  35.     /currentdict /currentfile /currentfont /currentgray /currentgstate
  36.     /currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix
  37. % 40
  38.     /currentpoint /currentrgbcolor /currentshared /curveto /cvi
  39.     /cvlit /cvn /cvr /cvrs /cvs
  40.     /cvx /def /defineusername /dict /div
  41.     /dtransform /dup /end /eoclip /eofill
  42. % 60
  43.     /eoviewclip /eq /exch /exec /exit
  44.     /file /fill /findfont /flattenpath /floor
  45.     /flush /flushfile /for /forall /ge
  46.     /get /getinterval /grestore /gsave /gstate
  47. % 80
  48.     /gt /identmatrix /idiv /idtransform /if
  49.     /ifelse /image /imagemask /index /ineofill
  50.     /infill /initviewclip /inueofill /inufill /invertmatrix
  51.     /itransform /known /le /length /lineto
  52. % 100
  53.     /load /loop /lt /makefont /matrix
  54.     /maxlength /mod /moveto /mul /ne
  55.     /neg /newpath /not /null /or
  56.     /pathbbox /pathforall /pop /print /printobject
  57. % 120
  58.     /put /putinterval /rcurveto /read /readhexstring
  59.     /readline /readstring /rectclip /rectfill /rectstroke
  60.     /rectviewclip /repeat /restore /rlineto /rmoveto
  61.     /roll /rotate /round /save /scale
  62. % 140
  63.     /scalefont /search /selectfont /setbbox /setcachedevice
  64.     /setcachedevice2 /setcharwidth /setcmykcolor /setdash /setfont
  65.     /setgray /setgstate /sethsbcolor /setlinecap /setlinejoin
  66.     /setlinewidth /setmatrix /setrgbcolor /setshared /shareddict
  67. % 160
  68.     /show /showpage /stop /stopped /store
  69.     /string /stringwidth /stroke /strokepath /sub
  70.     /systemdict /token /transform /translate /truncate
  71.     /type /uappend /ucache /ueofill /ufill
  72. % 180
  73.     /undef /upath /userdict /ustroke /viewclip
  74.     /viewclippath /where /widthshow /write /writehexstring
  75.     /writeobject /writestring /wtranslation /xor /xshow
  76.     /xyshow /yshow /FontDirectory /SharedFontDirectory /Courier
  77. % 200
  78.     /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold
  79.     /Helvetica-BoldOblique /Helvetica-Oblique /Symbol /Times-Bold /Times-BoldItalic
  80.     /Times-Italic /Times-Roman /execuserobject /currentcolor /currentcolorspace
  81.     /currentglobal /execform /filter /findresource /globaldict
  82. % 220
  83.     /makepattern /setcolor /setcolorspace /setglobal /setpagedevice
  84.     /setpattern
  85. % pad to 256
  86.     counttomark 256 exch sub { 0 } repeat
  87. % 256
  88.     /= /== /ISOLatin1Encoding /StandardEncoding
  89. % 260
  90.     /[ /] /atan /banddevice /bytesavailable
  91.     /cachestatus /closefile /colorimage /condition /copypage
  92.     /cos /countdictstack /countexecstack /cshow /currentblackgeneration
  93.     /currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat
  94. % 280
  95.     /currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking
  96.     /currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix
  97.     /definefont /deletefile /detach /deviceinfo /dictstack
  98.     /echo /erasepage /errordict /execstack /executeonly
  99. % 300
  100.     /exp /false /filenameforall /fileposition /fork
  101.     /framedevice /grestoreall /handleerror /initclip /initgraphics
  102.     /initmatrix /instroke /inustroke /join /kshow
  103.     /ln /lock /log /mark /monitor
  104. % 320
  105.     /noaccess /notify /nulldevice /packedarray /quit
  106.     /rand /rcheck /readonly /realtime /renamefile
  107.     /renderbands /resetfile /reversepath /rootfont /rrand
  108.     /run /scheck /setblackgeneration /setcachelimit /setcacheparams
  109. % 340
  110.     /setcolorscreen /setcolortransfer /setfileposition /setflat /sethalftone
  111.     /sethalftonephase /setmiterlimit /setobjectformat /setpacking /setscreen
  112.     /setstrokeadjust /settransfer /setucacheparams /setundercolorremoval /sin
  113.     /sqrt /srand /stack /status /statusdict
  114. % 360
  115.     /true /ucachestatus /undefinefont /usertime /ustrokepath
  116.     /version /vmreclaim /vmstatus /wait /wcheck
  117.     /xcheck /yield /defineuserobject /undefineuserobject /UserObjects
  118.     /cleardictstack
  119. % 376
  120.     /A /B /C /D /E /F /G /H /I /J /K /L /M
  121.     /N /O /P /Q /R /S /T /U /V /W /X /Y /Z
  122.     /a /b /c /d /e /f /g /h /i /j /k /l /m
  123.     /n /o /p /q /r /s /t /u /v /w /x /y /z
  124. % 428
  125.     /setvmthreshold (<<) cvn
  126.     (>>) cvn /currentcolorrendering /currentdevparams /currentoverprint /currentpagedevice
  127.     /currentsystemparams /currentuserparams /defineresource /findencoding /gcheck
  128. % 440
  129.     /glyphshow /languagelevel /product /pstack /resourceforall
  130.     /resourcestatus /revision /serialnumber /setcolorrendering /setdevparams
  131.     /setoverprint /setsystemparams /setuserparams /startjob /undefineresource
  132.     /GlobalFontDirectory /ASCII85Decode /ASCII85Encode /ASCIIHexDecode /ASCIIHexEncode
  133. % 460
  134.     /CCITTFaxDecode /CCITTFaxEncode /DCTDecode /DCTEncode /LZWDecode
  135.     /LZWEncode /NullEncode /RunLengthDecode /RunLengthEncode /SubFileDecode
  136.     /CIEBasedA /CIEBasedABC /DeviceCMYK /DeviceGray /DeviceRGB
  137.     /Indexed /Pattern /Separation
  138. % 478 -- end
  139. .packtomark
  140.  
  141. % Install the system and user name tables.
  142. % The user name table is read-only for ordinary programs,
  143. % since it doesn't obey save/restore and must be managed specially.
  144.  
  145. dup /SystemNames exch def
  146. 100 array readonly dup /UserNames exch def
  147. .installnames
  148.  
  149. % Define printobject and writeobject.
  150. % These are mostly implemented in PostScript, so that we don't have to
  151. % worry about interrupts or callbacks when writing to the output file.
  152.  
  153. % Define procedures for accumulating the space required to represent
  154. % an object in binary form.
  155. /cntdict mark        % <#refs> <#chars> <obj> -proc- <#refs> <#chars>
  156.     /integertype /pop load
  157.     /realtype 1 index
  158.     /marktype 1 index
  159.     /nulltype 1 index
  160.     /booleantype 1 index
  161.     /nametype { length add } bind
  162.     /stringtype 1 index
  163.     /arraytype null
  164.     WRITEDICTS { /dicttype null } if
  165. .dicttomark def
  166. cntdict /arraytype
  167.  { dup dup length 5 -1 roll add 4 2 roll
  168.     { dup type //cntdict exch get exec } forall
  169.  } bind put
  170. WRITEDICTS
  171.  { cntdict /dicttype
  172.     { dup dup length 2 mul 5 -1 roll add 4 2 roll
  173.        { 4 1 roll dup type //cntdict exch get exec
  174.      3 -1 roll dup type //cntdict exch get exec
  175.        } forall
  176.     } bind put
  177.  } if
  178.  
  179. /w2dict mark
  180.     /nametype { 2 copy .writecvs pop } bind
  181.     /stringtype 1 index
  182. .dicttomark def
  183.  
  184. /.writeobjects        % <file> <tag> <array> .writeobjects -
  185.  {
  186.     mark exch
  187.  
  188.     % Count the space required for refs and strings.
  189.     dup length 0 3 -1 roll
  190.     % Stack: <file> <tag> -mark- <#refs> <#chars> <array>
  191.  
  192.     dup 4 1 roll
  193.      { dup type //cntdict exch get exec
  194.      } forall
  195.  
  196.     % Write the header.
  197.     % Stack: <file> <tag> -mark- <array1> ... <array|dictN> <#refs> <#chars>
  198.     counttomark 3 add -2 roll 4 1 roll
  199.     % Stack: -mark- <array1> ... <array|dictN> <tag> <#refs> <#chars> <file>
  200.     dup counttomark 1 sub index length
  201.     4 index 3 bitshift 4 index add
  202.     (xxxxxxxx) .bosheader writestring
  203.  
  204.     % Write the objects per se.
  205.     3 1 roll pop
  206.     counttomark 1 sub index length 3 bitshift exch
  207.     3 bitshift
  208.     % Stack: -mark- <array1> ... <array|dictN> <tag> <file> <ref#> <char#>
  209.  
  210.     counttomark 4 sub
  211.      { counttomark -1 roll dup 6 1 roll
  212.        dup type /dicttype eq        % can't be first object
  213.         {  { 5 1 roll (xxxxxxxx) .bosobject
  214.          3 index exch writestring
  215.          4 -1 roll (xxxxxxxx) .bosobject
  216.          3 index exch writestring
  217.            } forall
  218.         }
  219.         {  { (xxxxxxxx) .bosobject
  220.          dup 1 6 index put
  221.          3 index exch writestring
  222.          4 -1 roll pop 0 4 1 roll    % clear tag
  223.            } forall
  224.         }
  225.        ifelse
  226.      }
  227.     repeat
  228.  
  229.     % Write the strings and names.
  230.     pop pop exch pop
  231.     % Stack: -mark- <array1> ... <array|dictN> <file>
  232.  
  233.      counttomark 1 sub
  234.      { counttomark -1 roll
  235.         {        % The counting pass ensured that the keys and values
  236.             % of any dictionary must be writable objects.
  237.             % Hence, we are processing a dictionary iff
  238.             % the next-to-top stack element is not a file.
  239.           1 index type /filetype ne
  240.            { exch 2 index exch dup type //w2dict exch .knownget
  241.           { exec } { pop } ifelse pop
  242.            }
  243.           if
  244.               dup type //w2dict exch .knownget { exec } { pop } ifelse
  245.         } forall
  246.      }
  247.     repeat
  248.  
  249.     % Clean up.
  250.     % Stack: -mark- <file>
  251.  
  252.     pop pop
  253.  
  254.  } odef
  255. currentdict /cntdict undef
  256. currentdict /w2dict undef
  257.  
  258. /printobject { .stdout 3 1 roll writeobject } odef
  259. /writeobject { exch 1 array astore .writeobjects } odef
  260.  
  261. % Implement binary error message output.
  262.   /.printerror
  263.    { $error /binary get .languagelevel 2 eq and
  264.       { currentobjectformat 0 ne
  265.          { [ /Error $error /errorname get $error /command get false
  266.        ] 250 printobject
  267.      }
  268.      //.printerror
  269.     ifelse
  270.       }
  271.       //.printerror
  272.      ifelse
  273.    } bind def
  274.  
  275. % End of level2dict
  276.  
  277. end
  278.