Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_posix/sys/lib/ghostscript/pphs.ps – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
%    Copyright (C) 2001 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: pphs.ps,v 1.6 2003/08/08 18:45:05 ray Exp $
17
% Print Linearized PDF hint streams
18
 
19
% Utilities
20
/read1 {	% <file> read1 <value>
21
  read not {
22
    (**** Unexpected EOF) = flush quit
23
  } if
24
} bind def
25
/read2 {	% <file> read2 <value>
26
  dup read1 8 bitshift exch read1 add
27
} bind def
28
/read4 {	% <file> read4 <value>
29
  dup read2 16 bitshift exch read2 add
30
} bind def
31
% Free variables: Bits, Bitsleft
32
/readninit {	% - <readninit> -
33
  /Bits 0 def
34
  /Bitsleft 0 def
35
} bind def
36
 
37
/pdftoken {	% <file> pdftoken <token>
38
  dup token pop
39
  dup type /nametype eq 1 index xcheck and {
40
    dup dup (<<) cvn eq exch ([) eq or {
41
      exec exch {
42
	dup pdftoken dup dup (>>) cvn eq exch (]) eq or {
43
	  exch pop exec exit
44
	} if exch
45
      } loop
46
    } {
47
      exch pop
48
    } ifelse
49
  } {
50
    exch pop
51
  } ifelse
52
} bind def
53
/makemask {	% <nbits> makemask <mask>
54
  1 exch bitshift 1 sub
55
} bind def
56
/readn {	% <file> <nbits> readn <value>
57
  dup Bitsleft le {
58
    exch pop
59
    /Bitsleft Bitsleft 2 index sub def
60
    makemask Bits Bitsleft neg bitshift and
61
  } {
62
    Bitsleft makemask Bits and
63
    exch Bitsleft sub exch 1 index bitshift 3 1 roll
64
    /Bits 2 index read1 def /Bitsleft 8 def
65
    readn add
66
  } ifelse
67
} bind def
68
/sread {	% <string> sread <file>
69
 
70
} bind def
71
 
72
/ptag {		% <pre-tag> <proc> <post-tag> ptag -
73
  3 -1 roll print (: ) print
74
  exch exec
75
  (        % ) print =
76
} bind def
77
 
78
% Print the linearization parameters dictionary.
79
/plpkeys <<
80
  /E (end of p. 1 objects)
81
  /L (total file length)
82
  /H (PHS start + length)
83
  /N (# of pages)
84
  /O (p. 1 object #)
85
  /T (offset of first main xref entry)
86
>> def
87
/plpdict {	% <dict> plpdict -
88
  (<<) = plpkeys {
89
    2 index 2 index .knownget {
90
	% Stack: dict key label value
91
      (  ) print 3 -1 roll ===only ( ) print ===only
92
      (        % ) print =
93
    } {
94
      pop pop
95
    } ifelse
96
  } forall {
97
    plpkeys 2 index known {
98
      pop pop
99
    } {
100
      (  ) print exch ===only ( ) print ===
101
    } ifelse
102
  } forall (>>) =
103
} bind def
104
 
105
% Print the Page Offset Hint Table.
106
/ppoht {	% <npages> <file> ppoht -
107
 
108
  20 dict begin
109
  /f exch def
110
  /npages exch def
111
  readninit
112
 
113
  (1) { f read4 =only } (least # objs/page) ptag
114
  (2) { f read4 =only } (offset of p. 1 object (+PHS length if beyond PHS)) ptag
115
  (3) { f read2 dup =only /nb3 exch def } (# bits for # objs/page delta) ptag
116
  (4) { f read4 =only } (least # bytes/page) ptag
117
  (5) { f read2 dup =only /nb5 exch def } (# bits for # bytes/page delta) ptag
118
  (6) { f read4 =only } (least content stream offset-in-page) ptag
119
  (7) { f read2 dup =only /nb7 exch def } (# bits for content stream offset delta) ptag
120
  (8) { f read4 =only } (least content stream length) ptag
121
  (9) { f read2 dup =only /nb9 exch def } (# bits for content stream length delta) ptag
122
  (10) { f read2 dup =only /nb10 exch def } (# bits for # of shared obj refs) ptag
123
  (11) { f read2 dup =only /nb11 exch def } (# bits for shared obj indices) ptag
124
  (12) { f read2 dup =only /nb12 exch def } (# bits for shared obj ref pos numerators) ptag
125
  (13) { f read2 =only } (shared obj ref pos denominator) ptag
126
 
127
  (*1) { [ npages { f nb3 readn } repeat ] ==only } (# objs/page deltas (see 1,3)) ptag
128
  (*2) { [ npages { f nb5 readn } repeat ] ==only } (# bytes/page deltas (see 4,5)) ptag
129
  (*3) { [ npages { f nb10 readn } repeat ] dup ==only /nso exch def } (# of shared obj refs (see 10)) ptag
130
  (*4) { [ nso { [ exch { f nb11 readn } repeat ] } forall ] ==only } (shared obj indices (see 11)) ptag
131
  (*5) { [ nso { [ exch { f nb12 readn } repeat ] } forall ] ==only } (shared obj ref pos numerators (see 12)) ptag
132
  (*6) { [ npages { f nb7 readn } repeat ] ==only } (content stream offset-in-page deltas (see 6,7)) ptag
133
  (*7) { [ npages { f nb9 readn } repeat ] ==only } (content stream length deltas (see 8,9)) ptag
134
 
135
  end		% temp dict
136
 
137
} bind def
138
 
139
% Print the Shared Objects Hint Table.
140
/psoht {	% <file> psoht -
141
 
142
  20 dict begin
143
  /f exch def
144
  readninit
145
 
146
  (1) { f read4 =only } (first shared obj #) ptag
147
  (2) { f read4 =only } (first shared obj offset (+PHS length if beyond PHS)) ptag
148
  (3) { f read4 dup =only /n3 exch def } (# of p. 1 shared objs) ptag
149
  (4) { f read4 dup =only /n4 exch def } (total # of shared objs) ptag
150
  (5) { f read2 dup =only /nb5 exch def } (# bits for # of shared objs/group) ptag
151
  (6) { f read4 =only } (least shared obj group length) ptag
152
  (7) { f read2 dup =only /nb7 exch def } (# bits for shared obj group length delta) ptag
153
 
154
  /nse n4 def
155
  (*1) { [ nse { f nb7 readn } repeat ] ==only } (shared obj group length deltas (see 6,7)) ptag
156
  (*2) { [ nse { f 1 readn } repeat ] dup ==only /md5s exch def } (MD5 present?) ptag
157
  (*3:) = md5s {
158
 
159
      (  ) print f 16 string readstring pop
160
      (%stdout) (w) file dup 3 -1 roll writehexstring closefile () =
161
    } if
162
  } forall
163
  (*4) { [ nse { f nb5 readn } repeat ] ==only } (# objs/group (see 5)) ptag
164
 
165
  end		% temp dict
166
 
167
} bind def
168
 
169
% Print the Primary Hint Stream of a PDF file.
170
/pphs {		% <file> pphs -
171
  /pdf exch def
172
 
173
	% Read the linearization parameter dictionary.
174
  { pdf pdftoken /obj eq { exit } if } loop
175
  pdf pdftoken /lpdict exch def
176
  /lpdict type /dicttype eq { lpdict /Linearized known } { false } ifelse {
177
    (Not a linearized PDF file.) = stop
178
  } if
179
 
180
  lpdict plpdict flush
181
 
182
	% Read the primary hint stream.
183
  null {
184
    pdf pdftoken dup /stream eq { pop exit } if
185
    exch pop
186
  } loop
187
  /phsdict exch def
188
	% Remove Length if indirect reference.
189
  phsdict 0 known {
190
    phsdict 0 undef  phsdict /Length undef
191
  } if
192
  (PHS: ) print phsdict === flush
193
  pdf 0 (endstream) /SubFileDecode filter
194
  dup 64000 string readstring pop exch closefile
195
  sread /phsdata exch def
196
 
197
	% Decode the hint stream data if necessary.
198
  phsdict /Filter .knownget {
199
    phsdata exch filter
200
    dup 5000 string readstring pop exch closefile
201
    sread /phsdata exch def
202
  } if
203
 
204
	% Adobe says we can assume /P = 0.
205
  (Page Offset Hint Table:) =
206
  lpdict /N get
207
  phsdata phsdict /S get string readstring pop sread
208
  ppoht
209
  (Shared Objects Hint Table:) =
210
  phsdata psoht
211
} bind def
212
 
213
% Check for command line arguments.
214
[ shellarguments
215
 { ] dup length 1 eq
216
    { 0 get (r) file dup pphs closefile }
217
    { (Usage: pphs filename.pdf\n) print flush }
218
   ifelse
219
 }
220
 { pop }
221
ifelse