Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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