summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2022-02-15 19:40:06 +0000
committerRobin Watts <Robin.Watts@artifex.com>2022-02-16 12:13:50 +0000
commit8ab9ed0869e1e010c1d6bd604462875d1a915f47 (patch)
tree80704f2e44b9144475227cec7582dfd674ba54a8
parent898af912a11457c4c0e0dec7d058e3336b7c59e2 (diff)
downloadghostpdl-8ab9ed0869e1e010c1d6bd604462875d1a915f47.tar.gz
Move pdfi warning and error definitions into their own file.
This avoids having 2 tables of errors (enum and error strings) defined in 2 separate files that need to be kept in sync. Same for warnings.
-rw-r--r--pdf/ghostpdf.c83
-rw-r--r--pdf/ghostpdf.h81
-rw-r--r--pdf/pdf_errors.h55
-rw-r--r--pdf/pdf_warnings.h60
-rw-r--r--windows/ghostpdf.vcxproj4
-rw-r--r--windows/ghostpdf.vcxproj.filters6
6 files changed, 134 insertions, 155 deletions
diff --git a/pdf/ghostpdf.c b/pdf/ghostpdf.c
index 6bdad2eed..8341a96e7 100644
--- a/pdf/ghostpdf.c
+++ b/pdf/ghostpdf.c
@@ -304,86 +304,15 @@ static int pdfi_output_page_info(pdf_context *ctx, uint64_t page_num)
* 'unknown' message.
*/
const char *pdf_error_strings[] = {
- "no error",
- "no header detected",
- "header lacks a version number",
- "no startxref token found",
- "startxref offset invalid",
- "couldn't read hybrid file's XrefStm",
- "error in xref table",
- "too few entries in xref table",
- "content stream lacks endstream",
- "request for unknown filter",
- "missing white space after number",
- "malformed number",
- "unbalanced or unescaped character '(' in string",
- "invalid object number",
- "object lacks an endobj",
- "error executing PDF token",
- "potential token is too long",
- "Page object doe snot have /Page type",
- "circular reference to indirect object",
- "couldn't repair PDF file",
- "PDF file was repaired",
- "error reading a stream",
- "obj token missing",
- "error in Page dictionary",
- "out of memory",
- "error reading page dictionary",
- "stack underflow",
- "error in stream dictionary",
- "stream inherited a resource",
- "counting down reference to freed object",
- "error in transparency XObject",
- "object lacks a required Subtype",
- "error in image colour",
- "dictionary contains a key which (indirectly) references the dictionary.",
- "Image has both ImageMask and ColorSpace keys.",
- "" /* last error, should not be used */
+#define PARAM(A,B) B
+#include "pdf_errors.h"
+ "" /* last error, should not be used */
};
const char *pdf_warning_strings[] = {
- "no warning",
- "incorrect xref size",
- "used inline filter name inappropriately",
- "used inline colour space inappropriately",
- "used inline image key inappropriately",
- "recoverable image error",
- "recoverable error in image dictionary",
- "encountered more Q than q",
- "encountered more q than Q",
- "garbage left on stack",
- "stack underflow",
- "error in group definition",
- "invalid operator used in text block",
- "used invalid operator in CharProc",
- "BT found inside a text block",
- "ET found outside text block",
- "text operator outside text block",
- "degenerate text matrix",
- "bad ICC colour profile, using alternate",
- "bad ICC vs number components, using components",
- "bad value for text rendering mode",
- "error in shading",
- "error in pattern",
- "non standard operator found - ignoring",
- "number uses illegal exponent form",
- "Stream has inappropriate /Contents entry",
- "bad DecodeParms",
- "error in Mask",
- "error in annotation Appearance",
- "badly escaped name",
- "typecheck error",
- "bad trailer dictionary",
- "error in annotation",
- "failed to create ICC profile link",
- "overflowed a real reading a number, assuming 0",
- "failed to read a valid number, assuming 0",
- "A DeviceN space used the /All ink name.",
- "Couldn't retrieve MediaBox for page, using current media size",
- "CA or ca value not in range 0.0 to 1.0, clamped to range.",
- "Invalid DefaultGray, DefaultRGB or DefaultCMYK space specified, ignored.",
- "" /* Last warning shuld not be used */
+#define PARAM(A,B) B
+#include "pdf_warnings.h"
+ "" /* Last warning should not be used */
};
const char *gs_error_strings[] = {
diff --git a/pdf/ghostpdf.h b/pdf/ghostpdf.h
index 65b631627..fc260d4dc 100644
--- a/pdf/ghostpdf.h
+++ b/pdf/ghostpdf.h
@@ -54,86 +54,13 @@ typedef struct pdf_context_switch {
* how to deal with this.
*/
typedef enum pdf_error_e {
- E_PDF_NOERROR,
- E_PDF_NOHEADER,
- E_PDF_NOHEADERVERSION,
- E_PDF_NOSTARTXREF,
- E_PDF_BADSTARTXREF,
- E_PDF_BADXREFSTREAM,
- E_PDF_BADXREF,
- E_PDF_SHORTXREF,
- E_PDF_MISSINGENDSTREAM,
- E_PDF_UNKNOWNFILTER,
- E_PDF_MISSINGWHITESPACE,
- E_PDF_MALFORMEDNUMBER,
- E_PDF_UNESCAPEDSTRING,
- E_PDF_BADOBJNUMBER,
- E_PDF_MISSINGENDOBJ,
- E_PDF_TOKENERROR,
- E_PDF_KEYWORDTOOLONG,
- E_PDF_BADPAGETYPE,
- E_PDF_CIRCULARREF,
- E_PDF_UNREPAIRABLE,
- E_PDF_REPAIRED,
- E_PDF_BADSTREAM,
- E_PDF_MISSINGOBJ,
- E_PDF_BADPAGEDICT,
- E_PDF_OUTOFMEMORY,
- E_PDF_PAGEDICTERROR,
- E_PDF_STACKUNDERFLOWERROR,
- E_PDF_BADSTREAMDICT,
- E_PDF_INHERITED_STREAM_RESOURCE,
- E_PDF_DEREF_FREE_OBJ,
- E_PDF_INVALID_TRANS_XOBJECT,
- E_PDF_NO_SUBTYPE,
- E_PDF_IMAGECOLOR_ERROR,
- E_DICT_SELF_REFERENCE,
- E_IMAGE_MASKWITHCOLOR,
- E_PDF_MAX_ERROR /* Must be last entry, add new errors immediately before this and update pdf_error_strings in ghostpdf.c */
+#include "pdf_errors.h"
+ E_PDF_MAX_ERROR /* last entry */
}pdf_error;
typedef enum pdf_warning_e {
- W_PDF_NOWARNING,
- W_PDF_BAD_XREF_SIZE,
- W_PDF_BAD_INLINEFILTER,
- W_PDF_BAD_INLINECOLORSPACE,
- W_PDF_BAD_INLINEIMAGEKEY,
- W_PDF_IMAGE_ERROR,
- W_PDF_BAD_IMAGEDICT,
- W_PDF_TOOMANYQ,
- W_PDF_TOOMANYq,
- W_PDF_STACKGARBAGE,
- W_PDF_STACKUNDERFLOW,
- W_PDF_GROUPERROR,
- W_PDF_OPINVALIDINTEXT,
- W_PDF_NOTINCHARPROC,
- W_PDF_NESTEDTEXTBLOCK,
- W_PDF_ETNOTEXTBLOCK,
- W_PDF_TEXTOPNOBT,
- W_PDF_DEGENERATETM,
- W_PDF_BADICC_USE_ALT,
- W_PDF_BADICC_USECOMPS,
- W_PDF_BADTRSWITCH,
- W_PDF_BADSHADING,
- W_PDF_BADPATTERN,
- W_PDF_NONSTANDARD_OP,
- W_PDF_NUM_EXPONENT,
- W_PDF_STREAM_HAS_CONTENTS,
- W_PDF_STREAM_BAD_DECODEPARMS,
- W_PDF_MASK_ERROR,
- W_PDF_ANNOT_AP_ERROR,
- W_PDF_BAD_NAME_ESCAPE,
- W_PDF_TYPECHECK,
- W_PDF_BAD_TRAILER,
- W_PDF_ANNOT_ERROR,
- W_PDF_BAD_ICC_PROFILE_LINK,
- W_PDF_OVERFLOW_REAL,
- W_PDF_INVALID_REAL,
- W_PDF_DEVICEN_USES_ALL,
- W_PDF_BAD_MEDIABOX,
- W_PDF_CA_OUTOFRANGE,
- W_PDF_INVALID_DEFAULTSPACE,
- W_PDF_MAX_WARNING /* Must be last entry, add new warnings immediately before this and update pdf_warning_strings in ghostpdf.c */
+#include "pdf_warnings.h"
+ W_PDF_MAX_WARNING /* last entry */
} pdf_warning;
#define PDF_ERROR_BYTE_SIZE ((E_PDF_MAX_ERROR - 1) / (sizeof(char) * 8) + 1)
diff --git a/pdf/pdf_errors.h b/pdf/pdf_errors.h
new file mode 100644
index 000000000..4d15f26bf
--- /dev/null
+++ b/pdf/pdf_errors.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 2022 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+ implied.
+
+ This software is distributed under license and may not be copied,
+ modified or distributed except as expressly authorized under the terms
+ of the license contained in the file LICENSE in this distribution.
+
+ Refer to licensing information at http://www.artifex.com or contact
+ Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
+ CA 94945, U.S.A., +1(415)492-9861, for further information.
+*/
+
+#ifndef PARAM
+#define PARAM(A,B) A
+#endif
+PARAM(E_PDF_NOERROR, "no error"),
+PARAM(E_PDF_NOHEADER, "no header detected"),
+PARAM(E_PDF_NOHEADERVERSION, "header lacks a version number"),
+PARAM(E_PDF_NOSTARTXREF, "no startxref token found"),
+PARAM(E_PDF_BADSTARTXREF, "startxref offset invalid"),
+PARAM(E_PDF_BADXREFSTREAM, "couldn't read hybrid file's XrefStm"),
+PARAM(E_PDF_BADXREF, "error in xref table"),
+PARAM(E_PDF_SHORTXREF, "too few entries in xref table"),
+PARAM(E_PDF_MISSINGENDSTREAM, "content stream lacks endstream"),
+PARAM(E_PDF_UNKNOWNFILTER, "request for unknown filter"),
+PARAM(E_PDF_MISSINGWHITESPACE, "missing white space after number"),
+PARAM(E_PDF_MALFORMEDNUMBER, "malformed number"),
+PARAM(E_PDF_UNESCAPEDSTRING, "unbalanced or unescaped character '(' in string"),
+PARAM(E_PDF_BADOBJNUMBER, "invalid object number"),
+PARAM(E_PDF_MISSINGENDOBJ, "object lacks an endobj"),
+PARAM(E_PDF_TOKENERROR, "error executing PDF token"),
+PARAM(E_PDF_KEYWORDTOOLONG, "potential token is too long"),
+PARAM(E_PDF_BADPAGETYPE, "Page object doe snot have /Page type"),
+PARAM(E_PDF_CIRCULARREF, "circular reference to indirect object"),
+PARAM(E_PDF_UNREPAIRABLE, "couldn't repair PDF file"),
+PARAM(E_PDF_REPAIRED, "PDF file was repaired"),
+PARAM(E_PDF_BADSTREAM, "error reading a stream"),
+PARAM(E_PDF_MISSINGOBJ, "obj token missing"),
+PARAM(E_PDF_BADPAGEDICT, "error in Page dictionary"),
+PARAM(E_PDF_OUTOFMEMORY, "out of memory"),
+PARAM(E_PDF_PAGEDICTERROR, "error reading page dictionary"),
+PARAM(E_PDF_STACKUNDERFLOWERROR, "stack underflow"),
+PARAM(E_PDF_BADSTREAMDICT, "error in stream dictionary"),
+PARAM(E_PDF_INHERITED_STREAM_RESOURCE, "stream inherited a resource"),
+PARAM(E_PDF_DEREF_FREE_OBJ, "counting down reference to freed object"),
+PARAM(E_PDF_INVALID_TRANS_XOBJECT, "error in transparency XObject"),
+PARAM(E_PDF_NO_SUBTYPE, "object lacks a required Subtype"),
+PARAM(E_PDF_IMAGECOLOR_ERROR, "error in image colour"),
+PARAM(E_DICT_SELF_REFERENCE, "dictionary contains a key which (indirectly) references the dictionary."),
+PARAM(E_IMAGE_MASKWITHCOLOR, "Image has both ImageMask and ColorSpace keys."),
+
+#undef PARAM
diff --git a/pdf/pdf_warnings.h b/pdf/pdf_warnings.h
new file mode 100644
index 000000000..04999b828
--- /dev/null
+++ b/pdf/pdf_warnings.h
@@ -0,0 +1,60 @@
+/* Copyright (C) 2022 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+ implied.
+
+ This software is distributed under license and may not be copied,
+ modified or distributed except as expressly authorized under the terms
+ of the license contained in the file LICENSE in this distribution.
+
+ Refer to licensing information at http://www.artifex.com or contact
+ Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
+ CA 94945, U.S.A., +1(415)492-9861, for further information.
+*/
+
+#ifndef PARAM
+#define PARAM(A,B) A
+#endif
+PARAM(W_PDF_NOWARNING, "no warning"),
+PARAM(W_PDF_BAD_XREF_SIZE, "incorrect xref size"),
+PARAM(W_PDF_BAD_INLINEFILTER, "used inline filter name inappropriately"),
+PARAM(W_PDF_BAD_INLINECOLORSPACE, "used inline colour space inappropriately"),
+PARAM(W_PDF_BAD_INLINEIMAGEKEY, "used inline image key inappropriately"),
+PARAM(W_PDF_IMAGE_ERROR, "recoverable image error"),
+PARAM(W_PDF_BAD_IMAGEDICT, "recoverable error in image dictionary"),
+PARAM(W_PDF_TOOMANYQ, "encountered more Q than q"),
+PARAM(W_PDF_TOOMANYq, "encountered more q than Q"),
+PARAM(W_PDF_STACKGARBAGE, "garbage left on stack"),
+PARAM(W_PDF_STACKUNDERFLOW, "stack underflow"),
+PARAM(W_PDF_GROUPERROR, "error in group definition"),
+PARAM(W_PDF_OPINVALIDINTEXT, "invalid operator used in text block"),
+PARAM(W_PDF_NOTINCHARPROC, "used invalid operator in CharProc"),
+PARAM(W_PDF_NESTEDTEXTBLOCK, "BT found inside a text block"),
+PARAM(W_PDF_ETNOTEXTBLOCK, "ET found outside text block"),
+PARAM(W_PDF_TEXTOPNOBT, "text operator outside text block"),
+PARAM(W_PDF_DEGENERATETM, "degenerate text matrix"),
+PARAM(W_PDF_BADICC_USE_ALT, "bad ICC colour profile, using alternate"),
+PARAM(W_PDF_BADICC_USECOMPS, "bad ICC vs number components, using components"),
+PARAM(W_PDF_BADTRSWITCH, "bad value for text rendering mode"),
+PARAM(W_PDF_BADSHADING, "error in shading"),
+PARAM(W_PDF_BADPATTERN, "error in pattern"),
+PARAM(W_PDF_NONSTANDARD_OP, "non standard operator found - ignoring"),
+PARAM(W_PDF_NUM_EXPONENT, "number uses illegal exponent form"),
+PARAM(W_PDF_STREAM_HAS_CONTENTS, "Stream has inappropriate /Contents entry"),
+PARAM(W_PDF_STREAM_BAD_DECODEPARMS, "bad DecodeParms"),
+PARAM(W_PDF_MASK_ERROR, "error in Mask"),
+PARAM(W_PDF_ANNOT_AP_ERROR, "error in annotation Appearance"),
+PARAM(W_PDF_BAD_NAME_ESCAPE, "badly escaped name"),
+PARAM(W_PDF_TYPECHECK, "typecheck error"),
+PARAM(W_PDF_BAD_TRAILER, "bad trailer dictionary"),
+PARAM(W_PDF_ANNOT_ERROR, "error in annotation"),
+PARAM(W_PDF_BAD_ICC_PROFILE_LINK, "failed to create ICC profile link"),
+PARAM(W_PDF_OVERFLOW_REAL, "overflowed a real reading a number, assuming 0"),
+PARAM(W_PDF_INVALID_REAL, "failed to read a valid number, assuming 0"),
+PARAM(W_PDF_DEVICEN_USES_ALL, "A DeviceN space used the /All ink name."),
+PARAM(W_PDF_BAD_MEDIABOX, "Couldn't retrieve MediaBox for page, using current media size"),
+PARAM(W_PDF_CA_OUTOFRANGE, "CA or ca value not in range 0.0 to 1.0, clamped to range."),
+PARAM(W_PDF_INVALID_DEFAULTSPACE, "Invalid DefaultGray, DefaultRGB or DefaultCMYK space specified, ignored."),
+
+#undef PARAM
diff --git a/windows/ghostpdf.vcxproj b/windows/ghostpdf.vcxproj
index 7615ec842..73ea04d03 100644
--- a/windows/ghostpdf.vcxproj
+++ b/windows/ghostpdf.vcxproj
@@ -356,6 +356,7 @@
<ClInclude Include="..\pdf\pdf_device.h" />
<ClInclude Include="..\pdf\pdf_dict.h" />
<ClInclude Include="..\pdf\pdf_doc.h" />
+ <ClInclude Include="..\pdf\pdf_errors.h" />
<ClInclude Include="..\pdf\pdf_file.h" />
<ClInclude Include="..\pdf\pdf_fmap.h" />
<ClInclude Include="..\pdf\pdf_font.h" />
@@ -386,9 +387,10 @@
<ClInclude Include="..\pdf\pdf_trans.h" />
<ClInclude Include="..\pdf\pdf_types.h" />
<ClInclude Include="..\pdf\pdf_utf8.h" />
+ <ClInclude Include="..\pdf\pdf_warnings.h" />
<ClInclude Include="..\pdf\pdf_xref.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/windows/ghostpdf.vcxproj.filters b/windows/ghostpdf.vcxproj.filters
index 3a43e9281..6de2eaba1 100644
--- a/windows/ghostpdf.vcxproj.filters
+++ b/windows/ghostpdf.vcxproj.filters
@@ -272,5 +272,11 @@
<ClInclude Include="..\pdf\pdf_utf8.h">
<Filter>pdf %28%2a.h%29</Filter>
</ClInclude>
+ <ClInclude Include="..\pdf\pdf_errors.h">
+ <Filter>pdf %28%2a.h%29</Filter>
+ </ClInclude>
+ <ClInclude Include="..\pdf\pdf_warnings.h">
+ <Filter>pdf %28%2a.h%29</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file