/src/ghostpdl/pdf/ghostpdf.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2018-2022 Artifex Software, Inc. |
2 | | All Rights Reserved. |
3 | | |
4 | | This software is provided AS-IS with no warranty, either express or |
5 | | implied. |
6 | | |
7 | | This software is distributed under license and may not be copied, |
8 | | modified or distributed except as expressly authorized under the terms |
9 | | of the license contained in the file LICENSE in this distribution. |
10 | | |
11 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, |
13 | | CA 94945, U.S.A., +1(415)492-9861, for further information. |
14 | | */ |
15 | | |
16 | | |
17 | | #ifndef PDF_CONTEXT |
18 | | #define PDF_CONTEXT |
19 | | |
20 | | #include "gserrors.h" /* Most files use this to set errors of the gs_error_ form */ |
21 | | #include "gxgstate.h" |
22 | | |
23 | 402k | #define BUF_SIZE 2048 |
24 | | |
25 | | /* Limit nesting of arrays and dictionaries. We don't want to allow this |
26 | | * to be unbounded, because on exit we could end up exceeding the C execution stack |
27 | | * if we get too deeply nested. |
28 | | */ |
29 | 17.3M | #define MAX_NESTING_DEPTH 100 |
30 | | |
31 | | #include "pdf_types.h" |
32 | | |
33 | | #if defined(MEMENTO) |
34 | | #define PDFI_LEAK_CHECK 0 |
35 | | #endif |
36 | | |
37 | | #ifndef PDFI_LEAK_CHECK |
38 | | #define PDFI_LEAK_CHECK 0 |
39 | | #endif |
40 | | |
41 | | /* A structure for setting/resetting the interpreter graphics state |
42 | | * and some graphics state content when switching between Ghostscript |
43 | | * and pdfi, when running under GS. |
44 | | */ |
45 | | typedef struct pdf_context_switch { |
46 | | gs_gstate *pgs; |
47 | | gs_font *psfont; |
48 | | gs_gstate_client_procs procs; |
49 | | void *client_data; |
50 | | void *profile_cache; |
51 | | } pdfi_switch_t; |
52 | | |
53 | | /* |
54 | | * The interpreter context. |
55 | | */ |
56 | | /* Warnings and errors. The difference between a warning and an error is that we use a warning where |
57 | | * the file is technically illegal but we can be certain as to the real intent. At the time of writing |
58 | | * the only case is also a perfect example; the use of an inline image filter abbreviation (eg A85) |
59 | | * on a stream or object which is not an inline image. Although technically incorrect, its obvious |
60 | | * how to deal with this. |
61 | | */ |
62 | | typedef enum pdf_error_e { |
63 | | #include "pdf_errors.h" |
64 | | E_PDF_MAX_ERROR /* last entry */ |
65 | | }pdf_error; |
66 | | |
67 | | typedef enum pdf_warning_e { |
68 | | #include "pdf_warnings.h" |
69 | | W_PDF_MAX_WARNING /* last entry */ |
70 | | } pdf_warning; |
71 | | |
72 | 0 | #define PDF_ERROR_BYTE_SIZE ((E_PDF_MAX_ERROR - 1) / (sizeof(char) * 8) + 1) |
73 | 0 | #define PDF_WARNING_BYTE_SIZE ((W_PDF_MAX_WARNING - 1) / (sizeof(char) * 8) + 1) |
74 | | |
75 | | typedef enum pdf_crypt_filter_e { |
76 | | CRYPT_NONE, /* Not an encrypted file */ |
77 | | CRYPT_IDENTITY, /* Encrypted file, but no encryption on this object type */ |
78 | | CRYPT_V1, /* 40-bit RC4 */ |
79 | | CRYPT_V2, /* 128-bit RC4 */ |
80 | | CRYPT_AESV2, /* 128-bit AES */ |
81 | | CRYPT_AESV3, /* 256-bit AES */ |
82 | | } pdf_crypt_filter; |
83 | | |
84 | | typedef enum pdf_type3_d_type_e { |
85 | | pdf_type3_d_none, |
86 | | pdf_type3_d0, |
87 | | pdf_type3_d1 |
88 | | } pdf_type3_d_type; |
89 | | |
90 | 331k | #define INITIAL_STACK_SIZE 32 |
91 | 291k | #define MAX_STACK_SIZE 524288 |
92 | 1.54M | #define MAX_OBJECT_CACHE_SIZE 200 |
93 | 3.88M | #define INITIAL_LOOP_TRACKER_SIZE 32 |
94 | | |
95 | | typedef struct pdf_transfer_s { |
96 | | gs_mapping_proc proc; /* typedef is in gxtmap.h */ |
97 | | frac values[transfer_map_size]; |
98 | | } pdf_transfer_t; |
99 | | |
100 | | /* Items we want preserved around content stream executions */ |
101 | | typedef struct stream_save_s { |
102 | | gs_offset_t stream_offset; |
103 | | int gsave_level; |
104 | | int stack_count; |
105 | | gs_matrix intial_CTM; |
106 | | int group_depth; |
107 | | } stream_save; |
108 | | |
109 | | typedef struct name_entry_s { |
110 | | char *name; |
111 | | int len; |
112 | | unsigned int index; |
113 | | void *next; |
114 | | } pdfi_name_entry_t; |
115 | | |
116 | | typedef struct cmd_args_s { |
117 | | /* These are various command line switches, the list is not yet complete */ |
118 | | int first_page; /* -dFirstPage= */ |
119 | | int last_page; /* -dLastPage= */ |
120 | | bool pdfdebug; |
121 | | bool pdfstoponerror; |
122 | | bool pdfstoponwarning; |
123 | | bool notransparency; |
124 | | bool nocidfallback; |
125 | | bool no_pdfmark_outlines; /* can be overridden to true if multi-page output */ |
126 | | bool no_pdfmark_dests; /* can be overridden to true if multi-page output */ |
127 | | bool pdffitpage; |
128 | | bool usecropbox; |
129 | | bool useartbox; |
130 | | bool usebleedbox; |
131 | | bool usetrimbox; |
132 | | bool printed; |
133 | | bool showacroform; |
134 | | bool showannots; |
135 | | char **showannottypes; /* Null terminated array of strings, NULL if none */ |
136 | | bool dopdfmarks; |
137 | | bool preserveannots; |
138 | | char **preserveannottypes; /* Null terminated array of strings, NULL if none */ |
139 | | bool preservemarkedcontent; |
140 | | bool nouserunit; |
141 | | bool renderttnotdef; |
142 | | bool pdfinfo; |
143 | | bool UsePDFX3Profile; |
144 | | bool NOSUBSTDEVICECOLORS; |
145 | | bool ditherppi; |
146 | | int PDFX3Profile_num; |
147 | | char *UseOutputIntent; |
148 | | char *PageList; |
149 | | bool QUIET; |
150 | | bool verbose_errors; |
151 | | bool verbose_warnings; |
152 | | gs_string cidfsubstpath; |
153 | | gs_string cidfsubstfont; |
154 | | gs_string defaultfont; |
155 | | bool defaultfont_is_name; |
156 | | |
157 | | bool ignoretounicode; |
158 | | bool nonativefontmap; |
159 | | } cmd_args_t; |
160 | | |
161 | | typedef struct encryption_state_s { |
162 | | /* Encryption, passwords and filter details */ |
163 | | bool is_encrypted; |
164 | | int V; |
165 | | int Length; |
166 | | char *Password; |
167 | | int PasswordLen; |
168 | | int R; |
169 | | /* Revision 1-4 have O and E being 32 bytes, revision 5 and 6 48 bytes */ |
170 | | char O[48]; |
171 | | char U[48]; |
172 | | /* OE and UE are used for revision 5 and 6 encryption */ |
173 | | char OE[32]; |
174 | | char UE[32]; |
175 | | int P; |
176 | | pdf_string *EKey; |
177 | | bool EncryptMetadata; |
178 | | pdf_crypt_filter StrF; |
179 | | pdf_crypt_filter StmF; |
180 | | /* decrypting strings is complicated :-( |
181 | | * Streams are easy, because they can't be in compressed ObjStms, and they |
182 | | * have to be indirect objects. Strings can be indirect references or directly |
183 | | * defined, can be in compressed ObjStms and can appear inside content streams. |
184 | | * When they are in content streams we don't decrypt them, because the *stream* |
185 | | * was already decrypted. So when strings are directly or indirectly defined, |
186 | | * and *NOT* defined as part of a content stream, and not in an Objstm, we |
187 | | * need to decrypt them. We can handle the checking for ObjStm in the actual |
188 | | * decryption routine, where we also handle picking out the object number of the |
189 | | * enclosing parent, if its a directly defined string, but we cannot tell |
190 | | * whether we are executing a content stream or not, so we need to know that. This |
191 | | * flag is set whenever we are executing a content stream, it is temporarily reset |
192 | | * by pdfi_dereference() because indirect references can't appear in a content stream |
193 | | * so we know we need to decrypt any strings that are indirectly referenced. Note that |
194 | | * Form handling needs to set this flag for the duration of a Form content stream, |
195 | | * because we can execute Forms outside a page context (eg Annotations). |
196 | | */ |
197 | | bool decrypt_strings; |
198 | | } encryption_state_t; |
199 | | |
200 | | typedef struct page_state_s { |
201 | | /* Page level PDF objects */ |
202 | | /* DefaultGray, RGB and CMYK spaces */ |
203 | | gs_color_space *DefaultGray_cs; |
204 | | gs_color_space *DefaultRGB_cs; |
205 | | gs_color_space *DefaultCMYK_cs; |
206 | | /* Last-ditch resource lookup */ |
207 | | pdf_dict *CurrentPageDict; |
208 | | /* Page leve 'Default' transfer functions, black generation and under colour removal */ |
209 | | pdf_transfer_t DefaultTransfers[4]; |
210 | | pdf_transfer_t DefaultBG; |
211 | | pdf_transfer_t DefaultUCR; |
212 | | /* This tracks whether the current page uses transparency features */ |
213 | | bool has_transparency; |
214 | | /* This tracks how many spots are on the current page */ |
215 | | int num_spots; |
216 | | /* Does this page need overprint support? */ |
217 | | bool needs_OP; |
218 | | /* Does this page have OP=true in ExtGState? */ |
219 | | bool has_OP; |
220 | | /* Are we simulating overprint on this page? */ |
221 | | bool simulate_op; |
222 | | double Size[4]; |
223 | | double Crop[4]; |
224 | | double UserUnit; |
225 | | } page_state_t; |
226 | | |
227 | | typedef struct text_state_s { |
228 | | /* we need the text enumerator in order to call gs_text_setcharwidth() for d0 and d1 */ |
229 | | gs_text_enum_t *current_enum; |
230 | | /* Detect if we are inside a text block at any time. Nested text blocks are illegal and certain |
231 | | * marking operations are illegal inside text blocks. We also manipulate this when rendering |
232 | | * type 3 BuildChar procedures, as those marking operations are legal in a BuildChar, even |
233 | | * when we are in a text block. |
234 | | */ |
235 | | int BlockDepth; |
236 | | /* This is to determine if we get Type 3 Charproc operators (d0 and d1) outside |
237 | | * a Type 3 BuildChar. |
238 | | */ |
239 | | bool inside_CharProc; |
240 | | /* We need to know if we're in a type 3 CharProc which has executed a 'd1' operator. |
241 | | * Colour operators are technically invalid if we are in a 'd1' context and we must |
242 | | * ignore them. |
243 | | * OSS-fuzz #45320 has a type 3 font with a BuildChar which has a 'RG' before the |
244 | | * d1. This is (obviously) illegal because the spec says the first operation must |
245 | | * be either a d0 or d1, in addition because of the graphics state depth hackery |
246 | | * (see comments in pdf_d0() in pdf_font.c) this messes up the reference counting |
247 | | * of the colour spaces, leading to a crash. So what was a boolean flag is now an |
248 | | * enumerated type; pdf_type3_d_none, pdf_type3_d0 or pdf_type3_d1. |
249 | | */ |
250 | | pdf_type3_d_type CharProc_d_type; |
251 | | /* If there is no current point when we do a BT we start by doing a 0 0 moveto in order |
252 | | * to establish an initial point. However, this also starts a path. When we finish |
253 | | * off with a BT we need to clear that path by doing a newpath, otherwise we might |
254 | | * end up drawing it. See /tests_private/comparefiles/Bug692867.pdf |
255 | | * We store the initial current poitn validity and if t was not initially valid |
256 | | * (ie no path) then we do a newpath on a ET. |
257 | | * BT/ET are not supposed to be nested, and path construction is not permitted inside |
258 | | * a BT/ET block. |
259 | | */ |
260 | | bool initial_current_point_valid; |
261 | | } text_state_t; |
262 | | |
263 | | typedef struct device_state_s { |
264 | | /* Parameters/capabilities of the selected device */ |
265 | | /* Needed to determine whether we need to reset the device to handle any spots |
266 | | * and whether we need to prescan the PDF file to determine how many spot colourants |
267 | | * (if any) are used in the file. |
268 | | */ |
269 | | bool spot_capable; |
270 | | /* for avoiding charpath with pdfwrite */ |
271 | | bool preserve_tr_mode; |
272 | | /* Are SMask's preserved by device (pdfwrite) */ |
273 | | bool preserve_smask; |
274 | | bool ForOPDFRead; |
275 | | bool pdfmark; |
276 | | bool HighLevelDevice; |
277 | | /* These are derived from the device parameters rather than extracted from the device */ |
278 | | /* But this is a convenient place to keep them. */ |
279 | | /* Does current output device handle pdfmark */ |
280 | | bool writepdfmarks; |
281 | | /* Should annotations be preserved or marked for current output device? */ |
282 | | bool annotations_preserved; |
283 | | /* Should we pass on PageLabels (using a device param, not a pdfmark) */ |
284 | | bool WantsPageLabels; |
285 | | } device_state_t; |
286 | | |
287 | | /* |
288 | | * resource_paths: for CMaps, iccprofiles, fonts... mainly build time settings and from |
289 | | * "-I" command line options. |
290 | | * font_paths: Specific to fonts: from the -sFONTPATH=<> option |
291 | | * We keep a running count (num_resource_paths) of all, and a one off count of paths that |
292 | | * came from the build (num_init_resource_paths) so we can keep the (weird) search order |
293 | | * that gs uses. |
294 | | */ |
295 | | typedef struct search_paths_s |
296 | | { |
297 | | gs_param_string *resource_paths; |
298 | | int num_resource_paths; /* total */ |
299 | | int num_init_resource_paths; /* number of paths that came from the build */ |
300 | | gs_param_string *font_paths; |
301 | | int num_font_paths; |
302 | | gs_param_string genericresourcedir; |
303 | | bool search_here_first; |
304 | | } search_paths_t; |
305 | | |
306 | | typedef struct pdf_context_s |
307 | | { |
308 | | pdf_obj_common; |
309 | | void *instance; |
310 | | gs_memory_t *memory; |
311 | | |
312 | | /* command line argument storage */ |
313 | | cmd_args_t args; |
314 | | |
315 | | /* Encryption state */ |
316 | | encryption_state_t encryption; |
317 | | |
318 | | /* Text and text state parameters */ |
319 | | text_state_t text; |
320 | | |
321 | | /* The state of the current page being processed */ |
322 | | page_state_t page; |
323 | | |
324 | | device_state_t device_state; |
325 | | |
326 | | |
327 | | /* PDF interpreter state */ |
328 | | |
329 | | /* State for handling the wacky W and W* operators */ |
330 | | bool clip_active; |
331 | | bool do_eoclip; |
332 | | |
333 | | /* Doing a high level form for pdfwrite (annotations) */ |
334 | | bool PreservePDFForm; |
335 | | /* If processing multiple files, the number of pages to add to /Page Destinations |
336 | | * when handling Outlines and Annotations. This is the number of pages in all |
337 | | * files completely processed so far. |
338 | | */ |
339 | | int Pdfmark_InitialPage; |
340 | | |
341 | | /* Optional things from Root */ |
342 | | pdf_dict *OCProperties; |
343 | | pdf_dict *Collection; |
344 | | |
345 | | /* Optional/Marked Content stuff */ |
346 | | void *OFFlevels; |
347 | | uint64_t BMClevel; |
348 | | bool BDCWasOC; |
349 | | |
350 | | /* Bitfields recording whether any errors or warnings were encountered */ |
351 | | char pdf_errors[PDF_ERROR_BYTE_SIZE]; |
352 | | char pdf_warnings[PDF_WARNING_BYTE_SIZE]; |
353 | | |
354 | | /* We need a gs_font_dir for gs_definefotn() */ |
355 | | gs_font_dir * font_dir; |
356 | | /* Obviously we need a graphics state */ |
357 | | gs_gstate *pgs; |
358 | | |
359 | | /* PDF really doesn't have a path in the graphics state. This is different to |
360 | | * PostScript and has implications; changing the CTM partway through path |
361 | | * construction affects path segments already accumulated. The path is |
362 | | * unaffected by gsvae and grestore. Previously we've unwound any pending |
363 | | * path and rerun it, this is causing problems so instead we'll do what |
364 | | * Acrobat obviously does and build the path outside the graphics state |
365 | | */ |
366 | | /* We make allocations in chunks for the path to avoid lots of little |
367 | | * allocations, but we need to know where the end of the current allocation |
368 | | * is so that we can tell if we would overflow and increase it. |
369 | | */ |
370 | | char *PathSegments; |
371 | | /* The current insertion point. */ |
372 | | char *PathSegmentsCurrent; |
373 | | /* The current limit of the block */ |
374 | | char *PathSegmentsTop; |
375 | | double *PathPts; |
376 | | double *PathPtsCurrent; |
377 | | double *PathPtsTop; |
378 | | |
379 | | /* set up by pdf_impl_set_device, this is the 'high water mark' for |
380 | | * restoring back to when we close a PDF file. This ensures the device |
381 | | * is correctly set up for any subesquent file to be run. |
382 | | */ |
383 | | int job_gstate_level; |
384 | | /* This is currently used for Patterns, but I suspect needs to be changed to use |
385 | | * 'the enclosing context' |
386 | | */ |
387 | | gs_gstate *DefaultQState; |
388 | | |
389 | | |
390 | | /* The input PDF filename and the stream for it */ |
391 | | char *filename; |
392 | | pdf_c_stream *main_stream; |
393 | | |
394 | | /* Length of the main file */ |
395 | | gs_offset_t main_stream_length; |
396 | | /* offset to the xref table */ |
397 | | gs_offset_t startxref; |
398 | | |
399 | | /* Track whether file is a hybrid. Initially prefer XRefStm but |
400 | | * if we fail to read the structure using an XRefStm, try again |
401 | | * using the xref |
402 | | */ |
403 | | bool prefer_xrefstm; |
404 | | bool is_hybrid; |
405 | | /* If we've already repaired the file once, and it still fails, don't try to repair it again */ |
406 | | bool repaired; |
407 | | |
408 | | /* The HeaderVersion is the declared version from the PDF header, but this |
409 | | * can be overridden by later trailer dictionaries, so the FinalVersion is |
410 | | * the version as finally read from the file. Note we don't currently use |
411 | | * these for anything, we might in future emit warnings if PDF files use features |
412 | | * inconsistent with the FinalVersion. |
413 | | */ |
414 | | float HeaderVersion, FinalVersion; |
415 | | |
416 | | /* Document level PDF objects */ |
417 | | xref_table_t *xref_table; |
418 | | /* Warning! Do not use ctx->Trailer directly as it may be replaced if the file is repaired. |
419 | | * See pdf_doc.c, pdf_read_Root() |
420 | | */ |
421 | | pdf_dict *Trailer; |
422 | | pdf_dict *Root; |
423 | | pdf_dict *Info; |
424 | | pdf_dict *PagesTree; |
425 | | uint64_t num_pages; |
426 | | uint32_t *page_array; /* cache of page dict object_num's for pdfmark Dest */ |
427 | | pdf_dict *AcroForm; |
428 | | bool NeedAppearances; /* From AcroForm, if any */ |
429 | | |
430 | | /* The interpreter operand stack */ |
431 | | uint32_t stack_size; |
432 | | pdf_obj **stack_bot; |
433 | | pdf_obj **stack_top; |
434 | | pdf_obj **stack_limit; |
435 | | |
436 | | /* The object cache */ |
437 | | uint32_t cache_entries; |
438 | | pdf_obj_cache_entry *cache_LRU; |
439 | | pdf_obj_cache_entry *cache_MRU; |
440 | | |
441 | | /* The loop detection state */ |
442 | | uint32_t loop_detection_size; |
443 | | uint32_t loop_detection_entries; |
444 | | uint64_t *loop_detection; |
445 | | |
446 | | /* A counter for nesting of arrays and dictionaries. We don't want to allow this |
447 | | * to be unbounded, because on exit we could end up exceeding the C execution stack |
448 | | * if we get too deeply nested. |
449 | | */ |
450 | | uint32_t object_nesting; |
451 | | |
452 | | /* Used to set the 'parent' stream of a stream that gets created by dereferencing |
453 | | * We should not need this but badly fromed PDF files can use Resources defined in |
454 | | * an earlier (non-Page) stream object, and Acrobat handles this, so we need to. |
455 | | * We could haev done this more neatly if we'd known this during design :-( |
456 | | */ |
457 | | pdf_stream *current_stream; |
458 | | stream_save current_stream_save; |
459 | | |
460 | | /* A name table :-( */ |
461 | | pdfi_name_entry_t *name_table; |
462 | | |
463 | | gs_string *fontmapfiles; |
464 | | int num_fontmapfiles; |
465 | | |
466 | | search_paths_t search_paths; |
467 | | pdf_dict *pdffontmap; |
468 | | pdf_dict *pdfnativefontmap; /* Explicit mappings take precedence, hence we need separate dictionaries */ |
469 | | pdf_dict *pdf_substitute_fonts; |
470 | | pdf_dict *pdfcidfmap; |
471 | | |
472 | | gx_device *devbbox; /* Cached for use in pdfi_string_bbox */ |
473 | | /* These function pointers can be replaced by ones intended to replicate |
474 | | * PostScript functionality when running inside the Ghostscript PostScript |
475 | | * interpreter. |
476 | | */ |
477 | | int (*finish_page) (struct pdf_context_s *ctx); |
478 | | int (*get_glyph_name)(gs_font *font, gs_glyph index, gs_const_string *pstr); |
479 | | int (*get_glyph_index)(gs_font *font, byte *str, uint size, uint *glyph); |
480 | | |
481 | | #if REFCNT_DEBUG |
482 | | uint64_t ref_UID; |
483 | | #endif |
484 | | #if CACHE_STATISTICS |
485 | | uint64_t hits; |
486 | | uint64_t misses; |
487 | | uint64_t compressed_hits; |
488 | | uint64_t compressed_misses; |
489 | | #endif |
490 | | #if PDFI_LEAK_CHECK |
491 | | gs_memory_status_t memstat; |
492 | | #endif |
493 | | }pdf_context; |
494 | | |
495 | 142k | #define OBJ_CTX(o) ((pdf_context *)(o->ctx)) |
496 | 16.8k | #define OBJ_MEMORY(o) OBJ_CTX(o)->memory |
497 | | |
498 | | int pdfi_add_paths_to_search_paths(pdf_context *ctx, const char *ppath, int l, bool fontpath); |
499 | | int pdfi_add_initial_paths_to_search_paths(pdf_context *ctx, const char *ppath, int l); |
500 | | int pdfi_add_fontmapfiles(pdf_context *ctx, const char *ppath, int l); |
501 | | |
502 | | pdf_context *pdfi_create_context(gs_memory_t *pmem); |
503 | | int pdfi_clear_context(pdf_context *ctx); |
504 | | int pdfi_free_context(pdf_context *ctx); |
505 | | |
506 | | int pdfi_get_name_index(pdf_context *ctx, char *name, int len, unsigned int *returned); |
507 | | int pdfi_name_from_index(pdf_context *ctx, int index, unsigned char **name, unsigned int *len); |
508 | | int pdfi_separation_name_from_index(gs_gstate *pgs, gs_separation_name index, unsigned char **name, unsigned int *len); |
509 | | int pdfi_open_pdf_file(pdf_context *ctx, char *filename); |
510 | | int pdfi_set_input_stream(pdf_context *ctx, stream *stm); |
511 | | int pdfi_process_pdf_file(pdf_context *ctx, char *filename); |
512 | | int pdfi_prep_collection(pdf_context *ctx, uint64_t *TotalFiles, char ***names_array); |
513 | | int pdfi_close_pdf_file(pdf_context *ctx); |
514 | | int pdfi_gstate_from_PS(pdf_context *ctx, gs_gstate *pgs, pdfi_switch_t *i_switch, gsicc_profile_cache_t *profile_cache); |
515 | | void pdfi_gstate_to_PS(pdf_context *ctx, gs_gstate *pgs, pdfi_switch_t *i_switch); |
516 | | int pdfi_output_page_info(pdf_context *ctx, uint64_t page_num); |
517 | | |
518 | | void pdfi_report_errors(pdf_context *ctx); |
519 | | void pdfi_verbose_error(pdf_context *ctx, int gs_error, const char *gs_lib_function, int pdfi_error, const char *pdfi_function_name, const char *extra_info); |
520 | | void pdfi_verbose_warning(pdf_context *ctx, int gs_error, const char *gs_lib_function, int pdfi_warning, const char *pdfi_function_name, const char *extra_info); |
521 | | void pdfi_log_info(pdf_context *ctx, const char *pdfi_function, const char *info); |
522 | | |
523 | | static inline void pdfi_set_error(pdf_context *ctx, int gs_error, const char *gs_lib_function, pdf_error pdfi_error, const char *pdfi_function_name, const char *extra_info) |
524 | 12.8M | { |
525 | 12.8M | if (pdfi_error != 0) |
526 | 12.8M | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); |
527 | 12.8M | if (ctx->args.verbose_errors) |
528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); |
529 | 12.8M | } Unexecuted instantiation: zpdfops.c:pdfi_set_error pdf_loop_detect.c:pdfi_set_error Line | Count | Source | 524 | 21.5k | { | 525 | 21.5k | if (pdfi_error != 0) | 526 | 21.5k | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 21.5k | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 21.5k | } |
ghostpdf.c:pdfi_set_error Line | Count | Source | 524 | 44.1k | { | 525 | 44.1k | if (pdfi_error != 0) | 526 | 34.3k | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 44.1k | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 44.1k | } |
Unexecuted instantiation: pdf_dict.c:pdfi_set_error Unexecuted instantiation: pdf_array.c:pdfi_set_error pdf_xref.c:pdfi_set_error Line | Count | Source | 524 | 7.04k | { | 525 | 7.04k | if (pdfi_error != 0) | 526 | 7.04k | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 7.04k | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 7.04k | } |
Line | Count | Source | 524 | 12.3M | { | 525 | 12.3M | if (pdfi_error != 0) | 526 | 12.3M | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 12.3M | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 12.3M | } |
pdf_file.c:pdfi_set_error Line | Count | Source | 524 | 667 | { | 525 | 667 | if (pdfi_error != 0) | 526 | 667 | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 667 | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 667 | } |
Unexecuted instantiation: pdf_path.c:pdfi_set_error Unexecuted instantiation: pdf_colour.c:pdfi_set_error Unexecuted instantiation: pdf_pattern.c:pdfi_set_error pdf_gstate.c:pdfi_set_error Line | Count | Source | 524 | 8 | { | 525 | 8 | if (pdfi_error != 0) | 526 | 8 | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 8 | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 8 | } |
Unexecuted instantiation: pdf_stack.c:pdfi_set_error pdf_image.c:pdfi_set_error Line | Count | Source | 524 | 4.65k | { | 525 | 4.65k | if (pdfi_error != 0) | 526 | 4.65k | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 4.65k | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 4.65k | } |
pdf_page.c:pdfi_set_error Line | Count | Source | 524 | 49 | { | 525 | 49 | if (pdfi_error != 0) | 526 | 49 | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 49 | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 49 | } |
Unexecuted instantiation: pdf_annot.c:pdfi_set_error Unexecuted instantiation: pdf_mark.c:pdfi_set_error pdf_font.c:pdfi_set_error Line | Count | Source | 524 | 143k | { | 525 | 143k | if (pdfi_error != 0) | 526 | 143k | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 143k | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 143k | } |
Unexecuted instantiation: pdf_font0.c:pdfi_set_error Unexecuted instantiation: pdf_ciddec.c:pdfi_set_error Unexecuted instantiation: pdf_font1.c:pdfi_set_error Unexecuted instantiation: pdf_font1C.c:pdfi_set_error Unexecuted instantiation: pdf_fontps.c:pdfi_set_error Unexecuted instantiation: pdf_font3.c:pdfi_set_error Unexecuted instantiation: pdf_fontTT.c:pdfi_set_error Unexecuted instantiation: pdf_font11.c:pdfi_set_error Unexecuted instantiation: pdf_cmap.c:pdfi_set_error Unexecuted instantiation: pdf_fmap.c:pdfi_set_error Unexecuted instantiation: pdf_text.c:pdfi_set_error Unexecuted instantiation: pdf_shading.c:pdfi_set_error Unexecuted instantiation: pdf_func.c:pdfi_set_error pdf_trans.c:pdfi_set_error Line | Count | Source | 524 | 3 | { | 525 | 3 | if (pdfi_error != 0) | 526 | 3 | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 3 | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 3 | } |
Unexecuted instantiation: pdf_device.c:pdfi_set_error Unexecuted instantiation: pdf_misc.c:pdfi_set_error Unexecuted instantiation: pdf_optcontent.c:pdfi_set_error Unexecuted instantiation: pdf_check.c:pdfi_set_error Unexecuted instantiation: pdf_sec.c:pdfi_set_error Unexecuted instantiation: pdf_utf8.c:pdfi_set_error pdf_deref.c:pdfi_set_error Line | Count | Source | 524 | 65.3k | { | 525 | 65.3k | if (pdfi_error != 0) | 526 | 65.3k | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 65.3k | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 65.3k | } |
pdf_repair.c:pdfi_set_error Line | Count | Source | 524 | 132k | { | 525 | 132k | if (pdfi_error != 0) | 526 | 132k | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 132k | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 132k | } |
Unexecuted instantiation: pdf_obj.c:pdfi_set_error Line | Count | Source | 524 | 88.3k | { | 525 | 88.3k | if (pdfi_error != 0) | 526 | 88.3k | ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); | 527 | 88.3k | if (ctx->args.verbose_errors) | 528 | 0 | pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); | 529 | 88.3k | } |
Unexecuted instantiation: pdf_fapi.c:pdfi_set_error |
530 | | |
531 | | static inline void pdfi_set_warning(pdf_context *ctx, int gs_error, const char *gs_lib_function, pdf_warning pdfi_warning, const char *pdfi_function_name, const char *extra_info) |
532 | 1.40M | { |
533 | 1.40M | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); |
534 | 1.40M | if (ctx->args.verbose_warnings) |
535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); |
536 | 1.40M | } Unexecuted instantiation: zpdfops.c:pdfi_set_warning Unexecuted instantiation: pdf_loop_detect.c:pdfi_set_warning Unexecuted instantiation: ghostpdf.c:pdfi_set_warning pdf_dict.c:pdfi_set_warning Line | Count | Source | 532 | 386 | { | 533 | 386 | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 386 | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 386 | } |
Unexecuted instantiation: pdf_array.c:pdfi_set_warning pdf_xref.c:pdfi_set_warning Line | Count | Source | 532 | 5.26k | { | 533 | 5.26k | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 5.26k | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 5.26k | } |
pdf_int.c:pdfi_set_warning Line | Count | Source | 532 | 138k | { | 533 | 138k | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 138k | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 138k | } |
pdf_file.c:pdfi_set_warning Line | Count | Source | 532 | 119 | { | 533 | 119 | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 119 | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 119 | } |
pdf_path.c:pdfi_set_warning Line | Count | Source | 532 | 830k | { | 533 | 830k | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 830k | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 830k | } |
pdf_colour.c:pdfi_set_warning Line | Count | Source | 532 | 23.6k | { | 533 | 23.6k | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 23.6k | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 23.6k | } |
pdf_pattern.c:pdfi_set_warning Line | Count | Source | 532 | 95 | { | 533 | 95 | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 95 | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 95 | } |
pdf_gstate.c:pdfi_set_warning Line | Count | Source | 532 | 118k | { | 533 | 118k | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 118k | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 118k | } |
pdf_stack.c:pdfi_set_warning Line | Count | Source | 532 | 3.45k | { | 533 | 3.45k | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 3.45k | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 3.45k | } |
pdf_image.c:pdfi_set_warning Line | Count | Source | 532 | 18.2k | { | 533 | 18.2k | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 18.2k | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 18.2k | } |
pdf_page.c:pdfi_set_warning Line | Count | Source | 532 | 466 | { | 533 | 466 | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 466 | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 466 | } |
pdf_annot.c:pdfi_set_warning Line | Count | Source | 532 | 113 | { | 533 | 113 | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 113 | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 113 | } |
Unexecuted instantiation: pdf_mark.c:pdfi_set_warning pdf_font.c:pdfi_set_warning Line | Count | Source | 532 | 201 | { | 533 | 201 | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 201 | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 201 | } |
Unexecuted instantiation: pdf_font0.c:pdfi_set_warning Unexecuted instantiation: pdf_ciddec.c:pdfi_set_warning Unexecuted instantiation: pdf_font1.c:pdfi_set_warning Unexecuted instantiation: pdf_font1C.c:pdfi_set_warning Unexecuted instantiation: pdf_fontps.c:pdfi_set_warning Unexecuted instantiation: pdf_font3.c:pdfi_set_warning Unexecuted instantiation: pdf_fontTT.c:pdfi_set_warning Unexecuted instantiation: pdf_font11.c:pdfi_set_warning Unexecuted instantiation: pdf_cmap.c:pdfi_set_warning Unexecuted instantiation: pdf_fmap.c:pdfi_set_warning pdf_text.c:pdfi_set_warning Line | Count | Source | 532 | 210k | { | 533 | 210k | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 210k | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 210k | } |
pdf_shading.c:pdfi_set_warning Line | Count | Source | 532 | 39.5k | { | 533 | 39.5k | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 39.5k | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 39.5k | } |
Unexecuted instantiation: pdf_func.c:pdfi_set_warning pdf_trans.c:pdfi_set_warning Line | Count | Source | 532 | 1 | { | 533 | 1 | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 1 | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 1 | } |
Unexecuted instantiation: pdf_device.c:pdfi_set_warning Unexecuted instantiation: pdf_misc.c:pdfi_set_warning Unexecuted instantiation: pdf_optcontent.c:pdfi_set_warning Unexecuted instantiation: pdf_check.c:pdfi_set_warning Unexecuted instantiation: pdf_sec.c:pdfi_set_warning Unexecuted instantiation: pdf_utf8.c:pdfi_set_warning Unexecuted instantiation: pdf_deref.c:pdfi_set_warning Unexecuted instantiation: pdf_repair.c:pdfi_set_warning Unexecuted instantiation: pdf_obj.c:pdfi_set_warning pdf_doc.c:pdfi_set_warning Line | Count | Source | 532 | 16.1k | { | 533 | 16.1k | ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); | 534 | 16.1k | if (ctx->args.verbose_warnings) | 535 | 0 | pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); | 536 | 16.1k | } |
Unexecuted instantiation: pdf_fapi.c:pdfi_set_warning |
537 | | |
538 | | /* Variants of the above that work in a printf style. */ |
539 | | void pdfi_set_error_var(pdf_context *ctx, int gs_error, const char *gs_lib_function, pdf_error pdfi_error, const char *pdfi_function_name, const char *fmt, ...); |
540 | | void pdfi_set_warning_var(pdf_context *ctx, int gs_error, const char *gs_lib_function, pdf_warning pdfi_warning, const char *pdfi_function_name, const char *fmt, ...); |
541 | | |
542 | | #define PURGE_CACHE_PER_PAGE 0 |
543 | | |
544 | | #if PURGE_CACHE_PER_PAGE |
545 | | void pdfi_purge_obj_cache(pdf_context *ctx); |
546 | | #endif |
547 | | |
548 | | #endif |