home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / gs_btokn.ps < prev    next >
Text File  |  2002-04-20  |  11KB  |  322 lines

  1. %    Copyright (C) 1994, 2000 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_btokn.ps,v 1.9 2002/04/19 06:52:25 lpd Exp $
  14. % Initialization file for binary tokens.
  15. % When this is run, systemdict is still writable,
  16. % but everything defined here goes into level2dict.
  17.  
  18. % Define whether or not to allow writing dictionaries.
  19. % This is a non-standard feature!
  20. /WRITEDICTS false def
  21.  
  22. languagelevel 1 .setlanguagelevel
  23. level2dict begin
  24.  
  25. % Initialization for the system name table.
  26.  
  27. mark
  28. % 0
  29.     /abs /add /aload /anchorsearch /and
  30.     /arc /arcn /arct /arcto /array
  31.     /ashow /astore /awidthshow /begin /bind
  32.     /bitshift /ceiling /charpath /clear /cleartomark
  33. % 20
  34.     /clip /clippath /closepath /concat /concatmatrix
  35.     /copy /count /counttomark /currentcmykcolor /currentdash
  36.     /currentdict /currentfile /currentfont /currentgray /currentgstate
  37.     /currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix
  38. % 40
  39.     /currentpoint /currentrgbcolor /currentshared /curveto /cvi
  40.     /cvlit /cvn /cvr /cvrs /cvs
  41.     /cvx /def /defineusername /dict /div
  42.     /dtransform /dup /end /eoclip /eofill
  43. % 60
  44.     /eoviewclip /eq /exch /exec /exit
  45.     /file /fill /findfont /flattenpath /floor
  46.     /flush /flushfile /for /forall /ge
  47.     /get /getinterval /grestore /gsave /gstate
  48. % 80
  49.     /gt /identmatrix /idiv /idtransform /if
  50.     /ifelse /image /imagemask /index /ineofill
  51.     /infill /initviewclip /inueofill /inufill /invertmatrix
  52.     /itransform /known /le /length /lineto
  53. % 100
  54.     /load /loop /lt /makefont /matrix
  55.     /maxlength /mod /moveto /mul /ne
  56.     /neg /newpath /not /null /or
  57.     /pathbbox /pathforall /pop /print /printobject
  58. % 120
  59.     /put /putinterval /rcurveto /read /readhexstring
  60.     /readline /readstring /rectclip /rectfill /rectstroke
  61.     /rectviewclip /repeat /restore /rlineto /rmoveto
  62.     /roll /rotate /round /save /scale
  63. % 140
  64.     /scalefont /search /selectfont /setbbox /setcachedevice
  65.     /setcachedevice2 /setcharwidth /setcmykcolor /setdash /setfont
  66.     /setgray /setgstate /sethsbcolor /setlinecap /setlinejoin
  67.     /setlinewidth /setmatrix /setrgbcolor /setshared /shareddict
  68. % 160
  69.     /show /showpage /stop /stopped /store
  70.     /string /stringwidth /stroke /strokepath /sub
  71.     /systemdict /token /transform /translate /truncate
  72.     /type /uappend /ucache /ueofill /ufill
  73. % 180
  74.     /undef /upath /userdict /ustroke /viewclip
  75.     /viewclippath /where /widthshow /write /writehexstring
  76.     /writeobject /writestring /wtranslation /xor /xshow
  77.     /xyshow /yshow /FontDirectory /SharedFontDirectory /Courier
  78. % 200
  79.     /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold
  80.     /Helvetica-BoldOblique /Helvetica-Oblique /Symbol /Times-Bold /Times-BoldItalic
  81.     /Times-Italic /Times-Roman /execuserobject /currentcolor /currentcolorspace
  82.     /currentglobal /execform /filter /findresource /globaldict
  83. % 220
  84.     /makepattern /setcolor /setcolorspace /setglobal /setpagedevice
  85.     /setpattern
  86. % pad to 256
  87.     counttomark 256 exch sub { 0 } repeat
  88. % 256
  89.     /= /== /ISOLatin1Encoding /StandardEncoding
  90. % 260
  91.     ([) cvn (]) cvn /atan /banddevice /bytesavailable
  92.     /cachestatus /closefile /colorimage /condition /copypage
  93.     /cos /countdictstack /countexecstack /cshow /currentblackgeneration
  94.     /currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat
  95. % 280
  96.     /currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking
  97.     /currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix
  98.     /definefont /deletefile /detach /deviceinfo /dictstack
  99.     /echo /erasepage /errordict /execstack /executeonly
  100. % 300
  101.     /exp /false /filenameforall /fileposition /fork
  102.     /framedevice /grestoreall /handleerror /initclip /initgraphics
  103.     /initmatrix /instroke /inustroke /join /kshow
  104.     /ln /lock /log /mark /monitor
  105. % 320
  106.     /noaccess /notify /nulldevice /packedarray /quit
  107.     /rand /rcheck /readonly /realtime /renamefile
  108.     /renderbands /resetfile /reversepath /rootfont /rrand
  109.     /run /scheck /setblackgeneration /setcachelimit /setcacheparams
  110. % 340
  111.     /setcolorscreen /setcolortransfer /setfileposition /setflat /sethalftone
  112.     /sethalftonephase /setmiterlimit /setobjectformat /setpacking /setscreen
  113.     /setstrokeadjust /settransfer /setucacheparams /setundercolorremoval /sin
  114.     /sqrt /srand /stack /status /statusdict
  115. % 360
  116.     /true /ucachestatus /undefinefont /usertime /ustrokepath
  117.     /version /vmreclaim /vmstatus /wait /wcheck
  118.     /xcheck /yield /defineuserobject /undefineuserobject /UserObjects
  119.     /cleardictstack
  120. % 376
  121.     /A /B /C /D /E /F /G /H /I /J /K /L /M
  122.     /N /O /P /Q /R /S /T /U /V /W /X /Y /Z
  123.     /a /b /c /d /e /f /g /h /i /j /k /l /m
  124.     /n /o /p /q /r /s /t /u /v /w /x /y /z
  125. % 428
  126.     /setvmthreshold (<<) cvn
  127.     (>>) cvn /currentcolorrendering /currentdevparams /currentoverprint /currentpagedevice
  128.     /currentsystemparams /currentuserparams /defineresource /findencoding /gcheck
  129. % 440
  130.     /glyphshow /languagelevel /product /pstack /resourceforall
  131.     /resourcestatus /revision /serialnumber /setcolorrendering /setdevparams
  132.     /setoverprint /setsystemparams /setuserparams /startjob /undefineresource
  133.     /GlobalFontDirectory /ASCII85Decode /ASCII85Encode /ASCIIHexDecode /ASCIIHexEncode
  134. % 460
  135.     /CCITTFaxDecode /CCITTFaxEncode /DCTDecode /DCTEncode /LZWDecode
  136.     /LZWEncode /NullEncode /RunLengthDecode /RunLengthEncode /SubFileDecode
  137.     /CIEBasedA /CIEBasedABC /DeviceCMYK /DeviceGray /DeviceRGB
  138.     /Indexed /Pattern /Separation /CIEBasedDEF /CIEBasedDEFG
  139. % 480
  140.     /DeviceN
  141. % 481 -- end
  142. .packtomark .installsystemnames
  143.  
  144. % Define printobject and writeobject.
  145. % These are mostly implemented in PostScript, so that we don't have to
  146. % worry about interrupts or callbacks when writing to the output file.
  147.  
  148. % Define procedures for accumulating the space required to represent
  149. % an object in binary form.  The procedures for composite objects (arrays
  150. % and dictionaries) leave different results on the stack:
  151. %    <#refs> <#chars> <simple_obj> -proc- <#refs> <#chars>
  152. %    <#refs> <#chars> <array|dict> -proc- <array|dict> <#refs> <#chars>
  153. % This is required so that .writeobjects can also accumulate the actual
  154. % list of composite objects to write in the binary object sequence.
  155. /cntdict mark
  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.   /dicttype null
  165. .dicttomark def
  166. /.cntobj {    % <<arguments and results as for procedures in cntdict>>
  167.   dup type //cntdict exch get exec
  168. } .bind def
  169. cntdict /arraytype {
  170.   dup dup length 5 -1 roll add 4 2 roll { .cntobj } forall
  171. } bind put
  172. cntdict /dicttype {
  173.   WRITEDICTS {
  174.     dup dup length 2 mul 5 -1 roll add 4 2 roll {
  175.     % We have to use .execn here, rather than simply rolling the
  176.     % value under the top elements, because key might involve arrays
  177.     % or dictionaries.
  178.       cvlit {.cntobj} exch 2 .execn .cntobj
  179.     } forall
  180.   } {
  181.     /writeobject load /typecheck signalerror
  182.   } ifelse
  183. } bind put
  184.  
  185. /w2dict mark
  186.   /nametype { 2 copy .writecvs pop } bind
  187.   /stringtype 1 index
  188. .dicttomark def
  189.  
  190. /.bosheader {        % <top_length> <total_length> <string8> .bosheader
  191.             %   <string4|8>
  192.   dup 0 currentobjectformat 127 add put        % object format => BOS tag
  193.   2 index 255 le 2 index 65531 le and {
  194.     % Use the short header format: tag toplen(1) totlen(2)
  195.     exch 4 add exch
  196.     0 4 getinterval
  197.     dup 1 5 -1 roll put
  198.   } {
  199.     % Use the long header format: tag 0(1) toplen(2) totlen(4)
  200.     exch 8 add exch
  201.     0 0 4 2 roll .bosobject exch pop exch pop    % store with byte swapping
  202.   } ifelse        % Stack: shortlen str
  203.   exch dup -8 bitshift exch 255 and    % str hibyte lobyte
  204.   currentobjectformat 1 and 0 eq {    % lsb first
  205.     exch
  206.   } if
  207.   2 index 3 3 -1 roll put
  208.   1 index 2 3 -1 roll put
  209. } .bind def
  210.  
  211. /.writeobjects {    % <file> <tag> <array> .writeobjects -
  212.   mark exch
  213.  
  214.     % Count the space required for refs and strings.
  215.  
  216.   dup length 0 3 -1 roll
  217.     % Stack: file tag -mark- #refs #chars array
  218.   dup 4 1 roll { .cntobj } forall
  219.  
  220.     % Write the header.
  221.  
  222.     % Stack: file tag -mark- array1 ... (array|dict)N #refs #chars
  223.   counttomark 3 add -2 roll 4 1 roll
  224.     % Stack: -mark- array1 ... (array|dict)N tag #refs #chars file
  225.   dup counttomark 1 sub index length
  226.   4 index 3 bitshift 4 index add
  227.   (xxxxxxxx) .bosheader writestring
  228.  
  229.     % Write the objects per se.
  230.  
  231.   3 1 roll pop
  232.   counttomark 1 sub index length 3 bitshift exch
  233.   3 bitshift
  234.     % Stack: -mark- array1 ... (array|dict)N tag file ref# char#
  235.   counttomark 4 sub {
  236.     counttomark -1 roll dup 6 1 roll
  237.     % Stack: ... objN tag file ref# char# objN
  238.     dup type /dicttype eq {        % can't be first object
  239.       { 5 1 roll (x\000xxxxxx) .bosobject
  240.     3 index exch writestring
  241.     4 -1 roll (x\000xxxxxx) .bosobject
  242.     3 index exch writestring
  243.       } forall
  244.     } {
  245.       { (xxxxxxxx) .bosobject
  246.     dup 1 6 index put
  247.     3 index exch writestring
  248.     4 -1 roll pop 0 4 1 roll    % clear tag
  249.       } forall
  250.     } ifelse
  251.   } repeat
  252.  
  253.     % Write the strings and names.
  254.  
  255.   pop pop exch pop
  256.     % Stack: -mark- array1 ... array|dictN file
  257.   counttomark 1 sub {
  258.     counttomark -1 roll {
  259.         % The counting pass ensured that the keys and values
  260.         % of any dictionary must be writable objects.
  261.         % Hence, we are processing a dictionary iff
  262.         % the next-to-top stack element is not a file.
  263.       1 index type /filetype ne {
  264.     exch 2 index exch dup type //w2dict exch .knownget
  265.      { exec } { pop } ifelse pop
  266.       } if
  267.       dup type //w2dict exch .knownget { exec } { pop } ifelse
  268.     } forall
  269.   } repeat
  270.  
  271.     % Clean up.
  272.  
  273.     % Stack: -mark- file
  274.   pop pop
  275.  
  276. } odef
  277.  
  278. /printobject {        % <obj> <tag> printobject -
  279.   (%stdout) (w) file 2 index 2 index writeobject pop pop
  280. } odef
  281. /writeobject {        % <file> <obj> <tag> writeobject -
  282.   3 copy exch
  283.         % We must allocate the array in local VM
  284.         % to avoid a possible invalidaccess.
  285.   .currentglobal false .setglobal exch 1 array astore exch .setglobal
  286.   .writeobjects pop pop pop
  287. } odef
  288.  
  289. % Implement binary error message output.
  290. /.objectprinttest {        % <obj> .objectprinttest -
  291.         % This is a pseudo-operator so it will restore the stack
  292.         % if it gets an error.
  293.   mark 0 0 3 index .cntobj cleartomark pop
  294. } bind odef
  295. /.printerror {
  296.   $error /binary get .languagelevel 2 ge and {
  297.     currentobjectformat 0 ne {
  298.       [ /Error $error /errorname get $error /command get
  299.         % Convert the object with cvs if it isn't printable.
  300.       dup { .objectprinttest } .internalstopped {
  301.     pop 100 string cvs
  302.       } if
  303.       false ] 250 printobject
  304.     }
  305.     //.printerror    % known to be a procedure
  306.     ifelse
  307.   }
  308.   //.printerror        % known to be a procedure
  309.   ifelse
  310. } bind def
  311.  
  312. currentdict /cntdict .undef
  313. currentdict /w2dict .undef
  314.  
  315. % End of level2dict
  316.  
  317. end
  318. .setlanguagelevel
  319.