From b67a3c15e768ed88ea3cdf7525c1ddc649aec2fe Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 19 Oct 2009 20:17:14 +0000 Subject: DLL.hh -> DLL.h, move public enumerated types into Constants.h and use them both for C and C++ interfaces git-svn-id: svn+q:///qpdf/trunk@828 71b93d88-0707-0410-a8cf-f5a4172ac649 --- examples/pdf-mod-info.cc | 2 +- include/qpdf/Buffer.hh | 2 +- include/qpdf/Constants.h | 52 ++++++++++++++++++++++++++++++++ include/qpdf/DLL.h | 10 +++++++ include/qpdf/DLL.hh | 10 ------- include/qpdf/Pipeline.hh | 2 +- include/qpdf/QPDF.hh | 2 +- include/qpdf/QPDFExc.hh | 2 +- include/qpdf/QPDFObject.hh | 2 +- include/qpdf/QPDFObjectHandle.hh | 2 +- include/qpdf/QPDFTokenizer.hh | 2 +- include/qpdf/QPDFWriter.hh | 33 ++++++-------------- include/qpdf/QPDFXRefEntry.hh | 2 +- include/qpdf/QTC.hh | 2 +- include/qpdf/QUtil.hh | 2 +- include/qpdf/qpdf-c.h | 35 +++++----------------- libqpdf/QPDFWriter.cc | 55 +++++++++++++++++----------------- libqpdf/QUtil.cc | 1 - libqpdf/qpdf-c.cc | 65 ++++++---------------------------------- libqpdf/qpdf/BitStream.hh | 2 +- libqpdf/qpdf/BitWriter.hh | 2 +- libqpdf/qpdf/MD5.hh | 2 +- libqpdf/qpdf/PCRE.hh | 2 +- qpdf/qpdf-ctest.c | 8 ++--- qpdf/qpdf.cc | 38 +++++++++++------------ 25 files changed, 154 insertions(+), 183 deletions(-) create mode 100644 include/qpdf/Constants.h create mode 100644 include/qpdf/DLL.h delete mode 100644 include/qpdf/DLL.hh diff --git a/examples/pdf-mod-info.cc b/examples/pdf-mod-info.cc index 45425634..ef5a280d 100644 --- a/examples/pdf-mod-info.cc +++ b/examples/pdf-mod-info.cc @@ -200,7 +200,7 @@ int main(int argc, char* argv[]) } } QPDFWriter w(file, fl_tmp.c_str()); - w.setStreamDataMode(QPDFWriter::s_preserve); + w.setStreamDataMode(qpdf_s_preserve); w.setLinearization(true); w.setStaticID(static_id); w.write(); diff --git a/include/qpdf/Buffer.hh b/include/qpdf/Buffer.hh index 8da972ca..36f673ce 100644 --- a/include/qpdf/Buffer.hh +++ b/include/qpdf/Buffer.hh @@ -8,7 +8,7 @@ #ifndef __BUFFER_HH__ #define __BUFFER_HH__ -#include +#include class DLL_EXPORT Buffer { diff --git a/include/qpdf/Constants.h b/include/qpdf/Constants.h new file mode 100644 index 00000000..31cefd54 --- /dev/null +++ b/include/qpdf/Constants.h @@ -0,0 +1,52 @@ +#ifndef __QPDFCONSTANTS_H__ +#define __QPDFCONSTANTS_H__ + +/* Keep this file 'C' compatible so it can be used from the C and C++ + * interfaces. + */ + +/* Error Codes */ + +enum qpdf_error_code_e +{ + qpdf_e_success = 0, + qpdf_e_internal, /* logic/programming error -- indicates bug */ + qpdf_e_system, /* I/O error, memory error, etc. */ + qpdf_e_unsupported, /* PDF feature not (yet) supported by qpdf */ + qpdf_e_password, /* incorrect password for encrypted file */ + qpdf_e_damaged_pdf /* syntax errors or other damage in PDF */ +}; + +/* Write Parameters */ + +enum qpdf_object_stream_e +{ + qpdf_o_disable = 0, /* disable object streams */ + qpdf_o_preserve, /* preserve object streams */ + qpdf_o_generate /* generate object streams */ +}; +enum qpdf_stream_data_e +{ + qpdf_s_uncompress = 0, /* uncompress stream data */ + qpdf_s_preserve, /* preserve stream data compression */ + qpdf_s_compress /* compress stream data */ +}; + +/* R3 Encryption Parameters */ + +enum qpdf_r3_print_e +{ + qpdf_r3p_full = 0, /* allow all printing */ + qpdf_r3p_low, /* allow only low-resolution printing */ + qpdf_r3p_none /* allow no printing */ +}; +enum qpdf_r3_modify_e +{ + qpdf_r3m_all = 0, /* allow all modification */ + qpdf_r3m_annotate, /* allow comment authoring and form operations */ + qpdf_r3m_form, /* allow form field fill-in or signing */ + qpdf_r3m_assembly, /* allow only document assembly */ + qpdf_r3m_none /* allow no modification */ +}; + +#endif /* __QPDFCONSTANTS_H__ */ diff --git a/include/qpdf/DLL.h b/include/qpdf/DLL.h new file mode 100644 index 00000000..b0c465a3 --- /dev/null +++ b/include/qpdf/DLL.h @@ -0,0 +1,10 @@ +#ifndef __QPDF_DLL_HH__ +#define __QPDF_DLL_HH__ + +#ifdef _WIN32 +# define DLL_EXPORT __declspec(dllexport) +#else +# define DLL_EXPORT +#endif + +#endif /* __QPDF_DLL_HH__ */ diff --git a/include/qpdf/DLL.hh b/include/qpdf/DLL.hh deleted file mode 100644 index 0b72ff0a..00000000 --- a/include/qpdf/DLL.hh +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __QPDF_DLL_HH__ -#define __QPDF_DLL_HH__ - -#ifdef _WIN32 -# define DLL_EXPORT __declspec(dllexport) -#else -# define DLL_EXPORT -#endif - -#endif // __QPDF_DLL_HH__ diff --git a/include/qpdf/Pipeline.hh b/include/qpdf/Pipeline.hh index 8b589e20..aefb1b0b 100644 --- a/include/qpdf/Pipeline.hh +++ b/include/qpdf/Pipeline.hh @@ -30,7 +30,7 @@ #ifndef __PIPELINE_HH__ #define __PIPELINE_HH__ -#include +#include #include class DLL_EXPORT Pipeline diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 44d069f4..9770f46d 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include diff --git a/include/qpdf/QPDFExc.hh b/include/qpdf/QPDFExc.hh index 341b5f0b..d9a61bf3 100644 --- a/include/qpdf/QPDFExc.hh +++ b/include/qpdf/QPDFExc.hh @@ -8,7 +8,7 @@ #ifndef __QPDFEXC_HH__ #define __QPDFEXC_HH__ -#include +#include #include class DLL_EXPORT QPDFExc: public std::runtime_error diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh index 99d56542..ff31f9a9 100644 --- a/include/qpdf/QPDFObject.hh +++ b/include/qpdf/QPDFObject.hh @@ -8,7 +8,7 @@ #ifndef __QPDFOBJECT_HH__ #define __QPDFOBJECT_HH__ -#include +#include #include diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 0a277384..0948fefe 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include diff --git a/include/qpdf/QPDFTokenizer.hh b/include/qpdf/QPDFTokenizer.hh index 705155a2..a48a78d6 100644 --- a/include/qpdf/QPDFTokenizer.hh +++ b/include/qpdf/QPDFTokenizer.hh @@ -8,7 +8,7 @@ #ifndef __QPDFTOKENIZER_HH__ #define __QPDFTOKENIZER_HH__ -#include +#include #include #include diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh index 9d92ffbb..15e9317b 100644 --- a/include/qpdf/QPDFWriter.hh +++ b/include/qpdf/QPDFWriter.hh @@ -19,7 +19,8 @@ #include #include -#include +#include +#include #include @@ -51,16 +52,14 @@ class DLL_EXPORT QPDFWriter // generate a conventional cross-reference table if there are no // object streams and a cross-reference stream if there are object // streams. The default is o_preserve. - enum object_stream_e { o_disable, o_preserve, o_generate }; - void setObjectStreamMode(object_stream_e); + void setObjectStreamMode(qpdf_object_stream_e); // Set value of stream data mode. In uncompress mode, we attempt // to uncompress any stream that we can. In preserve mode, we // preserve any filtering applied to streams. In compress mode, // if we can apply all filters and the stream is not already // optimally compressed, recompress the stream. - enum stream_data_e { s_uncompress, s_preserve, s_compress }; - void setStreamDataMode(stream_data_e); + void setStreamDataMode(qpdf_stream_data_e); // Set value of content stream normalization. The default is // "false". If true, we attempt to normalize newlines inside of @@ -137,28 +136,14 @@ class DLL_EXPORT QPDFWriter char const* user_password, char const* owner_password, bool allow_print, bool allow_modify, bool allow_extract, bool allow_annotate); - enum r3_print_e - { - r3p_full, // allow all printing - r3p_low, // allow only low-resolution printing - r3p_none // allow no printing - }; - enum r3_modify_e - { - r3m_all, // allow all modification - r3m_annotate, // allow comment authoring and form operations - r3m_form, // allow form field fill-in or signing - r3m_assembly, // allow only document assembly - r3m_none // allow no modification - }; void setR3EncryptionParameters( char const* user_password, char const* owner_password, bool allow_accessibility, bool allow_extract, - r3_print_e print, r3_modify_e modify); + qpdf_r3_print_e print, qpdf_r3_modify_e modify); void setR4EncryptionParameters( char const* user_password, char const* owner_password, bool allow_accessibility, bool allow_extract, - r3_print_e print, r3_modify_e modify, + qpdf_r3_print_e print, qpdf_r3_modify_e modify, bool encrypt_metadata, bool use_aes); // Create linearized output. Disables qdf mode, content @@ -203,7 +188,7 @@ class DLL_EXPORT QPDFWriter std::set& bits_to_clear, char const* user_password, char const* owner_password, bool allow_accessibility, bool allow_extract, - r3_print_e print, r3_modify_e modify); + qpdf_r3_print_e print, qpdf_r3_modify_e modify); void disableIncompatbleEncryption(float v); void setEncryptionParameters( char const* user_password, char const* owner_password, @@ -265,7 +250,7 @@ class DLL_EXPORT QPDFWriter bool normalize_content_set; bool normalize_content; bool stream_data_mode_set; - stream_data_e stream_data_mode; + qpdf_stream_data_e stream_data_mode; bool qdf_mode; bool static_id; bool suppress_original_object_ids; @@ -273,7 +258,7 @@ class DLL_EXPORT QPDFWriter bool encrypted; bool preserve_encryption; bool linearized; - object_stream_e object_stream_mode; + qpdf_object_stream_e object_stream_mode; std::string encryption_key; bool encrypt_metadata; bool encrypt_use_aes; diff --git a/include/qpdf/QPDFXRefEntry.hh b/include/qpdf/QPDFXRefEntry.hh index e5b79df5..05a3f21e 100644 --- a/include/qpdf/QPDFXRefEntry.hh +++ b/include/qpdf/QPDFXRefEntry.hh @@ -8,7 +8,7 @@ #ifndef __QPDFXREFENTRY_HH__ #define __QPDFXREFENTRY_HH__ -#include +#include class DLL_EXPORT QPDFXRefEntry { diff --git a/include/qpdf/QTC.hh b/include/qpdf/QTC.hh index 6e7e4a90..d91fa6a5 100644 --- a/include/qpdf/QTC.hh +++ b/include/qpdf/QTC.hh @@ -8,7 +8,7 @@ #ifndef __QTC_HH__ #define __QTC_HH__ -#include +#include namespace QTC { diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh index bfd59b61..de3d3a39 100644 --- a/include/qpdf/QUtil.hh +++ b/include/qpdf/QUtil.hh @@ -8,7 +8,7 @@ #ifndef __QUTIL_HH__ #define __QUTIL_HH__ -#include +#include #include #include #include diff --git a/include/qpdf/qpdf-c.h b/include/qpdf/qpdf-c.h index 8c112ba5..90b3e5f9 100644 --- a/include/qpdf/qpdf-c.h +++ b/include/qpdf/qpdf-c.h @@ -61,7 +61,8 @@ * primarily on differences between the C and C++ API. */ -#include +#include +#include #ifdef __cplusplus extern "C" { @@ -199,20 +200,13 @@ extern "C" { DLL_EXPORT QPDF_ERROR_CODE qpdf_init_write(qpdf_data qpdf, char const* filename); -# define QPDF_OBJECT_STREAM_DISABLE 0 -# define QPDF_OBJECT_STREAM_PRESERVE 1 -# define QPDF_OBJECT_STREAM_GENERATE 2 - - /* For mode, pass one of the QPDF_OBJECT_STREAM constants. */ DLL_EXPORT - void qpdf_set_object_stream_mode(qpdf_data qpdf, int mode); + void qpdf_set_object_stream_mode(qpdf_data qpdf, + enum qpdf_object_stream_e mode); -# define QPDF_STREAM_DATA_UNCOMPRESS 0 -# define QPDF_STREAM_DATA_PRESERVE 1 -# define QPDF_STREAM_DATA_COMPRESS 2 - /* For mode, pass one of the QPDF_STREAM_DATA constants. */ DLL_EXPORT - void qpdf_set_stream_data_mode(qpdf_data qpdf, int mode); + void qpdf_set_stream_data_mode(qpdf_data qpdf, + enum qpdf_stream_data_e mode); DLL_EXPORT void qpdf_set_content_normalization(qpdf_data qpdf, QPDF_BOOL value); @@ -245,30 +239,17 @@ extern "C" { QPDF_BOOL allow_print, QPDF_BOOL allow_modify, QPDF_BOOL allow_extract, QPDF_BOOL allow_annotate); -# define QPDF_R3_PRINT_FULL 0 -# define QPDF_R3_PRINT_LOW 1 -# define QPDF_R3_PRINT_NONE 2 - -# define QPDF_R3_MODIFY_ALL 0 -# define QPDF_R3_MODIFY_ANNOTATE 1 -# define QPDF_R3_MODIFY_FORM 2 -# define QPDF_R3_MODIFY_ASSEMBLY 3 -# define QPDF_R3_MODIFY_NONE 4 - - /* Value of print should be one of the QPDF_R3_PRINT constants. - * Value of modify should be one of the QPDF_R3_MODIFY constants. - */ DLL_EXPORT void qpdf_set_r3_encryption_parameters( qpdf_data qpdf, char const* user_password, char const* owner_password, QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract, - int print, int modify); + enum qpdf_r3_print_e print, enum qpdf_r3_modify_e modify); DLL_EXPORT void qpdf_set_r4_encryption_parameters( qpdf_data qpdf, char const* user_password, char const* owner_password, QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract, - int print, int modify, + enum qpdf_r3_print_e print, enum qpdf_r3_modify_e modify, QPDF_BOOL encrypt_metadata, QPDF_BOOL use_aes); DLL_EXPORT diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 320706b0..7a1caa46 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -29,7 +29,7 @@ QPDFWriter::QPDFWriter(QPDF& pdf, char const* filename) : normalize_content_set(false), normalize_content(false), stream_data_mode_set(false), - stream_data_mode(s_compress), + stream_data_mode(qpdf_s_compress), qdf_mode(false), static_id(false), suppress_original_object_ids(false), @@ -37,7 +37,7 @@ QPDFWriter::QPDFWriter(QPDF& pdf, char const* filename) : encrypted(false), preserve_encryption(true), linearized(false), - object_stream_mode(o_preserve), + object_stream_mode(qpdf_o_preserve), encrypt_metadata(true), encrypt_use_aes(false), encryption_dict_objid(0), @@ -77,13 +77,13 @@ QPDFWriter::~QPDFWriter() } void -QPDFWriter::setObjectStreamMode(object_stream_e mode) +QPDFWriter::setObjectStreamMode(qpdf_object_stream_e mode) { this->object_stream_mode = mode; } void -QPDFWriter::setStreamDataMode(stream_data_e mode) +QPDFWriter::setStreamDataMode(qpdf_stream_data_e mode) { this->stream_data_mode_set = true; this->stream_data_mode = mode; @@ -198,7 +198,7 @@ void QPDFWriter::setR3EncryptionParameters( char const* user_password, char const* owner_password, bool allow_accessibility, bool allow_extract, - r3_print_e print, r3_modify_e modify) + qpdf_r3_print_e print, qpdf_r3_modify_e modify) { std::set clear; interpretR3EncryptionParameters( @@ -212,7 +212,7 @@ void QPDFWriter::setR4EncryptionParameters( char const* user_password, char const* owner_password, bool allow_accessibility, bool allow_extract, - r3_print_e print, r3_modify_e modify, + qpdf_r3_print_e print, qpdf_r3_modify_e modify, bool encrypt_metadata, bool use_aes) { std::set clear; @@ -230,7 +230,7 @@ QPDFWriter::interpretR3EncryptionParameters( std::set& clear, char const* user_password, char const* owner_password, bool allow_accessibility, bool allow_extract, - r3_print_e print, r3_modify_e modify) + qpdf_r3_print_e print, qpdf_r3_modify_e modify) { // Acrobat 5 security options: @@ -263,13 +263,13 @@ QPDFWriter::interpretR3EncryptionParameters( // statements). Each option clears successively more access bits. switch (print) { - case r3p_none: + case qpdf_r3p_none: clear.insert(3); // any printing - case r3p_low: + case qpdf_r3p_low: clear.insert(12); // high resolution printing - case r3p_full: + case qpdf_r3p_full: break; // no default so gcc warns for missing cases @@ -277,19 +277,19 @@ QPDFWriter::interpretR3EncryptionParameters( switch (modify) { - case r3m_none: + case qpdf_r3m_none: clear.insert(11); // document assembly - case r3m_assembly: + case qpdf_r3m_assembly: clear.insert(9); // filling in form fields - case r3m_form: + case qpdf_r3m_form: clear.insert(6); // modify annotations, fill in form fields - case r3m_annotate: + case qpdf_r3m_annotate: clear.insert(4); // other modifications - case r3m_all: + case qpdf_r3m_all: break; // no default so gcc warns for missing cases @@ -922,8 +922,8 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, { is_metadata = true; } - bool filter = (this->stream_data_mode != s_preserve); - if (this->stream_data_mode == s_compress) + bool filter = (this->stream_data_mode != qpdf_s_preserve); + if (this->stream_data_mode == qpdf_s_compress) { // Don't filter if the stream is already compressed with // FlateDecode. We don't want to make it worse by getting @@ -952,7 +952,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, normalize = true; filter = true; } - else if (filter && (this->stream_data_mode == s_compress)) + else if (filter && (this->stream_data_mode == qpdf_s_compress)) { compress = true; QTC::TC("qpdf", "QPDFWriter compressing uncompressed stream"); @@ -1107,7 +1107,8 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object) // Set up a stream to write the stream data into a buffer. Pipeline* next = pushPipeline(new Pl_Buffer("object stream")); - if (! ((this->stream_data_mode == s_uncompress) || this->qdf_mode)) + if (! ((this->stream_data_mode == qpdf_s_uncompress) || + this->qdf_mode)) { compressed = true; next = pushPipeline( @@ -1455,7 +1456,7 @@ QPDFWriter::write() } if (! this->stream_data_mode_set) { - this->stream_data_mode = s_uncompress; + this->stream_data_mode = qpdf_s_uncompress; } } @@ -1465,7 +1466,7 @@ QPDFWriter::write() this->preserve_encryption = false; } else if (this->normalize_content || - (this->stream_data_mode == s_uncompress) || + (this->stream_data_mode == qpdf_s_uncompress) || this->qdf_mode) { // Encryption makes looking at contents pretty useless. If @@ -1485,12 +1486,12 @@ QPDFWriter::write() if (v < 1.5) { QTC::TC("qpdf", "QPDFWriter forcing object stream disable"); - this->object_stream_mode = o_disable; + this->object_stream_mode = qpdf_o_disable; } } if (this->qdf_mode || this->normalize_content || - (this->stream_data_mode == s_uncompress)) + (this->stream_data_mode == qpdf_s_uncompress)) { initializeSpecialStreams(); } @@ -1506,15 +1507,15 @@ QPDFWriter::write() switch (this->object_stream_mode) { - case o_disable: + case qpdf_o_disable: // no action required break; - case o_preserve: + case qpdf_o_preserve: preserveObjectStreams(); break; - case o_generate: + case qpdf_o_generate: generateObjectStreams(); break; @@ -1760,7 +1761,7 @@ QPDFWriter::writeXRefStream(int xref_id, int max_id, int max_offset, Pipeline* p = pushPipeline(new Pl_Buffer("xref stream")); bool compressed = false; - if (! ((this->stream_data_mode == s_uncompress) || this->qdf_mode)) + if (! ((this->stream_data_mode == qpdf_s_uncompress) || this->qdf_mode)) { compressed = true; p = pushPipeline( diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 1f5603fb..bc81ce57 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc index 96de680f..f18080b2 100644 --- a/libqpdf/qpdf-c.cc +++ b/libqpdf/qpdf-c.cc @@ -251,48 +251,16 @@ QPDF_ERROR_CODE qpdf_init_write(qpdf_data qpdf, char const* filename) return status; } -void qpdf_set_object_stream_mode(qpdf_data qpdf, int mode) +void qpdf_set_object_stream_mode(qpdf_data qpdf, qpdf_object_stream_e mode) { QTC::TC("qpdf", "qpdf-c called qpdf_set_object_stream_mode"); - QPDFWriter::object_stream_e omode = QPDFWriter::o_preserve; - switch (mode) - { - case QPDF_OBJECT_STREAM_DISABLE: - omode = QPDFWriter::o_disable; - break; - - case QPDF_OBJECT_STREAM_GENERATE: - omode = QPDFWriter::o_generate; - break; - - default: - // already set to o_preserve; treate out of range values as - // the default. - break; - } - - qpdf->qpdf_writer->setObjectStreamMode(omode); + qpdf->qpdf_writer->setObjectStreamMode(mode); } -void qpdf_set_stream_data_mode(qpdf_data qpdf, int mode) +void qpdf_set_stream_data_mode(qpdf_data qpdf, qpdf_stream_data_e mode) { QTC::TC("qpdf", "qpdf-c called qpdf_set_stream_data_mode"); - QPDFWriter::stream_data_e smode = QPDFWriter::s_preserve; - switch (mode) - { - case QPDF_STREAM_DATA_UNCOMPRESS: - smode = QPDFWriter::s_uncompress; - break; - - case QPDF_STREAM_DATA_COMPRESS: - smode = QPDFWriter::s_compress; - break; - - default: - // Treat anything else as default - break; - } - qpdf->qpdf_writer->setStreamDataMode(smode); + qpdf->qpdf_writer->setStreamDataMode(mode); } void qpdf_set_content_normalization(qpdf_data qpdf, QPDF_BOOL value) @@ -346,39 +314,24 @@ void qpdf_set_r2_encryption_parameters( void qpdf_set_r3_encryption_parameters( qpdf_data qpdf, char const* user_password, char const* owner_password, QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract, - int print, int modify) + qpdf_r3_print_e print, qpdf_r3_modify_e modify) { QTC::TC("qpdf", "qpdf-c called qpdf_set_r3_encryption_parameters"); qpdf->qpdf_writer->setR3EncryptionParameters( user_password, owner_password, - allow_accessibility, allow_extract, - ((print == QPDF_R3_PRINT_LOW) ? QPDFWriter::r3p_low : - (print == QPDF_R3_PRINT_NONE) ? QPDFWriter::r3p_none : - QPDFWriter::r3p_full), - ((modify == QPDF_R3_MODIFY_ANNOTATE) ? QPDFWriter::r3m_annotate : - (modify == QPDF_R3_MODIFY_FORM) ? QPDFWriter::r3m_form : - (modify == QPDF_R3_MODIFY_ASSEMBLY) ? QPDFWriter::r3m_assembly : - (modify == QPDF_R3_MODIFY_NONE) ? QPDFWriter::r3m_none : - QPDFWriter::r3m_all)); + allow_accessibility, allow_extract, print, modify); } void qpdf_set_r4_encryption_parameters( qpdf_data qpdf, char const* user_password, char const* owner_password, QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract, - int print, int modify, QPDF_BOOL encrypt_metadata, QPDF_BOOL use_aes) + qpdf_r3_print_e print, qpdf_r3_modify_e modify, + QPDF_BOOL encrypt_metadata, QPDF_BOOL use_aes) { QTC::TC("qpdf", "qpdf-c called qpdf_set_r4_encryption_parameters"); qpdf->qpdf_writer->setR4EncryptionParameters( user_password, owner_password, - allow_accessibility, allow_extract, - ((print == QPDF_R3_PRINT_LOW) ? QPDFWriter::r3p_low : - (print == QPDF_R3_PRINT_NONE) ? QPDFWriter::r3p_none : - QPDFWriter::r3p_full), - ((modify == QPDF_R3_MODIFY_ANNOTATE) ? QPDFWriter::r3m_annotate : - (modify == QPDF_R3_MODIFY_FORM) ? QPDFWriter::r3m_form : - (modify == QPDF_R3_MODIFY_ASSEMBLY) ? QPDFWriter::r3m_assembly : - (modify == QPDF_R3_MODIFY_NONE) ? QPDFWriter::r3m_none : - QPDFWriter::r3m_all), + allow_accessibility, allow_extract, print, modify, encrypt_metadata, use_aes); } diff --git a/libqpdf/qpdf/BitStream.hh b/libqpdf/qpdf/BitStream.hh index d01be32e..b4b3ad02 100644 --- a/libqpdf/qpdf/BitStream.hh +++ b/libqpdf/qpdf/BitStream.hh @@ -3,7 +3,7 @@ #ifndef __BITSTREAM_HH__ #define __BITSTREAM_HH__ -#include +#include class DLL_EXPORT BitStream { diff --git a/libqpdf/qpdf/BitWriter.hh b/libqpdf/qpdf/BitWriter.hh index 9e99123b..09d758c7 100644 --- a/libqpdf/qpdf/BitWriter.hh +++ b/libqpdf/qpdf/BitWriter.hh @@ -3,7 +3,7 @@ #ifndef __BITWRITER_HH__ #define __BITWRITER_HH__ -#include +#include class Pipeline; diff --git a/libqpdf/qpdf/MD5.hh b/libqpdf/qpdf/MD5.hh index 9bc82877..f44c6069 100644 --- a/libqpdf/qpdf/MD5.hh +++ b/libqpdf/qpdf/MD5.hh @@ -2,7 +2,7 @@ #define __MD5_HH__ #include -#include +#include #include #ifdef HAVE_INTTYPES_H # include diff --git a/libqpdf/qpdf/PCRE.hh b/libqpdf/qpdf/PCRE.hh index f8487ee9..ad7d960a 100644 --- a/libqpdf/qpdf/PCRE.hh +++ b/libqpdf/qpdf/PCRE.hh @@ -12,7 +12,7 @@ #include #include -#include +#include // Note: this class does not encapsulate all features of the PCRE // package -- only those that I actually need right now are here. diff --git a/qpdf/qpdf-ctest.c b/qpdf/qpdf-ctest.c index ce785a3a..3b62f5ee 100644 --- a/qpdf/qpdf-ctest.c +++ b/qpdf/qpdf-ctest.c @@ -114,7 +114,7 @@ static void test06(char const* infile, qpdf_read(qpdf, infile, password); qpdf_init_write(qpdf, outfile); qpdf_set_static_ID(qpdf, QPDF_TRUE); - qpdf_set_object_stream_mode(qpdf, QPDF_OBJECT_STREAM_GENERATE); + qpdf_set_object_stream_mode(qpdf, qpdf_o_generate); qpdf_write(qpdf); report_errors(); } @@ -154,7 +154,7 @@ static void test09(char const* infile, qpdf_read(qpdf, infile, password); qpdf_init_write(qpdf, outfile); qpdf_set_static_ID(qpdf, QPDF_TRUE); - qpdf_set_stream_data_mode(qpdf, QPDF_STREAM_DATA_UNCOMPRESS); + qpdf_set_stream_data_mode(qpdf, qpdf_s_uncompress); qpdf_write(qpdf); report_errors(); } @@ -193,7 +193,7 @@ static void test12(char const* infile, qpdf_set_static_ID(qpdf, QPDF_TRUE); qpdf_set_r3_encryption_parameters( qpdf, "user2", "owner2", QPDF_TRUE, QPDF_TRUE, - QPDF_R3_PRINT_LOW, QPDF_R3_MODIFY_ALL); + qpdf_r3p_low, qpdf_r3m_all); qpdf_write(qpdf); report_errors(); } @@ -240,7 +240,7 @@ static void test15(char const* infile, qpdf_set_static_aes_IV(qpdf, QPDF_TRUE); qpdf_set_r4_encryption_parameters( qpdf, "user2", "owner2", QPDF_TRUE, QPDF_TRUE, - QPDF_R3_PRINT_LOW, QPDF_R3_MODIFY_ALL, QPDF_TRUE, QPDF_TRUE); + qpdf_r3p_low, qpdf_r3m_all, QPDF_TRUE, QPDF_TRUE); qpdf_write(qpdf); report_errors(); } diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index c614b5bf..bfce0555 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -233,7 +233,7 @@ parse_encrypt_options( std::string& user_password, std::string& owner_password, int& keylen, bool& r2_print, bool& r2_modify, bool& r2_extract, bool& r2_annotate, bool& r3_accessibility, bool& r3_extract, - QPDFWriter::r3_print_e& r3_print, QPDFWriter::r3_modify_e& r3_modify, + qpdf_r3_print_e& r3_print, qpdf_r3_modify_e& r3_modify, bool& force_V4, bool& cleartext_metadata, bool& use_aes) { if (cur_arg + 3 >= argc) @@ -310,15 +310,15 @@ parse_encrypt_options( { if (val == "full") { - r3_print = QPDFWriter::r3p_full; + r3_print = qpdf_r3p_full; } else if (val == "low") { - r3_print = QPDFWriter::r3p_low; + r3_print = qpdf_r3p_low; } else if (val == "none") { - r3_print = QPDFWriter::r3p_none; + r3_print = qpdf_r3p_none; } else { @@ -352,23 +352,23 @@ parse_encrypt_options( { if (val == "all") { - r3_modify = QPDFWriter::r3m_all; + r3_modify = qpdf_r3m_all; } else if (val == "annotate") { - r3_modify = QPDFWriter::r3m_annotate; + r3_modify = qpdf_r3m_annotate; } else if (val == "form") { - r3_modify = QPDFWriter::r3m_form; + r3_modify = qpdf_r3m_form; } else if (val == "assembly") { - r3_modify = QPDFWriter::r3m_assembly; + r3_modify = qpdf_r3m_assembly; } else if (val == "none") { - r3_modify = QPDFWriter::r3m_none; + r3_modify = qpdf_r3m_none; } else { @@ -587,19 +587,19 @@ int main(int argc, char* argv[]) bool r2_annotate = true; bool r3_accessibility = true; bool r3_extract = true; - QPDFWriter::r3_print_e r3_print = QPDFWriter::r3p_full; - QPDFWriter::r3_modify_e r3_modify = QPDFWriter::r3m_all; + qpdf_r3_print_e r3_print = qpdf_r3p_full; + qpdf_r3_modify_e r3_modify = qpdf_r3m_all; bool force_V4 = false; bool cleartext_metadata = false; bool use_aes = false; bool stream_data_set = false; - QPDFWriter::stream_data_e stream_data_mode = QPDFWriter::s_compress; + qpdf_stream_data_e stream_data_mode = qpdf_s_compress; bool normalize_set = false; bool normalize = false; bool suppress_recovery = false; bool object_stream_set = false; - QPDFWriter::object_stream_e object_stream_mode = QPDFWriter::o_preserve; + qpdf_object_stream_e object_stream_mode = qpdf_o_preserve; bool ignore_xref_streams = false; bool qdf_mode = false; std::string min_version; @@ -677,15 +677,15 @@ int main(int argc, char* argv[]) stream_data_set = true; if (strcmp(parameter, "compress") == 0) { - stream_data_mode = QPDFWriter::s_compress; + stream_data_mode = qpdf_s_compress; } else if (strcmp(parameter, "preserve") == 0) { - stream_data_mode = QPDFWriter::s_preserve; + stream_data_mode = qpdf_s_preserve; } else if (strcmp(parameter, "uncompress") == 0) { - stream_data_mode = QPDFWriter::s_uncompress; + stream_data_mode = qpdf_s_uncompress; } else { @@ -716,15 +716,15 @@ int main(int argc, char* argv[]) object_stream_set = true; if (strcmp(parameter, "disable") == 0) { - object_stream_mode = QPDFWriter::o_disable; + object_stream_mode = qpdf_o_disable; } else if (strcmp(parameter, "preserve") == 0) { - object_stream_mode = QPDFWriter::o_preserve; + object_stream_mode = qpdf_o_preserve; } else if (strcmp(parameter, "generate") == 0) { - object_stream_mode = QPDFWriter::o_generate; + object_stream_mode = qpdf_o_generate; } else { -- cgit v1.2.3-70-g09d2