From aab4058bae733fa1fd0df774a7cdec1282dbbd59 Mon Sep 17 00:00:00 2001 From: Matej Kenda Date: Fri, 4 Oct 2024 09:50:39 +0200 Subject: [PATCH] Hide zlib and expat libs from the user of Poco libraries (replaces #4579) (#4724) * foundation: Remove unused ucp.h Nothing use this and it is not even included in Visual Studio project files. Remove it so it will not confuse any more. * foundation: Hide zlib from user Hide zlib completly from user. This way we do not need to publish zlib.h or zconfig.h. As we now have two different pointer initalizing in constructor I choose to use unique pointers so it is more obvious those are safe. I also choose to use make_unique which default initalize z_stream_t. This makes code more readable as we do not need to specifie every field of z_stream_t. It really should not matter much if we initialize couple field for nothing. If does we should add comment about that. Still keeping _buffer without inializing as it is quite big. * xml: Hide expat and ParserEngine from user Hide expat completly from user. This way we do not need to publish expat.h or expat_external.h. I move also headers to orignal locations so diff is smaller compared to original. * chore(Foundation): Compression level constants --------- Co-authored-by: Kari Argillander --- Foundation/CMakeLists.txt | 6 - Foundation/include/Poco/DeflatingStream.h | 36 +-- Foundation/include/Poco/InflatingStream.h | 19 +- Foundation/src/Checksum.cpp | 2 +- Foundation/src/DeflatingStream.cpp | 178 ++++++-------- Foundation/src/InflatingStream.cpp | 140 +++++------ Foundation/src/ucp.h | 224 ------------------ Foundation/testsuite/src/ZLibTest.cpp | 3 +- PocoDoc/cfg/mkdoc-poco.xml | 3 - PocoDoc/cfg/mkdocumentation.xml | 3 - XML/XML_vs90.vcproj | 16 +- XML/include/Poco/SAX/SAXParser.h | 7 +- XML/include/Poco/XML/XMLStreamParser.h | 21 +- XML/src/ParserEngine.cpp | 2 +- XML/{include/Poco/XML => src}/ParserEngine.h | 2 +- XML/src/SAXParser.cpp | 63 ++--- XML/src/XMLStreamParser.cpp | 16 +- XML/{include/Poco/XML => src}/expat.h | 0 .../Poco/XML => src}/expat_external.h | 0 XML/src/internal.h | 2 +- XML/src/xmlparse.cpp | 2 +- XML/src/xmlrole.c | 6 +- XML/src/xmltok.c | 6 +- Zip/src/ZipStream.cpp | 3 +- 24 files changed, 248 insertions(+), 512 deletions(-) delete mode 100644 Foundation/src/ucp.h rename XML/{include/Poco/XML => src}/ParserEngine.h (99%) rename XML/{include/Poco/XML => src}/expat.h (100%) rename XML/{include/Poco/XML => src}/expat_external.h (100%) diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index 9d623ac2c2..1223d0b923 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -70,12 +70,6 @@ else() src/pcre2_xclass.c ) - # zlib - POCO_HEADERS(SRCS zlib - include/Poco/zconf.h - include/Poco/zlib.h - ) - POCO_SOURCES(SRCS zlib src/adler32.c src/compress.c diff --git a/Foundation/include/Poco/DeflatingStream.h b/Foundation/include/Poco/DeflatingStream.h index d755707149..e48eef046c 100644 --- a/Foundation/include/Poco/DeflatingStream.h +++ b/Foundation/include/Poco/DeflatingStream.h @@ -22,11 +22,8 @@ #include "Poco/BufferedStreamBuf.h" #include #include -#if defined(POCO_UNBUNDLED) -#include -#else -#include "Poco/zlib.h" -#endif + +struct z_stream_s; namespace Poco { @@ -47,6 +44,17 @@ class Foundation_API DeflatingStreamBuf: public BufferedStreamBuf STREAM_GZIP /// Create a gzip header, use CRC-32 checksum. }; + enum CompressionLevel + /// Constants for compression levels. + /// Note to maintainers: These must be kept in sync with the constants + /// defined by zlib. + { + DEFAULT_COMPRESSION = -1, + NO_COMPRESSION = 0, + BEST_SPEED = 1, + BEST_COMPRESSION = 9 + }; + DeflatingStreamBuf(std::istream& istr, StreamType type, int level); /// Creates a DeflatingStreamBuf for compressing data read /// from the given input stream. @@ -89,11 +97,11 @@ class Foundation_API DeflatingStreamBuf: public BufferedStreamBuf DEFLATE_BUFFER_SIZE = 32768 }; - std::istream* _pIstr; - std::ostream* _pOstr; - char* _buffer; - z_stream _zstr; - bool _eof; + std::istream* _pIstr; + std::ostream* _pOstr; + char* _buffer; + z_stream_s* _pZstr; + bool _eof; }; @@ -104,7 +112,7 @@ class Foundation_API DeflatingIOS: public virtual std::ios /// order of the stream buffer and base classes. { public: - DeflatingIOS(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION); + DeflatingIOS(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION); /// Creates a DeflatingIOS for compressing data passed /// through and forwarding it to the given output stream. @@ -115,7 +123,7 @@ class Foundation_API DeflatingIOS: public virtual std::ios /// Please refer to the zlib documentation of deflateInit2() for a description /// of the windowBits parameter. - DeflatingIOS(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION); + DeflatingIOS(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION); /// Creates a DeflatingIOS for compressing data read /// from the given input stream. @@ -150,7 +158,7 @@ class Foundation_API DeflatingOutputStream: public std::ostream, public Deflatin /// ostr.close(); { public: - DeflatingOutputStream(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION); + DeflatingOutputStream(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION); /// Creates a DeflatingOutputStream for compressing data passed /// through and forwarding it to the given output stream. @@ -179,7 +187,7 @@ class Foundation_API DeflatingInputStream: public std::istream, public Deflating /// using zlib's deflate algorithm. { public: - DeflatingInputStream(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION); + DeflatingInputStream(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION); /// Creates a DeflatingIOS for compressing data read /// from the given input stream. diff --git a/Foundation/include/Poco/InflatingStream.h b/Foundation/include/Poco/InflatingStream.h index 61064dc87c..0a01d121da 100644 --- a/Foundation/include/Poco/InflatingStream.h +++ b/Foundation/include/Poco/InflatingStream.h @@ -22,11 +22,8 @@ #include "Poco/BufferedStreamBuf.h" #include #include -#if defined(POCO_UNBUNDLED) -#include -#else -#include "Poco/zlib.h" -#endif + +struct z_stream_s; namespace Poco { @@ -92,12 +89,12 @@ class Foundation_API InflatingStreamBuf: public BufferedStreamBuf INFLATE_BUFFER_SIZE = 32768 }; - std::istream* _pIstr; - std::ostream* _pOstr; - char* _buffer; - z_stream _zstr; - bool _eof; - bool _check; + std::istream* _pIstr; + std::ostream* _pOstr; + char* _buffer; + z_stream_s* _pZstr; + bool _eof; + bool _check; }; diff --git a/Foundation/src/Checksum.cpp b/Foundation/src/Checksum.cpp index 097ffd9e73..ac722dfef5 100644 --- a/Foundation/src/Checksum.cpp +++ b/Foundation/src/Checksum.cpp @@ -16,7 +16,7 @@ #if defined(POCO_UNBUNDLED) #include #else -#include "Poco/zlib.h" +#include "zlib.h" #endif diff --git a/Foundation/src/DeflatingStream.cpp b/Foundation/src/DeflatingStream.cpp index eba64d0533..3952105640 100644 --- a/Foundation/src/DeflatingStream.cpp +++ b/Foundation/src/DeflatingStream.cpp @@ -14,6 +14,12 @@ #include "Poco/DeflatingStream.h" #include "Poco/Exception.h" +#include +#if defined(POCO_UNBUNDLED) +#include +#else +#include "zlib.h" +#endif namespace Poco { @@ -25,29 +31,17 @@ DeflatingStreamBuf::DeflatingStreamBuf(std::istream& istr, StreamType type, int _pOstr(0), _eof(false) { - _zstr.next_in = 0; - _zstr.avail_in = 0; - _zstr.total_in = 0; - _zstr.next_out = 0; - _zstr.avail_out = 0; - _zstr.total_out = 0; - _zstr.msg = 0; - _zstr.state = 0; - _zstr.zalloc = Z_NULL; - _zstr.zfree = Z_NULL; - _zstr.opaque = Z_NULL; - _zstr.data_type = 0; - _zstr.adler = 0; - _zstr.reserved = 0; - - _buffer = new char[DEFLATE_BUFFER_SIZE]; - - int rc = deflateInit2(&_zstr, level, Z_DEFLATED, 15 + (type == STREAM_GZIP ? 16 : 0), 8, Z_DEFAULT_STRATEGY); + std::unique_ptr buffer(new char[DEFLATE_BUFFER_SIZE]); + + std::unique_ptr pZstr = std::make_unique(z_stream{}); + int rc = deflateInit2(pZstr.get(), level, Z_DEFLATED, 15 + (type == STREAM_GZIP ? 16 : 0), 8, Z_DEFAULT_STRATEGY); if (rc != Z_OK) { - delete [] _buffer; throw IOException(zError(rc)); } + + _pZstr = pZstr.release(); + _buffer = buffer.release(); } @@ -57,22 +51,17 @@ DeflatingStreamBuf::DeflatingStreamBuf(std::istream& istr, int windowBits, int l _pOstr(0), _eof(false) { - _zstr.zalloc = Z_NULL; - _zstr.zfree = Z_NULL; - _zstr.opaque = Z_NULL; - _zstr.next_in = 0; - _zstr.avail_in = 0; - _zstr.next_out = 0; - _zstr.avail_out = 0; + std::unique_ptr buffer(new char[DEFLATE_BUFFER_SIZE]); - _buffer = new char[DEFLATE_BUFFER_SIZE]; - - int rc = deflateInit2(&_zstr, level, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY); + std::unique_ptr pZstr = std::make_unique(z_stream{}); + int rc = deflateInit2(pZstr.get(), level, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY); if (rc != Z_OK) { - delete [] _buffer; throw IOException(zError(rc)); } + + _pZstr = pZstr.release(); + _buffer = buffer.release(); } @@ -82,22 +71,17 @@ DeflatingStreamBuf::DeflatingStreamBuf(std::ostream& ostr, StreamType type, int _pOstr(&ostr), _eof(false) { - _zstr.zalloc = Z_NULL; - _zstr.zfree = Z_NULL; - _zstr.opaque = Z_NULL; - _zstr.next_in = 0; - _zstr.avail_in = 0; - _zstr.next_out = 0; - _zstr.avail_out = 0; + std::unique_ptr buffer(new char[DEFLATE_BUFFER_SIZE]); - _buffer = new char[DEFLATE_BUFFER_SIZE]; - - int rc = deflateInit2(&_zstr, level, Z_DEFLATED, 15 + (type == STREAM_GZIP ? 16 : 0), 8, Z_DEFAULT_STRATEGY); + std::unique_ptr pZstr = std::make_unique(z_stream{}); + int rc = deflateInit2(pZstr.get(), level, Z_DEFLATED, 15 + (type == STREAM_GZIP ? 16 : 0), 8, Z_DEFAULT_STRATEGY); if (rc != Z_OK) { - delete [] _buffer; throw IOException(zError(rc)); } + + _pZstr = pZstr.release(); + _buffer = buffer.release(); } @@ -107,22 +91,17 @@ DeflatingStreamBuf::DeflatingStreamBuf(std::ostream& ostr, int windowBits, int l _pOstr(&ostr), _eof(false) { - _zstr.zalloc = Z_NULL; - _zstr.zfree = Z_NULL; - _zstr.opaque = Z_NULL; - _zstr.next_in = 0; - _zstr.avail_in = 0; - _zstr.next_out = 0; - _zstr.avail_out = 0; + std::unique_ptr buffer(new char[DEFLATE_BUFFER_SIZE]); - _buffer = new char[DEFLATE_BUFFER_SIZE]; - - int rc = deflateInit2(&_zstr, level, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY); + std::unique_ptr pZstr = std::make_unique(z_stream{}); + int rc = deflateInit2(pZstr.get(), level, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY); if (rc != Z_OK) { - delete [] _buffer; throw IOException(zError(rc)); } + + _pZstr = pZstr.release(); + _buffer = buffer.release(); } @@ -136,7 +115,8 @@ DeflatingStreamBuf::~DeflatingStreamBuf() { } delete [] _buffer; - deflateEnd(&_zstr); + deflateEnd(_pZstr); + delete _pZstr; } @@ -146,22 +126,22 @@ int DeflatingStreamBuf::close() _pIstr = 0; if (_pOstr) { - if (_zstr.next_out) + if (_pZstr->next_out) { - int rc = deflate(&_zstr, Z_FINISH); + int rc = deflate(_pZstr, Z_FINISH); if (rc != Z_OK && rc != Z_STREAM_END) throw IOException(zError(rc)); - _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out); + _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _pZstr->avail_out); if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream"); - _zstr.next_out = (unsigned char*) _buffer; - _zstr.avail_out = DEFLATE_BUFFER_SIZE; + _pZstr->next_out = (unsigned char*) _buffer; + _pZstr->avail_out = DEFLATE_BUFFER_SIZE; while (rc != Z_STREAM_END) { - rc = deflate(&_zstr, Z_FINISH); + rc = deflate(_pZstr, Z_FINISH); if (rc != Z_OK && rc != Z_STREAM_END) throw IOException(zError(rc)); - _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out); + _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _pZstr->avail_out); if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream"); - _zstr.next_out = (unsigned char*) _buffer; - _zstr.avail_out = DEFLATE_BUFFER_SIZE; + _pZstr->next_out = (unsigned char*) _buffer; + _pZstr->avail_out = DEFLATE_BUFFER_SIZE; } } _pOstr->flush(); @@ -178,23 +158,23 @@ int DeflatingStreamBuf::sync() if (_pOstr) { - if (_zstr.next_out) + if (_pZstr->next_out) { - int rc = deflate(&_zstr, Z_SYNC_FLUSH); + int rc = deflate(_pZstr, Z_SYNC_FLUSH); if (rc != Z_OK) throw IOException(zError(rc)); - _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out); + _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _pZstr->avail_out); if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream"); - while (_zstr.avail_out == 0) + while (_pZstr->avail_out == 0) { - _zstr.next_out = (unsigned char*) _buffer; - _zstr.avail_out = DEFLATE_BUFFER_SIZE; - rc = deflate(&_zstr, Z_SYNC_FLUSH); + _pZstr->next_out = (unsigned char*) _buffer; + _pZstr->avail_out = DEFLATE_BUFFER_SIZE; + rc = deflate(_pZstr, Z_SYNC_FLUSH); if (rc != Z_OK) throw IOException(zError(rc)); - _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out); + _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _pZstr->avail_out); if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream"); }; - _zstr.next_out = (unsigned char*) _buffer; - _zstr.avail_out = DEFLATE_BUFFER_SIZE; + _pZstr->next_out = (unsigned char*) _buffer; + _pZstr->avail_out = DEFLATE_BUFFER_SIZE; } // NOTE: This breaks the Zip library and causes corruption in some files. // See GH #1828 @@ -207,7 +187,7 @@ int DeflatingStreamBuf::sync() int DeflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) { if (!_pIstr) return 0; - if (_zstr.avail_in == 0 && !_eof) + if (_pZstr->avail_in == 0 && !_eof) { int n = 0; if (_pIstr->good()) @@ -217,32 +197,32 @@ int DeflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) } if (n > 0) { - _zstr.next_in = (unsigned char*) _buffer; - _zstr.avail_in = n; + _pZstr->next_in = (unsigned char*) _buffer; + _pZstr->avail_in = n; } else { - _zstr.next_in = 0; - _zstr.avail_in = 0; + _pZstr->next_in = 0; + _pZstr->avail_in = 0; _eof = true; } } - _zstr.next_out = (unsigned char*) buffer; - _zstr.avail_out = static_cast(length); + _pZstr->next_out = (unsigned char*) buffer; + _pZstr->avail_out = static_cast(length); for (;;) { - int rc = deflate(&_zstr, _eof ? Z_FINISH : Z_NO_FLUSH); + int rc = deflate(_pZstr, _eof ? Z_FINISH : Z_NO_FLUSH); if (_eof && rc == Z_STREAM_END) { _pIstr = 0; - return static_cast(length) - _zstr.avail_out; + return static_cast(length) - _pZstr->avail_out; } if (rc != Z_OK) throw IOException(zError(rc)); - if (_zstr.avail_out == 0) + if (_pZstr->avail_out == 0) { return static_cast(length); } - if (_zstr.avail_in == 0) + if (_pZstr->avail_in == 0) { int n = 0; if (_pIstr->good()) @@ -252,13 +232,13 @@ int DeflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) } if (n > 0) { - _zstr.next_in = (unsigned char*) _buffer; - _zstr.avail_in = n; + _pZstr->next_in = (unsigned char*) _buffer; + _pZstr->avail_in = n; } else { - _zstr.next_in = 0; - _zstr.avail_in = 0; + _pZstr->next_in = 0; + _pZstr->avail_in = 0; _eof = true; } } @@ -270,27 +250,27 @@ int DeflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length { if (length == 0 || !_pOstr) return 0; - _zstr.next_in = (unsigned char*) buffer; - _zstr.avail_in = static_cast(length); - _zstr.next_out = (unsigned char*) _buffer; - _zstr.avail_out = DEFLATE_BUFFER_SIZE; + _pZstr->next_in = (unsigned char*) buffer; + _pZstr->avail_in = static_cast(length); + _pZstr->next_out = (unsigned char*) _buffer; + _pZstr->avail_out = DEFLATE_BUFFER_SIZE; for (;;) { - int rc = deflate(&_zstr, Z_NO_FLUSH); + int rc = deflate(_pZstr, Z_NO_FLUSH); if (rc != Z_OK) throw IOException(zError(rc)); - if (_zstr.avail_out == 0) + if (_pZstr->avail_out == 0) { _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE); if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream"); - _zstr.next_out = (unsigned char*) _buffer; - _zstr.avail_out = DEFLATE_BUFFER_SIZE; + _pZstr->next_out = (unsigned char*) _buffer; + _pZstr->avail_out = DEFLATE_BUFFER_SIZE; } - if (_zstr.avail_in == 0) + if (_pZstr->avail_in == 0) { - _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out); + _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _pZstr->avail_out); if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream"); - _zstr.next_out = (unsigned char*) _buffer; - _zstr.avail_out = DEFLATE_BUFFER_SIZE; + _pZstr->next_out = (unsigned char*) _buffer; + _pZstr->avail_out = DEFLATE_BUFFER_SIZE; break; } } diff --git a/Foundation/src/InflatingStream.cpp b/Foundation/src/InflatingStream.cpp index cb59b4d091..4b685c80d0 100644 --- a/Foundation/src/InflatingStream.cpp +++ b/Foundation/src/InflatingStream.cpp @@ -15,6 +15,12 @@ #include "Poco/InflatingStream.h" #include "Poco/Exception.h" #include +#include +#if defined(POCO_UNBUNDLED) +#include +#else +#include "zlib.h" +#endif namespace Poco { @@ -27,29 +33,17 @@ InflatingStreamBuf::InflatingStreamBuf(std::istream& istr, StreamType type): _eof(false), _check(type != STREAM_ZIP) { - _zstr.next_in = 0; - _zstr.avail_in = 0; - _zstr.total_in = 0; - _zstr.next_out = 0; - _zstr.avail_out = 0; - _zstr.total_out = 0; - _zstr.msg = 0; - _zstr.state = 0; - _zstr.zalloc = Z_NULL; - _zstr.zfree = Z_NULL; - _zstr.opaque = Z_NULL; - _zstr.data_type = 0; - _zstr.adler = 0; - _zstr.reserved = 0; - - _buffer = new char[INFLATE_BUFFER_SIZE]; - - int rc = inflateInit2(&_zstr, 15 + (type == STREAM_GZIP ? 16 : 0)); + std::unique_ptr buffer(new char[INFLATE_BUFFER_SIZE]); + + std::unique_ptr pZstr = std::make_unique(z_stream{}); + int rc = inflateInit2(pZstr.get(), 15 + (type == STREAM_GZIP ? 16 : 0)); if (rc != Z_OK) { - delete [] _buffer; throw IOException(zError(rc)); } + + _pZstr = pZstr.release(); + _buffer = buffer.release(); } @@ -60,22 +54,17 @@ InflatingStreamBuf::InflatingStreamBuf(std::istream& istr, int windowBits): _eof(false), _check(false) { - _zstr.zalloc = Z_NULL; - _zstr.zfree = Z_NULL; - _zstr.opaque = Z_NULL; - _zstr.next_in = 0; - _zstr.avail_in = 0; - _zstr.next_out = 0; - _zstr.avail_out = 0; + std::unique_ptr buffer(new char[INFLATE_BUFFER_SIZE]); - _buffer = new char[INFLATE_BUFFER_SIZE]; - - int rc = inflateInit2(&_zstr, windowBits); + std::unique_ptr pZstr = std::make_unique(z_stream{}); + int rc = inflateInit2(pZstr.get(), windowBits); if (rc != Z_OK) { - delete [] _buffer; throw IOException(zError(rc)); } + + _pZstr = pZstr.release(); + _buffer = buffer.release(); } @@ -86,22 +75,17 @@ InflatingStreamBuf::InflatingStreamBuf(std::ostream& ostr, StreamType type): _eof(false), _check(type != STREAM_ZIP) { - _zstr.zalloc = Z_NULL; - _zstr.zfree = Z_NULL; - _zstr.opaque = Z_NULL; - _zstr.next_in = 0; - _zstr.avail_in = 0; - _zstr.next_out = 0; - _zstr.avail_out = 0; + std::unique_ptr buffer(new char[INFLATE_BUFFER_SIZE]); - _buffer = new char[INFLATE_BUFFER_SIZE]; - - int rc = inflateInit2(&_zstr, 15 + (type == STREAM_GZIP ? 16 : 0)); + std::unique_ptr pZstr = std::make_unique(z_stream{}); + int rc = inflateInit2(pZstr.get(), 15 + (type == STREAM_GZIP ? 16 : 0)); if (rc != Z_OK) { - delete [] _buffer; throw IOException(zError(rc)); } + + _pZstr = pZstr.release(); + _buffer = buffer.release(); } @@ -112,22 +96,17 @@ InflatingStreamBuf::InflatingStreamBuf(std::ostream& ostr, int windowBits): _eof(false), _check(false) { - _zstr.zalloc = Z_NULL; - _zstr.zfree = Z_NULL; - _zstr.opaque = Z_NULL; - _zstr.next_in = 0; - _zstr.avail_in = 0; - _zstr.next_out = 0; - _zstr.avail_out = 0; + std::unique_ptr buffer(new char[INFLATE_BUFFER_SIZE]); - _buffer = new char[INFLATE_BUFFER_SIZE]; - - int rc = inflateInit2(&_zstr, windowBits); + std::unique_ptr pZstr = std::make_unique(z_stream{}); + int rc = inflateInit2(pZstr.get(), windowBits); if (rc != Z_OK) { - delete [] _buffer; throw IOException(zError(rc)); } + + _pZstr = pZstr.release(); + _buffer = buffer.release(); } @@ -141,7 +120,8 @@ InflatingStreamBuf::~InflatingStreamBuf() { } delete [] _buffer; - inflateEnd(&_zstr); + inflateEnd(_pZstr); + delete _pZstr; } @@ -156,7 +136,7 @@ int InflatingStreamBuf::close() void InflatingStreamBuf::reset() { - int rc = inflateReset(&_zstr); + int rc = inflateReset(_pZstr); if (rc == Z_OK) _eof = false; else @@ -168,7 +148,7 @@ int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) { if (_eof || !_pIstr) return 0; - if (_zstr.avail_in == 0) + if (_pZstr->avail_in == 0) { int n = 0; if (_pIstr->good()) @@ -176,17 +156,17 @@ int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) _pIstr->read(_buffer, INFLATE_BUFFER_SIZE); n = static_cast(_pIstr->gcount()); } - _zstr.next_in = (unsigned char*) _buffer; - _zstr.avail_in = n; + _pZstr->next_in = (unsigned char*) _buffer; + _pZstr->avail_in = n; } - _zstr.next_out = (unsigned char*) buffer; - _zstr.avail_out = static_cast(length); + _pZstr->next_out = (unsigned char*) buffer; + _pZstr->avail_out = static_cast(length); for (;;) { - int rc = inflate(&_zstr, Z_NO_FLUSH); + int rc = inflate(_pZstr, Z_NO_FLUSH); if (rc == Z_DATA_ERROR && !_check) { - if (_zstr.avail_in == 0) + if (_pZstr->avail_in == 0) { if (_pIstr->good()) rc = Z_OK; @@ -197,12 +177,12 @@ int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (rc == Z_STREAM_END) { _eof = true; - return static_cast(length) - _zstr.avail_out; + return static_cast(length) - _pZstr->avail_out; } if (rc != Z_OK) throw IOException(zError(rc)); - if (_zstr.avail_out == 0) + if (_pZstr->avail_out == 0) return static_cast(length); - if (_zstr.avail_in == 0) + if (_pZstr->avail_in == 0) { int n = 0; if (_pIstr->good()) @@ -212,10 +192,10 @@ int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) } if (n > 0) { - _zstr.next_in = (unsigned char*) _buffer; - _zstr.avail_in = n; + _pZstr->next_in = (unsigned char*) _buffer; + _pZstr->avail_in = n; } - else return static_cast(length) - _zstr.avail_out; + else return static_cast(length) - _pZstr->avail_out; } } } @@ -225,33 +205,33 @@ int InflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length { if (length == 0 || !_pOstr) return 0; - _zstr.next_in = (unsigned char*) buffer; - _zstr.avail_in = static_cast(length); - _zstr.next_out = (unsigned char*) _buffer; - _zstr.avail_out = INFLATE_BUFFER_SIZE; + _pZstr->next_in = (unsigned char*) buffer; + _pZstr->avail_in = static_cast(length); + _pZstr->next_out = (unsigned char*) _buffer; + _pZstr->avail_out = INFLATE_BUFFER_SIZE; for (;;) { - int rc = inflate(&_zstr, Z_NO_FLUSH); + int rc = inflate(_pZstr, Z_NO_FLUSH); if (rc == Z_STREAM_END) { - _pOstr->write(_buffer, INFLATE_BUFFER_SIZE - _zstr.avail_out); + _pOstr->write(_buffer, INFLATE_BUFFER_SIZE - _pZstr->avail_out); if (!_pOstr->good()) throw IOException("Failed writing inflated data to output stream"); break; } if (rc != Z_OK) throw IOException(zError(rc)); - if (_zstr.avail_out == 0) + if (_pZstr->avail_out == 0) { _pOstr->write(_buffer, INFLATE_BUFFER_SIZE); if (!_pOstr->good()) throw IOException("Failed writing inflated data to output stream"); - _zstr.next_out = (unsigned char*) _buffer; - _zstr.avail_out = INFLATE_BUFFER_SIZE; + _pZstr->next_out = (unsigned char*) _buffer; + _pZstr->avail_out = INFLATE_BUFFER_SIZE; } - if (_zstr.avail_in == 0) + if (_pZstr->avail_in == 0) { - _pOstr->write(_buffer, INFLATE_BUFFER_SIZE - _zstr.avail_out); + _pOstr->write(_buffer, INFLATE_BUFFER_SIZE - _pZstr->avail_out); if (!_pOstr->good()) throw IOException("Failed writing inflated data to output stream"); - _zstr.next_out = (unsigned char*) _buffer; - _zstr.avail_out = INFLATE_BUFFER_SIZE; + _pZstr->next_out = (unsigned char*) _buffer; + _pZstr->avail_out = INFLATE_BUFFER_SIZE; break; } } diff --git a/Foundation/src/ucp.h b/Foundation/src/ucp.h deleted file mode 100644 index 2fa00296e4..0000000000 --- a/Foundation/src/ucp.h +++ /dev/null @@ -1,224 +0,0 @@ -/************************************************* -* Unicode Property Table handler * -*************************************************/ - -#ifndef _UCP_H -#define _UCP_H - -/* This file contains definitions of the property values that are returned by -the UCD access macros. New values that are added for new releases of Unicode -should always be at the end of each enum, for backwards compatibility. - -IMPORTANT: Note also that the specific numeric values of the enums have to be -the same as the values that are generated by the maint/MultiStage2.py script, -where the equivalent property descriptive names are listed in vectors. - -ALSO: The specific values of the first two enums are assumed for the table -called catposstab in pcre_compile.c. */ - -/* These are the general character categories. */ - -enum { - ucp_C, /* Other */ - ucp_L, /* Letter */ - ucp_M, /* Mark */ - ucp_N, /* Number */ - ucp_P, /* Punctuation */ - ucp_S, /* Symbol */ - ucp_Z /* Separator */ -}; - -/* These are the particular character categories. */ - -enum { - ucp_Cc, /* Control */ - ucp_Cf, /* Format */ - ucp_Cn, /* Unassigned */ - ucp_Co, /* Private use */ - ucp_Cs, /* Surrogate */ - ucp_Ll, /* Lower case letter */ - ucp_Lm, /* Modifier letter */ - ucp_Lo, /* Other letter */ - ucp_Lt, /* Title case letter */ - ucp_Lu, /* Upper case letter */ - ucp_Mc, /* Spacing mark */ - ucp_Me, /* Enclosing mark */ - ucp_Mn, /* Non-spacing mark */ - ucp_Nd, /* Decimal number */ - ucp_Nl, /* Letter number */ - ucp_No, /* Other number */ - ucp_Pc, /* Connector punctuation */ - ucp_Pd, /* Dash punctuation */ - ucp_Pe, /* Close punctuation */ - ucp_Pf, /* Final punctuation */ - ucp_Pi, /* Initial punctuation */ - ucp_Po, /* Other punctuation */ - ucp_Ps, /* Open punctuation */ - ucp_Sc, /* Currency symbol */ - ucp_Sk, /* Modifier symbol */ - ucp_Sm, /* Mathematical symbol */ - ucp_So, /* Other symbol */ - ucp_Zl, /* Line separator */ - ucp_Zp, /* Paragraph separator */ - ucp_Zs /* Space separator */ -}; - -/* These are grapheme break properties. Note that the code for processing them -assumes that the values are less than 16. If more values are added that take -the number to 16 or more, the code will have to be rewritten. */ - -enum { - ucp_gbCR, /* 0 */ - ucp_gbLF, /* 1 */ - ucp_gbControl, /* 2 */ - ucp_gbExtend, /* 3 */ - ucp_gbPrepend, /* 4 */ - ucp_gbSpacingMark, /* 5 */ - ucp_gbL, /* 6 Hangul syllable type L */ - ucp_gbV, /* 7 Hangul syllable type V */ - ucp_gbT, /* 8 Hangul syllable type T */ - ucp_gbLV, /* 9 Hangul syllable type LV */ - ucp_gbLVT, /* 10 Hangul syllable type LVT */ - ucp_gbRegionalIndicator, /* 11 */ - ucp_gbOther /* 12 */ -}; - -/* These are the script identifications. */ - -enum { - ucp_Arabic, - ucp_Armenian, - ucp_Bengali, - ucp_Bopomofo, - ucp_Braille, - ucp_Buginese, - ucp_Buhid, - ucp_Canadian_Aboriginal, - ucp_Cherokee, - ucp_Common, - ucp_Coptic, - ucp_Cypriot, - ucp_Cyrillic, - ucp_Deseret, - ucp_Devanagari, - ucp_Ethiopic, - ucp_Georgian, - ucp_Glagolitic, - ucp_Gothic, - ucp_Greek, - ucp_Gujarati, - ucp_Gurmukhi, - ucp_Han, - ucp_Hangul, - ucp_Hanunoo, - ucp_Hebrew, - ucp_Hiragana, - ucp_Inherited, - ucp_Kannada, - ucp_Katakana, - ucp_Kharoshthi, - ucp_Khmer, - ucp_Lao, - ucp_Latin, - ucp_Limbu, - ucp_Linear_B, - ucp_Malayalam, - ucp_Mongolian, - ucp_Myanmar, - ucp_New_Tai_Lue, - ucp_Ogham, - ucp_Old_Italic, - ucp_Old_Persian, - ucp_Oriya, - ucp_Osmanya, - ucp_Runic, - ucp_Shavian, - ucp_Sinhala, - ucp_Syloti_Nagri, - ucp_Syriac, - ucp_Tagalog, - ucp_Tagbanwa, - ucp_Tai_Le, - ucp_Tamil, - ucp_Telugu, - ucp_Thaana, - ucp_Thai, - ucp_Tibetan, - ucp_Tifinagh, - ucp_Ugaritic, - ucp_Yi, - /* New for Unicode 5.0: */ - ucp_Balinese, - ucp_Cuneiform, - ucp_Nko, - ucp_Phags_Pa, - ucp_Phoenician, - /* New for Unicode 5.1: */ - ucp_Carian, - ucp_Cham, - ucp_Kayah_Li, - ucp_Lepcha, - ucp_Lycian, - ucp_Lydian, - ucp_Ol_Chiki, - ucp_Rejang, - ucp_Saurashtra, - ucp_Sundanese, - ucp_Vai, - /* New for Unicode 5.2: */ - ucp_Avestan, - ucp_Bamum, - ucp_Egyptian_Hieroglyphs, - ucp_Imperial_Aramaic, - ucp_Inscriptional_Pahlavi, - ucp_Inscriptional_Parthian, - ucp_Javanese, - ucp_Kaithi, - ucp_Lisu, - ucp_Meetei_Mayek, - ucp_Old_South_Arabian, - ucp_Old_Turkic, - ucp_Samaritan, - ucp_Tai_Tham, - ucp_Tai_Viet, - /* New for Unicode 6.0.0: */ - ucp_Batak, - ucp_Brahmi, - ucp_Mandaic, - /* New for Unicode 6.1.0: */ - ucp_Chakma, - ucp_Meroitic_Cursive, - ucp_Meroitic_Hieroglyphs, - ucp_Miao, - ucp_Sharada, - ucp_Sora_Sompeng, - ucp_Takri, - /* New for Unicode 7.0.0: */ - ucp_Bassa_Vah, - ucp_Caucasian_Albanian, - ucp_Duployan, - ucp_Elbasan, - ucp_Grantha, - ucp_Khojki, - ucp_Khudawadi, - ucp_Linear_A, - ucp_Mahajani, - ucp_Manichaean, - ucp_Mende_Kikakui, - ucp_Modi, - ucp_Mro, - ucp_Nabataean, - ucp_Old_North_Arabian, - ucp_Old_Permic, - ucp_Pahawh_Hmong, - ucp_Palmyrene, - ucp_Psalter_Pahlavi, - ucp_Pau_Cin_Hau, - ucp_Siddham, - ucp_Tirhuta, - ucp_Warang_Citi -}; - -#endif - -/* End of ucp.h */ diff --git a/Foundation/testsuite/src/ZLibTest.cpp b/Foundation/testsuite/src/ZLibTest.cpp index c750d661d1..f450a1f9a1 100644 --- a/Foundation/testsuite/src/ZLibTest.cpp +++ b/Foundation/testsuite/src/ZLibTest.cpp @@ -18,7 +18,6 @@ #include "Poco/Buffer.h" #include - using Poco::InflatingInputStream; using Poco::InflatingOutputStream; using Poco::DeflatingOutputStream; @@ -97,7 +96,7 @@ void ZLibTest::testDeflate4() { Poco::Buffer buffer(1024); Poco::MemoryOutputStream ostr(buffer.begin(), static_cast(buffer.size())); - DeflatingOutputStream deflater(ostr, -10, Z_BEST_SPEED); + DeflatingOutputStream deflater(ostr, -10, DeflatingStreamBuf::BEST_SPEED); std::string data(36828, 'x'); deflater << data; deflater.close(); diff --git a/PocoDoc/cfg/mkdoc-poco.xml b/PocoDoc/cfg/mkdoc-poco.xml index 0c22fdca02..d0b9c8f0fa 100644 --- a/PocoDoc/cfg/mkdoc-poco.xml +++ b/PocoDoc/cfg/mkdoc-poco.xml @@ -10,9 +10,6 @@ *_*.h, - expat*.h, - zconf.h, - zlib.h, diff --git a/PocoDoc/cfg/mkdocumentation.xml b/PocoDoc/cfg/mkdocumentation.xml index 7bc1bcb515..7519cd5baa 100644 --- a/PocoDoc/cfg/mkdocumentation.xml +++ b/PocoDoc/cfg/mkdocumentation.xml @@ -10,9 +10,6 @@ *_*.h, - expat*.h, - zconf.h, - zlib.h, ${PocoBuild}/Util/include/Poco/Util/Units.h diff --git a/XML/XML_vs90.vcproj b/XML/XML_vs90.vcproj index 19f5166d2e..626d84210b 100644 --- a/XML/XML_vs90.vcproj +++ b/XML/XML_vs90.vcproj @@ -1168,30 +1168,26 @@ Name="Expat" > - - -#else -#include "Poco/XML/expat.h" -#endif +#include "Poco/XML/XMLString.h" #include #include #include @@ -42,6 +38,9 @@ #include +struct XML_ParserStruct; + + namespace Poco { namespace XML { @@ -269,11 +268,11 @@ class XML_API XMLStreamParser XMLStreamParser(const XMLStreamParser&); XMLStreamParser& operator = (const XMLStreamParser&); - static void XMLCALL handleStartElement(void*, const XML_Char*, const XML_Char**); - static void XMLCALL handleEndElement(void*, const XML_Char*); - static void XMLCALL handleCharacters(void*, const XML_Char*, int); - static void XMLCALL handleStartNamespaceDecl(void*, const XML_Char*, const XML_Char*); - static void XMLCALL handleEndNamespaceDecl(void*, const XML_Char*); + static void handleStartElement(void*, const XMLChar*, const XMLChar**); + static void handleEndElement(void*, const XMLChar*); + static void handleCharacters(void*, const XMLChar*, int); + static void handleStartNamespaceDecl(void*, const XMLChar*, const XMLChar*); + static void handleEndNamespaceDecl(void*, const XMLChar*); void init(); EventType nextImpl(bool peek); @@ -299,7 +298,7 @@ class XML_API XMLStreamParser std::size_t _size; const std::string _inputName; FeatureType _feature; - XML_Parser _parser; + XML_ParserStruct* _parser; std::size_t _depth; bool _accumulateContent; // Whether we are accumulating character content. ParserState _parserState; diff --git a/XML/src/ParserEngine.cpp b/XML/src/ParserEngine.cpp index 191084be05..296254566d 100644 --- a/XML/src/ParserEngine.cpp +++ b/XML/src/ParserEngine.cpp @@ -12,7 +12,7 @@ // -#include "Poco/XML/ParserEngine.h" +#include "ParserEngine.h" #include "Poco/XML/NamespaceStrategy.h" #include "Poco/XML/XMLException.h" #include "Poco/SAX/EntityResolver.h" diff --git a/XML/include/Poco/XML/ParserEngine.h b/XML/src/ParserEngine.h similarity index 99% rename from XML/include/Poco/XML/ParserEngine.h rename to XML/src/ParserEngine.h index e0c8455005..f74b553f36 100644 --- a/XML/include/Poco/XML/ParserEngine.h +++ b/XML/src/ParserEngine.h @@ -21,7 +21,7 @@ #if defined(POCO_UNBUNDLED) #include #else -#include "Poco/XML/expat.h" +#include "expat.h" #endif #include "Poco/XML/XMLString.h" #include "Poco/XML/XMLStream.h" diff --git a/XML/src/SAXParser.cpp b/XML/src/SAXParser.cpp index 54238b51b4..fa4af43925 100644 --- a/XML/src/SAXParser.cpp +++ b/XML/src/SAXParser.cpp @@ -18,6 +18,7 @@ #include "Poco/SAX/InputSource.h" #include "Poco/XML/NamespaceStrategy.h" #include "Poco/NumberParser.h" +#include "ParserEngine.h" #include @@ -34,85 +35,87 @@ SAXParser::SAXParser(): _namespaces(true), _namespacePrefixes(false) { + _engine = new ParserEngine; } SAXParser::SAXParser(const XMLString& encoding): - _engine(encoding), _namespaces(true), _namespacePrefixes(false) { + _engine = new ParserEngine(encoding); } SAXParser::~SAXParser() { + delete _engine; } void SAXParser::setEncoding(const XMLString& encoding) { - _engine.setEncoding(encoding); + _engine->setEncoding(encoding); } const XMLString& SAXParser::getEncoding() const { - return _engine.getEncoding(); + return _engine->getEncoding(); } void SAXParser::addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding) { - _engine.addEncoding(name, pEncoding); + _engine->addEncoding(name, pEncoding); } void SAXParser::setEntityResolver(EntityResolver* pResolver) { - _engine.setEntityResolver(pResolver); + _engine->setEntityResolver(pResolver); } EntityResolver* SAXParser::getEntityResolver() const { - return _engine.getEntityResolver(); + return _engine->getEntityResolver(); } void SAXParser::setDTDHandler(DTDHandler* pDTDHandler) { - _engine.setDTDHandler(pDTDHandler); + _engine->setDTDHandler(pDTDHandler); } DTDHandler* SAXParser::getDTDHandler() const { - return _engine.getDTDHandler(); + return _engine->getDTDHandler(); } void SAXParser::setContentHandler(ContentHandler* pContentHandler) { - _engine.setContentHandler(pContentHandler); + _engine->setContentHandler(pContentHandler); } ContentHandler* SAXParser::getContentHandler() const { - return _engine.getContentHandler(); + return _engine->getContentHandler(); } void SAXParser::setErrorHandler(ErrorHandler* pErrorHandler) { - _engine.setErrorHandler(pErrorHandler); + _engine->setErrorHandler(pErrorHandler); } ErrorHandler* SAXParser::getErrorHandler() const { - return _engine.getErrorHandler(); + return _engine->getErrorHandler(); } @@ -121,15 +124,15 @@ void SAXParser::setFeature(const XMLString& featureId, bool state) if (featureId == XMLReader::FEATURE_VALIDATION || featureId == XMLReader::FEATURE_STRING_INTERNING) throw SAXNotSupportedException(fromXMLString(XMLReader::FEATURE_VALIDATION)); else if (featureId == XMLReader::FEATURE_EXTERNAL_GENERAL_ENTITIES) - _engine.setExternalGeneralEntities(state); + _engine->setExternalGeneralEntities(state); else if (featureId == XMLReader::FEATURE_EXTERNAL_PARAMETER_ENTITIES) - _engine.setExternalParameterEntities(state); + _engine->setExternalParameterEntities(state); else if (featureId == XMLReader::FEATURE_NAMESPACES) _namespaces = state; else if (featureId == XMLReader::FEATURE_NAMESPACE_PREFIXES) _namespacePrefixes = state; else if (featureId == FEATURE_PARTIAL_READS) - _engine.setEnablePartialReads(state); + _engine->setEnablePartialReads(state); else throw SAXNotRecognizedException(fromXMLString(featureId)); } @@ -139,15 +142,15 @@ bool SAXParser::getFeature(const XMLString& featureId) const if (featureId == XMLReader::FEATURE_VALIDATION || featureId == XMLReader::FEATURE_STRING_INTERNING) throw SAXNotSupportedException(fromXMLString(XMLReader::FEATURE_VALIDATION)); else if (featureId == XMLReader::FEATURE_EXTERNAL_GENERAL_ENTITIES) - return _engine.getExternalGeneralEntities(); + return _engine->getExternalGeneralEntities(); else if (featureId == XMLReader::FEATURE_EXTERNAL_PARAMETER_ENTITIES) - return _engine.getExternalParameterEntities(); + return _engine->getExternalParameterEntities(); else if (featureId == XMLReader::FEATURE_NAMESPACES) return _namespaces; else if (featureId == XMLReader::FEATURE_NAMESPACE_PREFIXES) return _namespacePrefixes; else if (featureId == FEATURE_PARTIAL_READS) - return _engine.getEnablePartialReads(); + return _engine->getEnablePartialReads(); else throw SAXNotRecognizedException(fromXMLString(featureId)); } @@ -157,9 +160,9 @@ void SAXParser::setProperty(const XMLString& propertyId, const XMLString& value) if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER || propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER) throw SAXNotSupportedException(std::string("property does not take a string value: ") + fromXMLString(propertyId)); else if (propertyId == PROPERTY_BLA_MAXIMUM_AMPLIFICATION) - _engine.setBillionLaughsAttackProtectionMaximumAmplification(static_cast(Poco::NumberParser::parseFloat(value))); + _engine->setBillionLaughsAttackProtectionMaximumAmplification(static_cast(Poco::NumberParser::parseFloat(value))); else if (propertyId == PROPERTY_BLA_ACTIVATION_THRESHOLD) - _engine.setBillionLaughsAttackProtectionActivationThreshold(Poco::NumberParser::parseUnsigned64(value)); + _engine->setBillionLaughsAttackProtectionActivationThreshold(Poco::NumberParser::parseUnsigned64(value)); else throw SAXNotRecognizedException(fromXMLString(propertyId)); } @@ -168,9 +171,9 @@ void SAXParser::setProperty(const XMLString& propertyId, const XMLString& value) void SAXParser::setProperty(const XMLString& propertyId, void* value) { if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER) - _engine.setDeclHandler(reinterpret_cast(value)); + _engine->setDeclHandler(reinterpret_cast(value)); else if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER) - _engine.setLexicalHandler(reinterpret_cast(value)); + _engine->setLexicalHandler(reinterpret_cast(value)); else throw SAXNotRecognizedException(fromXMLString(propertyId)); } @@ -178,9 +181,9 @@ void SAXParser::setProperty(const XMLString& propertyId, void* value) void* SAXParser::getProperty(const XMLString& propertyId) const { if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER) - return _engine.getDeclHandler(); + return _engine->getDeclHandler(); else if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER) - return _engine.getLexicalHandler(); + return _engine->getLexicalHandler(); else throw SAXNotSupportedException(fromXMLString(propertyId)); } @@ -190,7 +193,7 @@ void SAXParser::parse(InputSource* pInputSource) if (pInputSource->getByteStream() || pInputSource->getCharacterStream()) { setupParse(); - _engine.parse(pInputSource); + _engine->parse(pInputSource); } else parse(pInputSource->getSystemId()); } @@ -205,7 +208,7 @@ void SAXParser::parse(const XMLString& systemId) { try { - _engine.parse(pInputSource); + _engine->parse(pInputSource); } catch (...) { @@ -227,18 +230,18 @@ void SAXParser::parseString(const std::string& xml) void SAXParser::parseMemoryNP(const char* xml, std::size_t size) { setupParse(); - _engine.parse(xml, size); + _engine->parse(xml, size); } void SAXParser::setupParse() { if (_namespaces && !_namespacePrefixes) - _engine.setNamespaceStrategy(new NoNamespacePrefixesStrategy); + _engine->setNamespaceStrategy(new NoNamespacePrefixesStrategy); else if (_namespaces && _namespacePrefixes) - _engine.setNamespaceStrategy(new NamespacePrefixesStrategy); + _engine->setNamespaceStrategy(new NamespacePrefixesStrategy); else - _engine.setNamespaceStrategy(new NoNamespacesStrategy); + _engine->setNamespaceStrategy(new NoNamespacesStrategy); } diff --git a/XML/src/XMLStreamParser.cpp b/XML/src/XMLStreamParser.cpp index e3937c327c..4eaf35c5de 100644 --- a/XML/src/XMLStreamParser.cpp +++ b/XML/src/XMLStreamParser.cpp @@ -16,6 +16,12 @@ #include "Poco/XML/XMLStreamParser.h" +#include "Poco/XML/XMLString.h" +#if defined(POCO_UNBUNDLED) +#include +#else +#include "expat.h" +#endif #include #include #include @@ -705,7 +711,7 @@ static void splitName(const XML_Char* s, QName& qn) } -void XMLCALL XMLStreamParser::handleStartElement(void* v, const XML_Char* name, const XML_Char** atts) +void XMLStreamParser::handleStartElement(void* v, const XMLChar* name, const XMLChar** atts) { XMLStreamParser& p(*static_cast(v)); @@ -789,7 +795,7 @@ void XMLCALL XMLStreamParser::handleStartElement(void* v, const XML_Char* name, } -void XMLCALL XMLStreamParser::handleEndElement(void* v, const XML_Char* name) +void XMLStreamParser::handleEndElement(void* v, const XMLChar* name) { XMLStreamParser& p(*static_cast(v)); @@ -828,7 +834,7 @@ void XMLCALL XMLStreamParser::handleEndElement(void* v, const XML_Char* name) } -void XMLCALL XMLStreamParser::handleCharacters(void* v, const XML_Char* s, int n) +void XMLStreamParser::handleCharacters(void* v, const XMLChar* s, int n) { XMLStreamParser& p(*static_cast(v)); @@ -899,7 +905,7 @@ void XMLCALL XMLStreamParser::handleCharacters(void* v, const XML_Char* s, int n } -void XMLCALL XMLStreamParser::handleStartNamespaceDecl(void* v, const XML_Char* prefix, const XML_Char* ns) +void XMLStreamParser::handleStartNamespaceDecl(void* v, const XMLChar* prefix, const XMLChar* ns) { XMLStreamParser& p(*static_cast(v)); @@ -918,7 +924,7 @@ void XMLCALL XMLStreamParser::handleStartNamespaceDecl(void* v, const XML_Char* } -void XMLCALL XMLStreamParser::handleEndNamespaceDecl(void* v, const XML_Char* prefix) +void XMLStreamParser::handleEndNamespaceDecl(void* v, const XMLChar* prefix) { XMLStreamParser& p(*static_cast(v)); diff --git a/XML/include/Poco/XML/expat.h b/XML/src/expat.h similarity index 100% rename from XML/include/Poco/XML/expat.h rename to XML/src/expat.h diff --git a/XML/include/Poco/XML/expat_external.h b/XML/src/expat_external.h similarity index 100% rename from XML/include/Poco/XML/expat_external.h rename to XML/src/expat_external.h diff --git a/XML/src/internal.h b/XML/src/internal.h index a27eb20bcc..167ec36804 100644 --- a/XML/src/internal.h +++ b/XML/src/internal.h @@ -147,7 +147,7 @@ 8388608 // 8 MiB, 2^23 /* NOTE END */ -#include "Poco/XML/expat.h" // so we can use type XML_Parser below +#include "expat.h" // so we can use type XML_Parser below #ifdef __cplusplus extern "C" { diff --git a/XML/src/xmlparse.cpp b/XML/src/xmlparse.cpp index b3aea4b13c..89b0613edd 100644 --- a/XML/src/xmlparse.cpp +++ b/XML/src/xmlparse.cpp @@ -124,7 +124,7 @@ #include "expat_config.h" #include "ascii.h" -#include "Poco/XML/expat.h" +#include "expat.h" #include "siphash.h" #if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) diff --git a/XML/src/xmlrole.c b/XML/src/xmlrole.c index ea4dd85414..e754ce295e 100644 --- a/XML/src/xmlrole.c +++ b/XML/src/xmlrole.c @@ -38,15 +38,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "expat_config.h" + #include #ifdef EXPAT_WIN32 #include "winconfig.h" #endif -#include "expat_config.h" - -#include "Poco/XML/expat_external.h" +#include "expat_external.h" #include "internal.h" #include "xmlrole.h" #include "ascii.h" diff --git a/XML/src/xmltok.c b/XML/src/xmltok.c index a44b57ffb0..0ddf7ab25c 100644 --- a/XML/src/xmltok.c +++ b/XML/src/xmltok.c @@ -46,6 +46,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "expat_config.h" + #include #include /* memcpy */ #include @@ -54,9 +56,7 @@ # include "winconfig.h" #endif -#include "expat_config.h" - -#include "Poco/XML/expat_external.h" +#include "expat_external.h" #include "internal.h" #include "xmltok.h" #include "nametab.h" diff --git a/Zip/src/ZipStream.cpp b/Zip/src/ZipStream.cpp index 04acb21184..8472f870e4 100644 --- a/Zip/src/ZipStream.cpp +++ b/Zip/src/ZipStream.cpp @@ -25,7 +25,8 @@ #if defined(POCO_UNBUNDLED) #include #else -#include "Poco/zlib.h" +// Quirk before we move zlib to external libs. +#include "../../Foundation/src/zlib.h" #endif