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