From 492db82f6f698e5dcf7ff51dab5fccc79378906c Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 26 Sep 2009 15:15:33 +0000 Subject: more dll exports git-svn-id: svn+q:///qpdf/trunk@697 71b93d88-0707-0410-a8cf-f5a4172ac649 --- libqpdf/BitStream.cc | 4 ++++ libqpdf/BitWriter.cc | 3 +++ libqpdf/MD5.cc | 13 +++++++++++++ libqpdf/PCRE.cc | 20 ++++++++++++++++---- libqpdf/Pl_ASCIIHexDecoder.cc | 4 ++++ libqpdf/Pl_Buffer.cc | 5 +++++ libqpdf/Pl_LZWDecoder.cc | 5 ++++- libqpdf/Pl_MD5.cc | 5 +++++ libqpdf/Pl_PNGFilter.cc | 4 ++++ libqpdf/Pl_RC4.cc | 4 ++++ libqpdf/qpdf/BitStream.hh | 4 ++++ libqpdf/qpdf/BitWriter.hh | 3 +++ libqpdf/qpdf/MD5.hh | 13 +++++++++++++ libqpdf/qpdf/PCRE.hh | 18 ++++++++++++++++++ libqpdf/qpdf/Pl_ASCIIHexDecoder.hh | 4 ++++ libqpdf/qpdf/Pl_LZWDecoder.hh | 4 ++++ libqpdf/qpdf/Pl_MD5.hh | 5 +++++ libqpdf/qpdf/Pl_PNGFilter.hh | 7 ++++++- libqpdf/qpdf/Pl_RC4.hh | 6 ++++++ 19 files changed, 125 insertions(+), 6 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/BitStream.cc b/libqpdf/BitStream.cc index c6fda4e6..e5558655 100644 --- a/libqpdf/BitStream.cc +++ b/libqpdf/BitStream.cc @@ -6,6 +6,7 @@ #define BITS_READ 1 #include "bits.icc" +DLL_EXPORT BitStream::BitStream(unsigned char const* p, int nbytes) : start(p), nbytes(nbytes) @@ -13,6 +14,7 @@ BitStream::BitStream(unsigned char const* p, int nbytes) : reset(); } +DLL_EXPORT void BitStream::reset() { @@ -21,6 +23,7 @@ BitStream::reset() bits_available = 8 * nbytes; } +DLL_EXPORT unsigned long BitStream::getBits(int nbits) { @@ -28,6 +31,7 @@ BitStream::getBits(int nbits) this->bits_available, nbits); } +DLL_EXPORT void BitStream::skipToNextByte() { diff --git a/libqpdf/BitWriter.cc b/libqpdf/BitWriter.cc index f682aac5..b9b3caec 100644 --- a/libqpdf/BitWriter.cc +++ b/libqpdf/BitWriter.cc @@ -6,6 +6,7 @@ #define BITS_WRITE 1 #include "bits.icc" +DLL_EXPORT BitWriter::BitWriter(Pipeline* pl) : pl(pl), ch(0), @@ -13,12 +14,14 @@ BitWriter::BitWriter(Pipeline* pl) : { } +DLL_EXPORT void BitWriter::writeBits(unsigned long val, int bits) { write_bits(this->ch, this->bit_offset, val, bits, this->pl); } +DLL_EXPORT void BitWriter::flush() { diff --git a/libqpdf/MD5.cc b/libqpdf/MD5.cc index ecdd8a33..b05afa8b 100644 --- a/libqpdf/MD5.cc +++ b/libqpdf/MD5.cc @@ -295,16 +295,19 @@ void MD5::decode(UINT4 *output, unsigned char *input, unsigned int len) // Public functions +DLL_EXPORT MD5::MD5() { init(); } +DLL_EXPORT void MD5::reset() { init(); } +DLL_EXPORT void MD5::encodeString(char const* str) { unsigned int len = strlen(str); @@ -313,16 +316,19 @@ void MD5::encodeString(char const* str) final(); } +DLL_EXPORT void MD5::appendString(char const* input_string) { update((unsigned char *)input_string, strlen(input_string)); } +DLL_EXPORT void MD5::encodeDataIncrementally(char const* data, int len) { update((unsigned char *)data, len); } +DLL_EXPORT void MD5::encodeFile(char const *filename, int up_to_size) throw (QEXC::System) { @@ -366,12 +372,14 @@ void MD5::encodeFile(char const *filename, int up_to_size) final(); } +DLL_EXPORT void MD5::digest(Digest result) { final(); memcpy(result, digest_val, sizeof(digest_val)); } +DLL_EXPORT void MD5::print() { final(); @@ -384,6 +392,7 @@ void MD5::print() printf("\n"); } +DLL_EXPORT std::string MD5::unparse() { final(); @@ -399,6 +408,7 @@ std::string MD5::unparse() return result; } +DLL_EXPORT std::string MD5::getDataChecksum(char const* buf, int len) { @@ -407,6 +417,7 @@ MD5::getDataChecksum(char const* buf, int len) return m.unparse(); } +DLL_EXPORT std::string MD5::getFileChecksum(char const* filename, int up_to_size) { @@ -415,6 +426,7 @@ MD5::getFileChecksum(char const* filename, int up_to_size) return m.unparse(); } +DLL_EXPORT bool MD5::checkDataChecksum(char const* const checksum, char const* buf, int len) @@ -423,6 +435,7 @@ MD5::checkDataChecksum(char const* const checksum, return (checksum == actual_checksum); } +DLL_EXPORT bool MD5::checkFileChecksum(char const* const checksum, char const* filename, int up_to_size) diff --git a/libqpdf/PCRE.cc b/libqpdf/PCRE.cc index 872fde36..3236e941 100644 --- a/libqpdf/PCRE.cc +++ b/libqpdf/PCRE.cc @@ -5,31 +5,37 @@ #include #include +DLL_EXPORT PCRE::Exception::Exception(std::string const& message) { this->setMessage("PCRE error: " + message); } +DLL_EXPORT PCRE::NoBackref::NoBackref() : Exception("no match") { } +DLL_EXPORT PCRE::Match::Match(int nbackrefs, char const* subject) { this->init(-1, nbackrefs, subject); } +DLL_EXPORT PCRE::Match::~Match() { this->destroy(); } +DLL_EXPORT PCRE::Match::Match(Match const& rhs) { this->copy(rhs); } +DLL_EXPORT PCRE::Match& PCRE::Match::operator=(Match const& rhs) { @@ -72,12 +78,13 @@ PCRE::Match::destroy() delete [] this->ovector; } +DLL_EXPORT PCRE::Match::operator bool() { return (this->nmatches >= 0); } - +DLL_EXPORT std::string PCRE::Match::getMatch(int n, int flags) throw(QEXC::General, Exception) @@ -107,6 +114,7 @@ PCRE::Match::getMatch(int n, int flags) return std::string(this->subject).substr(offset, length); } +DLL_EXPORT void PCRE::Match::getOffsetLength(int n, int& offset, int& length) throw(Exception) { @@ -120,7 +128,7 @@ PCRE::Match::getOffsetLength(int n, int& offset, int& length) throw(Exception) length = this->ovector[n * 2 + 1] - offset; } - +DLL_EXPORT int PCRE::Match::getOffset(int n) throw(Exception) { @@ -130,7 +138,7 @@ PCRE::Match::getOffset(int n) throw(Exception) return offset; } - +DLL_EXPORT int PCRE::Match::getLength(int n) throw(Exception) { @@ -140,13 +148,14 @@ PCRE::Match::getLength(int n) throw(Exception) return length; } - +DLL_EXPORT int PCRE::Match::nMatches() const { return this->nmatches; } +DLL_EXPORT PCRE::PCRE(char const* pattern, int options) throw (PCRE::Exception) { char const *errptr; @@ -166,11 +175,13 @@ PCRE::PCRE(char const* pattern, int options) throw (PCRE::Exception) } } +DLL_EXPORT PCRE::~PCRE() { pcre_free(this->code); } +DLL_EXPORT PCRE::Match PCRE::match(char const* subject, int options, int startoffset, int size) throw (QEXC::General, Exception) @@ -219,6 +230,7 @@ PCRE::match(char const* subject, int options, int startoffset, int size) return result; } +DLL_EXPORT void PCRE::test(int n) { diff --git a/libqpdf/Pl_ASCIIHexDecoder.cc b/libqpdf/Pl_ASCIIHexDecoder.cc index d1b4ef1c..728e3eb8 100644 --- a/libqpdf/Pl_ASCIIHexDecoder.cc +++ b/libqpdf/Pl_ASCIIHexDecoder.cc @@ -4,6 +4,7 @@ #include #include +DLL_EXPORT Pl_ASCIIHexDecoder::Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next) : Pipeline(identifier, next), pos(0), @@ -12,10 +13,12 @@ Pl_ASCIIHexDecoder::Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next) : strcpy(this->inbuf, "00"); } +DLL_EXPORT Pl_ASCIIHexDecoder::~Pl_ASCIIHexDecoder() { } +DLL_EXPORT void Pl_ASCIIHexDecoder::write(unsigned char* buf, int len) { @@ -100,6 +103,7 @@ Pl_ASCIIHexDecoder::flush() strcpy(this->inbuf, "00"); } +DLL_EXPORT void Pl_ASCIIHexDecoder::finish() { diff --git a/libqpdf/Pl_Buffer.cc b/libqpdf/Pl_Buffer.cc index 27e1004e..25aff218 100644 --- a/libqpdf/Pl_Buffer.cc +++ b/libqpdf/Pl_Buffer.cc @@ -4,6 +4,7 @@ #include #include +DLL_EXPORT Pl_Buffer::Pl_Buffer(char const* identifier, Pipeline* next) : Pipeline(identifier, next), ready(false), @@ -11,10 +12,12 @@ Pl_Buffer::Pl_Buffer(char const* identifier, Pipeline* next) : { } +DLL_EXPORT Pl_Buffer::~Pl_Buffer() { } +DLL_EXPORT void Pl_Buffer::write(unsigned char* buf, int len) { @@ -30,6 +33,7 @@ Pl_Buffer::write(unsigned char* buf, int len) } } +DLL_EXPORT void Pl_Buffer::finish() { @@ -40,6 +44,7 @@ Pl_Buffer::finish() } } +DLL_EXPORT Buffer* Pl_Buffer::getBuffer() { diff --git a/libqpdf/Pl_LZWDecoder.cc b/libqpdf/Pl_LZWDecoder.cc index f4bf3012..050998d6 100644 --- a/libqpdf/Pl_LZWDecoder.cc +++ b/libqpdf/Pl_LZWDecoder.cc @@ -5,6 +5,7 @@ #include #include +DLL_EXPORT Pl_LZWDecoder::Pl_LZWDecoder(char const* identifier, Pipeline* next, bool early_code_change) : Pipeline(identifier, next), @@ -20,11 +21,12 @@ Pl_LZWDecoder::Pl_LZWDecoder(char const* identifier, Pipeline* next, memset(buf, 0, 3); } - +DLL_EXPORT Pl_LZWDecoder::~Pl_LZWDecoder() { } +DLL_EXPORT void Pl_LZWDecoder::write(unsigned char* bytes, int len) { @@ -43,6 +45,7 @@ Pl_LZWDecoder::write(unsigned char* bytes, int len) } } +DLL_EXPORT void Pl_LZWDecoder::finish() { diff --git a/libqpdf/Pl_MD5.cc b/libqpdf/Pl_MD5.cc index 0a2711b8..f368b93b 100644 --- a/libqpdf/Pl_MD5.cc +++ b/libqpdf/Pl_MD5.cc @@ -3,16 +3,19 @@ #include +DLL_EXPORT Pl_MD5::Pl_MD5(char const* identifier, Pipeline* next) : Pipeline(identifier, next), in_progress(false) { } +DLL_EXPORT Pl_MD5::~Pl_MD5() { } +DLL_EXPORT void Pl_MD5::write(unsigned char* buf, int len) { @@ -25,6 +28,7 @@ Pl_MD5::write(unsigned char* buf, int len) this->getNext()->write(buf, len); } +DLL_EXPORT void Pl_MD5::finish() { @@ -32,6 +36,7 @@ Pl_MD5::finish() this->in_progress = false; } +DLL_EXPORT std::string Pl_MD5::getHexDigest() { diff --git a/libqpdf/Pl_PNGFilter.cc b/libqpdf/Pl_PNGFilter.cc index 28b87c5e..792b4a02 100644 --- a/libqpdf/Pl_PNGFilter.cc +++ b/libqpdf/Pl_PNGFilter.cc @@ -2,6 +2,7 @@ #include #include +DLL_EXPORT Pl_PNGFilter::Pl_PNGFilter(char const* identifier, Pipeline* next, action_e action, unsigned int columns, unsigned int bytes_per_pixel) : @@ -22,12 +23,14 @@ Pl_PNGFilter::Pl_PNGFilter(char const* identifier, Pipeline* next, this->incoming = (action == a_encode ? columns : columns + 1); } +DLL_EXPORT Pl_PNGFilter::~Pl_PNGFilter() { delete [] buf1; delete [] buf2; } +DLL_EXPORT void Pl_PNGFilter::write(unsigned char* data, int len) { @@ -129,6 +132,7 @@ Pl_PNGFilter::encodeRow() } } +DLL_EXPORT void Pl_PNGFilter::finish() { diff --git a/libqpdf/Pl_RC4.cc b/libqpdf/Pl_RC4.cc index 74e53c8b..e176511f 100644 --- a/libqpdf/Pl_RC4.cc +++ b/libqpdf/Pl_RC4.cc @@ -3,6 +3,7 @@ #include +DLL_EXPORT Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next, unsigned char const* key_data, int key_len, int out_bufsize) : @@ -13,6 +14,7 @@ Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next, this->outbuf = new unsigned char[out_bufsize]; } +DLL_EXPORT Pl_RC4::~Pl_RC4() { if (this->outbuf) @@ -22,6 +24,7 @@ Pl_RC4::~Pl_RC4() } } +DLL_EXPORT void Pl_RC4::write(unsigned char* data, int len) { @@ -45,6 +48,7 @@ Pl_RC4::write(unsigned char* data, int len) } } +DLL_EXPORT void Pl_RC4::finish() { diff --git a/libqpdf/qpdf/BitStream.hh b/libqpdf/qpdf/BitStream.hh index d02eea42..1a42b5e7 100644 --- a/libqpdf/qpdf/BitStream.hh +++ b/libqpdf/qpdf/BitStream.hh @@ -6,9 +6,13 @@ 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 799e1c1a..d4a42182 100644 --- a/libqpdf/qpdf/BitWriter.hh +++ b/libqpdf/qpdf/BitWriter.hh @@ -10,9 +10,12 @@ 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 eb0b9680..b0b93e3d 100644 --- a/libqpdf/qpdf/MD5.hh +++ b/libqpdf/qpdf/MD5.hh @@ -14,37 +14,50 @@ 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) throw(QEXC::System); // 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); + 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 deba8733..93071d07 100644 --- a/libqpdf/qpdf/PCRE.hh +++ b/libqpdf/qpdf/PCRE.hh @@ -22,7 +22,9 @@ class PCRE class Exception: public QEXC::General { public: + DLL_EXPORT Exception(std::string const& message); + DLL_EXPORT virtual ~Exception() throw() {} }; @@ -31,7 +33,9 @@ class PCRE class NoBackref: public Exception { public: + DLL_EXPORT NoBackref(); + DLL_EXPORT virtual ~NoBackref() throw() {} }; @@ -39,10 +43,15 @@ class 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 @@ -54,10 +63,14 @@ class PCRE // and not matching at all. // see getMatch flags below + DLL_EXPORT std::string getMatch(int n, int flags = 0) throw(QEXC::General, Exception); + DLL_EXPORT void getOffsetLength(int n, int& offset, int& length) throw(Exception); + DLL_EXPORT int getOffset(int n) throw(Exception); + DLL_EXPORT int getLength(int n) throw(Exception); // nMatches returns the number of available matches including @@ -67,6 +80,7 @@ class 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 @@ -89,13 +103,17 @@ class 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) throw(Exception); + DLL_EXPORT ~PCRE(); + DLL_EXPORT Match match(char const* subject, int options = 0, int startoffset = 0, int size = -1) throw(QEXC::General, Exception); + DLL_EXPORT static void test(int n = 0); private: diff --git a/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh b/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh index 36272328..068294d7 100644 --- a/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh +++ b/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh @@ -7,9 +7,13 @@ 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 95ec55b3..4d348406 100644 --- a/libqpdf/qpdf/Pl_LZWDecoder.hh +++ b/libqpdf/qpdf/Pl_LZWDecoder.hh @@ -10,10 +10,14 @@ 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 2d9d11fd..9da018d1 100644 --- a/libqpdf/qpdf/Pl_MD5.hh +++ b/libqpdf/qpdf/Pl_MD5.hh @@ -16,10 +16,15 @@ 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 1ecc7060..1d9afabd 100644 --- a/libqpdf/qpdf/Pl_PNGFilter.hh +++ b/libqpdf/qpdf/Pl_PNGFilter.hh @@ -1,4 +1,3 @@ - #ifndef __PL_PNGFILTER_HH__ #define __PL_PNGFILTER_HH__ @@ -23,11 +22,13 @@ class Pl_PNGFilter: public Pipeline class Exception: public Pipeline::Exception { public: + DLL_EXPORT Exception(std::string const& message) : Pipeline::Exception(message) { } + DLL_EXPORT virtual ~Exception() throw () { } @@ -36,12 +37,16 @@ class Pl_PNGFilter: public Pipeline // 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 6bebe5aa..01b651a5 100644 --- a/libqpdf/qpdf/Pl_RC4.hh +++ b/libqpdf/qpdf/Pl_RC4.hh @@ -12,11 +12,13 @@ class Pl_RC4: public Pipeline class Exception: public Pipeline::Exception { public: + DLL_EXPORT Exception(std::string const& message) : Pipeline::Exception(message) { } + DLL_EXPORT virtual ~Exception() throw() { } @@ -25,12 +27,16 @@ class Pl_RC4: public Pipeline 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: -- cgit v1.2.3-70-g09d2