Debian Codegraph @

pdf/pdf_int.h

raw
1 /* Copyright (C) 2018-2023 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., 39 Mesa Street, Suite 108A, San Francisco,
13 CA 94129, USA, for further information.
14 */
15
16 #ifndef PDF_INTERPRETER
17 #define PDF_INTERPRETER
18
19 #include "ghostpdf.h"
20 #include "pdf_types.h"
21
22
23 static inline bool ishex(char c)
24 {
25 if (c < 0x30)
26 return false;
27
28 if (c > 0x39) {
29 if (c > 'F') {
30 if (c < 'a')
31 return false;
32 if (c > 'f')
33 return false;
34 return true;
35 } else {
36 if (c < 'A')
37 return false;
38 return true;
39 }
40 } else
41 return true;
42 }
43
44 /* You must ensure the character is a hex character before calling this, no error trapping here */
45 static inline int fromhex(char c)
46 {
47 if (c > 0x39) {
48 if (c > 'F') {
49 return c - 0x57;
50 } else {
51 return c - 0x37;
52 }
53 } else
54 return c - 0x30;
55 }
56
57 int pdfi_skip_white(pdf_context *ctx, pdf_c_stream *s);
58 int pdfi_skip_eol(pdf_context *ctx, pdf_c_stream *s);
59 int pdfi_skip_comment(pdf_context *ctx, pdf_c_stream *s);
60 int pdfi_read_token(pdf_context *ctx, pdf_c_stream *s, uint32_t indirect_num, uint32_t indirect_gen);
61
62 int pdfi_name_alloc(pdf_context *ctx, byte *key, uint32_t size, pdf_obj **o);
63
64 int pdfi_read_dict(pdf_context *ctx, pdf_c_stream *s, uint32_t indirect_num, uint32_t indirect_gen);
65
66 int pdfi_read_bare_int(pdf_context *ctx, pdf_c_stream *s, int *parsed_int);
67 int pdfi_read_bare_keyword(pdf_context *ctx, pdf_c_stream *s);
68
69 void local_save_stream_state(pdf_context *ctx, stream_save *local_save);
70 void local_restore_stream_state(pdf_context *ctx, stream_save *local_save);
71 void cleanup_context_interpretation(pdf_context *ctx, stream_save *local_save);
72 void initialise_stream_save(pdf_context *ctx);
73 int pdfi_run_context(pdf_context *ctx, pdf_stream *stream_obj, pdf_dict *page_dict, bool stoponerror, const char *desc);
74 int pdfi_interpret_inner_content_buffer(pdf_context *ctx, byte *content_data, uint32_t content_length,
75 pdf_dict *stream_dict, pdf_dict *page_dict,
76 bool stoponerror, const char *desc);
77 int pdfi_interpret_inner_content_c_string(pdf_context *ctx, char *content_string,
78 pdf_dict *stream_dict, pdf_dict *page_dict,
79 bool stoponerror, const char *desc);
80 int pdfi_interpret_inner_content_string(pdf_context *ctx, pdf_string *content_string,
81 pdf_dict *stream_dict, pdf_dict *page_dict,
82 bool stoponerror, const char *desc);
83 int pdfi_interpret_inner_content_stream(pdf_context *ctx, pdf_stream *stream_obj, pdf_dict *page_dict, bool stoponerror, const char *desc);
84 int pdfi_interpret_content_stream(pdf_context *ctx, pdf_c_stream *content_stream, pdf_stream *stream_obj, pdf_dict *page_dict);
85
86 #endif