diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/qpdf/BitStream.hh | 6 | ||||
-rw-r--r-- | libqpdf/qpdf/BitWriter.hh | 5 | ||||
-rw-r--r-- | libqpdf/qpdf/MD5.hh | 18 | ||||
-rw-r--r-- | libqpdf/qpdf/PCRE.hh | 17 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_AES_PDF.hh | 8 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_ASCII85Decoder.hh | 6 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_ASCIIHexDecoder.hh | 6 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_LZWDecoder.hh | 6 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_MD5.hh | 7 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_PNGFilter.hh | 6 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_RC4.hh | 6 |
11 files changed, 79 insertions, 12 deletions
diff --git a/libqpdf/qpdf/BitStream.hh b/libqpdf/qpdf/BitStream.hh index b4b3ad02..75fc3db9 100644 --- a/libqpdf/qpdf/BitStream.hh +++ b/libqpdf/qpdf/BitStream.hh @@ -5,12 +5,16 @@ #include <qpdf/DLL.h> -class DLL_EXPORT BitStream +class BitStream { public: + DLL_EXPORT BitStream(unsigned char const* p, int nbytes); + DLL_EXPORT void reset(); + DLL_EXPORT unsigned long getBits(int nbits); + DLL_EXPORT void skipToNextByte(); private: diff --git a/libqpdf/qpdf/BitWriter.hh b/libqpdf/qpdf/BitWriter.hh index 09d758c7..32dc8e49 100644 --- a/libqpdf/qpdf/BitWriter.hh +++ b/libqpdf/qpdf/BitWriter.hh @@ -7,14 +7,17 @@ class Pipeline; -class DLL_EXPORT BitWriter +class BitWriter { public: // Write bits to the pipeline. It is the caller's responsibility // to eventually call finish on the pipeline. + DLL_EXPORT BitWriter(Pipeline* pl); + DLL_EXPORT void writeBits(unsigned long val, int bits); // Force any partial byte to be written to the pipeline. + DLL_EXPORT void flush(); private: diff --git a/libqpdf/qpdf/MD5.hh b/libqpdf/qpdf/MD5.hh index f44c6069..7de995a1 100644 --- a/libqpdf/qpdf/MD5.hh +++ b/libqpdf/qpdf/MD5.hh @@ -8,41 +8,55 @@ # include <inttypes.h> #endif -class DLL_EXPORT MD5 +class MD5 { public: typedef unsigned char Digest[16]; + DLL_EXPORT MD5(); + DLL_EXPORT void reset(); // encodes string and finalizes + DLL_EXPORT void encodeString(char const* input_string); // encodes file and finalizes + DLL_EXPORT void encodeFile(char const* filename, int up_to_size = -1); // appends string to current md5 object + DLL_EXPORT void appendString(char const* input_string); // appends arbitrary data to current md5 object + DLL_EXPORT void encodeDataIncrementally(char const* input_data, int len); // computes a raw digest + DLL_EXPORT void digest(Digest); // prints the digest to stdout terminated with \r\n (primarily for // testing) + DLL_EXPORT void print(); // returns the digest as a hexadecimal string + DLL_EXPORT std::string unparse(); // Convenience functions + DLL_EXPORT static std::string getDataChecksum(char const* buf, int len); - static std::string getFileChecksum(char const* filename, int up_to_size = -1); + DLL_EXPORT + static std::string getFileChecksum(char const* filename, + int up_to_size = -1); + DLL_EXPORT static bool checkDataChecksum(char const* const checksum, char const* buf, int len); + DLL_EXPORT static bool checkFileChecksum(char const* const checksum, char const* filename, int up_to_size = -1); diff --git a/libqpdf/qpdf/PCRE.hh b/libqpdf/qpdf/PCRE.hh index ad7d960a..546c374d 100644 --- a/libqpdf/qpdf/PCRE.hh +++ b/libqpdf/qpdf/PCRE.hh @@ -17,7 +17,7 @@ // Note: this class does not encapsulate all features of the PCRE // package -- only those that I actually need right now are here. -class DLL_EXPORT PCRE +class PCRE { public: // This is thrown when an attempt is made to access a non-existent @@ -25,6 +25,7 @@ class DLL_EXPORT PCRE class NoBackref: public std::logic_error { public: + DLL_EXPORT NoBackref(); virtual ~NoBackref() throw() {} }; @@ -33,10 +34,15 @@ class DLL_EXPORT PCRE { friend class PCRE; public: + DLL_EXPORT Match(int nbackrefs, char const* subject); + DLL_EXPORT Match(Match const&); + DLL_EXPORT Match& operator=(Match const&); + DLL_EXPORT ~Match(); + DLL_EXPORT operator bool(); // All the back reference accessing routines may throw the @@ -48,9 +54,13 @@ class DLL_EXPORT PCRE // and not matching at all. // see getMatch flags below + DLL_EXPORT std::string getMatch(int n, int flags = 0); + DLL_EXPORT void getOffsetLength(int n, int& offset, int& length); + DLL_EXPORT int getOffset(int n); + DLL_EXPORT int getLength(int n); // nMatches returns the number of available matches including @@ -60,6 +70,7 @@ class DLL_EXPORT PCRE // will return the whole string, getMatch(1) will return the // text that matched the backreference, and getMatch(2) will // throw an exception because it is out of range. + DLL_EXPORT int nMatches() const; // Flags for getMatch @@ -82,12 +93,16 @@ class DLL_EXPORT PCRE // The value passed in as options is passed to pcre_exec. See man // pcreapi for details. + DLL_EXPORT PCRE(char const* pattern, int options = 0); + DLL_EXPORT ~PCRE(); + DLL_EXPORT Match match(char const* subject, int options = 0, int startoffset = 0, int size = -1); + DLL_EXPORT static void test(int n = 0); private: diff --git a/libqpdf/qpdf/Pl_AES_PDF.hh b/libqpdf/qpdf/Pl_AES_PDF.hh index 4857cd64..e062057b 100644 --- a/libqpdf/qpdf/Pl_AES_PDF.hh +++ b/libqpdf/qpdf/Pl_AES_PDF.hh @@ -7,21 +7,27 @@ // This pipeline implements AES-128 with CBC and block padding as // specified in the PDF specification. -class DLL_EXPORT Pl_AES_PDF: public Pipeline +class Pl_AES_PDF: public Pipeline { public: // key_data should be a pointer to key_size bytes of data static unsigned int const key_size = 16; + DLL_EXPORT Pl_AES_PDF(char const* identifier, Pipeline* next, bool encrypt, unsigned char const key[key_size]); + DLL_EXPORT virtual ~Pl_AES_PDF(); + DLL_EXPORT virtual void write(unsigned char* data, int len); + DLL_EXPORT virtual void finish(); // For testing only; PDF always uses CBC + DLL_EXPORT void disableCBC(); // For testing only: use a fixed initialization vector for CBC + DLL_EXPORT static void useStaticIV(); private: diff --git a/libqpdf/qpdf/Pl_ASCII85Decoder.hh b/libqpdf/qpdf/Pl_ASCII85Decoder.hh index bcb31340..a2c38da3 100644 --- a/libqpdf/qpdf/Pl_ASCII85Decoder.hh +++ b/libqpdf/qpdf/Pl_ASCII85Decoder.hh @@ -3,12 +3,16 @@ #include <qpdf/Pipeline.hh> -class DLL_EXPORT Pl_ASCII85Decoder: public Pipeline +class Pl_ASCII85Decoder: public Pipeline { public: + DLL_EXPORT Pl_ASCII85Decoder(char const* identifier, Pipeline* next); + DLL_EXPORT virtual ~Pl_ASCII85Decoder(); + DLL_EXPORT virtual void write(unsigned char* buf, int len); + DLL_EXPORT virtual void finish(); private: diff --git a/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh b/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh index 8a0c43f6..8a7b1899 100644 --- a/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh +++ b/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh @@ -3,12 +3,16 @@ #include <qpdf/Pipeline.hh> -class DLL_EXPORT Pl_ASCIIHexDecoder: public Pipeline +class Pl_ASCIIHexDecoder: public Pipeline { public: + DLL_EXPORT Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next); + DLL_EXPORT virtual ~Pl_ASCIIHexDecoder(); + DLL_EXPORT virtual void write(unsigned char* buf, int len); + DLL_EXPORT virtual void finish(); private: diff --git a/libqpdf/qpdf/Pl_LZWDecoder.hh b/libqpdf/qpdf/Pl_LZWDecoder.hh index ab7a3d25..3226cd6a 100644 --- a/libqpdf/qpdf/Pl_LZWDecoder.hh +++ b/libqpdf/qpdf/Pl_LZWDecoder.hh @@ -6,13 +6,17 @@ #include <qpdf/Buffer.hh> #include <vector> -class DLL_EXPORT Pl_LZWDecoder: public Pipeline +class Pl_LZWDecoder: public Pipeline { public: + DLL_EXPORT Pl_LZWDecoder(char const* identifier, Pipeline* next, bool early_code_change); + DLL_EXPORT virtual ~Pl_LZWDecoder(); + DLL_EXPORT virtual void write(unsigned char* buf, int len); + DLL_EXPORT virtual void finish(); private: diff --git a/libqpdf/qpdf/Pl_MD5.hh b/libqpdf/qpdf/Pl_MD5.hh index 6184ef15..13973f29 100644 --- a/libqpdf/qpdf/Pl_MD5.hh +++ b/libqpdf/qpdf/Pl_MD5.hh @@ -12,13 +12,18 @@ #include <qpdf/Pipeline.hh> #include <qpdf/MD5.hh> -class DLL_EXPORT Pl_MD5: public Pipeline +class Pl_MD5: public Pipeline { public: + DLL_EXPORT Pl_MD5(char const* identifier, Pipeline* next); + DLL_EXPORT virtual ~Pl_MD5(); + DLL_EXPORT virtual void write(unsigned char*, int); + DLL_EXPORT virtual void finish(); + DLL_EXPORT std::string getHexDigest(); private: diff --git a/libqpdf/qpdf/Pl_PNGFilter.hh b/libqpdf/qpdf/Pl_PNGFilter.hh index 99d8ac14..eb2ed028 100644 --- a/libqpdf/qpdf/Pl_PNGFilter.hh +++ b/libqpdf/qpdf/Pl_PNGFilter.hh @@ -16,18 +16,22 @@ #include <qpdf/Pipeline.hh> -class DLL_EXPORT Pl_PNGFilter: public Pipeline +class Pl_PNGFilter: public Pipeline { public: // Encoding is not presently supported enum action_e { a_encode, a_decode }; + DLL_EXPORT Pl_PNGFilter(char const* identifier, Pipeline* next, action_e action, unsigned int columns, unsigned int bytes_per_pixel); + DLL_EXPORT virtual ~Pl_PNGFilter(); + DLL_EXPORT virtual void write(unsigned char* data, int len); + DLL_EXPORT virtual void finish(); private: diff --git a/libqpdf/qpdf/Pl_RC4.hh b/libqpdf/qpdf/Pl_RC4.hh index ade69053..907b4af8 100644 --- a/libqpdf/qpdf/Pl_RC4.hh +++ b/libqpdf/qpdf/Pl_RC4.hh @@ -5,18 +5,22 @@ #include <qpdf/RC4.hh> -class DLL_EXPORT Pl_RC4: public Pipeline +class Pl_RC4: public Pipeline { public: static int const def_bufsize = 65536; // key_len of -1 means treat key_data as a null-terminated string + DLL_EXPORT Pl_RC4(char const* identifier, Pipeline* next, unsigned char const* key_data, int key_len = -1, int out_bufsize = def_bufsize); + DLL_EXPORT virtual ~Pl_RC4(); + DLL_EXPORT virtual void write(unsigned char* data, int len); + DLL_EXPORT virtual void finish(); private: |