@libgs/linux-x64 0.0.0-stage → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,280 @@
1
+ /* Copyright (C) 2001-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
+
17
+ /* Error code definitions */
18
+
19
+ #ifndef gserrors_INCLUDED
20
+ # define gserrors_INCLUDED
21
+
22
+ /* A procedure that may return an error always returns */
23
+ /* a non-negative value (zero, unless otherwise noted) for success, */
24
+ /* or negative for failure. */
25
+ /* We don't use a typedef internally to avoid a lot of casting. */
26
+
27
+ enum gs_error_type {
28
+ gs_error_ok = 0,
29
+ gs_error_unknownerror = -1, /* unknown error */
30
+ gs_error_dictfull = -2,
31
+ gs_error_dictstackoverflow = -3,
32
+ gs_error_dictstackunderflow = -4,
33
+ gs_error_execstackoverflow = -5,
34
+ gs_error_interrupt = -6,
35
+ gs_error_invalidaccess = -7,
36
+ gs_error_invalidexit = -8,
37
+ gs_error_invalidfileaccess = -9,
38
+ gs_error_invalidfont = -10,
39
+ gs_error_invalidrestore = -11,
40
+ gs_error_ioerror = -12,
41
+ gs_error_limitcheck = -13,
42
+ gs_error_nocurrentpoint = -14,
43
+ gs_error_rangecheck = -15,
44
+ gs_error_stackoverflow = -16,
45
+ gs_error_stackunderflow = -17,
46
+ gs_error_syntaxerror = -18,
47
+ gs_error_timeout = -19,
48
+ gs_error_typecheck = -20,
49
+ gs_error_undefined = -21,
50
+ gs_error_undefinedfilename = -22,
51
+ gs_error_undefinedresult = -23,
52
+ gs_error_unmatchedmark = -24,
53
+ gs_error_VMerror = -25, /* must be the last Level 1 error */
54
+
55
+ /* ------ Additional Level 2 errors (also in DPS, ------ */
56
+
57
+ gs_error_configurationerror = -26,
58
+ gs_error_undefinedresource = -27,
59
+
60
+ gs_error_unregistered = -28,
61
+ gs_error_invalidcontext = -29,
62
+ /* invalidid is for the NeXT DPS extension. */
63
+ gs_error_invalidid = -30,
64
+
65
+ /* We need a specific stackoverflow error for the PDF interpreter to avoid dropping into
66
+ * the Postscript interpreter's stack extending code, when the PDF interpreter is called from
67
+ * Postscript
68
+ */
69
+ gs_error_pdf_stackoverflow = -31,
70
+
71
+ /* Internal error for the C-based PDF interpreter, to indicate a circular PDF reference */
72
+ gs_error_circular_reference = -32,
73
+
74
+ /* ------ Pseudo-errors used internally ------ */
75
+
76
+ gs_error_hit_detected = -99,
77
+
78
+ gs_error_Fatal = -100,
79
+ /*
80
+ * Internal code for the .quit operator.
81
+ * The real quit code is an integer on the operand stack.
82
+ * gs_interpret returns this only for a .quit with a zero exit code.
83
+ */
84
+ gs_error_Quit = -101,
85
+
86
+ /*
87
+ * Internal code for a normal exit from the interpreter.
88
+ * Do not use outside of interp.c.
89
+ */
90
+ gs_error_InterpreterExit = -102,
91
+
92
+ /* Need the remap color error for high level pattern support */
93
+ gs_error_Remap_Color = -103,
94
+
95
+ /*
96
+ * Internal code to indicate we have underflowed the top block
97
+ * of the e-stack.
98
+ */
99
+ gs_error_ExecStackUnderflow = -104,
100
+
101
+ /*
102
+ * Internal code for the vmreclaim operator with a positive operand.
103
+ * We need to handle this as an error because otherwise the interpreter
104
+ * won't reload enough of its state when the operator returns.
105
+ */
106
+ gs_error_VMreclaim = -105,
107
+
108
+ /*
109
+ * Internal code for requesting more input from run_string.
110
+ */
111
+ gs_error_NeedInput = -106,
112
+
113
+ /*
114
+ * Internal code to all run_string to request that the data is rerun
115
+ * using run_file.
116
+ */
117
+ gs_error_NeedFile = -107,
118
+
119
+ /*
120
+ * Internal code for a normal exit when usage info is displayed.
121
+ * This allows Window versions of Ghostscript to pause until
122
+ * the message can be read.
123
+ */
124
+ gs_error_Info = -110,
125
+
126
+ /* A special 'error', like reamp color above. This is used by a subclassing
127
+ * device to indicate that it has fully processed a device method, and parent
128
+ * subclasses should not perform any further action. Currently this is limited
129
+ * to compositor creation.
130
+ */
131
+ gs_error_handled = -111,
132
+
133
+ };
134
+
135
+ /* We do provide a typedef type for external API use */
136
+ typedef enum gs_error_type gs_error_t;
137
+
138
+ int gs_log_error(int, const char *, int);
139
+ #if !defined(DEBUG)
140
+ # define gs_log_error(err, file, line) (err)
141
+ #endif
142
+ #define gs_note_error(err) gs_log_error(err, __FILE__, __LINE__)
143
+ #define return_error(err) return gs_note_error(err)
144
+
145
+ #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
146
+ # if defined(__GNUC__) && __GNUC__ >= 2
147
+ # define __func__ __FUNCTION__
148
+ # elif defined(__FUNCTION__)
149
+ # define __func__ __FUNCTION__
150
+ # elif defined(__FUNC__)
151
+ # define __func__ __FUNC__
152
+ # else
153
+ # define __func__ "<unknown>"
154
+ # endif
155
+ #endif
156
+
157
+ /*
158
+ * Error reporting macros.
159
+ *
160
+ */
161
+
162
+ #ifndef __printflike
163
+ #if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7
164
+ #define __printflike(fmtarg, firstvararg) \
165
+ __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
166
+ #else
167
+ #define __printflike(fmtarg, firstvararg)
168
+ #endif
169
+ #endif
170
+
171
+ const char *gs_errstr(int code);
172
+
173
+ int gs_throw_imp(const char *func, const char *file, int line,
174
+ int op, int code, const char *fmt, ...) __printflike(6, 7);
175
+
176
+ /* Use throw at origin of error
177
+ */
178
+ #define gs_throw_code(code) \
179
+ gs_throw1((code), "%s", gs_errstr((code)))
180
+
181
+ #define gs_throw(code, fmt) \
182
+ gs_throw_imp(__func__, __FILE__, __LINE__, 0, code, fmt)
183
+ #define gs_throw1(code, fmt, arg1) \
184
+ gs_throw_imp(__func__, __FILE__, __LINE__, 0, code, fmt, arg1)
185
+ #define gs_throw2(code, fmt, arg1, arg2) \
186
+ gs_throw_imp(__func__, __FILE__, __LINE__, 0, code, fmt, arg1, arg2)
187
+ #define gs_throw3(code, fmt, arg1, arg2, arg3) \
188
+ gs_throw_imp(__func__, __FILE__, __LINE__, 0, code, fmt, arg1, arg2, arg3)
189
+ #define gs_throw4(code, fmt, arg1, arg2, arg3, arg4) \
190
+ gs_throw_imp(__func__, __FILE__, __LINE__, 0, code, fmt, arg1, arg2, arg3, arg4)
191
+ #define gs_throw5(code, fmt, arg1, arg2, arg3, arg4, arg5) \
192
+ gs_throw_imp(__func__, __FILE__, __LINE__, 0, code, fmt, arg1, arg2, arg3, arg4, arg5)
193
+ #define gs_throw6(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
194
+ gs_throw_imp(__func__, __FILE__, __LINE__, 0, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
195
+ #define gs_throw7(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
196
+ gs_throw_imp(__func__, __FILE__, __LINE__, 0, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
197
+ #define gs_throw8(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
198
+ gs_throw_imp(__func__, __FILE__, __LINE__, 0, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
199
+ #define gs_throw9(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
200
+ gs_throw_imp(__func__, __FILE__, __LINE__, 0, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
201
+
202
+ /* Bubble the code up the stack
203
+ */
204
+ #define gs_rethrow_code(code) \
205
+ gs_rethrow1((code), "%s", gs_errstr((code)))
206
+
207
+ #define gs_rethrow(code, fmt) \
208
+ gs_throw_imp(__func__, __FILE__, __LINE__, 1, code, fmt)
209
+ #define gs_rethrow1(code, fmt, arg1) \
210
+ gs_throw_imp(__func__, __FILE__, __LINE__, 1, code, fmt, arg1)
211
+ #define gs_rethrow2(code, fmt, arg1, arg2) \
212
+ gs_throw_imp(__func__, __FILE__, __LINE__, 1, code, fmt, arg1, arg2)
213
+ #define gs_rethrow3(code, fmt, arg1, arg2, arg3) \
214
+ gs_throw_imp(__func__, __FILE__, __LINE__, 1, code, fmt, arg1, arg2, arg3)
215
+ #define gs_rethrow4(code, fmt, arg1, arg2, arg3, arg4) \
216
+ gs_throw_imp(__func__, __FILE__, __LINE__, 1, code, fmt, arg1, arg2, arg3, arg4)
217
+ #define gs_rethrow5(code, fmt, arg1, arg2, arg3, arg4, arg5) \
218
+ gs_throw_imp(__func__, __FILE__, __LINE__, 1, code, fmt, arg1, arg2, arg3, arg4, arg5)
219
+ #define gs_rethrow6(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
220
+ gs_throw_imp(__func__, __FILE__, __LINE__, 1, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
221
+ #define gs_rethrow7(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
222
+ gs_throw_imp(__func__, __FILE__, __LINE__, 1, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
223
+ #define gs_rethrow8(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
224
+ gs_throw_imp(__func__, __FILE__, __LINE__, 1, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
225
+ #define gs_rethrow9(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
226
+ gs_throw_imp(__func__, __FILE__, __LINE__, 1, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
227
+
228
+ /* This will cause trouble, as it implies you are fixing an error
229
+ * the system will spew messages
230
+ */
231
+ #define gs_catch(code, fmt) \
232
+ gs_throw_imp(__func__, __FILE__, __LINE__, 2, code, fmt)
233
+ #define gs_catch1(code, fmt, arg1) \
234
+ gs_throw_imp(__func__, __FILE__, __LINE__, 2, code, fmt, arg1)
235
+ #define gs_catch2(code, fmt, arg1, arg2) \
236
+ gs_throw_imp(__func__, __FILE__, __LINE__, 2, code, fmt, arg1, arg2)
237
+ #define gs_catch3(code, fmt, arg1, arg2, arg3) \
238
+ gs_throw_imp(__func__, __FILE__, __LINE__, 2, code, fmt, arg1, arg2, arg3)
239
+ #define gs_catch4(code, fmt, arg1, arg2, arg3, arg4) \
240
+ gs_throw_imp(__func__, __FILE__, __LINE__, 2, code, fmt, arg1, arg2, arg3, arg4)
241
+ #define gs_catch5(code, fmt, arg1, arg2, arg3, arg4, arg5) \
242
+ gs_throw_imp(__func__, __FILE__, __LINE__, 2, code, fmt, arg1, arg2, arg3, arg4, arg5)
243
+ #define gs_catch6(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
244
+ gs_throw_imp(__func__, __FILE__, __LINE__, 2, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
245
+ #define gs_catch7(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
246
+ gs_throw_imp(__func__, __FILE__, __LINE__, 2, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
247
+ #define gs_catch8(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
248
+ gs_throw_imp(__func__, __FILE__, __LINE__, 2, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
249
+ #define gs_catch9(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
250
+ gs_throw_imp(__func__, __FILE__, __LINE__, 2, code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
251
+
252
+ /* gs_warn is a printf
253
+ */
254
+ #define gs_warn(fmt) \
255
+ (void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt)
256
+ #define gs_warn1(fmt, arg1) \
257
+ (void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1)
258
+ #define gs_warn2(fmt, arg1, arg2) \
259
+ (void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2)
260
+ #define gs_warn3(fmt, arg1, arg2, arg3) \
261
+ (void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3)
262
+ #define gs_warn4(fmt, arg1, arg2, arg3, arg4) \
263
+ (void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3, arg4)
264
+ #define gs_warn5(fmt, arg1, arg2, arg3, arg4, arg5) \
265
+ (void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3, arg4, arg5)
266
+ #define gs_warn6(fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
267
+ (void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
268
+ #define gs_warn7(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
269
+ (void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
270
+ #define gs_warn8(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
271
+ (void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
272
+ #define gs_warn9(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
273
+ (void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
274
+
275
+ /* just in case you don't know 0 means no error
276
+ * other return codes are errors.
277
+ */
278
+ #define gs_okay 0
279
+
280
+ #endif /* gserrors_INCLUDED */