diff --git a/.gitmodules b/.gitmodules index e69de29bb2d..4ee568768ff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,15 @@ +[submodule "contrib/librdkafka"] + path = contrib/librdkafka + url = https://github.com/edenhill/librdkafka.git +[submodule "contrib/zookeeper"] + path = contrib/zookeeper + url = https://github.com/ClickHouse-Extras/zookeeper.git +[submodule "contrib/poco"] + path = contrib/poco + url = https://github.com/ClickHouse-Extras/poco +[submodule "contrib/zstd"] + path = contrib/zstd + url = https://github.com/facebook/zstd.git +[submodule "contrib/lz4"] + path = contrib/lz4 + url = https://github.com/lz4/lz4.git diff --git a/CMakeLists.txt b/CMakeLists.txt index a73871109ae..0b578387c47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,6 +229,7 @@ include (cmake/find_rt.cmake) include (cmake/find_readline_edit.cmake) include (cmake/find_zookeeper.cmake) include (cmake/find_re2.cmake) +include (cmake/find_rdkafka.cmake) include (cmake/find_contrib_lib.cmake) find_contrib_lib(cityhash) diff --git a/cmake/find_boost.cmake b/cmake/find_boost.cmake index 72693bafe8e..603b8d51d2f 100644 --- a/cmake/find_boost.cmake +++ b/cmake/find_boost.cmake @@ -19,7 +19,6 @@ if (NOT USE_INTERNAL_BOOST_LIBRARY) endif () if (NOT Boost_SYSTEM_LIBRARY) - add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED) set (USE_INTERNAL_BOOST_LIBRARY 1) set (Boost_PROGRAM_OPTIONS_LIBRARY boost_program_options_internal) set (Boost_SYSTEM_LIBRARY boost_system_internal) diff --git a/cmake/find_lz4.cmake b/cmake/find_lz4.cmake index f7c703fe44a..ddcf1c03ba8 100644 --- a/cmake/find_lz4.cmake +++ b/cmake/find_lz4.cmake @@ -1,13 +1,18 @@ option (USE_INTERNAL_LZ4_LIBRARY "Set to FALSE to use system lz4 library instead of bundled" ${NOT_UNBUNDLED}) +if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/lz4/lib/lz4.h") + message (WARNING "submodule contrib/lz4 is missing. to fix try run: \n git submodule update --init --recursive") + set (USE_INTERNAL_LZ4_LIBRARY 0) +endif () + if (NOT USE_INTERNAL_LZ4_LIBRARY) find_library (LZ4_LIBRARY lz4) find_path (LZ4_INCLUDE_DIR NAMES lz4.h PATHS ${LZ4_INCLUDE_PATHS}) endif () if (LZ4_LIBRARY AND LZ4_INCLUDE_DIR) - include_directories (${LZ4_INCLUDE_DIR}) else () + set (LZ4_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/lz4/lib) set (USE_INTERNAL_LZ4_LIBRARY 1) set (LZ4_LIBRARY lz4) endif () diff --git a/cmake/find_poco.cmake b/cmake/find_poco.cmake index cd14b68fa4a..6d3c8dee94b 100644 --- a/cmake/find_poco.cmake +++ b/cmake/find_poco.cmake @@ -5,42 +5,55 @@ if (NOT USE_INTERNAL_POCO_LIBRARY) endif () if (Poco_INCLUDE_DIRS AND Poco_Foundation_LIBRARY) - include_directories (${Poco_INCLUDE_DIRS}) + #include_directories (${Poco_INCLUDE_DIRS}) else () set (USE_INTERNAL_POCO_LIBRARY 1) - include (${ClickHouse_SOURCE_DIR}/cmake/find_ltdl.cmake) - include (${ClickHouse_SOURCE_DIR}/contrib/libpoco/cmake/FindODBC.cmake) + set (ENABLE_ZIP 0 CACHE BOOL "") + set (ENABLE_PAGECOMPILER 0 CACHE BOOL "") + set (ENABLE_PAGECOMPILER_FILE2PAGE 0 CACHE BOOL "") + set (ENABLE_REDIS 0 CACHE BOOL "") + set (ENABLE_DATA_SQLITE 0 CACHE BOOL "") + set (ENABLE_DATA_MYSQL 0 CACHE BOOL "") + set (ENABLE_DATA_POSTGRESQL 0 CACHE BOOL "") + set (POCO_UNBUNDLED 1 CACHE BOOL "") + set (POCO_UNBUNDLED_PCRE 0 CACHE BOOL "") + set (POCO_UNBUNDLED_EXPAT 0 CACHE BOOL "") + set (POCO_STATIC ${MAKE_STATIC_LIBRARIES} CACHE BOOL "") + set (POCO_VERBOSE_MESSAGES 1 CACHE BOOL "") + include (${ClickHouse_SOURCE_DIR}/cmake/find_ltdl.cmake) + include (${ClickHouse_SOURCE_DIR}/contrib/poco/cmake/FindODBC.cmake) + + # used in internal compiler list (APPEND Poco_INCLUDE_DIRS - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Foundation/include/" - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Util/include/" - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Net/include/" - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Data/include/" - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/XML/include/" + "${ClickHouse_SOURCE_DIR}/contrib/poco/Foundation/include/" + "${ClickHouse_SOURCE_DIR}/contrib/poco/Util/include/" ) if (NOT DEFINED POCO_ENABLE_MONGODB OR POCO_ENABLE_MONGODB) set (Poco_MongoDB_FOUND 1) set (Poco_MongoDB_LIBRARY PocoMongoDB) - list (APPEND Poco_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/libpoco/MongoDB/include/") + set (Poco_MongoDB_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/poco/MongoDB/include/") endif () if (ODBC_FOUND) set (Poco_DataODBC_FOUND 1) set (Poco_DataODBC_LIBRARY PocoDataODBC) - list (APPEND Poco_DataODBC_LIBRARY ${LTDL_LIB}) - list (APPEND Poco_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Data/ODBC/include/") + if (USE_STATIC_LIBRARIES) + list (APPEND Poco_DataODBC_LIBRARY ${LTDL_LIB}) + endif () + set (Poco_DataODBC_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/poco/Data/ODBC/include/") endif () if (OPENSSL_FOUND) set (Poco_NetSSL_FOUND 1) set (Poco_NetSSL_LIBRARY PocoNetSSL) set (Poco_Crypto_LIBRARY PocoCrypto) - list (APPEND Poco_INCLUDE_DIRS - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/NetSSL_OpenSSL/include/" - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Crypto/include/" + set (Poco_NetSSL_INCLUDE_DIRS + "${ClickHouse_SOURCE_DIR}/contrib/poco/NetSSL_OpenSSL/include/" + "${ClickHouse_SOURCE_DIR}/contrib/poco/Crypto/include/" ) endif () @@ -56,7 +69,23 @@ else () set (Poco_Net_LIBRARY PocoNet) set (Poco_Data_LIBRARY PocoData) set (Poco_XML_LIBRARY PocoXML) - include_directories (BEFORE ${Poco_INCLUDE_DIRS}) + + #include_directories (BEFORE ${Poco_INCLUDE_DIRS}) + endif () message(STATUS "Using Poco: ${Poco_INCLUDE_DIRS} : ${Poco_Foundation_LIBRARY},${Poco_Util_LIBRARY},${Poco_Net_LIBRARY},${Poco_NetSSL_LIBRARY},${Poco_XML_LIBRARY},${Poco_Data_LIBRARY},${Poco_DataODBC_LIBRARY},${Poco_MongoDB_LIBRARY}; MongoDB=${Poco_MongoDB_FOUND}, DataODBC=${Poco_DataODBC_FOUND}, NetSSL=${Poco_NetSSL_FOUND}") + +# How to make sutable poco: +# use branch: +# develop OR poco-1.7.9-release + 6a49c94d18c654d7a20b8c8ea47071b1fdd4813b +# and merge: +# ClickHouse-Extras/clickhouse_unbundled +# ClickHouse-Extras/clickhouse_unbundled_zlib +# ClickHouse-Extras/clickhouse_task # uses c++11, can't push to poco +# ClickHouse-Extras/clickhouse_misc +# ClickHouse-Extras/clickhouse_anl +# ClickHouse-Extras/clickhouse_http_header https://github.com/pocoproject/poco/pull/1574 +# ClickHouse-Extras/clickhouse_socket +# ClickHouse-Extras/clickhouse_warning + diff --git a/cmake/find_rdkafka.cmake b/cmake/find_rdkafka.cmake new file mode 100644 index 00000000000..ae0fb05158b --- /dev/null +++ b/cmake/find_rdkafka.cmake @@ -0,0 +1,24 @@ +option (ENABLE_RDKAFKA "Enable kafka" ON) + +if (ENABLE_RDKAFKA) + +option (USE_INTERNAL_RDKAFKA_LIBRARY "Set to FALSE to use system librdkafka instead of the bundled" ${NOT_UNBUNDLED}) + +if (NOT USE_INTERNAL_RDKAFKA_LIBRARY) + find_library (RDKAFKA_LIBRARY rdkafka) + find_path (RDKAFKA_INCLUDE_DIR NAMES librdkafka/rdkafka.h PATHS ${RDKAFKA_INCLUDE_PATHS}) +endif () + +if (RDKAFKA_LIBRARY AND RDKAFKA_INCLUDE_DIR) + include_directories (${RDKAFKA_INCLUDE_DIR}) +else () + set (USE_INTERNAL_RDKAFKA_LIBRARY 1) + set (RDKAFKA_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/librdkafka/src") + set (RDKAFKA_LIBRARY rdkafka) +endif () + +set (USE_RDKAFKA 1) + +endif () + +message (STATUS "Using librdkafka=${USE_RDKAFKA}: ${RDKAFKA_INCLUDE_DIR} : ${RDKAFKA_LIBRARY}") diff --git a/cmake/find_zlib.cmake b/cmake/find_zlib.cmake index e9f3d89eb08..bbfc75e5e24 100644 --- a/cmake/find_zlib.cmake +++ b/cmake/find_zlib.cmake @@ -6,7 +6,9 @@ endif () if (NOT ZLIB_FOUND) set (USE_INTERNAL_ZLIB_LIBRARY 1) - set (ZLIB_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libzlib-ng") + set (ZLIB_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libzlib-ng" "${ClickHouse_BINARY_DIR}/contrib/libzlib-ng") # generated zconf.h + set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) # for poco + set (ZLIB_FOUND 1) # for poco if (USE_STATIC_LIBRARIES) set (ZLIB_LIBRARIES zlibstatic) else () diff --git a/cmake/find_zookeeper.cmake b/cmake/find_zookeeper.cmake index 26effbc9115..2e6d398b8de 100644 --- a/cmake/find_zookeeper.cmake +++ b/cmake/find_zookeeper.cmake @@ -3,13 +3,24 @@ option (USE_INTERNAL_ZOOKEEPER_LIBRARY "Set to FALSE to use system zookeeper lib if (NOT USE_INTERNAL_ZOOKEEPER_LIBRARY) find_library (ZOOKEEPER_LIBRARY zookeeper_mt) find_path (ZOOKEEPER_INCLUDE_DIR NAMES zookeeper/zookeeper.h PATHS ${ZOOKEEPER_INCLUDE_PATHS}) + set(ZOOKEEPER_INCLUDE_DIR "${ZOOKEEPER_INCLUDE_DIR}/zookeeper") endif () if (ZOOKEEPER_LIBRARY AND ZOOKEEPER_INCLUDE_DIR) include_directories (${ZOOKEEPER_INCLUDE_DIR}) else () set (USE_INTERNAL_ZOOKEEPER_LIBRARY 1) - set (ZOOKEEPER_LIBRARY zookeeper_mt) + set(WANT_CPPUNIT 0 CACHE BOOL "") + set (ZOOKEEPER_LIBRARY zookeeper) endif () message (STATUS "Using zookeeper: ${ZOOKEEPER_INCLUDE_DIR} : ${ZOOKEEPER_LIBRARY}") + + +# how to make clickhouse branch of https://github.com/ClickHouse-Extras/zookeeper.git : +# git remote add upstream https://github.com/apache/zookeeper.git +# git checkhout upstream/master +# git branch -D clickhouse +# git checkout -b clickhouse +# git merge clickhouse_misc +# git merge clickhouse_706 diff --git a/cmake/find_zstd.cmake b/cmake/find_zstd.cmake index 86bd420acff..909a02c28c3 100644 --- a/cmake/find_zstd.cmake +++ b/cmake/find_zstd.cmake @@ -1,12 +1,16 @@ option (USE_INTERNAL_ZSTD_LIBRARY "Set to FALSE to use system zstd library instead of bundled" ${NOT_UNBUNDLED}) +if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/zstd/lib/zstd.h") + message (WARNING "submodule contrib/zstd is missing. to fix try run: \n git submodule update --init --recursive") + set (USE_INTERNAL_ZSTD_LIBRARY 0) +endif () + if (NOT USE_INTERNAL_ZSTD_LIBRARY) find_library (ZSTD_LIBRARY zstd) find_path (ZSTD_INCLUDE_DIR NAMES zstd.h PATHS ${ZSTD_INCLUDE_PATHS}) endif () if (ZSTD_LIBRARY AND ZSTD_INCLUDE_DIR) - include_directories (${ZSTD_INCLUDE_DIR}) else () set (USE_INTERNAL_ZSTD_LIBRARY 1) set (ZSTD_LIBRARY zstd) diff --git a/cmake/print_include_directories.cmake b/cmake/print_include_directories.cmake index 83b8064d262..d9a60389fc8 100644 --- a/cmake/print_include_directories.cmake +++ b/cmake/print_include_directories.cmake @@ -12,6 +12,10 @@ if (USE_INTERNAL_BOOST_LIBRARY) list(APPEND dirs ${dirs1}) endif () +if (USE_INTERNAL_POCO_LIBRARY) + list(APPEND dirs "./contrib/poco/Foundation/include") +endif () + list(REMOVE_DUPLICATES dirs) file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/include_directories.txt "") foreach (dir ${dirs}) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index bb61c089acc..f21bee5d979 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -4,16 +4,12 @@ if (USE_INTERNAL_BOOST_LIBRARY) add_subdirectory (libboost) endif () -if (USE_INTERNAL_POCO_LIBRARY) - add_subdirectory (libpoco) -endif () - if (USE_INTERNAL_LZ4_LIBRARY) - add_subdirectory (liblz4) + add_subdirectory (lz4-cmake) endif () if (USE_INTERNAL_ZSTD_LIBRARY) - add_subdirectory (libzstd) + add_subdirectory (zstd-cmake) endif () if (USE_INTERNAL_RE2_LIBRARY) @@ -25,7 +21,7 @@ if (USE_INTERNAL_DOUBLE_CONVERSION_LIBRARY) endif () if (USE_INTERNAL_ZOOKEEPER_LIBRARY) - add_subdirectory (libzookeeper) + add_subdirectory (zookeeper/src/c) endif () if (USE_INTERNAL_CITYHASH_LIBRARY) @@ -63,3 +59,19 @@ endif () if (NOT ARCH_ARM) add_subdirectory (libcpuid) endif () + +if (USE_INTERNAL_RDKAFKA_LIBRARY) + set(RDKAFKA_BUILD_EXAMPLES OFF CACHE BOOL "") + set(RDKAFKA_BUILD_TESTS OFF CACHE BOOL "") + mark_as_advanced(ZLIB_INCLUDE_DIR) + add_subdirectory (librdkafka) +endif () + +if (USE_INTERNAL_POCO_LIBRARY) + set (_save ${ENABLE_TESTS}) + set (ENABLE_TESTS 0) + set (CMAKE_DISABLE_FIND_PACKAGE_ZLIB 1) + add_subdirectory (poco) + unset (CMAKE_DISABLE_FIND_PACKAGE_ZLIB) + set (ENABLE_TESTS ${_save}) +endif () diff --git a/contrib/libboost/CMakeLists.txt b/contrib/libboost/CMakeLists.txt index 908ddfc1e43..8cfe084636a 100644 --- a/contrib/libboost/CMakeLists.txt +++ b/contrib/libboost/CMakeLists.txt @@ -30,3 +30,7 @@ boost_1_65_0/libs/system/src/error_code.cpp) target_include_directories (boost_program_options_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS}) target_include_directories (boost_filesystem_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS}) target_include_directories (boost_system_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS}) + +target_compile_definitions (boost_program_options_internal PUBLIC BOOST_SYSTEM_NO_DEPRECATED) +target_compile_definitions (boost_filesystem_internal PUBLIC BOOST_SYSTEM_NO_DEPRECATED) +target_compile_definitions (boost_system_internal PUBLIC BOOST_SYSTEM_NO_DEPRECATED) diff --git a/contrib/liblz4/CMakeLists.txt b/contrib/liblz4/CMakeLists.txt deleted file mode 100644 index 865c0dca2bf..00000000000 --- a/contrib/liblz4/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -add_library (lz4 - src/lz4.c - src/lz4hc.c - - include/lz4/lz4.h - include/lz4/lz4hc.h - include/lz4/lz4opt.h) - -target_include_directories(lz4 PUBLIC include/lz4) diff --git a/contrib/liblz4/LICENSE b/contrib/liblz4/LICENSE deleted file mode 100644 index 552349d382f..00000000000 --- a/contrib/liblz4/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -LZ4 Library -Copyright (c) 2011-2014, Yann Collet -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/contrib/liblz4/include/lz4/lz4.h b/contrib/liblz4/include/lz4/lz4.h deleted file mode 100644 index 0aae19c9a73..00000000000 --- a/contrib/liblz4/include/lz4/lz4.h +++ /dev/null @@ -1,463 +0,0 @@ -/* - * LZ4 - Fast LZ compression algorithm - * Header File - * Copyright (C) 2011-2016, Yann Collet. - - BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - You can contact the author at : - - LZ4 homepage : http://www.lz4.org - - LZ4 source repository : https://github.com/lz4/lz4 -*/ -#ifndef LZ4_H_2983827168210 -#define LZ4_H_2983827168210 - -#if defined (__cplusplus) -extern "C" { -#endif - -/* --- Dependency --- */ -#include /* size_t */ - - -/** - Introduction - - LZ4 is lossless compression algorithm, providing compression speed at 400 MB/s per core, - scalable with multi-cores CPU. It features an extremely fast decoder, with speed in - multiple GB/s per core, typically reaching RAM speed limits on multi-core systems. - - The LZ4 compression library provides in-memory compression and decompression functions. - Compression can be done in: - - a single step (described as Simple Functions) - - a single step, reusing a context (described in Advanced Functions) - - unbounded multiple steps (described as Streaming compression) - - lz4.h provides block compression functions. It gives full buffer control to user. - Decompressing an lz4-compressed block also requires metadata (such as compressed size). - Each application is free to encode such metadata in whichever way it wants. - - An additional format, called LZ4 frame specification (doc/lz4_Frame_format.md), - take care of encoding standard metadata alongside LZ4-compressed blocks. - If your application requires interoperability, it's recommended to use it. - A library is provided to take care of it, see lz4frame.h. -*/ - -/*^*************************************************************** -* Export parameters -*****************************************************************/ -/* -* LZ4_DLL_EXPORT : -* Enable exporting of functions when building a Windows DLL -*/ -#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) -# define LZ4LIB_API __declspec(dllexport) -#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1) -# define LZ4LIB_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ -#else -# define LZ4LIB_API -#endif - - -/*========== Version =========== */ -#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ -#define LZ4_VERSION_MINOR 7 /* for new (non-breaking) interface capabilities */ -#define LZ4_VERSION_RELEASE 5 /* for tweaks, bug-fixes, or development */ - -#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) - -#define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE -#define LZ4_QUOTE(str) #str -#define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str) -#define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) - -LZ4LIB_API int LZ4_versionNumber (void); -LZ4LIB_API const char* LZ4_versionString (void); - - -/*-************************************ -* Tuning parameter -**************************************/ -/*! - * LZ4_MEMORY_USAGE : - * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.) - * Increasing memory usage improves compression ratio - * Reduced memory usage can improve speed, due to cache effect - * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache - */ -#define LZ4_MEMORY_USAGE 14 - - -/*-************************************ -* Simple Functions -**************************************/ -/*! LZ4_compress_default() : - Compresses 'sourceSize' bytes from buffer 'source' - into already allocated 'dest' buffer of size 'maxDestSize'. - Compression is guaranteed to succeed if 'maxDestSize' >= LZ4_compressBound(sourceSize). - It also runs faster, so it's a recommended setting. - If the function cannot compress 'source' into a more limited 'dest' budget, - compression stops *immediately*, and the function result is zero. - As a consequence, 'dest' content is not valid. - This function never writes outside 'dest' buffer, nor read outside 'source' buffer. - sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE - maxDestSize : full or partial size of buffer 'dest' (which must be already allocated) - return : the number of bytes written into buffer 'dest' (necessarily <= maxOutputSize) - or 0 if compression fails */ -LZ4LIB_API int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize); - -/*! LZ4_decompress_safe() : - compressedSize : is the precise full size of the compressed block. - maxDecompressedSize : is the size of destination buffer, which must be already allocated. - return : the number of bytes decompressed into destination buffer (necessarily <= maxDecompressedSize) - If destination buffer is not large enough, decoding will stop and output an error code (<0). - If the source stream is detected malformed, the function will stop decoding and return a negative result. - This function is protected against buffer overflow exploits, including malicious data packets. - It never writes outside output buffer, nor reads outside input buffer. -*/ -LZ4LIB_API int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize); - - -/*-************************************ -* Advanced Functions -**************************************/ -#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */ -#define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16) - -/*! -LZ4_compressBound() : - Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible) - This function is primarily useful for memory allocation purposes (destination buffer size). - Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example). - Note that LZ4_compress_default() compress faster when dest buffer size is >= LZ4_compressBound(srcSize) - inputSize : max supported value is LZ4_MAX_INPUT_SIZE - return : maximum output size in a "worst case" scenario - or 0, if input size is too large ( > LZ4_MAX_INPUT_SIZE) -*/ -LZ4LIB_API int LZ4_compressBound(int inputSize); - -/*! -LZ4_compress_fast() : - Same as LZ4_compress_default(), but allows to select an "acceleration" factor. - The larger the acceleration value, the faster the algorithm, but also the lesser the compression. - It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed. - An acceleration value of "1" is the same as regular LZ4_compress_default() - Values <= 0 will be replaced by ACCELERATION_DEFAULT (see lz4.c), which is 1. -*/ -LZ4LIB_API int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration); - - -/*! -LZ4_compress_fast_extState() : - Same compression function, just using an externally allocated memory space to store compression state. - Use LZ4_sizeofState() to know how much memory must be allocated, - and allocate it on 8-bytes boundaries (using malloc() typically). - Then, provide it as 'void* state' to compression function. -*/ -LZ4LIB_API int LZ4_sizeofState(void); -LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* source, char* dest, int inputSize, int maxDestSize, int acceleration); - - -/*! -LZ4_compress_destSize() : - Reverse the logic, by compressing as much data as possible from 'source' buffer - into already allocated buffer 'dest' of size 'targetDestSize'. - This function either compresses the entire 'source' content into 'dest' if it's large enough, - or fill 'dest' buffer completely with as much data as possible from 'source'. - *sourceSizePtr : will be modified to indicate how many bytes where read from 'source' to fill 'dest'. - New value is necessarily <= old value. - return : Nb bytes written into 'dest' (necessarily <= targetDestSize) - or 0 if compression fails -*/ -LZ4LIB_API int LZ4_compress_destSize (const char* source, char* dest, int* sourceSizePtr, int targetDestSize); - - -/*! -LZ4_decompress_fast() : - originalSize : is the original and therefore uncompressed size - return : the number of bytes read from the source buffer (in other words, the compressed size) - If the source stream is detected malformed, the function will stop decoding and return a negative result. - Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes. - note : This function fully respect memory boundaries for properly formed compressed data. - It is a bit faster than LZ4_decompress_safe(). - However, it does not provide any protection against intentionally modified data stream (malicious input). - Use this function in trusted environment only (data to decode comes from a trusted source). -*/ -LZ4LIB_API int LZ4_decompress_fast (const char* source, char* dest, int originalSize); - -/*! -LZ4_decompress_safe_partial() : - This function decompress a compressed block of size 'compressedSize' at position 'source' - into destination buffer 'dest' of size 'maxDecompressedSize'. - The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached, - reducing decompression time. - return : the number of bytes decoded in the destination buffer (necessarily <= maxDecompressedSize) - Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller. - Always control how many bytes were decoded. - If the source stream is detected malformed, the function will stop decoding and return a negative result. - This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets -*/ -LZ4LIB_API int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize); - - -/*-********************************************* -* Streaming Compression Functions -***********************************************/ -typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */ - -/*! LZ4_createStream() and LZ4_freeStream() : - * LZ4_createStream() will allocate and initialize an `LZ4_stream_t` structure. - * LZ4_freeStream() releases its memory. - */ -LZ4LIB_API LZ4_stream_t* LZ4_createStream(void); -LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr); - -/*! LZ4_resetStream() : - * An LZ4_stream_t structure can be allocated once and re-used multiple times. - * Use this function to init an allocated `LZ4_stream_t` structure and start a new compression. - */ -LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr); - -/*! LZ4_loadDict() : - * Use this function to load a static dictionary into LZ4_stream. - * Any previous data will be forgotten, only 'dictionary' will remain in memory. - * Loading a size of 0 is allowed. - * Return : dictionary size, in bytes (necessarily <= 64 KB) - */ -LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize); - -/*! LZ4_compress_fast_continue() : - * Compress buffer content 'src', using data from previously compressed blocks as dictionary to improve compression ratio. - * Important : Previous data blocks are assumed to still be present and unmodified ! - * 'dst' buffer must be already allocated. - * If maxDstSize >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster. - * If not, and if compressed data cannot fit into 'dst' buffer size, compression stops, and function returns a zero. - */ -LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int maxDstSize, int acceleration); - -/*! LZ4_saveDict() : - * If previously compressed data block is not guaranteed to remain available at its memory location, - * save it into a safer place (char* safeBuffer). - * Note : you don't need to call LZ4_loadDict() afterwards, - * dictionary is immediately usable, you can therefore call LZ4_compress_fast_continue(). - * Return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error. - */ -LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dictSize); - - -/*-********************************************** -* Streaming Decompression Functions -* Bufferless synchronous API -************************************************/ -typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* incomplete type (defined later) */ - -/* creation / destruction of streaming decompression tracking structure */ -LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void); -LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream); - -/*! LZ4_setStreamDecode() : - * Use this function to instruct where to find the dictionary. - * Setting a size of 0 is allowed (same effect as reset). - * @return : 1 if OK, 0 if error - */ -LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize); - -/*! -LZ4_decompress_*_continue() : - These decoding functions allow decompression of multiple blocks in "streaming" mode. - Previously decoded blocks *must* remain available at the memory position where they were decoded (up to 64 KB) - In the case of a ring buffers, decoding buffer must be either : - - Exactly same size as encoding buffer, with same update rule (block boundaries at same positions) - In which case, the decoding & encoding ring buffer can have any size, including very small ones ( < 64 KB). - - Larger than encoding buffer, by a minimum of maxBlockSize more bytes. - maxBlockSize is implementation dependent. It's the maximum size you intend to compress into a single block. - In which case, encoding and decoding buffers do not need to be synchronized, - and encoding ring buffer can have any size, including small ones ( < 64 KB). - - _At least_ 64 KB + 8 bytes + maxBlockSize. - In which case, encoding and decoding buffers do not need to be synchronized, - and encoding ring buffer can have any size, including larger than decoding buffer. - Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer, - and indicate where it is saved using LZ4_setStreamDecode() -*/ -LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize); -LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize); - - -/*! LZ4_decompress_*_usingDict() : - * These decoding functions work the same as - * a combination of LZ4_setStreamDecode() followed by LZ4_decompress_*_continue() - * They are stand-alone, and don't need an LZ4_streamDecode_t structure. - */ -LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize); -LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize); - - -/*^********************************************** - * !!!!!! STATIC LINKING ONLY !!!!!! - ***********************************************/ -/*-************************************ - * Private definitions - ************************************** - * Do not use these definitions. - * They are exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`. - * Using these definitions will expose code to API and/or ABI break in future versions of the library. - **************************************/ -#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2) -#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE) -#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */ - -#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) -#include - -typedef struct { - uint32_t hashTable[LZ4_HASH_SIZE_U32]; - uint32_t currentOffset; - uint32_t initCheck; - const uint8_t* dictionary; - uint8_t* bufferStart; /* obsolete, used for slideInputBuffer */ - uint32_t dictSize; -} LZ4_stream_t_internal; - -typedef struct { - const uint8_t* externalDict; - size_t extDictSize; - const uint8_t* prefixEnd; - size_t prefixSize; -} LZ4_streamDecode_t_internal; - -#else - -typedef struct { - unsigned int hashTable[LZ4_HASH_SIZE_U32]; - unsigned int currentOffset; - unsigned int initCheck; - const unsigned char* dictionary; - unsigned char* bufferStart; /* obsolete, used for slideInputBuffer */ - unsigned int dictSize; -} LZ4_stream_t_internal; - -typedef struct { - const unsigned char* externalDict; - size_t extDictSize; - const unsigned char* prefixEnd; - size_t prefixSize; -} LZ4_streamDecode_t_internal; - -#endif - -/*! - * LZ4_stream_t : - * information structure to track an LZ4 stream. - * init this structure before first use. - * note : only use in association with static linking ! - * this definition is not API/ABI safe, - * and may change in a future version ! - */ -#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4) -#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long)) -union LZ4_stream_u { - unsigned long long table[LZ4_STREAMSIZE_U64]; - LZ4_stream_t_internal internal_donotuse; -} ; /* previously typedef'd to LZ4_stream_t */ - - -/*! - * LZ4_streamDecode_t : - * information structure to track an LZ4 stream during decompression. - * init this structure using LZ4_setStreamDecode (or memset()) before first use - * note : only use in association with static linking ! - * this definition is not API/ABI safe, - * and may change in a future version ! - */ -#define LZ4_STREAMDECODESIZE_U64 4 -#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long)) -union LZ4_streamDecode_u { - unsigned long long table[LZ4_STREAMDECODESIZE_U64]; - LZ4_streamDecode_t_internal internal_donotuse; -} ; /* previously typedef'd to LZ4_streamDecode_t */ - - -/*=************************************ -* Obsolete Functions -**************************************/ -/* Deprecation warnings */ -/* Should these warnings be a problem, - it is generally possible to disable them, - typically with -Wno-deprecated-declarations for gcc - or _CRT_SECURE_NO_WARNINGS in Visual. - Otherwise, it's also possible to define LZ4_DISABLE_DEPRECATE_WARNINGS */ -#ifdef LZ4_DISABLE_DEPRECATE_WARNINGS -# define LZ4_DEPRECATED(message) /* disable deprecation warnings */ -#else -# define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) -# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */ -# define LZ4_DEPRECATED(message) [[deprecated(message)]] -# elif (LZ4_GCC_VERSION >= 405) || defined(__clang__) -# define LZ4_DEPRECATED(message) __attribute__((deprecated(message))) -# elif (LZ4_GCC_VERSION >= 301) -# define LZ4_DEPRECATED(message) __attribute__((deprecated)) -# elif defined(_MSC_VER) -# define LZ4_DEPRECATED(message) __declspec(deprecated(message)) -# else -# pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler") -# define LZ4_DEPRECATED(message) -# endif -#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */ - -/* Obsolete compression functions */ -LZ4_DEPRECATED("use LZ4_compress_default() instead") int LZ4_compress (const char* source, char* dest, int sourceSize); -LZ4_DEPRECATED("use LZ4_compress_default() instead") int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize); -LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize); -LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); -LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize); -LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize); - -/* Obsolete decompression functions */ -/* These function names are completely deprecated and must no longer be used. - They are only provided in lz4.c for compatibility with older programs. - - LZ4_uncompress is the same as LZ4_decompress_fast - - LZ4_uncompress_unknownOutputSize is the same as LZ4_decompress_safe - These function prototypes are now disabled; uncomment them only if you really need them. - It is highly recommended to stop using these prototypes and migrate to maintained ones */ -/* int LZ4_uncompress (const char* source, char* dest, int outputSize); */ -/* int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); */ - -/* Obsolete streaming functions; use new streaming interface whenever possible */ -LZ4_DEPRECATED("use LZ4_createStream() instead") void* LZ4_create (char* inputBuffer); -LZ4_DEPRECATED("use LZ4_createStream() instead") int LZ4_sizeofStreamState(void); -LZ4_DEPRECATED("use LZ4_resetStream() instead") int LZ4_resetStreamState(void* state, char* inputBuffer); -LZ4_DEPRECATED("use LZ4_saveDict() instead") char* LZ4_slideInputBuffer (void* state); - -/* Obsolete streaming decoding functions */ -LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize); -LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize); - - -#if defined (__cplusplus) -} -#endif - -#endif /* LZ4_H_2983827168210 */ diff --git a/contrib/liblz4/include/lz4/lz4hc.h b/contrib/liblz4/include/lz4/lz4hc.h deleted file mode 100644 index 1036fd0bf5c..00000000000 --- a/contrib/liblz4/include/lz4/lz4hc.h +++ /dev/null @@ -1,228 +0,0 @@ -/* - LZ4 HC - High Compression Mode of LZ4 - Header File - Copyright (C) 2011-2016, Yann Collet. - BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - You can contact the author at : - - LZ4 source repository : https://github.com/lz4/lz4 - - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c -*/ -#ifndef LZ4_HC_H_19834876238432 -#define LZ4_HC_H_19834876238432 - -#if defined (__cplusplus) -extern "C" { -#endif - -/* --- Dependency --- */ -/* note : lz4hc is not an independent module, it requires lz4.h/lz4.c for proper compilation */ -#include "lz4.h" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */ - - -/* --- Useful constants --- */ -#define LZ4HC_CLEVEL_MIN 3 -#define LZ4HC_CLEVEL_DEFAULT 9 -#define LZ4HC_CLEVEL_OPT_MIN 11 -#define LZ4HC_CLEVEL_MAX 12 - - -/*-************************************ - * Block Compression - **************************************/ -/*! LZ4_compress_HC() : - * Compress data from `src` into `dst`, using the more powerful but slower "HC" algorithm. - * `dst` must be already allocated. - * Compression is guaranteed to succeed if `dstCapacity >= LZ4_compressBound(srcSize)` (see "lz4.h") - * Max supported `srcSize` value is LZ4_MAX_INPUT_SIZE (see "lz4.h") - * `compressionLevel` : Recommended values are between 4 and 9, although any value between 1 and LZ4HC_MAX_CLEVEL will work. - * Values >LZ4HC_MAX_CLEVEL behave the same as LZ4HC_MAX_CLEVEL. - * @return : the number of bytes written into 'dst' - * or 0 if compression fails. - */ -LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int dstCapacity, int compressionLevel); - - -/* Note : - * Decompression functions are provided within "lz4.h" (BSD license) - */ - - -/*! LZ4_compress_HC_extStateHC() : - * Same as LZ4_compress_HC(), but using an externally allocated memory segment for `state`. - * `state` size is provided by LZ4_sizeofStateHC(). - * Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() will do properly). - */ -LZ4LIB_API int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); -LZ4LIB_API int LZ4_sizeofStateHC(void); - - -/*-************************************ - * Streaming Compression - * Bufferless synchronous API - **************************************/ - typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */ - -/*! LZ4_createStreamHC() and LZ4_freeStreamHC() : - * These functions create and release memory for LZ4 HC streaming state. - * Newly created states are automatically initialized. - * Existing states can be re-used several times, using LZ4_resetStreamHC(). - * These methods are API and ABI stable, they can be used in combination with a DLL. - */ -LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC(void); -LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr); - -LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel); -LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize); - -LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize); - -LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize); - -/* - These functions compress data in successive blocks of any size, using previous blocks as dictionary. - One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks. - There is an exception for ring buffers, which can be smaller than 64 KB. - Ring buffers scenario is automatically detected and handled by LZ4_compress_HC_continue(). - - Before starting compression, state must be properly initialized, using LZ4_resetStreamHC(). - A first "fictional block" can then be designated as initial dictionary, using LZ4_loadDictHC() (Optional). - - Then, use LZ4_compress_HC_continue() to compress each successive block. - Previous memory blocks (including initial dictionary when present) must remain accessible and unmodified during compression. - 'dst' buffer should be sized to handle worst case scenarios, using LZ4_compressBound(), to ensure operation success. - - If, for any reason, previous data blocks can't be preserved unmodified in memory during next compression block, - you must save it to a safer memory space, using LZ4_saveDictHC(). - Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer'. -*/ - - -/*-****************************************** - * !!!!! STATIC LINKING ONLY !!!!! - *******************************************/ - - /*-************************************* - * PRIVATE DEFINITIONS : - * Do not use these definitions. - * They are exposed to allow static allocation of `LZ4_streamHC_t`. - * Using these definitions makes the code vulnerable to potential API break when upgrading LZ4 - **************************************/ -#define LZ4HC_DICTIONARY_LOGSIZE 17 -#define LZ4HC_MAXD (1<= 199901L) /* C99 */) -#include - -typedef struct -{ - uint32_t hashTable[LZ4HC_HASHTABLESIZE]; - uint16_t chainTable[LZ4HC_MAXD]; - const uint8_t* end; /* next block here to continue on current prefix */ - const uint8_t* base; /* All index relative to this position */ - const uint8_t* dictBase; /* alternate base for extDict */ - uint8_t* inputBuffer; /* deprecated */ - uint32_t dictLimit; /* below that point, need extDict */ - uint32_t lowLimit; /* below that point, no more dict */ - uint32_t nextToUpdate; /* index from which to continue dictionary update */ - uint32_t searchNum; /* only for optimal parser */ - uint32_t compressionLevel; -} LZ4HC_CCtx_internal; - -#else - -typedef struct -{ - unsigned int hashTable[LZ4HC_HASHTABLESIZE]; - unsigned short chainTable[LZ4HC_MAXD]; - const unsigned char* end; /* next block here to continue on current prefix */ - const unsigned char* base; /* All index relative to this position */ - const unsigned char* dictBase; /* alternate base for extDict */ - unsigned char* inputBuffer; /* deprecated */ - unsigned int dictLimit; /* below that point, need extDict */ - unsigned int lowLimit; /* below that point, no more dict */ - unsigned int nextToUpdate; /* index from which to continue dictionary update */ - unsigned int searchNum; /* only for optimal parser */ - unsigned int compressionLevel; -} LZ4HC_CCtx_internal; - -#endif - -#define LZ4_STREAMHCSIZE (4*LZ4HC_HASHTABLESIZE + 2*LZ4HC_MAXD + 56) /* 393268 */ -#define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t)) -union LZ4_streamHC_u { - size_t table[LZ4_STREAMHCSIZE_SIZET]; - LZ4HC_CCtx_internal internal_donotuse; -}; /* previously typedef'd to LZ4_streamHC_t */ -/* - LZ4_streamHC_t : - This structure allows static allocation of LZ4 HC streaming state. - State must be initialized using LZ4_resetStreamHC() before first use. - - Static allocation shall only be used in combination with static linking. - When invoking LZ4 from a DLL, use create/free functions instead, which are API and ABI stable. -*/ - - -/*-************************************ -* Deprecated Functions -**************************************/ -/* see lz4.h LZ4_DISABLE_DEPRECATE_WARNINGS to turn off deprecation warnings */ - -/* deprecated compression functions */ -/* these functions will trigger warning messages in future releases */ -LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC (const char* source, char* dest, int inputSize); -LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize); -LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel); -LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); -LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize); -LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); -LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel); -LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); -LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize); -LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize); - -/* Deprecated Streaming functions using older model; should no longer be used */ -LZ4_DEPRECATED("use LZ4_createStreamHC() instead") void* LZ4_createHC (char* inputBuffer); -LZ4_DEPRECATED("use LZ4_saveDictHC() instead") char* LZ4_slideInputBufferHC (void* LZ4HC_Data); -LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") int LZ4_freeHC (void* LZ4HC_Data); -LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel); -LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); -LZ4_DEPRECATED("use LZ4_createStreamHC() instead") int LZ4_sizeofStreamStateHC(void); -LZ4_DEPRECATED("use LZ4_resetStreamHC() instead") int LZ4_resetStreamStateHC(void* state, char* inputBuffer); - - -#if defined (__cplusplus) -} -#endif - -#endif /* LZ4_HC_H_19834876238432 */ diff --git a/contrib/liblz4/include/lz4/lz4opt.h b/contrib/liblz4/include/lz4/lz4opt.h deleted file mode 100644 index b346eba87f1..00000000000 --- a/contrib/liblz4/include/lz4/lz4opt.h +++ /dev/null @@ -1,361 +0,0 @@ -/* - lz4opt.h - Optimal Mode of LZ4 - Copyright (C) 2015-2017, Przemyslaw Skibinski - Note : this file is intended to be included within lz4hc.c - - BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - You can contact the author at : - - LZ4 source repository : https://github.com/lz4/lz4 - - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c -*/ - -#define LZ4_OPT_NUM (1<<12) - - -typedef struct { - int off; - int len; -} LZ4HC_match_t; - -typedef struct { - int price; - int off; - int mlen; - int litlen; -} LZ4HC_optimal_t; - - -/* price in bytes */ -FORCE_INLINE size_t LZ4HC_literalsPrice(size_t litlen) -{ - size_t price = litlen; - if (litlen >= (size_t)RUN_MASK) - price += 1 + (litlen-RUN_MASK)/255; - return price; -} - - -/* requires mlen >= MINMATCH */ -FORCE_INLINE size_t LZ4HC_sequencePrice(size_t litlen, size_t mlen) -{ - size_t price = 2 + 1; /* 16-bit offset + token */ - - price += LZ4HC_literalsPrice(litlen); - - if (mlen >= (size_t)(ML_MASK+MINMATCH)) - price+= 1 + (mlen-(ML_MASK+MINMATCH))/255; - - return price; -} - - -/*-************************************* -* Binary Tree search -***************************************/ -FORCE_INLINE int LZ4HC_BinTree_InsertAndGetAllMatches ( - LZ4HC_CCtx_internal* ctx, - const BYTE* const ip, - const BYTE* const iHighLimit, - size_t best_mlen, - LZ4HC_match_t* matches, - int* matchNum) -{ - U16* const chainTable = ctx->chainTable; - U32* const HashTable = ctx->hashTable; - const BYTE* const base = ctx->base; - const U32 dictLimit = ctx->dictLimit; - const U32 current = (U32)(ip - base); - const U32 lowLimit = (ctx->lowLimit + MAX_DISTANCE > current) ? ctx->lowLimit : current - (MAX_DISTANCE - 1); - const BYTE* const dictBase = ctx->dictBase; - const BYTE* match; - int nbAttempts = ctx->searchNum; - int mnum = 0; - U16 *ptr0, *ptr1, delta0, delta1; - U32 matchIndex; - size_t matchLength = 0; - U32* HashPos; - - if (ip + MINMATCH > iHighLimit) return 1; - - /* HC4 match finder */ - HashPos = &HashTable[LZ4HC_hashPtr(ip)]; - matchIndex = *HashPos; - *HashPos = current; - - ptr0 = &DELTANEXTMAXD(current*2+1); - ptr1 = &DELTANEXTMAXD(current*2); - delta0 = delta1 = (U16)(current - matchIndex); - - while ((matchIndex < current) && (matchIndex>=lowLimit) && (nbAttempts)) { - nbAttempts--; - if (matchIndex >= dictLimit) { - match = base + matchIndex; - matchLength = LZ4_count(ip, match, iHighLimit); - } else { - const BYTE* vLimit = ip + (dictLimit - matchIndex); - match = dictBase + matchIndex; - if (vLimit > iHighLimit) vLimit = iHighLimit; - matchLength = LZ4_count(ip, match, vLimit); - if ((ip+matchLength == vLimit) && (vLimit < iHighLimit)) - matchLength += LZ4_count(ip+matchLength, base+dictLimit, iHighLimit); - } - - if (matchLength > best_mlen) { - best_mlen = matchLength; - if (matches) { - if (matchIndex >= dictLimit) - matches[mnum].off = (int)(ip - match); - else - matches[mnum].off = (int)(ip - (base + matchIndex)); /* virtual matchpos */ - matches[mnum].len = (int)matchLength; - mnum++; - } - if (best_mlen > LZ4_OPT_NUM) break; - } - - if (ip+matchLength >= iHighLimit) /* equal : no way to know if inf or sup */ - break; /* drop , to guarantee consistency ; miss a bit of compression, but other solutions can corrupt the tree */ - - if (*(ip+matchLength) < *(match+matchLength)) { - *ptr0 = delta0; - ptr0 = &DELTANEXTMAXD(matchIndex*2); - if (*ptr0 == (U16)-1) break; - delta0 = *ptr0; - delta1 += delta0; - matchIndex -= delta0; - } else { - *ptr1 = delta1; - ptr1 = &DELTANEXTMAXD(matchIndex*2+1); - if (*ptr1 == (U16)-1) break; - delta1 = *ptr1; - delta0 += delta1; - matchIndex -= delta1; - } - } - - *ptr0 = (U16)-1; - *ptr1 = (U16)-1; - if (matchNum) *matchNum = mnum; - /* if (best_mlen > 8) return best_mlen-8; */ - if (!matchNum) return 1; - return 1; -} - - -FORCE_INLINE void LZ4HC_updateBinTree(LZ4HC_CCtx_internal* ctx, const BYTE* const ip, const BYTE* const iHighLimit) -{ - const BYTE* const base = ctx->base; - const U32 target = (U32)(ip - base); - U32 idx = ctx->nextToUpdate; - while(idx < target) - idx += LZ4HC_BinTree_InsertAndGetAllMatches(ctx, base+idx, iHighLimit, 8, NULL, NULL); -} - - -/** Tree updater, providing best match */ -FORCE_INLINE int LZ4HC_BinTree_GetAllMatches ( - LZ4HC_CCtx_internal* ctx, - const BYTE* const ip, const BYTE* const iHighLimit, - size_t best_mlen, LZ4HC_match_t* matches, const int fullUpdate) -{ - int mnum = 0; - if (ip < ctx->base + ctx->nextToUpdate) return 0; /* skipped area */ - if (fullUpdate) LZ4HC_updateBinTree(ctx, ip, iHighLimit); - best_mlen = LZ4HC_BinTree_InsertAndGetAllMatches(ctx, ip, iHighLimit, best_mlen, matches, &mnum); - ctx->nextToUpdate = (U32)(ip - ctx->base + best_mlen); - return mnum; -} - - -#define SET_PRICE(pos, ml, offset, ll, cost) \ -{ \ - while (last_pos < pos) { opt[last_pos+1].price = 1<<30; last_pos++; } \ - opt[pos].mlen = (int)ml; \ - opt[pos].off = (int)offset; \ - opt[pos].litlen = (int)ll; \ - opt[pos].price = (int)cost; \ -} - - -static int LZ4HC_compress_optimal ( - LZ4HC_CCtx_internal* ctx, - const char* const source, - char* dest, - int inputSize, - int maxOutputSize, - limitedOutput_directive limit, - size_t sufficient_len, - const int fullUpdate - ) -{ - LZ4HC_optimal_t opt[LZ4_OPT_NUM + 1]; /* this uses a bit too much stack memory to my taste ... */ - LZ4HC_match_t matches[LZ4_OPT_NUM + 1]; - - const BYTE* ip = (const BYTE*) source; - const BYTE* anchor = ip; - const BYTE* const iend = ip + inputSize; - const BYTE* const mflimit = iend - MFLIMIT; - const BYTE* const matchlimit = (iend - LASTLITERALS); - BYTE* op = (BYTE*) dest; - BYTE* const oend = op + maxOutputSize; - - /* init */ - if (sufficient_len >= LZ4_OPT_NUM) sufficient_len = LZ4_OPT_NUM-1; - ctx->end += inputSize; - ip++; - - /* Main Loop */ - while (ip < mflimit) { - size_t const llen = ip - anchor; - size_t last_pos = 0; - size_t match_num, cur, best_mlen, best_off; - memset(opt, 0, sizeof(LZ4HC_optimal_t)); /* memset only the first one */ - - match_num = LZ4HC_BinTree_GetAllMatches(ctx, ip, matchlimit, MINMATCH-1, matches, fullUpdate); - if (!match_num) { ip++; continue; } - - if ((size_t)matches[match_num-1].len > sufficient_len) { - /* good enough solution : immediate encoding */ - best_mlen = matches[match_num-1].len; - best_off = matches[match_num-1].off; - cur = 0; - last_pos = 1; - goto encode; - } - - /* set prices using matches at position = 0 */ - { size_t matchNb; - for (matchNb = 0; matchNb < match_num; matchNb++) { - size_t mlen = (matchNb>0) ? (size_t)matches[matchNb-1].len+1 : MINMATCH; - best_mlen = matches[matchNb].len; /* necessarily < sufficient_len < LZ4_OPT_NUM */ - for ( ; mlen <= best_mlen ; mlen++) { - size_t const cost = LZ4HC_sequencePrice(llen, mlen) - LZ4HC_literalsPrice(llen); - SET_PRICE(mlen, mlen, matches[matchNb].off, 0, cost); /* updates last_pos and opt[pos] */ - } } } - - if (last_pos < MINMATCH) { ip++; continue; } /* note : on clang at least, this test improves performance */ - - /* check further positions */ - opt[0].mlen = opt[1].mlen = 1; - for (cur = 1; cur <= last_pos; cur++) { - const BYTE* const curPtr = ip + cur; - - /* establish baseline price if cur is literal */ - { size_t price, litlen; - if (opt[cur-1].mlen == 1) { - /* no match at previous position */ - litlen = opt[cur-1].litlen + 1; - if (cur > litlen) { - price = opt[cur - litlen].price + LZ4HC_literalsPrice(litlen); - } else { - price = LZ4HC_literalsPrice(llen + litlen) - LZ4HC_literalsPrice(llen); - } - } else { - litlen = 1; - price = opt[cur - 1].price + LZ4HC_literalsPrice(1); - } - - if (price < (size_t)opt[cur].price) - SET_PRICE(cur, 1 /*mlen*/, 0 /*off*/, litlen, price); /* note : increases last_pos */ - } - - if (cur == last_pos || curPtr >= mflimit) break; - - match_num = LZ4HC_BinTree_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1, matches, fullUpdate); - if ((match_num > 0) && (size_t)matches[match_num-1].len > sufficient_len) { - /* immediate encoding */ - best_mlen = matches[match_num-1].len; - best_off = matches[match_num-1].off; - last_pos = cur + 1; - goto encode; - } - - /* set prices using matches at position = cur */ - { size_t matchNb; - for (matchNb = 0; matchNb < match_num; matchNb++) { - size_t ml = (matchNb>0) ? (size_t)matches[matchNb-1].len+1 : MINMATCH; - best_mlen = (cur + matches[matchNb].len < LZ4_OPT_NUM) ? - (size_t)matches[matchNb].len : LZ4_OPT_NUM - cur; - - for ( ; ml <= best_mlen ; ml++) { - size_t ll, price; - if (opt[cur].mlen == 1) { - ll = opt[cur].litlen; - if (cur > ll) - price = opt[cur - ll].price + LZ4HC_sequencePrice(ll, ml); - else - price = LZ4HC_sequencePrice(llen + ll, ml) - LZ4HC_literalsPrice(llen); - } else { - ll = 0; - price = opt[cur].price + LZ4HC_sequencePrice(0, ml); - } - - if (cur + ml > last_pos || price < (size_t)opt[cur + ml].price) { - SET_PRICE(cur + ml, ml, matches[matchNb].off, ll, price); - } } } } - } /* for (cur = 1; cur <= last_pos; cur++) */ - - best_mlen = opt[last_pos].mlen; - best_off = opt[last_pos].off; - cur = last_pos - best_mlen; - -encode: /* cur, last_pos, best_mlen, best_off must be set */ - opt[0].mlen = 1; - while (1) { /* from end to beginning */ - size_t const ml = opt[cur].mlen; - int const offset = opt[cur].off; - opt[cur].mlen = (int)best_mlen; - opt[cur].off = (int)best_off; - best_mlen = ml; - best_off = offset; - if (ml > cur) break; /* can this happen ? */ - cur -= ml; - } - - /* encode all recorded sequences */ - cur = 0; - while (cur < last_pos) { - int const ml = opt[cur].mlen; - int const offset = opt[cur].off; - if (ml == 1) { ip++; cur++; continue; } - cur += ml; - if ( LZ4HC_encodeSequence(&ip, &op, &anchor, ml, ip - offset, limit, oend) ) return 0; - } - } /* while (ip < mflimit) */ - - /* Encode Last Literals */ - { int lastRun = (int)(iend - anchor); - if ((limit) && (((char*)op - dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize)) return 0; /* Check output limit */ - if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK< 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; } - else *op++ = (BYTE)(lastRun< 1 > 2) - */ -#ifndef LZ4_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */ -# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) ) -# define LZ4_FORCE_MEMORY_ACCESS 2 -# elif defined(__INTEL_COMPILER) || \ - (defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) )) -# define LZ4_FORCE_MEMORY_ACCESS 1 -# endif -#endif - -/* - * LZ4_FORCE_SW_BITCOUNT - * Define this parameter if your target system or compiler does not support hardware bit count - */ -#if defined(_MSC_VER) && defined(_WIN32_WCE) /* Visual Studio for Windows CE does not support Hardware bit count */ -# define LZ4_FORCE_SW_BITCOUNT -#endif - - -/*-************************************ -* Dependency -**************************************/ -#include "lz4.h" -/* see also "memory routines" below */ - - -/*-************************************ -* Compiler Options -**************************************/ -#ifdef _MSC_VER /* Visual Studio */ -# define FORCE_INLINE static __forceinline -# include -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -# pragma warning(disable : 4293) /* disable: C4293: too large shift (32-bits) */ -#else -# if defined(__GNUC__) || defined(__clang__) -# define FORCE_INLINE static inline __attribute__((always_inline)) -# elif defined(__cplusplus) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) -# define FORCE_INLINE static inline -# else -# define FORCE_INLINE static -# endif -#endif /* _MSC_VER */ - -#if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) || defined(__clang__) -# define expect(expr,value) (__builtin_expect ((expr),(value)) ) -#else -# define expect(expr,value) (expr) -#endif - -#define likely(expr) expect((expr) != 0, 1) -#define unlikely(expr) expect((expr) != 0, 0) - - -/*-************************************ -* Memory routines -**************************************/ -#include /* malloc, calloc, free */ -#define ALLOCATOR(n,s) calloc(n,s) -#define FREEMEM free -#include /* memset, memcpy */ -#define MEM_INIT memset - - -/*-************************************ -* Basic Types -**************************************/ -#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) -# include - typedef uint8_t BYTE; - typedef uint16_t U16; - typedef uint32_t U32; - typedef int32_t S32; - typedef uint64_t U64; - typedef uintptr_t uptrval; -#else - typedef unsigned char BYTE; - typedef unsigned short U16; - typedef unsigned int U32; - typedef signed int S32; - typedef unsigned long long U64; - typedef size_t uptrval; /* generally true, except OpenVMS-64 */ -#endif - -#if defined(__x86_64__) - typedef U64 reg_t; /* 64-bits in x32 mode */ -#else - typedef size_t reg_t; /* 32-bits in x32 mode */ -#endif - -/*-************************************ -* Reading and writing into memory -**************************************/ -static unsigned LZ4_isLittleEndian(void) -{ - const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */ - return one.c[0]; -} - - -#if defined(LZ4_FORCE_MEMORY_ACCESS) && (LZ4_FORCE_MEMORY_ACCESS==2) -/* lie to the compiler about data alignment; use with caution */ - -static U16 LZ4_read16(const void* memPtr) { return *(const U16*) memPtr; } -static U32 LZ4_read32(const void* memPtr) { return *(const U32*) memPtr; } -static reg_t LZ4_read_ARCH(const void* memPtr) { return *(const reg_t*) memPtr; } - -static void LZ4_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; } -static void LZ4_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; } - -#elif defined(LZ4_FORCE_MEMORY_ACCESS) && (LZ4_FORCE_MEMORY_ACCESS==1) - -/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */ -/* currently only defined for gcc and icc */ -typedef union { U16 u16; U32 u32; reg_t uArch; } __attribute__((packed)) unalign; - -static U16 LZ4_read16(const void* ptr) { return ((const unalign*)ptr)->u16; } -static U32 LZ4_read32(const void* ptr) { return ((const unalign*)ptr)->u32; } -static reg_t LZ4_read_ARCH(const void* ptr) { return ((const unalign*)ptr)->uArch; } - -static void LZ4_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; } -static void LZ4_write32(void* memPtr, U32 value) { ((unalign*)memPtr)->u32 = value; } - -#else /* safe and portable access through memcpy() */ - -static U16 LZ4_read16(const void* memPtr) -{ - U16 val; memcpy(&val, memPtr, sizeof(val)); return val; -} - -static U32 LZ4_read32(const void* memPtr) -{ - U32 val; memcpy(&val, memPtr, sizeof(val)); return val; -} - -static reg_t LZ4_read_ARCH(const void* memPtr) -{ - reg_t val; memcpy(&val, memPtr, sizeof(val)); return val; -} - -static void LZ4_write16(void* memPtr, U16 value) -{ - memcpy(memPtr, &value, sizeof(value)); -} - -static void LZ4_write32(void* memPtr, U32 value) -{ - memcpy(memPtr, &value, sizeof(value)); -} - -#endif /* LZ4_FORCE_MEMORY_ACCESS */ - - -static U16 LZ4_readLE16(const void* memPtr) -{ - if (LZ4_isLittleEndian()) { - return LZ4_read16(memPtr); - } else { - const BYTE* p = (const BYTE*)memPtr; - return (U16)((U16)p[0] + (p[1]<<8)); - } -} - -static void LZ4_writeLE16(void* memPtr, U16 value) -{ - if (LZ4_isLittleEndian()) { - LZ4_write16(memPtr, value); - } else { - BYTE* p = (BYTE*)memPtr; - p[0] = (BYTE) value; - p[1] = (BYTE)(value>>8); - } -} - -static void LZ4_copy8(void* dst, const void* src) -{ - memcpy(dst,src,8); -} - -/* customized variant of memcpy, which can overwrite up to 8 bytes beyond dstEnd */ -static void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd) -{ - BYTE* d = (BYTE*)dstPtr; - const BYTE* s = (const BYTE*)srcPtr; - BYTE* const e = (BYTE*)dstEnd; - - do { LZ4_copy8(d,s); d+=8; s+=8; } while (d>3); -# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT) - return (__builtin_ctzll((U64)val) >> 3); -# else - static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 }; - return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58]; -# endif - } else /* 32 bits */ { -# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT) - unsigned long r; - _BitScanForward( &r, (U32)val ); - return (int)(r>>3); -# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT) - return (__builtin_ctz((U32)val) >> 3); -# else - static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 }; - return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27]; -# endif - } - } else /* Big Endian CPU */ { - if (sizeof(val)==8) { -# if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT) - unsigned long r = 0; - _BitScanReverse64( &r, val ); - return (unsigned)(r>>3); -# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT) - return (__builtin_clzll((U64)val) >> 3); -# else - unsigned r; - if (!(val>>32)) { r=4; } else { r=0; val>>=32; } - if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; } - r += (!val); - return r; -# endif - } else /* 32 bits */ { -# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT) - unsigned long r = 0; - _BitScanReverse( &r, (unsigned long)val ); - return (unsigned)(r>>3); -# elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT) - return (__builtin_clz((U32)val) >> 3); -# else - unsigned r; - if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; } - r += (!val); - return r; -# endif - } - } -} - -#define STEPSIZE sizeof(reg_t) -static unsigned LZ4_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLimit) -{ - const BYTE* const pStart = pIn; - - while (likely(pIn compression run slower on incompressible data */ - - -/*-************************************ -* Local Structures and types -**************************************/ -typedef enum { notLimited = 0, limitedOutput = 1 } limitedOutput_directive; -typedef enum { byPtr, byU32, byU16 } tableType_t; - -typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive; -typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive; - -typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive; -typedef enum { full = 0, partial = 1 } earlyEnd_directive; - - -/*-************************************ -* Local Utils -**************************************/ -int LZ4_versionNumber (void) { return LZ4_VERSION_NUMBER; } -const char* LZ4_versionString(void) { return LZ4_VERSION_STRING; } -int LZ4_compressBound(int isize) { return LZ4_COMPRESSBOUND(isize); } -int LZ4_sizeofState() { return LZ4_STREAMSIZE; } - - -/*-****************************** -* Compression functions -********************************/ -static U32 LZ4_hash4(U32 sequence, tableType_t const tableType) -{ - if (tableType == byU16) - return ((sequence * 2654435761U) >> ((MINMATCH*8)-(LZ4_HASHLOG+1))); - else - return ((sequence * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG)); -} - -static U32 LZ4_hash5(U64 sequence, tableType_t const tableType) -{ - static const U64 prime5bytes = 889523592379ULL; - static const U64 prime8bytes = 11400714785074694791ULL; - const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG; - if (LZ4_isLittleEndian()) - return (U32)(((sequence << 24) * prime5bytes) >> (64 - hashLog)); - else - return (U32)(((sequence >> 24) * prime8bytes) >> (64 - hashLog)); -} - -FORCE_INLINE U32 LZ4_hashPosition(const void* const p, tableType_t const tableType) -{ - if ((sizeof(reg_t)==8) && (tableType != byU16)) return LZ4_hash5(LZ4_read_ARCH(p), tableType); - return LZ4_hash4(LZ4_read32(p), tableType); -} - -static void LZ4_putPositionOnHash(const BYTE* p, U32 h, void* tableBase, tableType_t const tableType, const BYTE* srcBase) -{ - switch (tableType) - { - case byPtr: { const BYTE** hashTable = (const BYTE**)tableBase; hashTable[h] = p; return; } - case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = (U32)(p-srcBase); return; } - case byU16: { U16* hashTable = (U16*) tableBase; hashTable[h] = (U16)(p-srcBase); return; } - } -} - -FORCE_INLINE void LZ4_putPosition(const BYTE* p, void* tableBase, tableType_t tableType, const BYTE* srcBase) -{ - U32 const h = LZ4_hashPosition(p, tableType); - LZ4_putPositionOnHash(p, h, tableBase, tableType, srcBase); -} - -static const BYTE* LZ4_getPositionOnHash(U32 h, void* tableBase, tableType_t tableType, const BYTE* srcBase) -{ - if (tableType == byPtr) { const BYTE** hashTable = (const BYTE**) tableBase; return hashTable[h]; } - if (tableType == byU32) { const U32* const hashTable = (U32*) tableBase; return hashTable[h] + srcBase; } - { const U16* const hashTable = (U16*) tableBase; return hashTable[h] + srcBase; } /* default, to ensure a return */ -} - -FORCE_INLINE const BYTE* LZ4_getPosition(const BYTE* p, void* tableBase, tableType_t tableType, const BYTE* srcBase) -{ - U32 const h = LZ4_hashPosition(p, tableType); - return LZ4_getPositionOnHash(h, tableBase, tableType, srcBase); -} - - -/** LZ4_compress_generic() : - inlined, to ensure branches are decided at compilation time */ -FORCE_INLINE int LZ4_compress_generic( - LZ4_stream_t_internal* const cctx, - const char* const source, - char* const dest, - const int inputSize, - const int maxOutputSize, - const limitedOutput_directive outputLimited, - const tableType_t tableType, - const dict_directive dict, - const dictIssue_directive dictIssue, - const U32 acceleration) -{ - const BYTE* ip = (const BYTE*) source; - const BYTE* base; - const BYTE* lowLimit; - const BYTE* const lowRefLimit = ip - cctx->dictSize; - const BYTE* const dictionary = cctx->dictionary; - const BYTE* const dictEnd = dictionary + cctx->dictSize; - const ptrdiff_t dictDelta = dictEnd - (const BYTE*)source; - const BYTE* anchor = (const BYTE*) source; - const BYTE* const iend = ip + inputSize; - const BYTE* const mflimit = iend - MFLIMIT; - const BYTE* const matchlimit = iend - LASTLITERALS; - - BYTE* op = (BYTE*) dest; - BYTE* const olimit = op + maxOutputSize; - - U32 forwardH; - - /* Init conditions */ - if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported inputSize, too large (or negative) */ - switch(dict) - { - case noDict: - default: - base = (const BYTE*)source; - lowLimit = (const BYTE*)source; - break; - case withPrefix64k: - base = (const BYTE*)source - cctx->currentOffset; - lowLimit = (const BYTE*)source - cctx->dictSize; - break; - case usingExtDict: - base = (const BYTE*)source - cctx->currentOffset; - lowLimit = (const BYTE*)source; - break; - } - if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */ - if (inputSizehashTable, tableType, base); - ip++; forwardH = LZ4_hashPosition(ip, tableType); - - /* Main Loop */ - for ( ; ; ) { - ptrdiff_t refDelta = 0; - const BYTE* match; - BYTE* token; - - /* Find a match */ - { const BYTE* forwardIp = ip; - unsigned step = 1; - unsigned searchMatchNb = acceleration << LZ4_skipTrigger; - do { - U32 const h = forwardH; - ip = forwardIp; - forwardIp += step; - step = (searchMatchNb++ >> LZ4_skipTrigger); - - if (unlikely(forwardIp > mflimit)) goto _last_literals; - - match = LZ4_getPositionOnHash(h, cctx->hashTable, tableType, base); - if (dict==usingExtDict) { - if (match < (const BYTE*)source) { - refDelta = dictDelta; - lowLimit = dictionary; - } else { - refDelta = 0; - lowLimit = (const BYTE*)source; - } } - forwardH = LZ4_hashPosition(forwardIp, tableType); - LZ4_putPositionOnHash(ip, h, cctx->hashTable, tableType, base); - - } while ( ((dictIssue==dictSmall) ? (match < lowRefLimit) : 0) - || ((tableType==byU16) ? 0 : (match + MAX_DISTANCE < ip)) - || (LZ4_read32(match+refDelta) != LZ4_read32(ip)) ); - } - - /* Catch up */ - while (((ip>anchor) & (match+refDelta > lowLimit)) && (unlikely(ip[-1]==match[refDelta-1]))) { ip--; match--; } - - /* Encode Literals */ - { unsigned const litLength = (unsigned)(ip - anchor); - token = op++; - if ((outputLimited) && /* Check output buffer overflow */ - (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit))) - return 0; - if (litLength >= RUN_MASK) { - int len = (int)litLength-RUN_MASK; - *token = (RUN_MASK<= 255 ; len-=255) *op++ = 255; - *op++ = (BYTE)len; - } - else *token = (BYTE)(litLength< matchlimit) limit = matchlimit; - matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, limit); - ip += MINMATCH + matchCode; - if (ip==limit) { - unsigned const more = LZ4_count(ip, (const BYTE*)source, matchlimit); - matchCode += more; - ip += more; - } - } else { - matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, matchlimit); - ip += MINMATCH + matchCode; - } - - if ( outputLimited && /* Check output buffer overflow */ - (unlikely(op + (1 + LASTLITERALS) + (matchCode>>8) > olimit)) ) - return 0; - if (matchCode >= ML_MASK) { - *token += ML_MASK; - matchCode -= ML_MASK; - LZ4_write32(op, 0xFFFFFFFF); - while (matchCode >= 4*255) op+=4, LZ4_write32(op, 0xFFFFFFFF), matchCode -= 4*255; - op += matchCode / 255; - *op++ = (BYTE)(matchCode % 255); - } else - *token += (BYTE)(matchCode); - } - - anchor = ip; - - /* Test end of chunk */ - if (ip > mflimit) break; - - /* Fill table */ - LZ4_putPosition(ip-2, cctx->hashTable, tableType, base); - - /* Test next position */ - match = LZ4_getPosition(ip, cctx->hashTable, tableType, base); - if (dict==usingExtDict) { - if (match < (const BYTE*)source) { - refDelta = dictDelta; - lowLimit = dictionary; - } else { - refDelta = 0; - lowLimit = (const BYTE*)source; - } } - LZ4_putPosition(ip, cctx->hashTable, tableType, base); - if ( ((dictIssue==dictSmall) ? (match>=lowRefLimit) : 1) - && (match+MAX_DISTANCE>=ip) - && (LZ4_read32(match+refDelta)==LZ4_read32(ip)) ) - { token=op++; *token=0; goto _next_match; } - - /* Prepare next loop */ - forwardH = LZ4_hashPosition(++ip, tableType); - } - -_last_literals: - /* Encode Last Literals */ - { size_t const lastRun = (size_t)(iend - anchor); - if ( (outputLimited) && /* Check output buffer overflow */ - ((op - (BYTE*)dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize) ) - return 0; - if (lastRun >= RUN_MASK) { - size_t accumulator = lastRun - RUN_MASK; - *op++ = RUN_MASK << ML_BITS; - for(; accumulator >= 255 ; accumulator-=255) *op++ = 255; - *op++ = (BYTE) accumulator; - } else { - *op++ = (BYTE)(lastRun<internal_donotuse; - LZ4_resetStream((LZ4_stream_t*)state); - if (acceleration < 1) acceleration = ACCELERATION_DEFAULT; - - if (maxOutputSize >= LZ4_compressBound(inputSize)) { - if (inputSize < LZ4_64Klimit) - return LZ4_compress_generic(ctx, source, dest, inputSize, 0, notLimited, byU16, noDict, noDictIssue, acceleration); - else - return LZ4_compress_generic(ctx, source, dest, inputSize, 0, notLimited, (sizeof(void*)==8) ? byU32 : byPtr, noDict, noDictIssue, acceleration); - } else { - if (inputSize < LZ4_64Klimit) - return LZ4_compress_generic(ctx, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue, acceleration); - else - return LZ4_compress_generic(ctx, source, dest, inputSize, maxOutputSize, limitedOutput, (sizeof(void*)==8) ? byU32 : byPtr, noDict, noDictIssue, acceleration); - } -} - - -int LZ4_compress_fast(const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration) -{ -#if (HEAPMODE) - void* ctxPtr = ALLOCATOR(1, sizeof(LZ4_stream_t)); /* malloc-calloc always properly aligned */ -#else - LZ4_stream_t ctx; - void* const ctxPtr = &ctx; -#endif - - int const result = LZ4_compress_fast_extState(ctxPtr, source, dest, inputSize, maxOutputSize, acceleration); - -#if (HEAPMODE) - FREEMEM(ctxPtr); -#endif - return result; -} - - -int LZ4_compress_default(const char* source, char* dest, int inputSize, int maxOutputSize) -{ - return LZ4_compress_fast(source, dest, inputSize, maxOutputSize, 1); -} - - -/* hidden debug function */ -/* strangely enough, gcc generates faster code when this function is uncommented, even if unused */ -int LZ4_compress_fast_force(const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration) -{ - LZ4_stream_t ctx; - LZ4_resetStream(&ctx); - - if (inputSize < LZ4_64Klimit) - return LZ4_compress_generic(&ctx.internal_donotuse, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue, acceleration); - else - return LZ4_compress_generic(&ctx.internal_donotuse, source, dest, inputSize, maxOutputSize, limitedOutput, sizeof(void*)==8 ? byU32 : byPtr, noDict, noDictIssue, acceleration); -} - - -/*-****************************** -* *_destSize() variant -********************************/ - -static int LZ4_compress_destSize_generic( - LZ4_stream_t_internal* const ctx, - const char* const src, - char* const dst, - int* const srcSizePtr, - const int targetDstSize, - const tableType_t tableType) -{ - const BYTE* ip = (const BYTE*) src; - const BYTE* base = (const BYTE*) src; - const BYTE* lowLimit = (const BYTE*) src; - const BYTE* anchor = ip; - const BYTE* const iend = ip + *srcSizePtr; - const BYTE* const mflimit = iend - MFLIMIT; - const BYTE* const matchlimit = iend - LASTLITERALS; - - BYTE* op = (BYTE*) dst; - BYTE* const oend = op + targetDstSize; - BYTE* const oMaxLit = op + targetDstSize - 2 /* offset */ - 8 /* because 8+MINMATCH==MFLIMIT */ - 1 /* token */; - BYTE* const oMaxMatch = op + targetDstSize - (LASTLITERALS + 1 /* token */); - BYTE* const oMaxSeq = oMaxLit - 1 /* token */; - - U32 forwardH; - - - /* Init conditions */ - if (targetDstSize < 1) return 0; /* Impossible to store anything */ - if ((U32)*srcSizePtr > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported input size, too large (or negative) */ - if ((tableType == byU16) && (*srcSizePtr>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */ - if (*srcSizePtrhashTable, tableType, base); - ip++; forwardH = LZ4_hashPosition(ip, tableType); - - /* Main Loop */ - for ( ; ; ) { - const BYTE* match; - BYTE* token; - - /* Find a match */ - { const BYTE* forwardIp = ip; - unsigned step = 1; - unsigned searchMatchNb = 1 << LZ4_skipTrigger; - - do { - U32 h = forwardH; - ip = forwardIp; - forwardIp += step; - step = (searchMatchNb++ >> LZ4_skipTrigger); - - if (unlikely(forwardIp > mflimit)) goto _last_literals; - - match = LZ4_getPositionOnHash(h, ctx->hashTable, tableType, base); - forwardH = LZ4_hashPosition(forwardIp, tableType); - LZ4_putPositionOnHash(ip, h, ctx->hashTable, tableType, base); - - } while ( ((tableType==byU16) ? 0 : (match + MAX_DISTANCE < ip)) - || (LZ4_read32(match) != LZ4_read32(ip)) ); - } - - /* Catch up */ - while ((ip>anchor) && (match > lowLimit) && (unlikely(ip[-1]==match[-1]))) { ip--; match--; } - - /* Encode Literal length */ - { unsigned litLength = (unsigned)(ip - anchor); - token = op++; - if (op + ((litLength+240)/255) + litLength > oMaxLit) { - /* Not enough space for a last match */ - op--; - goto _last_literals; - } - if (litLength>=RUN_MASK) { - unsigned len = litLength - RUN_MASK; - *token=(RUN_MASK<= 255 ; len-=255) *op++ = 255; - *op++ = (BYTE)len; - } - else *token = (BYTE)(litLength< oMaxMatch) { - /* Match description too long : reduce it */ - matchLength = (15-1) + (oMaxMatch-op) * 255; - } - ip += MINMATCH + matchLength; - - if (matchLength>=ML_MASK) { - *token += ML_MASK; - matchLength -= ML_MASK; - while (matchLength >= 255) { matchLength-=255; *op++ = 255; } - *op++ = (BYTE)matchLength; - } - else *token += (BYTE)(matchLength); - } - - anchor = ip; - - /* Test end of block */ - if (ip > mflimit) break; - if (op > oMaxSeq) break; - - /* Fill table */ - LZ4_putPosition(ip-2, ctx->hashTable, tableType, base); - - /* Test next position */ - match = LZ4_getPosition(ip, ctx->hashTable, tableType, base); - LZ4_putPosition(ip, ctx->hashTable, tableType, base); - if ( (match+MAX_DISTANCE>=ip) - && (LZ4_read32(match)==LZ4_read32(ip)) ) - { token=op++; *token=0; goto _next_match; } - - /* Prepare next loop */ - forwardH = LZ4_hashPosition(++ip, tableType); - } - -_last_literals: - /* Encode Last Literals */ - { size_t lastRunSize = (size_t)(iend - anchor); - if (op + 1 /* token */ + ((lastRunSize+240)/255) /* litLength */ + lastRunSize /* literals */ > oend) { - /* adapt lastRunSize to fill 'dst' */ - lastRunSize = (oend-op) - 1; - lastRunSize -= (lastRunSize+240)/255; - } - ip = anchor + lastRunSize; - - if (lastRunSize >= RUN_MASK) { - size_t accumulator = lastRunSize - RUN_MASK; - *op++ = RUN_MASK << ML_BITS; - for(; accumulator >= 255 ; accumulator-=255) *op++ = 255; - *op++ = (BYTE) accumulator; - } else { - *op++ = (BYTE)(lastRunSize<= LZ4_compressBound(*srcSizePtr)) { /* compression success is guaranteed */ - return LZ4_compress_fast_extState(state, src, dst, *srcSizePtr, targetDstSize, 1); - } else { - if (*srcSizePtr < LZ4_64Klimit) - return LZ4_compress_destSize_generic(&state->internal_donotuse, src, dst, srcSizePtr, targetDstSize, byU16); - else - return LZ4_compress_destSize_generic(&state->internal_donotuse, src, dst, srcSizePtr, targetDstSize, sizeof(void*)==8 ? byU32 : byPtr); - } -} - - -int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targetDstSize) -{ -#if (HEAPMODE) - LZ4_stream_t* ctx = (LZ4_stream_t*)ALLOCATOR(1, sizeof(LZ4_stream_t)); /* malloc-calloc always properly aligned */ -#else - LZ4_stream_t ctxBody; - LZ4_stream_t* ctx = &ctxBody; -#endif - - int result = LZ4_compress_destSize_extState(ctx, src, dst, srcSizePtr, targetDstSize); - -#if (HEAPMODE) - FREEMEM(ctx); -#endif - return result; -} - - - -/*-****************************** -* Streaming functions -********************************/ - -LZ4_stream_t* LZ4_createStream(void) -{ - LZ4_stream_t* lz4s = (LZ4_stream_t*)ALLOCATOR(8, LZ4_STREAMSIZE_U64); - LZ4_STATIC_ASSERT(LZ4_STREAMSIZE >= sizeof(LZ4_stream_t_internal)); /* A compilation error here means LZ4_STREAMSIZE is not large enough */ - LZ4_resetStream(lz4s); - return lz4s; -} - -void LZ4_resetStream (LZ4_stream_t* LZ4_stream) -{ - MEM_INIT(LZ4_stream, 0, sizeof(LZ4_stream_t)); -} - -int LZ4_freeStream (LZ4_stream_t* LZ4_stream) -{ - FREEMEM(LZ4_stream); - return (0); -} - - -#define HASH_UNIT sizeof(reg_t) -int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize) -{ - LZ4_stream_t_internal* dict = &LZ4_dict->internal_donotuse; - const BYTE* p = (const BYTE*)dictionary; - const BYTE* const dictEnd = p + dictSize; - const BYTE* base; - - if ((dict->initCheck) || (dict->currentOffset > 1 GB)) /* Uninitialized structure, or reuse overflow */ - LZ4_resetStream(LZ4_dict); - - if (dictSize < (int)HASH_UNIT) { - dict->dictionary = NULL; - dict->dictSize = 0; - return 0; - } - - if ((dictEnd - p) > 64 KB) p = dictEnd - 64 KB; - dict->currentOffset += 64 KB; - base = p - dict->currentOffset; - dict->dictionary = p; - dict->dictSize = (U32)(dictEnd - p); - dict->currentOffset += dict->dictSize; - - while (p <= dictEnd-HASH_UNIT) { - LZ4_putPosition(p, dict->hashTable, byU32, base); - p+=3; - } - - return dict->dictSize; -} - - -static void LZ4_renormDictT(LZ4_stream_t_internal* LZ4_dict, const BYTE* src) -{ - if ((LZ4_dict->currentOffset > 0x80000000) || - ((uptrval)LZ4_dict->currentOffset > (uptrval)src)) { /* address space overflow */ - /* rescale hash table */ - U32 const delta = LZ4_dict->currentOffset - 64 KB; - const BYTE* dictEnd = LZ4_dict->dictionary + LZ4_dict->dictSize; - int i; - for (i=0; ihashTable[i] < delta) LZ4_dict->hashTable[i]=0; - else LZ4_dict->hashTable[i] -= delta; - } - LZ4_dict->currentOffset = 64 KB; - if (LZ4_dict->dictSize > 64 KB) LZ4_dict->dictSize = 64 KB; - LZ4_dict->dictionary = dictEnd - LZ4_dict->dictSize; - } -} - - -int LZ4_compress_fast_continue (LZ4_stream_t* LZ4_stream, const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration) -{ - LZ4_stream_t_internal* streamPtr = &LZ4_stream->internal_donotuse; - const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize; - - const BYTE* smallest = (const BYTE*) source; - if (streamPtr->initCheck) return 0; /* Uninitialized structure detected */ - if ((streamPtr->dictSize>0) && (smallest>dictEnd)) smallest = dictEnd; - LZ4_renormDictT(streamPtr, smallest); - if (acceleration < 1) acceleration = ACCELERATION_DEFAULT; - - /* Check overlapping input/dictionary space */ - { const BYTE* sourceEnd = (const BYTE*) source + inputSize; - if ((sourceEnd > streamPtr->dictionary) && (sourceEnd < dictEnd)) { - streamPtr->dictSize = (U32)(dictEnd - sourceEnd); - if (streamPtr->dictSize > 64 KB) streamPtr->dictSize = 64 KB; - if (streamPtr->dictSize < 4) streamPtr->dictSize = 0; - streamPtr->dictionary = dictEnd - streamPtr->dictSize; - } - } - - /* prefix mode : source data follows dictionary */ - if (dictEnd == (const BYTE*)source) { - int result; - if ((streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset)) - result = LZ4_compress_generic(streamPtr, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, withPrefix64k, dictSmall, acceleration); - else - result = LZ4_compress_generic(streamPtr, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, withPrefix64k, noDictIssue, acceleration); - streamPtr->dictSize += (U32)inputSize; - streamPtr->currentOffset += (U32)inputSize; - return result; - } - - /* external dictionary mode */ - { int result; - if ((streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset)) - result = LZ4_compress_generic(streamPtr, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, usingExtDict, dictSmall, acceleration); - else - result = LZ4_compress_generic(streamPtr, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, usingExtDict, noDictIssue, acceleration); - streamPtr->dictionary = (const BYTE*)source; - streamPtr->dictSize = (U32)inputSize; - streamPtr->currentOffset += (U32)inputSize; - return result; - } -} - - -/* Hidden debug function, to force external dictionary mode */ -int LZ4_compress_forceExtDict (LZ4_stream_t* LZ4_dict, const char* source, char* dest, int inputSize) -{ - LZ4_stream_t_internal* streamPtr = &LZ4_dict->internal_donotuse; - int result; - const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize; - - const BYTE* smallest = dictEnd; - if (smallest > (const BYTE*) source) smallest = (const BYTE*) source; - LZ4_renormDictT(streamPtr, smallest); - - result = LZ4_compress_generic(streamPtr, source, dest, inputSize, 0, notLimited, byU32, usingExtDict, noDictIssue, 1); - - streamPtr->dictionary = (const BYTE*)source; - streamPtr->dictSize = (U32)inputSize; - streamPtr->currentOffset += (U32)inputSize; - - return result; -} - - -/*! LZ4_saveDict() : - * If previously compressed data block is not guaranteed to remain available at its memory location, - * save it into a safer place (char* safeBuffer). - * Note : you don't need to call LZ4_loadDict() afterwards, - * dictionary is immediately usable, you can therefore call LZ4_compress_fast_continue(). - * Return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error. - */ -int LZ4_saveDict (LZ4_stream_t* LZ4_dict, char* safeBuffer, int dictSize) -{ - LZ4_stream_t_internal* const dict = &LZ4_dict->internal_donotuse; - const BYTE* const previousDictEnd = dict->dictionary + dict->dictSize; - - if ((U32)dictSize > 64 KB) dictSize = 64 KB; /* useless to define a dictionary > 64 KB */ - if ((U32)dictSize > dict->dictSize) dictSize = dict->dictSize; - - memmove(safeBuffer, previousDictEnd - dictSize, dictSize); - - dict->dictionary = (const BYTE*)safeBuffer; - dict->dictSize = (U32)dictSize; - - return dictSize; -} - - - -/*-***************************** -* Decompression functions -*******************************/ -/*! LZ4_decompress_generic() : - * This generic decompression function cover all use cases. - * It shall be instantiated several times, using different sets of directives - * Note that it is important this generic function is really inlined, - * in order to remove useless branches during compilation optimization. - */ -FORCE_INLINE int LZ4_decompress_generic( - const char* const source, - char* const dest, - int inputSize, - int outputSize, /* If endOnInput==endOnInputSize, this value is the max size of Output Buffer. */ - - int endOnInput, /* endOnOutputSize, endOnInputSize */ - int partialDecoding, /* full, partial */ - int targetOutputSize, /* only used if partialDecoding==partial */ - int dict, /* noDict, withPrefix64k, usingExtDict */ - const BYTE* const lowPrefix, /* == dest when no prefix */ - const BYTE* const dictStart, /* only if dict==usingExtDict */ - const size_t dictSize /* note : = 0 if noDict */ - ) -{ - /* Local Variables */ - const BYTE* ip = (const BYTE*) source; - const BYTE* const iend = ip + inputSize; - - BYTE* op = (BYTE*) dest; - BYTE* const oend = op + outputSize; - BYTE* cpy; - BYTE* oexit = op + targetOutputSize; - const BYTE* const lowLimit = lowPrefix - dictSize; - - const BYTE* const dictEnd = (const BYTE*)dictStart + dictSize; - const unsigned dec32table[] = {0, 1, 2, 1, 4, 4, 4, 4}; - const int dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3}; - - const int safeDecode = (endOnInput==endOnInputSize); - const int checkOffset = ((safeDecode) && (dictSize < (int)(64 KB))); - - - /* Special cases */ - if ((partialDecoding) && (oexit > oend-MFLIMIT)) oexit = oend-MFLIMIT; /* targetOutputSize too high => decode everything */ - if ((endOnInput) && (unlikely(outputSize==0))) return ((inputSize==1) && (*ip==0)) ? 0 : -1; /* Empty output buffer */ - if ((!endOnInput) && (unlikely(outputSize==0))) return (*ip==0?1:-1); - - /* Main Loop : decode sequences */ - while (1) { - size_t length; - const BYTE* match; - size_t offset; - - /* get literal length */ - unsigned const token = *ip++; - if ((length=(token>>ML_BITS)) == RUN_MASK) { - unsigned s; - do { - s = *ip++; - length += s; - } while ( likely(endOnInput ? ip(partialDecoding?oexit:oend-MFLIMIT)) || (ip+length>iend-(2+1+LASTLITERALS))) ) - || ((!endOnInput) && (cpy>oend-WILDCOPYLENGTH)) ) - { - if (partialDecoding) { - if (cpy > oend) goto _output_error; /* Error : write attempt beyond end of output buffer */ - if ((endOnInput) && (ip+length > iend)) goto _output_error; /* Error : read attempt beyond end of input buffer */ - } else { - if ((!endOnInput) && (cpy != oend)) goto _output_error; /* Error : block decoding must stop exactly there */ - if ((endOnInput) && ((ip+length != iend) || (cpy > oend))) goto _output_error; /* Error : input must be consumed */ - } - memcpy(op, ip, length); - ip += length; - op += length; - break; /* Necessarily EOF, due to parsing restrictions */ - } - LZ4_wildCopy(op, ip, cpy); - ip += length; op = cpy; - - /* get offset */ - offset = LZ4_readLE16(ip); ip+=2; - match = op - offset; - if ((checkOffset) && (unlikely(match < lowLimit))) goto _output_error; /* Error : offset outside buffers */ - LZ4_write32(op, (U32)offset); /* costs ~1%; silence an msan warning when offset==0 */ - - /* get matchlength */ - length = token & ML_MASK; - if (length == ML_MASK) { - unsigned s; - do { - s = *ip++; - if ((endOnInput) && (ip > iend-LASTLITERALS)) goto _output_error; - length += s; - } while (s==255); - if ((safeDecode) && unlikely((uptrval)(op)+length<(uptrval)op)) goto _output_error; /* overflow detection */ - } - length += MINMATCH; - - /* check external dictionary */ - if ((dict==usingExtDict) && (match < lowPrefix)) { - if (unlikely(op+length > oend-LASTLITERALS)) goto _output_error; /* doesn't respect parsing restriction */ - - if (length <= (size_t)(lowPrefix-match)) { - /* match can be copied as a single segment from external dictionary */ - memmove(op, dictEnd - (lowPrefix-match), length); - op += length; - } else { - /* match encompass external dictionary and current block */ - size_t const copySize = (size_t)(lowPrefix-match); - size_t const restSize = length - copySize; - memcpy(op, dictEnd - copySize, copySize); - op += copySize; - if (restSize > (size_t)(op-lowPrefix)) { /* overlap copy */ - BYTE* const endOfMatch = op + restSize; - const BYTE* copyFrom = lowPrefix; - while (op < endOfMatch) *op++ = *copyFrom++; - } else { - memcpy(op, lowPrefix, restSize); - op += restSize; - } } - continue; - } - - /* copy match within block */ - cpy = op + length; - if (unlikely(offset<8)) { - const int dec64 = dec64table[offset]; - op[0] = match[0]; - op[1] = match[1]; - op[2] = match[2]; - op[3] = match[3]; - match += dec32table[offset]; - memcpy(op+4, match, 4); - match -= dec64; - } else { LZ4_copy8(op, match); match+=8; } - op += 8; - - if (unlikely(cpy>oend-12)) { - BYTE* const oCopyLimit = oend-(WILDCOPYLENGTH-1); - if (cpy > oend-LASTLITERALS) goto _output_error; /* Error : last LASTLITERALS bytes must be literals (uncompressed) */ - if (op < oCopyLimit) { - LZ4_wildCopy(op, match, oCopyLimit); - match += oCopyLimit - op; - op = oCopyLimit; - } - while (op16) LZ4_wildCopy(op+8, match+8, cpy); - } - op=cpy; /* correction */ - } - - /* end of decoding */ - if (endOnInput) - return (int) (((char*)op)-dest); /* Nb of output bytes decoded */ - else - return (int) (((const char*)ip)-source); /* Nb of input bytes read */ - - /* Overflow error detected */ -_output_error: - return (int) (-(((const char*)ip)-source))-1; -} - - -int LZ4_decompress_safe(const char* source, char* dest, int compressedSize, int maxDecompressedSize) -{ - return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize, endOnInputSize, full, 0, noDict, (BYTE*)dest, NULL, 0); -} - -int LZ4_decompress_safe_partial(const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize) -{ - return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize, endOnInputSize, partial, targetOutputSize, noDict, (BYTE*)dest, NULL, 0); -} - -int LZ4_decompress_fast(const char* source, char* dest, int originalSize) -{ - return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, (BYTE*)(dest - 64 KB), NULL, 64 KB); -} - - -/*===== streaming decompression functions =====*/ - -/* - * If you prefer dynamic allocation methods, - * LZ4_createStreamDecode() - * provides a pointer (void*) towards an initialized LZ4_streamDecode_t structure. - */ -LZ4_streamDecode_t* LZ4_createStreamDecode(void) -{ - LZ4_streamDecode_t* lz4s = (LZ4_streamDecode_t*) ALLOCATOR(1, sizeof(LZ4_streamDecode_t)); - return lz4s; -} - -int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream) -{ - FREEMEM(LZ4_stream); - return 0; -} - -/*! - * LZ4_setStreamDecode() : - * Use this function to instruct where to find the dictionary. - * This function is not necessary if previous data is still available where it was decoded. - * Loading a size of 0 is allowed (same effect as no dictionary). - * Return : 1 if OK, 0 if error - */ -int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize) -{ - LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse; - lz4sd->prefixSize = (size_t) dictSize; - lz4sd->prefixEnd = (const BYTE*) dictionary + dictSize; - lz4sd->externalDict = NULL; - lz4sd->extDictSize = 0; - return 1; -} - -/* -*_continue() : - These decoding functions allow decompression of multiple blocks in "streaming" mode. - Previously decoded blocks must still be available at the memory position where they were decoded. - If it's not possible, save the relevant part of decoded data into a safe buffer, - and indicate where it stands using LZ4_setStreamDecode() -*/ -int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxOutputSize) -{ - LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse; - int result; - - if (lz4sd->prefixEnd == (BYTE*)dest) { - result = LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, - endOnInputSize, full, 0, - usingExtDict, lz4sd->prefixEnd - lz4sd->prefixSize, lz4sd->externalDict, lz4sd->extDictSize); - if (result <= 0) return result; - lz4sd->prefixSize += result; - lz4sd->prefixEnd += result; - } else { - lz4sd->extDictSize = lz4sd->prefixSize; - lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize; - result = LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, - endOnInputSize, full, 0, - usingExtDict, (BYTE*)dest, lz4sd->externalDict, lz4sd->extDictSize); - if (result <= 0) return result; - lz4sd->prefixSize = result; - lz4sd->prefixEnd = (BYTE*)dest + result; - } - - return result; -} - -int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize) -{ - LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse; - int result; - - if (lz4sd->prefixEnd == (BYTE*)dest) { - result = LZ4_decompress_generic(source, dest, 0, originalSize, - endOnOutputSize, full, 0, - usingExtDict, lz4sd->prefixEnd - lz4sd->prefixSize, lz4sd->externalDict, lz4sd->extDictSize); - if (result <= 0) return result; - lz4sd->prefixSize += originalSize; - lz4sd->prefixEnd += originalSize; - } else { - lz4sd->extDictSize = lz4sd->prefixSize; - lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize; - result = LZ4_decompress_generic(source, dest, 0, originalSize, - endOnOutputSize, full, 0, - usingExtDict, (BYTE*)dest, lz4sd->externalDict, lz4sd->extDictSize); - if (result <= 0) return result; - lz4sd->prefixSize = originalSize; - lz4sd->prefixEnd = (BYTE*)dest + originalSize; - } - - return result; -} - - -/* -Advanced decoding functions : -*_usingDict() : - These decoding functions work the same as "_continue" ones, - the dictionary must be explicitly provided within parameters -*/ - -FORCE_INLINE int LZ4_decompress_usingDict_generic(const char* source, char* dest, int compressedSize, int maxOutputSize, int safe, const char* dictStart, int dictSize) -{ - if (dictSize==0) - return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, noDict, (BYTE*)dest, NULL, 0); - if (dictStart+dictSize == dest) { - if (dictSize >= (int)(64 KB - 1)) - return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, withPrefix64k, (BYTE*)dest-64 KB, NULL, 0); - return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, noDict, (BYTE*)dest-dictSize, NULL, 0); - } - return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize); -} - -int LZ4_decompress_safe_usingDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize) -{ - return LZ4_decompress_usingDict_generic(source, dest, compressedSize, maxOutputSize, 1, dictStart, dictSize); -} - -int LZ4_decompress_fast_usingDict(const char* source, char* dest, int originalSize, const char* dictStart, int dictSize) -{ - return LZ4_decompress_usingDict_generic(source, dest, 0, originalSize, 0, dictStart, dictSize); -} - -/* debug function */ -int LZ4_decompress_safe_forceExtDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize) -{ - return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize); -} - - -/*=************************************************* -* Obsolete Functions -***************************************************/ -/* obsolete compression functions */ -int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize) { return LZ4_compress_default(source, dest, inputSize, maxOutputSize); } -int LZ4_compress(const char* source, char* dest, int inputSize) { return LZ4_compress_default(source, dest, inputSize, LZ4_compressBound(inputSize)); } -int LZ4_compress_limitedOutput_withState (void* state, const char* src, char* dst, int srcSize, int dstSize) { return LZ4_compress_fast_extState(state, src, dst, srcSize, dstSize, 1); } -int LZ4_compress_withState (void* state, const char* src, char* dst, int srcSize) { return LZ4_compress_fast_extState(state, src, dst, srcSize, LZ4_compressBound(srcSize), 1); } -int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_stream, const char* src, char* dst, int srcSize, int maxDstSize) { return LZ4_compress_fast_continue(LZ4_stream, src, dst, srcSize, maxDstSize, 1); } -int LZ4_compress_continue (LZ4_stream_t* LZ4_stream, const char* source, char* dest, int inputSize) { return LZ4_compress_fast_continue(LZ4_stream, source, dest, inputSize, LZ4_compressBound(inputSize), 1); } - -/* -These function names are deprecated and should no longer be used. -They are only provided here for compatibility with older user programs. -- LZ4_uncompress is totally equivalent to LZ4_decompress_fast -- LZ4_uncompress_unknownOutputSize is totally equivalent to LZ4_decompress_safe -*/ -int LZ4_uncompress (const char* source, char* dest, int outputSize) { return LZ4_decompress_fast(source, dest, outputSize); } -int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize) { return LZ4_decompress_safe(source, dest, isize, maxOutputSize); } - - -/* Obsolete Streaming functions */ - -int LZ4_sizeofStreamState() { return LZ4_STREAMSIZE; } - -static void LZ4_init(LZ4_stream_t* lz4ds, BYTE* base) -{ - MEM_INIT(lz4ds, 0, sizeof(LZ4_stream_t)); - lz4ds->internal_donotuse.bufferStart = base; -} - -int LZ4_resetStreamState(void* state, char* inputBuffer) -{ - if ((((uptrval)state) & 3) != 0) return 1; /* Error : pointer is not aligned on 4-bytes boundary */ - LZ4_init((LZ4_stream_t*)state, (BYTE*)inputBuffer); - return 0; -} - -void* LZ4_create (char* inputBuffer) -{ - LZ4_stream_t* lz4ds = (LZ4_stream_t*)ALLOCATOR(8, sizeof(LZ4_stream_t)); - LZ4_init (lz4ds, (BYTE*)inputBuffer); - return lz4ds; -} - -char* LZ4_slideInputBuffer (void* LZ4_Data) -{ - LZ4_stream_t_internal* ctx = &((LZ4_stream_t*)LZ4_Data)->internal_donotuse; - int dictSize = LZ4_saveDict((LZ4_stream_t*)LZ4_Data, (char*)ctx->bufferStart, 64 KB); - return (char*)(ctx->bufferStart + dictSize); -} - -/* Obsolete streaming decompression functions */ - -int LZ4_decompress_safe_withPrefix64k(const char* source, char* dest, int compressedSize, int maxOutputSize) -{ - return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, withPrefix64k, (BYTE*)dest - 64 KB, NULL, 64 KB); -} - -int LZ4_decompress_fast_withPrefix64k(const char* source, char* dest, int originalSize) -{ - return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, (BYTE*)dest - 64 KB, NULL, 64 KB); -} - -#endif /* LZ4_COMMONDEFS_ONLY */ diff --git a/contrib/liblz4/src/lz4hc.c b/contrib/liblz4/src/lz4hc.c deleted file mode 100644 index 5d4ea3e6328..00000000000 --- a/contrib/liblz4/src/lz4hc.c +++ /dev/null @@ -1,720 +0,0 @@ -/* - LZ4 HC - High Compression Mode of LZ4 - Copyright (C) 2011-2016, Yann Collet. - - BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - You can contact the author at : - - LZ4 source repository : https://github.com/lz4/lz4 - - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c -*/ -/* note : lz4hc is not an independent module, it requires lz4.h/lz4.c for proper compilation */ - - -/* ************************************* -* Tuning Parameter -***************************************/ - -/*! - * HEAPMODE : - * Select how default compression function will allocate workplace memory, - * in stack (0:fastest), or in heap (1:requires malloc()). - * Since workplace is rather large, heap mode is recommended. - */ -#ifndef LZ4HC_HEAPMODE -# define LZ4HC_HEAPMODE 1 -#endif - - -/* ************************************* -* Dependency -***************************************/ -#include "lz4hc.h" - - -/* ************************************* -* Local Compiler Options -***************************************/ -#if defined(__GNUC__) -# pragma GCC diagnostic ignored "-Wunused-function" -#endif - -#if defined (__clang__) -# pragma clang diagnostic ignored "-Wunused-function" -#endif - - -/* ************************************* -* Common LZ4 definition -***************************************/ -#define LZ4_COMMONDEFS_ONLY -#include "lz4.c" - - -/* ************************************* -* Local Constants -***************************************/ -#define OPTIMAL_ML (int)((ML_MASK-1)+MINMATCH) - - -/************************************** -* Local Macros -**************************************/ -#define HASH_FUNCTION(i) (((i) * 2654435761U) >> ((MINMATCH*8)-LZ4HC_HASH_LOG)) -#define DELTANEXTMAXD(p) chainTable[(p) & LZ4HC_MAXD_MASK] /* flexible, LZ4HC_MAXD dependent */ -#define DELTANEXTU16(p) chainTable[(U16)(p)] /* faster */ - -static U32 LZ4HC_hashPtr(const void* ptr) { return HASH_FUNCTION(LZ4_read32(ptr)); } - - - -/************************************** -* HC Compression -**************************************/ -static void LZ4HC_init (LZ4HC_CCtx_internal* hc4, const BYTE* start) -{ - MEM_INIT((void*)hc4->hashTable, 0, sizeof(hc4->hashTable)); - MEM_INIT(hc4->chainTable, 0xFF, sizeof(hc4->chainTable)); - hc4->nextToUpdate = 64 KB; - hc4->base = start - 64 KB; - hc4->end = start; - hc4->dictBase = start - 64 KB; - hc4->dictLimit = 64 KB; - hc4->lowLimit = 64 KB; -} - - -/* Update chains up to ip (excluded) */ -FORCE_INLINE void LZ4HC_Insert (LZ4HC_CCtx_internal* hc4, const BYTE* ip) -{ - U16* const chainTable = hc4->chainTable; - U32* const hashTable = hc4->hashTable; - const BYTE* const base = hc4->base; - U32 const target = (U32)(ip - base); - U32 idx = hc4->nextToUpdate; - - while (idx < target) { - U32 const h = LZ4HC_hashPtr(base+idx); - size_t delta = idx - hashTable[h]; - if (delta>MAX_DISTANCE) delta = MAX_DISTANCE; - DELTANEXTU16(idx) = (U16)delta; - hashTable[h] = idx; - idx++; - } - - hc4->nextToUpdate = target; -} - - -FORCE_INLINE int LZ4HC_InsertAndFindBestMatch (LZ4HC_CCtx_internal* hc4, /* Index table will be updated */ - const BYTE* ip, const BYTE* const iLimit, - const BYTE** matchpos, - const int maxNbAttempts) -{ - U16* const chainTable = hc4->chainTable; - U32* const HashTable = hc4->hashTable; - const BYTE* const base = hc4->base; - const BYTE* const dictBase = hc4->dictBase; - const U32 dictLimit = hc4->dictLimit; - const U32 lowLimit = (hc4->lowLimit + 64 KB > (U32)(ip-base)) ? hc4->lowLimit : (U32)(ip - base) - (64 KB - 1); - U32 matchIndex; - int nbAttempts=maxNbAttempts; - size_t ml=0; - - /* HC4 match finder */ - LZ4HC_Insert(hc4, ip); - matchIndex = HashTable[LZ4HC_hashPtr(ip)]; - - while ((matchIndex>=lowLimit) && (nbAttempts)) { - nbAttempts--; - if (matchIndex >= dictLimit) { - const BYTE* const match = base + matchIndex; - if (*(match+ml) == *(ip+ml) - && (LZ4_read32(match) == LZ4_read32(ip))) - { - size_t const mlt = LZ4_count(ip+MINMATCH, match+MINMATCH, iLimit) + MINMATCH; - if (mlt > ml) { ml = mlt; *matchpos = match; } - } - } else { - const BYTE* const match = dictBase + matchIndex; - if (LZ4_read32(match) == LZ4_read32(ip)) { - size_t mlt; - const BYTE* vLimit = ip + (dictLimit - matchIndex); - if (vLimit > iLimit) vLimit = iLimit; - mlt = LZ4_count(ip+MINMATCH, match+MINMATCH, vLimit) + MINMATCH; - if ((ip+mlt == vLimit) && (vLimit < iLimit)) - mlt += LZ4_count(ip+mlt, base+dictLimit, iLimit); - if (mlt > ml) { ml = mlt; *matchpos = base + matchIndex; } /* virtual matchpos */ - } - } - matchIndex -= DELTANEXTU16(matchIndex); - } - - return (int)ml; -} - - -FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch ( - LZ4HC_CCtx_internal* hc4, - const BYTE* const ip, - const BYTE* const iLowLimit, - const BYTE* const iHighLimit, - int longest, - const BYTE** matchpos, - const BYTE** startpos, - const int maxNbAttempts) -{ - U16* const chainTable = hc4->chainTable; - U32* const HashTable = hc4->hashTable; - const BYTE* const base = hc4->base; - const U32 dictLimit = hc4->dictLimit; - const BYTE* const lowPrefixPtr = base + dictLimit; - const U32 lowLimit = (hc4->lowLimit + 64 KB > (U32)(ip-base)) ? hc4->lowLimit : (U32)(ip - base) - (64 KB - 1); - const BYTE* const dictBase = hc4->dictBase; - U32 matchIndex; - int nbAttempts = maxNbAttempts; - int delta = (int)(ip-iLowLimit); - - - /* First Match */ - LZ4HC_Insert(hc4, ip); - matchIndex = HashTable[LZ4HC_hashPtr(ip)]; - - while ((matchIndex>=lowLimit) && (nbAttempts)) { - nbAttempts--; - if (matchIndex >= dictLimit) { - const BYTE* matchPtr = base + matchIndex; - if (*(iLowLimit + longest) == *(matchPtr - delta + longest)) { - if (LZ4_read32(matchPtr) == LZ4_read32(ip)) { - int mlt = MINMATCH + LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, iHighLimit); - int back = 0; - - while ((ip+back > iLowLimit) - && (matchPtr+back > lowPrefixPtr) - && (ip[back-1] == matchPtr[back-1])) - back--; - - mlt -= back; - - if (mlt > longest) { - longest = (int)mlt; - *matchpos = matchPtr+back; - *startpos = ip+back; - } - } - } - } else { - const BYTE* const matchPtr = dictBase + matchIndex; - if (LZ4_read32(matchPtr) == LZ4_read32(ip)) { - size_t mlt; - int back=0; - const BYTE* vLimit = ip + (dictLimit - matchIndex); - if (vLimit > iHighLimit) vLimit = iHighLimit; - mlt = LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH; - if ((ip+mlt == vLimit) && (vLimit < iHighLimit)) - mlt += LZ4_count(ip+mlt, base+dictLimit, iHighLimit); - while ((ip+back > iLowLimit) && (matchIndex+back > lowLimit) && (ip[back-1] == matchPtr[back-1])) back--; - mlt -= back; - if ((int)mlt > longest) { longest = (int)mlt; *matchpos = base + matchIndex + back; *startpos = ip+back; } - } - } - matchIndex -= DELTANEXTU16(matchIndex); - } - - return longest; -} - - -typedef enum { noLimit = 0, limitedOutput = 1 } limitedOutput_directive; - -#define LZ4HC_DEBUG 0 -#if LZ4HC_DEBUG -static unsigned debug = 0; -#endif - -FORCE_INLINE int LZ4HC_encodeSequence ( - const BYTE** ip, - BYTE** op, - const BYTE** anchor, - int matchLength, - const BYTE* const match, - limitedOutput_directive limitedOutputBuffer, - BYTE* oend) -{ - int length; - BYTE* token; - -#if LZ4HC_DEBUG - if (debug) printf("literal : %u -- match : %u -- offset : %u\n", (U32)(*ip - *anchor), (U32)matchLength, (U32)(*ip-match)); -#endif - - /* Encode Literal length */ - length = (int)(*ip - *anchor); - token = (*op)++; - if ((limitedOutputBuffer) && ((*op + (length>>8) + length + (2 + 1 + LASTLITERALS)) > oend)) return 1; /* Check output limit */ - if (length>=(int)RUN_MASK) { int len; *token=(RUN_MASK< 254 ; len-=255) *(*op)++ = 255; *(*op)++ = (BYTE)len; } - else *token = (BYTE)(length<>8) + (1 + LASTLITERALS) > oend)) return 1; /* Check output limit */ - if (length>=(int)ML_MASK) { - *token += ML_MASK; - length -= ML_MASK; - for(; length > 509 ; length-=510) { *(*op)++ = 255; *(*op)++ = 255; } - if (length > 254) { length-=255; *(*op)++ = 255; } - *(*op)++ = (BYTE)length; - } else { - *token += (BYTE)(length); - } - - /* Prepare next loop */ - *ip += matchLength; - *anchor = *ip; - - return 0; -} - -#include "lz4opt.h" - -static int LZ4HC_compress_hashChain ( - LZ4HC_CCtx_internal* const ctx, - const char* const source, - char* const dest, - int const inputSize, - int const maxOutputSize, - unsigned maxNbAttempts, - limitedOutput_directive limit - ) -{ - const BYTE* ip = (const BYTE*) source; - const BYTE* anchor = ip; - const BYTE* const iend = ip + inputSize; - const BYTE* const mflimit = iend - MFLIMIT; - const BYTE* const matchlimit = (iend - LASTLITERALS); - - BYTE* op = (BYTE*) dest; - BYTE* const oend = op + maxOutputSize; - - int ml, ml2, ml3, ml0; - const BYTE* ref = NULL; - const BYTE* start2 = NULL; - const BYTE* ref2 = NULL; - const BYTE* start3 = NULL; - const BYTE* ref3 = NULL; - const BYTE* start0; - const BYTE* ref0; - - /* init */ - ctx->end += inputSize; - - ip++; - - /* Main Loop */ - while (ip < mflimit) { - ml = LZ4HC_InsertAndFindBestMatch (ctx, ip, matchlimit, (&ref), maxNbAttempts); - if (!ml) { ip++; continue; } - - /* saved, in case we would skip too much */ - start0 = ip; - ref0 = ref; - ml0 = ml; - -_Search2: - if (ip+ml < mflimit) - ml2 = LZ4HC_InsertAndGetWiderMatch(ctx, ip + ml - 2, ip + 0, matchlimit, ml, &ref2, &start2, maxNbAttempts); - else ml2 = ml; - - if (ml2 == ml) { /* No better match */ - if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml, ref, limit, oend)) return 0; - continue; - } - - if (start0 < ip) { - if (start2 < ip + ml0) { /* empirical */ - ip = start0; - ref = ref0; - ml = ml0; - } - } - - /* Here, start0==ip */ - if ((start2 - ip) < 3) { /* First Match too small : removed */ - ml = ml2; - ip = start2; - ref =ref2; - goto _Search2; - } - -_Search3: - /* - * Currently we have : - * ml2 > ml1, and - * ip1+3 <= ip2 (usually < ip1+ml1) - */ - if ((start2 - ip) < OPTIMAL_ML) { - int correction; - int new_ml = ml; - if (new_ml > OPTIMAL_ML) new_ml = OPTIMAL_ML; - if (ip+new_ml > start2 + ml2 - MINMATCH) new_ml = (int)(start2 - ip) + ml2 - MINMATCH; - correction = new_ml - (int)(start2 - ip); - if (correction > 0) { - start2 += correction; - ref2 += correction; - ml2 -= correction; - } - } - /* Now, we have start2 = ip+new_ml, with new_ml = min(ml, OPTIMAL_ML=18) */ - - if (start2 + ml2 < mflimit) - ml3 = LZ4HC_InsertAndGetWiderMatch(ctx, start2 + ml2 - 3, start2, matchlimit, ml2, &ref3, &start3, maxNbAttempts); - else ml3 = ml2; - - if (ml3 == ml2) { /* No better match : 2 sequences to encode */ - /* ip & ref are known; Now for ml */ - if (start2 < ip+ml) ml = (int)(start2 - ip); - /* Now, encode 2 sequences */ - if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml, ref, limit, oend)) return 0; - ip = start2; - if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml2, ref2, limit, oend)) return 0; - continue; - } - - if (start3 < ip+ml+3) { /* Not enough space for match 2 : remove it */ - if (start3 >= (ip+ml)) { /* can write Seq1 immediately ==> Seq2 is removed, so Seq3 becomes Seq1 */ - if (start2 < ip+ml) { - int correction = (int)(ip+ml - start2); - start2 += correction; - ref2 += correction; - ml2 -= correction; - if (ml2 < MINMATCH) { - start2 = start3; - ref2 = ref3; - ml2 = ml3; - } - } - - if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml, ref, limit, oend)) return 0; - ip = start3; - ref = ref3; - ml = ml3; - - start0 = start2; - ref0 = ref2; - ml0 = ml2; - goto _Search2; - } - - start2 = start3; - ref2 = ref3; - ml2 = ml3; - goto _Search3; - } - - /* - * OK, now we have 3 ascending matches; let's write at least the first one - * ip & ref are known; Now for ml - */ - if (start2 < ip+ml) { - if ((start2 - ip) < (int)ML_MASK) { - int correction; - if (ml > OPTIMAL_ML) ml = OPTIMAL_ML; - if (ip + ml > start2 + ml2 - MINMATCH) ml = (int)(start2 - ip) + ml2 - MINMATCH; - correction = ml - (int)(start2 - ip); - if (correction > 0) { - start2 += correction; - ref2 += correction; - ml2 -= correction; - } - } else { - ml = (int)(start2 - ip); - } - } - if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml, ref, limit, oend)) return 0; - - ip = start2; - ref = ref2; - ml = ml2; - - start2 = start3; - ref2 = ref3; - ml2 = ml3; - - goto _Search3; - } - - /* Encode Last Literals */ - { int lastRun = (int)(iend - anchor); - if ((limit) && (((char*)op - dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize)) return 0; /* Check output limit */ - if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK< 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; } - else *op++ = (BYTE)(lastRun< 9) { - switch (compressionLevel) { - case 10: return LZ4HC_compress_hashChain(ctx, source, dest, inputSize, maxOutputSize, 1 << (16-1), limit); - case 11: ctx->searchNum = LZ4HC_getSearchNum(compressionLevel); return LZ4HC_compress_optimal(ctx, source, dest, inputSize, maxOutputSize, limit, 128, 0); - default: - case 12: ctx->searchNum = LZ4HC_getSearchNum(compressionLevel); return LZ4HC_compress_optimal(ctx, source, dest, inputSize, maxOutputSize, limit, LZ4_OPT_NUM, 1); - } - } - return LZ4HC_compress_hashChain(ctx, source, dest, inputSize, maxOutputSize, 1 << (compressionLevel-1), limit); -} - - -int LZ4_sizeofStateHC(void) { return sizeof(LZ4_streamHC_t); } - -int LZ4_compress_HC_extStateHC (void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel) -{ - LZ4HC_CCtx_internal* ctx = &((LZ4_streamHC_t*)state)->internal_donotuse; - if (((size_t)(state)&(sizeof(void*)-1)) != 0) return 0; /* Error : state is not aligned for pointers (32 or 64 bits) */ - LZ4HC_init (ctx, (const BYTE*)src); - if (maxDstSize < LZ4_compressBound(srcSize)) - return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, compressionLevel, limitedOutput); - else - return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, compressionLevel, noLimit); -} - -int LZ4_compress_HC(const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel) -{ -#if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1 - LZ4_streamHC_t* const statePtr = (LZ4_streamHC_t*)malloc(sizeof(LZ4_streamHC_t)); -#else - LZ4_streamHC_t state; - LZ4_streamHC_t* const statePtr = &state; -#endif - int const cSize = LZ4_compress_HC_extStateHC(statePtr, src, dst, srcSize, maxDstSize, compressionLevel); -#if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1 - free(statePtr); -#endif - return cSize; -} - - - -/************************************** -* Streaming Functions -**************************************/ -/* allocation */ -LZ4_streamHC_t* LZ4_createStreamHC(void) { return (LZ4_streamHC_t*)malloc(sizeof(LZ4_streamHC_t)); } -int LZ4_freeStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr) { free(LZ4_streamHCPtr); return 0; } - - -/* initialization */ -void LZ4_resetStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel) -{ - LZ4_STATIC_ASSERT(sizeof(LZ4HC_CCtx_internal) <= sizeof(size_t) * LZ4_STREAMHCSIZE_SIZET); /* if compilation fails here, LZ4_STREAMHCSIZE must be increased */ - LZ4_streamHCPtr->internal_donotuse.base = NULL; - LZ4_streamHCPtr->internal_donotuse.compressionLevel = (unsigned)compressionLevel; - LZ4_streamHCPtr->internal_donotuse.searchNum = LZ4HC_getSearchNum(compressionLevel); -} - -int LZ4_loadDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, const char* dictionary, int dictSize) -{ - LZ4HC_CCtx_internal* ctxPtr = &LZ4_streamHCPtr->internal_donotuse; - if (dictSize > 64 KB) { - dictionary += dictSize - 64 KB; - dictSize = 64 KB; - } - LZ4HC_init (ctxPtr, (const BYTE*)dictionary); - ctxPtr->end = (const BYTE*)dictionary + dictSize; - if (ctxPtr->compressionLevel >= LZ4HC_CLEVEL_OPT_MIN) - LZ4HC_updateBinTree(ctxPtr, ctxPtr->end - MFLIMIT, ctxPtr->end - LASTLITERALS); - else - if (dictSize >= 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3); - return dictSize; -} - - -/* compression */ - -static void LZ4HC_setExternalDict(LZ4HC_CCtx_internal* ctxPtr, const BYTE* newBlock) -{ - if (ctxPtr->compressionLevel >= LZ4HC_CLEVEL_OPT_MIN) - LZ4HC_updateBinTree(ctxPtr, ctxPtr->end - MFLIMIT, ctxPtr->end - LASTLITERALS); - else - if (ctxPtr->end >= ctxPtr->base + 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3); /* Referencing remaining dictionary content */ - - /* Only one memory segment for extDict, so any previous extDict is lost at this stage */ - ctxPtr->lowLimit = ctxPtr->dictLimit; - ctxPtr->dictLimit = (U32)(ctxPtr->end - ctxPtr->base); - ctxPtr->dictBase = ctxPtr->base; - ctxPtr->base = newBlock - ctxPtr->dictLimit; - ctxPtr->end = newBlock; - ctxPtr->nextToUpdate = ctxPtr->dictLimit; /* match referencing will resume from there */ -} - -static int LZ4_compressHC_continue_generic (LZ4_streamHC_t* LZ4_streamHCPtr, - const char* source, char* dest, - int inputSize, int maxOutputSize, limitedOutput_directive limit) -{ - LZ4HC_CCtx_internal* ctxPtr = &LZ4_streamHCPtr->internal_donotuse; - /* auto-init if forgotten */ - if (ctxPtr->base == NULL) LZ4HC_init (ctxPtr, (const BYTE*) source); - - /* Check overflow */ - if ((size_t)(ctxPtr->end - ctxPtr->base) > 2 GB) { - size_t dictSize = (size_t)(ctxPtr->end - ctxPtr->base) - ctxPtr->dictLimit; - if (dictSize > 64 KB) dictSize = 64 KB; - LZ4_loadDictHC(LZ4_streamHCPtr, (const char*)(ctxPtr->end) - dictSize, (int)dictSize); - } - - /* Check if blocks follow each other */ - if ((const BYTE*)source != ctxPtr->end) LZ4HC_setExternalDict(ctxPtr, (const BYTE*)source); - - /* Check overlapping input/dictionary space */ - { const BYTE* sourceEnd = (const BYTE*) source + inputSize; - const BYTE* const dictBegin = ctxPtr->dictBase + ctxPtr->lowLimit; - const BYTE* const dictEnd = ctxPtr->dictBase + ctxPtr->dictLimit; - if ((sourceEnd > dictBegin) && ((const BYTE*)source < dictEnd)) { - if (sourceEnd > dictEnd) sourceEnd = dictEnd; - ctxPtr->lowLimit = (U32)(sourceEnd - ctxPtr->dictBase); - if (ctxPtr->dictLimit - ctxPtr->lowLimit < 4) ctxPtr->lowLimit = ctxPtr->dictLimit; - } - } - - return LZ4HC_compress_generic (ctxPtr, source, dest, inputSize, maxOutputSize, ctxPtr->compressionLevel, limit); -} - -int LZ4_compress_HC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize) -{ - if (maxOutputSize < LZ4_compressBound(inputSize)) - return LZ4_compressHC_continue_generic (LZ4_streamHCPtr, source, dest, inputSize, maxOutputSize, limitedOutput); - else - return LZ4_compressHC_continue_generic (LZ4_streamHCPtr, source, dest, inputSize, maxOutputSize, noLimit); -} - - -/* dictionary saving */ - -int LZ4_saveDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, char* safeBuffer, int dictSize) -{ - LZ4HC_CCtx_internal* const streamPtr = &LZ4_streamHCPtr->internal_donotuse; - int const prefixSize = (int)(streamPtr->end - (streamPtr->base + streamPtr->dictLimit)); - if (dictSize > 64 KB) dictSize = 64 KB; - if (dictSize < 4) dictSize = 0; - if (dictSize > prefixSize) dictSize = prefixSize; - memmove(safeBuffer, streamPtr->end - dictSize, dictSize); - { U32 const endIndex = (U32)(streamPtr->end - streamPtr->base); - streamPtr->end = (const BYTE*)safeBuffer + dictSize; - streamPtr->base = streamPtr->end - endIndex; - streamPtr->dictLimit = endIndex - dictSize; - streamPtr->lowLimit = endIndex - dictSize; - if (streamPtr->nextToUpdate < streamPtr->dictLimit) streamPtr->nextToUpdate = streamPtr->dictLimit; - } - return dictSize; -} - - -/*********************************** -* Deprecated Functions -***********************************/ -/* These functions currently generate deprecation warnings */ -/* Deprecated compression functions */ -int LZ4_compressHC(const char* src, char* dst, int srcSize) { return LZ4_compress_HC (src, dst, srcSize, LZ4_compressBound(srcSize), 0); } -int LZ4_compressHC_limitedOutput(const char* src, char* dst, int srcSize, int maxDstSize) { return LZ4_compress_HC(src, dst, srcSize, maxDstSize, 0); } -int LZ4_compressHC2(const char* src, char* dst, int srcSize, int cLevel) { return LZ4_compress_HC (src, dst, srcSize, LZ4_compressBound(srcSize), cLevel); } -int LZ4_compressHC2_limitedOutput(const char* src, char* dst, int srcSize, int maxDstSize, int cLevel) { return LZ4_compress_HC(src, dst, srcSize, maxDstSize, cLevel); } -int LZ4_compressHC_withStateHC (void* state, const char* src, char* dst, int srcSize) { return LZ4_compress_HC_extStateHC (state, src, dst, srcSize, LZ4_compressBound(srcSize), 0); } -int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* src, char* dst, int srcSize, int maxDstSize) { return LZ4_compress_HC_extStateHC (state, src, dst, srcSize, maxDstSize, 0); } -int LZ4_compressHC2_withStateHC (void* state, const char* src, char* dst, int srcSize, int cLevel) { return LZ4_compress_HC_extStateHC(state, src, dst, srcSize, LZ4_compressBound(srcSize), cLevel); } -int LZ4_compressHC2_limitedOutput_withStateHC (void* state, const char* src, char* dst, int srcSize, int maxDstSize, int cLevel) { return LZ4_compress_HC_extStateHC(state, src, dst, srcSize, maxDstSize, cLevel); } -int LZ4_compressHC_continue (LZ4_streamHC_t* ctx, const char* src, char* dst, int srcSize) { return LZ4_compress_HC_continue (ctx, src, dst, srcSize, LZ4_compressBound(srcSize)); } -int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* ctx, const char* src, char* dst, int srcSize, int maxDstSize) { return LZ4_compress_HC_continue (ctx, src, dst, srcSize, maxDstSize); } - - -/* Deprecated streaming functions */ -int LZ4_sizeofStreamStateHC(void) { return LZ4_STREAMHCSIZE; } - -int LZ4_resetStreamStateHC(void* state, char* inputBuffer) -{ - LZ4HC_CCtx_internal *ctx = &((LZ4_streamHC_t*)state)->internal_donotuse; - if ((((size_t)state) & (sizeof(void*)-1)) != 0) return 1; /* Error : pointer is not aligned for pointer (32 or 64 bits) */ - LZ4HC_init(ctx, (const BYTE*)inputBuffer); - ctx->inputBuffer = (BYTE*)inputBuffer; - return 0; -} - -void* LZ4_createHC (char* inputBuffer) -{ - LZ4_streamHC_t* hc4 = (LZ4_streamHC_t*)ALLOCATOR(1, sizeof(LZ4_streamHC_t)); - if (hc4 == NULL) return NULL; /* not enough memory */ - LZ4HC_init (&hc4->internal_donotuse, (const BYTE*)inputBuffer); - hc4->internal_donotuse.inputBuffer = (BYTE*)inputBuffer; - return hc4; -} - -int LZ4_freeHC (void* LZ4HC_Data) { FREEMEM(LZ4HC_Data); return 0; } - -int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel) -{ - return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, 0, compressionLevel, noLimit); -} - -int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel) -{ - return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, maxOutputSize, compressionLevel, limitedOutput); -} - -char* LZ4_slideInputBufferHC(void* LZ4HC_Data) -{ - LZ4HC_CCtx_internal* const hc4 = &((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse; - int const dictSize = LZ4_saveDictHC((LZ4_streamHC_t*)LZ4HC_Data, (char*)(hc4->inputBuffer), 64 KB); - return (char*)(hc4->inputBuffer + dictSize); -} diff --git a/contrib/libpoco/CHANGELOG b/contrib/libpoco/CHANGELOG deleted file mode 100644 index 19bdd0d3d84..00000000000 --- a/contrib/libpoco/CHANGELOG +++ /dev/null @@ -1,2360 +0,0 @@ -This is the changelog file for the POCO C++ Libraries. - -Release 1.6.1 (2015-08-03) -========================== - -- added project and solution files for Visual Studio 2015 -- upgraded bundled SQLite to 3.8.11.1 -- fixed GH #782: Poco::JSON::PrintHandler not working for nested arrays -- fixed GH #819: JSON Stringifier fails with preserve insert order -- fixed GH #878: UUID tryParse -- fixed GH #869: FIFOBuffer::read(T*, std::size_t) documentation inaccurate -- fixed GH #861: Var BadCastException -- fixed GH #779: BUG in 1.6.0 Zip code -- fixed GH #769: Poco::Var operator== throws exception -- fixed GH #766: Poco::JSON::PrintHandler not working for objects in array -- fixed GH #763: Unable to build static with NetSSL_OpenSSL for OS X -- fixed GH #750: BsonWriter::write missing size ? -- fixed GH #741: Timestamp anomaly in Poco::Logger on WindowsCE -- fixed GH #735: WEC2013 build fails due to missing Poco::Path methods. -- fixed GH #722: poco-1.6.0: Unicode Converter Test confuses string and char types -- fixed GH #719: StreamSocket::receiveBytes and FIFOBuffer issue in 1.6 -- fixed GH #706: POCO1.6 Sample EchoServer BUG -- fixed GH #646: Prevent possible data race in access to Timer::_periodicInerval -- DeflatingStream: do not flush underlying stream on sync() as these can cause - corrupted files in Zip archives - - -Release 1.6.0 (2014-12-22) -========================== - -- fixed GH #625: MongoDB ensureIndex double insert? -- fixed GH #622: Crypto: RSATest::testSign() should verify with public key only -- fixed GH #620: Data documentation sample code outdated -- fixed GH #618: OS X 10.10 defines PAGE_SIZE macro, conflicts with PAGE_SIZE in Thread_POSIX.cpp -- fixed GH #616: Visual Studio warning C4244 -- fixed GH #612: OpenSSLInitializer calls OPENSSL_config but not CONF_modules_free -- fixed GH #608: (Parallel)SocketAcceptor ctor/dtor call virtual functions -- fixed GH #607: Idle Reactor high CPU usage -- fixed GH #606: HTMLForm constructor read application/x-www-form-urlencoded UTF-8 request - body first parameter with BOM in name -- fixed GH #596: For OpenSSL 1.0.1, include openssl/crypto.h not openssl/fips.h -- fixed GH #592: Incorrect format string in Poco::Dynamic::Struct -- fixed GH #590: Poco::Data::SQlite doesn't support URI filenames -- fixed GH #564: URI::encode -- fixed GH #560: DateTime class calculates a wrong day -- fixed GH #549: Memory allocation is not safe between fork() and execve() -- fixed GH #500: SSLManager causes a crash -- fixed GH #490: 2 byte frame with payload length of 0 throws "Incomplete Frame Received" exception -- fixed GH #483: multiple cases for sqlite_busy -- fixed GH #482: Poco::JSON::Stringifier::stringify bad behaviour -- fixed GH #478: HTTPCredentials not according to HTTP spec -- fixed GH #471: vs2010 release builds have optimization disabled ? -- fixed GH #468: HTTPClientSession/HTTPResponse not forwarding exceptions -- fixed GH #438: Poco::File::setLastModified() doesn't work -- fixed GH #402: StreamSocket::receiveBytes(FIFOBuffer&) and sendBytes(FIFOBuffer&) are - not thread safe -- fixed GH #345: Linker warning LNK4221 in Foundation for SignalHandler.obj, String.obj - and ByteOrder.obj -- fixed GH #331: Poco::Zip does not support files with ".." in the name. -- fixed GH #318: Logger local time doesn't automatically account for DST -- fixed GH #294: Poco::Net::TCPServerParams::setMaxThreads(int count) will not accept count == 0. -- fixed GH #215: develop WinCE build broken -- fixed GH #63: Net::NameValueCollection::size() returns int -- Poco::Logger: formatting methods now support up to 10 arguments. -- added Poco::Timestamp::raw() -- Poco::DeflatingOutputStream and Poco::InflatingOutputStreams also flush underlying stream - on flush()/sync(). -- Poco::Util::Timer: prevent re-schedule of cancelled TimerTask -- enabled WinRegistryKey and WinRegistryConfiguration for WinCE -- Poco::BasicEvent improvements and preparations for future support of lambdas/std::function -- upgraded bundled sqlite to 3.8.7.2 -- Poco::Thread: added support for starting functors/lambdas -- Poco::Net::HTTPClientSession: added support for global proxy configuration -- added support for OAuth 1.0/2.0 via Poco::Net::OAuth10Credentials and - Poco::Net::OAuth20Credentials classes. -- Poco::Net::IPAddress: fixed IPv6 prefix handling issue on Windows -- added Poco::Timestamp::TIMEVAL_MIN and Poco::Timestamp::TIMEVAL_MAX -- added Poco::Clock::CLOCKVAL_MIN and Poco::Clock::CLOCKVAL_MAX -- added poco_assert_msg() and poco_assert_msg_dbg() macros -- Poco::Net::Context: fixed a memory leak if the CA file was not found while creating the - Context object (the underlying OpenSSL context would leak) -- Poco::URI: added new constructor to create URI from Path -- Various documentation and style fixes -- Removed support (project/solution files) for Visual Studio.NET 2003 and Visual Studio 2005. -- Improved CMake support - - -Release 1.5.4 (2014-10-14) -========================== - -- fixed GH #326: compile Net lib 1.5.2 without UTF8 support enabled -- fixed GH #518: NetworkInterface.cpp compile error w/ POCO_NO_WSTRING (1.5.3) -- Fixed MSVC 2010 warnings on large alignment -- make HTTPAuthenticationParams::parse() add value on end of string -- fixed GH #482: Poco::JSON::Stringifier::stringify bad behaviour -- fixed GH #508: Can't compile for arm64 architecture -- fixed GH #510: Incorrect RSAKey construction from istream -- fix SharedMemory for WinCE/WEC2013 -- Add NIOS2 double conversion detection, fixes compile errors -- added VS2013 project/solution files for Windows Embedded Compact 2013 -- added Process::isRunning() -- NetSSL: Fix typo in documentation -- NetSSL_OpenSSL: support for TLS 1.1 and 1.2 -- Zip: Added CM_AUTO, which automatically selects CM_STORE or CM_DEFLATE based - on file extension. Used to avoid double-compression of already compressed file - formats such as images. -- added %L modifier to PatternFormatter to switch to local time -- removed unnecessary explicit in some multi-arg constructors -- Allow SecureStreamSocket::attach() to be used in server connections -- added Var::isBoolean() and fixed JSON stringifier -- added poco_unexpected() macro invoking Bugcheck::unexpected() to deal - with unexpected exceptions in destructors -- fixed GH #538 prevent destructors from throwing exceptions -- improved HTTP server handling of errors while reading header -- fixed GH #545: use short for sign -- upgraded SQLite to 3.8.6 -- fixed GH #550 WebSocket fragmented message problem -- improved HTTPClientSession handling of network errors while sending the request -- updated bundled PCRE to 8.35.0 -- fixed GH #552: FIFOBuffer drain() problem -- fixed GH #402: StreamSocket::receiveBytes(FIFOBuffer&) and sendBytes(FIFOBuffer&) are - not thread safe -- HTTPCookie: fix documentation for max age -- added Timestamp::raw() and Clock::raw() -- Poco::Buffer properly handles zero-sized buffers -- GH #512: Poco:Data:ODBC:Binder.h causes a crash -- Added Crypto_Win and NetSSL_Win libraries which are re-implementations of existing - Crypto and NetSSL_OpenSSL libraries based on WinCrypt/Schannel. The new libraries - can be used as an almost drop-in replacement for the OpenSSL based libraries on - Windows and Windows Embedded Compact platforms. Only available from GitHub for now. - - -Release 1.5.3 (2014-06-30) -========================== - -- fixed GH# 316: Poco::DateTimeFormatter::append() gives wrong result for - Poco::LocalDateTime -- Poco::Data::MySQL: added SQLite thread cleanup handler -- Poco::Net::X509Certificate: improved and fixed domain name verification for - wildcard domains -- added Poco::Clock class, which uses a system-provided monotonic clock - (if available) and is thus not affected by system realtime clock changes. - Monotonic Clock is available on Windows, Linux, OS X and on POSIX platforms - supporting clock_gettime() and CLOCK_MONOTONIC. -- Poco::Timer, Poco::Stopwatch, Poco::TimedNotificationQueue and Poco::Util::Timer - have been changed to use Poco::Clock instead of Poco::Timestamp and are now - unaffected by system realtime clock changes. -- fixed GH# 350: Memory leak in Data/ODBC with BLOB -- Correctly set MySQL time_type for Poco::Data::Date. -- fixed GH #352: Removed redundant #includes and fixed spelling mistakes. -- fixed setting of MYSQL_BIND is_unsigned value. -- fixed GH #360: CMakeLists foundation: add Clock.cpp in the list of source files -- Add extern "C" around on HPUX platform. -- added runtests.sh -- fixed CPPUNIT_IGNORE parsing -- fixed Glob from start path, for platforms not alowing transverse from root (Android) -- added NTPClient (Rangel Reale) -- added PowerShell build script -- added SmartOS build support -- fix warnings in headers -- XMLWriter: removed unnecessary apostrophe escaping (&apos) -- MongoDB: use Int32 for messageLength -- fixed GH #380: SecureSocket+DialogSocket crashes with SIGSEGV when timeout occours -- Improve RSADigestEngine, using Poco::Crypto::DigestEngine to calculate hash before signing -- added Poco::PBKDF2Engine -- Fixed GH #380: SecureSocket+DialogSocket crashes with SIGSEGV when timeout occours -- added support for a 'Priority' attribute on cookies. -- GH #386: fixed bug in MailMessage without content-transfer-encoding header -- GH #384: ew hash algorithms support for RSADigestEngine -- fixed Clock overflow bug on Windows -- Poco::ByteOrder now uses intrinsics, if available -- CMake: added /bigobj option for msvc -- Fix typo to restore Net/TestSuite_x64_vs120 build -- correct path for CONFIGURE_FILE in CMakeLists.txt -- Building Poco 1.5.2 for Synology RS812+ (Intel Atom) (honor POCO_NO_INOTIFY) -- added WEC2013 support to buildwin.cmd and buildwin.ps1 -- HTMLForm: in URL encoding, percent-encode more characters -- Fixed #include conflict with other libraries -- Poco::Net::X509Certificate::verify() no longer uses DNS reverse lookups to validate host names -- cert hostname validation is case insensitive and stricter for wildcard certificates -- TCPServer: do not reduce the capacity of the default ThreadPool -- added POCO_LOG_DEBUG flag -- Zip: fixed a crash caused by an I/O error -- added runtest script for windows -- added SQlite Full Text Search support -- added Thread::trySleep() and Thread::wakeUp() -- fixed GH #410: Bug in JSON::Object.stringify() in 1.5.2 -- fixed GH #362: Defect in Var::parseString when there is no space between value and newline -- fixed GH #314: JSON parsing bug -- added GH #313: MetaColumn additions for Data::ODBC and Data::SQLite -- fixed GH #346: Make Poco::Data::Date and Poco::Data::Time compare functions const. -- fixed GH #341: Compiling poco-1.5.2 for Cygwin -- fixed GH #305: There are bugs in Buffer.h -- fixed GH #321: trivial build fixes (BB QNX build) -- fixed GH #440: MongoDB ObjectId string formatting -- added SevenZip library (Guenter Obiltschnig) -- fixed GH #442: Use correct prefix length field of Windows IP_ADAPTER_PREFIX structure -- improved GH #328: NetworkInterface on Windows XP -- fixed GH #154 Add support for MYSQL_TYPE_NEWDECIMAL to Poco::Data::MySQL -- fixed GH #290: Unicode support -- fixed GH #318: Logger local time doesn't automatically account for DST -- fixed GH #363: DateTimeParser tryParse/parse -- added HTMLForm Content-Length calculation (Rangel Reale) -- Make TemporaryFile append a slash to tempDir -- fixed GH #319 android build with cmake -- added hasDelegates() method to AbstractEvent -- fixed GH #230: Poco::Timer problem -- fixed GH #317: Poco::Zip does not support newer Zip file versions. -- fixed GH #176: Poco::JSON::Stringifier UTF encoding -- fixed GH #458: Broadcast address and subnet mask for IEEE802.11 network interface -- fixed GH #456: poco: library install dirs per RUNTIME/LIBRARY/ARCHIVE - - -Release 1.5.2 (2013-09-16) -========================== - -- added MongoDB library -- fixed GH #57: poco-1.5.1: Doesn't compile for Android -- added VoidEvent (Arturo Castro) -- fixed GH #80: NumberFormatter::append broken -- fixed GH #93: ParallelSocketAcceptor virtual functions -- optional small object optimization for IPAddress, SocketAddress, Any and Dynamic::Var -- SQLite events (insert, update, delete, commit, rollback) handlers -- merged GH #91: Improve SQLite multi-threaded use (Rangel Reale) -- merged GH #86: Invalid pointers to vector internals (Adrian Imboden) -- automatic library initialization macros -- fixed GH #110: WebSocket accept() fails when Connection header contains multiple tokens -- fixed GH #71: WebSocket and broken Timeouts (POCO_BROKEN_TIMEOUTS) -- fixed a warning in Poco/Crypto/OpenSSLInitializer.h -- fixed GH #109: Bug in Poco::Net::SMTPClientSession::loginUsingPlain -- added clang libc++ build configurations for Darwin and iPhone (Andrea Bigagli) -- fixed GH #116: Wrong timezone parsing in DateTimeParse (Matej Knopp) -- fixed GH #118: JSON::Object::stringify endless loop -- added Recursive and SortedDirectoryIterator (Marian Krivos) -- added ListMap (map-like container with preserving insertion order) -- MailMessage: attachments saving support and consistent read/write -- fixed GH #124: Possible buffer overrun in Foundation/EventLogChannel -- fixed GH #119: JSON::Object holds values in ordered map -- added JSON::PrintHandler -- renamed JSON::DefaultHandler to ParseHandler (breaking change!) -- fixed GH #127: Eliminate -Wshadow warnings -- fixed GH #79: Poco::Thread leak on Linux -- fixed GH #61: static_md build configs for Crypto and NetSSL -- fixed GH #130: prefer sysconf over sysctlbyname -- fixed GH #131: no timezone global var on OpenBSD -- fixed GH #102: Some subprojects don't have x64 solutions for VS 2010 -- added GH #75: Poco::Uri addQueryParameter method -- Poco::Environment::osDisplayName() now recognizes Windows 8/Server 2012 -- fixed GH #140: Poco::Runnable threading cleanup issue -- simplified default TCP/HTTPServer construction -- fixed GH #141: Application::run() documentation/implementation discrepancy -- changed RowFormatter to SharedPtr in Data::RecordSet interface (breaking change!) -- fixed GH #144: Poco::Dynamic emits invalid JSON -- removed naked pointers from Data interfaces -- fixed GH #82: name conflict in Data::Keywords::bind -- fixed GH #157: MySQL: cannot bind to 'long' data type on Windows/Visual C++ -- fixed GH #158: MySQL: MYSQL_BIND 'is_unsigned' member is not set -- fixed GH #160: MultipartReader ignores first part, if preamble is missing -- fixed GH #156: Possible buffer overrun in Foundation/EventLogChannel -- XML: fixed an issue with parsing a memory buffer > 2 GB -- upgraded to expat 2.1.0 -- Data/ODBC: added support for setting query timeout (via setProperty - of "queryTimeout"). Timeout is int, given in seconds. -- fixed a potential endless loop in SecureStreamSocketImpl::sendBytes() - and also removed unnecessary code. -- fixed GH #159: Crash in openssl CRYPTO_thread_id() after library libPocoCrypto.so - has been unloaded. -- fixed GH #155: MailOutputStream mangles consecutive newline sequences -- fixed GH #139: FileChannel::PROP_FLUSH is invalid (contains a tab character) -- fixed GH #173: HTTPClientSession::proxyConnect forces DNS lookup of host names -- fixed GH #194: MessageNotification constructor is inefficient. -- fixed GH #189: Poco::NumberParser::tryParse() documentation bug -- fixed GH #172: IPv6 Host field is stripped of Brackets in HTTPClientSession -- fixed GH #188: Net: SocketAddress operator < unusable for std::map key -- fixed GH #128: DOMWriter incorrectly adds SYSTEM keyword to DTD if PUBLIC is - already specified -- fixed GH #65: Poco::format() misorders sign and padding specifiers -- upgraded bundled SQLite to 3.7.17 -- replaced JSON parser with Poco::Web::JSON parser (from sandbox) -- added JSON conversion to Dynamic Struct and Array -- added VarIterator -- modified behavior of empty Var (empty == empty) -- added Alignment.h header for C++03 alignment needs -- added Data/WebNotifier (DB, WebSocket) example -- fixed GH #209: Poco::NumberFormatter double length -- fixed GH #204: Upgrade zlib to 1.2.8 -- fixed GH #198: The "application.configDir" property is not always created. -- fixed GH #185: Poco::NumberFormatter::format(double value, int precision) - ignore precision == 0 -- fixed GH #138: FreeBSD JSON tests fail -- fixed GH #99: JSON::Query an JSON::Object -- limited allowed types for JSON::Query to Object, Array, Object::Ptr, - Array::Ptr and empty -- fixed GH #175: HTMLForm does not read URL parameters on POST or PUT -- added GH #187: MySQL: allow access to the underlying connection handle -- added GH #186: MySQL: support for MYSQL_SECURE_AUTH -- fixed GH #174: MySQL: 4GB allocated when reading any largetext or largeblob field -- fixed a potential memory leak in Poco::Net::HTTPClientSession if it is misused - (e.g., sendRequest() is sent two times in a row without an intermediate call to - receiveResponse(), or by calling receiveResponse() two times in a row without - an intermediate call to sendRequest()) - GH #217 -- removed a few unnecessary protected accessor methods from Poco::Net::HTTPClientSession - that would provide inappropriate access to internal state -- merged GH #210: Don't call CloseHandle() twice on Windows; Ability to select the - threadpool that will be used to start an Activity(Patrice Tarabbia) -- fixed GH #212: JSONConfiguration was missing from the vs90 project(Patrice Tarabbia) -- fixed GH #220: add qualifiers for FPEnvironment in C99 (Lucas Clemente) -- fixed GH #222: HTTPCookie doesn't support expiry times in the past (Karl Reid) -- fixed GH #224: building 1.5.1 on Windows for x64 -- fixed GH# 233: ServerSocket::bind6(Poco::UInt16 port, bool reuseAddress, bool ipV6Only) does not work -- fixed GH# 231: Compatibility issue with Poco::Net::NetworkInterface -- fixed GH# 236: Bug in RecursiveDirectoryIterator -- added ColorConsoleChannel and WindowsColorConsoleChannel classes supporting - colorizing log messages -- fixed GH# 259: Poco::EventLogChannel fails to find 64bit Poco Foundation dll -- fixed GH# 254: UTF8::icompare unexpected behavior -- Poco::UUID::tryParse() also accepts UUIDs without hyphens. Also updated documentation - (links to specifications). -- added GH# 268: Method to get JSON object value using Poco::Nullable -- fixed GH# 267: JSON 'find' not returning empty result if object is expected but another value is found -- Added support for ARM64 architecture and iPhone 5s 64-bit builds - (POCO_TARGET_OSARCH=arm64). - - -Release 1.5.1 (2013-01-11) -========================== - -- using double-conversion library for floating-point numeric/string conversions -- added Poco::istring (case-insensitive string) and Poco::isubstr -- added SQLite sys.dual (in-memory system table) -- applied SF Patch #120: The ExpireLRUCache does not compile with a tuple as key on Visual Studio 2010 -- fixed SF Bug #599: JSON::Array and JSON::Object size() member can implicitly lose precision -- fixed SF Bug #602: iterating database table rows not correct if no data in table -- fixed SF Bug #603: count() is missing in HashMap -- fixed GH #23: JSON::Object::stringify throw BadCastException -- fixed GH #16: NetworkInterface::firstAddress() should not throw on unconfigured interfaces -- Android compile/build support (by Rangel Reale) -- TypeHandler::prepare() now takes const-reference -- fixed GH #27: Poco::URI::decode() doesn't properly handle '+' -- fixed GH #31: JSON implementation bug -- fixed SF #597: Configure script ignores cflags -- fixed SF #593: Poco 1.5.0 on FreeBSD: cannot find -ldl -- added SF #542: SocketAddress() needs port-only constructor -- fixed SF #215: Wrong return type in SocketConnector.h -- applied SF Patch #97: fix c++0x / clang++ bugs -- fixed GH32/SF596: Poco::JSON: Parsing long integer (int64) value fails. -- added Net ifconfig sample (contributed by Philip Prindeville) -- merged GH #34: add algorithm header (Roger Meier/Philip Prindeville) -- fixed GH #26: Cannot compile on gcc -- merged SF #111: FTP Client logging (Marian Krivos) -- fixed GH #30: Poco::Path::home() throws when called from Windows Service -- fixed GH #22: MySQL connection string lowercased -- added MySQL support for Date/Time -- upgraded SQLite to version 3.7.15.1 (2012-12-19) -- improved SQLite execute() return (affected rows) value and added tests -- added SQLite::Utility::isThreadSafe() function -- added SQLite::Utility::setThreadMode(int mode) function -- fixed GH #36: 'distclean' requires 3 traversals of project tree -- fixed GH #41: Buffer::resize crash -- fixed GH #42: Linux unbundled builds don't link -- fixed GH #44: Problems with win x64 build -- fixed GH #46: 1.5.1 build fails on OS X when using libc++ -- fixed GH #48: Need getArgs() accessor to Util::Application to retrieve start-up arguments -- fixed GH #49: NetworkInterface::list doesn't return MAC addresses -- fixed GH #51: Android should use isfinite, isinf, isnan and signbit from the std namespace -- fixed GH #53: JSON unicode fixes and running tests on invalid unicode JSON -- added ParallelAcceptor and ParallelReactor classes -- added EOF and error to FIFOBuffer - - -Release 1.5.0 (2012-10-14) -========================== - -- added JSON library -- added Util::JSONConfiguration -- added FIFOBuffer and FIFOBufferStream -- fixed SF# 3522906: Unregistering handlers from SocketReactor -- fixed SF# 3522084: AbstractConfiguration does not support 64-bit integers -- HTTPServer::stopAll(): close the socket instead of just shutting it down, as the latter won't wake up a select() on Windows -- added SMTPLogger -- added cmake support -- fixed SF#3538778: NetworkInterface enumeration uses deprecated API -- fixed SF#3538779: IPAddress lacks useful constructors: from prefix mask, native SOCKADDR -- fixed SF#3538780: SocketAddress needs operator < function -- fixed SF#3538775: Issues building on Fedora/Centos, etc. for AMD64 -- fixed SF#3538786: Use size_t for describing data-blocks in DigestEngine -- added IPAddress bitwise operators (&,|,^,~) -- added IPAddress BinaryReader/Writer << and >> operators -- modified IPAddress to force IPv6 to lowercase (RFC 5952) -- fixed SF#3538785: SMTPClientSession::sendMessage() should take recipient list -- added IPAddress::prefixLength() -- UTF portability improvements -- fixed SF#3556186: Linux shouldn't use in Net/SocketDefs.h -- added IPAddress RFC 4291 compatible site-local prefix support -- fixed SF#3012166: IPv6 patch -- added SF#3558085: Add formatter to MACAddress object -- fixed SF#3552774: Don't hide default target in subordinate makefile -- fixed SF#3534307: Building IPv6 for Linux by default -- fixed SF#3516844: poco missing symbols with external >=lipcre-8.13 -- added SF#3544720: AbstractConfigurator to support 64bit values -- fixed SF#3522081: WinRegistryConfiguration unable to read REG_QWORD values -- fixed SF#3563626: For Win32 set Up/Running flags on NetworkInterface -- fixed SF#3560807: Deprecate setPeerAddress() as this is now done in getifaddrs -- fixed SF#3560776: Fix byte-ordering issues with INADDR_* literals -- fixed SF#3563627: Set IP address on multicast socket from socket family -- fixed SF#3563999: Size BinaryWriter based on buffer's capacity(), not size() -- fixed SF#102 Fix building Poco on Debian GNU/kFreeBSD -- fixed SF#321 Binding DatTime or Timestamp -- fixed SF#307 Detect the SQL driver type at run time -- added VS 2012 Projects/Solutions -- enhanced and accelerated numeric parsing for integers and floats -- fixed SF#590 Segfault on FreeBSD when stack size not rounded -- added warn function and warnmsg macro in CppUnit -- fixed SF# 3558012 Compilation fails when building with -ansi or -std=c++0x -- fixed SF# 3563517 Get rid of loss-of-precision warnings on x64 MacOS -- fixed SF#3562244: Portability fix for AF_LINK -- fixed SF #3562400: DatagramSocketImpl comment is incorrect - - -Release 1.4.7p1 (2014-11-25) -============================ - -- Fixed Visual C++ 2010-2013 project files. Release builds now have optimization enabled. -- Poco::URI: added constructor to create URI from Path. -- fixed GH #618: OS X 10.10 defines PAGE_SIZE macro, conflicts with PAGE_SIZE in Thread_POSIX.cpp -- Poco::Net::HTTPClientSession: added support for global proxy configuration -- fixed GH #331: Poco::Zip does not support files with .. in the name. -- fixed a memory leak in Poco::Net::Context constructor when it fails to load the certificate - or private key files. -- upgraded bundled SQLite to 3.8.7.2 -- fixed GH #229: added missing value() function -- fixed GH #69: MySQL empty text/blob - - -Release 1.4.7 (2014-10-06) -========================== - -- fixed GH #398: PropertyFileConfiguration: input != output -- fixed GH #368: Build failure of Poco 1.4.6p2 on FreeBSD 9.2 -- fixed GH #318: Logger local time doesn't automatically account for DST -- fixed GH #317: Poco::Zip does not support newer Zip file versions. -- fixed GH #454: Fix: handle unhandled exceptions -- fixed GH #463: XML does not compile with XML_UNICODE_WCHAR_T -- fixed GH #282: Using Thread in a global can cause crash on Windows -- fixed GH #424: Poco::Timer deadlock -- fixed GH #465: Fix result enum type XML_Error -> XML_Status -- fixed GH #510: Incorrect RSAKey construction from istream -- fixed GH #332: POCO::ConsoleChannnel::initColors() assigns no color to - PRIO_TRACE and wrong color to PRIO_FATAL -- fixed GH #550: WebSocket fragmented message problem -- Poco::Data::MySQL: added SQLite thread cleanup handler -- Poco::Net::X509Certificate: improved and fixed domain name verification for - wildcard domains -- fixed a crash in Foundation testsuite with Visual C++ 2012 -- improved and fixed domain name verification for wildcard domains in - Poco::Net::X509Certificate -- updated TwitterClient sample to use new 1.1 API and OAuth -- added Poco::Clock class, which uses a system-provided monotonic clock - (if available) and is thus not affected by system realtime clock changes. - Monotonic Clock is available on Windows, Linux, OS X and on POSIX platforms - supporting clock_gettime() and CLOCK_MONOTONIC. -- Poco::Timer, Poco::Stopwatch, Poco::TimedNotificationQueue and Poco::Util::Timer - have been changed to use Poco::Clock instead of Poco::Timestamp and are now - unaffected by system realtime clock changes. -- added Poco::PBKDF2Engine class template -- Poco::Net::HTTPCookie: added support for Priority attribute (backport from develop) -- fixed makedepend.* scripts to work in paths containing '.o*' - (contributed by Per-Erik Bjorkstad, Hakan Bengtsen) -- Upgraded bundled SQLite to 3.8.6 -- Support for Windows Embedded Compact 2013 (Visual Studio 2012) -- Project and solution files for Visual Studio 2013 -- Changes for C++11 compatibility. -- fixed an issue with receiving empty web socket frames (such as ping) -- improved error handling in secure socket classes -- Poco::ByteOrder now uses intrinsics if available -- added new text encoding classes: Latin2Encoding, Windows1250Encoding, Windows1251Encoding -- Zip: Added CM_AUTO, which automatically selects CM_STORE or CM_DEFLATE based on file extension. - Used to avoid double-compression of already compressed file formats such as images. - - -Release 1.4.6p4 (2014-04-18) -============================ - -- no longer use reverse DNS lookups for cert hostname validation -- cert hostname validation is case insensitive and more strict -- HTMLForm: in URL encoding, percent-encode more special characters -- fixed thread priority issues on POSIX platforms with non-standard scheduling policy -- XMLWriter no longer escapes apostrophe character -- fixed GH #316: Poco::DateTimeFormatter::append() gives wrong result for Poco::LocalDateTime -- fixed GH #305 (memcpy in Poco::Buffer uses wrong size if type != char) -- Zip: fixed a crash caused by an I/O error (e.g., full disk) while creating a Zip archive - - -Release 1.4.6p3 (2014-04-02) -============================ - -- Fixed a potential security vulnerability in client-side X509 - certificate verification. - - -Release 1.4.6p2 (2013-09-16) -============================ - -- fixed GH #156: Possible buffer overrun in Foundation/EventLogChannel -- XML: fixed an issue with parsing a memory buffer > 2 GB -- upgraded to expat 2.1.0 -- Data/ODBC: added support for setting query timeout (via setProperty - of "queryTimeout"). Timeout is int, given in seconds. -- fixed a potential endless loop in SecureStreamSocketImpl::sendBytes() - and also removed unnecessary code. -- fixed GH #159: Crash in openssl CRYPTO_thread_id() after library libPocoCrypto.so - has been unloaded. -- fixed GH #155: MailOutputStream mangles consecutive newline sequences -- fixed GH# 139: FileChannel::PROP_FLUSH is invalid (contains a tab character) -- fixed GH# 173: HTTPClientSession::proxyConnect forces DNS lookup of host names -- fixed GH# 194: MessageNotification constructor is inefficient. -- fixed GH# 189: Poco::NumberParser::tryParse() documentation bug -- fixed GH# 172: IPv6 Host field is stripped of Brackets in HTTPClientSession -- fixed GH# 188: Net: SocketAddress operator < unusable for std::map key -- fixed GH# 128: DOMWriter incorrectly adds SYSTEM keyword to DTD if PUBLIC is - already specified -- fixed GH# 65: Poco::format() misorders sign and padding specifiers -- upgraded bundled SQLite to 3.7.17 -- upgraded bundled zlib to 1.2.8 -- fixed a potential memory leak in Poco::Net::HTTPClientSession if it is misused - (e.g., sendRequest() is sent two times in a row without an intermediate call to - receiveResponse(), or by calling receiveResponse() two times in a row without - an intermediate call to sendRequest()) - GH #217 -- removed a few unnecessary protected accessor methods from Poco::Net::HTTPClientSession - that would provide inappropriate access to internal state -- fixed GH# 223 (Poco::Net::HTTPCookie does not support expiry times in the past) -- fixed GH# 233: ServerSocket::bind6(Poco::UInt16 port, bool reuseAddress, bool ipV6Only) - does not work -- added ColorConsoleChannel and WindowsColorConsoleChannel classes supporting - colorizing log messages -- fixed GH# 259: Poco::EventLogChannel fails to find 64bit Poco Foundation dll -- fixed GH# 254: UTF8::icompare unexpected behavior -- Poco::UUID::tryParse() also accepts UUIDs without hyphens. Also updated documentation - (links to specifications). -- Added support for ARM64 architecture and iPhone 5s 64-bit builds - (POCO_TARGET_OSARCH=arm64). - - -Release 1.4.6p1 (2013-03-06) -============================ - -- fixed GH# 71: WebSocket and broken Timeouts (POCO_BROKEN_TIMEOUTS) -- fixed an ambiguity error with VC++ 2010 in Data/MySQL testsuite -- Poco::Net::NetworkInterface now provides the interface index even for IPv4 -- added DNS::reload() as a wrapper for res_init(). -- On Linux, Poco::Environment::nodeId() first always tries to obtain the - MAC address of eth0, before looking for other interfaces. -- Poco::Net::HTTPSession now always resets the buffer in connect() to clear - any leftover data from a (failed) previous session -- fixed copysign namespace issue in FPEnvironment_DUMMY.h -- fixed a warning in Poco/Crypto/OpenSSLInitializer.h -- added a build configuration for BeagleBoard/Angstrom -- fixed GH# 109: Bug in Poco::Net::SMTPClientSession::loginUsingPlain) -- fixed compile errors with clang -std=c++11 -- fixed GH# 116: Wrong timezone parsing in DateTimeParse (fix by Matej Knopp) -- updated bundled SQLite to 3.7.15.2 - - -Release 1.4.6 (2013-01-10) -========================== - -- changed FPEnvironment_DUMMY.h to include instead of -- updated bundled SQLite to 3.7.15.1 -- fixed GH# 30: Poco::Path::home() throws -- fixed SF Patch# 120 The ExpireLRUCache does not compile with a tuple as key on VS2010 -- fixed SF# 603 count() is missing in HashMap -- Crypto and NetSSL_OpenSSL project files now use OpenSSL *MD.lib library files for - static_md builds. Previously, the DLL import libs were used. -- Poco::Environment::osDisplayName() now recognizes Windows 8/Server 2012 - - -Release 1.4.5 (2012-11-19) -========================== - -- added Visual Studio 2012 project files -- buildwin.cmd now support building with msbuild for VS2010 and 2012. -- added Poco::Optional class -- fixed SF# 3558012 Compilation fails when building with -ansi or -std=c++0x -- fixed SF# 3563517 Get rid of loss-of-precision warnings on x64 MacOS -- fixed SF# 3562244: Portability fix for AF_LINK -- fixed SF# 3562400: DatagramSocketImpl comment -- fixed SF# 594: Websocket fails with small masked payloads -- fixed SF# 588: Missing POCO_ARCH and POCO_ARCH_LITTLE_ENDIAN define for WinCE on SH4 -- fixed SF# 581: Out-of-bound array access in Unicode::properties() function. -- fixed SF# 590: Segfault on FreeBSD when stack size not rounded -- fixed SF# 586: Poco::DateTimeParser and ISO8601 issues when seconds fraction has more than 6 digits -- Poco::Net::HTTPSSessionInstantiator::registerInstantiator() now optionally accepts a - Poco::Net::Context object. -- added Poco::XML::XMLWriter::depth() member function. -- added Poco::XML::XMLWriter::uniquePrefix() and Poco::XML::XMLWriter::isNamespaceMapped(). -- Poco::FileChannel now supports a new rotateOnOpen property (true/false) which can be used - to force rotation of the log file when it's opened. -- fixed a bug in Poco::XML::XMLWriter::emptyElement(): need to pop namespace context -- OS X builds now use Clang as default compiler -- Updated SQLite to 3.7.14.1 -- POCO_SERVER_MAIN macro now has a try ... catch block for Poco::Exception and writes - the displayText to stderr. -- Poco/Platform.h now defines POCO_LOCAL_STATIC_INIT_IS_THREADSAFE macro if the compiler - generates thread-safe static local initialization code. - - -Release 1.4.4 (2012-09-03) -========================== - -- ZipStream now builds correctly in unbundled build. -- added proxy digest authentication support to Net library -- integrated MySQL BLOB fixes from Franky Braem. -- use standard OpenSSL import libraries (libeay32.lib, ssleay32.lib) for Crypto and - NetSSL_OpenSSL Visual Studio project files. -- fixed a potential buffer corruption issue in Poco::Net::SecureStreamSocket if lazy - handshake is enabled and the first attempt to complete the handshake fails -- Poco::DateTimeParser::tryParse() without format specifier now correctly parses ISO8601 - date/times with fractional seconds. -- Poco::Process::launch() now has additional overloads allowing to specify an initial - directory and/or environment. -- Poco::Net::FTPClientSession: timeout was not applied to data connection, only to - control connection. -- Fixed potential IPv6 issue with socket constructors if IPv6 SocketAddress is given - (contributed by ??????? ????????? ). -- Added an additional (optional) parameter to Poco::Thread::setOSPriority() allowing to - specify a scheduling policy. Currently this is only used on POSIX platforms and allows - specifying SCHED_OTHER (default), SCHED_FIFO or SCHED_RR, as well as other - platform-specific policy values. -- Added Poco::Crypto::DigestEngine class providing a Poco::DigestEngine interface to - the digest algorithms provided by OpenSSL. -- Fixed some potential compiler warnings in Crypto library -- In some cases, when an SSL exception was unexpectedly closed, a generic Poco::IOException - was thrown. This was fixed to throw a SSLConnectionUnexpectedlyClosedException instead. -- Added Poco::ObjectPool class template. -- Poco::Net::HTTPServer has a new stopAll() method allowing stopping/aborting of all - currently active client connections. -- The HTTP server framework now actively prevents sending a message body in the - response to a HEAD request, or in case of a 204 No Content or 304 Not Modified - response status. -- fixed a DOM parser performance bug (patch by Peter Klotz) -- fixed SF# 3559325: Util Windows broken in non-Unicode -- updated iOS build configuration to use xcode-select for finding toolchain -- Poco::Net::SecureSocketImpl::shutdown() now also shuts down the underlying socket. -- fixed SF# 3552597: Crypto des-ecb error -- fixed SF# 3550553: SecureSocketImpl::connect hangs -- fixed SF# 3543047: Poco::Timer bug for long startInterval/periodic interval -- fixed SF# 3539695: Thread attributes should be destroyed using the pthread_attr_destroy() -- fixed SF# 3532311: Not able to set socket option on ServerSocket before bind - Added Poco::Net::Socket::init(int af) which can be used to explicitely - initialize the underlying socket before calling bind(), connect(), etc. -- fixed SF# 3521347: Typo in UnWindows.h undef -- fixed SF# 3519474: WinRegistryConfiguration bug - Also added tests and fixed another potential issue with an empty root path passed to the constructor. -- fixed SF# 3516827: wrong return value of WinRegistryKey::exists() -- fixed SF# 3515284: RSA publickey format(X.509 SubjectPublicKeyInfo) -- fixed SF# 3503267: VxWorks OS prio is not set in standard constructor -- fixed SF# 3500438: HTTPResponse failure when reason is empty -- fixed SF# 3495656: numberformater, numberparser error in mingw -- fixed SF# 3496493: Reference counting broken in TaskManager postNotification -- fixed SF# 3483174: LogFile flushing behavior on Windows - Flushing is now configurable for FileChannel and SimpleFileChannel - using the "flush" property (true or false). -- fixed SF# 3479561: Subsequent IPs on a NIC is not enumerated -- fixed SF# 3478665: Permission checks in Poco::File not correct for root -- fixed SF# 3475050: Threading bug in initializeNetwork() on Windows -- fixed SF# 3552680: websocket small frames bug and proposed fix -- fixed a WebSocket interop issue with Firefox -- added Poco::Net::MessageHeader::hasToken() -- Poco::AtomicCounter now uses GCC 4.3 builtin atomics on more platforms -- fixed SF# 3555938: NetSSL: socket closed twice -- socket exceptions now include OS error code -- fixed SF# 3556975: Need to fix Shared Memory for memory map -- Poco::Net::SecureSocketImpl::close() now catches exceptions thrown by its call to shutdown(). -- fixed SF# 3535990: POCO_HAVE_IPv6 without POCO_WIN32_UTF8 conflict -- fixed SF# 3559665: Poco::InflatingInputStream may not always inflate completely -- added Poco::DirectoryWatcher class -- fixed SF# 3561464: Poco::File::isDevice() can throw due to sharing violation -- Poco::Zip::Compress::addRecursive() has a second variant that allows to specify the compression method. -- Upgraded internal SQLite to 3.7.14 - - -Release 1.4.3p1 (2012-01-23) -============================ - -- fixed SF# 3476926: RegDeleteKeyEx not available on Windows XP 32-bit - - -Release 1.4.3 (2012-01-16) -========================== - -- fixed a compilation error with Data/MySQL on QNX. -- fixed Util project files for WinCE (removed sources not compileable on CE) -- removed MD2 license text from Ackowledgements document -- fixed iPhone build config for Xcode 4.2 (compiler name changed to llvm-g++) -- Poco::Util::XMLConfiguration: delimiter char (default '.') is now configurable. - This allows for working with XML documents having element names with '.' in them. -- Poco::Util::OptionProcessor: Required option arguments can now be specified as - separate command line arguments, as in "--option value" in addition to the - "--option=value" format. -- Poco::Util::HelpFormatter: improved option help formatting if indentation has - been set explicitely. -- added Mail sample to NetSSL_OpenSSL, showing use of Poco::Net::SecureSMTPClientSession. -- added additional read() overloads to Poco::Net::HTMLForm. -- fixed SF# 3440769: Poco::Net::HTTPResponse doesn't like Amazon EC2 cookies. -- added support for requiring TLSv1 to Poco::Net::Context. -- added an additional constructor to Poco::Net::HTTPBasicCredentials, allowing - the object to be created from a string containing a base64-encoded, colon-separated - username and password. -- Poco::Zip::ZipStreamBuf: fixed a crash if CM_STORE was used. -- Added setContentLength64() and getContentLength64() to Poco::Net::HTTPMessage. -- added Poco::Environment::osDisplayName(). -- fixed SF# 3463096: WinService leaves dangling handles (open() now does not reopen the - service handle if it's already open) -- fixed SF# 3426537: WinRegistryConfiguration can't read virtualized keys -- added Poco::Buffer::resize() -- fixed SF# 3441822: thread safety issue in HTTPClientSession: - always use getaddrinfo() instead of gethostbyname() on all platforms supporting it -- added version resource to POCO DLLs -- fixed SF# 3440599: Dir Path in Quotes in PATH cause PathTest::testFind to fail. -- fixed SF# 3406030: Glob::collect problem -- added Poco::Util::AbstractConfiguration::enableEvents() -- Poco::AtomicCounter now uses GCC builtins with GCC 4.1 or newer - (contributed by Alexey Milovidov) -- made Poco::Logger::formatDump() public as it may be useful for others as well - (SF# 3453446) -- Poco::Net::DialogSocket now has a proper copy constructor (SF# 3414602) -- Poco::Net::MessageHeader and Poco::Net::HTMLForm now limit the maximum number of - fields parsed from a message to prevent certain kinds of denial-of-service - attacks. The field limit can be changed with the new method setFieldLimit(). - The default limit is 100. -- Poco::NumberFormatter, Poco::NumberParser and Poco::format() now always use the - classic ("C") locale to format and parse floating-point numbers. -- added Poco::StreamCopier::copyStream64(), Poco::StreamCopier::copyStreamUnbuffered64() - and Poco::StreamCopier::copyToString64(). These functions use a 64-bit integer - to count the number of bytes copied. -- upgraded internal zlib to 1.2.5 -- upgraded internal sqlite to 3.7.9 -- XML: integrated bugfix for Expat bug# 2958794 (memory leak in poolGrow) -- Added support for HTTP Digest authentication (based on a contribution by - Anton V. Yabchinskiy (arn at bestmx dot ru)). For information on how - to use this, see the Poco::Net::HTTPCredentials, Poco::Net::HTTPDigestCredentials - and Poco::Net::HTTPAuthenticationParams classes. -- Poco::Net::HTTPStreamFactory and Poco::Net::HTTPSStreamFactory now support Basic - and Digest authentication. Username and password must be provided in the URI. -- added Poco::Net::WebSocket, supporting the WebSocket protocol as described in RFC 6455 -- NetSSL_OpenSSL: added client-side support for Server Name Indication. - Poco::Net::SecureSocketImpl::connectSSL() now calls SSL_set_tlsext_host_name() - if its available (OpenSSL 9.8.6f and later). -- added Poco::Net::HTTPClientSession::proxyConnect() (factored out from - Poco::Net::HTTPSClientSession::connect()) -- added Poco::Process::kill(const Poco::ProcessHandle&) which is preferable to - kill(pid) on Windows, as process IDs on Windows may be reused. -- fixed SF# 3471463: Compiler warnings with -Wformat -- Poco::Util::Application::run() now catches and logs exceptions thrown in initialize() -- Fixed a WinCE-specific bug in Poco::Util::ServerApplication where uninitialize() would - be called twice. -- fixed SF# 3471957: WinRegistryKey::deleteKey() unable to delete alt views -- Added additional constructor to Poco::ScopedLock and Poco::ScopedLockWithUnlock - accepting a timeout as second argument. -- Added Poco::Logger::parseLevel() -- Poco::format(): an argument that does not match the format - specifier no longer results in a BadCastException. The string [ERRFMT] is - written to the result string instead. -- PageCompiler: added createSession page attribute. - - -Release 1.4.2p1 (2011-09-24) -============================ - -- On Linux, the RTLD_DEEPBIND option is no longer passed to dlopen(). - This change was introduced in 1.4.2 to solve a specific problem one customer - was having. Unfortunately, it leads to problems with RTTI. -- It's now possible to pass flags (SHLIB_GLOBAL, SHLIB_LOCAL) to - Poco::SharedLibrary::load() (and the constructor implicitly calling load()), - controlling the mode flags (RTLD_GLOBAL, RTLD_LOCAL) passed to dlopen(). - On platforms not using dlopen(), these flags are ignored. -- fixed SF# 3400267: Path_WIN32.cpp bug - - -Release 1.4.2 (2011-08-28) -========================== - -- added Poco::DateTimeFormat::ISO8601_FRAC_FORMAT -- added new Poco::DateTimeFormatter and Poco::DateTimeParser format specifier: - %s for seconds with optional fractions of a second -- fixed a problem with ioctl() on BSD platforms (including OS X) where the - second argument to ioctl() is unsigned long instead of int, causing bad - things on a OS X 64-bit kernel. -- fixed a potential endless loop when enumerating IPv6 network addresses - (reported by Laurent Carcagno) -- new compile-time config option on Windows to set thread names in - debugger. Enable with -DPOCO_WIN32_DEBUGGER_THREAD_NAMES. Available - only in debug builds. -- Cipher can now create Base64 and HexBinary encoded output without linefeeds - (suitable for use in cookies, etc.) -- added Poco::Path::popFrontDirectory() -- improved VxWorks support -- IPv6 fixes: added proper scope id handling in IPAddress, SocketAddress - and related classes. -- Added Poco::Net::ServerSocket::bind6() which allows control over the - IPPROTO_IPV6/IPV6_V6ONLY socket option. -- Removed Poco::MD2Engine class due to licensing issues (the - license for the MD2 code from RSA only allows non-commercial - use). Note that the MD4 and MD5 code from RSA does not have - this issue. -- fixed a Net HTTP client testsuite issue where some tests might - have failed due to prematurely aborted connections by - the HTTPTestServer. -- Poco::Net::SocketAddress: when there is more than one address - returned by a DNS lookup for a name, IPv4 addresses will be - preferred to IPv6 ones. -- NetworkInterface::list() now also returns IPv4 interfaces on Windows when - built with -DPOCO_HAVE_IPv6 -- XMLWriter: fixed a bug with attribute namespaces (no namespace prefix - written if attribute namespace is the same as element namespace) -- fixed SF# 3378588: Mismatched new[]/delete (in RSAEncryptImpl and RSADecryptImpl) -- fixed SF# 3212954 (OpenSSLInitializer::uninitialize() crash) and - SF# 3196862 (Static OpenSSLInitializer instance causes Windows deadlocks) by - removing the static Poco::Crypto::OpenSSLInitializer instance. Automatic OpenSSL - initialization is now done through Poco::Crypto::Cipher, Poco::Crypto::CipherKey, - Poco::Crypto::X509Certificate, Poco::Net::Context classes; however, it is still - recommended to call Poco::Crypto::initializeCrypto() and - Poco::Crypto::uninitializeCrypto() early at application startup, and late at - shutdown respectively (or Poco::Net::initializeSSL()/Poco::Net::uninitializeSSL() - if the NetSSL library is used) to avoid multiple full OpenSSL init/uninit cycles - during application runtime. -- Poco::Logger now also support a symbolic log level "none" - (for use with setLevel()) that disables logging completely - for that Logger (equivalent to setLevel(0)). -- Added experimental Android support, using the existing gmake-based - build system. -- fixed SF# 3288584: DateTimeFormatter link error -- fixed SF# 3187117: Typo in InflatingInputStream doc -- fixed SF# 3309731: _WIN32_WCE comparison should be with 0x600 not 600 -- fixed SF# 3393026: RegularExpression.h identical enum value -- fixed SF# 3274222: AtomicCounter's postfix operators aren't atomic on Windows -- fixed SF# 3317177: Handle leak on windows -- fixed SF# 3181882: Poco::URI::getPathEtc() double-encodes query -- fixed SF# 3379935: ThreadPool Start Bug -- fixed SF# 3354451: Poco::Format::parsePrec never sets the precision to zero -- fixed SF# 3387258: _MAX_PATH used but unknown in Path_WIN32 -- fixed a problem in RSAKeyImpl where direct access to the RSA in a EVP_PKEY - would no longer work in recent OpenSSL versions. Using EVP_PKEY_get1_RSA() - fixes the issue. -- added Poco::Crypto::EncryptingInputStream, Poco::Crypto::EncryptingOutputStream, - Poco::Crypto::DecryptingInputStream and Poco::Crypto::DecryptingOutputStream. -- fixed SF# 3148126: HTTPSClientSession destructor (!) throws an IOException -- fixed SF# 3178098: Add constructor to Poco::TemporaryFile to specify directory -- fixed SF# 3175310: Absolute path when device -- fixed SF# 3301207: Guided tour example contradicts apidoc (API doc was wrong) -- Poco::Net::HTTPMessage::setContentLength() and Poco::Net::HTTPMessage::getContentLength() now - use std::streamsize instead of int. This enables 64-bit Content-Length support at least - on 64-bit platforms. -- fixed SF# 3177530: TemporaryFile::tempName() + glob bug on xp -- fixed SF# 3177372: FileChannel documentation inconsistency -- added %E format specifier to Poco::PattermFormatter (epoch time in seconds - since midnight, January 1 1970) -- On Windows, Poco::Util::ServerApplication now supports a /description command - line argument for specifying a service description (together with /registerService) -- added Poco::Util::WinService::setDescription() and - Poco::Util::WinService::getDescription() -- fixed SF# 3155477: Incorrect URI path handling -- fixed SF# 3309736: Extended Exception macros to set default exception code - new macro is named POCO_DECLARE_EXCEPTION_CODE -- added getter functions for modulus and exponents to Poco::Crypto::RSAKey. -- added Poco::Net::SocketAddress::operator == () and - Poco::Net::SocketAddress::operator != () -- fixed SF# 3182746: IPAddress.cpp IPv6 bug on big-endian -- fixed SF# 3196961: Unix daemon fails to loadConfiguration() if started from cwd -- fixed SF# 3393700: NotificationCenter may call a removed observer and crash. -- Reworked implementation of the events framework (Poco::BasicEvent and friends). - The framework is now completely multithreading save (even in the case that - an event subscriber object unsubscribes and is deleted while an event is - being dispatched). Also, the restriction that any object can only register - one delegate for each event has been removed. For most cases, dispatching - events should be faster, as dispatching an event now needs less dynamic memory - allocations. -- fixed SF# 3178109: getNodeByPath() changes: - getNodeByPath() and getNodeByPathNS() have been moved to Poco::XML::Node. - Furthermore, when invoked on a Poco::XML::Document, the behavior has changed - so that the document element is now included when traversing the path (previously, - traversal would start at the document element, now it starts at the document). - The path expression can now start with a double-slash, which results in a recursive - search for the path's first element in the DOM tree. -- fixed SF# 3382935: String data being truncated using ODBC, and - SF# 2921813: Wrong implementation of the ODBC string binding - - -Release 1.4.1p1 (2011-02-08) -============================ - -- Poco::Mutex is now a recursive mutex again on Linux - (this was caused by an unfortunate feature test for - PTHREAD_MUTEX_RECURSIVE which did not work on Linux - as PTHREAD_MUTEX_RECURSIVE is an enum value and not - a macro) -- Poco::Net::SecureSocketImpl::abort() now only shuts - down the underlying socket connection and does not free - the SSL object, due to multithreading issues. - - -Release 1.4.1 (2011-01-29) -========================== - -- fixed SF# 3150223: Poco::BinaryReader cannot read std::vector correctly -- fixed SF# 3146326: SharedMemory issue -- made Poco::Net::HTTPSession::abort() virtual -- added Poco::Net::SecureStreamSocket::abort() to immediately close - a SSL/TLS connection without performing an orderly SSL/TLS shutdown. -- fixed SF# 3148126: HTTPSClientSession destructor (!) throws an IOException. - Added try/catch block to Poco::Net::SecureSocketImpl destructor. -- added additional constructor to Poco::Net::HTTPSClientSession, taking - both a socket and a session object. -- Poco::Net::HTTPSession::abort() now also can be used with a - Poco::Net::HTTPSClientSession. -- fixed SF# 3148045: make clean and distclean issues -- changed Data library names on Unix/Linux platforms to - match the names on Windows (PocoSQLite -> PocoDataSQLite, - PocoMySQL -> PocoDataMySQL, PocoODBC -> PocoDataODBC) -- added additional options to configure script -- added additional documentation to Poco::Net::HTTPClientSession -- Poco::Net::HTTPClientSession::receiveResponse() closes the connection - if an exception is thrown while reading the response header. - This ensures that a new connection will be set up for the next request - if persistent connections are used. -- improved Poco::Net::MultipartDecoder performance by reading directly from streambuf -- improved performance of Poco::Base64Encoder, Poco::Base64Decoder, - Poco::HexBinaryEncoder and Poco::HexBinaryDecoder by working directly with the - given stream's streambuf. -- improved performance of MessageHeader::read() by reading directly from streambuf - instead of istream. -- it is now possible to specify additional MIME part header fields - for a MIME part through the Poco::Net::PartSource class. -- upgraded SQLite to release 3.7.4 -- added experimental VxWorks support for VxWorks 5.5.1/Tornado 2.2 and - newer. Please see the VxWorks Platform Notes in the reference documentation - for more information. Currently, the VxWorks is untested; full support - will be available in release 1.4.2. -- fixed SF# 3165918: Poco::DynamicAny fails to convert from string to float -- fixed SF# 3165910: Poco::Net::MessageHeader does not accept HTTP conforming header -- made Poco::Task::cancel() virtual so that tasks can implement custom - cancellation behavior. -- added optional argument to Poco::Util::WinRegistryKey constructor - to specify additional flags (in addition to KEY_READ and KEY_WRITE) - for the samDesired argument of RegOpenKeyEx() or RegCreateKeyEx(). -- improved Poco::BasicEvent::notify() performance by avoiding an unnecessary heap - allocation. -- added additional well-known port numbers to Poco::URI: rtsp, sip, sips, xmpp. -- added Poco::Net::MediaType::matchesRange() -- improved invalid socket handling: a Poco::Net::InvalidSocketException is - now thrown instead of an assertion when an operation is attempted on a closed or - otherwise uninitialized socket. - - -Release 1.4.0 (2010-12-14) -========================== - -- SSLManager: documentation fixes, code cleanup -- SSLManager: renamed PrivateKeyPassPhrase event to PrivateKeyPassphraseRequired -- added HTTPServerRequestImpl::socket() to get access to the underlying socket -- added Socket::secure() to find out whether a given socket supports SSL/TLS -- added SecureStreamSocket::havePeerCertificate() -- NetSSL: added support for turning off extended certificate validation (hostname matching) -- fixed SF# 2941228: ICMPClient::ping() issues on Mac OS X -- fixed SF# 2941231: ICMPEventArgs out of bounds array access -- added PageCompiler sample -- added missing newline at end of xmlparse.c -- Poco::Glob can now be used with an empty pattern which will match nothing (patch from Kim Graesman) -- added support for HTTP proxy authentication (Basic authentication only) -- fixed SF# 2958959: XMLWriter must encode CR, LF and TAB in attribute values as character entities. -- HTMLForm now supports PUT requests as well (see ) -- fixed SF# #2970521: FileOutputStream and file permissions. - (also fixed in File class) -- removed an unused (and wrong) default parameter from EventImpl constructor for WIN32. -- added full support for session caching to NetSSL_OpenSSL -- fixed SF# 2984454: Poco::Util::Timer::scheduleAtFixedRate() works incorrectly -- fixed a bug in Poco::Util::Timer that could lead to high CPU load if - the system clock is moved forward. -- added system.nodeId to SystemConfiguration -- added a note to Poco::Util::ServerApplication documentation regarding - creation of threads -- added Poco::Net::IPAddress::broadcast() and Poco::Net::IPAddress::wildcard() to - create broadcast (255.255.255.255) and wildcard (0.0.0.0) addresses. -- fixed SF# 2916154: Poco::Net::IPAddress::isLoopback() only works for 127.0.0.1. -- added build configuration for iPhone Simulator -- GNU Make based build system provides new variables: POCO_HOST_BINDIR, POCO_HOST_BINPATH, - POCO_HOST_LIBDIR, POCO_HOST_LIBPATH and POCO_TARGET_* equivalents. -- Application::initialize() and Application::uninitialize() will now be called from within run(). - This solves various issues with uninitialize() not being called, or being called inappropriately - from the Application destructor. - Please note that this change will break applications that use the Application class, - but only call init() and not run(). -- added /startup option to specify startup mode for Windows services (automatic or manual) -- fixed SF# 2967354: SecureSocketImpl shutdown/close problem -- fixed SF# 3006340: LinearHashTable grows even if key already exists -- fixed a particularly nasty Windows error handling issue that manifested itself on WinCE: - WSAGetLastError() would be called after a std::string was created. The string creation could result - in a heap operation which called a Windows API to allocate memory. This would reset the - GetLastError() error code. Since WSAGetLastError() is just an alias for GetLastError(), the actual - error code from the socket operation would be lost. -- upgraded SQLite to 3.7.3 -- added --header-prefix option to PageCompiler -- fixed SF# 3003875: SQLite data binding is broken -- fixed SF# 2993988: Issue with multiple calls to open()/close() on File*Stream -- fixed SF# 2990256: HTMLForm and file uploads -- fixed SF# 2969227: DateTimeParser bug -- fixed SF# 2966698: Socket connect with timeout issue -- fixed SF# 2981041: Bind NULL to a query (patch supplied) -- fixed SF# 2961419: UTF8Encoding::convert() doesn't work properly in DEBUG mode -- fixed SF# 2957068: Timeout value not picked up by proxy in HTTPSClientSession -- fixed NetSSL_OpenSSL test runner for Poco::Util::Application class changes -- Poco::AbstractEvent, Poco::AbstractCache and related classes now accept a Mutex class as additional template argument. - Poco::NullMutex can be used if no synchronization is desired. -- Added Poco::AbstractEvent::empty() to check whether an event has registered delegates. -- Poco::URI now correctly handles IPv6 addresses. -- Added Poco::Nullable class template. -- Added Poco::NullMutex, a no-op mutex to be used as template argument for template classes - taking a mutex policy argument. -- Poco::XML::XMLWriter: fixed a namespace handling issue that occured with startPrefixMapping() and endPrefixMapping() -- Poco::Net::Context now allows for loading certificates and private keys from Poco::Crypto::X509Certificate objects - and Poco::Crypto::RSAKey objects. -- Poco::Crypto::RSAKey no longer uses temporary files for stream operations. Memory buffers are used instead. -- fixed SF# 2957865: added Poco::UUID::tryParse() -- All Zip classes now use Poco::File[Input|Output]Stream instead of std::[i|o]fstream. - UTF-8 filenames will now be handled correctly on Windows. -- fixed SF# 2902029: zlib flush support (Z_SYNC_FLUSH) -- added Poco::TextBufferIterator class -- fixed SF# 2977249: Use epoll instead select under Linux - Socket::select() and Socket::poll() will use epoll under Linux if the Net library is compiled - with -DPOCO_HAVE_FD_EPOLL. This is the default for the Linux build configuration (but not for - the various build configurations targeting embedded Linux platforms). -- fixed SF# 2941664: Memory leak in DeflatingStream with zero-length streams (also fixed some other potential, - but unlikely, memory leaks) -- fixed SF# 2946457: added RejectCertificateHandler -- fixed SF# 2946621: Poco::Path bug with POCO_WIN32_UTF8 -- fixed SF# 2929805: Environment::nodeId() does not work if no eth0 device exists -- Environment::nodeId() no longer throws if no hardware ethernet address can be determined. - It returns an all-zero address instead. -- Added additional classification functions to Poco::Unicode class; made classification functions inline. -- added Ascii class for ASCII character classification. - Methods of the Ascii class are now used instead of the - standard library functions (std::isspace(), etc.) due to - possible inconsistent results or assertions when the - standard library functions are used with character codes - outside the ASCII range. -- Poco::Net::MailMessage: fixed a bug in StringPartHandler that resulted in incorrect handling of non-ASCII data if - char is signed. -- Improved Poco::Net::SMTPClientSession compatibility with various mail servers when using AUTH_LOGIN authentication. -- Added CRAM-SHA1 support to Poco::Net::SMTPClientSession -- Poco::Net::SMTPClientSession now also supports login with AUTH PLAIN. -- Added Poco::Net::SecureSMTPClientSession class, supporting STARTTLS for secure SMTP connections. -- fixed an issue with SharedMemory on POSIX systems, where a shared memory region would be deleted - despite the server flag set to true (see http://pocoproject.org/forum/viewtopic.php?f=12&t=3494). -- PageCompiler: added a new page context directive, to allow passing custom context objects to the - request handler. -- fixed StreamSocketImpl::sendBytes() for non-blocking sockets -- added Poco::Net::DialogSocket::receiveRawBytes(), which should be used instead of receiveBytes() due to internal - buffering by DialogSocket. -- DOMParser: FEATURE_WHITESPACE has been renamed to FEATURE_FILTER_WHITESPACE (which now matches the underlying URI) - and is now handled correctly (previously we did the exact reverse thing) -- added Poco::Util::AbstractConfiguration::remove() to remove a configuration property; added removeRaw() implementations - to all implementations (contributions by Daniel Hobi and Alexey Shults). -- fixed NetSSL_OpenSSL compilation error on Windows with OpenSSL 1.0 -- Added optional FIPS mode support to NetSSL_OpenSSL (contributed by Lior Okman). - If OpenSSL has been configured and built with FIPS support, then FIPS support can - be enabled by calling Poco::Crypto::OpenSSLInitializer::enableFIPSMode(true); or - by setting the fips property in the OpenSSL configuration to true (see Poco::Net::SSLManager - for details). -- fixed SF# 3031530: Ping and possible no timeout -- added Poco::Net::SocketReactor::onBusy(), called whenever at least one notification will - be dispatched. -- fixed SF# 3034863: Compiler warning in net/IPAddress.h with poco 1.3.2 -- added support for CRAM-SHA1 authentication to SMTPClientSession -- Poco::format(): arguments can now be addressed by their index, e.g. %[2]d -- Poco::Util::Timer::cancel() now accepts an optional boolean argument. - If true is passed, cancel() waits until the task queue has been purged. - Otherwise, it returns immediately and works asynchronously, as before. -- Poco::Net::HTTPServerResponse::redirect() now accepts an optional additional - argument to specify the HTTP status code for the redirection. -- fixed a warning (BinaryReader.cpp) and error (ThreadLocal.cpp) in Foundation when compiling with Visual Studio 2010 -- fixed a wrong exception in Poco::Net::POP3ClientSession -- Poco::Net::FTPClientSession and Poco::Net::SMTPClientSession now set the error code in exceptions they throw -- fixed a potential race condition with terminating a Windows service based on Poco::Util::ServerApplication -- fixed a bug in global build configuration file: explicitly setting POCO_CONFIG did not work on Solaris platforms, - as it was always overridden by the automatically determined configuration. -- Added support for MinGW cross builds on Linux. -- Changed location of statically linked build products in the gmake-based build system. - Statically linked executables are now in bin/$(OSNAME)/$(OSARCH)/static and no longer - have the _s suffix -- The POCO_VERSION macro now is in its own header file, "Poco/Version.h". It is no longer - available through "Poco/Foundation.h". -- added Poco::Net::HTTPCookie::escape() and Poco::Net::HTTPCookie::unescape(). -- fixed SF# 3021173: Thread (POSIX) returns uninitialised value for OS priority -- fixed SF# 3040870: ThreadPool has no function to get assigned name -- fixed SF# 3044303: Can't use own config file on Solaris & OSARCH_64BITS ignored -- fixed SF# 2943896: AsyncChannel::log blocks -- fixed a bug in Poco::Util::WinRegistryKey::getInt(): - The size variable passed to RegQueryValueExW() should be initialized to the size - of the output buffer. -- Added rudimentary support for compiling with Clang 2.0 (Xcode 4) on Mac OS X. -- New build configurations for Mac OS X: Darwin32 and Darwin64 for explicit - 32-bit and 64-bit builds. Note that the default Darwin build configuration - will build 64-bit on Snow Leopard and 32-bit on Leopard, but will always place - build products in Darwin/i386. The new Darwin32 and Darwin64 configurations - will use the correct directories. -- fixed SF# 3051598: Bug in URL encoding -- Poco::ThreadPool::stopAll() (and thus also the destructor) will now wait for each - pooled thread to terminate before returning. This fixes an issue with creating - and orderly shutting down a thread pool in a plugin. Previously, a pooled thread - in a thread pool created by a dynamically loaded library might still be running - when the plugin's shared library was unloaded, resulting in Bad Things happening. - This can now no longer happen. As a downside, a pooled thread that fails to - finish will block stopAll() and the destructor forever. -- NetSSL_OpenSSL: for a SecureStreamSocket, available() now returns the number of bytes that - are pending in the SSL buffer (SSL_pending()), not the actual socket buffer. -- Added Poco::Net::HTTPClientSession::secure() to check for a secure connection. -- Poco::Net::HTTPRequest::setHost() now does not include the port number in the Host header - if it's either 80 or 443. -- log messages can now optionally include source file path and line number -- Poco::PatternFormatter can format source file path and line number (%U, %u) -- logging macros (poco_information(), etc.) now use __LINE__ and __FILE__ -- new logging macros that incorporate Poco::format(): poco_information_f1(logger, format, arg) with up to 4 arguments -- added Poco::Net::HTTPSession::attachSessionData() and Poco::Net::HTTPSession::sessionData() - to attach arbitrary data to a HTTP session. -- added additional constructors to zlib stream classes that allow passing - a windowBits parameter to the underlying zlib library. -- fixed a potential error handling issue in Poco::Net::SecureSocketImpl. -- fixed SF# 3110272: RSACipherImpl bug. -- fixed SF# 3081677: ConfigurationView's getRaw not retrieving xml attributes. -- added basic support for Canonical XML and better pretty-printing support to Poco::XML::XMLWriter. -- Poco::Util::AbstractConfiguration now supports events fired when changing or - removing properties. -- XML: added support for finding DOM nodes by XPath-like - expressions. Only a very minimal subset of XPath is supported. - See Poco::XML::Element::getNodeByPath(), Poco::XML::Element::getNodeByPathNS() - and the same methods in Poco::XML::Document. -- Poco::Timer: If the callback takes longer to execute than the - timer interval, the callback function will not be called until the next - proper interval. The number of skipped invocations since the last - invocation will be recorded and can be obtained by the callback - by calling skipped(). -- Poco::BinaryReader and Poco::BinaryWriter now support reading and - writing std::vectors of the supported basic types. Also, strings - can now be written in a different encoding (a Poco::TextEncoding - can be optionally passed to the constructor). -- Poco::UUID::nil() and Poco::UUID::isNil() have been renamed to - Poco::UUID::null() and Poco::UUID::isNull(), respectively, to avoid - issues with Objective-C++ projects on Mac OS X and iOS where nil is - a system-provided macro. -- Crypto bugfixes: RSACipherImpl now pads every block of data, not just the - last (or last two). -- Improved Crypto testsuite by adding new tests -- Added new Visual Studio project configurations: debug_static_mt and release_static_mt - (linking with static runtime libraries). The existing configurations debug_static - and release_static have been renamed to debug_static_md and release_static_md, respectively. - The suffixes of the static libraries have also changed. The static_md configurations - now build libraries with suffixes md[d], while the libraries built by the static_mt - configurations have mt[d] suffixes. -- Added Visual Studio project files for 64-bit builds. -- Added Visual Studio 2010 project files. -- Removed the use of local static objects in various methods due to - their construction not being threadsafe (and thus leading to - potential race conditions) on Windows/Visual C++. -- Fixed some warning on 64-bit Windows builds. -- The name of the Data connector libraries have changed. They are now - named PocoDataMySQL, PocoDataODBC and PocoDataSQLite. -- fixed SF# 3125498: Linux NetworkInterface::list() doesn't return IPv6 IPs -- fixed SF# 3125457: IPv6 IPAddress tests are wrong -- Added initialization functions for the NetSSL_OpenSSL and Crypto libraries. - These should be called instead of relying on automatic initialization, - implemented with static initializer objects, as this won't work with - statically linked executables (where the linker won't include the - static initializer object). - The functions are Poco::Crypto::initializeCrypto(), Poco::Crypto::uninitializeCrypto(), - Poco::Net::initializeSSL() and Poco::Net::uninitializeSSL(). - Applications using Crypto and/or NetSSL should call these methods appropriately at - program startup and shutdown. - Note: In release 1.3.6, similar functions have been added to the Net library. - - -Release 1.3.6p2 (2010-01-15) -============================ - -- fixed an issue in the Windows implementation Poco::RWLock, where - tryReadLock() sometimes would return false even if no writers - were using the lock (fix contributed by Bjrn Carlsson) -- added Poco::Environment::libraryVersion(). -- fixed SF# 2919461: Context ignores parameter cypherList -- removed an unused enum from RSACipherImpl.cpp (Crypto) -- integrated a new expat patch for CVE-2009-3560. -- fixed SF# 2926458: SSL Context Problem. The Poco::Net::Context - class now makes sure that OpenSSL is properly initialized. -- updated iPhone build configuration (contributed by Martin York) -- fixed SF# 1815124 (reopened): XML Compile failed on VS7.1 with - XML_UNICODE_WCHAR_T -- fixed SF# 2932647: FTPClientSession::getWorkingDirectory() returns a bad result - - -Release 1.3.6p1 (2009-12-21) -============================ - -- added support for using external zlib, pcre, expat and sqlite3 instead of - bundled ones (-DPOCO_UNBUNDLED, configure --unbundled) -- fixed SF# 2911407: Add sh4 support -- fixed SF# 2912746: RSAKey::EXP_LARGE doesn't work -- fixed SF# 2904119: abstractstrategy uses std::set but do not includes it -- fixed SF# 2909946: localtime NULL pointer -- fixed SF# 2914986: potential expat DoS security issues (CVE-2009-3560 and CVE-2009-3720) -- fixed SF# 2916305: SSL Manager crashes -- fixed SF# 2903676: Tuple TypeHander does not handle composites. - - -Release 1.3.6 (2009-11-24) -========================== - -- added Environment::processorCount() -- added POCO_VERSION macro to Poco/Foundation.h -- fixed SF# 2807527: Poco::Timer bug for long startInterval/periodic interval -- fixed a bug similar to SF# 2807527 in Poco::Util::Timer. -- fixed SF# 2795395: Constructor doesn't treat the params "key" and "iv" -- fixed SF# 2804457: DateTime::checkLimit looks wrong -- fixed SF# 2804546: DateTimeParser requires explicit RFC1123 format -- added ReleaseArrayPolicy to Poco::SharedPtr -- upgraded to SQLite 3.6.20 -- fixed SF# 2782709: Missing semicolons in "Logger.h" convenience -- fixed SF# 2526407: DefaultStrategy.h ++it instead of it++ in a loop -- fixed SF# 2502235: Poco STLPort patch -- fixed SF# 2186643: Data::Statement::reset() not implemented in 1.3.3 -- fixed SF# 2164227: Allow File opened read only by FileInputSteam to be writable -- fixed SF# 2791934: use of char_traits::copy in BufferedStreamBuf::underflow -- fixed SF# 2807750: Support additional SQL types in SQLite -- fixed documentation bugs in Timed/PriorityNotificationQueue -- fixed SF# 2828401: Deadlock in SocketReactor/NotificationCenter (also fixes patch# 1956490) - NotificationCenter now uses a std::vector internally instead of a std::list, and the mutex is - no longer held while notifications are sent to observers. -- fixed SF# 2835206: File_WIN32 not checking aganist INVALID_HANDLE_VALUE -- fixed SF# 2841812: Posix ThreadImpl::sleepImpl throws exceptions on EINTR -- fixed SF# 2839579: simple DoS for SSL TCPServer, HTTPS server - No SSL handshake is performed during accept() - the handshake is delayed until - sendBytes(), receiveBytes() or completeHandshake() is called for the first time. - This also allows for better handshake and certificate validation when using - nonblocking connections. -- fixed SF# 2836049: Possible handle leak in FileStream - If sync() fails, close() now simply set's the stream's bad bit. - In any case, close() closes the file handle/descriptor. -- fixed SF# 2814451: NetSSL: receiveBytes crashes if socket is closed -- added a workaround for Vista service network initialization issue - (an Windows service using the Net library running under Vista will - crash in the call to WSAStartup() done in NetworkInitializer). - Workaround is to call WSAStartup() in the application's main(). - Automatic call to WSAStartup() in the Net library can now be disabled - by compiling Net with -DPOCO_NET_NO_AUTOMATIC_WSASTARTUP. Also - the new Poco::Net::initializeNetwork() and Poco::Net::uninitializeNetwork() - functions can be used to call WSAStartup() and WSACleanup(), respectively, - in a platform-independent way (on platforms other than Windows, these - functions will simply do nothing). -- added VCexpress build script support (contributed by Jolyon Wright) -- fixed SF# 2851052: Poco::DirectoryIterator copy constructor is broken -- fixed SF# 2851197: IPAddress ctor throw keyword missing -- added Poco::ProtocolException -- PageCompiler improvements: new tags, support for buffered output, etc. -- better error reporting in Data MySQL connector (patch #2881270 by Jan "HanzZ" Kaluza) -- fixed SF# 1892462: FTPClient:Choose explicitely between EPSV and PASV -- fixed SF# 2806365: Option for PageCompiler to write output to different dir -- fixed a documentation bug (wrong sample code) in Process::launch() documentation -- added --header-output-dir option to PageCompiler -- fixed SF# 2849144: Zip::Decompress notifications error -- SAXParser has a new feature: "http://www.appinf.com/features/enable-partial-reads". - See ParserEngine::setEnablePartialReads() for a description of what this does. -- fixed SF# 2876179: MySQL Signed/Unsigned value bug -- fixed SF# 2877970: possible bug in timer task -- fixed SF# 2874104: wrong parsing empty http headers -- fixed SF# 2860694: Incorrect return code from SecureStreamSocketImpl::sendBytes -- fixed SF# 2849750: Possible bug with XMLWriter? -- added MailMessage::encodeWord() to support RFC 2047 word encoded - mail header fields when sending out mail containing non-ASCII - characters. -- fixed SF# 2890975: SMTPClientSession bug with 7BIT encoding -- fixed an issue with retrieving the value of socket options on Windows 7. - Before obtaining the value of a socket, we now initialize the variable receiving the - socket option value to zero. -- fixed SF# 2836141: Documentation errors -- fixed SF# 2864232: Socket::select() does not detect closed sockets on windows -- fixed SF# 2812143: Socket::select() should check socket descriptors... -- fixed SF# 2801750: NetworkInterface forName returns wrong subnetMask -- fixed SF# 2816315: Problem with POSIX Thread::sleepImpl -- fixed SF# 2795646: IPv6 address parsing bug -- fixed #0000092: ServerApplication::waitForTerminationRequest(), SIGINT and GDB. - Poco::Util::ServerApplication::waitForTerminationRequest() no longer registers a - signal handler for SIGINT if the environment variable POCO_ENABLE_DEBUGGER - is defined. -- fixed SF# 2896070: Poco::Net::Context with non-ASCII paths -- added Unicode Surrogate support to Poco::UTF16Encoding. - See Poco::TextEncoding::queryConvert() and Poco::TextEncoding::sequenceLength() - for how this is implemented. Contributed by Philippe Cuvillier. -- fixed SF# 2897650: [branch 1.3.6] Net.SocketAddress won't compile for CYGWIN -- fixed SF# 2896161: Building on Windows fails when basedir has space in it -- fixed SF# 2864380: Memory leak when using secure sockets -- NetSSL_OpenSSL: the SSL/TLS session cache is now disabled by default and - can be enabled per Context using Poco::Net::Context::enableSessionCache(). -- fixed SF# 2899039: Wrong DST handling in LocalDateTime -- added RWLock::ScopedReadLock and RWLock::ScopedWriteLock (contributed by Marc Chevrier) -- added Thread::TID type, as well as Thread::tid() and Thread::currentTid() to obtain the native - thread handle/ID -- added Zip file comment support -- On Windows, Poco::SharedLibrary::load() now uses LoadLibraryEx instead of LoadLibrary - and uses the LOAD_WITH_ALTERED_SEARCH_PATH if an absolute path is specified. This will - add the directory containing the library to the search path for DLLs that the - loaded library depends upon. -- Mac OS X build settings now match those used by default Xcode projects, making linking the - POCO libs to Xcode projects easier -- Replaced use of std::valarray in Poco::Net::ICMPEventArgs with std::vector due to issues with - std::valarray together with STDCXX debug mode on OS X - - -Release 1.3.5 (2009-05-11) -========================== - -- fixed SF# 2779410: Poco::Data::ODBC::HandleException impovement -- fixed wrong exception text for Poco::UnhandledException -- Fixed a problem with SSL shutdown that causes clients (web browsers) - to hang when the server attempts to perform a clean SSL shutdown. We now call - SSL_shutdown() once, even if the shutdown is not complete after the first call. -- added Poco::Crypto::X509Certificate::save() -- fixed a bug in Poco::Zip::Decompress that results in wrong paths for extracted files -- fixed a bug in Poco::Zip::ZipManipulator where the Zip file was opened in text format - on Windows. -- added Poco::Crypto::X509Certificate::issuedBy() to verify certificate chain. -- fixed 0000089: Thread::sleep() on Linux is extremely inaccurate -- added methods to extract the contents of specific fields from the - subject and issuer distinguished names of a certificate. - - -Release 1.3.4 (2009-04-21) -========================== - -- fixed SF# 2611804: PropertyFileConfiguration continuation lines -- fixed SF# 2529788: ServerApplication::beDaemon() broken -- fixed SF# 2445467: Bug in Thread_WIN32.cpp -- Improved performance of HTTP Server by removing some - string copy operations -- fixed SF# 2310735: HTTPServer: Keep-Alive only works with send() -- fixed appinf.com IP address in Net testsuite -- fixed RFC-00188: NumberFormatter and float/double numbers -- added --pidfile option to ServerApplication on Unix -- fixed SF# 2499504: Bug in Win32_Thread when using from dll (fixed also for POSIX threads) -- fixed SF# 2465794: HTTPServerRequestImpl memory leak -- fixed SF# 2583934: Zip: No Unix permissions set -- the NetSSL_OpenSSL library has been heavily refactored -- added NumberFormatter::append*() and DateTimeFormatter::append() functions -- use NumberFormatter::append() and DateTimeFormatter::append() instead of format() where - it makes sense to gain some performance -- added system.dateTime and system.pid to Poco::Util::SystemConfiguration -- added %F format specifier (fractional seconds/microseconds) to DateTimeFormatter, - DateTimeParser and PatternFormatter. -- fixed SF# 2630476: Thread_POSIX::setStackSize() failure with g++ 4.3 -- fixed SF# 2679279: Handling of -- option broken -- added compile options to reduce memory footprint of statically linked applications - by excluding various classes from automatically being linked. - See the POCO_NO_* macros in Poco/Config.h. -- fixed SF# 2644940: on Windows the COMPUTER-NAME and the HOSTNAME can be different -- added DNS::hostName() function -- added build configuration for iPhone (using Apple's SDK) -- basic support for AIX 5.x/xlC 8 -- fixed a bug resulting in a badly formatted exception message with IOException - thrown due to a socket-related error -- fixed SF# 2644718: NetworkInterface name conflict in MinGW -- added a missing #include to CryptoTransform.h -- fixed SF# 2635377: HTTPServer::HTTPServer should take AutoPtr -- replaced plain pointers with smart pointers in some interfaces -- upgraded to sqlite 3.6.13 -- improved Data::SQLite error reporting -- Poco::Glob now works with UTF-8 encoded strings and supports case-insensitive comparison. - This also fixes SF# 1944831: Glob::glob on windows should be case insensitve -- added Twitter client sample to Net library -- Fixed SF# 2513643: Seg fault in Poco::UTF8::toLower on 64-bit Linux -- Poco::Data::SessionPool: the janitor can be disabled by specifying a zero idle time. -- added Poco::Data::SessionPool::customizeSession() -- added support for different SQLite transaction modes (DEFERRED, IMMEDIATE, EXCLUSIVE) -- fixed a few wrong #if POCO_HAVE_IPv6 in the Net library -- added support for creating an initialized, but unconnected StreamSocket. -- added File::isDevice() -- added family() member function to SocketAddress, -- Data::SQLite: added support for automatic retries if the database is locked -- XMLConfiguration is now writable -- fixed an IPv6 implementation for Windows bug in HostEntry -- Timer class improvement: interval between callback is no longer influenced by the - time needed to execute the callback. -- added PriorityNotificationQueue and TimedNotificationQueue classes to Foundation. - These are variants of the NotificationQueue class that support priority and - timestamp-tagged notifications. -- added Poco::Util::Timer class. This implements a timer that can schedule different - tasks at different times, using only one thread. -- the signatures of Poco::NotificationQueue and Poco::NotificationCenter member functions - have been changed to accept a Poco::Notification::Ptr instead of Poco::Notification* - to improve exception safety. This change should be transparent and fully backwards - compatible. The signature of the methods returning a Poco::Notification* have not been - changed for backwards compatibility. It is recommended, that any Notification* obtained - should be immediately assigned to a Notification::Ptr. -- SQLite::SessionImpl::isTransaction() now uses sqlite3_get_autocommit() to find out - about the transaction state. -- refactored Crypto library to make it independent from NetSSL_OpenSSL. -- added support for RSA-MD5 digital signatures to Crypto library. -- removed SSLInitializer from NetSSL library (now moved to Crypto library) -- added build configs for static libraries to Crypto library -- OpenSSL now depends on Crypto library (which makes more sense than - vice versa, as it was before). Poco::Net::X509Certificate is now - a subclass of Poco::Crypto::X509Certificate (adding the verify() - member function) and the Poco::Net::SSLInitializer class was - moved to Poco::Crypto::OpenSSLInitializer. -- added build configs for static libraries to Zip -- added batch mode to CppUnit::WinTestRunner. - WinTestRunnerApp supports a batch mode, which runs the - test using the standard text-based TestRunner from CppUnit. - To enable batch mode, start the application with the "/b" - or "/B" command line argument. Optionally, a path to a file - where the test output will be written to may be given: - "/b:" or "/B:". - When run in batch mode, the exit code of the application - will denote test success (0) or failure (1). -- testsuites now also work for static builds on Windows -- The IPv6 support for Windows now basically works (Net library compiled with POCO_HAVE_IPv6) -- fixed a potential error when shutting down openssl in a statically linked application -- added static build configs to Data library -- added Poco::AtomicCounter class, which uses OS-specific APIs for atomic (thread-safe) - manipulation of counter values. -- Poco::RefCountedObject and Poco::SharedPtr now use Poco::AtomicCounter for - reference counting -- fixed SF# 2765569: LoadConfiguration failing from current directory - - -Release 1.3.3p1 (2008-10-09) -============================ - -- Fixed SF# 2153031: 1.3.3 Crypto won't compile on 64-bit Linux -- Fixed a warning in MySQL connector -- Updated README -- The global Makefile in the Zip archive is no longer broken - - -Release 1.3.3 (2008-10-07) -========================== - -- Threads now have optional user-settable stack size (if the OS supports that feature) -- Events now support simplified delegate syntax based on delegate function template. - See Poco::AbstractEvent documentation for new syntax. -- Cache supports new access expire strategy. -- Upgraded to SQLite 3.6.2 -- Upgraded to PCRE 7.8 -- added HttpOnly support to Poco::Net::HTTPCookie -- NetworkInterface now has displayName() member (useful only on Windows) -- Poco::Util::WinRegistryKey now has a read-only mode -- Poco::Util::WinRegistryKey::deleteKey() can now recursively delete registry keys -- Poco::File::created() now returns 0 if the creation date/time is not known, as - it's the case on most Unix platforms (including Linux). - On FreeBSD and Mac OS X, it returns the real creation time. -- Time interval based log file rotation (Poco::FileChannel) now works - correctly. Since there's no reliable and portable way to find out the creation - date of a file (Windows has the tunneling "feature", most Unixes don't provide - the creation date), the creation/rotation date of the log file is written into - the log file as the first line. -- added Environment::nodeId() for obtaining the Ethernet address of the system - (this is now also used by UUIDGenerator - the corresponding code from UUIDGenerator - was moved into Environment) -- added a release policy argument to SharedPtr template -- Socket::select() will no longer throw an InvalidArgumentException - on Windows when called with no sockets at all. If all three socket - sets are empty, Socket::select() will return 0 immediately. -- SocketReactor::run() now catches exceptions and reports them via - the ErrorHandler. -- SocketReactor has a new IdleNotification, which will be posted when - the SocketReactor has no sockets to handle. -- added referenceCount() method to Poco::SharedPtr. -- POCO now builds with GCC 4.3 (but there are some stupid warnings: - "suggest parentheses around && within ||". -- Solution and project files for Visual Studio 2008 are included -- The Zip library is now officially part of the standard POCO release. -- The Crypto library (based on OpenSSL) has been added. The original code - was kindly contributed by Ferdinand Beyer. -- A Data Connector to MySQL, contributed by Sergey Kholodilov, is now part - of the POCO release. -- fixed SF# 1859738: AsyncChannel stall -- fixed SF# 1815124: XML Compile failed on VS7.1 with XML_UNICODE_WCHAR_T -- fixed SF# 1867340: Net and NetSSL additional dependency not set - ws2_32.lib -- fixed SF# 1871946: no exception thrown on error -- fixed SF# 1881113: LinearHashTable does not conform to stl iterators -- fixed SF# 1899808: HTMLForm.load() should call clear() first -- fixed SF# 2030074: Cookie problem with .NET server -- fixed SF# 2009707: small bug in Net/ICMPPacketImpl.cpp -- fixed SF# 1988579: Intel Warning: invalid multibyte character sequence -- fixed SF# 2007486: Please clarify license for Data/samples/* -- fixed SF# 1985180: Poco::Net::DNS multithreading issue -- fixed SF# 1968106: DigestOutputStream losing data -- fixed SF# 1980478: FileChannel loses messages with "archive"="timestamp" -- fixed SF# 1906481: mingw build WC_NO_BEST_FIT_CHARS is not defined -- fixed SF# 1916763: Bug in Activity? -- fixed SF# 1956300: HTTPServerConnection hanging -- fixed SF# 1963214: Typo in documentation for NumberParser::parseFloat -- fixed SF# 1981865: Cygwin Makefile lacks ThreadTarget.cpp -- fixed SF# 1981130: pointless comparison of unsigned integer with zero -- fixed SF# 1943728: POCO_APP_MAIN namespace issue -- fixed SF# 1981139: initial value of reference to non-const must be an lvalue -- fixed SF# 1995073: setupRegistry is broken if POCO_WIN32_UTF8 enabled -- fixed SF# 1981125: std::swap_ranges overloading resolution failed -- fixed SF# 2019857: Memory leak in Data::ODBC Extractor -- fixed SF# 1916761: Bug in Stopwatch? -- fixed SF# 1951443: NetworkInterface::list BSD/QNX no netmask and broadcast addr -- fixed SF# 1935310: Unhandled characters in Windows1252Encoding -- fixed SF# 1948361: a little bug for win32 -- fixed SF# 1896482: tryReadLock intermittent error -- workaround for SF# 1959059: Poco::SignalHandler deadlock - the SignalHandler can now be disabled globally by adding a - #define POCO_NO_SIGNAL_HANDLER to Poco/Config.h -- fixed SF# 2012050: Configuration key created on read access -- fixed SF# 1895483: PCRE - possible buffer overflow -- fixed SF# 2062835: Logfile _creationDate is wrong -- fixed SF# 2118943: out_of_bound access in Poco::Data::BLOB:rawContent -- fixed SF# 2121732: Prevent InvalidArgumentException in SocketReactor -- fixed SF# 1891132: Poco::Data::StatementImpl::executeWithLimit is not correct -- fixed SF# 1951604: POCO refuses to compile with g++ 4.3.0 -- fixed SF# 1954327: CYGWIN's pthread does not define PTHREAD_STACK_MIN -- fixed SF# 2124636: Discrepancy between FileWIN32(U)::handleLastError -- fixed SF# 1558300: MinGW/MSYS Builds -- fixed SF# 2123266: Memory leak under QNX6 with dinkum library -- fixed SF# 2140411: ScopedUnlock documentation bug -- fixed SF# 2036460: UUID regression tests are failing on Linux with g++ 4.3.1 -- fixed SF# 2150438: Tuple TypeHandler position increment size is wrong - - -Release 1.3.2 (2008-02-04) -========================== - -Foundation, XML, Net, Util: -- added POCO_NO_SHAREDMEMORY to Config.h -- POCO_NO_WSTRING now really disables all wide string related calls -- added template specialization for string hashfunction (performance) -- XML parser performance improvements (SAX parser is now up to 40 % faster -- added parseMemoryNP() to XMLReader and friends -- URIStreamOpener improvement: redirect logic is now in URIStreamOpener. - this enables support for redirects from http to https. -- added support for temporary redirects and useproxy return code -- added getBlocking() to Socket -- added File::isHidden() -- better WIN64 support (AMD64 and IA64 platforms are recognized) -- added support for timed lock operations to [Fast]Mutex -- SharedLibrary: dlopen() is called with RTLD_GLOBAL instead of RTLD_LOCAL - (see http://gcc.gnu.org/faq.html#dso) -- Poco::Timer threads can now run with a specified priority -- added testcase for SF# 1774351 -- fixed SF# 1784772: Message::swap omits _tid mem -- fixed SF# 1790894: IPAddress(addr,family) doesn't fail on invalid address -- fixed SF# 1804395: Constructor argument name wrong -- fixed SF# 1806807: XMLWriter::characters should ignore empty strings -- fixed SF# 1806994: property application.runAsService set too late -- fixed SF# 1828908: HTMLForm does not encode '+' -- fixed SF# 1831871: Windows configuration file line endings not correct. -- fixed SF# 1845545: TCP server hangs on shutdown -- fixed SF# 1846734: Option::validator() does not behave according to doc -- fixed SF# 1856567: Assertion in DateTimeParser::tryParse() -- fixed SF# 1864832: HTTP server sendFile() uses incorrect date -- HTTPServerResponseImpl now always sets the Date header automatically - in the constructor. -- fixed SF# 1787667: DateTimeFormatter and time related classes - (also SF# 1800031: The wrong behavior of time related classes) -- fixed SF# 1829700: TaskManager::_taskList contains tasks that never started -- fixed SF# 1834127: Anonymous enums in Tuple.h result in invalid C++ -- fixed SF# 1834130: RunnableAdapter::operator= not returning a value -- fixed SF# 1873924: Add exception code to NetException -- fixed SF# 1873929: SMTPClientSession support for name in sender field -- logging performance improvements (PatternFormatter) -- fixed SF# 1883871: TypeList operator < fails for tuples with duplicate values -- CYGWIN build works again (most things work but Foundation testsuite still fails) -- new build configuration for Digi Embedded Linux (ARM9, uclibc) -- new build configuration for PowerPC Linux - -Data: -- fixed SF# 1724388: ODBC Diagnostics -- fixed SF# 1804797: ODBC Statement multiple execution fails -- fixed SF# 1803435: SessionPool onJanitorTimer called too often? -- fixed SF# 1851997: Undefined Behavior in ODBC::Preparation -- updated SQlite to 3.5.5 - - -Release 1.3.1 (2007-08-08) -========================== - -Foundation, XML, Net, Util: -- DynamicAny fixes for char conversions -- fixed SF# 1733362: Strange timeout handling in SocketImpl::poll and Socket::select -- fixed SF patch# 1728912: crash in POCO on Solaris -- fixed SF# 1732138: Bug in WinRegistryConfiguration::getString -- fixed SF# 1730790: Reference counting breaks NetworkInterface::list() -- fixed SF# 1720733: Poco::SignalHandler bug -- fixed SF# 1718724: Poco::StreamCopier::copyStream loops forever -- fixed SF# 1718437: HashMap bug -- changed LinearHashTable iterator implementation. less templates -> good thing. -- fixed SF# 1733964: DynamicAny compile error -- UUIDGenerator: fixed infinite loop with non ethernet interfaces -- updated expat to 2.0.1 -- fixed SF# 1730566: HTTP server throws exception -- Glob supports symbolic links (additional flag to control behavior) -- fixed a problem with non blocking connect in NetSSL_OpenSSL - (see http://www.appinf.com/poco/wiki/tiki-view_forum_thread.php?comments_parentId=441&topics_threshold=0&topics_offset=29&topics_sort_mode=commentDate_desc&topics_find=&forumId=6) -- fixed a problem with SSL renegotiation in NetSSL_OpenSSL (thanks to Sanjay Chouksey for the fix) -- fixed SF# 1714753: NetSSL_OpenSSL: HTTPS connections fail with wildcard certs -- HTTPClientSession: set Host header only if it's not already set (proposed by EHL) -- NetworkInterface (Windows): Loopback interface now has correct netmask; - interfaces that do not have an IP address assigned are no longer reported. -- Fixes for VC++ W4 warnings from EHL -- SharedMemory: first constructor has an additional "server" parameter - Setting to true does not unlink the shared memory region when the SharedMemory object is destroyed. (Alessandro Oliveira Ungaro) -- fixed SF# 1768231: MemoryPool constructor - -Data: -- fixed SF# 1739989: Data::RecordSet::operator = () (in 1.3 branch) -- fixed SF# 1747525: SQLite, Transactions and Session Pooling (in 1.3 branch) -- upgraded to SQLite 3.4.1 - - -Release 1.3.0 (2007-05-07) -========================== - -- added HashMap, HashSet classes -- the HashFunction class template has been changed in an incompatible - way. The member function formerly named hash() is now the function - call operator. If you have defined your own HashFunction classes, - you have to update your code. Sorry for the inconvenience. -- added Poco::Tuple -- added AbstractCache::getAllKeys(), improved performance of the get operation -- fixed AbstractCache::size() to do cache replacement before returning the size -- added additional match() method to RegularExpression and documented the fact that the simple - match() method internally sets RE_ANCHORED and RE_NOTEMPTY. -- added ExpirationDecorator template. Decorates data types so that they can be used with UniqueExpireCaches -- added operator ! to AutoPtr and SharedPtr -- Buffer uses std::size_t instead of int -- Exception::what() now returns exception name instead of message -- added poco_ndc_dbg() macro (same as poco_ndc(), but only enabled in debug builds) -- added Environment::get(name, defaultValue); -- Foundation.h now includes Config.h at the very beginning. -- added replace() and replaceInPlace() to Poco/String.h -- added AutoPtr::assign() and SharedPtr::assign() -- added operator () to AbstractEvent -- gcc Makefiles now strip release builds -- Void now has a == and != operator -- Base64Encoder and HexBinaryEncoder now support an unlimited line length - (no newlines written), by specifying a line length of 0 -- NumberParser now has stricter syntax requirements: garbage following a number leads to a SyntaxException - (Thanks to phireis@gmail.com for the suggestion) -- fixed SF# 1676830: Don't use -rpath in libraries -- fixed SF# 1670279: AbstractConfiguration::unckeckedExpand crash -- fixed a warning in Hashtable -- HTTPClientSession now uses a keepAliveTimeout for better persistent connection handling -- added DateTime::makeUTC() and DateTime::makeLocal() -- added another constructor to LocalDateTime -- POCO_WIN32_UTF8 is ignored on non-Windows platforms -- fixed a timeout bug (with NetSSL) in HTTPSession -- AsyncChannel is automatically opened with first log() -- minor fix to NotificationQueue sample (reported by Laszlo Keresztfalvi) -- added File::canExecute() and File::setExecutable() -- added SharedMemory class to Foundation -- added FileStream, FileInputStream, FileOutputStream to Foundation -- added NodeAppender class to XML for faster DOM tree creation -- HTTPServerRequest and HTTPServerResponse are now abstract base classes, - actual functionality has moved into HTTPServerRequestImpl and - HTTPServerResponseImpl. This allows us to plug other HTTP servers - into POCO. -- added DynamicAny class to Foundation -- replaced std::fstream with Poco::FileStream across POCO. -- added Poco::Checksum class to Foundation. -- fixed SF# 1700811: conflict in threadpool -- bugfix: File::moveTo() does not work if the target is a directory -- File::copyTo() and File::moveTo() now copy/move directories recursively -- refactored NetworkInterface (now using pimpl idiom); - added broadcast address and netmask support -- fixed SF# 1688982: POP3ClientSession fails when retrieving mails with attachment -- fixed SF# 1655104: Enhance Poco::TextEncoding functionality -- added Poco::Condition class, implementing a POSIX-style condition variable -- fixed a bug in File::create() for Windows -- added poco_static_assert (imported from boost) -- added Thread::join(timeout) and Thread::tryJoin() -- ClassLoader support for named manifests (see ClassLibrary.h - POCO_EXPORT_NAMED_MANIFEST) -- POCO_WIN32_UTF8: UNICODE #define is no longer required (and no longer - automatically defined in POCO_WIN32_UTF8 is defined) -- PCRE: upgraded to PCRE version 7.1 -- fixed SF# 1682162: Suggestion on thread priority -- fixed SF# 1613460: MSVC/STLPort warnings -- fixed SF# 1709358: Format double percent std::String bug -- added WindowsConsoleChannel class to Foundation -- added AutoPtr::unsafeCast<>() and SharedPtr::unsafeCast<>() -- fixed SF# 1708552: Failed to build on arm and powerpc -- fixed SF$ 1708529: Failed to build using GCC 4.3: missing #includes -- fixed SF# 1710053: LogStream proposal -- fixed a bug involving empty root directories in Windows DirectoryIterator implementation - (see http://www.appinf.com/poco/wiki/tiki-view_forum_thread.php?comments_parentId=343&forumId=6) -- robustness improvements to ActiveMethod - removed the opportunity for memory leaks in - case something goes while invoking the method -- made C library usage more C++-like - use C++ headers (e.g. ) instead of - C ones (). Also, use C library functions in std namespace. -- added Unicode and UTF8String for improved Unicode support. - The Unicode class can be used to obtain the Unicode properties of a character. - The UTF8 class provides case insensitive comparison and case conversion - for UTF-8 encoded strings. -- added UnWindows.h header file, replaced all #include with #include "Poco/UnWindows.h". - See the Poco/UnWindows.h header file for a rationale and explanations. -- fixed SF# 1713820: StreamSocketImpl::sendBytes sends too many bytes -- File::copyTo(): on Windows, the copy now always has the read-only flag reset, to be consistent - with other platforms. -- With Microsoft Visual C++, the necessary POCO libraries are now implicitly linked when - the corresponding header files are included (#pragma comment(lib, "PocoXYZ.lib") is used). - To disable this, compile POCO with the preprocessor symbol POCO_NO_AUTOMATIC_LIBS #define'd - (see Poco/Foundation.h and Poco/Config.h). -- The Visual Studio project files for the POCO libraries now include configurations - for building static libraries. - - -Release 1.2.9 (2007-02-26) -========================== - -- fixed a formatting problem in Util::HelpFormatter -- HTTPClientSession::sendRequest() now attempts to send the complete request in one network packet. -- improved network performance of ChunkedOutputStream: chunk size and chunk data - are sent in one network packet if possible -- fixed SF# 1655035: Wrong expires field calculation in HTTPCookie - (thanks to Sergey N. Yatskevich for this and other fixes) -- fixed SF# 1655049: Fix discrepancy of a code to the description -- fixed SF# 1655170: Poco::Timezone::standardName() problem on WIN32 -- fixed SF# 1629095: POCO_WIN32_UTF8 problem - There is a new function Path::transcode() that can be used to convert a path (or any other string) - from UTF-8 to the current Windows code page. This string can the be passed as a filename - to an fstream or fopen(). This function only does the conversion on Windows, - and only, if POCO_WIN32_UTF8 is defined. Otherwise, it simply returns the unmodified argument. -- fixed SF# 1659607: Probably a bug in Poco::Net::DialogSocket -- HTTPServer network performance improvement: responses that fit into a single network packet - sent with HTTPServerResponse::sendFile() or the new HTTPServerResponse::sendBuffer() are - sent in only one packet. -- added HTTPServerResponse::sendBuffer() -- HTTPServer now sends a Bad Request response if it fails to parse the HTTP request header. -- HTTPServer now sends an Internal Server Error response if the request handler throws an - exception prior to sending a response.- enabled TCP_NODELAY per default on TCPServer/HTTPServer -- fixed a bug in HTTP persistent connection handling - (server does not send Connection: close when it reaches connection maximum) -- HTMLForm - POST submission of URL encoded form no longer uses chunked transfer encoding - (thus improving interoperability with certain web servers) -- integrated Environment.cpp from Main (missing get(var, default)) -- added missing AutoPtr include to Util/Application - (and using Poco::AutoPtr is no longer necessary for POCO_APP_MAIN macro) -- fixed SF# 1635420: Per Regents of the University of Calfornia letter, - remove advertising from BSD licensed parts -- fixed SF# 1633133: MultipartWriter writes superluous CR-LF at beginning - - -Release 1.2.8 (2007-01-04) -========================== - -- fixed SF# 1613906: Util/Application.h and GCC 3.3 -- fixed a byte order issue (failed test) in IPv6 address formatting -- fixed SF# 1626640: Poco::Net::SocketReactor bug -- fixed client side chunked transfer encoding handling -- fixed client side persistent connection handling -- fixed SF# 1623536: HTTP Server Chunked Transfer Encoding Bug -- improved HTTP server exception text -- fixed SF# 1616294: KeepAlive HTTPServerSession patch -- fixed SF# 1616296: Trivial Poco::TaskCustomNotification patch -- fixed SF# 1619282: PurgeStrategy bug fix -- fixed SF# 1620855: Format problem - there is a new format specifier %z for std::size_t, as well as a new - flag ? for %d, %i, %o, %x meaning any signed or unsigned integer - - -Release 1.2.7 (2006-12-07) -========================== - -- Poco::File: fixed root directory handling -- fixed UUIDGenerator documentation -- clarified Application::setUnixOptions() documentation -- fixes for issue [SOAPLite Transport 0000023]: SOAP Transport Listener should be able to use existing HTTPServer instance -- fixing mantis issues 13, 14, 15, 16, 17, 18, 19, 21 -- fixed SF# 1597022: Signed/unsigned warning in StringTokenizer::operator[] -- fixed SF# 1598601: Message::op= leaks -- fixed SF# 1605960: PatternFormatter crashes on custom property -- fixed SF# 1605950: Memory leak in Logger sample code -- fixed SF# 1591635: Copy Paste Error in sample code -- fixed SF# 1591512: SMTPClientSession response stream -- fixed SF #1592776: LayeredConfiguration: getRaw should enumerate in reverse order -- SF Patch # 1599848 ] VS 2005 Util build fails -- Logger::dump() now uses std::size_t instead of int for buffer size -- LayeredConfiguration now supports a priority value for each configuration. - Also, it's possible to specify for each configuration added whether it - should be writeable. -- ServerApplication: cd to root directory only if running as a daemon -- added Message::swap() -- improvements to build system: - global Makefile has correct dependencies for samples - on Windows, samples build after libraries are ready - configure supports --no-wstring and --no-fpenvironment flags - build system supports POCO_FLAGS environment variable for compiler flags -- RemoteGen: fixed error handling for write protected files (SystemException) - fixing integral constant overflow messages with large cache expiration, m_ support for type serializers, - case-insensitive comparison added - - -Release 1.2.6 (2006-11-19) -========================== - -- added additional match() method to RegularExpression and documented the fact that the simple - match() method internally sets RE_ANCHORED and RE_NOTEMPTY. -- added ExpirationDecorator template. Decorates data types so that they can be used with UniqueExpireCaches -- added operator ! to AutoPtr and SharedPtr -- Buffer uses std::size_t instead of int -- added poco_ndc_dbg() macro (same as poco_ndc(), but only enabled in debug builds) -- Foundation.h now includes Config.h at the very beginning. -- added AutoPtr::assign() and SharedPtr::assign() -- added operator () to AbstractEvent -- gcc Makefiles now strip release builds -- documentation improvements - - -Release 1.2.5 (2006-10-23) -========================== - -- Improved LoggingConfigurator: channel creation and configuration is now a two-step process. - This means that the previous problems with PropertyFileConfiguration and IniFileConfiguration when referencing other channels are solved. -- improved options handling: better handling of (non) ambiguities. - If both an option named "help" and one named "helper" is specified, this no longer causes ambiguity errors. -- added check for duplicate option definition -- ThreadPool bugfix: fixed a crash that occurs on Linux multiprocessor machines - (caused by an thread unsafe string assignment corrupting the heap...) - (SF# 1575315) -- improved ThreadPool performance -- XML now compiles with -DXML_UNICODE_WCHAR_T (SF# 1575174) -- fixed SF# 1572757: HTML forms can have more than one key/value pair with the same name -- got rid of the dynamic casts in Events, Events/Cache: simpler/faster Delegate < operator, - prevents some rare dynamic casts error from occuring when using StrategyCollection with Caches -- improvements to Logger and LoggingConfigurator: - * added Logger::unsafeGet() - * added Logger::setProperty(loggerName, propertyName, value) - * LoggingConfigurator now correctly (re)configures existing Loggers - (prior to this change, if a Logger named "a.b.c" existed before - the LoggingConfigurator started its work, and the LoggingConfigurator - configured a Logger named "a.b", then "a.b.c" would not inherit - the new configuration). -- improvements to SplitterChannel and EventLogChannel configuration -- improved LoggingRegistry exception messages -- MessageHeader::read() is more liberal with malformed message headers. - This fixes problems with certain network cameras sending malformed HTTP headers. - - -Release 1.2.4 (2006-10-02) -========================== - -- some code beautifying and improvements to comments -- DOMParser now automatically sets FEATURE_NAMESPACE_PREFIXES -- fixed SF #1567051: DOMBuilder/DOMParser/NamespaceStrategy bug -- fixed SF #1567364: POCO_APP_MAIN -- added Document::getElementById() (two-argument) and getElementByIdNS() -- added another test for DOMParser -- added AutoPtr::isNull() (to be consistent with SharedPtr) -- this release again compiles on PA-RISC HP-UX systems with aCC -- added CMAKE support files contributed by Andrew J. P. Maclean - - -Release 1.2.3 (2006-09-14) -========================== - -- configure script now checks if (auto)selected configuration is supported -- fixed SF #1552904: NamedEvent bug? -- fixed SF #1552787: POCO not handling EINTR -- fixed SF #1552846: Random::~Random uses scalar delete -- fixed SF #1552987: TLSSlot should explicitly default-construct _value -- IPAddress no longer accepts an empty address string -- split up Observer.h into AbstractObserver.h and Observer.h -- added NObserver class template which supports an AutoPtr - argument for the notification callback -- changed EchoServer sample to use NObserver -- some Windows-specific files were missing in the tarballs - - -Release 1.2.2 (2006-09-01) -========================== - -- fixed SF # 1549973: NotificationCenter::hasObservers() returns wrong result -- fixed a memory leak in EchoServer sample -- fixed SocketReactor TimeoutNotification bug (SF #1549365, SocketNotifier::addObserver() incorrect behavior) -- fixed SF# 1549513: MultipartReader does not work with Unix-style linefeeds -- MailMessage and HTMLForm: processing of multipart messages will no longer fail if a PartHandler does not read all data from the part stream. -- added additional test case (Unix-style line ends) to MultipartReaderTest - - -Release 1.2.1 (2006-08-29) -========================== - -- fixed Config.h header (no more #undefs) - -Release 1.2.0 (2006-08-29) -========================== - -- DateTime fixes: Julian Day is no longer stored internally. - Times (hours, minutes, seconds, ...) are now always taken from an utcValue (if available) and not from the Julian day. - The Julian day is only used for calculating year, month and day (except when the Julian day is the only thing we have) - This helps us get rid of rounding errors that the Julian Day arithmetic introduced.- on Windows, UUIDGenerator no longer uses Netbios, but GetAdaptersInfo instead -- The main Makefile now has correct dependencies -- updated poco-doc.pl with latest version by Caleb Epstein -- fixed SF #1542722: InflatingInputStream: buffer error -- improved Windows UTF-8 support -- added Logger::names() -- added configure script and make install target -- XMLWriter bugfix: pretty-print bug with characters() and rawCharacters() -- improvements to build system: support builds outside of source tree -- added header doc conversion tool contributed by Caleb Epstein -- fixed SF #1542618 (build/config/Linux patch) -- bugfix: BinaryReader/BinaryWriter BOM is now 16 bits, as documented -- fixed SF #1542247 (Compiler warning from OptionCallback) -- fixed SF #1542253 (ServerApplication::handleOption doesn't call Application::handleOption) -- added Application::stopOptionsProcessing() -- updated samples -- Util::Application command line handling now supports: - * argument validation (Option::validator(); see Validator, IntValidator, RegExpValidator) - * binding of argument values to config properties (Option::binding()) - * callbacks for arguments (Option::callback()) - * checking of required parameters -- changed header file locations: - Foundation headers are now in Poco (#include "Poco/Foundation.h") - XML headers are now in Poco/XML, Poco/SAX and Poco/DOM (#include "Poco/XML/XML.h") - Util headers are now in Poco/Util (#include "Poco/Util/Util.h") - etc. - Unfortunately, this change will break existing code. However, fixing the code is - a matter of a few global search/replace operations and can be done quickly. - On the plus side, POCO is now a much better citizen when used with other - libraries. -- changed namespaces: - Foundation is now Poco - XML is now Poco::XML - Util is now Poco::Util - Net is now Poco::Net -- removed namespace macros -- fixed some warnings reported by gcc -Wall -Wextra -- fixed AutoPtr and LayeredConfiguration documentation -- improved StreamSocket::receiveBytes() doc -- added Pipe and PipeStream classes -- added support for I/O redirection (pipes) to Process::launch() -- added LogStream class (ostream interface to Logger) -- improved Makefiles (no more double-building if clean all is specified) -- added CppUnit and DateTime testsuite contributions by Andrew Marlow -- improved Cygwin and minimal MinGW support -- FileChannel: gzip compression if archived files now runs in a background thread (SF #1537481) -- POCO now compiles with large (64-bit) file support on Linux (SF #1536634) -- added format() function, which provides typesafe sprintf-like functionality (SF #1327621) -- added File::isLink() -- bugfix: dangling symbolic links in a directory no longer cause recursive remove to fail with file not found error -- added Void class (useful as argument to ActiveMethod) -- ActiveResult now supports exceptions -- bugfix: Timezone::utcOffset() and Timezone::dst() returned wrong values on Unix platforms (SF #1535428) -- added ActiveDispatcher class -- added ActiveStarter class, which is a policy used by ActiveMethod for starting methods -- ActiveRunnable moved to its own header file -- ThreadPool: added startWithPriority(), which allows for running threads with a different priority -- added error handling to dir sample -- added additional test case to HTTPServer test suite- HTMLForm: should now work with request methods other than POST and GET (all non-POST requests are treated the same as GET) -- clarified HTMLForm documentation -- HTMLForm bugfix: uploaded files no longer end up in value; PartHandler is called instead -- NameValueCollection: added get(name, defaultValue) -- added HTTPFormServer sample -- added Foundation::HashTable and SimpleHashTable -- added Net::HTTPSessionFactory -- improvements to AutoPtr and SharedPtr -- improvements to namespaces handling in XMLWriter -- Foundation Cache: fixed add implementation to match the docu: a 2nd add will now simply overwrite existing entries -- added DateTime::isValid() -- added Exception::rethrow() (virtual, must be overridden by all subclasses) -- Timer can now use a user-supplied ThreadPool -- added rethrow() to exception classes -- Net: made some constructors explicit -- Net: added SocketAddress constructor to HTTPClientSession -- Net: added HTTPSession::networkException() to check for exceptions swallowed by stream classes -- Net: added single string argument constructor to SocketAddress. -- Net: improved HTTPClientSession error handling (no more "Invalid HTTP version string" exceptions when the server prematurely closes the connection due to too much load) -- Net: improved HTTPSession error handling. Exceptions while sending and receiving data are stored for later retrieval and no longer get lost since streambufs swallow them. -- Net: added HTTPLoadTest sample -- fixed a bug when opening logfiles on Unix platforms causing an existing logfile to be truncated -- bugfix: log file purge intervals given in months did not work, due to a stupid typo -- added RawSocket and ICMP classes -- UUID: fixed a doc formatting bug -- NetworkInterface::list() now includes loopback interface on Windows (SF #1460309) -- made Exception::message() and Exception::nested() inline -- added Net::UnsupportedRedirectException -- HTTPStreamFactory throws an UnsupportedRedirectException if it encounters a redirect to https -- HTTP: fixed bad 100 Continue handling in client and server code -- added CONTRIBUTORS file - - -Release 1.1.2 (2006-07-07) -========================== - -- Changed license to Boost license -- DBlite and NetSSL have been removed from the Boost-licensed release. - Please contact Applied Informatics (info@appinf.com) if you're interested in them. - - -Release 1.1.1 (2006-04-03) -========================== - -- NetSSL_OpenSSL now supports separate certificate verification - settings for client and server. -- fixed SF #1460309 (enumerating network interfaces failed on 64bit Linux) -- TCPServer no longer crashes if accept() fails - - -Release 1.1.0 (2006-03-23) -========================== - -- events no longer require awkward += new syntax -- source code and documentation cleanups -- basic support for new compilers and platforms - - -Release 1.1b2 (2006-03-04) -========================== - -- made NetSSL threadsafe (added locking callbacks for OpenSSL) -- improved OpenSSL initialization (random generator seeding) -- various changes to improve compatibility with various platforms - - -Release 1.1b1 (2006-03-03) -========================== - -- New Events package in Foundation. The package supports C#-style event handling -- New Cache package in Foundation: a templates-based caching framework -- added Any class to Foundation -- added DBLite library -- fixed a memory leak with layered configurations in the application -- made POCO_DLL the default (unless POCO_STATIC is #defined) - It is no longer necessary to specify POCO_DLL in projects that use Poco - (SourceForge Patch #1408231 and Feature Request #1407575). -- added Buffer template class to Foundation -- added the UnicodeConverter utility class. This is mainly used for Windows Unicode support and probably of little use for anything else. -- added Path::resolve() -- added Windows Unicode support. This calls the Unicode variant of the Windows API functions. - For this to work, all strings must be UTF-8 encoded and POCO_WIN32_UTF8 must be defined in all compilation units. -- added StreamCopier::copyToString() -- added URIStreamOpener::unregisterStreamFactory() and new variants of URIStreamOpener::open() that also work with filesystem paths. - This fixes SourceForge Bug #1409064 and Feature Request #1409062. -- added NodeIterator::currentNodeNP() to XML library -- added some sanity checks to UTF8Encoding::convert() -- added NetSSL - SSL support for Net library, based on OpenSSL -- console output of processes launched with Process::launch() is now visible - - -Release 1.0.0 (2006-01-19) -========================== - -- removed unnecessary console output from ProcessTest -- documentation fixes - - -Release 1.0b2 (2006-01-16) -========================== - -- added ProcessHandle class -- Process::launch() now returns a ProcessHandle instead of a process ID. - This fixes a potential problem on Windows with Process::wait() when - the process terminates before wait() is called. -- added SplitterChannel::close() -- added Logger::destroy() -- added POP3ClientSession::deleteMessage() -- added test for Process::launch() -- documentation fixes - - -Release 1.0b1 (2006-01-09) -========================== - -- improved recognition of Windows paths in Path::parseGuess() -- added setCurrentLineNumber()/getCurrentLineNumber() to CountingStreamBuf -- improvememts to StreamTokenizer and Token; fixed documentation -- added a workaround for some strange istream behaviour with VS 2005 and FTPClientSessionTest -- improved exception/error reporting in cppunit -- added POP3ClientSession -- added Process::launch() and Process::wait() -- added Mail sample -- added MailStream and SMTPClientSession classes -- renamed some methods in DialogSocket to make them more general -- NullPartHandler has moved out of HTMLForm.cpp into a separate file -- Base64Encoder now always writes \r\n line ends -- MessageHeader::quote has an optional addition arg controlling the treatment of whitespace -- bugfix: MultipartReader had a problem with empty lines (\r\n sequences) in a part -- added MailMessage and MailRecipient classes -- added text encoding support for Windows-1252 codepage - - -Release 1.0a1 (2006-01-03) [internal] -===================================== - -- mediaType is used consistently to refer to a MIME media type (some occurences of contentType and mimeType have been replaced) -- moved MediaType::quote() to MessageHeader and made it public -- added MultipartWriter::stream() -- Renamed AttachmentSource to PartSource and AttachmentHandler to PartHandler -- SIGPIPE is always blocked in main thread on Unix systems -- added EchoServer sample -- fixed a bug in SocketImpl::setBlocking() - did exactly the opposite (value to ioctl was wrong) -- fixed a memory leak in NotificationQueue sample -- added comparison operators to Socket so that Sockets can be used as keys in maps -- added Socket::setBlocking() -- added StreamSocket::connectNB() (non-blocking connect) -- added Observer::accepts() -- added SocketReactor, SocketConnector and SocketAcceptor classes to support event-based socket programming -- NamespacePrefixesStrategy now uses expat's XML_SetReturnNSTriplet(). - The previously used separate namespace handling code has been removed. - This improves performance if NamespacePrefixesStrategy is used (both the n - amespaces and namespace-prefixes SAX2 features are used) -- upgraded expat to 2.0 pre-release (2005-12-27) snapshot -- added TeeInputStream and TeeOutputStream classes -- added download sample for URIStreamOpener -- renamed registerOpener() to registerFactory() in HTTPStreamFactory and FTPStreamFactory -- added LineEndingConverter streams -- added FTPClientSession -- code and documentation clean-up -- added DialogSocket class -- reorganized HTTP test suites -- added FTPClientSession and FTPStreamFactory -- added DialogSocket class - - -Release 0.96.1 (2005-12-28) -=========================== - -- fixed a memory leak caused by a bug in Microsoft's stream implementation (see the comment in Foundation/StreamUtil.h for an explanation) -- added samples for Net library -- added uptime() and startTime() to Util::Application -- added DateTimeFormatter::format() for Timespan -- added ErrorHandler class and better exception handling for threads -- added poco_debugger() and poco_debugger_msg() macros -- added project and solution files for Visual Studio 2005 (due to some bugs/leaks in Microsofts standard library - see - http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=e08bd793-3fef-40ff-adda-ed313e0eafcc - we do not recommend using this for production purposes) -- fixed two problems with out-of-range string iterator in Path (the testsuite triggered an assertion in VC++ 8.0) -- fixed mac line endings in a few files -- added a workaround to the class loader that fixes strange behavior with VC++ 8.0. There seems to be a problem with typeid() not returning a valid typeinfo under certain circumstances. -- added buffer allocator argument to buffered stream buffer templates -- added buffer pools to HTTP to reduce memory fragmentation and to improve performance -- added Net to Windows build.cmd script -- added swap() to various classes that already support assignment -- added a null pointer check in DOMWriter::writeNode() -- fixed documentation in BinaryWriter.h and BinaryReader.h -- added explicit support for network byte order to BinaryReader and BinaryWriter -- added basic support for FreeBSD (needs more testing) -- BinaryReader: renamed readRawData() to readRaw() to be consistent with BinaryWriter::writeRaw() -- added support for uppercase output to HexBinaryEncoder. -- added MediaType class -- added QuotedPrintableEncoder and QuotedPrintableDecoder classes -- renamed ObjectFactory to Instantiator. This should prevent the confusion caused by DynamicFactory and ObjectFactory. Sorry for the inconvenience if you are already using this. -- AttachmentSource::filename() now returns const string& -- added StringAttachmentSource -- replaced old-style C casts with C++ casts in NetworkInterface.cpp -- MutexImpl (WIN32): replaced InitializeCriticalSection with InitializeCriticalSectionAndSpinCount, which should increase performance on multiprocessor or multicore systems when many locks are used. -- fixed a problem with STLport 5.0 when compiling StreamTokenizer -- HTTPStreamOpener now also works with no-path URIs (like http://www.appinf.com) -- fixed wrong delete usage (plain delete instead of delete [] was used in a few cases) -- fixed a handle leak in WinTestRunner - - -Release 0.95.4 (2005-11-07) -=========================== - -- fixed #1348006 and #1348005 - - -Release 0.95.3 (2005-10-28) [internal] -====================================== - -- updated build scripts (patch #1339015) -- added support for AMD64 platforms (patch #1339015) -- MultipartWriter creates its own boundary if an empty string is passed in as boundary -- made MultipartWriter::createBoundary() public -- fixed wrong documentation for DateTimeFormat::HTTP_FORMAT -- added support for HTTP Basic authentication -- added support for HTTP Cookies -- added support for HTML forms - - -Release 0.95.2 (2005-10-22) [internal] -====================================== - -- fixed a potential problems with streams when close in destructor fails (added try..catch block around close in destructors) -- added HTTPServer & friends -- added hasIdleThreads() method to NotificationQueue -- added TCPServer and friend -- added support for HTTP proxies to HTTPClientSession and HTTPStreamOpener -- fixed documentation bugs (Mutex.h, ClassLoader.h) - - -Relesae 0.95.1 (2005-10-15) [internal] -====================================== - -- Tasks can now throw custom notifications (contributed by Alex Fabijanic) -- renamed URIFileStreamFactory to FileStreamFactory -- added a few methods to URI (setPathEtc(), getPathEtc(), getPathAndQuery()) -- added new exception classes -- fixed some documentation -- added basic checks when reading a MessageHeader from a stream -- added HTTP classes (testsuite still incomplete) -- added MessageHeader, NameValueCollection, MultipartReader and MultipartWriter classes -- added Timespan::useconds() -- added ClassLoader::isLibraryLoaded() -- Socket classes use Timespan::useconds() to fill struct timeval -- added DatagramSocket, MulticastSocket and NetworkInterface classes -- added socket classes and related basic stuff -- added additonal constructor/assign to Timespan- added BasicBufferedBidirectionalStreamBuf -- fixed a potential MT issue in Base64Decoder -- code beautifying in [Un]BufferedStreamBuf -- more improvements to ClassLoader -- code cleanup and naming convention fixes (changed all *Imp classes to *Impl for consistency) - - -Release 0.94.1 (2005-09-30) [internal] -====================================== - -- added MetaSingleton (based on a contribution by Alex Fabijanic) -- added ClassLoader::create() -- added ClassLoader::instance() -- code clean-ups in FileChannel and related classes -- added SimpleFileChannel -- RotateAtTimeStrategy: - ::getNextRollover() rewritten (buggy) -- DateTime - microseconds assert corrected - asserts in computeGregorian() (except for year - see comment in computeGregorian()) - milliseconds calculation modified in computeGregorian() - microseconds assigned in computeGregorian() - normalize() and checkLimit() private functions to correct cases of overflow for milli/microseconds -- LocalDateTime: added timestamp() method -- FileChannel: - added "times" property (used to determine whether to use UTC or local time with RotateAtTimeStrategy) - ::setProperty() modified (whenever "times" property is set, methods setRotation and setArchive are - reinvoked to reflect the change) -- FileChannel: added support for archived file compression and archived file purging -- FileChannel tests modified -- FileChannel: put LogFile, RotateStrategy and ArchiveStrategy into their own files -- Message: added thread id field -- PatternFormatter: added %I specifier for thread id -- ThreadPool: PooledThread can be assigned a name -- TaskManager: task name is reflected in thread name -- fixed LocalDateTime::operator - (const Timespan&) [#0000004] -- upon startup all loggers' channels are set to a console channel -- improved search for application configuration files (see loadConfiguration()). -- added Glob class (fixes #1249700) -- upgraded to zlib 1.2.3 (fixes #1261712) -- added Logger::dump() -- fixed a wrong condition in Logger::log(const Message&) -- Path::find() now also works with relative paths in addition to plain file names -- added Path(const Path&, const Path&) constructor -- added SharedPtr template -- added Path::tryParse() -- SAXParser::parse()/EntityResolverImpl now works for both URIs and local filesystem paths (fixes #1254812) - - -Release 0.93.1 (2005-08-01) -=========================== - -This release contains various new features, improvements and bugfixes: -- bugfix: UUIDGenerator throws an exception if no connected ethernet adapter can - be found (and thus no MAC address can be obtained) -- added UUIDGenerator::createOne() method -- added error handling to UUID sample application -- added relational (==, !=, <, <=, >, >=) and arithmetic operators (+, -, +=, -=) to DateTime -- added LocalDateTime class -- added support for LocalDateTime to DateTimeParser and DateTimeFormatter -- added enqueueUrgentNotification() to NotificationQueue -- added support for timezone specifiers (%z, %Z) to PatternFormatter -- added [] operator and count() to StringTokenizer -- added elapsed() and isElapsed() to Timestamp -- added tzd() to Timezone -- added WinRegistryKey and WinService classes (Windows only) -- added index operator and count() to StringTokenizer -- added day/time-based log rotation (thanks to Alex Fabijanic), minor improvements to DateTimeParser -- support for Mac OS X 10.4/gcc 4.0.0 -- added NamedMutex and NamedEvent -- added Process::kill() -- added NoPermissionException -- added Task and TaskManager classes -- added ServerApplication class -- bugfix: EventLogChannel - _logFile was not properly initialized in one constructor -- bugfix: File::createDirectories did not work for hierarchies deeper than three -- added Util::FilesystemConfiguration -- documented logging policy: log() must open channel if it hasn't been opened yet -- FileChannel::log() opens channel if necessary -- the application reference passed to initialize() and reinitialize() is no longer const -- improved application logging initialization -- fixed a problem with configuration view and property placeholders -- fixed Util build configuration for Visual Studio -- improved application samples -- fixed documentation for Semaphore class - - -Release 0.92.1 (2005-05-09) -=========================== - -This release introduces the Util library that provides support for -configuration file parsing (different file formats), command line -argument processing, logging configuration and a framework for -command line/server applications. -There have also been various changes to the Foundation library: -- a new RefCountedObject class that acts as a base class for - various classes that use reference counting -- some missing members have been added to the AutoPtr template -- various improvements and bugfixes to the Logging framework, as well as - new LoggingFactory and LoggingRegistry classses, and a NullChannel class -- the SignalHandler class (Unix platforms only) -- ObjectFactory and DynamicFactory template classes -- the Path::find method for searching a file in a list of directories -- various new Exception classes - - -Release 0.91.4 (2005-04-11) -=========================== - -This is mainly a maintenance release that adds support for QNX Neutrino -and OpenVMS. There are also minor bugfixes and improvements. - -The Unix build system has been modified to work on QNX Neutrino. -The OpenVMS build system has been fixed and works now. -Some missing #include's have been added for QNX Neutrino. -Foundation/String.h: icompare now supports comparison with const char*; -the classic C version of isspace() has been used in a few places instead of the -C++ version, this has been fixed. -Foundation/Exception.h: IllegalStateException added. - - -Release 0.91.3 (2005-03-19) -=========================== - -This is a maintenance release that adds support for Solaris/Sun Forte C++. -No new features have been added. - -An implementation of FPEnvironment for Solaris has been included. -All stream classes have been modified to work around an initialization -problem that surfaced with Sun's C++ compiler when using STLport. -Source-code compatibility with the previous release is not affected. Various -minor changes, mostly adding missing #include's for Solaris. - - -Release 0.91.2 (2005-02-27) -=========================== - -Minor improvements to the Unix build system. No actual changes in the -libraries. - - -Release 0.91.1 (2005-02-21) -=========================== - -This is the first public release of the C++ Portable Components. -The release does not contain all features planned for the later 1.0 release -(the NET library is missing, for example), but is already quite usable. -Please refer to the README file for more information and instructions for -building the libraries. - - --- -$Id: //poco/1.4/dist/CHANGELOG#59 $ diff --git a/contrib/libpoco/CMakeLists.txt b/contrib/libpoco/CMakeLists.txt deleted file mode 100644 index 2baa9dbd82c..00000000000 --- a/contrib/libpoco/CMakeLists.txt +++ /dev/null @@ -1,317 +0,0 @@ -cmake_minimum_required(VERSION 2.8.0) - -# POCO_BUILD_TYPE -# POCO_STATIC -# POCO_UNBUNDLED -# POCO_NO_LOCALE -# -# POCO_ENABLE_{COMPONENT} -# POCO_ENABLE_TESTS - -project(Poco) - -file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/libversion" SHARED_LIBRARY_VERSION) - -# Read the version information from the VERSION file -file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" PACKAGE_VERSION ) -message(STATUS "Poco package version: ${PACKAGE_VERSION}") -string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${PACKAGE_VERSION}) -string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${PACKAGE_VERSION}) -string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_PATCH ${PACKAGE_VERSION}) - -set(COMPLETE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}) -set(RELEASE_NAME "Unstable-trunk") -set(PROJECT_VERSION ${COMPLETE_VERSION}) - -# Put the libaries and binaries that get built into directories at the -# top of the build tree rather than in hard-to-find leaf -# directories. This simplifies manual testing and the use of the build -# tree rather than installed Boost libraries. -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) -# Windows DLLs are "runtime" for CMake. Output them to "bin" like the Visual Studio projects do. -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) - -# Append our module directory to CMake -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -################################################################################# -# Setup C/C++ compiler options -################################################################################# - -if(NOT MSVC_IDE) - if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING - "Choose the type of build, options are: None Debug Release" FORCE) - endif() - message(STATUS "Setting Poco build type - ${CMAKE_BUILD_TYPE}") -endif() - -if (CMAKE_BUILD_TYPE STREQUAL "") - set( CMAKE_BUILD_TYPE "RelWithDebInfo" ) -endif () - -# http://www.cmake.org/Wiki/CMake_Useful_Variables : -# CMAKE_BUILD_TYPE -# Choose the type of build. CMake has default flags for these: -# -# * None (CMAKE_C_FLAGS or CMAKE_CXX_FLAGS used) -# * Debug (CMAKE_C_FLAGS_DEBUG or CMAKE_CXX_FLAGS_DEBUG) -# * Release (CMAKE_C_FLAGS_RELEASE or CMAKE_CXX_FLAGS_RELEASE) -# * RelWithDebInfo (CMAKE_C_FLAGS_RELWITHDEBINFO or CMAKE_CXX_FLAGS_RELWITHDEBINFO -# * MinSizeRel (CMAKE_C_FLAGS_MINSIZEREL or CMAKE_CXX_FLAGS_MINSIZEREL) - -# For Debug build types, append a "d" to the library names. -set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix" FORCE) - -# Include some common macros to simpilfy the Poco CMake files -include(PocoMacros) - -# Allow enabling and disabling components -option(POCO_ENABLE_XML "Enable the XML" ON) -option(POCO_ENABLE_MONGODB "Enable MongoDB" ON) -option(POCO_ENABLE_PDF "Enable PDF" OFF) -option(POCO_ENABLE_UTIL "Enable Util" ON) -option(POCO_ENABLE_NET "Enable Net" ON) -option(POCO_ENABLE_NETSSL "Enable NetSSL" ON) -option(POCO_ENABLE_NETSSL_WIN "Enable NetSSL Windows" OFF) -option(POCO_ENABLE_CRYPTO "Enable Crypto" ON) -option(POCO_ENABLE_DATA "Enable Data" ON) -option(POCO_ENABLE_DATA_SQLITE "Enable Data SQlite" OFF) -option(POCO_ENABLE_DATA_MYSQL "Enable Data MySQL" OFF) -option(POCO_ENABLE_DATA_ODBC "Enable Data ODBC" ON) -option(POCO_ENABLE_SEVENZIP "Enable SevenZip" OFF) -option(POCO_ENABLE_ZIP "Enable Zip" OFF) -option(POCO_ENABLE_APACHECONNECTOR "Enable ApacheConnector" OFF) -option(POCO_ENABLE_CPPPARSER "Enable C++ parser" OFF) -option(POCO_ENABLE_POCODOC "Enable Poco Documentation Generator" OFF) - -option(FORCE_OPENSSL "Force usage of OpenSSL even under windows" OFF) - -option(POCO_ENABLE_TESTS - "Set to OFF|ON (default is OFF) to control build of POCO tests & samples" OFF) - -option(POCO_STATIC - "Set to OFF|ON (default is ON) to control build of POCO as STATIC library" ON) - -option(POCO_UNBUNDLED - "Set to OFF|ON (default is OFF) to control linking dependencies as external" OFF) - -# Uncomment from next two lines to force statitc or dynamic library, default is autodetection -if (POCO_STATIC) - add_definitions( -DPOCO_STATIC -DPOCO_NO_AUTOMATIC_LIBS) - set( LIB_MODE STATIC ) - message(STATUS "Building static libraries") -else (POCO_STATIC) - set( LIB_MODE SHARED ) - message(STATUS "Building dynamic libraries") -endif (POCO_STATIC) - -if (POCO_ENABLE_TESTS) - include(CTest) - enable_testing() - message(STATUS "Building with unittests & samples") -else () - message(STATUS "Building without tests & samples") -endif () - -if (POCO_UNBUNDLED) - add_definitions( -DPOCO_UNBUNDLED) - message(STATUS "Build with using external sqlite, pcre, expat ...") -else () - message(STATUS "Build with using internal copy of sqlite, pcre, expat, ...") -endif () - -include(CheckTypeSize) -find_package(Cygwin) - -# OS Detection -if(WIN32) - add_definitions( -DPOCO_OS_FAMILY_WINDOWS -DUNICODE -D_UNICODE) - #set(SYSLIBS iphlpapi gdi32 odbc32) -endif(WIN32) - -if (UNIX AND NOT ANDROID ) - add_definitions( -DPOCO_OS_FAMILY_UNIX ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field -Wno-unused-local-typedef -Wno-for-loop-analysis -Wno-unknown-pragmas -Wno-unused-variable") - if (APPLE) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") - endif () - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas -Wno-unused-variable") - # Standard 'must be' defines - if (APPLE) - add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64) - set(SYSLIBS ${CMAKE_DL_LIBS}) - elseif (CMAKE_SYSTEM MATCHES "FreeBSD") - add_definitions(-D__BSD_VISIBLE ) # better #include - add_definitions(-D_XOPEN_SOURCE=700 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_IPv6 -DPOCO_HAVE_FD_POLL) - set(SYSLIBS pthread ${CMAKE_DL_LIBS} rt) - else () - add_definitions(-D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -DPOCO_HAVE_IPv6) - set(SYSLIBS pthread ${CMAKE_DL_LIBS} rt) - endif () -endif(UNIX AND NOT ANDROID ) - -if (CMAKE_SYSTEM MATCHES "SunOS") - add_definitions( -DPOCO_OS_FAMILY_UNIX ) - # Standard 'must be' defines - add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ) - set(SYSLIBS pthread socket xnet nsl resolv rt ${CMAKE_DL_LIBS}) -endif(CMAKE_SYSTEM MATCHES "SunOS") - -if (CMAKE_COMPILER_IS_MINGW) - add_definitions(-DWC_NO_BEST_FIT_CHARS=0x400 -DPOCO_WIN32_UTF8) - add_definitions(-D_WIN32 -DMINGW32 -DWINVER=0x500 -DODBCVER=0x0300 -DPOCO_THREAD_STACK_SIZE) -endif (CMAKE_COMPILER_IS_MINGW) - -if (CYGWIN) -# add_definitions(-DWC_NO_BEST_FIT_CHARS=0x400 -DPOCO_WIN32_UTF8) -endif (CYGWIN) - -# SunPro C++ -if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") - add_definitions( -D_BSD_SOURCE -library=stlport4) -endif (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") - -# iOS -if (IOS) - add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES ) -endif (IOS) - -#Android -if (ANDROID) - add_definitions( -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY ) -endif (ANDROID) - - -# Collect the built libraries and include dirs, the will be used to create the PocoConfig.cmake file -set (Poco_COMPONENTS "") - -if (POCO_ENABLE_TESTS) - add_subdirectory (CppUnit) -endif () - -add_subdirectory (Foundation) -if (POCO_ENABLE_XML) - add_subdirectory (XML) - list (APPEND Poco_COMPONENTS "XML") -endif () -if (POCO_ENABLE_MONGODB) - add_subdirectory (MongoDB) - list (APPEND Poco_COMPONENTS "MongoDB") -endif () -if (POCO_ENABLE_PDF) - add_subdirectory (PDF) - list (APPEND Poco_COMPONENTS "PDF") -endif() -if (POCO_ENABLE_UTIL) - add_subdirectory (Util) - list (APPEND Poco_COMPONENTS "Util") -endif () -if (POCO_ENABLE_NET) - add_subdirectory (Net) - list (APPEND Poco_COMPONENTS "Net") -endif () - - -#NetSSL - - -if(WIN32 AND POCO_ENABLE_NETSSL_WIN) - add_subdirectory(NetSSL_Win) - list(APPEND Poco_COMPONENTS "NetSSL_Win") -endif(WIN32 AND POCO_ENABLE_NETSSL_WIN) - -find_package(OpenSSL) -if(OPENSSL_FOUND) - include_directories("${OPENSSL_INCLUDE_DIR}") - if(POCO_ENABLE_NETSSL) - add_subdirectory(NetSSL_OpenSSL) - list(APPEND Poco_COMPONENTS "NetSSL_OpenSSL") - endif() - if(POCO_ENABLE_CRYPTO) - add_subdirectory(Crypto) - list(APPEND Poco_COMPONENTS "Crypto") - endif() -endif(OPENSSL_FOUND) - -if(POCO_ENABLE_DATA) -add_subdirectory(Data) -list(APPEND Poco_COMPONENTS "Data") -endif() -if(POCO_ENABLE_SEVENZIP) -add_subdirectory(SevenZip) -list(APPEND Poco_COMPONENTS "SevenZip") -endif() -if(POCO_ENABLE_ZIP) -add_subdirectory(Zip) -list(APPEND Poco_COMPONENTS "Zip") -endif() - -find_package(APR) -find_package(Apache2) -if(APRUTIL_FOUND AND APACHE_FOUND) - include_directories( "${APACHE_INCLUDE_DIR}" "${APRUTIL_INCLUDE_DIR}" ) - if(POCO_ENABLE_APACHECONNECTOR) - add_subdirectory(ApacheConnector) - list(APPEND Poco_COMPONENTS "ApacheConnector") - endif() -endif(APRUTIL_FOUND AND APACHE_FOUND) - -if(POCO_ENABLE_CPPPARSER) -add_subdirectory(CppParser) -list(APPEND Poco_COMPONENTS "CppParser") -endif() - -if(POCO_ENABLE_POCODOC) -add_subdirectory(PocoDoc) -list(APPEND Poco_COMPONENTS "PocoDoc") -endif() - -############################################################# -# Uninstall stuff see: http://www.vtk.org/Wiki/CMake_FAQ -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY) - -add_custom_target(uninstall - "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") - -############################################################# -# Enable packaging - -include(InstallRequiredSystemLibraries) - -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Poco Libraries") -set(CPACK_PACKAGE_VENDOR "Applied Informatics Software Engineering GmbH") -set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") -set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr/local") - -include(CPack) - -############################################################# -# cmake config files - -configure_file(cmake/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" @ONLY) -install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake - DESTINATION - "lib/cmake/${PROJECT_NAME}" - COMPONENT - Devel -) - -# in tree build settings -#configure_file(PocoBuildTreeSettings.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/PocoBuildTreeSettings.cmake @ONLY) - - -message(STATUS "CMake ${CMAKE_VERSION} successfully configured ${PROJECT_NAME} using ${CMAKE_GENERATOR} generator") -message(STATUS "Installation target path: ${CMAKE_INSTALL_PREFIX}") - -foreach(component ${Poco_COMPONENTS}) -message(STATUS "Building: ${component}") -endforeach() - diff --git a/contrib/libpoco/CONTRIBUTORS b/contrib/libpoco/CONTRIBUTORS deleted file mode 100644 index 4ef48d2a2ad..00000000000 --- a/contrib/libpoco/CONTRIBUTORS +++ /dev/null @@ -1,53 +0,0 @@ -Guenter Obiltschnig -Alex Fabijanic -Peter Schojer -Ferdinand Beyer -Krzysztof Burghardt -Claus Dabringer -Caleb Epstein -Eran Hammer-Lahav -Chris Johnson -Sergey Kholodilov -Ryan Kraay -Larry Lewis -Andrew J. P. Maclean -Andrew Marlow -Paschal Mushubi -Jiang Shan -David Shawley -Sergey Skorokhodov -Tom Tan -Sergey N. Yatskevich -Marc Chevrier -Philippe Cuvillier -Marian Krivos -Franky Braem -Philip Prindeville -Anton Yabchinskiy -Rangel Reale -Fabrizio Duhem -Patrick White -Mike Naquin -Roger Meier -Mathaus Mendel -Arturo Castro -Adrian Imboden -Matej Knopp -Patrice Tarabbia -Lucas Clemente -Karl Reid -Pascal Bach -Cristian Thiago Moecke -Sergei Nikulov -Aaron Kaluszka -Iyed Bennour -Scott Davis -Kristin Cowalcijk -Yuval Kashtan -Christopher Baker -Scott Davis -Jeff Adams -Martin Osborne -Björn Schramke --- -$Id$ diff --git a/contrib/libpoco/CppUnit/WinTestRunner/include/WinTestRunner/WinTestRunner.h b/contrib/libpoco/CppUnit/WinTestRunner/include/WinTestRunner/WinTestRunner.h deleted file mode 100644 index 2e7ac701443..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/include/WinTestRunner/WinTestRunner.h +++ /dev/null @@ -1,77 +0,0 @@ -// -// WinTestRunner.h -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/include/WinTestRunner/WinTestRunner.h#1 $ -// -// Application shell for CppUnit's TestRunner dialog. -// - - -#ifndef WinTestRunner_H_INCLUDED -#define WinTestRunner_H_INCLUDED - - -#if !defined(POCO_STATIC) -#if defined(WinTestRunner_EXPORTS) -#define WinTestRunner_API __declspec(dllexport) -#else -#define WinTestRunner_API __declspec(dllimport) -#endif -#else -#define WinTestRunner_API -#endif - - -#include "CppUnit/CppUnit.h" -#include -#include - - -namespace CppUnit { - - -class Test; - - -class WinTestRunner_API WinTestRunner -{ -public: - WinTestRunner(); - ~WinTestRunner(); - - void run(); - void addTest(Test* pTest); - -private: - std::vector _tests; -}; - - -class WinTestRunner_API WinTestRunnerApp: public CWinApp - /// A simple application class that hosts the TestRunner dialog. - /// Create a subclass and override the TestMain() method. - /// - /// WinTestRunnerApp supports a batch mode, which runs the - /// test using the standard text-based TestRunner from CppUnit. - /// To enable batch mode, start the application with the "/b" - /// or "/B" argument. Optionally, a filename may be specified - /// where the test output will be written to: "/b:" or - /// "/B:". - /// - /// When run in batch mode, the exit code of the application - /// will denote test success (0) or failure (1). -{ -public: - virtual BOOL InitInstance(); - - virtual void TestMain() = 0; - - DECLARE_MESSAGE_MAP() -}; - - -} // namespace CppUnit - - -#endif // WinTestRunner_H_INCLUDED - diff --git a/contrib/libpoco/CppUnit/WinTestRunner/res/Resource.h b/contrib/libpoco/CppUnit/WinTestRunner/res/Resource.h deleted file mode 100644 index cd0bf352877..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/res/Resource.h +++ /dev/null @@ -1,27 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by TestRunner.rc -// -#define IDD_DIALOG_TESTRUNNER 129 -#define IDC_LIST 1000 -#define ID_RUN 1001 -#define ID_STOP 1002 -#define IDC_PROGRESS 1003 -#define IDC_INDICATOR 1004 -#define IDC_COMBO_TEST 1005 -#define IDC_STATIC_RUNS 1007 -#define IDC_STATIC_ERRORS 1008 -#define IDC_STATIC_FAILURES 1009 -#define IDC_EDIT_TIME 1010 -#define IDC_CHK_AUTORUN 1013 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 131 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1014 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/contrib/libpoco/CppUnit/WinTestRunner/res/WinTestRunner.rc b/contrib/libpoco/CppUnit/WinTestRunner/res/WinTestRunner.rc deleted file mode 100644 index c4056f26972..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/res/WinTestRunner.rc +++ /dev/null @@ -1,175 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif\r\n" - "#include ""..\\res\\WinTestRunner.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "CppUnit WinTestRunner DLL" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "WinTestRunner" - VALUE "LegalCopyright", "Copyright (c) 2005" - VALUE "OriginalFilename", "TestRunner.dll" - VALUE "ProductName", "CppUnit WinTestRunner Dynamic Link Library" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_DIALOG_TESTRUNNER DIALOGEX 0, 0, 512, 300 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "CppUnit WinTestRunner" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - COMBOBOX IDC_COMBO_TEST,7,20,424,273,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "Run",ID_RUN,455,7,50,14 - DEFPUSHBUTTON "Stop",ID_STOP,455,24,50,14 - CONTROL "List1",IDC_LIST,"SysListView32",LVS_REPORT | WS_BORDER | - WS_TABSTOP,7,110,498,160 - PUSHBUTTON "Close",IDOK,455,279,50,14 - LTEXT "Test Name:",IDC_STATIC,7,9,179,9 - LTEXT "Progress:",IDC_STATIC,7,55,49,9 - LTEXT "Errors and Failures:",IDC_STATIC,7,99,67,9 - LTEXT "Runs:",IDC_STATIC,457,54,26,10 - LTEXT "Failures:",IDC_STATIC,457,80,26,10 - LTEXT "Errors:",IDC_STATIC,457,67,26,10 - RTEXT "0",IDC_STATIC_RUNS,487,54,16,10 - RTEXT "0",IDC_STATIC_ERRORS,487,67,16,10 - RTEXT "0",IDC_STATIC_FAILURES,487,80,16,10 - EDITTEXT IDC_EDIT_TIME,7,281,440,12,ES_AUTOHSCROLL | ES_READONLY | - NOT WS_BORDER - LTEXT "",IDC_PROGRESS,7,67,424,20,SS_SUNKEN | NOT WS_VISIBLE - CONTROL "Auto Run",IDC_CHK_AUTORUN,"Button",BS_AUTOCHECKBOX | - BS_LEFTTEXT | WS_TABSTOP,383,38,46,10 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_DIALOG_TESTRUNNER, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 505 - TOPMARGIN, 7 - BOTTOMMARGIN, 293 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif -#include "afxres.rc" // Standard components -#endif -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/ActiveTest.cpp b/contrib/libpoco/CppUnit/WinTestRunner/src/ActiveTest.cpp deleted file mode 100644 index 2fc5110fad3..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/ActiveTest.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -// ActiveTest.cpp -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/src/ActiveTest.cpp#1 $ -// - - -#include -#include "ActiveTest.h" - - -namespace CppUnit { - - -// Spawn a thread to a test -void ActiveTest::run(TestResult* result) -{ - CWinThread* thread; - - setTestResult(result); - _runCompleted.ResetEvent(); - - thread = AfxBeginThread(threadFunction, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); - DuplicateHandle(GetCurrentProcess(), thread->m_hThread, GetCurrentProcess(), &_threadHandle, 0, FALSE, DUPLICATE_SAME_ACCESS); - - thread->ResumeThread(); -} - - -// Simple execution thread. Assuming that an ActiveTest instance -// only creates one of these at a time. -UINT ActiveTest::threadFunction(LPVOID thisInstance) -{ - ActiveTest* test = (ActiveTest*) thisInstance; - - test->run(); - test->_runCompleted.SetEvent(); - - return 0; -} - - -} // namespace CppUnit - diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/ActiveTest.h b/contrib/libpoco/CppUnit/WinTestRunner/src/ActiveTest.h deleted file mode 100644 index bf9df5e7da1..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/ActiveTest.h +++ /dev/null @@ -1,89 +0,0 @@ -// -// ActiveTest.h -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/src/ActiveTest.h#1 $ -// - - -#ifndef ActiveTest_INCLUDED -#define ActiveTest_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/TestDecorator.h" -#include - - -namespace CppUnit { - - -/* A Microsoft-specific active test - * - * An active test manages its own - * thread of execution. This one - * is very simple and only sufficient - * for the limited use we put it through - * in the TestRunner. It spawns a thread - * on run (TestResult *) and signals - * completion of the test. - * - * We assume that only one thread - * will be active at once for each - * instance. - * - */ -class ActiveTest: public TestDecorator -{ -public: - ActiveTest(Test* test); - ~ActiveTest(); - - void run(TestResult* result); - -protected: - HANDLE _threadHandle; - CEvent _runCompleted; - TestResult* _currentTestResult; - - void run (); - void setTestResult(TestResult* result); - static UINT threadFunction(LPVOID thisInstance); -}; - - -// Construct the active test -inline ActiveTest::ActiveTest(Test *test): TestDecorator(test) -{ - _currentTestResult = NULL; - _threadHandle = INVALID_HANDLE_VALUE; -} - - -// Pend until the test has completed -inline ActiveTest::~ActiveTest() -{ - CSingleLock(&_runCompleted, TRUE); - CloseHandle(_threadHandle); -} - - -// Set the test result that we are to run -inline void ActiveTest::setTestResult(TestResult* result) -{ - _currentTestResult = result; -} - - -// Run our test result -inline void ActiveTest::run() -{ - TestDecorator::run(_currentTestResult); -} - - -} // namespace CppUnit - - -#endif // ActiveTest_INCLUDED - - diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/DLLMain.cpp b/contrib/libpoco/CppUnit/WinTestRunner/src/DLLMain.cpp deleted file mode 100644 index 8fd293115fe..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/DLLMain.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// -// DLLMain.cpp -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/src/DLLMain.cpp#1 $ -// - - -#include -#include - - -static AFX_EXTENSION_MODULE TestRunnerDLL = { NULL, NULL }; - - -extern "C" int APIENTRY -DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) -{ - // Remove this if you use lpReserved - UNREFERENCED_PARAMETER(lpReserved); - - if (dwReason == DLL_PROCESS_ATTACH) - { - TRACE0("WinTestRunner.DLL Initializing\n"); - - // Extension DLL one-time initialization - if (!AfxInitExtensionModule(TestRunnerDLL, hInstance)) - return 0; - - // Insert this DLL into the resource chain - // NOTE: If this Extension DLL is being implicitly linked to by - // an MFC Regular DLL (such as an ActiveX Control) - // instead of an MFC application, then you will want to - // remove this line from DllMain and put it in a separate - // function exported from this Extension DLL. The Regular DLL - // that uses this Extension DLL should then explicitly call that - // function to initialize this Extension DLL. Otherwise, - // the CDynLinkLibrary object will not be attached to the - // Regular DLL's resource chain, and serious problems will - // result. - - new CDynLinkLibrary(TestRunnerDLL); - } - else if (dwReason == DLL_PROCESS_DETACH) - { - TRACE0("WinTestRunner.DLL Terminating\n"); - // Terminate the library before destructors are called - AfxTermExtensionModule(TestRunnerDLL); - } - return 1; // ok -} diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/GUITestResult.cpp b/contrib/libpoco/CppUnit/WinTestRunner/src/GUITestResult.cpp deleted file mode 100644 index 9486d02b572..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/GUITestResult.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -// GUITestResult.cpp -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/src/GUITestResult.cpp#1 $ -// - - -#include "TestRunnerDlg.h" -#include "GUITestResult.h" - - -namespace CppUnit { - - -void GUITestResult::addError(Test *test, CppUnitException *e) -{ - ExclusiveZone zone(_syncObject); - - TestResult::addError(test, e); - _runner->addError(this, test, e); -} - - -void GUITestResult::addFailure(Test *test, CppUnitException *e) -{ - ExclusiveZone zone(_syncObject); - - TestResult::addFailure(test, e); - _runner->addFailure(this, test, e); -} - - -void GUITestResult::startTest(Test *test) -{ - ExclusiveZone zone(_syncObject); - - TestResult::startTest(test); - _runner->startTest(test); -} - - -void GUITestResult::endTest(Test *test) -{ - ExclusiveZone zone(_syncObject); - - TestResult::endTest(test); - _runner->endTest(this, test); -} - - -} // namespace CppUnit - diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/GUITestResult.h b/contrib/libpoco/CppUnit/WinTestRunner/src/GUITestResult.h deleted file mode 100644 index 3fae4e00a0c..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/GUITestResult.h +++ /dev/null @@ -1,83 +0,0 @@ -// -// GUITestResult.h -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/src/GUITestResult.h#1 $ -// - - -#ifndef GuiTestResult_INCLUDED -#define GuiTestResult_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/TestResult.h" -#include - - -namespace CppUnit { - - -class TestRunnerDlg; - - -class GUITestResult: public TestResult -{ -public: - GUITestResult(TestRunnerDlg* runner); - ~GUITestResult(); - - void addError(Test* test, CppUnitException* e); - void addFailure(Test* test, CppUnitException* e); - - void startTest(Test* test); - void endTest(Test* test); - void stop(); - -protected: - class LightweightSynchronizationObject: public TestResult::SynchronizationObject - { - public: - void lock() - { - _syncObject.Lock(); - } - - void unlock() - { - _syncObject.Unlock(); - } - - private: - CCriticalSection _syncObject; - }; - -private: - TestRunnerDlg *_runner; -}; - - - -// Construct with lightweight synchronization -inline GUITestResult::GUITestResult(TestRunnerDlg* runner): _runner(runner) -{ - setSynchronizationObject(new LightweightSynchronizationObject()); -} - - -// Destructor -inline GUITestResult::~GUITestResult() -{ -} - - -// Override without protection to prevent deadlock -inline void GUITestResult::stop() -{ - _stop = true; -} - - -} // namespace CppUnit - - -#endif // GuiTestResult_INCLUDED diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/ProgressBar.cpp b/contrib/libpoco/CppUnit/WinTestRunner/src/ProgressBar.cpp deleted file mode 100644 index 08935e548e6..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/ProgressBar.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// -// ProgressBar.cpp -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/src/ProgressBar.cpp#1 $ -// - - -#include "ProgressBar.h" - - -namespace CppUnit { - - -// Paint the progress bar in response to a paint message -void ProgressBar::paint(CDC& dc) -{ - paintBackground (dc); - paintStatus (dc); -} - - -// Paint the background of the progress bar region -void ProgressBar::paintBackground (CDC& dc) -{ - CBrush brshBackground; - CPen penGray (PS_SOLID, 1, RGB (128, 128, 128)); - CPen penWhite (PS_SOLID, 1, RGB (255, 255, 255)); - - VERIFY (brshBackground.CreateSolidBrush (::GetSysColor (COLOR_BTNFACE))); - - dc.FillRect (_bounds, &brshBackground); - - CPen *pOldPen; - - pOldPen = dc.SelectObject (&penGray); - { - dc.MoveTo (_bounds.left, _bounds.top); - dc.LineTo (_bounds.left + _bounds.Width () -1, _bounds.top); - - dc.MoveTo (_bounds.left, _bounds.top); - dc.LineTo (_bounds.left, _bounds.top + _bounds.Height () -1); - - } - dc.SelectObject (&penWhite); - { - dc.MoveTo (_bounds.left + _bounds.Width () -1, _bounds.top); - dc.LineTo (_bounds.left + _bounds.Width () -1, _bounds.top + _bounds.Height () -1); - - dc.MoveTo (_bounds.left, _bounds.top + _bounds.Height () -1); - dc.LineTo (_bounds.left + _bounds.Width () -1, _bounds.top + _bounds.Height () -1); - - } - dc.SelectObject (pOldPen); - -} - - -// Paint the actual status of the progress bar -void ProgressBar::paintStatus (CDC& dc) -{ - if (_progress <= 0) - return; - - CBrush brshStatus; - CRect rect (_bounds.left, _bounds.top, - _bounds.left + _progressX, _bounds.bottom); - - COLORREF statusColor = getStatusColor (); - - VERIFY (brshStatus.CreateSolidBrush (statusColor)); - - rect.DeflateRect (1, 1); - dc.FillRect (rect, &brshStatus); - -} - - -// Paint the current step -void ProgressBar::paintStep (int startX, int endX) -{ - // kludge: painting the whole region on each step - _baseWindow->RedrawWindow (_bounds); - _baseWindow->UpdateWindow (); - -} - - -// Setup the progress bar for execution over a total number of steps -void ProgressBar::start (int total) -{ - _total = total; - reset (); -} - - -// Take one step, indicating whether it was a successful step -void ProgressBar::step (bool successful) -{ - _progress++; - - int x = _progressX; - - _progressX = scale (_progress); - - if (!_error && !successful) - { - _error = true; - x = 1; - } - - paintStep (x, _progressX); - -} - - -// Map from steps to display units -int ProgressBar::scale (int value) -{ - if (_total > 0) - return max (1, value * (_bounds.Width () - 1) / _total); - - return value; - -} - - -// Reset the progress bar -void ProgressBar::reset () -{ - _progressX = 1; - _progress = 0; - _error = false; - - _baseWindow->RedrawWindow (_bounds); - _baseWindow->UpdateWindow (); - -} - - -} // namespace CppUnit diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/ProgressBar.h b/contrib/libpoco/CppUnit/WinTestRunner/src/ProgressBar.h deleted file mode 100644 index 09eaa479607..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/ProgressBar.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// ProgressBar.h -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/src/ProgressBar.h#1 $ -// - - -#ifndef ProgressBar_INCLUDED -#define ProgressBar_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include - - -namespace CppUnit { - - -/* A Simple ProgressBar for test execution display - */ -class ProgressBar -{ -public: - ProgressBar(CWnd* baseWindow, CRect& bounds); - - void step(bool successful); - void paint(CDC& dc); - int scale(int value); - void reset(); - void start(int total); - -protected: - void paintBackground(CDC& dc); - void paintStatus(CDC& dc); - COLORREF getStatusColor(); - void paintStep(int startX, int endX); - - CWnd* _baseWindow; - CRect _bounds; - - bool _error; - int _total; - int _progress; - int _progressX; -}; - - -// Construct a ProgressBar -inline ProgressBar::ProgressBar(CWnd* baseWindow, CRect& bounds): - _baseWindow(baseWindow), - _bounds(bounds), - _error(false), - _total(0), - _progress(0), - _progressX(0) -{ - WINDOWINFO wi; - wi.cbSize = sizeof(WINDOWINFO); - baseWindow->GetWindowInfo(&wi); - _bounds.OffsetRect(-wi.rcClient.left, -wi.rcClient.top); -} - - -// Get the current color -inline COLORREF ProgressBar::getStatusColor() -{ - return _error ? RGB(255, 0, 0) : RGB(0, 255, 0); -} - - -} // namespace CppUnit - - -#endif // ProgressBar_INCLUDED diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/SynchronizedTestResult.h b/contrib/libpoco/CppUnit/WinTestRunner/src/SynchronizedTestResult.h deleted file mode 100644 index 55dc01c55bf..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/SynchronizedTestResult.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef SYNCHRONIZEDTESTRESULTDECORATOR_H -#define SYNCHRONIZEDTESTRESULTDECORATOR_H - -#include -#include "TestResultDecorator.h" - -class SynchronizedTestResult : public TestResultDecorator -{ -public: - SynchronizedTestResult (TestResult *result); - ~SynchronizedTestResult (); - - - bool shouldStop (); - void addError (Test *test, CppUnitException *e); - void addFailure (Test *test, CppUnitException *e); - void startTest (Test *test); - void endTest (Test *test); - int runTests (); - int testErrors (); - int testFailures (); - bool wasSuccessful (); - void stop (); - - vector& errors (); - vector& failures (); - -private: - CCriticalSection m_criticalSection; - -}; - - -// Constructor -inline SynchronizedTestResult::SynchronizedTestResult (TestResult *result) -: TestResultDecorator (result) {} - -// Destructor -inline SynchronizedTestResult::~SynchronizedTestResult () -{} - -// Returns whether the test should stop -inline bool SynchronizedTestResult::shouldStop () -{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->shouldStop (); } - - -// Adds an error to the list of errors. The passed in exception -// caused the error -inline void SynchronizedTestResult::addError (Test *test, CppUnitException *e) -{ CSingleLock sync (&m_criticalSection, TRUE); m_result->addError (test, e); } - - -// Adds a failure to the list of failures. The passed in exception -// caused the failure. -inline void SynchronizedTestResult::addFailure (Test *test, CppUnitException *e) -{ CSingleLock sync (&m_criticalSection, TRUE); m_result->addFailure (test, e); } - - -// Informs the result that a test will be started. -inline void SynchronizedTestResult::startTest (Test *test) -{ CSingleLock sync (&m_criticalSection, TRUE); m_result->startTest (test); } - - -// Informs the result that a test was completed. -inline void SynchronizedTestResult::endTest (Test *test) -{ CSingleLock sync (&m_criticalSection, TRUE); m_result->endTest (test); } - - -// Gets the number of run tests. -inline int SynchronizedTestResult::runTests () -{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->runTests (); } - - -// Gets the number of detected errors. -inline int SynchronizedTestResult::testErrors () -{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->testErrors (); } - - -// Gets the number of detected failures. -inline int SynchronizedTestResult::testFailures () -{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->testFailures (); } - - -// Returns whether the entire test was successful or not. -inline bool SynchronizedTestResult::wasSuccessful () -{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->wasSuccessful (); } - - -// Marks that the test run should stop. -inline void SynchronizedTestResult::stop () -{ CSingleLock sync (&m_criticalSection, TRUE); m_result->stop (); } - - -// Returns a vector of the errors. -inline vector& SynchronizedTestResult::errors () -{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->errors (); } - - -// Returns a vector of the failures. -inline vector& SynchronizedTestResult::failures () -{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->failures (); } - - -#endif - - diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/TestResultDecorator.h b/contrib/libpoco/CppUnit/WinTestRunner/src/TestResultDecorator.h deleted file mode 100644 index 33ed48db009..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/TestResultDecorator.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef CPP_UNIT_TESTRESULTDECORATOR_H -#define CPP_UNIT_TESTRESULTDECORATOR_H - -#include "TestResult.h" - -class TestResultDecorator -{ -public: - TestResultDecorator (TestResult *result); - virtual ~TestResultDecorator (); - - - virtual bool shouldStop (); - virtual void addError (Test *test, CppUnitException *e); - virtual void addFailure (Test *test, CppUnitException *e); - virtual void startTest (Test *test); - virtual void endTest (Test *test); - virtual int runTests (); - virtual int testErrors (); - virtual int testFailures (); - virtual bool wasSuccessful (); - virtual void stop (); - - vector& errors (); - vector& failures (); - -protected: - TestResult *m_result; -}; - - -inline TestResultDecorator::TestResultDecorator (TestResult *result) -: m_result (result) {} - -inline TestResultDecorator::~TestResultDecorator () -{} - -// Returns whether the test should stop -inline bool TestResultDecorator::shouldStop () -{ return m_result->shouldStop (); } - - -// Adds an error to the list of errors. The passed in exception -// caused the error -inline void TestResultDecorator::addError (Test *test, CppUnitException *e) -{ m_result->addError (test, e); } - - -// Adds a failure to the list of failures. The passed in exception -// caused the failure. -inline void TestResultDecorator::addFailure (Test *test, CppUnitException *e) -{ m_result->addFailure (test, e); } - - -// Informs the result that a test will be started. -inline void TestResultDecorator::startTest (Test *test) -{ m_result->startTest (test); } - - -// Informs the result that a test was completed. -inline void TestResultDecorator::endTest (Test *test) -{ m_result->endTest (test); } - - -// Gets the number of run tests. -inline int TestResultDecorator::runTests () -{ return m_result->runTests (); } - - -// Gets the number of detected errors. -inline int TestResultDecorator::testErrors () -{ return m_result->testErrors (); } - - -// Gets the number of detected failures. -inline int TestResultDecorator::testFailures () -{ return m_result->testFailures (); } - - -// Returns whether the entire test was successful or not. -inline bool TestResultDecorator::wasSuccessful () -{ return m_result->wasSuccessful (); } - - -// Marks that the test run should stop. -inline void TestResultDecorator::stop () -{ m_result->stop (); } - - -// Returns a vector of the errors. -inline vector& TestResultDecorator::errors () -{ return m_result->errors (); } - - -// Returns a vector of the failures. -inline vector& TestResultDecorator::failures () -{ return m_result->failures (); } - - -#endif - - diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/TestRunnerDlg.cpp b/contrib/libpoco/CppUnit/WinTestRunner/src/TestRunnerDlg.cpp deleted file mode 100644 index b8aca676a84..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/TestRunnerDlg.cpp +++ /dev/null @@ -1,439 +0,0 @@ -// -// TestRunnerDlg.cpp -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/src/TestRunnerDlg.cpp#1 $ -// - - -#include -#include -#include -#include -#include "TestRunnerDlg.h" -#include "ActiveTest.h" -#include "GUITestResult.h" -#include "ProgressBar.h" -#include "CppUnit/TestSuite.h" -#include "TestRunnerDlg.h" - - -namespace CppUnit { - - -TestRunnerDlg::TestRunnerDlg(CWnd* pParent): CDialog(TestRunnerDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(TestRunnerDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - - _testsProgress = 0; - _selectedTest = 0; - _currentTest = 0; -} - - -void TestRunnerDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(TestRunnerDlg) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(TestRunnerDlg, CDialog) - //{{AFX_MSG_MAP(TestRunnerDlg) - ON_BN_CLICKED(ID_RUN, OnRun) - ON_BN_CLICKED(ID_STOP, OnStop) - ON_CBN_SELCHANGE(IDC_COMBO_TEST, OnSelchangeComboTest) - ON_BN_CLICKED(IDC_CHK_AUTORUN, OnBnClickedAutorun) - ON_WM_PAINT() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -BOOL TestRunnerDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CListCtrl *listCtrl = (CListCtrl *)GetDlgItem (IDC_LIST); - CComboBox *comboBox = (CComboBox *)GetDlgItem (IDC_COMBO_TEST); - - ASSERT (listCtrl); - ASSERT (comboBox); - - CString title; - GetWindowText(title); -#if defined(_DEBUG) - title.Append(" [debug]"); -#else - title.Append(" [release]"); -#endif - SetWindowText(title); - - listCtrl->InsertColumn (0,"Type", LVCFMT_LEFT, 16 + listCtrl->GetStringWidth ("Type"), 1); - listCtrl->InsertColumn (1,"Name", LVCFMT_LEFT, 16 * listCtrl->GetStringWidth ("X"), 2); - listCtrl->InsertColumn (2,"Failed Condition", LVCFMT_LEFT, 24 * listCtrl->GetStringWidth ("M"), 3); - listCtrl->InsertColumn (3,"Line", LVCFMT_LEFT, 16 + listCtrl->GetStringWidth ("0000"), 4); - listCtrl->InsertColumn (4,"File Name", LVCFMT_LEFT, 36 * listCtrl->GetStringWidth ("M"), 5); - - int numberOfCases = 0; - - CWinApp* pApp = AfxGetApp(); - CString lastTestCS = pApp->GetProfileString("Tests", "lastTest"); - std::string lastTest((LPCSTR) lastTestCS); - int sel = -1; - for (std::vector::iterator it = _tests.begin (); it != _tests.end (); ++it) - { - std::string cbName(it->level*4, ' '); - cbName.append(it->pTest->toString()); - comboBox->AddString (cbName.c_str ()); - if (sel < 0) - { - if (lastTest.empty() || lastTest == it->pTest->toString()) - { - _selectedTest = it->pTest; - sel = numberOfCases; - } - } - numberOfCases++; - } - - if (numberOfCases > 0) - { - if (sel < 0) - { - _selectedTest = _tests[0].pTest; - sel = 0; - } - comboBox->SetCurSel (sel); - } - else - { - beRunDisabled (); - } - CWnd *pProgress = GetDlgItem(IDC_PROGRESS); - CRect rect; - pProgress->GetWindowRect(&rect); - _testsProgress = new ProgressBar (this, rect); - - CButton* autoRunBtn = (CButton*) GetDlgItem(IDC_CHK_AUTORUN); - autoRunBtn->SetCheck(pApp->GetProfileInt("Tests", "autoRun", BST_UNCHECKED)); - - reset (); - - if (autoRunBtn->GetCheck() == BST_CHECKED) - { - OnRun(); - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - - -TestRunnerDlg::~TestRunnerDlg () -{ - freeState (); - delete _testsProgress; -} - - -void TestRunnerDlg::OnRun() -{ - if (_selectedTest == 0) - return; - - freeState (); - reset (); - - beRunning (); - - int numberOfTests = _selectedTest->countTestCases (); - - _testsProgress->start (numberOfTests); - - _result = new GUITestResult ((TestRunnerDlg *)this); - _activeTest = new ActiveTest (_selectedTest); - - _testStartTime = timeGetTime (); - - _activeTest->run (_result); - - _testEndTime = timeGetTime (); - -} - - -void TestRunnerDlg::addListEntry(const std::string& type, TestResult *result, Test *test, CppUnitException *e) -{ - char stage [80]; - LV_ITEM lvi; - CListCtrl *listCtrl = (CListCtrl *)GetDlgItem (IDC_LIST); - int currentEntry = result->testErrors () + result->testFailures () -1; - - sprintf (stage, "%s", type.c_str ()); - - lvi.mask = LVIF_TEXT; - lvi.iItem = currentEntry; - lvi.iSubItem = 0; - lvi.pszText = stage; - lvi.iImage = 0; - lvi.stateMask = 0; - lvi.state = 0; - - listCtrl->InsertItem (&lvi); - - // Set class string - listCtrl->SetItemText (currentEntry, 1, test->toString ().c_str ()); - - // Set the asserted text - listCtrl->SetItemText(currentEntry, 2, e->what ()); - - // Set the line number - if (e->lineNumber () == CppUnitException::CPPUNIT_UNKNOWNLINENUMBER) - sprintf (stage, ""); - else - sprintf (stage, "%ld", e->lineNumber ()); - - listCtrl->SetItemText(currentEntry, 3, stage); - - // Set the file name - listCtrl->SetItemText(currentEntry, 4, e->fileName ().c_str ()); - - listCtrl->RedrawItems (currentEntry, currentEntry); - listCtrl->UpdateWindow (); - -} - - -void TestRunnerDlg::addError (TestResult *result, Test *test, CppUnitException *e) -{ - addListEntry ("Error", result, test, e); - _errors++; - - _currentTest = 0; - updateCountsDisplay (); - -} - - -void TestRunnerDlg::addFailure (TestResult *result, Test *test, CppUnitException *e) -{ - addListEntry ("Failure", result, test, e); - _failures++; - - _currentTest = 0; - updateCountsDisplay (); - -} - - -void TestRunnerDlg::startTest(Test* test) -{ - _currentTest = test; - updateCountsDisplay(); -} - - -void TestRunnerDlg::endTest (TestResult *result, Test *test) -{ - if (_selectedTest == 0) - return; - _currentTest = 0; - - _testsRun++; - updateCountsDisplay (); - _testsProgress->step (_failures == 0 && _errors == 0); - - _testEndTime = timeGetTime (); - - updateCountsDisplay (); - - if (_testsRun >= _selectedTest->countTestCases ()) - beIdle (); -} - - -void TestRunnerDlg::beRunning () -{ - CButton *runButton = (CButton *)GetDlgItem (ID_RUN); - CButton *closeButton = (CButton *)GetDlgItem (IDOK); - - runButton->EnableWindow (FALSE); - closeButton->EnableWindow (FALSE); - -} - - -void TestRunnerDlg::beIdle () -{ - CButton *runButton = (CButton *)GetDlgItem (ID_RUN); - CButton *closeButton = (CButton *)GetDlgItem (IDOK); - - runButton->EnableWindow (TRUE); - closeButton->EnableWindow (TRUE); - -} - - -void TestRunnerDlg::beRunDisabled () -{ - CButton *runButton = (CButton *)GetDlgItem (ID_RUN); - CButton *closeButton = (CButton *)GetDlgItem (IDOK); - CButton *stopButton = (CButton *)GetDlgItem (ID_STOP); - - runButton->EnableWindow (FALSE); - stopButton->EnableWindow (FALSE); - closeButton->EnableWindow (TRUE); - -} - - -void TestRunnerDlg::freeState () -{ - delete _activeTest; - delete _result; - -} - - -void TestRunnerDlg::reset () -{ - _testsRun = 0; - _errors = 0; - _failures = 0; - _testEndTime = _testStartTime; - - updateCountsDisplay (); - - _activeTest = 0; - _result = 0; - - CListCtrl *listCtrl = (CListCtrl *)GetDlgItem (IDC_LIST); - - listCtrl->DeleteAllItems (); - _testsProgress->reset (); - -} - - -void TestRunnerDlg::updateCountsDisplay () -{ - CStatic *statTestsRun = (CStatic *)GetDlgItem (IDC_STATIC_RUNS); - CStatic *statErrors = (CStatic *)GetDlgItem (IDC_STATIC_ERRORS); - CStatic *statFailures = (CStatic *)GetDlgItem (IDC_STATIC_FAILURES); - CEdit *editTime = (CEdit *)GetDlgItem (IDC_EDIT_TIME); - - CString argumentString; - - argumentString.Format ("%d", _testsRun); - statTestsRun ->SetWindowText (argumentString); - - argumentString.Format ("%d", _errors); - statErrors ->SetWindowText (argumentString); - - argumentString.Format ("%d", _failures); - statFailures ->SetWindowText (argumentString); - - if (_currentTest) - argumentString.Format ("Execution Time: %3.3lf seconds, Current Test: %s", (_testEndTime - _testStartTime) / 1000.0, _currentTest->toString().c_str()); - else - argumentString.Format ("Execution Time: %3.3lf seconds", (_testEndTime - _testStartTime) / 1000.0); - - editTime ->SetWindowText (argumentString); - - -} - - -void TestRunnerDlg::OnStop() -{ - if (_result) - _result->stop (); - - beIdle (); - -} - - -void TestRunnerDlg::OnOK() -{ - if (_result) - _result->stop (); - - CDialog::OnOK (); -} - - -void TestRunnerDlg::OnSelchangeComboTest() -{ - CComboBox *testsSelection = (CComboBox *)GetDlgItem (IDC_COMBO_TEST); - - int currentSelection = testsSelection->GetCurSel (); - - if (currentSelection >= 0 && currentSelection < _tests.size ()) - { - _selectedTest = (_tests.begin () + currentSelection)->pTest; - beIdle (); - CWinApp* pApp = AfxGetApp(); - pApp->WriteProfileString("Tests", "lastTest", _selectedTest->toString().c_str()); - } - else - { - _selectedTest = 0; - beRunDisabled (); - - } - - freeState (); - reset (); - -} - - -void TestRunnerDlg::OnBnClickedAutorun() -{ - CButton *autoRunBtn = (CButton *)GetDlgItem (IDC_CHK_AUTORUN); - CWinApp* pApp = AfxGetApp(); - pApp->WriteProfileInt("Tests", "autoRun", autoRunBtn->GetCheck()); -} - - -void TestRunnerDlg::OnPaint() -{ - CPaintDC dc (this); - - _testsProgress->paint (dc); -} - - -void TestRunnerDlg::setTests(const std::vector& tests) -{ - _tests.clear(); - for (std::vector::const_iterator it = tests.begin(); it != tests.end(); ++it) - { - addTest(*it, 0); - } -} - - -void TestRunnerDlg::addTest(Test* pTest, int level) -{ - TestInfo ti; - ti.pTest = pTest; - ti.level = level; - _tests.push_back(ti); - TestSuite* pSuite = dynamic_cast(pTest); - if (pSuite) - { - const std::vector& tests = pSuite->tests(); - for (std::vector::const_iterator it = tests.begin(); it != tests.end(); ++it) - { - addTest(*it, level + 1); - } - } -} - - -} // namespace CppUnit diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/TestRunnerDlg.h b/contrib/libpoco/CppUnit/WinTestRunner/src/TestRunnerDlg.h deleted file mode 100644 index 8357bda2ead..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/TestRunnerDlg.h +++ /dev/null @@ -1,94 +0,0 @@ -// -// TestRunnerDlg.h -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/src/TestRunnerDlg.h#1 $ -// - - -#ifndef TestRunnerDlg_INCLUDED -#define TestRunnerDlg_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/CppUnitException.h" -#include "ActiveTest.h" -#include -#include "../res/Resource.h" -#include -#include "afxwin.h" - - -namespace CppUnit { - - -class ProgressBar; - - -class TestRunnerDlg: public CDialog -{ -public: - TestRunnerDlg(CWnd* pParent = NULL); - ~TestRunnerDlg(); - - void setTests(const std::vector& tests); - - void addError(TestResult* result, Test* test, CppUnitException* e); - void addFailure(TestResult* result, Test* test, CppUnitException* e); - void startTest(Test* test); - void endTest(TestResult* result, Test* test); - - //{{AFX_DATA(TestRunnerDlg) - enum { IDD = IDD_DIALOG_TESTRUNNER }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - //{{AFX_VIRTUAL(TestRunnerDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -protected: - //{{AFX_MSG(TestRunnerDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnRun(); - afx_msg void OnStop(); - virtual void OnOK(); - afx_msg void OnSelchangeComboTest(); - afx_msg void OnBnClickedAutorun(); - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - void addListEntry(const std::string& type, TestResult* result, Test* test, CppUnitException* e); - void beIdle(); - void beRunning(); - void beRunDisabled(); - void reset(); - void freeState(); - void updateCountsDisplay(); - void addTest(Test* pTest, int level); - - struct TestInfo - { - Test* pTest; - int level; - }; - std::vector _tests; - ProgressBar* _testsProgress; - Test* _selectedTest; - ActiveTest* _activeTest; - TestResult* _result; - int _testsRun; - int _errors; - int _failures; - DWORD _testStartTime; - DWORD _testEndTime; - Test* _currentTest; -}; - - -} // namespace CppUnit - - -#endif // TestRunnerDlg_INCLUDED - diff --git a/contrib/libpoco/CppUnit/WinTestRunner/src/WinTestRunner.cpp b/contrib/libpoco/CppUnit/WinTestRunner/src/WinTestRunner.cpp deleted file mode 100644 index cc5ff5721d4..00000000000 --- a/contrib/libpoco/CppUnit/WinTestRunner/src/WinTestRunner.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// -// WinTestRunner.cpp -// -// $Id: //poco/1.4/CppUnit/WinTestRunner/src/WinTestRunner.cpp#1 $ -// - - -#include "WinTestRunner/WinTestRunner.h" -#include "TestRunnerDlg.h" -#include "CppUnit/TestRunner.h" -#include - - -namespace CppUnit { - - -WinTestRunner::WinTestRunner() -{ -} - - -WinTestRunner::~WinTestRunner() -{ - for (std::vector::iterator it = _tests.begin(); it != _tests.end(); ++it) - delete *it; -} - - -void WinTestRunner::run() -{ - // Note: The following code is some evil hack to - // add batch capability to the MFC based WinTestRunner. - - std::string cmdLine(AfxGetApp()->m_lpCmdLine); - if (cmdLine.size() >= 2 && cmdLine[0] == '/' && (cmdLine[1] == 'b' || cmdLine[1] == 'B')) - { - TestRunner runner; - for (std::vector::iterator it = _tests.begin(); it != _tests.end(); ++it) - runner.addTest((*it)->toString(), *it); - _tests.clear(); - std::vector args; - args.push_back("WinTestRunner"); - args.push_back("-all"); - bool success = runner.run(args); - ExitProcess(success ? 0 : 1); - } - else - { - // We're running in interactive mode. - TestRunnerDlg dlg; - dlg.setTests(_tests); - dlg.DoModal(); - } -} - - -void WinTestRunner::addTest(Test* pTest) -{ - _tests.push_back(pTest); -} - - -BEGIN_MESSAGE_MAP(WinTestRunnerApp, CWinApp) -END_MESSAGE_MAP() - - -BOOL WinTestRunnerApp::InitInstance() -{ - std::string cmdLine(AfxGetApp()->m_lpCmdLine); - if (cmdLine.size() >= 2 && cmdLine[0] == '/' && (cmdLine[1] == 'b' || cmdLine[1] == 'B')) - { - // We're running in batch mode. - std::string outPath; - if (cmdLine.size() > 4 && cmdLine[2] == ':') - { - outPath = cmdLine.substr(3); - } - else - { - char buffer[1024]; - GetModuleFileName(NULL, buffer, sizeof(buffer)); - outPath = buffer; - outPath += ".out"; - } - freopen(outPath.c_str(), "w", stdout); - freopen(outPath.c_str(), "w", stderr); - TestMain(); - } - else - { - AllocConsole(); - SetConsoleTitle("CppUnit WinTestRunner Console"); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); - freopen("CONIN$", "r", stdin); - TestMain(); - FreeConsole(); - } - return FALSE; -} - - -void WinTestRunnerApp::TestMain() -{ -} - - -} // namespace CppUnit diff --git a/contrib/libpoco/CppUnit/doc/README.html b/contrib/libpoco/CppUnit/doc/README.html deleted file mode 100644 index 5f8a1418a1b..00000000000 --- a/contrib/libpoco/CppUnit/doc/README.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - -CppUnit 1.5 - - - - -

-

CppUnit 1.5

-

Last Revision: 12/15/99 - Michael Feathers (mfeathers@acm.org) - written in standard C++, tested under Microsoft Visual C++ 6.0

-


-

Background

-

CppUnit is a simple unit test framework for C++. It is a port from JUnit, a testing framework for Java, developed by Kent Beck and Erich Gamma.

-

Contents

-
README.html                     this file
-    
-    test                        the source code
-        framework               the testing framework
-		extensions	some framework extension classes 
-        textui                  a command line interface to run tests 
-    ms                          code for a Microsoft specific TestRunner
-    samples                     some example test cases and extensions to the framework
-        multicaster             a sample illustrating a publish/subscribe 
-				multicaster under test
-    doc                         documentation
-

Installation

-

To use the test framework, create a makefile or load all files in test\framework into your IDE. In this incarnation of CppUnit, all includes assume the current directory first. A makefile or project can be used to resolve the dependencies.

-

The directory test\textui contains a simple command line example that uses the framework.

-

Documentation

-

CppUnit comes with the following documentation:

- -
    -
  • a cookbook: doc\cookbook.htm
  • -
  • this file
- -

Samples

-

You can find several sample test cases in the samples directory:

- -
    -
  • ExampleTestCase - some simple tests
  • -
  • Multicaster - test cases for a sample publish/subscribe multicaster class
- -

Also, the wiki page http://c2.com/cgi/wiki?ClassHierarchyTestingInCppUnit shows how to automatically apply tests of classes to the classes' subclasses.

- -

Extensions

-

You can find several classes that illustrate framework extensions in the extensions directory:

- -
    -
  • TestDecorator - A Decorator for Test. You can use it as the base class for decorators that extend test cases.
  • -
  • TestSetup - A Decorator that can be used to set up and tear down additional fixture state. Subclass TestSetup and insert it into your tests when you want to set up additional state once before the test is run.
  • -
  • Orthodox - a template class which can be used to verify operations on an arbitrary class.
- - -

Notes

-

Porting this framework has been fun. I've tried to maintain the spirit and utility of JUnit in a C++ environment. Naturally, the move from Java to standard C++ forces out several nice JUnit features:

-
    - -
  1. Platform independent GUI.
  2. -
  3. Stack traces of test failures
  4. -
  5. Active (threaded) tests
  6. -
  7. Direct invocation of test cases via reflection
  8. -
  9. Run-time loading of new tests
- -

In addition, the lack of garbage collection in C++ requires some careful use of the framework classes. In particular, TestSuites are composites that manage the lifetime of any tests added to them. Holding onto a TestResult past the lifetime of the tests which filled it is a bad idea. This is because TestResults hold TestFailures and TestFailures hold pointers to the Tests that generated them.

-

On the plus side, we can use the C++ macro preprocessor to get the exact line at which a failure occurs, along with the actual text inside the assert () call that detected the failure. The features of C++ that enable this are the __LINE__ and __FILE__ preprocessor definitions, along with the stringizing operator. If you find that generating this much literal text bulks up your test executables, you can use the CPP_UNIT_SOURCEANNOT define to disable that portion of the reporting.

-

Note: If you use the C++ macro "assert ()" in your code, or include assert.h, you may have a name clash with CppUnit's assert macro. This can be remedied by changing the name of the macro to "cu_assert ()" in TestCase.h.

-

I'd like to thank Kent Beck and Erich Gamma for the inspiration, design, and a wonderful cookbook that was easily/shamelessly mutated to describe CppUnit. Double thanks to Erich for thinking up a way to implement TestCaller. Additional thanks to Kent, Ward Cunningham, Ron Jeffries, Martin Fowler, and several other netizens of the WikiWikiWeb. I don't think any other bunch of people could have convinced me that rapid development with unit tests can be both effective and easy.

-

Thanks also to Fred Huls for mentioning the idea of template-based testing. The orthodox template class demonstrates only a small part of what can be done with templated test cases.

-

History Of Changes

-

1.2 -- Added the TestCaller template class. There is now no need to use the CPP_UNIT_TESTCASEDISPATCH macro unless you are using a C++ compiler which does not support templates well. CPP_UNIT_TESTCASEDISPATCH remains in TestCase.h for backward compatibility. I've also kept the use of the macro in the Multicaster sample to leave in an example.

-

1.3 -- Retired the CPP_UNIT_TESTCASEDISPATCH macro and cleaned up the include structure. Fixed bug in the textui version.

-

1.4 -- Removed using directives for std in CppUnit headers. Merged the old AssertionFailedError into CppUnitException. Fixed a memory leak in the TestRunner class of the MS GUI TestRunner. Removed CppUnit.h file. Now headers for each class must be included directly.

-

1.5 -- Upgraded projects from VC++ 5.0 to 6.0.

diff --git a/contrib/libpoco/CppUnit/doc/cookbook.htm b/contrib/libpoco/CppUnit/doc/cookbook.htm deleted file mode 100644 index 08224883be9..00000000000 --- a/contrib/libpoco/CppUnit/doc/cookbook.htm +++ /dev/null @@ -1,164 +0,0 @@ - - - - -CppUnit Cookbook - - - - -

-

CppUnit Cookbook

-

Here is a short cookbook to help you get started.

-

Simple Test Case

-

You want to know whether your code is working. How do you do it? There are many ways. Stepping through a debugger or littering your code with stream output calls are two of the simpler ways, but they both have drawbacks. Stepping through your code is a good idea, but it is not automatic. You have to do it every time you make changes. Streaming out text is also fine, but it makes code ugly and it generates far more information than you need most of the time.

-

Tests in CppUnit can be run automatically. They are easy to set up and once you have written them, they are always there to help you keep confidence in the quality of your code.

-

To make a simple test, here is what you do:

-

Subclass the TestCase class. Override the method "runTest ()". When you want to check a value, call "assert (bool)" and pass in an expression that is true if the test succeeds.

-

For example, to test the equality comparison for a Complex number class, write:

-
	class ComplexNumberTest : public TestCase { 
-	public: 
-                    ComplexNumberTest (string name) : TestCase (name) {}
-        void        runTest () {
-                        assert (Complex (10, 1) == Complex (10, 1));
-                        assert (!(Complex (1, 1) == Complex (2, 2)));
-                    }
-        };
-

That was a very simple test. Ordinarily, you'll have many little test cases that you'll want to run on the same set of objects. To do this, use a fixture.

-

 

-

Fixture

-

A fixture is a known set of objects that serves as a base for a set of test cases. Fixtures come in very handy when you are testing as you develop. Let's try out this style of development and learn about fixtures along the away. Suppose that we are really developing a complex number class. Let's start by defining a empty class named Complex.

-
	class Complex {}; 
-

Now create an instance of ComplexNumberTest above, compile the code and see what happens. The first thing we notice is a few compiler errors. The test uses operator==, but it is not defined. Let's fix that.

-
	bool operator== (const Complex& a, const Complex& b) { return true; }
-

Now compile the test, and run it. This time it compiles but the test fails. We need a bit more to get an operator== working correctly, so we revisit the code.

-
	class Complex { 
-        friend bool operator== (const Complex& a, const Complex& b);
-        double      real, imaginary;
-        public:
-                    Complex ()  {
-                    real = imaginary = 0.0;
-                    }
-        };
-
-        bool operator== (const Complex& a, const Complex& b)
-        { return eq(a.real,b.real) && eq(a.imaginary,b.imaginary); }
-

If we compile now and run our test it will pass.

-

Now we are ready to add new operations and new tests. At this point a fixture would be handy. We would probably be better off when doing our tests if we decided to instantiate three or four complex numbers and reuse them across our tests.

-

Here is how we do it:

-
    - -
  1. Add member variables for each part of the fixture
  2. -
  3. Override "setUp ()" to initialize the variables
  4. -
  5. Override "tearDown ()" to release any permanent resources you allocated in "setUp ()"
- -
	class ComplexNumberTest : public TestCase  {
-	private:
-        Complex 	*m_10_1, *m_1_1; *m_11_2;
-	protected:
-	void		setUp ()  {
-			    m_10_1 = new Complex (10, 1);
-			    m_1_1  = new Complex (1, 1);
-			    m_11_2  = new Complex (11, 2);  
-                        }
-	void		tearDown ()  {
-			    delete m_10_1, delete m_1_1, delete m_11_2;
-			}
-	};
-

Once we have this fixture, we can add the complex addition test case any any others that we need over the course of our development.

-

 

-

Test Case

-

How do you write and invoke individual tests using a fixture?

-

There are two steps to this process:

-
    - -
  1. Write the test case as a method in the fixture class
  2. -
  3. Create a TestCaller which runs that particular method
- -

Here is our test case class with a few extra case methods:

-
	class ComplexNumberTest : public TestCase  {
-	private:
-        Complex 	*m_10_1, *m_1_1; *m_11_2;
-	protected:
-	void		setUp ()  {
-			    m_10_1 = new Complex (10, 1);
-			    m_1_1  = new Complex (1, 1);
-			    m_11_2 = new Complex (11, 2);  
-                        }
-	void		tearDown ()  {
-			    delete m_10_1, delete m_1_1, delete m_11_2;
-			}
-	void		testEquality ()  {
-			    assert (*m_10_1 == *m_10_1);
-			    assert (!(*m_10_1 == *m_11_2));
-			}
-	void		testAddition ()  {
-			    assert (*m_10_1 + *m_1_1 == *m_11_2);
-                 	}
-	};
-

Create and run instances for each test case like this:

-
	test = new TestCaller<ComplexNumberTest>("testEquality", ComplexNumberTest::testEquality);
-        test->run (); 
-

The second argument to the test caller constructor is the address of a method on ComplexNumberTest. When the test caller is run, that specific method will be run.

-

Once you have several tests, organize them into a suite.

-

 

-

Suite

-

How do you set up your tests so that you can run them all at once?
-
-CppUnit provides a TestSuite class that runs any number of TestCases together. For example, to run a single test case, you execute:

-
	TestResult result;
-	TestCaller<ComplexNumberTest> test ("testAddition", ComplexNumberTest::testAddition);
-	Test.run (&result);
-

 

-

To create a suite of two or more tests, you do the following:

-
	TestSuite suite;
-	TestResult result;
-	suite.addTest (new TestCaller<ComplexNumberTest>("testEquality", ComplexNumberTest::testEquality));
-	suite.addTest (new TestCaller<ComplexNumberTest>("testAddition", ComplexNumberTest::testAddition));
-	suite.run (&result);
-           
-

TestSuites don't only have to contain callers for TestCases. They can contain any object that implements the Test interface. For example, you can create a TestSuite in your code and I can create one in mine, and we can run them together by creating a TestSuite that contains both:

-
	TestSuite suite;
-	suite.addTest (ComplexNumberTest.suite ());
-	suite.addTest (SurrealNumberTest.suite ());
-	suite.run (&result);
-

 

-

TestRunner

-

How do you run your tests and collect their results?

-

Once you have a test suite, you'll want to run it. CppUnit provides tools to define the suite to be run and to display its results. You make your suite accessible to a TestRunner program with a static method suite that returns a test suite.
-For example, to make a ComplexNumberTest suite available to a TestRunner, add the following code to ComplexNumberTest:

-
	public: static Test *suite ()  {
-	    TestSuite *suiteOfTests = new TestSuite;
-	    suiteOfTests->addTest (new TestCaller<ComplexNumberTest>("testEquality", testEquality));
-	    suiteOfTests->addTest (new TestCaller<ComplexNumberTest>("testAddition", testAddition));
-            return suiteOfTests;
-	}
-

CppUnit provides both a textual version of a TestRunner tool, and a Micosoft Visual C++ 5.0 graphical version. If you are running on another platform, take a look at the graphical version. It is easy to port.

-

To use the text version, include the header file for the test in TestRunner.cpp:

-
	#include "ExampleTestCase.h"
-	#include "ComplexNumberTest.h"
-

And add a call to "addTest (string, Test *) in the "main ()" function:

-
	int main (int ac, char **av)  {
-	    TestRunner runner;
-	    runner.addTest (ExampleTestCase::suite ());
-	    runner.addTest (ComplexNumberTest::suite ());
-	    runner.run ();
-	    return 0;
-	}
-

The TestRunner will run the tests. If all the tests pass, you'll get an informative message. If any fail, you'll get the following information:

-
    - -
  1. The name of the test case that failed
  2. -
  3. The name of the source file that contains the test
  4. -
  5. The line number where the failure occurred
  6. -
  7. All of the text inside the call to assert which detected the failure
- -

CppUnit distinguishes between failures and errors. A failure is anticipated and checked for with assertions. Errors are unanticipated problems like division by zero and other exceptions thrown by the C++ runtime or your code.

-

If you are running MS Developer's Studio, you can build the GUI version rather easily. There are three projects: culib, TestRunner, and HostApp. They make a static library for the framework, a dialog based TestRunner in a DLL and an example Hosting application, respectively. To incorporate a TestRunner in an application you are developing, link with the static library and the TestRunner DLL. Note that the TestRunner DLL must be in the home directory of your application, the system directory or the path. In your application, create an instance of TestRunnerDlg whenever you want to run tests. Pass tests you want to run to the dialog object and then execute.

-

Here is a screen shot of the TestRunner in use:

-

-

 

-

More notes about the implementation of CppUnit can be found in README.HTML.

-

 

-

 

- diff --git a/contrib/libpoco/CppUnit/doc/license.htm b/contrib/libpoco/CppUnit/doc/license.htm deleted file mode 100644 index 951a688b58f..00000000000 --- a/contrib/libpoco/CppUnit/doc/license.htm +++ /dev/null @@ -1,15 +0,0 @@ - - - - -License Agreement - - - - -

Permission to reproduce and create derivative works from the Software ("Software Derivative Works") is hereby granted to you under the copyright of Michael Feathers.  Michael Feathers also grants you the right to distribute the Software and Software Derivative Works.

-

Michael Feathers licenses the Software to you on an "AS IS" basis, without warranty of any kind. Michael Feathers HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES OR CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, NON INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.  You are solely responsible for determining the appropriateness of using the Software and assume all risks associated with the use and distribution of this Software, including but not limited to the risks of program errors, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.  MICHAEL FEATHERS WILL NOT BE LIABLE FOR ANY DIRECT DAMAGES OR FOR ANY SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF MICHAEL FEATHERS HAD BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  Michael Feathers will not be liable for the loss of, or damage to, your records or data, or any damages claimed by you based on a third party claim.

-

You agree to distribute the Software and any Software Derivatives under a license agreement that: 1) is sufficient to notify all licensees of the Software and Software Derivatives that Michael Feathers assumes no liability for any claim that may arise regarding the Software or Software Derivatives, and 2) that disclaims all warranties, both express and implied, from Michael Feathers regarding the Software and Software Derivatives.  (If you include this Agreement with any distribution of the Software and Software Derivatives you will have meet this requirement).  You agree that you will not delete any copyright notices in the Software.

-

This Agreement is the exclusive statement of your rights in the Software as provided by Michael Feathers.  Except for the licenses granted to you in the second paragraph above, no other licenses are granted hereunder, by estoppel, implication or otherwise.

- diff --git a/contrib/libpoco/CppUnit/doc/test.gif b/contrib/libpoco/CppUnit/doc/test.gif deleted file mode 100644 index 861cf14b31c..00000000000 Binary files a/contrib/libpoco/CppUnit/doc/test.gif and /dev/null differ diff --git a/contrib/libpoco/CppUnit/include/CppUnit/CppUnit.h b/contrib/libpoco/CppUnit/include/CppUnit/CppUnit.h deleted file mode 100644 index 57583bc8bcc..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/CppUnit.h +++ /dev/null @@ -1,60 +0,0 @@ -// -// CppUnit.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/CppUnit.h#1 $ -// - - -#ifndef CppUnit_CppUnit_INCLUDED -#define CppUnit_CppUnit_INCLUDED - - -// -// Ensure that POCO_DLL is default unless POCO_STATIC is defined -// -#if defined(_WIN32) && defined(_DLL) - #if !defined(POCO_DLL) && !defined(POCO_STATIC) - #define POCO_DLL - #endif -#endif - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the CppUnit_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// CppUnit_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && defined(POCO_DLL) - #if defined(CppUnit_EXPORTS) - #define CppUnit_API __declspec(dllexport) - #else - #define CppUnit_API __declspec(dllimport) - #endif -#endif - - -#if !defined(CppUnit_API) - #if defined (__GNUC__) && (__GNUC__ >= 4) - #define CppUnit_API __attribute__ ((visibility ("default"))) - #else - #define CppUnit_API - #endif -#endif - - -// Turn off some annoying warnings -#ifdef _MSC_VER - #pragma warning(disable:4786) // identifier truncation warning - #pragma warning(disable:4503) // decorated name length exceeded - mainly a problem with STLPort - #pragma warning(disable:4018) // signed/unsigned comparison - #pragma warning(disable:4284) // return type for operator -> is not UDT - #pragma warning(disable:4251) // ... needs to have dll-interface warning - #pragma warning(disable:4273) - #pragma warning(disable:4275) // ... non dll-interface class used as base for dll-interface class -#endif - - -#endif // CppUnit_CppUnit_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/CppUnitException.h b/contrib/libpoco/CppUnit/include/CppUnit/CppUnitException.h deleted file mode 100644 index 27c50a3cb57..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/CppUnitException.h +++ /dev/null @@ -1,141 +0,0 @@ -// -// CppUnitException.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/CppUnitException.h#1 $ -// - - -#ifndef CppUnit_CppUnitException_INCLUDED -#define CppUnit_CppUnitException_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include -#include - - -namespace CppUnit { - - -class CppUnit_API CppUnitException: public std::exception - /// CppUnitException is an exception that serves - /// descriptive strings through its what() method -{ -public: - CppUnitException(const std::string& message = "", - long lineNumber = CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CPPUNIT_UNKNOWNFILENAME); - CppUnitException(const std::string& message, - long lineNumber, - long data1lineNumber, - const std::string& fileName); - CppUnitException(const std::string& message, - long lineNumber, - long data1lineNumber, - long data2lineNumber, - const std::string& fileName); - CppUnitException(const CppUnitException& other); - virtual ~CppUnitException() throw(); - - CppUnitException& operator = (const CppUnitException& other); - - const char* what() const throw (); - - long lineNumber() const; - long data1LineNumber() const; - long data2LineNumber() const; - const std::string& fileName() const; - - static const std::string CPPUNIT_UNKNOWNFILENAME; - static const int CPPUNIT_UNKNOWNLINENUMBER; - -private: - std::string _message; - long _lineNumber; - long _data1lineNumber; - long _data2lineNumber; - std::string _fileName; -}; - - -inline CppUnitException::CppUnitException(const CppUnitException& other): exception (other) -{ - _message = other._message; - _lineNumber = other._lineNumber; - _data1lineNumber = other._data1lineNumber; - _data2lineNumber = other._data2lineNumber; - _fileName = other._fileName; -} - - -inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _data2lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _fileName(fileName) -{ -} - - -inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, long data1lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(data1lineNumber), _data2lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _fileName(fileName) -{ -} - - -inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, long data1lineNumber, long data2lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(data1lineNumber), _data2lineNumber(data2lineNumber), _fileName(fileName) -{ -} - - -inline CppUnitException::~CppUnitException () throw() -{ -} - - -inline CppUnitException& CppUnitException::operator = (const CppUnitException& other) -{ - exception::operator= (other); - - if (&other != this) - { - _message = other._message; - _lineNumber = other._lineNumber; - _data1lineNumber = other._data1lineNumber; - _data2lineNumber = other._data2lineNumber; - _fileName = other._fileName; - } - return *this; -} - - -inline const char* CppUnitException::what() const throw () -{ - return _message.c_str(); -} - - -inline long CppUnitException::lineNumber() const -{ - return _lineNumber; -} - - -inline long CppUnitException::data1LineNumber() const -{ - return _data1lineNumber; -} - - -inline long CppUnitException::data2LineNumber() const -{ - return _data2lineNumber; -} - - -// The file in which the error occurred -inline const std::string& CppUnitException::fileName() const -{ - return _fileName; -} - - -} // namespace CppUnit - - -#endif // CppUnit_CppUnitException_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/Guards.h b/contrib/libpoco/CppUnit/include/CppUnit/Guards.h deleted file mode 100644 index ef8a7d6abe9..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/Guards.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// Guards.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/Guards.h#1 $ -// - - -#ifndef CppUnit_Guards_INCLUDED -#define CppUnit_Guards_INCLUDED - - -// Prevent copy construction and assignment for a class -#define REFERENCEOBJECT(className) \ -private: \ - className(const className& other); \ - className& operator = (const className& other); - - -#endif // CppUnit_Guards_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/Orthodox.h b/contrib/libpoco/CppUnit/include/CppUnit/Orthodox.h deleted file mode 100644 index 3a038975cbe..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/Orthodox.h +++ /dev/null @@ -1,105 +0,0 @@ -// -// Orthodox.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/Orthodox.h#1 $ -// - - -#ifndef CppUnit_Orthodox_INCLUDED -#define CppUnit_Orthodox_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/TestCase.h" - - -namespace CppUnit { - - -/* - * Orthodox performs a simple set of tests on an arbitary - * class to make sure that it supports at least the - * following operations: - * - * default construction - constructor - * equality/inequality - operator== && operator!= - * assignment - operator= - * negation - operator! - * safe passage - copy construction - * - * If operations for each of these are not declared - * the template will not instantiate. If it does - * instantiate, tests are performed to make sure - * that the operations have correct semantics. - * - * Adding an orthodox test to a suite is very - * easy: - * - * public: Test *suite () { - * TestSuite *suiteOfTests = new TestSuite; - * suiteOfTests->addTest (new ComplexNumberTest ("testAdd"); - * suiteOfTests->addTest (new TestCaller > ()); - * return suiteOfTests; - * } - * - * Templated test cases be very useful when you are want to - * make sure that a group of classes have the same form. - * - * see TestSuite - */ -template -class Orthodox: public TestCase -{ -public: - Orthodox(): TestCase("Orthodox") - { - } - -protected: - ClassUnderTest call(ClassUnderTest object); - void runTest (); -}; - - -// Run an orthodoxy test -template -void Orthodox::runTest() -{ - // make sure we have a default constructor - ClassUnderTest a, b, c; - - // make sure we have an equality operator - assert (a == b); - - // check the inverse - b.operator= (a.operator! ()); - assert (a != b); - - // double inversion - b = !!a; - assert (a == b); - - // invert again - b = !a; - - // check calls - c = a; - assert (c == call (a)); - - c = b; - assert (c == call (b)); -} - - -// Exercise a call -template -ClassUnderTest Orthodox::call(ClassUnderTest object) -{ - return object; -} - - -} // namespace CppUnit - - -#endif // CppUnit_Orthodox_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/RepeatedTest.h b/contrib/libpoco/CppUnit/include/CppUnit/RepeatedTest.h deleted file mode 100644 index 1842762efef..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/RepeatedTest.h +++ /dev/null @@ -1,77 +0,0 @@ -// -// RepeatedTest.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/RepeatedTest.h#1 $ -// - - -#ifndef CppUnit_RepeatedTest_INCLUDED -#define CppUnit_RepeatedTest_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/Guards.h" -#include "CppUnit/TestDecorator.h" - - -namespace CppUnit { - - -class Test; -class TestResult; - - -/* - * A decorator that runs a test repeatedly. - * Does not assume ownership of the test it decorates - * - */ -class CppUnit_API RepeatedTest: public TestDecorator -{ - REFERENCEOBJECT (RepeatedTest) - -public: - RepeatedTest(Test* test, int timesRepeat): TestDecorator (test), _timesRepeat (timesRepeat) - { - } - - int countTestCases(); - std::string toString(); - void run(TestResult *result); - -private: - const int _timesRepeat; -}; - - -// Counts the number of test cases that will be run by this test. -inline RepeatedTest::countTestCases () -{ - return TestDecorator::countTestCases() * _timesRepeat; -} - - -// Returns the name of the test instance. -inline std::string RepeatedTest::toString() -{ - return TestDecorator::toString() + " (repeated)"; -} - - -// Runs a repeated test -inline void RepeatedTest::run(TestResult *result) -{ - for (int n = 0; n < _timesRepeat; n++) - { - if (result->shouldStop()) - break; - - TestDecorator::run(result); - } -} - - -} // namespace CppUnit - - -#endif // CppUnit_RepeatedTest_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/Test.h b/contrib/libpoco/CppUnit/include/CppUnit/Test.h deleted file mode 100644 index 84be1679387..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/Test.h +++ /dev/null @@ -1,65 +0,0 @@ -// -// Test.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/Test.h#1 $ -// - - -#ifndef CppUnit_Test_INCLUDED -#define CppUnit_Test_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include - - -namespace CppUnit { - - -class TestResult; - - -/* - * A Test can be run and collect its results. - * See TestResult. - * - */ -class CppUnit_API Test -{ -public: - virtual ~Test() = 0; - virtual void run(TestResult* result) = 0; - virtual int countTestCases() = 0; - virtual std::string toString() = 0; -}; - - -inline Test::~Test() -{ -} - - -// Runs a test and collects its result in a TestResult instance. -inline void Test::run(TestResult *result) -{ -} - - -// Counts the number of test cases that will be run by this test. -inline int Test::countTestCases() -{ - return 0; -} - - -// Returns the name of the test instance. -inline std::string Test::toString() -{ - return ""; -} - - -} // namespace CppUnit - - -#endif // CppUnit_Test_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/TestCaller.h b/contrib/libpoco/CppUnit/include/CppUnit/TestCaller.h deleted file mode 100644 index b6f7c64b693..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/TestCaller.h +++ /dev/null @@ -1,95 +0,0 @@ -// -// TestCaller.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/TestCaller.h#1 $ -// - - -#ifndef CppUnit_TestCaller_INCLUDED -#define CppUnit_TestCaller_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "Guards.h" -#include "TestCase.h" -#include - - -namespace CppUnit { - - -/* - * A test caller provides access to a test case method - * on a test case class. Test callers are useful when - * you want to run an individual test or add it to a - * suite. - * - * Here is an example: - * - * class MathTest : public TestCase { - * ... - * public: - * void setUp (); - * void tearDown (); - * - * void testAdd (); - * void testSubtract (); - * }; - * - * Test *MathTest::suite () { - * TestSuite *suite = new TestSuite; - * - * suite->addTest (new TestCaller ("testAdd", testAdd)); - * return suite; - * } - * - * You can use a TestCaller to bind any test method on a TestCase - * class, as long as it returns accepts void and returns void. - * - * See TestCase - */ -template -class TestCaller: public TestCase -{ - REFERENCEOBJECT (TestCaller) - - typedef void (Fixture::*TestMethod)(); - -public: - TestCaller(const std::string& name, TestMethod test): - TestCase(name), - _test(test), - _fixture(new Fixture(name)) - { - } - -protected: - void runTest() - { - (_fixture.get()->*_test)(); - } - - void setUp() - { - _fixture.get()->setUp(); - } - - void tearDown() - { - _fixture.get()->tearDown(); - } - -private: - TestMethod _test; - std::unique_ptr _fixture; -}; - - -} // namespace CppUnit - - -#define CppUnit_addTest(suite, cls, mth) \ - suite->addTest(new CppUnit::TestCaller(#mth, &cls::mth)) - - -#endif // CppUnit_TestCaller_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/TestCase.h b/contrib/libpoco/CppUnit/include/CppUnit/TestCase.h deleted file mode 100644 index 1811d428dc7..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/TestCase.h +++ /dev/null @@ -1,257 +0,0 @@ -// -// TestCase.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/TestCase.h#1 $ -// - - -#ifndef CppUnit_TestCase_INCLUDED -#define CppUnit_TestCase_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/Guards.h" -#include "CppUnit/Test.h" -#include "CppUnit/CppUnitException.h" -#include -#include - - -namespace CppUnit { - - -class TestResult; - - -/* - * A test case defines the fixture to run multiple tests. To define a test case - * 1) implement a subclass of TestCase - * 2) define instance variables that store the state of the fixture - * 3) initialize the fixture state by overriding setUp - * 4) clean-up after a test by overriding tearDown. - * - * Each test runs in its own fixture so there - * can be no side effects among test runs. - * Here is an example: - * - * class MathTest : public TestCase { - * protected: int m_value1; - * protected: int m_value2; - * - * public: MathTest (std::string name) - * : TestCase (name) { - * } - * - * protected: void setUp () { - * m_value1 = 2; - * m_value2 = 3; - * } - * } - * - * - * For each test implement a method which interacts - * with the fixture. Verify the expected results with assertions specified - * by calling assert on the expression you want to test: - * - * protected: void testAdd () { - * int result = value1 + value2; - * assert (result == 5); - * } - * - * Once the methods are defined you can run them. To do this, use - * a TestCaller. - * - * Test *test = new TestCaller("testAdd", MathTest::testAdd); - * test->run (); - * - * - * The tests to be run can be collected into a TestSuite. CppUnit provides - * different test runners which can run a test suite and collect the results. - * The test runners expect a static method suite as the entry - * point to get a test to run. - * - * public: static MathTest::suite () { - * TestSuite *suiteOfTests = new TestSuite; - * suiteOfTests->addTest(new TestCaller("testAdd", testAdd)); - * suiteOfTests->addTest(new TestCaller("testDivideByZero", testDivideByZero)); - * return suiteOfTests; - * } - * - * Note that the caller of suite assumes lifetime control - * for the returned suite. - * - * see TestResult, TestSuite and TestCaller - * - */ -class CppUnit_API TestCase: public Test -{ - REFERENCEOBJECT (TestCase) - -public: - TestCase(const std::string& Name); - ~TestCase(); - - virtual void run(TestResult* result); - virtual TestResult* run(); - virtual int countTestCases(); - const std::string& name() const; - std::string toString(); - - virtual void setUp(); - virtual void tearDown(); - -protected: - virtual void runTest(); - TestResult* defaultResult(); - - void assertImplementation(bool condition, - const std::string& conditionExpression = "", - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - void loop1assertImplementation(bool condition, - const std::string& conditionExpression = "", - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - long dataLineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - void loop2assertImplementation(bool condition, - const std::string& conditionExpression = "", - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - long data1LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - long data2LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - void assertEquals(long expected, - long actual, - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - void assertEquals(double expected, - double actual, - double delta, - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - void assertEquals(const std::string& expected, - const std::string& actual, - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - void assertEquals(const void* expected, - const void* actual, - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - std::string notEqualsMessage(long expected, long actual); - std::string notEqualsMessage(double expected, double actual); - std::string notEqualsMessage(const void* expected, const void* actual); - std::string notEqualsMessage(const std::string& expected, const std::string& actual); - - void assertNotNull(const void* pointer, - const std::string& pointerExpression = "", - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - void assertNull(const void* pointer, - const std::string& pointerExpression = "", - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - void fail(const std::string& message = "", - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - void warn(const std::string& message = "", - long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER, - const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME); - - -private: - const std::string _name; -}; - - -// Constructs a test case -inline TestCase::TestCase(const std::string& name): _name (name) -{ -} - - -// Destructs a test case -inline TestCase::~TestCase() -{ -} - - -// Returns a count of all the tests executed -inline int TestCase::countTestCases() -{ - return 1; -} - - -// Returns the name of the test case -inline const std::string& TestCase::name() const -{ - return _name; -} - - -// A hook for fixture set up -inline void TestCase::setUp() -{ -} - - -// A hook for fixture tear down -inline void TestCase::tearDown() -{ -} - - -// Returns the name of the test case instance -inline std::string TestCase::toString() -{ - const std::type_info& thisClass = typeid(*this); - return std::string(thisClass.name()) + "." + name(); -} - - -// A set of macros which allow us to get the line number -// and file name at the point of an error. -// Just goes to show that preprocessors do have some -// redeeming qualities. -#undef assert -#define assert(condition) \ - (this->assertImplementation((condition), (#condition), __LINE__, __FILE__)) - -#define loop_1_assert(data1line, condition) \ - (this->loop1assertImplementation((condition), (#condition), __LINE__, data1line, __FILE__)) - -#define loop_2_assert(data1line, data2line, condition) \ - (this->loop2assertImplementation((condition), (#condition), __LINE__, data1line, data2line, __FILE__)) - -#define assertEqualDelta(expected, actual, delta) \ - (this->assertEquals((expected), (actual), (delta), __LINE__, __FILE__)) - -#define assertEqual(expected, actual) \ - (this->assertEquals((expected), (actual), __LINE__, __FILE__)) - -#define assertNullPtr(ptr) \ - (this->assertNull((ptr), #ptr, __LINE__, __FILE__)) - -#define assertNotNullPtr(ptr) \ - (this->assertNotNull((ptr), #ptr, __LINE__, __FILE__)) - -#define failmsg(msg) \ - (this->fail(msg, __LINE__, __FILE__)) - -#define warnmsg(msg) \ - (this->fail(msg, __LINE__, __FILE__)) - - -} // namespace CppUnit - - -#endif // CppUnit_TestCase_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/TestDecorator.h b/contrib/libpoco/CppUnit/include/CppUnit/TestDecorator.h deleted file mode 100644 index ac57c591e4b..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/TestDecorator.h +++ /dev/null @@ -1,52 +0,0 @@ -// -// TestDecorator.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/TestDecorator.h#1 $ -// - - -#ifndef CppUnit_TestDecorator_INCLUDED -#define CppUnit_TestDecorator_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/Guards.h" -#include "CppUnit/Test.h" - - -namespace CppUnit { - - -class TestResult; - - -/* - * A Decorator for Tests - * - * Does not assume ownership of the test it decorates - * - */ -class CppUnit_API TestDecorator: public Test -{ - REFERENCEOBJECT(TestDecorator) - -public: - TestDecorator(Test* test); - - virtual ~TestDecorator(); - - int countTestCases(); - - void run(TestResult* result); - - std::string toString(); - -protected: - Test* _test; -}; - - -} // namespace CppUnit - - -#endif // CppUnit_TestDecorator_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/TestFailure.h b/contrib/libpoco/CppUnit/include/CppUnit/TestFailure.h deleted file mode 100644 index c1f845d7211..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/TestFailure.h +++ /dev/null @@ -1,86 +0,0 @@ -// -// TestFailure.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/TestFailure.h#1 $ -// - - -#ifndef CppUnit_TestFailure_INCLUDED -#define CppUnit_TestFailure_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/CppUnitException.h" -#include "CppUnit/Guards.h" - - -namespace CppUnit { - - -class Test; - - -/* - * A TestFailure collects a failed test together with - * the caught exception. - * - * TestFailure assumes lifetime control for any exception - * passed to it. The lifetime of tests is handled by - * their TestSuite (if they have been added to one) or - * whomever creates them. - * - * see TestResult - * see TestSuite - * - */ -class CppUnit_API TestFailure -{ - REFERENCEOBJECT (TestFailure) - -public: - TestFailure(Test* failedTest, CppUnitException* thrownException); - ~TestFailure(); - - Test* failedTest(); - CppUnitException* thrownException(); - std::string toString(); - -protected: - Test* _failedTest; - CppUnitException *_thrownException; -}; - - -// Constructs a TestFailure with the given test and exception. -inline TestFailure::TestFailure(Test* failedTest, CppUnitException* thrownException): _failedTest(failedTest), _thrownException(thrownException) -{ -} - - -// Deletes the owned exception. -inline TestFailure::~TestFailure() -{ - delete _thrownException; -} - - -// Gets the failed test. -inline Test* TestFailure::failedTest() -{ - return _failedTest; -} - - -// Gets the thrown exception. -inline CppUnitException* TestFailure::thrownException() -{ - return _thrownException; -} - - -} // namespace CppUnit - - -#endif // CppUnit_TestFailure_INCLUDED - - diff --git a/contrib/libpoco/CppUnit/include/CppUnit/TestResult.h b/contrib/libpoco/CppUnit/include/CppUnit/TestResult.h deleted file mode 100644 index 22fbd44c44b..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/TestResult.h +++ /dev/null @@ -1,231 +0,0 @@ -// -// TestResult.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/TestResult.h#1 $ -// - - -#ifndef CppUnit_TestResult_INCLUDED -#define CppUnit_TestResult_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/Guards.h" -#include "CppUnit/TestFailure.h" -#include - - -namespace CppUnit { - - -class CppUnitException; -class Test; - - -/* - * A TestResult collects the results of executing a test case. It is an - * instance of the Collecting Parameter pattern. - * - * The test framework distinguishes between failures and errors. - * A failure is anticipated and checked for with assertions. Errors are - * unanticipated problems signified by exceptions that are not generated - * by the framework. - * - * TestResult supplies a template method 'setSynchronizationObject ()' - * so that subclasses can provide mutual exclusion in the face of multiple - * threads. This can be useful when tests execute in one thread and - * they fill a subclass of TestResult which effects change in another - * thread. To have mutual exclusion, override setSynchronizationObject () - * and make sure that you create an instance of ExclusiveZone at the - * beginning of each method. - * - * see Test - */ -class CppUnit_API TestResult -{ - REFERENCEOBJECT (TestResult) - -public: - TestResult(); - virtual ~TestResult(); - - virtual void addError(Test* test, CppUnitException* e); - virtual void addFailure(Test* test, CppUnitException* e); - virtual void startTest(Test* test); - virtual void endTest(Test* test); - virtual int runTests(); - virtual int testErrors(); - virtual int testFailures(); - virtual bool wasSuccessful(); - virtual bool shouldStop(); - virtual void stop(); - - virtual std::vector& errors(); - virtual std::vector& failures(); - - class SynchronizationObject - { - public: - SynchronizationObject() - { - } - - virtual ~SynchronizationObject() - { - } - - virtual void lock() - { - } - - virtual void unlock() - { - } - }; - - class ExclusiveZone - { - SynchronizationObject* m_syncObject; - - public: - ExclusiveZone(SynchronizationObject* syncObject): m_syncObject(syncObject) - { - m_syncObject->lock(); - } - - ~ExclusiveZone() - { - m_syncObject->unlock(); - } - }; - -protected: - virtual void setSynchronizationObject(SynchronizationObject* syncObject); - - std::vector _errors; - std::vector _failures; - int _runTests; - bool _stop; - SynchronizationObject* _syncObject; - -}; - - -// Construct a TestResult -inline TestResult::TestResult(): _syncObject(new SynchronizationObject()) -{ - _runTests = 0; - _stop = false; -} - - -// Adds an error to the list of errors. The passed in exception -// caused the error -inline void TestResult::addError(Test* test, CppUnitException* e) -{ - ExclusiveZone zone(_syncObject); - _errors.push_back(new TestFailure(test, e)); -} - - -// Adds a failure to the list of failures. The passed in exception -// caused the failure. -inline void TestResult::addFailure(Test* test, CppUnitException* e) -{ - ExclusiveZone zone(_syncObject); - _failures.push_back(new TestFailure(test, e)); -} - - -// Informs the result that a test will be started. -inline void TestResult::startTest(Test* test) -{ - ExclusiveZone zone(_syncObject); - _runTests++; -} - - -// Informs the result that a test was completed. -inline void TestResult::endTest(Test* test) -{ - ExclusiveZone zone(_syncObject); -} - - -// Gets the number of run tests. -inline int TestResult::runTests() -{ - ExclusiveZone zone(_syncObject); - return _runTests; -} - - -// Gets the number of detected errors. -inline int TestResult::testErrors() -{ - ExclusiveZone zone(_syncObject); - return (int) _errors.size(); -} - - -// Gets the number of detected failures. -inline int TestResult::testFailures() -{ - ExclusiveZone zone(_syncObject); - return (int) _failures.size(); -} - - -// Returns whether the entire test was successful or not. -inline bool TestResult::wasSuccessful() -{ - ExclusiveZone zone(_syncObject); - return _failures.size() == 0 && _errors.size () == 0; -} - - -// Returns a std::vector of the errors. -inline std::vector& TestResult::errors() -{ - ExclusiveZone zone(_syncObject); - return _errors; -} - - -// Returns a std::vector of the failures. -inline std::vector& TestResult::failures() -{ - ExclusiveZone zone(_syncObject); - return _failures; -} - - -// Returns whether testing should be stopped -inline bool TestResult::shouldStop() -{ - ExclusiveZone zone(_syncObject); - return _stop; -} - - -// Stop testing -inline void TestResult::stop() -{ - ExclusiveZone zone(_syncObject); - _stop = true; -} - - -// Accept a new synchronization object for protection of this instance -// TestResult assumes ownership of the object -inline void TestResult::setSynchronizationObject(SynchronizationObject* syncObject) -{ - delete _syncObject; - _syncObject = syncObject; -} - - -} // namespace CppUnit - - -#endif // CppUnit_TestResult_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/TestRunner.h b/contrib/libpoco/CppUnit/include/CppUnit/TestRunner.h deleted file mode 100644 index e4393465901..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/TestRunner.h +++ /dev/null @@ -1,103 +0,0 @@ -// -// TestRunner.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/TestRunner.h#2 $ -// - - -#ifndef CppUnit_TestRunner_INCLUDED -#define CppUnit_TestRunner_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include -#include -#include -#if defined(POCO_VXWORKS) -#include -#endif - - -namespace CppUnit { - - -class Test; - - -/* - * A command line based tool to run tests. - * TestRunner expects as its only argument the name of a TestCase class. - * TestRunner prints out a trace as the tests are executed followed by a - * summary at the end. - * - * You can add to the tests that the TestRunner knows about by - * making additional calls to "addTest (...)" in main. - * - * Here is the synopsis: - * - * TestRunner [-all] [-print] [-wait] ExampleTestCase - * - */ -class CppUnit_API TestRunner -{ - typedef std::pair Mapping; - typedef std::vector Mappings; - -public: - TestRunner(); - TestRunner(std::ostream& ostr); - ~TestRunner(); - - bool run(const std::vector& args); - void addTest(const std::string& name, Test* test); - -protected: - bool run(Test* test); - void printBanner(); - void print(const std::string& name, Test* pTest, int indent); - Test* find(const std::string& name, Test* pTest, const std::string& testName); - -private: - std::ostream& _ostr; - Mappings _mappings; -}; - - -} // namespace CppUnit - - -#if defined(POCO_VXWORKS) -#define CppUnitMain(testCase) \ - int testCase##Runner(const char* arg0, ...) \ - { \ - std::vector args; \ - args.push_back(#testCase "Runner"); \ - args.push_back(std::string(arg0)); \ - va_list vargs; \ - va_start(vargs, arg0); \ - const char* arg = va_arg(vargs, const char*); \ - while (arg) \ - { \ - args.push_back(std::string(arg)); \ - arg = va_arg(vargs, const char*); \ - } \ - va_end(vargs); \ - CppUnit::TestRunner runner; \ - runner.addTest(#testCase, testCase::suite()); \ - return runner.run(args) ? 0 : 1; \ - } -#else -#define CppUnitMain(testCase) \ - int main(int ac, char **av) \ - { \ - std::vector args; \ - for (int i = 0; i < ac; ++i) \ - args.push_back(std::string(av[i])); \ - CppUnit::TestRunner runner; \ - runner.addTest(#testCase, testCase::suite()); \ - return runner.run(args) ? 0 : 1; \ - } -#endif - - -#endif // CppUnit_TestRunner_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/TestSetup.h b/contrib/libpoco/CppUnit/include/CppUnit/TestSetup.h deleted file mode 100644 index 789a076e526..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/TestSetup.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// TestSetup.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/TestSetup.h#1 $ -// - - -#ifndef CppUnit_TestSetup_INCLUDED -#define CppUnit_TestSetup_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/Guards.h" -#include "CppUnit/TestDecorator.h" - - -namespace CppUnit { - - -class Test; -class TestResult; - - -class CppUnit_API TestSetup: public TestDecorator -{ - REFERENCEOBJECT (TestSetup) - -public: - TestSetup(Test* test): TestDecorator(test) - { - } - - void run(TestResult* result); - -protected: - void setUp() - { - } - - void tearDown() - { - } -}; - - -inline void TestSetup::run(TestResult* result) -{ - setUp(); - TestDecorator::run(result); - tearDown(); -} - - -} // namespace CppUnit - - -#endif // CppUnit_TestSetup_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/TestSuite.h b/contrib/libpoco/CppUnit/include/CppUnit/TestSuite.h deleted file mode 100644 index 197cf2747fa..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/TestSuite.h +++ /dev/null @@ -1,98 +0,0 @@ -// -// TestSuite.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/TestSuite.h#1 $ -// - - -#ifndef CppUnit_TestSuite_INCLUDED -#define CppUnit_TestSuite_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/Guards.h" -#include "CppUnit/Test.h" -#include -#include - - -namespace CppUnit { - - -class TestResult; - - -/* - * A TestSuite is a Composite of Tests. - * It runs a collection of test cases. Here is an example. - * - * TestSuite *suite= new TestSuite(); - * suite->addTest(new TestCaller ("testAdd", testAdd)); - * suite->addTest(new TestCaller ("testDivideByZero", testDivideByZero)); - * - * Note that TestSuites assume lifetime - * control for any tests added to them. - * - * see Test and TestCaller - */ -class CppUnit_API TestSuite: public Test -{ - REFERENCEOBJECT (TestSuite) - -public: - TestSuite(const std::string& name = ""); - ~TestSuite(); - - void run(TestResult* result); - int countTestCases(); - void addTest(Test* test); - std::string toString(); - - virtual void deleteContents(); - - const std::vector tests() const; - -private: - std::vector _tests; - const std::string _name; -}; - - -// Default constructor -inline TestSuite::TestSuite(const std::string& name): _name(name) -{ -} - - -// Destructor -inline TestSuite::~TestSuite() -{ - deleteContents(); -} - - -// Adds a test to the suite. -inline void TestSuite::addTest(Test* test) -{ - _tests.push_back(test); -} - - -// Returns a std::string representation of the test suite. -inline std::string TestSuite::toString() -{ - return "suite " + _name; -} - - -// Returns all tests -inline const std::vector TestSuite::tests() const -{ - return _tests; -} - - -} // namespace CppUnit - - -#endif // CppUnit_TestSuite_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/TextTestResult.h b/contrib/libpoco/CppUnit/include/CppUnit/TextTestResult.h deleted file mode 100644 index d3b191fd913..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/TextTestResult.h +++ /dev/null @@ -1,56 +0,0 @@ -// -// TextTestResult.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/TextTestResult.h#1 $ -// - - -#ifndef CppUnit_TextTestResult_INCLUDED -#define CppUnit_TextTestResult_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include "CppUnit/TestResult.h" -#include -#include - - -namespace CppUnit { - - -class CppUnit_API TextTestResult: public TestResult -{ -public: - TextTestResult(); - TextTestResult(std::ostream& ostr); - - virtual void addError(Test* test, CppUnitException* e); - virtual void addFailure(Test* test, CppUnitException* e); - virtual void startTest(Test* test); - virtual void print(std::ostream& stream); - virtual void printErrors(std::ostream& stream); - virtual void printFailures(std::ostream& stream); - virtual void printHeader(std::ostream& stream); - -protected: - std::string shortName(const std::string& testName); - void setup(); - -private: - std::ostream& _ostr; - std::set _ignored; -}; - - -/* insertion operator for easy output */ -inline std::ostream& operator<< (std::ostream& stream, TextTestResult& result) -{ - result.print(stream); - return stream; -} - - -} // namespace CppUnit - - -#endif // CppUnit_TextTestResult_INCLUDED diff --git a/contrib/libpoco/CppUnit/include/CppUnit/estring.h b/contrib/libpoco/CppUnit/include/CppUnit/estring.h deleted file mode 100644 index cc3fe99d941..00000000000 --- a/contrib/libpoco/CppUnit/include/CppUnit/estring.h +++ /dev/null @@ -1,73 +0,0 @@ -// -// estring.h -// -// $Id: //poco/1.4/CppUnit/include/CppUnit/estring.h#1 $ -// - - -#ifndef CppUnit_estring_INCLUDED -#define CppUnit_estring_INCLUDED - - -#include "CppUnit/CppUnit.h" -#include -#include - - -namespace CppUnit { - - -// Create a std::string from a const char pointer -inline std::string estring(const char *cstring) -{ - return std::string(cstring); -} - - -// Create a std::string from a std::string (for uniformities' sake) -inline std::string estring(std::string& expandedString) -{ - return expandedString; -} - - -// Create a std::string from an int -inline std::string estring(int number) -{ - char buffer[50]; - sprintf(buffer, "%d", number); - return std::string (buffer); -} - - -// Create a string from a long -inline std::string estring(long number) -{ - char buffer[50]; - sprintf(buffer, "%ld", number); - return std::string (buffer); -} - - -// Create a std::string from a double -inline std::string estring(double number) -{ - char buffer[50]; - sprintf(buffer, "%lf", number); - return std::string(buffer); -} - - -// Create a std::string from a double -inline std::string estring(const void* ptr) -{ - char buffer[50]; - sprintf(buffer, "%p", ptr); - return std::string(buffer); -} - - -} // namespace CppUnit - - -#endif // CppUnit_estring_INCLUDED diff --git a/contrib/libpoco/CppUnit/src/CppUnitException.cpp b/contrib/libpoco/CppUnit/src/CppUnitException.cpp deleted file mode 100644 index fa4edfcaf9c..00000000000 --- a/contrib/libpoco/CppUnit/src/CppUnitException.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// -// CppUnitException.cpp -// -// $Id: //poco/1.4/CppUnit/src/CppUnitException.cpp#1 $ -// - - -#include "CppUnit/CppUnitException.h" - - -namespace CppUnit { - - -const std::string CppUnitException::CPPUNIT_UNKNOWNFILENAME = ""; -const int CppUnitException::CPPUNIT_UNKNOWNLINENUMBER = -1; - - -} // namespace CppUnit diff --git a/contrib/libpoco/CppUnit/src/TestCase.cpp b/contrib/libpoco/CppUnit/src/TestCase.cpp deleted file mode 100644 index 0e8669d9725..00000000000 --- a/contrib/libpoco/CppUnit/src/TestCase.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// -// TestCase.cpp -// -// $Id: //poco/1.4/CppUnit/src/TestCase.cpp#1 $ -// - - -#include -#include -#include "CppUnit/TestCase.h" -#include "CppUnit/TestResult.h" -#include "CppUnit/estring.h" -#include -#include - - -using namespace std; - - -namespace CppUnit { - - -// Create a default TestResult -TestResult* TestCase::defaultResult() -{ - return new TestResult; -} - - -// Check for a failed general assertion -void TestCase::assertImplementation(bool condition, const std::string& conditionExpression, long lineNumber, const std::string& fileName) -{ - if (!condition) - throw CppUnitException(conditionExpression, lineNumber, fileName); -} - - -void TestCase::loop1assertImplementation(bool condition, const std::string& conditionExpression, long lineNumber, long data1lineNumber, const std::string& fileName) -{ - if (!condition) - throw CppUnitException(conditionExpression, lineNumber, data1lineNumber, fileName); -} - - -void TestCase::loop2assertImplementation(bool condition, const std::string& conditionExpression, long lineNumber, long data1lineNumber, long data2lineNumber, const std::string& fileName) -{ - if (!condition) - throw CppUnitException(conditionExpression, lineNumber, data1lineNumber, data2lineNumber, fileName); -} - - -// Check for a failed equality assertion -void TestCase::assertEquals(long expected, long actual, long lineNumber, const std::string& fileName) -{ - if (expected != actual) - assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName); -} - - -// Check for a failed equality assertion -void TestCase::assertEquals(double expected, double actual, double delta, long lineNumber, const std::string& fileName) -{ - if (fabs(expected - actual) > delta) - assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName); -} - - -// Check for a failed equality assertion -void TestCase::assertEquals(const void* expected, const void* actual, long lineNumber, const std::string& fileName) -{ - if (expected != actual) - assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName); -} - - -// Check for a failed equality assertion -void TestCase::assertEquals(const std::string& expected, const std::string& actual, long lineNumber, const std::string& fileName) -{ - if (expected != actual) - assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName); -} - - -void TestCase::assertNotNull(const void* pointer, const std::string& pointerExpression, long lineNumber, const std::string& fileName) -{ - if (pointer == NULL) - throw CppUnitException(pointerExpression + " must not be NULL", lineNumber, fileName); -} - - -void TestCase::assertNull(const void* pointer, const std::string& pointerExpression, long lineNumber, const std::string& fileName) -{ - if (pointer != NULL) - throw CppUnitException(pointerExpression + " must be NULL", lineNumber, fileName); -} - - -void TestCase::fail(const std::string& message, long lineNumber, const std::string& fileName) -{ - throw CppUnitException(std::string("fail: ") + message, lineNumber, fileName); -} - - -void TestCase::warn(const std::string& message, long lineNumber, const std::string& fileName) -{ - std::cout << "Warning [" << fileName << ':' << lineNumber << "]: " << message << std::endl; -} - - -// Run the test and catch any exceptions that are triggered by it -void TestCase::run(TestResult *result) -{ - result->startTest(this); - - setUp(); - try - { - runTest(); - } - catch (CppUnitException& e) - { - CppUnitException* copy = new CppUnitException(e); - result->addFailure(this, copy); - } - catch (std::exception& e) - { - std::string msg(typeid(e).name()); - msg.append(": "); - msg.append(e.what()); - result->addError(this, new CppUnitException(msg)); - - } -#if !defined(_WIN32) - catch (...) - { - CppUnitException *e = new CppUnitException ("unknown exception"); - result->addError (this, e); - } -#endif - tearDown (); - result->endTest(this); -} - - -// A default run method -TestResult* TestCase::run() -{ - TestResult* result = defaultResult(); - - run(result); - return result; -} - - -// All the work for runTest is deferred to subclasses -void TestCase::runTest() -{ -} - - -// Build a message about a failed equality check -std::string TestCase::notEqualsMessage(long expected, long actual) -{ - return "expected: " + estring(expected) + " but was: " + estring(actual); -} - - -// Build a message about a failed equality check -std::string TestCase::notEqualsMessage(double expected, double actual) -{ - return "expected: " + estring(expected) + " but was: " + estring(actual); -} - - -// Build a message about a failed equality check -std::string TestCase::notEqualsMessage(const void* expected, const void* actual) -{ - return "expected: " + estring(expected) + " but was: " + estring(actual); -} - - -// Build a message about a failed equality check -std::string TestCase::notEqualsMessage(const std::string& expected, const std::string& actual) -{ - return "expected: \"" + expected + "\" but was: \"" + actual + "\""; -} - - -} // namespace CppUnit diff --git a/contrib/libpoco/CppUnit/src/TestDecorator.cpp b/contrib/libpoco/CppUnit/src/TestDecorator.cpp deleted file mode 100644 index 40f4b6662bb..00000000000 --- a/contrib/libpoco/CppUnit/src/TestDecorator.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -// TestDecorator.cpp -// -// $Id: //poco/1.4/CppUnit/src/TestDecorator.cpp#1 $ -// - - -#include "CppUnit/TestDecorator.h" - - -namespace CppUnit { - - -TestDecorator::TestDecorator(Test* test) -{ - _test = test; -} - - -TestDecorator::~TestDecorator() -{ -} - - -int TestDecorator::countTestCases() -{ - return _test->countTestCases(); -} - - -void TestDecorator::run(TestResult* result) -{ - _test->run(result); -} - - -std::string TestDecorator::toString() -{ - return _test->toString(); -} - - -} // namespace CppUnit diff --git a/contrib/libpoco/CppUnit/src/TestFailure.cpp b/contrib/libpoco/CppUnit/src/TestFailure.cpp deleted file mode 100644 index bfae516069f..00000000000 --- a/contrib/libpoco/CppUnit/src/TestFailure.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// -// TestFailure.cpp -// -// $Id: //poco/1.4/CppUnit/src/TestFailure.cpp#1 $ -// - - -#include "CppUnit/TestFailure.h" -#include "CppUnit/Test.h" - - -namespace CppUnit { - - -// Returns a short description of the failure. -std::string TestFailure::toString() -{ - return _failedTest->toString () + ": " + _thrownException->what(); -} - - -} // namespace CppUnit diff --git a/contrib/libpoco/CppUnit/src/TestResult.cpp b/contrib/libpoco/CppUnit/src/TestResult.cpp deleted file mode 100644 index d6e3fcbbf28..00000000000 --- a/contrib/libpoco/CppUnit/src/TestResult.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -// TestResult.cpp -// -// $Id: //poco/1.4/CppUnit/src/TestResult.cpp#1 $ -// - - -#include "CppUnit/TestResult.h" - - -namespace CppUnit { - - -// Destroys a test result -TestResult::~TestResult() -{ - std::vector::iterator it; - - for (it = _errors.begin(); it != _errors.end(); ++it) - delete *it; - - for (it = _failures.begin(); it != _failures.end(); ++it) - delete *it; - - delete _syncObject; -} - - -} // namespace CppUnit diff --git a/contrib/libpoco/CppUnit/src/TestRunner.cpp b/contrib/libpoco/CppUnit/src/TestRunner.cpp deleted file mode 100644 index 196fbdeed0d..00000000000 --- a/contrib/libpoco/CppUnit/src/TestRunner.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// -// TestRunner.cpp -// -// $Id: //poco/1.4/CppUnit/src/TestRunner.cpp#1 $ -// - - -#include "CppUnit/TestRunner.h" -#include "CppUnit/Test.h" -#include "CppUnit/TestSuite.h" -#include "CppUnit/TextTestResult.h" -#include - - -namespace CppUnit { - - -TestRunner::TestRunner(): - _ostr(std::cout) -{ -} - - -TestRunner::TestRunner(std::ostream& ostr): - _ostr(ostr) -{ -} - - -TestRunner::~TestRunner() -{ - for (Mappings::iterator it = _mappings.begin(); it != _mappings.end(); ++it) - delete it->second; -} - - -void TestRunner::printBanner() -{ - _ostr - << "Usage: driver [-all] [-print] [-wait] [name] ..." << std::endl - << " where name is the name of a test case class" << std::endl; -} - - -bool TestRunner::run(const std::vector& args) -{ - std::string testCase; - int numberOfTests = 0; - bool success = true; - bool all = false; - bool wait = false; - bool printed = false; - - for (int i = 1; i < args.size(); i++) - { - const std::string& arg = args[i]; - if (arg == "-wait") - { - wait = true; - continue; - } - else if (arg == "-all") - { - all = true; - continue; - } - else if (arg == "-print") - { - for (Mappings::iterator it = _mappings.begin(); it != _mappings.end(); ++it) - { - print(it->first, it->second, 0); - } - printed = true; - continue; - } - - if (!all) - { - testCase = arg; - - if (testCase == "") - { - printBanner(); - return false; - } - - Test* testToRun = 0; - for (Mappings::iterator it = _mappings.begin(); !testToRun && it != _mappings.end(); ++it) - { - testToRun = find(testCase, it->second, it->first); - } - if (testToRun) - { - if (!run(testToRun)) success = false; - } - numberOfTests++; - - if (!testToRun) - { - _ostr << "Test " << testCase << " not found." << std::endl; - return false; - } - } - } - - if (all) - { - for (Mappings::iterator it = _mappings.begin(); it != _mappings.end(); ++it) - { - if (!run(it->second)) success = false; - numberOfTests++; - } - } - - if (numberOfTests == 0 && !printed) - { - printBanner(); - return false; - } - - if (wait) - { - _ostr << " to continue" << std::endl; - std::cin.get(); - } - - return success; -} - - -bool TestRunner::run(Test* test) -{ - TextTestResult result(_ostr); - - test->run(&result); - _ostr << result << std::endl; - - return result.wasSuccessful(); -} - - -void TestRunner::addTest(const std::string& name, Test* test) -{ - _mappings.push_back(Mapping(name, test)); -} - - -void TestRunner::print(const std::string& name, Test* pTest, int indent) -{ - for (int i = 0; i < indent; ++i) - _ostr << " "; - _ostr << name << std::endl; - TestSuite* pSuite = dynamic_cast(pTest); - if (pSuite) - { - const std::vector& tests = pSuite->tests(); - for (std::vector::const_iterator it = tests.begin(); it != tests.end(); ++it) - { - print((*it)->toString(), *it, indent + 1); - } - } -} - - -Test* TestRunner::find(const std::string& name, Test* pTest, const std::string& testName) -{ - if (testName.find(name) != std::string::npos) - { - return pTest; - } - else - { - TestSuite* pSuite = dynamic_cast(pTest); - if (pSuite) - { - const std::vector& tests = pSuite->tests(); - for (std::vector::const_iterator it = tests.begin(); it != tests.end(); ++it) - { - Test* result = find(name, *it, (*it)->toString()); - if (result) return result; - } - } - return 0; - } -} - - -} // namespace CppUnit diff --git a/contrib/libpoco/CppUnit/src/TestSuite.cpp b/contrib/libpoco/CppUnit/src/TestSuite.cpp deleted file mode 100644 index 066949243e7..00000000000 --- a/contrib/libpoco/CppUnit/src/TestSuite.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -// TestSuite.cpp -// -// $Id: //poco/1.4/CppUnit/src/TestSuite.cpp#1 $ -// - - -#include "CppUnit/TestSuite.h" -#include "CppUnit/TestResult.h" - - -namespace CppUnit { - - -// Deletes all tests in the suite. -void TestSuite::deleteContents() -{ - for (std::vector::iterator it = _tests.begin(); it != _tests.end(); ++it) - delete *it; -} - - -// Runs the tests and collects their result in a TestResult. -void TestSuite::run(TestResult *result) -{ - for (std::vector::iterator it = _tests.begin(); it != _tests.end(); ++it) - { - if (result->shouldStop ()) - break; - - Test *test = *it; - test->run(result); - } -} - - -// Counts the number of test cases that will be run by this test. -int TestSuite::countTestCases() -{ - int count = 0; - - for (std::vector::iterator it = _tests.begin (); it != _tests.end (); ++it) - count += (*it)->countTestCases(); - - return count; -} - - -} // namespace CppUnit diff --git a/contrib/libpoco/CppUnit/src/TextTestResult.cpp b/contrib/libpoco/CppUnit/src/TextTestResult.cpp deleted file mode 100644 index b77318941c5..00000000000 --- a/contrib/libpoco/CppUnit/src/TextTestResult.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// -// TextTestResult.cpp -// -// $Id: //poco/1.4/CppUnit/src/TextTestResult.cpp#1 $ -// - - -#include "CppUnit/TextTestResult.h" -#include "CppUnit/CppUnitException.h" -#include "CppUnit/Test.h" -#include "CppUnit/estring.h" -#include -#include -#include -#include - - -namespace CppUnit { - - -TextTestResult::TextTestResult(): - _ostr(std::cout) -{ - setup(); -} - - -TextTestResult::TextTestResult(std::ostream& ostr): - _ostr(ostr) -{ - setup(); -} - - -void TextTestResult::setup() -{ -#if !defined(_WIN32_WCE) - const char* env = std::getenv("CPPUNIT_IGNORE"); - if (env) - { - std::string ignored = env; - std::string::const_iterator it = ignored.begin(); - std::string::const_iterator end = ignored.end(); - while (it != end) - { - while (it != end && std::isspace(*it)) ++it; - std::string test; - while (it != end && !std::isspace(*it)) test += *it++; - if (!test.empty()) _ignored.insert(test); - } - } -#endif -} - - -void TextTestResult::addError(Test* test, CppUnitException* e) -{ - if (_ignored.find(test->toString()) == _ignored.end()) - { - TestResult::addError(test, e); - _ostr << "ERROR" << std::flush; - } - else - { - _ostr << "ERROR (ignored)" << std::flush; - } -} - - -void TextTestResult::addFailure(Test* test, CppUnitException* e) -{ - if (_ignored.find(test->toString()) == _ignored.end()) - { - TestResult::addFailure(test, e); - _ostr << "FAILURE" << std::flush; - } - else - { - _ostr << "FAILURE (ignored)" << std::flush; - } -} - - -void TextTestResult::startTest(Test* test) -{ - TestResult::startTest(test); - _ostr << "\n" << shortName(test->toString()) << ": "; -} - - -void TextTestResult::printErrors(std::ostream& stream) -{ - if (testErrors() != 0) - { - stream << "\n"; - - if (testErrors() == 1) - stream << "There was " << testErrors() << " error: " << std::endl; - else - stream << "There were " << testErrors() << " errors: " << std::endl; - - int i = 1; - for (std::vector::iterator it = errors().begin(); it != errors().end(); ++it) - { - TestFailure* failure = *it; - CppUnitException* e = failure->thrownException(); - - stream << std::setw(2) << i - << ": " - << failure->failedTest()->toString() << "\n" - << " \"" << (e ? e->what() : "") << "\"\n" - << " in \"" - << (e ? e->fileName() : std::string()) - << "\", line "; - if (e == 0) - { - stream << "0"; - } - else - { - stream << e->lineNumber(); - if (e->data2LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER) - { - stream << " data lines " << e->data1LineNumber() - << ", " << e->data2LineNumber(); - } - else if (e->data1LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER) - { - stream << " data line " << e->data1LineNumber(); - } - } - stream << "\n"; - i++; - } - } -} - - -void TextTestResult::printFailures(std::ostream& stream) -{ - if (testFailures() != 0) - { - stream << "\n"; - if (testFailures() == 1) - stream << "There was " << testFailures() << " failure: " << std::endl; - else - stream << "There were " << testFailures() << " failures: " << std::endl; - - int i = 1; - - for (std::vector::iterator it = failures().begin(); it != failures().end(); ++it) - { - TestFailure* failure = *it; - CppUnitException* e = failure->thrownException(); - - stream << std::setw(2) << i - << ": " - << failure->failedTest()->toString() << "\n" - << " \"" << (e ? e->what() : "") << "\"\n" - << " in \"" - << (e ? e->fileName() : std::string()) - << "\", line "; - if (e == 0) - { - stream << "0"; - } - else - { - stream << e->lineNumber(); - if (e->data2LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER) - { - stream << " data lines " - << e->data1LineNumber() - << ", " << e->data2LineNumber(); - } - else if (e->data1LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER) - { - stream << " data line " << e->data1LineNumber(); - } - } - stream << "\n"; - i++; - } - } -} - - -void TextTestResult::print(std::ostream& stream) -{ - printHeader(stream); - printErrors(stream); - printFailures(stream); -} - - -void TextTestResult::printHeader(std::ostream& stream) -{ - stream << "\n\n"; - if (wasSuccessful()) - stream << "OK (" - << runTests() << " tests)" - << std::endl; - else - stream << "!!!FAILURES!!!" << std::endl - << "Runs: " - << runTests () - << " Failures: " - << testFailures () - << " Errors: " - << testErrors () - << std::endl; -} - - -std::string TextTestResult::shortName(const std::string& testName) -{ - std::string::size_type pos = testName.rfind('.'); - if (pos != std::string::npos) - return std::string(testName, pos + 1); - else - return testName; -} - - -} // namespace CppUnit diff --git a/contrib/libpoco/Crypto/CMakeLists.txt b/contrib/libpoco/Crypto/CMakeLists.txt deleted file mode 100644 index 6a9ef188f96..00000000000 --- a/contrib/libpoco/Crypto/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -set(LIBNAME "PocoCrypto") -set(POCO_LIBNAME "${LIBNAME}") - -# Sources -file(GLOB SRCS_G "src/*.cpp") -POCO_SOURCES_AUTO( SRCS ${SRCS_G}) - -# Headers -file(GLOB_RECURSE HDRS_G "include/*.h" ) -POCO_HEADERS_AUTO( SRCS ${HDRS_G}) - -#add_definitions(-D_USRDLL) - -include_directories (BEFORE include) - -add_library( "${LIBNAME}" ${LIB_MODE} ${SRCS} ) -set_target_properties( "${LIBNAME}" - PROPERTIES - VERSION ${SHARED_LIBRARY_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION} - OUTPUT_NAME ${POCO_LIBNAME} - DEFINE_SYMBOL Crypto_EXPORTS - ) - -target_link_libraries( "${LIBNAME}" PocoFoundation ${OPENSSL_LIBRARIES} ) - -if (POCO_ENABLE_TESTS) - add_subdirectory(samples) - add_subdirectory(testsuite) -endif () diff --git a/contrib/libpoco/Crypto/cmake/PocoCryptoConfig.cmake b/contrib/libpoco/Crypto/cmake/PocoCryptoConfig.cmake deleted file mode 100644 index fe147f3afdc..00000000000 --- a/contrib/libpoco/Crypto/cmake/PocoCryptoConfig.cmake +++ /dev/null @@ -1,3 +0,0 @@ -include(CMakeFindDependencyMacro) -find_dependency(PocoFoundation) -include("${CMAKE_CURRENT_LIST_DIR}/PocoCryptoTargets.cmake") diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/Cipher.h b/contrib/libpoco/Crypto/include/Poco/Crypto/Cipher.h deleted file mode 100644 index 92ba5da9f4e..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/Cipher.h +++ /dev/null @@ -1,140 +0,0 @@ -// -// Cipher.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/Cipher.h#3 $ -// -// Library: Crypto -// Package: Cipher -// Module: Cipher -// -// Definition of the Cipher class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_Cipher_INCLUDED -#define Crypto_Cipher_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/RefCountedObject.h" -#include "Poco/AutoPtr.h" -#include -#include -#include - - -namespace Poco { -namespace Crypto { - - -class CryptoTransform; - - -class Crypto_API Cipher: public Poco::RefCountedObject - /// Represents the abstract base class from which all implementations of - /// symmetric/assymetric encryption algorithms must inherit. Use the CipherFactory - /// class to obtain an instance of this class: - /// - /// CipherFactory& factory = CipherFactory::defaultFactory(); - /// // Creates a 256-bit AES cipher - /// Cipher* pCipher = factory.createCipher(CipherKey("aes-256")); - /// Cipher* pRSACipher = factory.createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL)); - /// - /// Check the different Key constructors on how to initialize/create - /// a key. The above example auto-generates random keys. - /// - /// Note that you won't be able to decrypt data encrypted with a random key - /// once the Cipher is destroyed unless you persist the generated key and IV. - /// An example usage for random keys is to encrypt data saved in a temporary - /// file. - /// - /// Once your key is set up, you can use the Cipher object to encrypt or - /// decrypt strings or, in conjunction with a CryptoInputStream or a - /// CryptoOutputStream, to encrypt streams of data. - /// - /// Since encrypted strings will contain arbitary binary data that will cause - /// problems in applications that are not binary-safe (eg., when sending - /// encrypted data in e-mails), the encryptString() and decryptString() can - /// encode (or decode, respectively) encrypted data using a "transport encoding". - /// Supported encodings are Base64 and BinHex. - /// - /// The following example encrypts and decrypts a string utilizing Base64 - /// encoding: - /// - /// std::string plainText = "This is my secret information"; - /// std::string encrypted = pCipher->encryptString(plainText, Cipher::ENC_BASE64); - /// std::string decrypted = pCipher->decryptString(encrypted, Cipher::ENC_BASE64); - /// - /// In order to encrypt a stream of data (eg. to encrypt files), you can use - /// a CryptoStream: - /// - /// // Create an output stream that will encrypt all data going through it - /// // and write pass it to the underlying file stream. - /// Poco::FileOutputStream sink("encrypted.dat"); - /// CryptoOutputStream encryptor(sink, pCipher->createEncryptor()); - /// - /// Poco::FileInputStream source("source.txt"); - /// Poco::StreamCopier::copyStream(source, encryptor); - /// - /// // Always close output streams to flush all internal buffers - /// encryptor.close(); - /// sink.close(); -{ -public: - typedef Poco::AutoPtr Ptr; - typedef std::vector ByteVec; - - enum Encoding - /// Transport encoding to use for encryptString() and decryptString(). - { - ENC_NONE = 0x00, /// Plain binary output - ENC_BASE64 = 0x01, /// Base64-encoded output - ENC_BINHEX = 0x02, /// BinHex-encoded output - ENC_BASE64_NO_LF = 0x81, /// Base64-encoded output, no linefeeds - ENC_BINHEX_NO_LF = 0x82 /// BinHex-encoded output, no linefeeds - - }; - - virtual ~Cipher(); - /// Destroys the Cipher. - - virtual const std::string& name() const = 0; - /// Returns the name of the Cipher. - - virtual CryptoTransform* createEncryptor() = 0; - /// Creates an encrytor object to be used with a CryptoStream. - - virtual CryptoTransform* createDecryptor() = 0; - /// Creates a decryptor object to be used with a CryptoStream. - - virtual std::string encryptString(const std::string& str, Encoding encoding = ENC_NONE); - /// Directly encrypt a string and encode it using the given encoding. - - virtual std::string decryptString(const std::string& str, Encoding encoding = ENC_NONE); - /// Directly decrypt a string that is encoded with the given encoding. - - virtual void encrypt(std::istream& source, std::ostream& sink, Encoding encoding = ENC_NONE); - /// Directly encrypts an input stream and encodes it using the given encoding. - - virtual void decrypt(std::istream& source, std::ostream& sink, Encoding encoding = ENC_NONE); - /// Directly decrypt an input stream that is encoded with the given encoding. - -protected: - Cipher(); - /// Creates a new Cipher object. - -private: - Cipher(const Cipher&); - Cipher& operator = (const Cipher&); -}; - - -} } // namespace Poco::Crypto - - -#endif // Crypto_Cipher_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/CipherFactory.h b/contrib/libpoco/Crypto/include/Poco/Crypto/CipherFactory.h deleted file mode 100644 index 7cfd73e6fda..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/CipherFactory.h +++ /dev/null @@ -1,77 +0,0 @@ -// -// CipherFactory.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/CipherFactory.h#1 $ -// -// Library: Crypto -// Package: Cipher -// Module: CipherFactory -// -// Definition of the CipherFactory class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_CipherFactory_INCLUDED -#define Crypto_CipherFactory_INCLUDED - - -#include "Poco/Crypto/Crypto.h" - - -namespace Poco { -namespace Crypto { - - -class Cipher; -class CipherKey; -class RSAKey; - - -class Crypto_API CipherFactory - /// A factory for Cipher objects. See the Cipher class for examples on how to - /// use the CipherFactory. -{ -public: - CipherFactory(); - /// Creates a new CipherFactory object. - - virtual ~CipherFactory(); - /// Destroys the CipherFactory. - - Cipher* createCipher(const CipherKey& key); - /// Creates a Cipher object for the given Cipher name. Valid cipher - /// names depend on the OpenSSL version the library is linked with; - /// see the output of - /// - /// openssl enc --help - /// - /// for a list of supported block and stream ciphers. - /// - /// Common examples are: - /// - /// * AES: "aes-128", "aes-256" - /// * DES: "des", "des3" - /// * Blowfish: "bf" - - Cipher* createCipher(const RSAKey& key, RSAPaddingMode paddingMode = RSA_PADDING_PKCS1); - /// Creates a RSACipher using the given RSA key and padding mode - /// for public key encryption/private key decryption. - - static CipherFactory& defaultFactory(); - /// Returns the default CipherFactory. - -private: - CipherFactory(const CipherFactory&); - CipherFactory& operator = (const CipherFactory&); -}; - - -} } // namespace Poco::Crypto - - -#endif // Crypto_CipherFactory_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/CipherImpl.h b/contrib/libpoco/Crypto/include/Poco/Crypto/CipherImpl.h deleted file mode 100644 index 1a1f10b6e50..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/CipherImpl.h +++ /dev/null @@ -1,71 +0,0 @@ -// -// CipherImpl.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/CipherImpl.h#2 $ -// -// Library: Crypto -// Package: Cipher -// Module: CipherImpl -// -// Definition of the CipherImpl class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_CipherImpl_INCLUDED -#define Crypto_CipherImpl_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/Crypto/Cipher.h" -#include "Poco/Crypto/CipherKey.h" -#include "Poco/Crypto/OpenSSLInitializer.h" -#include - - -namespace Poco { -namespace Crypto { - - -class CipherImpl: public Cipher - /// An implementation of the Cipher class for OpenSSL's crypto library. -{ -public: - CipherImpl(const CipherKey& key); - /// Creates a new CipherImpl object for the given CipherKey. - - virtual ~CipherImpl(); - /// Destroys the CipherImpl. - - const std::string& name() const; - /// Returns the name of the cipher. - - CryptoTransform* createEncryptor(); - /// Creates an encrytor object. - - CryptoTransform* createDecryptor(); - /// Creates a decrytor object. - -private: - CipherKey _key; - OpenSSLInitializer _openSSLInitializer; -}; - - -// -// Inlines -// -inline const std::string& CipherImpl::name() const -{ - return _key.name(); -} - - -} } // namespace Poco::Crypto - - -#endif // Crypto_CipherImpl_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/CipherKey.h b/contrib/libpoco/Crypto/include/Poco/Crypto/CipherKey.h deleted file mode 100644 index 792de73b2e1..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/CipherKey.h +++ /dev/null @@ -1,184 +0,0 @@ -// -// CipherKey.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/CipherKey.h#1 $ -// -// Library: Crypto -// Package: Cipher -// Module: CipherKey -// -// Definition of the CipherKey class. -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_CipherKey_INCLUDED -#define Crypto_CipherKey_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/Crypto/CipherKeyImpl.h" - - -namespace Poco { -namespace Crypto { - - -class Crypto_API CipherKey - /// CipherKey stores the key information for decryption/encryption of data. - /// To create a random key, using the following code: - /// - /// CipherKey key("aes-256"); - /// - /// Note that you won't be able to decrypt data encrypted with a random key - /// once the Cipher is destroyed unless you persist the generated key and IV. - /// An example usage for random keys is to encrypt data saved in a temporary - /// file. - /// - /// To create a key using a human-readable password - /// string, use the following code. We create a AES Cipher and - /// use a salt value to make the key more robust: - /// - /// std::string password = "secret"; - /// std::string salt("asdff8723lasdf(**923412"); - /// CipherKey key("aes-256", password, salt); - /// -{ -public: - typedef CipherKeyImpl::Mode Mode; - typedef CipherKeyImpl::ByteVec ByteVec; - - enum - { - DEFAULT_ITERATION_COUNT = 2000 - /// Default iteration count to use with - /// generateKey(). RSA security recommends - /// an iteration count of at least 1000. - }; - - CipherKey(const std::string& name, - const std::string& passphrase, - const std::string& salt = "", - int iterationCount = DEFAULT_ITERATION_COUNT); - /// Creates a new CipherKeyImpl object using the given - /// cipher name, passphrase, salt value and iteration count. - - CipherKey(const std::string& name, - const ByteVec& key, - const ByteVec& iv); - /// Creates a new CipherKeyImpl object using the given cipher - /// name, key and initialization vector. - - CipherKey(const std::string& name); - /// Creates a new CipherKeyImpl object. Autoinitializes key and - /// initialization vector. - - ~CipherKey(); - /// Destroys the CipherKeyImpl. - - const std::string& name() const; - /// Returns the name of the Cipher. - - int keySize() const; - /// Returns the key size of the Cipher. - - int blockSize() const; - /// Returns the block size of the Cipher. - - int ivSize() const; - /// Returns the IV size of the Cipher. - - Mode mode() const; - /// Returns the Cipher's mode of operation. - - const ByteVec& getKey() const; - /// Returns the key for the Cipher. - - void setKey(const ByteVec& key); - /// Sets the key for the Cipher. - - const ByteVec& getIV() const; - /// Returns the initialization vector (IV) for the Cipher. - - void setIV(const ByteVec& iv); - /// Sets the initialization vector (IV) for the Cipher. - - CipherKeyImpl::Ptr impl(); - /// Returns the impl object - -private: - CipherKeyImpl::Ptr _pImpl; -}; - - -// -// inlines -// -inline const std::string& CipherKey::name() const -{ - return _pImpl->name(); -} - - -inline int CipherKey::keySize() const -{ - return _pImpl->keySize(); -} - - -inline int CipherKey::blockSize() const -{ - return _pImpl->blockSize(); -} - - -inline int CipherKey::ivSize() const -{ - return _pImpl->ivSize(); -} - - -inline CipherKey::Mode CipherKey::mode() const -{ - return _pImpl->mode(); -} - - -inline const CipherKey::ByteVec& CipherKey::getKey() const -{ - return _pImpl->getKey(); -} - - -inline void CipherKey::setKey(const CipherKey::ByteVec& key) -{ - _pImpl->setKey(key); -} - - -inline const CipherKey::ByteVec& CipherKey::getIV() const -{ - return _pImpl->getIV(); -} - - -inline void CipherKey::setIV(const CipherKey::ByteVec& iv) -{ - _pImpl->setIV(iv); -} - - -inline CipherKeyImpl::Ptr CipherKey::impl() -{ - return _pImpl; -} - - -} } // namespace Poco::Crypto - - -#endif // Crypto_CipherKey_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/CipherKeyImpl.h b/contrib/libpoco/Crypto/include/Poco/Crypto/CipherKeyImpl.h deleted file mode 100644 index 3b9e7bfce0a..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/CipherKeyImpl.h +++ /dev/null @@ -1,172 +0,0 @@ -// -// CipherKeyImpl.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/CipherKeyImpl.h#3 $ -// -// Library: Crypto -// Package: Cipher -// Module: CipherKeyImpl -// -// Definition of the CipherKeyImpl class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_CipherKeyImpl_INCLUDED -#define Crypto_CipherKeyImpl_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/Crypto/OpenSSLInitializer.h" -#include "Poco/RefCountedObject.h" -#include "Poco/AutoPtr.h" -#include - - -struct evp_cipher_st; -typedef struct evp_cipher_st EVP_CIPHER; - - -namespace Poco { -namespace Crypto { - - -class CipherKeyImpl: public RefCountedObject - /// An implementation of the CipherKey class for OpenSSL's crypto library. -{ -public: - typedef std::vector ByteVec; - typedef Poco::AutoPtr Ptr; - - enum Mode - /// Cipher mode of operation. This mode determines how multiple blocks - /// are connected; this is essential to improve security. - { - MODE_STREAM_CIPHER, /// Stream cipher - MODE_ECB, /// Electronic codebook (plain concatenation) - MODE_CBC, /// Cipher block chaining (default) - MODE_CFB, /// Cipher feedback - MODE_OFB /// Output feedback - }; - - CipherKeyImpl(const std::string& name, - const std::string& passphrase, - const std::string& salt, - int iterationCount); - /// Creates a new CipherKeyImpl object, using - /// the given cipher name, passphrase, salt value - /// and iteration count. - - CipherKeyImpl(const std::string& name, - const ByteVec& key, - const ByteVec& iv); - /// Creates a new CipherKeyImpl object, using the - /// given cipher name, key and initialization vector. - - CipherKeyImpl(const std::string& name); - /// Creates a new CipherKeyImpl object. Autoinitializes key - /// and initialization vector. - - virtual ~CipherKeyImpl(); - /// Destroys the CipherKeyImpl. - - const std::string& name() const; - /// Returns the name of the Cipher. - - int keySize() const; - /// Returns the key size of the Cipher. - - int blockSize() const; - /// Returns the block size of the Cipher. - - int ivSize() const; - /// Returns the IV size of the Cipher. - - Mode mode() const; - /// Returns the Cipher's mode of operation. - - const ByteVec& getKey() const; - /// Returns the key for the Cipher. - - void setKey(const ByteVec& key); - /// Sets the key for the Cipher. - - const ByteVec& getIV() const; - /// Returns the initialization vector (IV) for the Cipher. - - void setIV(const ByteVec& iv); - /// Sets the initialization vector (IV) for the Cipher. - - const EVP_CIPHER* cipher(); - /// Returns the cipher object - -private: - void generateKey(const std::string& passphrase, - const std::string& salt, - int iterationCount); - /// Generates key and IV from a password and optional salt string. - - void generateKey(); - /// Generates key and IV from random data. - - void getRandomBytes(ByteVec& vec, std::size_t count); - /// Stores random bytes in vec. - -private: - const EVP_CIPHER* _pCipher; - std::string _name; - ByteVec _key; - ByteVec _iv; - OpenSSLInitializer _openSSLInitializer; -}; - - -// -// Inlines -// -inline const std::string& CipherKeyImpl::name() const -{ - return _name; -} - - -inline const CipherKeyImpl::ByteVec& CipherKeyImpl::getKey() const -{ - return _key; -} - - -inline void CipherKeyImpl::setKey(const ByteVec& key) -{ - poco_assert(key.size() == static_cast(keySize())); - _key = key; -} - - -inline const CipherKeyImpl::ByteVec& CipherKeyImpl::getIV() const -{ - return _iv; -} - - -inline void CipherKeyImpl::setIV(const ByteVec& iv) -{ - poco_assert(iv.size() == static_cast(ivSize())); - _iv = iv; -} - - -inline const EVP_CIPHER* CipherKeyImpl::cipher() -{ - return _pCipher; -} - - -} } // namespace Poco::Crypto - - -#endif // Crypto_CipherKeyImpl_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/Crypto.h b/contrib/libpoco/Crypto/include/Poco/Crypto/Crypto.h deleted file mode 100644 index fcfb20ec26f..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/Crypto.h +++ /dev/null @@ -1,119 +0,0 @@ -// -// Crypto.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/Crypto.h#3 $ -// -// Library: Crypto -// Package: CryptoCore -// Module: Crypto -// -// Basic definitions for the Poco Crypto library. -// This file must be the first file included by every other Crypto -// header file. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_Crypto_INCLUDED -#define Crypto_Crypto_INCLUDED - - -#if defined(__APPLE__) -// OS X 10.7 deprecates some OpenSSL functions -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif - - -#include "Poco/Foundation.h" - - -enum RSAPaddingMode - /// The padding mode used for RSA public key encryption. -{ - RSA_PADDING_PKCS1, - /// PKCS #1 v1.5 padding. This currently is the most widely used mode. - - RSA_PADDING_PKCS1_OAEP, - /// EME-OAEP as defined in PKCS #1 v2.0 with SHA-1, MGF1 and an empty - /// encoding parameter. This mode is recommended for all new applications. - - RSA_PADDING_SSLV23, - /// PKCS #1 v1.5 padding with an SSL-specific modification that denotes - /// that the server is SSL3 capable. - - RSA_PADDING_NONE - /// Raw RSA encryption. This mode should only be used to implement cryptographically - /// sound padding modes in the application code. Encrypting user data directly with RSA - /// is insecure. -}; - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the Crypto_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// Crypto_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && defined(POCO_DLL) - #if defined(Crypto_EXPORTS) - #define Crypto_API __declspec(dllexport) - #else - #define Crypto_API __declspec(dllimport) - #endif -#endif - - -#if !defined(Crypto_API) - #if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4) - #define Crypto_API __attribute__ ((visibility ("default"))) - #else - #define Crypto_API - #endif -#endif - - -// -// Automatically link Crypto library. -// -#if defined(_MSC_VER) - #if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(Crypto_EXPORTS) - #pragma comment(lib, "PocoCrypto" POCO_LIB_SUFFIX) - #endif -#endif - - -namespace Poco { -namespace Crypto { - - -void Crypto_API initializeCrypto(); - /// Initialize the Crypto library, as well as the underlying OpenSSL - /// libraries, by calling OpenSSLInitializer::initialize(). - /// - /// Should be called before using any class from the Crypto library. - /// The Crypto library will be initialized automatically, through - /// OpenSSLInitializer instances held by various Crypto classes - /// (Cipher, CipherKey, RSAKey, X509Certificate). - /// However, it is recommended to call initializeCrypto() - /// in any case at application startup. - /// - /// Can be called multiple times; however, for every call to - /// initializeCrypto(), a matching call to uninitializeCrypto() - /// must be performed. - - -void Crypto_API uninitializeCrypto(); - /// Uninitializes the Crypto library by calling - /// OpenSSLInitializer::uninitialize(). - - -} } // namespace Poco::Crypto - - -#endif // Crypto_Crypto_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/CryptoStream.h b/contrib/libpoco/Crypto/include/Poco/Crypto/CryptoStream.h deleted file mode 100644 index 469b05cf6d1..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/CryptoStream.h +++ /dev/null @@ -1,194 +0,0 @@ -// -// CryptoStream.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/CryptoStream.h#2 $ -// -// Library: Crypto -// Package: Cipher -// Module: CryptoStream -// -// Definition of the CryptoStreamBuf, CryptoInputStream and CryptoOutputStream -// classes. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_CryptoStream_INCLUDED -#define Crypto_CryptoStream_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/BufferedStreamBuf.h" -#include "Poco/Buffer.h" -#include - - -namespace Poco { -namespace Crypto { - - -class CryptoTransform; -class Cipher; - - -class Crypto_API CryptoStreamBuf: public Poco::BufferedStreamBuf - /// This stream buffer performs cryptographic transformation on the data - /// going through it. -{ -public: - CryptoStreamBuf(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192); - CryptoStreamBuf(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192); - - virtual ~CryptoStreamBuf(); - - void close(); - /// Flushes all buffers and finishes the encryption. - -protected: - int readFromDevice(char* buffer, std::streamsize length); - int writeToDevice(const char* buffer, std::streamsize length); - -private: - CryptoTransform* _pTransform; - std::istream* _pIstr; - std::ostream* _pOstr; - bool _eof; - - Poco::Buffer _buffer; - - CryptoStreamBuf(const CryptoStreamBuf&); - CryptoStreamBuf& operator = (const CryptoStreamBuf&); -}; - - -class Crypto_API CryptoIOS: public virtual std::ios - /// The base class for CryptoInputStream and CryptoOutputStream. - /// - /// This class is needed to ensure correct initialization order of the - /// stream buffer and base classes. -{ -public: - CryptoIOS(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192); - CryptoIOS(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192); - ~CryptoIOS(); - CryptoStreamBuf* rdbuf(); - -protected: - CryptoStreamBuf _buf; -}; - - -class Crypto_API CryptoInputStream: public CryptoIOS, public std::istream - /// This stream transforms all data passing through it using the given - /// CryptoTransform. - /// - /// Use a CryptoTransform object provided by Cipher::createEncrytor() or - /// Cipher::createDecryptor() to create an encrypting or decrypting stream, - /// respectively. -{ -public: - CryptoInputStream(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192); - /// Create a new CryptoInputStream object. The CryptoInputStream takes the - /// ownership of the given CryptoTransform object. - - CryptoInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize = 8192); - /// Create a new encrypting CryptoInputStream object using the given cipher. - - ~CryptoInputStream(); - /// Destroys the CryptoInputStream. -}; - - -class Crypto_API CryptoOutputStream: public CryptoIOS, public std::ostream - /// This stream transforms all data passing through it using the given - /// CryptoTransform. - /// - /// Use a CryptoTransform object provided by Cipher::createEncrytor() or - /// Cipher::createDecryptor() to create an encrypting or decrypting stream, - /// respectively. - /// - /// After all data has been passed through the stream, close() must be called - /// to ensure completion of cryptographic transformation. -{ -public: - CryptoOutputStream(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192); - /// Create a new CryptoOutputStream object. The CryptoOutputStream takes the - /// ownership of the given CryptoTransform object. - - CryptoOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize = 8192); - /// Create a new decrypting CryptoOutputStream object using the given cipher. - - ~CryptoOutputStream(); - /// Destroys the CryptoOutputStream. - - void close(); - /// Flushes all buffers and finishes the encryption. -}; - - -class Crypto_API DecryptingInputStream: public CryptoIOS, public std::istream - /// This stream decrypts all data passing through it using the given - /// Cipher. -{ -public: - DecryptingInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize = 8192); - /// Create a new DecryptingInputStream object using the given cipher. - - ~DecryptingInputStream(); - /// Destroys the DecryptingInputStream. -}; - - -class Crypto_API DecryptingOutputStream: public CryptoIOS, public std::ostream - /// This stream decrypts all data passing through it using the given - /// Cipher. -{ -public: - DecryptingOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize = 8192); - /// Create a new DecryptingOutputStream object using the given cipher. - - ~DecryptingOutputStream(); - /// Destroys the DecryptingOutputStream. - - void close(); - /// Flushes all buffers and finishes the decryption. -}; - - -class Crypto_API EncryptingInputStream: public CryptoIOS, public std::istream - /// This stream encrypts all data passing through it using the given - /// Cipher. -{ -public: - EncryptingInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize = 8192); - /// Create a new EncryptingInputStream object using the given cipher. - - ~EncryptingInputStream(); - /// Destroys the EncryptingInputStream. -}; - - -class Crypto_API EncryptingOutputStream: public CryptoIOS, public std::ostream - /// This stream encrypts all data passing through it using the given - /// Cipher. -{ -public: - EncryptingOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize = 8192); - /// Create a new EncryptingOutputStream object using the given cipher. - - ~EncryptingOutputStream(); - /// Destroys the EncryptingOutputStream. - - void close(); - /// Flushes all buffers and finishes the encryption. -}; - - -} } // namespace Poco::Crypto - - -#endif // Crypto_CryptoStream_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/CryptoTransform.h b/contrib/libpoco/Crypto/include/Poco/Crypto/CryptoTransform.h deleted file mode 100644 index 1bae01ff547..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/CryptoTransform.h +++ /dev/null @@ -1,78 +0,0 @@ -// -// CryptoTransform.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/CryptoTransform.h#2 $ -// -// Library: Crypto -// Package: Cipher -// Module: CryptoTransform -// -// Definition of the CryptoTransform class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_CryptoTransform_INCLUDED -#define Crypto_CryptoTransform_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include - - -namespace Poco { -namespace Crypto { - - -class Crypto_API CryptoTransform - /// This interface represents the basic operations for cryptographic - /// transformations to be used with a CryptoInputStream or a - /// CryptoOutputStream. - /// - /// Implementations of this class are returned by the Cipher class to - /// perform encryption or decryption of data. -{ -public: - CryptoTransform(); - /// Creates a new CryptoTransform object. - - virtual ~CryptoTransform(); - /// Destroys the CryptoTransform. - - virtual std::size_t blockSize() const = 0; - /// Returns the block size for this CryptoTransform. - - virtual int setPadding(int padding); - /// Enables or disables padding. By default encryption operations are padded using standard block - /// padding and the padding is checked and removed when decrypting. If the padding parameter is zero then - /// no padding is performed, the total amount of data encrypted or decrypted must then be a multiple of - /// the block size or an error will occur. - - virtual std::streamsize transform( - const unsigned char* input, - std::streamsize inputLength, - unsigned char* output, - std::streamsize outputLength) = 0; - /// Transforms a chunk of data. The inputLength is arbitrary and does not - /// need to be a multiple of the block size. The output buffer has a maximum - /// capacity of the given outputLength that must be at least - /// inputLength + blockSize() - 1 - /// Returns the number of bytes written to the output buffer. - - virtual std::streamsize finalize(unsigned char* output, std::streamsize length) = 0; - /// Finalizes the transformation. The output buffer must contain enough - /// space for at least two blocks, ie. - /// length >= 2*blockSize() - /// must be true. Returns the number of bytes written to the output - /// buffer. -}; - - -} } // namespace Poco::Crypto - - -#endif // Crypto_CryptoTransform_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/DigestEngine.h b/contrib/libpoco/Crypto/include/Poco/Crypto/DigestEngine.h deleted file mode 100644 index e2121c414df..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/DigestEngine.h +++ /dev/null @@ -1,82 +0,0 @@ -// -// DigestEngine.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/DigestEngine.h#1 $ -// -// Library: Crypto -// Package: Digest -// Module: DigestEngine -// -// Definition of the DigestEngine class. -// -// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_DigestEngine_INCLUDED -#define Crypto_DigestEngine_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/Crypto/OpenSSLInitializer.h" -#include "Poco/DigestEngine.h" -#include - - -namespace Poco { -namespace Crypto { - - -class Crypto_API DigestEngine: public Poco::DigestEngine - /// This class implements a Poco::DigestEngine for all - /// digest algorithms supported by OpenSSL. -{ -public: - DigestEngine(const std::string& name); - /// Creates a DigestEngine using the digest with the given name - /// (e.g., "MD5", "SHA1", "SHA256", "SHA512", etc.). - /// See the OpenSSL documentation for a list of supported digest algorithms. - /// - /// Throws a Poco::NotFoundException if no algorithm with the given name exists. - - ~DigestEngine(); - /// Destroys the DigestEngine. - - const std::string& algorithm() const; - /// Returns the name of the digest algorithm. - - int nid() const; - /// Returns the NID (OpenSSL object identifier) of the digest algorithm. - - // DigestEngine - std::size_t digestLength() const; - void reset(); - const Poco::DigestEngine::Digest& digest(); - -protected: - void updateImpl(const void* data, std::size_t length); - -private: - std::string _name; - EVP_MD_CTX* _pContext; - Poco::DigestEngine::Digest _digest; - OpenSSLInitializer _openSSLInitializer; -}; - - -// -// inlines -// -inline const std::string& DigestEngine::algorithm() const -{ - return _name; -} - - -} } // namespace Poco::Crypto - - -#endif // Crypto_DigestEngine_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/OpenSSLInitializer.h b/contrib/libpoco/Crypto/include/Poco/Crypto/OpenSSLInitializer.h deleted file mode 100644 index 868530062cb..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/OpenSSLInitializer.h +++ /dev/null @@ -1,117 +0,0 @@ -// -// OpenSSLInitializer.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/OpenSSLInitializer.h#1 $ -// -// Library: Crypto -// Package: CryptoCore -// Module: OpenSSLInitializer -// -// Definition of the OpenSSLInitializer class. -// -// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_OpenSSLInitializer_INCLUDED -#define Crypto_OpenSSLInitializer_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/Mutex.h" -#include "Poco/AtomicCounter.h" -#include -#include -#if defined(OPENSSL_FIPS) && OPENSSL_VERSION_NUMBER < 0x010001000L -#include -#endif - - -extern "C" -{ - struct CRYPTO_dynlock_value - { - Poco::FastMutex _mutex; - }; -} - - -namespace Poco { -namespace Crypto { - - -class Crypto_API OpenSSLInitializer - /// Initalizes the OpenSSL library. - /// - /// The class ensures the earliest initialization and the - /// latest shutdown of the OpenSSL library. -{ -public: - OpenSSLInitializer(); - /// Automatically initialize OpenSSL on startup. - - ~OpenSSLInitializer(); - /// Automatically shut down OpenSSL on exit. - - static void initialize(); - /// Initializes the OpenSSL machinery. - - static void uninitialize(); - /// Shuts down the OpenSSL machinery. - - static bool isFIPSEnabled(); - // Returns true if FIPS mode is enabled, false otherwise. - - static void enableFIPSMode(bool enabled); - // Enable or disable FIPS mode. If FIPS is not available, this method doesn't do anything. - -protected: - enum - { - SEEDSIZE = 256 - }; - - // OpenSSL multithreading support - static void lock(int mode, int n, const char* file, int line); - static unsigned long id(); - static struct CRYPTO_dynlock_value* dynlockCreate(const char* file, int line); - static void dynlock(int mode, struct CRYPTO_dynlock_value* lock, const char* file, int line); - static void dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line); - -private: - static Poco::FastMutex* _mutexes; - static Poco::AtomicCounter _rc; -}; - - -// -// inlines -// -inline bool OpenSSLInitializer::isFIPSEnabled() -{ -#ifdef OPENSSL_FIPS - return FIPS_mode() ? true : false; -#else - return false; -#endif -} - -#ifdef OPENSSL_FIPS -inline void OpenSSLInitializer::enableFIPSMode(bool enabled) -{ - FIPS_mode_set(enabled); -} -#else -inline void OpenSSLInitializer::enableFIPSMode(bool /*enabled*/) -{ -} -#endif - - -} } // namespace Poco::Crypto - - -#endif // Crypto_OpenSSLInitializer_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/RSACipherImpl.h b/contrib/libpoco/Crypto/include/Poco/Crypto/RSACipherImpl.h deleted file mode 100644 index 6d433ed1f4b..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/RSACipherImpl.h +++ /dev/null @@ -1,79 +0,0 @@ -// -// RSACipherImpl.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSACipherImpl.h#2 $ -// -// Library: Crypto -// Package: RSA -// Module: RSACipherImpl -// -// Definition of the RSACipherImpl class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_RSACipherImpl_INCLUDED -#define Crypto_RSACipherImpl_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/Crypto/Cipher.h" -#include "Poco/Crypto/RSAKey.h" -#include "Poco/Crypto/OpenSSLInitializer.h" -#include - - -namespace Poco { -namespace Crypto { - - -class RSACipherImpl: public Cipher - /// An implementation of the Cipher class for - /// assymetric (public-private key) encryption - /// based on the the RSA algorithm in OpenSSL's - /// crypto library. - /// - /// Encryption is using the public key, decryption - /// requires the private key. -{ -public: - RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode); - /// Creates a new RSACipherImpl object for the given RSAKey - /// and using the given padding mode. - - virtual ~RSACipherImpl(); - /// Destroys the RSACipherImpl. - - const std::string& name() const; - /// Returns the name of the Cipher. - - CryptoTransform* createEncryptor(); - /// Creates an encrytor object. - - CryptoTransform* createDecryptor(); - /// Creates a decrytor object. - -private: - RSAKey _key; - RSAPaddingMode _paddingMode; - OpenSSLInitializer _openSSLInitializer; -}; - - -// -// Inlines -// -inline const std::string& RSACipherImpl::name() const -{ - return _key.name(); -} - - -} } // namespace Poco::Crypto - - -#endif // Crypto_RSACipherImpl_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/RSADigestEngine.h b/contrib/libpoco/Crypto/include/Poco/Crypto/RSADigestEngine.h deleted file mode 100644 index e4e8479151a..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/RSADigestEngine.h +++ /dev/null @@ -1,113 +0,0 @@ -// -// RSADigestEngine.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSADigestEngine.h#1 $ -// -// Library: Crypto -// Package: RSA -// Module: RSADigestEngine -// -// Definition of the RSADigestEngine class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_RSADigestEngine_INCLUDED -#define Crypto_RSADigestEngine_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/Crypto/RSAKey.h" -#include "Poco/DigestEngine.h" -#include "Poco/Crypto/DigestEngine.h" -#include -#include - - -namespace Poco { -namespace Crypto { - - -class Crypto_API RSADigestEngine: public Poco::DigestEngine - /// This class implements a Poco::DigestEngine that can be - /// used to compute a secure digital signature. - /// - /// First another Poco::Crypto::DigestEngine is created and - /// used to compute a cryptographic hash of the data to be - /// signed. Then, the hash value is encrypted, using - /// the RSA private key. - /// - /// To verify a signature, pass it to the verify() - /// member function. It will decrypt the signature - /// using the RSA public key and compare the resulting - /// hash with the actual hash of the data. -{ -public: - enum DigestType - { - DIGEST_MD5, - DIGEST_SHA1 - }; - - //@ deprecated - RSADigestEngine(const RSAKey& key, DigestType digestType = DIGEST_SHA1); - /// Creates the RSADigestEngine with the given RSA key, - /// using the MD5 or SHA-1 hash algorithm. - /// Kept for backward compatibility - - RSADigestEngine(const RSAKey& key, const std::string &name); - /// Creates the RSADigestEngine with the given RSA key, - /// using the hash algorithm with the given name - /// (e.g., "MD5", "SHA1", "SHA256", "SHA512", etc.). - /// See the OpenSSL documentation for a list of supported digest algorithms. - /// - /// Throws a Poco::NotFoundException if no algorithm with the given name exists. - - ~RSADigestEngine(); - /// Destroys the RSADigestEngine. - - std::size_t digestLength() const; - /// Returns the length of the digest in bytes. - - void reset(); - /// Resets the engine so that a new - /// digest can be computed. - - const DigestEngine::Digest& digest(); - /// Finishes the computation of the digest - /// (the first time it's called) and - /// returns the message digest. - /// - /// Can be called multiple times. - - const DigestEngine::Digest& signature(); - /// Signs the digest using the RSA algorithm - /// and the private key (teh first time it's - /// called) and returns the result. - /// - /// Can be called multiple times. - - bool verify(const DigestEngine::Digest& signature); - /// Verifies the data against the signature. - /// - /// Returns true if the signature can be verified, false otherwise. - -protected: - void updateImpl(const void* data, std::size_t length); - -private: - RSAKey _key; - Poco::Crypto::DigestEngine _engine; - Poco::DigestEngine::Digest _digest; - Poco::DigestEngine::Digest _signature; -}; - - -} } // namespace Poco::Crypto - - -#endif // Crypto_RSADigestEngine_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/RSAKey.h b/contrib/libpoco/Crypto/include/Poco/Crypto/RSAKey.h deleted file mode 100644 index a6a6bc206db..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/RSAKey.h +++ /dev/null @@ -1,133 +0,0 @@ -// -// RSAKey.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSAKey.h#2 $ -// -// Library: Crypto -// Package: RSA -// Module: RSAKey -// -// Definition of the RSAKey class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_RSAKey_INCLUDED -#define Crypto_RSAKey_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/Crypto/RSAKeyImpl.h" - - -namespace Poco { -namespace Crypto { - - -class X509Certificate; - - -class Crypto_API RSAKey - /// This class stores an RSA key pair, consisting - /// of private and public key. Storage of the private - /// key is optional. - /// - /// If a private key is available, the RSAKey can be - /// used for decrypting data (encrypted with the public key) - /// or computing secure digital signatures. -{ -public: - enum KeyLength - { - KL_512 = 512, - KL_1024 = 1024, - KL_2048 = 2048, - KL_4096 = 4096 - }; - - enum Exponent - { - EXP_SMALL = 0, - EXP_LARGE - }; - - explicit RSAKey(const X509Certificate& cert); - /// Extracts the RSA public key from the given certificate. - - RSAKey(KeyLength keyLength, Exponent exp); - /// Creates the RSAKey. Creates a new public/private keypair using the given parameters. - /// Can be used to sign data and verify signatures. - - RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = ""); - /// Creates the RSAKey, by reading public and private key from the given files and - /// using the given passphrase for the private key. - /// - /// Cannot be used for signing or decryption unless a private key is available. - /// - /// If a private key is specified, you don't need to specify a public key file. - /// OpenSSL will auto-create the public key from the private key. - - RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = ""); - /// Creates the RSAKey, by reading public and private key from the given streams and - /// using the given passphrase for the private key. - /// - /// Cannot be used for signing or decryption unless a private key is available. - /// - /// If a private key is specified, you don't need to specify a public key file. - /// OpenSSL will auto-create the public key from the private key. - - ~RSAKey(); - /// Destroys the RSAKey. - - int size() const; - /// Returns the RSA modulus size. - - RSAKeyImpl::ByteVec modulus() const; - /// Returns the RSA modulus. - - RSAKeyImpl::ByteVec encryptionExponent() const; - /// Returns the RSA encryption exponent. - - RSAKeyImpl::ByteVec decryptionExponent() const; - /// Returns the RSA decryption exponent. - - void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = ""); - /// Exports the public and private keys to the given files. - /// - /// If an empty filename is specified, the corresponding key - /// is not exported. - - void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = ""); - /// Exports the public and private key to the given streams. - /// - /// If a null pointer is passed for a stream, the corresponding - /// key is not exported. - - RSAKeyImpl::Ptr impl() const; - /// Returns the impl object. - - const std::string& name() const; - /// Returns "rsa" - -private: - RSAKeyImpl::Ptr _pImpl; -}; - - -// -// inlines -// -inline RSAKeyImpl::Ptr RSAKey::impl() const -{ - return _pImpl; -} - - -} } // namespace Poco::Crypto - - -#endif // Crypto_RSAKey_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/RSAKeyImpl.h b/contrib/libpoco/Crypto/include/Poco/Crypto/RSAKeyImpl.h deleted file mode 100644 index f439a3d1874..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/RSAKeyImpl.h +++ /dev/null @@ -1,131 +0,0 @@ -// -// RSAKeyImpl.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSAKeyImpl.h#3 $ -// -// Library: Crypto -// Package: RSA -// Module: RSAKeyImpl -// -// Definition of the RSAKeyImpl class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_RSAKeyImplImpl_INCLUDED -#define Crypto_RSAKeyImplImpl_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/Crypto/OpenSSLInitializer.h" -#include "Poco/RefCountedObject.h" -#include "Poco/AutoPtr.h" -#include -#include -#include - - -struct bignum_st; -struct rsa_st; -typedef struct bignum_st BIGNUM; -typedef struct rsa_st RSA; - - -namespace Poco { -namespace Crypto { - - -class X509Certificate; - - -class RSAKeyImpl: public Poco::RefCountedObject - /// class RSAKeyImpl -{ -public: - typedef Poco::AutoPtr Ptr; - typedef std::vector ByteVec; - - explicit RSAKeyImpl(const X509Certificate& cert); - /// Extracts the RSA public key from the given certificate. - - RSAKeyImpl(int keyLength, unsigned long exponent); - /// Creates the RSAKey. Creates a new public/private keypair using the given parameters. - /// Can be used to sign data and verify signatures. - - RSAKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase); - /// Creates the RSAKey, by reading public and private key from the given files and - /// using the given passphrase for the private key. Can only by used for signing if - /// a private key is available. - - RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase); - /// Creates the RSAKey. Can only by used for signing if pPrivKey - /// is not null. If a private key file is specified, you don't need to - /// specify a public key file. OpenSSL will auto-create it from the private key. - - ~RSAKeyImpl(); - /// Destroys the RSAKeyImpl. - - RSA* getRSA(); - /// Returns the OpenSSL RSA object. - - const RSA* getRSA() const; - /// Returns the OpenSSL RSA object. - - int size() const; - /// Returns the RSA modulus size. - - ByteVec modulus() const; - /// Returns the RSA modulus. - - ByteVec encryptionExponent() const; - /// Returns the RSA encryption exponent. - - ByteVec decryptionExponent() const; - /// Returns the RSA decryption exponent. - - void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = ""); - /// Exports the public and private keys to the given files. - /// - /// If an empty filename is specified, the corresponding key - /// is not exported. - - void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = ""); - /// Exports the public and private key to the given streams. - /// - /// If a null pointer is passed for a stream, the corresponding - /// key is not exported. - -private: - void freeRSA(); - - static ByteVec convertToByteVec(const BIGNUM* bn); - -private: - RSA* _pRSA; - OpenSSLInitializer _openSSLInitializer; -}; - - -// -// inlines -// -inline RSA* RSAKeyImpl::getRSA() -{ - return _pRSA; -} - - -inline const RSA* RSAKeyImpl::getRSA() const -{ - return _pRSA; -} - - -} } // namespace Poco::Crypto - - -#endif // Crypto_RSAKeyImplImpl_INCLUDED diff --git a/contrib/libpoco/Crypto/include/Poco/Crypto/X509Certificate.h b/contrib/libpoco/Crypto/include/Poco/Crypto/X509Certificate.h deleted file mode 100644 index a6d86901248..00000000000 --- a/contrib/libpoco/Crypto/include/Poco/Crypto/X509Certificate.h +++ /dev/null @@ -1,193 +0,0 @@ -// -// X509Certificate.h -// -// $Id: //poco/1.4/Crypto/include/Poco/Crypto/X509Certificate.h#2 $ -// -// Library: Crypto -// Package: Certificate -// Module: X509Certificate -// -// Definition of the X509Certificate class. -// -// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Crypto_X509Certificate_INCLUDED -#define Crypto_X509Certificate_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "Poco/Crypto/OpenSSLInitializer.h" -#include "Poco/DateTime.h" -#include "Poco/SharedPtr.h" -#include -#include -#include - - -namespace Poco { -namespace Crypto { - - -class Crypto_API X509Certificate - /// This class represents a X509 Certificate. -{ -public: - enum NID - /// Name identifier for extracting information from - /// a certificate subject's or issuer's distinguished name. - { - NID_COMMON_NAME = 13, - NID_COUNTRY = 14, - NID_LOCALITY_NAME = 15, - NID_STATE_OR_PROVINCE = 16, - NID_ORGANIZATION_NAME = 17, - NID_ORGANIZATION_UNIT_NAME = 18 - }; - - explicit X509Certificate(std::istream& istr); - /// Creates the X509Certificate object by reading - /// a certificate in PEM format from a stream. - - explicit X509Certificate(const std::string& path); - /// Creates the X509Certificate object by reading - /// a certificate in PEM format from a file. - - explicit X509Certificate(X509* pCert); - /// Creates the X509Certificate from an existing - /// OpenSSL certificate. Ownership is taken of - /// the certificate. - - X509Certificate(X509* pCert, bool shared); - /// Creates the X509Certificate from an existing - /// OpenSSL certificate. Ownership is taken of - /// the certificate. If shared is true, the - /// certificate's reference count is incremented. - - X509Certificate(const X509Certificate& cert); - /// Creates the certificate by copying another one. - - X509Certificate& operator = (const X509Certificate& cert); - /// Assigns a certificate. - - void swap(X509Certificate& cert); - /// Exchanges the certificate with another one. - - ~X509Certificate(); - /// Destroys the X509Certificate. - - const std::string& issuerName() const; - /// Returns the certificate issuer's distinguished name. - - std::string issuerName(NID nid) const; - /// Extracts the information specified by the given - /// NID (name identifier) from the certificate issuer's - /// distinguished name. - - const std::string& subjectName() const; - /// Returns the certificate subject's distinguished name. - - std::string subjectName(NID nid) const; - /// Extracts the information specified by the given - /// NID (name identifier) from the certificate subject's - /// distinguished name. - - std::string commonName() const; - /// Returns the common name stored in the certificate - /// subject's distinguished name. - - void extractNames(std::string& commonName, std::set& domainNames) const; - /// Extracts the common name and the alias domain names from the - /// certificate. - - Poco::DateTime validFrom() const; - /// Returns the date and time the certificate is valid from. - - Poco::DateTime expiresOn() const; - /// Returns the date and time the certificate expires. - - void save(std::ostream& stream) const; - /// Writes the certificate to the given stream. - /// The certificate is written in PEM format. - - void save(const std::string& path) const; - /// Writes the certificate to the file given by path. - /// The certificate is written in PEM format. - - bool issuedBy(const X509Certificate& issuerCertificate) const; - /// Checks whether the certificate has been issued by - /// the issuer given by issuerCertificate. This can be - /// used to validate a certificate chain. - /// - /// Verifies if the certificate has been signed with the - /// issuer's private key, using the public key from the issuer - /// certificate. - /// - /// Returns true if verification against the issuer certificate - /// was successfull, false otherwise. - - bool equals(const X509Certificate& otherCertificate) const; - /// Checks whether the certificate is equal to - /// the other certificate, by comparing the hashes - /// of both certificates. - /// - /// Returns true if both certificates are identical, - /// otherwise false. - - const X509* certificate() const; - /// Returns the underlying OpenSSL certificate. - -protected: - void load(std::istream& stream); - /// Loads the certificate from the given stream. The - /// certificate must be in PEM format. - - void load(const std::string& path); - /// Loads the certificate from the given file. The - /// certificate must be in PEM format. - - void init(); - /// Extracts issuer and subject name from the certificate. - -private: - enum - { - NAME_BUFFER_SIZE = 256 - }; - - std::string _issuerName; - std::string _subjectName; - X509* _pCert; - OpenSSLInitializer _openSSLInitializer; -}; - - -// -// inlines -// -inline const std::string& X509Certificate::issuerName() const -{ - return _issuerName; -} - - -inline const std::string& X509Certificate::subjectName() const -{ - return _subjectName; -} - - -inline const X509* X509Certificate::certificate() const -{ - return _pCert; -} - - -} } // namespace Poco::Crypto - - -#endif // Crypto_X509Certificate_INCLUDED diff --git a/contrib/libpoco/Crypto/samples/CMakeLists.txt b/contrib/libpoco/Crypto/samples/CMakeLists.txt deleted file mode 100644 index 2dbff2363ef..00000000000 --- a/contrib/libpoco/Crypto/samples/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory( genrsakey ) diff --git a/contrib/libpoco/Crypto/samples/genrsakey/CMakeLists.txt b/contrib/libpoco/Crypto/samples/genrsakey/CMakeLists.txt deleted file mode 100644 index 2feabdc9415..00000000000 --- a/contrib/libpoco/Crypto/samples/genrsakey/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -set(SAMPLE_NAME "genrsakey") - -set(LOCAL_SRCS "") -aux_source_directory(src LOCAL_SRCS) - -add_executable( ${SAMPLE_NAME} ${LOCAL_SRCS} ) -target_link_libraries( ${SAMPLE_NAME} PocoCrypto PocoUtil PocoXML PocoFoundation ) diff --git a/contrib/libpoco/Crypto/samples/genrsakey/src/genrsakey.cpp b/contrib/libpoco/Crypto/samples/genrsakey/src/genrsakey.cpp deleted file mode 100644 index 40ffc0a163f..00000000000 --- a/contrib/libpoco/Crypto/samples/genrsakey/src/genrsakey.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// -// genrsakey.cpp -// -// $Id: //poco/1.4/Crypto/samples/genrsakey/src/genrsakey.cpp#1 $ -// -// This sample demonstrates the XYZ class. -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Util/Application.h" -#include "Poco/Util/Option.h" -#include "Poco/Util/OptionException.h" -#include "Poco/Util/OptionSet.h" -#include "Poco/Util/HelpFormatter.h" -#include "Poco/Util/AbstractConfiguration.h" -#include "Poco/AutoPtr.h" -#include "Poco/NumberFormatter.h" -#include "Poco/NumberParser.h" -#include "Poco/String.h" -#include "Poco/Crypto/RSAKey.h" -#include - - -using Poco::Util::Application; -using Poco::Util::Option; -using Poco::Util::OptionSet; -using Poco::Util::HelpFormatter; -using Poco::Util::AbstractConfiguration; -using Poco::Util::OptionCallback; -using Poco::AutoPtr; -using Poco::NumberParser; -using Poco::Crypto::RSAKey; - - -class RSAApp: public Application - /// This sample demonstrates some of the features of the Util::Application class, - /// such as configuration file handling and command line arguments processing. - /// - /// Try genrsakey --help (on Unix platforms) or genrsakey /help (elsewhere) for - /// more information. -{ -public: - RSAApp(): - _helpRequested(false), - _length(RSAKey::KL_1024), - _exp(RSAKey::EXP_LARGE), - _name(), - _pwd() - { - Poco::Crypto::initializeCrypto(); - } - - ~RSAApp() - { - Poco::Crypto::uninitializeCrypto(); - } - -protected: - void initialize(Application& self) - { - loadConfiguration(); // load default configuration files, if present - Application::initialize(self); - } - - void uninitialize() - { - Application::uninitialize(); - } - - void reinitialize(Application& self) - { - Application::reinitialize(self); - } - - void defineOptions(OptionSet& options) - { - Application::defineOptions(options); - - options.addOption( - Option("help", "h", "display help information on command line arguments") - .required(false) - .repeatable(false) - .callback(OptionCallback(this, &RSAApp::handleHelp))); - - options.addOption( - Option("?", "?", "display help information on command line arguments") - .required(false) - .repeatable(false) - .callback(OptionCallback(this, &RSAApp::handleHelp))); - - options.addOption( - Option("key", "k", "define the key length") - .required(false) - .repeatable(false) - .argument("512|1024|2048|4096") - .callback(OptionCallback(this, &RSAApp::handleKeyLength))); - - options.addOption( - Option("exponent", "e", "defines the exponent of the key") - .required(false) - .repeatable(false) - .argument("small|large") - .callback(OptionCallback(this, &RSAApp::handleExponent))); - - options.addOption( - Option("file", "f", "defines the file base name. creates a file.pub and a file.priv") - .required(true) - .repeatable(false) - .argument("filebasename") - .callback(OptionCallback(this, &RSAApp::handleFilePrefix))); - - options.addOption( - Option("password", "p", "defines the password used to encrypt the private key file. If not defined user will be asked via stdin to provide in") - .required(false) - .repeatable(false) - .argument("pwd") - .callback(OptionCallback(this, &RSAApp::handlePassword))); - } - - void handleHelp(const std::string& name, const std::string& value) - { - _helpRequested = true; - displayHelp(); - stopOptionsProcessing(); - } - - void handleKeyLength(const std::string& name, const std::string& value) - { - int keyLen = Poco::NumberParser::parse(value); - if (keyLen == 512 || keyLen == 1024 || keyLen == 2048 || keyLen == 4096) - _length = (RSAKey::KeyLength)keyLen; - else - throw Poco::Util::IncompatibleOptionsException("Illegal key length value"); - } - - void handleExponent(const std::string& name, const std::string& value) - { - if (Poco::icompare(value, "small") == 0) - _exp = RSAKey::EXP_SMALL; - else - _exp = RSAKey::EXP_LARGE; - } - - void handleFilePrefix(const std::string& name, const std::string& value) - { - if (value.empty()) - throw Poco::Util::IncompatibleOptionsException("Empty file prefix forbidden"); - _name = value; - } - - void handlePassword(const std::string& name, const std::string& value) - { - _pwd = value; - } - - void displayHelp() - { - HelpFormatter helpFormatter(options()); - helpFormatter.setCommand(commandName()); - helpFormatter.setUsage("OPTIONS"); - helpFormatter.setHeader("Application for generating RSA public/private key pairs."); - helpFormatter.format(std::cout); - } - - int main(const std::vector& args) - { - if (!_helpRequested) - { - logger().information("Generating key with length " + Poco::NumberFormatter::format((int)_length)); - logger().information(std::string("Exponent is ") + ((_exp == RSAKey::EXP_SMALL)?"small":"large")); - logger().information("Generating key"); - RSAKey key(_length, _exp); - logger().information("Generating key: DONE"); - std::string pubFile(_name + ".pub"); - std::string privFile(_name + ".priv"); - - logger().information("Saving key to " + pubFile + " and " + privFile); - key.save(pubFile, privFile, _pwd); - logger().information("Key saved"); - } - return Application::EXIT_OK; - } - -private: - bool _helpRequested; - RSAKey::KeyLength _length; - RSAKey::Exponent _exp; - std::string _name; - std::string _pwd; -}; - - -POCO_APP_MAIN(RSAApp) diff --git a/contrib/libpoco/Crypto/src/Cipher.cpp b/contrib/libpoco/Crypto/src/Cipher.cpp deleted file mode 100644 index 55ebff7568e..00000000000 --- a/contrib/libpoco/Crypto/src/Cipher.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// -// Cipher.cpp -// -// $Id: //poco/1.4/Crypto/src/Cipher.cpp#2 $ -// -// Library: Crypto -// Package: Cipher -// Module: Cipher -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/Cipher.h" -#include "Poco/Crypto/CryptoStream.h" -#include "Poco/Crypto/CryptoTransform.h" -#include "Poco/Base64Encoder.h" -#include "Poco/Base64Decoder.h" -#include "Poco/HexBinaryEncoder.h" -#include "Poco/HexBinaryDecoder.h" -#include "Poco/StreamCopier.h" -#include "Poco/Exception.h" -#include -#include - - -namespace Poco { -namespace Crypto { - - -Cipher::Cipher() -{ -} - - -Cipher::~Cipher() -{ -} - - -std::string Cipher::encryptString(const std::string& str, Encoding encoding) -{ - std::istringstream source(str); - std::ostringstream sink; - - encrypt(source, sink, encoding); - - return sink.str(); -} - - -std::string Cipher::decryptString(const std::string& str, Encoding encoding) -{ - std::istringstream source(str); - std::ostringstream sink; - - decrypt(source, sink, encoding); - return sink.str(); -} - - -void Cipher::encrypt(std::istream& source, std::ostream& sink, Encoding encoding) -{ - CryptoInputStream encryptor(source, createEncryptor()); - - switch (encoding) - { - case ENC_NONE: - StreamCopier::copyStream(encryptor, sink); - break; - - case ENC_BASE64: - case ENC_BASE64_NO_LF: - { - Poco::Base64Encoder encoder(sink); - if (encoding == ENC_BASE64_NO_LF) - { - encoder.rdbuf()->setLineLength(0); - } - StreamCopier::copyStream(encryptor, encoder); - encoder.close(); - } - break; - - case ENC_BINHEX: - case ENC_BINHEX_NO_LF: - { - Poco::HexBinaryEncoder encoder(sink); - if (encoding == ENC_BINHEX_NO_LF) - { - encoder.rdbuf()->setLineLength(0); - } - StreamCopier::copyStream(encryptor, encoder); - encoder.close(); - } - break; - - default: - throw Poco::InvalidArgumentException("Invalid argument", "encoding"); - } -} - - -void Cipher::decrypt(std::istream& source, std::ostream& sink, Encoding encoding) -{ - CryptoOutputStream decryptor(sink, createDecryptor()); - - switch (encoding) - { - case ENC_NONE: - StreamCopier::copyStream(source, decryptor); - decryptor.close(); - break; - - case ENC_BASE64: - case ENC_BASE64_NO_LF: - { - Poco::Base64Decoder decoder(source); - StreamCopier::copyStream(decoder, decryptor); - decryptor.close(); - } - break; - - case ENC_BINHEX: - case ENC_BINHEX_NO_LF: - { - Poco::HexBinaryDecoder decoder(source); - StreamCopier::copyStream(decoder, decryptor); - decryptor.close(); - } - break; - - default: - throw Poco::InvalidArgumentException("Invalid argument", "encoding"); - } -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/CipherFactory.cpp b/contrib/libpoco/Crypto/src/CipherFactory.cpp deleted file mode 100644 index e8f5f6fb0cc..00000000000 --- a/contrib/libpoco/Crypto/src/CipherFactory.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -// CipherFactory.cpp -// -// $Id: //poco/1.4/Crypto/src/CipherFactory.cpp#2 $ -// -// Library: Crypto -// Package: Cipher -// Module: CipherFactory -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/CipherFactory.h" -#include "Poco/Crypto/Cipher.h" -#include "Poco/Crypto/CipherKey.h" -#include "Poco/Crypto/RSAKey.h" -#include "Poco/Crypto/CipherImpl.h" -#include "Poco/Crypto/RSACipherImpl.h" -#include "Poco/Exception.h" -#include "Poco/SingletonHolder.h" -#include -#include - - -namespace Poco { -namespace Crypto { - - -CipherFactory::CipherFactory() -{ -} - - -CipherFactory::~CipherFactory() -{ -} - - -namespace -{ - static Poco::SingletonHolder holder; -} - - -CipherFactory& CipherFactory::defaultFactory() -{ - return *holder.get(); -} - - -Cipher* CipherFactory::createCipher(const CipherKey& key) -{ - return new CipherImpl(key); -} - - -Cipher* CipherFactory::createCipher(const RSAKey& key, RSAPaddingMode paddingMode) -{ - return new RSACipherImpl(key, paddingMode); -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/CipherImpl.cpp b/contrib/libpoco/Crypto/src/CipherImpl.cpp deleted file mode 100644 index b8708a78c81..00000000000 --- a/contrib/libpoco/Crypto/src/CipherImpl.cpp +++ /dev/null @@ -1,229 +0,0 @@ -// -// CipherImpl.cpp -// -// $Id: //poco/1.4/Crypto/src/CipherImpl.cpp#3 $ -// -// Library: Crypto -// Package: Cipher -// Module: CipherImpl -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/CipherImpl.h" -#include "Poco/Crypto/CryptoTransform.h" -#include "Poco/Exception.h" -#include - - -namespace Poco { -namespace Crypto { - - -namespace -{ - void throwError() - { - unsigned long err; - std::string msg; - - while ((err = ERR_get_error())) - { - if (!msg.empty()) - msg.append("; "); - msg.append(ERR_error_string(err, 0)); - } - - throw Poco::IOException(msg); - } - - - class CryptoTransformImpl: public CryptoTransform - { - public: - typedef Cipher::ByteVec ByteVec; - - enum Direction - { - DIR_ENCRYPT, - DIR_DECRYPT - }; - - CryptoTransformImpl( - const EVP_CIPHER* pCipher, - const ByteVec& key, - const ByteVec& iv, - Direction dir); - - ~CryptoTransformImpl(); - - std::size_t blockSize() const; - - int setPadding(int padding); - - std::streamsize transform( - const unsigned char* input, - std::streamsize inputLength, - unsigned char* output, - std::streamsize outputLength); - - std::streamsize finalize( - unsigned char* output, - std::streamsize length); - - private: - const EVP_CIPHER* _pCipher; -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - EVP_CIPHER_CTX* _pContext; -#else - EVP_CIPHER_CTX _context; -#endif - ByteVec _key; - ByteVec _iv; - }; - - - CryptoTransformImpl::CryptoTransformImpl( - const EVP_CIPHER* pCipher, - const ByteVec& key, - const ByteVec& iv, - Direction dir): - _pCipher(pCipher), - _key(key), - _iv(iv) - { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - _pContext = EVP_CIPHER_CTX_new(); - EVP_CipherInit( - _pContext, - _pCipher, - &_key[0], - _iv.empty() ? 0 : &_iv[0], - (dir == DIR_ENCRYPT) ? 1 : 0); -#else - EVP_CipherInit( - &_context, - _pCipher, - &_key[0], - _iv.empty() ? 0 : &_iv[0], - (dir == DIR_ENCRYPT) ? 1 : 0); -#endif - } - - - CryptoTransformImpl::~CryptoTransformImpl() - { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - EVP_CIPHER_CTX_cleanup(_pContext); -#else - EVP_CIPHER_CTX_cleanup(&_context); -#endif - } - - - std::size_t CryptoTransformImpl::blockSize() const - { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - return EVP_CIPHER_CTX_block_size(_pContext); -#else - return EVP_CIPHER_CTX_block_size(&_context); -#endif - } - - - int CryptoTransformImpl::setPadding(int padding) - { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - return EVP_CIPHER_CTX_block_size(_pContext); -#else - return EVP_CIPHER_CTX_set_padding(&_context, padding); -#endif - } - - - std::streamsize CryptoTransformImpl::transform( - const unsigned char* input, - std::streamsize inputLength, - unsigned char* output, - std::streamsize outputLength) - { - poco_assert (outputLength >= (inputLength + blockSize() - 1)); - - int outLen = static_cast(outputLength); -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - int rc = EVP_CipherUpdate( - _pContext, - output, - &outLen, - input, - static_cast(inputLength)); -#else - int rc = EVP_CipherUpdate( - &_context, - output, - &outLen, - input, - static_cast(inputLength)); -#endif - if (rc == 0) - throwError(); - - return static_cast(outLen); - } - - - std::streamsize CryptoTransformImpl::finalize( - unsigned char* output, - std::streamsize length) - { - poco_assert (length >= blockSize()); - - int len = static_cast(length); - - // Use the '_ex' version that does not perform implicit cleanup since we - // will call EVP_CIPHER_CTX_cleanup() from the dtor as there is no - // guarantee that finalize() will be called if an error occurred. -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - int rc = EVP_CipherFinal_ex(_pContext, output, &len); -#else - int rc = EVP_CipherFinal_ex(&_context, output, &len); -#endif - - if (rc == 0) - throwError(); - - return static_cast(len); - } -} - - -CipherImpl::CipherImpl(const CipherKey& key): - _key(key) -{ -} - - -CipherImpl::~CipherImpl() -{ -} - - -CryptoTransform* CipherImpl::createEncryptor() -{ - CipherKeyImpl::Ptr p = _key.impl(); - return new CryptoTransformImpl(p->cipher(), p->getKey(), p->getIV(), CryptoTransformImpl::DIR_ENCRYPT); -} - - -CryptoTransform* CipherImpl::createDecryptor() -{ - CipherKeyImpl::Ptr p = _key.impl(); - return new CryptoTransformImpl(p->cipher(), p->getKey(), p->getIV(), CryptoTransformImpl::DIR_DECRYPT); -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/CipherKey.cpp b/contrib/libpoco/Crypto/src/CipherKey.cpp deleted file mode 100644 index eb535e9d89a..00000000000 --- a/contrib/libpoco/Crypto/src/CipherKey.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -// CipherKey.cpp -// -// $Id: //poco/1.4/Crypto/src/CipherKey.cpp#1 $ -// -// Library: Crypto -// Package: Cipher -// Module: CipherKey -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/CipherKey.h" - - -namespace Poco { -namespace Crypto { - - -CipherKey::CipherKey(const std::string& name, const std::string& passphrase, const std::string& salt, int iterationCount): - _pImpl(new CipherKeyImpl(name, passphrase, salt, iterationCount)) -{ -} - - -CipherKey::CipherKey(const std::string& name, const ByteVec& key, const ByteVec& iv): - _pImpl(new CipherKeyImpl(name, key, iv)) -{ -} - - -CipherKey::CipherKey(const std::string& name): - _pImpl(new CipherKeyImpl(name)) -{ -} - - -CipherKey::~CipherKey() -{ -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/CipherKeyImpl.cpp b/contrib/libpoco/Crypto/src/CipherKeyImpl.cpp deleted file mode 100644 index bcd7452c696..00000000000 --- a/contrib/libpoco/Crypto/src/CipherKeyImpl.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// -// CipherKeyImpl.cpp -// -// $Id: //poco/1.4/Crypto/src/CipherKeyImpl.cpp#1 $ -// -// Library: Crypto -// Package: Cipher -// Module: CipherKeyImpl -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/CipherKeyImpl.h" -#include "Poco/Crypto/CryptoTransform.h" -#include "Poco/Crypto/CipherFactory.h" -#include "Poco/Exception.h" -#include "Poco/RandomStream.h" -#include -#include - - -namespace Poco { -namespace Crypto { - - -CipherKeyImpl::CipherKeyImpl(const std::string& name, - const std::string& passphrase, - const std::string& salt, - int iterationCount): - _pCipher(0), - _name(name), - _key(), - _iv() -{ - // dummy access to Cipherfactory so that the EVP lib is initilaized - CipherFactory::defaultFactory(); - _pCipher = EVP_get_cipherbyname(name.c_str()); - - if (!_pCipher) - throw Poco::NotFoundException("Cipher " + name + " was not found"); - _key = ByteVec(keySize()); - _iv = ByteVec(ivSize()); - generateKey(passphrase, salt, iterationCount); -} - - -CipherKeyImpl::CipherKeyImpl(const std::string& name, - const ByteVec& key, - const ByteVec& iv): - _pCipher(0), - _name(name), - _key(key), - _iv(iv) -{ - // dummy access to Cipherfactory so that the EVP lib is initilaized - CipherFactory::defaultFactory(); - _pCipher = EVP_get_cipherbyname(name.c_str()); - - if (!_pCipher) - throw Poco::NotFoundException("Cipher " + name + " was not found"); -} - - -CipherKeyImpl::CipherKeyImpl(const std::string& name): - _pCipher(0), - _name(name), - _key(), - _iv() -{ - // dummy access to Cipherfactory so that the EVP lib is initilaized - CipherFactory::defaultFactory(); - _pCipher = EVP_get_cipherbyname(name.c_str()); - - if (!_pCipher) - throw Poco::NotFoundException("Cipher " + name + " was not found"); - _key = ByteVec(keySize()); - _iv = ByteVec(ivSize()); - generateKey(); -} - - -CipherKeyImpl::~CipherKeyImpl() -{ -} - - -CipherKeyImpl::Mode CipherKeyImpl::mode() const -{ - switch (EVP_CIPHER_mode(_pCipher)) - { - case EVP_CIPH_STREAM_CIPHER: - return MODE_STREAM_CIPHER; - - case EVP_CIPH_ECB_MODE: - return MODE_ECB; - - case EVP_CIPH_CBC_MODE: - return MODE_CBC; - - case EVP_CIPH_CFB_MODE: - return MODE_CFB; - - case EVP_CIPH_OFB_MODE: - return MODE_OFB; - } - throw Poco::IllegalStateException("Unexpected value of EVP_CIPHER_mode()"); -} - - -void CipherKeyImpl::generateKey() -{ - ByteVec vec; - - getRandomBytes(vec, keySize()); - setKey(vec); - - getRandomBytes(vec, ivSize()); - setIV(vec); -} - - -void CipherKeyImpl::getRandomBytes(ByteVec& vec, std::size_t count) -{ - Poco::RandomInputStream random; - - vec.clear(); - vec.reserve(count); - - for (int i = 0; i < count; ++i) - vec.push_back(static_cast(random.get())); -} - - -void CipherKeyImpl::generateKey( - const std::string& password, - const std::string& salt, - int iterationCount) -{ - unsigned char keyBytes[EVP_MAX_KEY_LENGTH]; - unsigned char ivBytes[EVP_MAX_IV_LENGTH]; - - // OpenSSL documentation specifies that the salt must be an 8-byte array. - unsigned char saltBytes[8]; - - if (!salt.empty()) - { - int len = static_cast(salt.size()); - // Create the salt array from the salt string - for (int i = 0; i < 8; ++i) - saltBytes[i] = salt.at(i % len); - for (int i = 8; i < len; ++i) - saltBytes[i % 8] ^= salt.at(i); - } - - // Now create the key and IV, using the MD5 digest algorithm. - int keySize = EVP_BytesToKey( - _pCipher, - EVP_md5(), - (salt.empty() ? 0 : saltBytes), - reinterpret_cast(password.data()), - static_cast(password.size()), - iterationCount, - keyBytes, - ivBytes); - - // Copy the buffers to our member byte vectors. - _key.assign(keyBytes, keyBytes + keySize); - - if (ivSize() == 0) - _iv.clear(); - else - _iv.assign(ivBytes, ivBytes + ivSize()); -} - - -int CipherKeyImpl::keySize() const -{ - return EVP_CIPHER_key_length(_pCipher); -} - - -int CipherKeyImpl::blockSize() const -{ - return EVP_CIPHER_block_size(_pCipher); -} - - -int CipherKeyImpl::ivSize() const -{ - return EVP_CIPHER_iv_length(_pCipher); -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/CryptoStream.cpp b/contrib/libpoco/Crypto/src/CryptoStream.cpp deleted file mode 100644 index 97e73ce810f..00000000000 --- a/contrib/libpoco/Crypto/src/CryptoStream.cpp +++ /dev/null @@ -1,357 +0,0 @@ -// -// CryptoStream.cpp -// -// $Id: //poco/1.4/Crypto/src/CryptoStream.cpp#2 $ -// -// Library: Crypto -// Package: Cipher -// Module: CryptoStream -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/CryptoStream.h" -#include "Poco/Crypto/CryptoTransform.h" -#include "Poco/Crypto/Cipher.h" -#include "Poco/Exception.h" -#include - - -#undef min -#undef max - - -namespace Poco { -namespace Crypto { - - -// -// CryptoStreamBuf -// - - -CryptoStreamBuf::CryptoStreamBuf(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize): - Poco::BufferedStreamBuf(bufferSize, std::ios::in), - _pTransform(pTransform), - _pIstr(&istr), - _pOstr(0), - _eof(false), - _buffer(static_cast(bufferSize)) -{ - poco_check_ptr (pTransform); - poco_assert (bufferSize > 2 * pTransform->blockSize()); -} - - -CryptoStreamBuf::CryptoStreamBuf(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize): - Poco::BufferedStreamBuf(bufferSize, std::ios::out), - _pTransform(pTransform), - _pIstr(0), - _pOstr(&ostr), - _eof(false), - _buffer(static_cast(bufferSize)) -{ - poco_check_ptr (pTransform); - poco_assert (bufferSize > 2 * pTransform->blockSize()); -} - - -CryptoStreamBuf::~CryptoStreamBuf() -{ - try - { - close(); - } - catch (...) - { - } - delete _pTransform; -} - - -void CryptoStreamBuf::close() -{ - sync(); - - if (_pIstr) - { - _pIstr = 0; - } - else if (_pOstr) - { - // Close can be called multiple times. By zeroing the pointer we make - // sure that we call finalize() only once, even if an exception is - // thrown. - std::ostream* pOstr = _pOstr; - _pOstr = 0; - - // Finalize transformation. - std::streamsize n = _pTransform->finalize(_buffer.begin(), static_cast(_buffer.size())); - - if (n > 0) - { - pOstr->write(reinterpret_cast(_buffer.begin()), n); - if (!pOstr->good()) - throw Poco::IOException("Output stream failure"); - } - } -} - - -int CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length) -{ - if (!_pIstr) - return 0; - - int count = 0; - - while (!_eof) - { - int m = (static_cast(length) - count)/2 - static_cast(_pTransform->blockSize()); - - // Make sure we can read at least one more block. Explicitely check - // for m < 0 since blockSize() returns an unsigned int and the - // comparison might give false results for m < 0. - if (m <= 0) - break; - - int n = 0; - - if (_pIstr->good()) - { - _pIstr->read(reinterpret_cast(_buffer.begin()), m); - n = static_cast(_pIstr->gcount()); - } - - if (n == 0) - { - _eof = true; - - // No more data, finalize transformation - count += static_cast(_pTransform->finalize( - reinterpret_cast(buffer + count), - static_cast(length) - count)); - } - else - { - // Transform next chunk of data - count += static_cast(_pTransform->transform( - _buffer.begin(), - n, - reinterpret_cast(buffer + count), - static_cast(length) - count)); - } - } - - return count; -} - - -int CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length) -{ - if (!_pOstr) - return 0; - - std::size_t maxChunkSize = _buffer.size()/2; - std::size_t count = 0; - - while (count < length) - { - // Truncate chunk size so that the maximum output fits into _buffer. - std::size_t n = static_cast(length) - count; - if (n > maxChunkSize) - n = maxChunkSize; - - // Transform next chunk of data - std::streamsize k = _pTransform->transform( - reinterpret_cast(buffer + count), - static_cast(n), - _buffer.begin(), - static_cast(_buffer.size())); - - // Attention: (n != k) might be true. In count, we have to track how - // many bytes from buffer have been consumed, not how many bytes have - // been written to _pOstr! - count += n; - - if (k > 0) - { - _pOstr->write(reinterpret_cast(_buffer.begin()), k); - if (!_pOstr->good()) - throw Poco::IOException("Output stream failure"); - } - } - - return static_cast(count); -} - - -// -// CryptoIOS -// - - -CryptoIOS::CryptoIOS(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize): - _buf(istr, pTransform, bufferSize) -{ - poco_ios_init(&_buf); -} - - -CryptoIOS::CryptoIOS(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize): - _buf(ostr, pTransform, bufferSize) -{ - poco_ios_init(&_buf); -} - - -CryptoIOS::~CryptoIOS() -{ -} - - -CryptoStreamBuf* CryptoIOS::rdbuf() -{ - return &_buf; -} - - -// -// CryptoInputStream -// - - -CryptoInputStream::CryptoInputStream(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize): - CryptoIOS(istr, pTransform, bufferSize), - std::istream(&_buf) -{ -} - - -CryptoInputStream::CryptoInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize): - CryptoIOS(istr, cipher.createEncryptor(), bufferSize), - std::istream(&_buf) -{ -} - - -CryptoInputStream::~CryptoInputStream() -{ -} - - -// -// CryptoOutputStream -// - - -CryptoOutputStream::CryptoOutputStream(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize): - CryptoIOS(ostr, pTransform, bufferSize), - std::ostream(&_buf) -{ -} - - -CryptoOutputStream::CryptoOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize): - CryptoIOS(ostr, cipher.createDecryptor(), bufferSize), - std::ostream(&_buf) -{ -} - - -CryptoOutputStream::~CryptoOutputStream() -{ -} - - -void CryptoOutputStream::close() -{ - _buf.close(); -} - - -// -// EncryptingInputStream -// - - -EncryptingInputStream::EncryptingInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize): - CryptoIOS(istr, cipher.createEncryptor(), bufferSize), - std::istream(&_buf) -{ -} - - -EncryptingInputStream::~EncryptingInputStream() -{ -} - - -// -// EncryptingOuputStream -// - - -EncryptingOutputStream::EncryptingOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize): - CryptoIOS(ostr, cipher.createEncryptor(), bufferSize), - std::ostream(&_buf) -{ -} - - -EncryptingOutputStream::~EncryptingOutputStream() -{ -} - - -void EncryptingOutputStream::close() -{ - _buf.close(); -} - - -// -// DecryptingInputStream -// - - -DecryptingInputStream::DecryptingInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize): - CryptoIOS(istr, cipher.createDecryptor(), bufferSize), - std::istream(&_buf) -{ -} - - -DecryptingInputStream::~DecryptingInputStream() -{ -} - - -// -// DecryptingOuputStream -// - - -DecryptingOutputStream::DecryptingOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize): - CryptoIOS(ostr, cipher.createDecryptor(), bufferSize), - std::ostream(&_buf) -{ -} - - -DecryptingOutputStream::~DecryptingOutputStream() -{ -} - - -void DecryptingOutputStream::close() -{ - _buf.close(); -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/CryptoTransform.cpp b/contrib/libpoco/Crypto/src/CryptoTransform.cpp deleted file mode 100644 index 20157ab7d0c..00000000000 --- a/contrib/libpoco/Crypto/src/CryptoTransform.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// -// CryptoTransform.cpp -// -// $Id: //poco/1.4/Crypto/src/CryptoTransform.cpp#2 $ -// -// Library: Crypto -// Package: Cipher -// Module: CryptoTransform -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/CryptoTransform.h" - - -namespace Poco { -namespace Crypto { - - -CryptoTransform::CryptoTransform() -{ -} - - -CryptoTransform::~CryptoTransform() -{ -} - - -int CryptoTransform::setPadding(int padding) -{ - return 1; -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/DigestEngine.cpp b/contrib/libpoco/Crypto/src/DigestEngine.cpp deleted file mode 100644 index 64042589f17..00000000000 --- a/contrib/libpoco/Crypto/src/DigestEngine.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -// DigestEngine.cpp -// -// $Id: //poco/1.4/Crypto/src/DigestEngine.cpp#1 $ -// -// Library: Crypto -// Package: Digest -// Module: DigestEngine -// -// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/DigestEngine.h" -#include "Poco/Exception.h" - - -namespace Poco { -namespace Crypto { - - -DigestEngine::DigestEngine(const std::string& name): - _name(name), - _pContext(EVP_MD_CTX_create()) -{ - const EVP_MD* md = EVP_get_digestbyname(_name.c_str()); - if (!md) throw Poco::NotFoundException(_name); - EVP_DigestInit_ex(_pContext, md, NULL); -} - - -DigestEngine::~DigestEngine() -{ - EVP_MD_CTX_destroy(_pContext); -} - -int DigestEngine::nid() const -{ - return EVP_MD_nid(EVP_MD_CTX_md(_pContext)); -} - -std::size_t DigestEngine::digestLength() const -{ - return EVP_MD_CTX_size(_pContext); -} - - -void DigestEngine::reset() -{ -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - EVP_MD_CTX_free(_pContext); - _pContext = EVP_MD_CTX_create(); -#else - EVP_MD_CTX_cleanup(_pContext); -#endif - const EVP_MD* md = EVP_get_digestbyname(_name.c_str()); - if (!md) throw Poco::NotFoundException(_name); - EVP_DigestInit_ex(_pContext, md, NULL); -} - - -const Poco::DigestEngine::Digest& DigestEngine::digest() -{ - _digest.clear(); - unsigned len = EVP_MD_CTX_size(_pContext); - _digest.resize(len); - EVP_DigestFinal_ex(_pContext, &_digest[0], &len); - reset(); - return _digest; -} - - -void DigestEngine::updateImpl(const void* data, std::size_t length) -{ - EVP_DigestUpdate(_pContext, data, length); -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/OpenSSLInitializer.cpp b/contrib/libpoco/Crypto/src/OpenSSLInitializer.cpp deleted file mode 100644 index 28ecd115de0..00000000000 --- a/contrib/libpoco/Crypto/src/OpenSSLInitializer.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// -// OpenSSLInitializer.cpp -// -// $Id: //poco/1.4/Crypto/src/OpenSSLInitializer.cpp#3 $ -// -// Library: Crypto -// Package: CryptoCore -// Module: OpenSSLInitializer -// -// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/OpenSSLInitializer.h" -#include "Poco/RandomStream.h" -#include "Poco/Thread.h" -#include -#include -#include -#include -#if OPENSSL_VERSION_NUMBER >= 0x0907000L -#include -#endif - - -using Poco::RandomInputStream; -using Poco::Thread; - - -namespace Poco { -namespace Crypto { - - -Poco::FastMutex* OpenSSLInitializer::_mutexes(0); -Poco::AtomicCounter OpenSSLInitializer::_rc; - - -OpenSSLInitializer::OpenSSLInitializer() -{ - initialize(); -} - - -OpenSSLInitializer::~OpenSSLInitializer() -{ - try - { - uninitialize(); - } - catch (...) - { - poco_unexpected(); - } -} - - -void OpenSSLInitializer::initialize() -{ - if (++_rc == 1) - { -#if OPENSSL_VERSION_NUMBER >= 0x0907000L - OPENSSL_config(NULL); -#endif - SSL_library_init(); - SSL_load_error_strings(); - OpenSSL_add_all_algorithms(); - - char seed[SEEDSIZE]; - RandomInputStream rnd; - rnd.read(seed, sizeof(seed)); - RAND_seed(seed, SEEDSIZE); - - int nMutexes = CRYPTO_num_locks(); - _mutexes = new Poco::FastMutex[nMutexes]; - CRYPTO_set_locking_callback(&OpenSSLInitializer::lock); -#ifndef POCO_OS_FAMILY_WINDOWS -// Not needed on Windows (see SF #110: random unhandled exceptions when linking with ssl). -// https://sourceforge.net/p/poco/bugs/110/ -// -// From http://www.openssl.org/docs/crypto/threads.html : -// "If the application does not register such a callback using CRYPTO_THREADID_set_callback(), -// then a default implementation is used - on Windows and BeOS this uses the system's -// default thread identifying APIs" - CRYPTO_set_id_callback(&OpenSSLInitializer::id); -#endif - CRYPTO_set_dynlock_create_callback(&OpenSSLInitializer::dynlockCreate); - CRYPTO_set_dynlock_lock_callback(&OpenSSLInitializer::dynlock); - CRYPTO_set_dynlock_destroy_callback(&OpenSSLInitializer::dynlockDestroy); - } -} - - -void OpenSSLInitializer::uninitialize() -{ - if (--_rc == 0) - { - EVP_cleanup(); - ERR_free_strings(); - CRYPTO_set_locking_callback(0); -#ifndef POCO_OS_FAMILY_WINDOWS - CRYPTO_set_id_callback(0); -#endif - delete [] _mutexes; - - CONF_modules_free(); - } -} - - -void OpenSSLInitializer::lock(int mode, int n, const char* file, int line) -{ - if (mode & CRYPTO_LOCK) - _mutexes[n].lock(); - else - _mutexes[n].unlock(); -} - - -unsigned long OpenSSLInitializer::id() -{ - // Note: we use an old-style C cast here because - // neither static_cast<> nor reinterpret_cast<> - // work uniformly across all platforms. - return (unsigned long) Poco::Thread::currentTid(); -} - - -struct CRYPTO_dynlock_value* OpenSSLInitializer::dynlockCreate(const char* file, int line) -{ - return new CRYPTO_dynlock_value; -} - - -void OpenSSLInitializer::dynlock(int mode, struct CRYPTO_dynlock_value* lock, const char* file, int line) -{ - poco_check_ptr (lock); - - if (mode & CRYPTO_LOCK) - lock->_mutex.lock(); - else - lock->_mutex.unlock(); -} - - -void OpenSSLInitializer::dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line) -{ - delete lock; -} - - -void initializeCrypto() -{ - OpenSSLInitializer::initialize(); -} - - -void uninitializeCrypto() -{ - OpenSSLInitializer::uninitialize(); -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/RSACipherImpl.cpp b/contrib/libpoco/Crypto/src/RSACipherImpl.cpp deleted file mode 100644 index 91c5b815d61..00000000000 --- a/contrib/libpoco/Crypto/src/RSACipherImpl.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// -// RSACipherImpl.cpp -// -// $Id: //poco/1.4/Crypto/src/RSACipherImpl.cpp#3 $ -// -// Library: Crypto -// Package: RSA -// Module: RSACipherImpl -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/RSACipherImpl.h" -#include "Poco/Crypto/CryptoTransform.h" -#include "Poco/Exception.h" -#include -#include -#include - - -namespace Poco { -namespace Crypto { - - -namespace -{ - void throwError() - { - unsigned long err; - std::string msg; - - while ((err = ERR_get_error())) - { - if (!msg.empty()) - msg.append("; "); - msg.append(ERR_error_string(err, 0)); - } - - throw Poco::IOException(msg); - } - - - int mapPaddingMode(RSAPaddingMode paddingMode) - { - switch (paddingMode) - { - case RSA_PADDING_PKCS1: - return RSA_PKCS1_PADDING; - case RSA_PADDING_PKCS1_OAEP: - return RSA_PKCS1_OAEP_PADDING; - case RSA_PADDING_SSLV23: - return RSA_SSLV23_PADDING; - case RSA_PADDING_NONE: - return RSA_NO_PADDING; - default: - poco_bugcheck(); - return RSA_NO_PADDING; - } - } - - - class RSAEncryptImpl: public CryptoTransform - { - public: - RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode); - ~RSAEncryptImpl(); - - std::size_t blockSize() const; - std::size_t maxDataSize() const; - - std::streamsize transform( - const unsigned char* input, - std::streamsize inputLength, - unsigned char* output, - std::streamsize outputLength); - - std::streamsize finalize(unsigned char* output, std::streamsize length); - - private: - const RSA* _pRSA; - RSAPaddingMode _paddingMode; - std::streamsize _pos; - unsigned char* _pBuf; - }; - - - RSAEncryptImpl::RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode): - _pRSA(pRSA), - _paddingMode(paddingMode), - _pos(0), - _pBuf(0) - { - _pBuf = new unsigned char[blockSize()]; - } - - - RSAEncryptImpl::~RSAEncryptImpl() - { - delete [] _pBuf; - } - - - std::size_t RSAEncryptImpl::blockSize() const - { - return RSA_size(_pRSA); - } - - - std::size_t RSAEncryptImpl::maxDataSize() const - { - std::size_t size = blockSize(); - switch (_paddingMode) - { - case RSA_PADDING_PKCS1: - case RSA_PADDING_SSLV23: - size -= 11; - break; - case RSA_PADDING_PKCS1_OAEP: - size -= 41; - break; - default: - break; - } - return size; - } - - - std::streamsize RSAEncryptImpl::transform( - const unsigned char* input, - std::streamsize inputLength, - unsigned char* output, - std::streamsize outputLength) - { - // always fill up the buffer before writing! - std::streamsize maxSize = static_cast(maxDataSize()); - std::streamsize rsaSize = static_cast(blockSize()); - poco_assert_dbg(_pos <= maxSize); - poco_assert (outputLength >= rsaSize); - int rc = 0; - while (inputLength > 0) - { - // check how many data bytes we are missing to get the buffer full - poco_assert_dbg (maxSize >= _pos); - std::streamsize missing = maxSize - _pos; - if (missing == 0) - { - poco_assert (outputLength >= rsaSize); - int n = RSA_public_encrypt(static_cast(maxSize), _pBuf, output, const_cast(_pRSA), mapPaddingMode(_paddingMode)); - if (n == -1) - throwError(); - rc += n; - output += n; - outputLength -= n; - _pos = 0; - - } - else - { - if (missing > inputLength) - missing = inputLength; - - std::memcpy(_pBuf + _pos, input, static_cast(missing)); - input += missing; - _pos += missing; - inputLength -= missing; - } - } - return rc; - } - - - std::streamsize RSAEncryptImpl::finalize(unsigned char* output, std::streamsize length) - { - poco_assert (length >= blockSize()); - poco_assert (_pos <= maxDataSize()); - int rc = 0; - if (_pos > 0) - { - rc = RSA_public_encrypt(static_cast(_pos), _pBuf, output, const_cast(_pRSA), mapPaddingMode(_paddingMode)); - if (rc == -1) throwError(); - } - return rc; - } - - - class RSADecryptImpl: public CryptoTransform - { - public: - RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode); - ~RSADecryptImpl(); - - std::size_t blockSize() const; - - std::streamsize transform( - const unsigned char* input, - std::streamsize inputLength, - unsigned char* output, - std::streamsize outputLength); - - std::streamsize finalize( - unsigned char* output, - std::streamsize length); - - private: - const RSA* _pRSA; - RSAPaddingMode _paddingMode; - std::streamsize _pos; - unsigned char* _pBuf; - }; - - - RSADecryptImpl::RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode): - _pRSA(pRSA), - _paddingMode(paddingMode), - _pos(0), - _pBuf(0) - { - _pBuf = new unsigned char[blockSize()]; - } - - - RSADecryptImpl::~RSADecryptImpl() - { - delete [] _pBuf; - } - - - std::size_t RSADecryptImpl::blockSize() const - { - return RSA_size(_pRSA); - } - - - std::streamsize RSADecryptImpl::transform( - const unsigned char* input, - std::streamsize inputLength, - unsigned char* output, - std::streamsize outputLength) - { - - // always fill up the buffer before decrypting! - std::streamsize rsaSize = static_cast(blockSize()); - poco_assert_dbg(_pos <= rsaSize); - poco_assert (outputLength >= rsaSize); - int rc = 0; - while (inputLength > 0) - { - // check how many data bytes we are missing to get the buffer full - poco_assert_dbg (rsaSize >= _pos); - std::streamsize missing = rsaSize - _pos; - if (missing == 0) - { - int tmp = RSA_private_decrypt(static_cast(rsaSize), _pBuf, output, const_cast(_pRSA), mapPaddingMode(_paddingMode)); - if (tmp == -1) - throwError(); - rc += tmp; - output += tmp; - outputLength -= tmp; - _pos = 0; - - } - else - { - if (missing > inputLength) - missing = inputLength; - - std::memcpy(_pBuf + _pos, input, static_cast(missing)); - input += missing; - _pos += missing; - inputLength -= missing; - } - } - return rc; - } - - - std::streamsize RSADecryptImpl::finalize(unsigned char* output, std::streamsize length) - { - poco_assert (length >= blockSize()); - int rc = 0; - if (_pos > 0) - { - rc = RSA_private_decrypt(static_cast(_pos), _pBuf, output, const_cast(_pRSA), mapPaddingMode(_paddingMode)); - if (rc == -1) - throwError(); - } - return rc; - } -} - - -RSACipherImpl::RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode): - _key(key), - _paddingMode(paddingMode) -{ -} - - -RSACipherImpl::~RSACipherImpl() -{ -} - - -CryptoTransform* RSACipherImpl::createEncryptor() -{ - return new RSAEncryptImpl(_key.impl()->getRSA(), _paddingMode); -} - - -CryptoTransform* RSACipherImpl::createDecryptor() -{ - return new RSADecryptImpl(_key.impl()->getRSA(), _paddingMode); -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/RSADigestEngine.cpp b/contrib/libpoco/Crypto/src/RSADigestEngine.cpp deleted file mode 100644 index f0ae5c98067..00000000000 --- a/contrib/libpoco/Crypto/src/RSADigestEngine.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// -// RSADigestEngine.cpp -// -// $Id: //poco/1.4/Crypto/src/RSADigestEngine.cpp#1 $ -// -// Library: Crypto -// Package: RSA -// Module: RSADigestEngine -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/RSADigestEngine.h" -#include - - -namespace Poco { -namespace Crypto { - - -RSADigestEngine::RSADigestEngine(const RSAKey& key, DigestType digestType): - _key(key), - _engine(digestType == DIGEST_MD5 ? "MD5" : "SHA1") -{ -} - -RSADigestEngine::RSADigestEngine(const RSAKey& key, const std::string &name): - _key(key), - _engine(name) -{ -} - - -RSADigestEngine::~RSADigestEngine() -{ -} - - -std::size_t RSADigestEngine::digestLength() const -{ - return _engine.digestLength(); -} - - -void RSADigestEngine::reset() -{ - _engine.reset(); - _digest.clear(); - _signature.clear(); -} - - -const DigestEngine::Digest& RSADigestEngine::digest() -{ - if (_digest.empty()) - { - _digest = _engine.digest(); - } - return _digest; -} - - -const DigestEngine::Digest& RSADigestEngine::signature() -{ - if (_signature.empty()) - { - digest(); - _signature.resize(_key.size()); - unsigned sigLen = static_cast(_signature.size()); - RSA_sign(_engine.nid(), &_digest[0], static_cast(_digest.size()), &_signature[0], &sigLen, _key.impl()->getRSA()); - // truncate _sig to sigLen - if (sigLen < _signature.size()) - _signature.resize(sigLen); - } - return _signature; -} - - -bool RSADigestEngine::verify(const DigestEngine::Digest& sig) -{ - digest(); - DigestEngine::Digest sigCpy = sig; // copy becausse RSA_verify can modify sigCpy - int ret = RSA_verify(_engine.nid(), &_digest[0], static_cast(_digest.size()), &sigCpy[0], static_cast(sigCpy.size()), _key.impl()->getRSA()); - return ret != 0; -} - - -void RSADigestEngine::updateImpl(const void* data, std::size_t length) -{ - _engine.update(data, length); -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/RSAKey.cpp b/contrib/libpoco/Crypto/src/RSAKey.cpp deleted file mode 100644 index 3dfcd138e9c..00000000000 --- a/contrib/libpoco/Crypto/src/RSAKey.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// -// RSAKey.cpp -// -// $Id: //poco/1.4/Crypto/src/RSAKey.cpp#2 $ -// -// Library: Crypto -// Package: RSA -// Module: RSAKey -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/RSAKey.h" -#include - - -namespace Poco { -namespace Crypto { - - -RSAKey::RSAKey(const X509Certificate& cert): - _pImpl(new RSAKeyImpl(cert)) -{ -} - - -RSAKey::RSAKey(KeyLength keyLength, Exponent exp): - _pImpl(0) -{ - int keyLen = keyLength; - unsigned long expVal = RSA_3; - if (exp == EXP_LARGE) - expVal = RSA_F4; - _pImpl = new RSAKeyImpl(keyLen, expVal); -} - - -RSAKey::RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase): - _pImpl(new RSAKeyImpl(publicKeyFile, privateKeyFile, privateKeyPassphrase)) -{ -} - - -RSAKey::RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase): - _pImpl(new RSAKeyImpl(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase)) -{ -} - - -RSAKey::~RSAKey() -{ -} - - -int RSAKey::size() const -{ - return _pImpl->size(); -} - - -RSAKeyImpl::ByteVec RSAKey::modulus() const -{ - return _pImpl->modulus(); -} - - -RSAKeyImpl::ByteVec RSAKey::encryptionExponent() const -{ - return _pImpl->encryptionExponent(); -} - - -RSAKeyImpl::ByteVec RSAKey::decryptionExponent() const -{ - return _pImpl->decryptionExponent(); -} - - -void RSAKey::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase) -{ - _pImpl->save(publicKeyFile, privateKeyFile, privateKeyPassphrase); -} - - -void RSAKey::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase) -{ - _pImpl->save(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase); -} - - -namespace -{ - static const std::string RSA("rsa"); -} - - -const std::string& RSAKey::name() const -{ - return RSA; -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/RSAKeyImpl.cpp b/contrib/libpoco/Crypto/src/RSAKeyImpl.cpp deleted file mode 100644 index 3a1580f6912..00000000000 --- a/contrib/libpoco/Crypto/src/RSAKeyImpl.cpp +++ /dev/null @@ -1,360 +0,0 @@ -// -// RSAKeyImpl.cpp -// -// $Id: //poco/1.4/Crypto/src/RSAKeyImpl.cpp#3 $ -// -// Library: Crypto -// Package: RSA -// Module: RSAKeyImpl -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/RSAKeyImpl.h" -#include "Poco/Crypto/X509Certificate.h" -#include "Poco/FileStream.h" -#include "Poco/StreamCopier.h" -#include -#include -#include -#include -#if OPENSSL_VERSION_NUMBER >= 0x00908000L -#include -#endif - - -namespace Poco { -namespace Crypto { - - -RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert): - _pRSA(0) -{ - const X509* pCert = cert.certificate(); - EVP_PKEY* pKey = X509_get_pubkey(const_cast(pCert)); - _pRSA = EVP_PKEY_get1_RSA(pKey); - EVP_PKEY_free(pKey); -} - - -RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent): - _pRSA(0) -{ -#if OPENSSL_VERSION_NUMBER >= 0x00908000L - _pRSA = RSA_new(); - int ret = 0; - BIGNUM* bn = 0; - try - { - bn = BN_new(); - BN_set_word(bn, exponent); - ret = RSA_generate_key_ex(_pRSA, keyLength, bn, 0); - BN_free(bn); - } - catch (...) - { - BN_free(bn); - throw; - } - if (!ret) throw Poco::InvalidArgumentException("Failed to create RSA context"); -#else - _pRSA = RSA_generate_key(keyLength, exponent, 0, 0); - if (!_pRSA) throw Poco::InvalidArgumentException("Failed to create RSA context"); -#endif -} - - -RSAKeyImpl::RSAKeyImpl( - const std::string& publicKeyFile, - const std::string& privateKeyFile, - const std::string& privateKeyPassphrase): - _pRSA(0) -{ - poco_assert_dbg(_pRSA == 0); - - _pRSA = RSA_new(); - if (!publicKeyFile.empty()) - { - BIO* bio = BIO_new(BIO_s_file()); - if (!bio) throw Poco::IOException("Cannot create BIO for reading public key", publicKeyFile); - int rc = BIO_read_filename(bio, publicKeyFile.c_str()); - if (rc) - { - RSA* pubKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0); - if (!pubKey) - { - int rc = BIO_reset(bio); - // BIO_reset() normally returns 1 for success and 0 or -1 for failure. - // File BIOs are an exception, they return 0 for success and -1 for failure. - if (rc != 0) throw Poco::FileException("Failed to load public key", publicKeyFile); - pubKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, 0, 0); - } - BIO_free(bio); - if (!pubKey) - { - freeRSA(); - throw Poco::FileException("Failed to load public key", publicKeyFile); - } - } - else - { - freeRSA(); - throw Poco::FileNotFoundException("Public key file", publicKeyFile); - } - } - - if (!privateKeyFile.empty()) - { - BIO* bio = BIO_new(BIO_s_file()); - if (!bio) throw Poco::IOException("Cannot create BIO for reading private key", privateKeyFile); - int rc = BIO_read_filename(bio, privateKeyFile.c_str()); - if (rc) - { - RSA* privKey = 0; - if (privateKeyPassphrase.empty()) - privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, 0); - else - privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, const_cast(privateKeyPassphrase.c_str())); - BIO_free(bio); - if (!privKey) - { - freeRSA(); - throw Poco::FileException("Failed to load private key", privateKeyFile); - } - } - else - { - freeRSA(); - throw Poco::FileNotFoundException("Private key file", privateKeyFile); - } - } -} - - -RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase): - _pRSA(0) -{ - poco_assert_dbg(_pRSA == 0); - - _pRSA = RSA_new(); - if (pPublicKeyStream) - { - std::string publicKeyData; - Poco::StreamCopier::copyToString(*pPublicKeyStream, publicKeyData); - BIO* bio = BIO_new_mem_buf(const_cast(publicKeyData.data()), static_cast(publicKeyData.size())); - if (!bio) throw Poco::IOException("Cannot create BIO for reading public key"); - RSA* publicKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0); - if (!publicKey) - { - int rc = BIO_reset(bio); - // BIO_reset() normally returns 1 for success and 0 or -1 for failure. - // File BIOs are an exception, they return 0 for success and -1 for failure. - if (rc != 1) throw Poco::FileException("Failed to load public key"); - publicKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, 0, 0); - } - BIO_free(bio); - if (!publicKey) - { - freeRSA(); - throw Poco::FileException("Failed to load public key"); - } - } - - if (pPrivateKeyStream) - { - std::string privateKeyData; - Poco::StreamCopier::copyToString(*pPrivateKeyStream, privateKeyData); - BIO* bio = BIO_new_mem_buf(const_cast(privateKeyData.data()), static_cast(privateKeyData.size())); - if (!bio) throw Poco::IOException("Cannot create BIO for reading private key"); - RSA* privateKey = 0; - if (privateKeyPassphrase.empty()) - privateKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, 0); - else - privateKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, const_cast(privateKeyPassphrase.c_str())); - BIO_free(bio); - if (!privateKey) - { - freeRSA(); - throw Poco::FileException("Failed to load private key"); - } - } -} - - -RSAKeyImpl::~RSAKeyImpl() -{ - freeRSA(); -} - - -void RSAKeyImpl::freeRSA() -{ - if (_pRSA) - RSA_free(_pRSA); - _pRSA = 0; -} - - -int RSAKeyImpl::size() const -{ - return RSA_size(_pRSA); -} - - -RSAKeyImpl::ByteVec RSAKeyImpl::modulus() const -{ -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - const BIGNUM* n = 0; - const BIGNUM* e = 0; - const BIGNUM* d = 0; - RSA_get0_key(_pRSA, &n, &e, &d); - return convertToByteVec(n); -#else - return convertToByteVec(_pRSA->n); -#endif -} - - -RSAKeyImpl::ByteVec RSAKeyImpl::encryptionExponent() const -{ -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - const BIGNUM* n = 0; - const BIGNUM* e = 0; - const BIGNUM* d = 0; - RSA_get0_key(_pRSA, &n, &e, &d); - return convertToByteVec(e); -#else - return convertToByteVec(_pRSA->e); -#endif -} - - -RSAKeyImpl::ByteVec RSAKeyImpl::decryptionExponent() const -{ -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - const BIGNUM* n = 0; - const BIGNUM* e = 0; - const BIGNUM* d = 0; - RSA_get0_key(_pRSA, &n, &e, &d); - return convertToByteVec(d); -#else - return convertToByteVec(_pRSA->d); -#endif -} - - -void RSAKeyImpl::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase) -{ - if (!publicKeyFile.empty()) - { - BIO* bio = BIO_new(BIO_s_file()); - if (!bio) throw Poco::IOException("Cannot create BIO for writing public key file", publicKeyFile); - try - { - if (BIO_write_filename(bio, const_cast(publicKeyFile.c_str()))) - { - if (!PEM_write_bio_RSAPublicKey(bio, _pRSA)) - throw Poco::WriteFileException("Failed to write public key to file", publicKeyFile); - } - else throw Poco::CreateFileException("Cannot create public key file"); - } - catch (...) - { - BIO_free(bio); - throw; - } - BIO_free(bio); - } - - if (!privateKeyFile.empty()) - { - BIO* bio = BIO_new(BIO_s_file()); - if (!bio) throw Poco::IOException("Cannot create BIO for writing private key file", privateKeyFile); - try - { - if (BIO_write_filename(bio, const_cast(privateKeyFile.c_str()))) - { - int rc = 0; - if (privateKeyPassphrase.empty()) - rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, 0, 0, 0, 0, 0); - else - rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(), - reinterpret_cast(const_cast(privateKeyPassphrase.c_str())), - static_cast(privateKeyPassphrase.length()), 0, 0); - if (!rc) throw Poco::FileException("Failed to write private key to file", privateKeyFile); - } - else throw Poco::CreateFileException("Cannot create private key file", privateKeyFile); - } - catch (...) - { - BIO_free(bio); - throw; - } - BIO_free(bio); - } -} - - -void RSAKeyImpl::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase) -{ - if (pPublicKeyStream) - { - BIO* bio = BIO_new(BIO_s_mem()); - if (!bio) throw Poco::IOException("Cannot create BIO for writing public key"); - if (!PEM_write_bio_RSAPublicKey(bio, _pRSA)) - { - BIO_free(bio); - throw Poco::WriteFileException("Failed to write public key to stream"); - } - char* pData; - long size = BIO_get_mem_data(bio, &pData); - pPublicKeyStream->write(pData, static_cast(size)); - BIO_free(bio); - } - - if (pPrivateKeyStream) - { - BIO* bio = BIO_new(BIO_s_mem()); - if (!bio) throw Poco::IOException("Cannot create BIO for writing public key"); - int rc = 0; - if (privateKeyPassphrase.empty()) - rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, 0, 0, 0, 0, 0); - else - rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(), - reinterpret_cast(const_cast(privateKeyPassphrase.c_str())), - static_cast(privateKeyPassphrase.length()), 0, 0); - if (!rc) - { - BIO_free(bio); - throw Poco::FileException("Failed to write private key to stream"); - } - char* pData; - long size = BIO_get_mem_data(bio, &pData); - pPrivateKeyStream->write(pData, static_cast(size)); - BIO_free(bio); - } -} - - -RSAKeyImpl::ByteVec RSAKeyImpl::convertToByteVec(const BIGNUM* bn) -{ - int numBytes = BN_num_bytes(bn); - ByteVec byteVector(numBytes); - - ByteVec::value_type* buffer = new ByteVec::value_type[numBytes]; - BN_bn2bin(bn, buffer); - - for (int i = 0; i < numBytes; ++i) - byteVector[i] = buffer[i]; - - delete [] buffer; - - return byteVector; -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/src/X509Certificate.cpp b/contrib/libpoco/Crypto/src/X509Certificate.cpp deleted file mode 100644 index f7f37965ed8..00000000000 --- a/contrib/libpoco/Crypto/src/X509Certificate.cpp +++ /dev/null @@ -1,295 +0,0 @@ -// -// X509Certificate.cpp -// -// $Id: //poco/1.4/Crypto/src/X509Certificate.cpp#1 $ -// -// Library: Crypto -// Package: Certificate -// Module: X509Certificate -// -// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Crypto/X509Certificate.h" -#include "Poco/StreamCopier.h" -#include "Poco/String.h" -#include "Poco/DateTimeParser.h" -#include -#include -#include -#include -#include - - -namespace Poco { -namespace Crypto { - - -X509Certificate::X509Certificate(std::istream& istr): - _pCert(0) -{ - load(istr); -} - - -X509Certificate::X509Certificate(const std::string& path): - _pCert(0) -{ - load(path); -} - - -X509Certificate::X509Certificate(X509* pCert): - _pCert(pCert) -{ - poco_check_ptr(_pCert); - - init(); -} - - -X509Certificate::X509Certificate(X509* pCert, bool shared): - _pCert(pCert) -{ - poco_check_ptr(_pCert); - - if (shared) - { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - X509_up_ref(_pCert); -#else - _pCert->references++; -#endif - } - - init(); -} - - -X509Certificate::X509Certificate(const X509Certificate& cert): - _issuerName(cert._issuerName), - _subjectName(cert._subjectName), - _pCert(cert._pCert) -{ - _pCert = X509_dup(_pCert); -} - - -X509Certificate& X509Certificate::operator = (const X509Certificate& cert) -{ - X509Certificate tmp(cert); - swap(tmp); - return *this; -} - - -void X509Certificate::swap(X509Certificate& cert) -{ - using std::swap; - swap(cert._issuerName, _issuerName); - swap(cert._subjectName, _subjectName); - swap(cert._pCert, _pCert); -} - - -X509Certificate::~X509Certificate() -{ - X509_free(_pCert); -} - - -void X509Certificate::load(std::istream& istr) -{ - poco_assert (!_pCert); - - std::stringstream certStream; - Poco::StreamCopier::copyStream(istr, certStream); - std::string cert = certStream.str(); - - BIO *pBIO = BIO_new_mem_buf(const_cast(cert.data()), static_cast(cert.size())); - if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate"); - _pCert = PEM_read_bio_X509(pBIO, 0, 0, 0); - BIO_free(pBIO); - - if (!_pCert) throw Poco::IOException("Faild to load certificate from stream"); - - init(); -} - - -void X509Certificate::load(const std::string& path) -{ - poco_assert (!_pCert); - - BIO *pBIO = BIO_new(BIO_s_file()); - if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate file", path); - if (!BIO_read_filename(pBIO, path.c_str())) - { - BIO_free(pBIO); - throw Poco::OpenFileException("Cannot open certificate file for reading", path); - } - - _pCert = PEM_read_bio_X509(pBIO, 0, 0, 0); - BIO_free(pBIO); - - if (!_pCert) throw Poco::ReadFileException("Faild to load certificate from", path); - - init(); -} - - -void X509Certificate::save(std::ostream& stream) const -{ - BIO *pBIO = BIO_new(BIO_s_mem()); - if (!pBIO) throw Poco::IOException("Cannot create BIO for writing certificate"); - try - { - if (!PEM_write_bio_X509(pBIO, _pCert)) - throw Poco::IOException("Failed to write certificate to stream"); - - char *pData; - long size; - size = BIO_get_mem_data(pBIO, &pData); - stream.write(pData, size); - } - catch (...) - { - BIO_free(pBIO); - throw; - } - BIO_free(pBIO); -} - - -void X509Certificate::save(const std::string& path) const -{ - BIO *pBIO = BIO_new(BIO_s_file()); - if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate file", path); - if (!BIO_write_filename(pBIO, const_cast(path.c_str()))) - { - BIO_free(pBIO); - throw Poco::CreateFileException("Cannot create certificate file", path); - } - try - { - if (!PEM_write_bio_X509(pBIO, _pCert)) - throw Poco::WriteFileException("Failed to write certificate to file", path); - } - catch (...) - { - BIO_free(pBIO); - throw; - } - BIO_free(pBIO); -} - - -void X509Certificate::init() -{ - char buffer[NAME_BUFFER_SIZE]; - X509_NAME_oneline(X509_get_issuer_name(_pCert), buffer, sizeof(buffer)); - _issuerName = buffer; - X509_NAME_oneline(X509_get_subject_name(_pCert), buffer, sizeof(buffer)); - _subjectName = buffer; -} - - -std::string X509Certificate::commonName() const -{ - return subjectName(NID_COMMON_NAME); -} - - -std::string X509Certificate::issuerName(NID nid) const -{ - if (X509_NAME* issuer = X509_get_issuer_name(_pCert)) - { - char buffer[NAME_BUFFER_SIZE]; - if (X509_NAME_get_text_by_NID(issuer, nid, buffer, sizeof(buffer)) >= 0) - return std::string(buffer); - } - return std::string(); -} - - -std::string X509Certificate::subjectName(NID nid) const -{ - if (X509_NAME* subj = X509_get_subject_name(_pCert)) - { - char buffer[NAME_BUFFER_SIZE]; - if (X509_NAME_get_text_by_NID(subj, nid, buffer, sizeof(buffer)) >= 0) - return std::string(buffer); - } - return std::string(); -} - - -void X509Certificate::extractNames(std::string& cmnName, std::set& domainNames) const -{ - domainNames.clear(); - if (STACK_OF(GENERAL_NAME)* names = static_cast(X509_get_ext_d2i(_pCert, NID_subject_alt_name, 0, 0))) - { - for (int i = 0; i < sk_GENERAL_NAME_num(names); ++i) - { - const GENERAL_NAME* name = sk_GENERAL_NAME_value(names, i); - if (name->type == GEN_DNS) - { - const char* data = reinterpret_cast(ASN1_STRING_data(name->d.ia5)); - std::size_t len = ASN1_STRING_length(name->d.ia5); - domainNames.insert(std::string(data, len)); - } - } - GENERAL_NAMES_free(names); - } - - cmnName = commonName(); - if (!cmnName.empty() && domainNames.empty()) - { - domainNames.insert(cmnName); - } -} - - -Poco::DateTime X509Certificate::validFrom() const -{ - ASN1_TIME* certTime = X509_get_notBefore(_pCert); - std::string dateTime(reinterpret_cast(certTime->data)); - int tzd; - return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd); -} - - -Poco::DateTime X509Certificate::expiresOn() const -{ - ASN1_TIME* certTime = X509_get_notAfter(_pCert); - std::string dateTime(reinterpret_cast(certTime->data)); - int tzd; - return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd); -} - - -bool X509Certificate::issuedBy(const X509Certificate& issuerCertificate) const -{ - X509* pCert = const_cast(_pCert); - X509* pIssuerCert = const_cast(issuerCertificate.certificate()); - EVP_PKEY* pIssuerPublicKey = X509_get_pubkey(pIssuerCert); - if (!pIssuerPublicKey) throw Poco::InvalidArgumentException("Issuer certificate has no public key"); - int rc = X509_verify(pCert, pIssuerPublicKey); - EVP_PKEY_free(pIssuerPublicKey); - return rc == 1; -} - - -bool X509Certificate::equals(const X509Certificate& otherCertificate) const -{ - X509* pCert = const_cast(_pCert); - X509* pOtherCert = const_cast(otherCertificate.certificate()); - return X509_cmp(pCert, pOtherCert) == 0; -} - - -} } // namespace Poco::Crypto diff --git a/contrib/libpoco/Crypto/testsuite/CMakeLists.txt b/contrib/libpoco/Crypto/testsuite/CMakeLists.txt deleted file mode 100644 index c0d6f8eed48..00000000000 --- a/contrib/libpoco/Crypto/testsuite/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -set(TESTUNIT "${LIBNAME}-testrunner") - -# Sources -file(GLOB SRCS_G "src/*.cpp") -POCO_SOURCES_AUTO( TEST_SRCS ${SRCS_G}) - -# Headers -file(GLOB_RECURSE HDRS_G "src/*.h" ) -POCO_HEADERS_AUTO( TEST_SRCS ${HDRS_G}) - -POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF - src/WinDriver.cpp -) - -POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE - src/WinCEDriver.cpp -) - -add_executable( ${TESTUNIT} ${TEST_SRCS} ) -add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) -target_link_libraries( ${TESTUNIT} PocoCrypto PocoNetSSL PocoXML PocoUtil PocoFoundation CppUnit ) -if(UNIX) - target_link_libraries( ${TESTUNIT} pthread) -endif(UNIX) diff --git a/contrib/libpoco/Crypto/testsuite/src/CryptoTest.cpp b/contrib/libpoco/Crypto/testsuite/src/CryptoTest.cpp deleted file mode 100644 index 53764df137c..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/CryptoTest.cpp +++ /dev/null @@ -1,281 +0,0 @@ -// -// CryptoTest.cpp -// -// $Id: //poco/1.4/Crypto/testsuite/src/CryptoTest.cpp#2 $ -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "CryptoTest.h" -#include "CppUnit/TestCaller.h" -#include "CppUnit/TestSuite.h" -#include "Poco/Crypto/CipherFactory.h" -#include "Poco/Crypto/Cipher.h" -#include "Poco/Crypto/CipherKey.h" -#include "Poco/Crypto/X509Certificate.h" -#include "Poco/Crypto/CryptoStream.h" -#include "Poco/StreamCopier.h" -#include "Poco/Base64Encoder.h" -#include - - -using namespace Poco::Crypto; - - -static const std::string APPINF_PEM( - "-----BEGIN CERTIFICATE-----\n" - "MIIESzCCAzOgAwIBAgIBATALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu\n" - "Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n\n" - "aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh\n" - "cmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl\n" - "bnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu\n" - "Y29tMB4XDTA5MDUwNzE0NTY1NloXDTI5MDUwMjE0NTY1NlowgdMxEzARBgNVBAMM\n" - "CmFwcGluZi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdh\n" - "cmUgRW5naW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNV\n" - "BAgMCUNhcmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBp\n" - "bSBSb3NlbnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0Bh\n" - "cHBpbmYuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA89GolWCR\n" - "KtLQclJ2M2QtpFqzNC54hUQdR6n8+DAeruH9WFwLSdWW2fEi+jrtd/WEWCdt4PxX\n" - "F2/eBYeURus7Hg2ZtJGDd3je0+Ygsv7+we4cMN/knaBY7rATqhmnZWk+yBpkf5F2\n" - "IHp9gBxUaJWmt/bq3XrvTtzrDXpCd4zg4zPXZ8IC8ket5o3K2vnkAOsIsgN+Ffqd\n" - "4GjF4dsblG6u6E3VarGRLwGtgB8BAZOA/33mV4FHSMkc4OXpAChaK3tM8YhrLw+m\n" - "XtsfqDiv1825S6OWFCKGj/iX8X2QAkrdB63vXCSpb3de/ByIUfp31PpMlMh6dKo1\n" - "vf7yj0nb2w0utQIDAQABoyowKDAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0lAQH/BAww\n" - "CgYIKwYBBQUHAwMwDQYJKoZIhvcNAQEFBQADggEBAM0cpfb4BgiU/rkYe121P581\n" - "ftg5Ck1PYYda1Fy/FgzbgJh2AwVo/6sn6GF79/QkEcWEgtCMNNO3LMTTddUUApuP\n" - "jnEimyfmUhIThyud/vryzTMNa/eZMwaAqUQWqLf+AwgqjUsBSMenbSHavzJOpsvR\n" - "LI0PQ1VvqB+3UGz0JUnBJiKvHs83Fdm4ewPAf3M5fGcIa+Fl2nU5Plzwzskj84f6\n" - "73ZlEEi3aW9JieNy7RWsMM+1E8Sj2CGRZC4BM9V1Fgnsh4+VHX8Eu7eHucvfeIYx\n" - "3mmLMoK4sCayL/FGhrUDw5AkWb8tKNpRXY+W60Et281yxQSeWLPIbatVzIWI0/M=\n" - "-----END CERTIFICATE-----\n" -); - - -CryptoTest::CryptoTest(const std::string& name): CppUnit::TestCase(name) -{ -} - - -CryptoTest::~CryptoTest() -{ -} - - -void CryptoTest::testEncryptDecrypt() -{ - Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256")); - - for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) - { - std::string in(n, 'x'); - std::string out = pCipher->encryptString(in, Cipher::ENC_NONE); - std::string result = pCipher->decryptString(out, Cipher::ENC_NONE); - assert (in == result); - } - - for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) - { - std::string in(n, 'x'); - std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64); - std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64); - assert (in == result); - } - - for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) - { - std::string in(n, 'x'); - std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX); - std::string result = pCipher->decryptString(out, Cipher::ENC_BINHEX); - assert (in == result); - } -} - - -void CryptoTest::testEncryptDecryptWithSalt() -{ - Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt")); - Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt")); - - for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) - { - std::string in(n, 'x'); - std::string out = pCipher->encryptString(in, Cipher::ENC_NONE); - std::string result = pCipher2->decryptString(out, Cipher::ENC_NONE); - assert (in == result); - } - - for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) - { - std::string in(n, 'x'); - std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64); - std::string result = pCipher2->decryptString(out, Cipher::ENC_BASE64); - assert (in == result); - } - - for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) - { - std::string in(n, 'x'); - std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX); - std::string result = pCipher2->decryptString(out, Cipher::ENC_BINHEX); - assert (in == result); - } -} - - -void CryptoTest::testEncryptDecryptDESECB() -{ - Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("des-ecb", "password")); - - for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) - { - std::string in(n, 'x'); - std::string out = pCipher->encryptString(in, Cipher::ENC_NONE); - std::string result = pCipher->decryptString(out, Cipher::ENC_NONE); - assert (in == result); - } - - for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) - { - std::string in(n, 'x'); - std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64); - std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64); - assert (in == result); - } - - for (std::size_t n = 1; n < MAX_DATA_SIZE; n++) - { - std::string in(n, 'x'); - std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX); - std::string result = pCipher->decryptString(out, Cipher::ENC_BINHEX); - assert (in == result); - } -} - - -void CryptoTest::testPassword() -{ - CipherKey key("aes256", "password", "salt"); - - std::ostringstream keyStream; - Poco::Base64Encoder base64KeyEnc(keyStream); - base64KeyEnc.write(reinterpret_cast(&key.getKey()[0]), key.keySize()); - base64KeyEnc.close(); - std::string base64Key = keyStream.str(); - assert (base64Key == "hIzxBt58GDd7/6mRp88bewKk42lM4QwaF78ek0FkVoA="); -} - - -void CryptoTest::testEncryptInterop() -{ - Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "password", "salt")); - - const std::string plainText = "This is a secret message."; - const std::string expectedCipherText = "9HITTPaU3A/LaZzldbdnRZ109DKlshouKren/n8BsHc="; - std::string cipherText = pCipher->encryptString(plainText, Cipher::ENC_BASE64); - assert (cipherText == expectedCipherText); -} - - -void CryptoTest::testDecryptInterop() -{ - Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "password", "salt")); - - const std::string expectedPlainText = "This is a secret message."; - const std::string cipherText = "9HITTPaU3A/LaZzldbdnRZ109DKlshouKren/n8BsHc="; - std::string plainText = pCipher->decryptString(cipherText, Cipher::ENC_BASE64); - assert (plainText == expectedPlainText); -} - - -void CryptoTest::testStreams() -{ - Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256")); - - static const std::string SECRET_MESSAGE = "This is a secret message. Don't tell anyone."; - - std::stringstream sstr; - EncryptingOutputStream encryptor(sstr, *pCipher); - encryptor << SECRET_MESSAGE; - encryptor.close(); - - DecryptingInputStream decryptor(sstr, *pCipher); - std::string result; - Poco::StreamCopier::copyToString(decryptor, result); - - assert (result == SECRET_MESSAGE); - assert (decryptor.eof()); - assert (!decryptor.bad()); - - - std::istringstream emptyStream; - DecryptingInputStream badDecryptor(emptyStream, *pCipher); - Poco::StreamCopier::copyToString(badDecryptor, result); - - assert (badDecryptor.fail()); - assert (badDecryptor.bad()); - assert (!badDecryptor.eof()); -} - - -void CryptoTest::testCertificate() -{ - std::istringstream certStream(APPINF_PEM); - X509Certificate cert(certStream); - - std::string subjectName(cert.subjectName()); - std::string issuerName(cert.issuerName()); - std::string commonName(cert.commonName()); - std::string country(cert.subjectName(X509Certificate::NID_COUNTRY)); - std::string localityName(cert.subjectName(X509Certificate::NID_LOCALITY_NAME)); - std::string stateOrProvince(cert.subjectName(X509Certificate::NID_STATE_OR_PROVINCE)); - std::string organizationName(cert.subjectName(X509Certificate::NID_ORGANIZATION_NAME)); - std::string organizationUnitName(cert.subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME)); - - assert (subjectName == "/CN=appinf.com/O=Applied Informatics Software Engineering GmbH/OU=Development/ST=Carinthia/C=AT/L=St. Jakob im Rosental/emailAddress=guenter.obiltschnig@appinf.com"); - assert (issuerName == subjectName); - assert (commonName == "appinf.com"); - assert (country == "AT"); - assert (localityName == "St. Jakob im Rosental"); - assert (stateOrProvince == "Carinthia"); - assert (organizationName == "Applied Informatics Software Engineering GmbH"); - assert (organizationUnitName == "Development"); - - // fails with recent OpenSSL versions: - // assert (cert.issuedBy(cert)); - - std::istringstream otherCertStream(APPINF_PEM); - X509Certificate otherCert(otherCertStream); - - assert (cert.equals(otherCert)); -} - - -void CryptoTest::setUp() -{ -} - - -void CryptoTest::tearDown() -{ -} - - -CppUnit::Test* CryptoTest::suite() -{ - CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("CryptoTest"); - - CppUnit_addTest(pSuite, CryptoTest, testEncryptDecrypt); - CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptWithSalt); - CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptDESECB); - CppUnit_addTest(pSuite, CryptoTest, testPassword); - CppUnit_addTest(pSuite, CryptoTest, testEncryptInterop); - CppUnit_addTest(pSuite, CryptoTest, testDecryptInterop); - CppUnit_addTest(pSuite, CryptoTest, testStreams); - CppUnit_addTest(pSuite, CryptoTest, testCertificate); - - return pSuite; -} diff --git a/contrib/libpoco/Crypto/testsuite/src/CryptoTest.h b/contrib/libpoco/Crypto/testsuite/src/CryptoTest.h deleted file mode 100644 index 18390f67095..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/CryptoTest.h +++ /dev/null @@ -1,52 +0,0 @@ -// -// CryptoTest.h -// -// $Id: //poco/1.4/Crypto/testsuite/src/CryptoTest.h#2 $ -// -// Definition of the CryptoTest class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef CryptoTest_INCLUDED -#define CryptoTest_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "CppUnit/TestCase.h" - - -class CryptoTest: public CppUnit::TestCase -{ -public: - enum - { - MAX_DATA_SIZE = 10000 - }; - - CryptoTest(const std::string& name); - ~CryptoTest(); - - void testEncryptDecrypt(); - void testEncryptDecryptWithSalt(); - void testEncryptDecryptDESECB(); - void testStreams(); - void testPassword(); - void testEncryptInterop(); - void testDecryptInterop(); - void testCertificate(); - - void setUp(); - void tearDown(); - - static CppUnit::Test* suite(); - -private: -}; - - -#endif // CryptoTest_INCLUDED diff --git a/contrib/libpoco/Crypto/testsuite/src/CryptoTestSuite.cpp b/contrib/libpoco/Crypto/testsuite/src/CryptoTestSuite.cpp deleted file mode 100644 index 2cd2396231a..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/CryptoTestSuite.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// -// CryptoTestSuite.cpp -// -// $Id: //poco/1.4/Crypto/testsuite/src/CryptoTestSuite.cpp#1 $ -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "CryptoTestSuite.h" -#include "CryptoTest.h" -#include "RSATest.h" -#include "DigestEngineTest.h" - - -CppUnit::Test* CryptoTestSuite::suite() -{ - CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("CryptoTestSuite"); - - pSuite->addTest(CryptoTest::suite()); - pSuite->addTest(RSATest::suite()); - pSuite->addTest(DigestEngineTest::suite()); - - return pSuite; -} diff --git a/contrib/libpoco/Crypto/testsuite/src/CryptoTestSuite.h b/contrib/libpoco/Crypto/testsuite/src/CryptoTestSuite.h deleted file mode 100644 index 0469b7cae0e..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/CryptoTestSuite.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// CryptoTestSuite.h -// -// $Id: //poco/1.4/Crypto/testsuite/src/CryptoTestSuite.h#1 $ -// -// Definition of the CryptoTestSuite class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef CryptoTestSuite_INCLUDED -#define CryptoTestSuite_INCLUDED - - -#include "CppUnit/TestSuite.h" - - -class CryptoTestSuite -{ -public: - static CppUnit::Test* suite(); -}; - - -#endif // CryptoTestSuite_INCLUDED diff --git a/contrib/libpoco/Crypto/testsuite/src/DigestEngineTest.cpp b/contrib/libpoco/Crypto/testsuite/src/DigestEngineTest.cpp deleted file mode 100644 index e1763e6bfa6..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/DigestEngineTest.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// -// DigestEngineTest.cpp -// -// $Id: //poco/1.4/Crypto/testsuite/src/DigestEngineTest.cpp#1 $ -// -// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "DigestEngineTest.h" -#include "CppUnit/TestCaller.h" -#include "CppUnit/TestSuite.h" -#include "Poco/Crypto/DigestEngine.h" - - -using Poco::Crypto::DigestEngine; - - -DigestEngineTest::DigestEngineTest(const std::string& name): CppUnit::TestCase(name) -{ -} - - -DigestEngineTest::~DigestEngineTest() -{ -} - - -void DigestEngineTest::testMD5() -{ - DigestEngine engine("MD5"); - - // test vectors from RFC 1321 - - engine.update(""); - assert (DigestEngine::digestToHex(engine.digest()) == "d41d8cd98f00b204e9800998ecf8427e"); - - engine.update("a"); - assert (DigestEngine::digestToHex(engine.digest()) == "0cc175b9c0f1b6a831c399e269772661"); - - engine.update("abc"); - assert (DigestEngine::digestToHex(engine.digest()) == "900150983cd24fb0d6963f7d28e17f72"); - - engine.update("message digest"); - assert (DigestEngine::digestToHex(engine.digest()) == "f96b697d7cb7938d525a2f31aaf161d0"); - - engine.update("abcdefghijklmnopqrstuvwxyz"); - assert (DigestEngine::digestToHex(engine.digest()) == "c3fcd3d76192e4007dfb496cca67e13b"); - - engine.update("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - engine.update("abcdefghijklmnopqrstuvwxyz0123456789"); - assert (DigestEngine::digestToHex(engine.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f"); - - engine.update("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); - assert (DigestEngine::digestToHex(engine.digest()) == "57edf4a22be3c955ac49da2e2107b67a"); -} - -void DigestEngineTest::testSHA1() -{ - DigestEngine engine("SHA1"); - - // test vectors from FIPS 180-1 - - engine.update("abc"); - assert (DigestEngine::digestToHex(engine.digest()) == "a9993e364706816aba3e25717850c26c9cd0d89d"); - - engine.update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"); - assert (DigestEngine::digestToHex(engine.digest()) == "84983e441c3bd26ebaae4aa1f95129e5e54670f1"); - - for (int i = 0; i < 1000000; ++i) - engine.update('a'); - assert (DigestEngine::digestToHex(engine.digest()) == "34aa973cd4c4daa4f61eeb2bdbad27316534016f"); -} - -void DigestEngineTest::setUp() -{ -} - - -void DigestEngineTest::tearDown() -{ -} - - -CppUnit::Test* DigestEngineTest::suite() -{ - CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DigestEngineTest"); - - CppUnit_addTest(pSuite, DigestEngineTest, testMD5); - CppUnit_addTest(pSuite, DigestEngineTest, testSHA1); - - return pSuite; -} diff --git a/contrib/libpoco/Crypto/testsuite/src/DigestEngineTest.h b/contrib/libpoco/Crypto/testsuite/src/DigestEngineTest.h deleted file mode 100644 index 89fc24d30f5..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/DigestEngineTest.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// DigestEngineTest.h -// -// $Id: //poco/1.4/Crypto/testsuite/src/DigestEngineTest.h#1 $ -// -// Definition of the DigestEngineTest class. -// -// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DigestEngineTest_INCLUDED -#define DigestEngineTest_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "CppUnit/TestCase.h" - - -class DigestEngineTest: public CppUnit::TestCase -{ -public: - DigestEngineTest(const std::string& name); - ~DigestEngineTest(); - - void testMD5(); - void testSHA1(); - - void setUp(); - void tearDown(); - - static CppUnit::Test* suite(); - -private: -}; - - -#endif // DigestEngineTest_INCLUDED diff --git a/contrib/libpoco/Crypto/testsuite/src/Driver.cpp b/contrib/libpoco/Crypto/testsuite/src/Driver.cpp deleted file mode 100644 index 96ff4f22139..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/Driver.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// -// Driver.cpp -// -// $Id: //poco/1.4/Crypto/testsuite/src/Driver.cpp#1 $ -// -// Console-based test driver for Poco Crypto. -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "CppUnit/TestRunner.h" -#include "CryptoTestSuite.h" -#include "Poco/Crypto/Crypto.h" - - -class CryptoInitializer -{ -public: - CryptoInitializer() - { - Poco::Crypto::initializeCrypto(); - } - - ~CryptoInitializer() - { - Poco::Crypto::uninitializeCrypto(); - } -}; - - -int main(int ac, char **av) -{ - CryptoInitializer ci; - - std::vector args; - for (int i = 0; i < ac; ++i) - args.push_back(std::string(av[i])); - CppUnit::TestRunner runner; - runner.addTest("CryptoTestSuite", CryptoTestSuite::suite()); - return runner.run(args) ? 0 : 1; -} diff --git a/contrib/libpoco/Crypto/testsuite/src/RSATest.cpp b/contrib/libpoco/Crypto/testsuite/src/RSATest.cpp deleted file mode 100644 index 690cfa0968d..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/RSATest.cpp +++ /dev/null @@ -1,279 +0,0 @@ -// -// RSATest.cpp -// -// $Id: //poco/1.4/Crypto/testsuite/src/RSATest.cpp#1 $ -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "RSATest.h" -#include "CppUnit/TestCaller.h" -#include "CppUnit/TestSuite.h" -#include "Poco/Crypto/RSADigestEngine.h" -#include "Poco/Crypto/CipherFactory.h" -#include "Poco/Crypto/Cipher.h" -#include "Poco/Crypto/X509Certificate.h" -#include - - -using namespace Poco::Crypto; - - -static const std::string anyPem( - "-----BEGIN CERTIFICATE-----\r\n" - "MIICaDCCAdECCQCzfxSsk7yaLjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n" - "VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n" - "BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n" - "aW5mLmNvbTAeFw0wNjAzMDExMzA3MzFaFw0wNjAzMzExMzA3MzFaMH4xCzAJBgNV\r\n" - "BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExETAPBgNVBAcTCFN0IEpha29iMRww\r\n" - "GgYDVQQKExNBcHBsaWVkIEluZm9ybWF0aWNzMQowCAYDVQQDFAEqMR4wHAYJKoZI\r\n" - "hvcNAQkBFg9pbmZvQGFwcGluZi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ\r\n" - "AoGBAJHGyXDHyCYoWz+65ltNwwZbhwOGnxr9P1WMATuFJh0bPBZxKbZRdbTm9KhZ\r\n" - "OlvsEIsfgiYdsxURYIqXfEgISYLZcZY0pQwGEOmB+0NeC/+ENSfOlNSthx6zSVlc\r\n" - "zhJ7+dJOGwepHAiLr1fRuc5jogYLraE+lKTnqAAFfzwvti77AgMBAAEwDQYJKoZI\r\n" - "hvcNAQEFBQADgYEAY/ZoeY1ukkEJX7259NeoVM0oahlulWV0rlCqyaeosOiDORPT\r\n" - "m6X1w/5MTCf9VyaD1zukoSZ4QqNVjHFXcXidbB7Tgt3yRuZ5PC5LIFCDPv9mgPne\r\n" - "mUA70yfctNfza2z3ZiQ6NDkW3mZX+1tmxYIrJQIrkVeYeqf1Gh2nyZrUMcE=\r\n" - "-----END CERTIFICATE-----\r\n" - "-----BEGIN RSA PRIVATE KEY-----\r\n" - "Proc-Type: 4,ENCRYPTED\r\n" - "DEK-Info: DES-EDE3-CBC,E7AE93C9E49184EA\r\n" - "\r\n" - "A2IqzNcWs+I5vzV+i+woDk56+yr58eU0Onw8eEvXkLjnSc58JU4327IF7yUbKWdW\r\n" - "Q7BYGGOkVFiZ7ANOwviDg5SUhxRDWCcW8dS6/p1vfdQ1C3qj2OwJjkpg0aDBIzJn\r\n" - "FzgguT3MF3ama77vxv0S3kOfmCj62MLqPGpj5pQ0/1hefRFbL8oAX8bXUN7/rmGM\r\n" - "Zc0QyzFZv2iQ04dY/6TNclwKPB4H0On4K+8BMs3PRkWA0clCaQaFO2+iwnk3XZfe\r\n" - "+MsKUEbLCpAQeYspYv1cw38dCdWq1KTP5aJk+oXgwjfX5cAaPTz74NTqTIsCcaTD\r\n" - "3vy7ukJYFlDR9Kyo7z8rMazYrKJslhnuRH0BhK9st9McwL957j5tZmrKyraCcmCx\r\n" - "dMAGcsis1va3ayYZpIpFqA4EhYrTM+6N8ZRfUap20+b5IQwHfTQDejUhL6rBwy7j\r\n" - "Ti5yD83/itoOMyXq2sV/XWfVD5zk/P5iv22O1EAQMhhnPB9K/I/JhuSGQJfn3cNh\r\n" - "ykOUYT0+vDeSeEVa+FVEP1W35G0alTbKbNs5Tb8KxJ3iDJUxokM//SvPXZy9hOVX\r\n" - "Y05imB04J15DaGbAHlNzunhuJi7121WV/JRXZRW9diE6hwpD8rwqi3FMuRUmy7U9\r\n" - "aFA5poKRAYlo9YtZ3YpFyjGKB6MfCQcB2opuSnQ/gbugV41m67uQ4CDwWLaNRkTb\r\n" - "GlsMBNcHnidg15Bsat5HaB7l250ukrI13Uw1MYdDUzaS3gPfw9aC4F2w0p3U+DPH\r\n" - "80/zePxtroR7T4/+rI136Rl+aMXDMOEGCX1TVP8rjuZzuRyUSUKC8Q==\r\n" - "-----END RSA PRIVATE KEY-----\r\n" - "-----BEGIN CERTIFICATE-----\r\n" - "MIICXTCCAcYCCQC1Vk/N8qR4AjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n" - "VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n" - "BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n" - "aW5mLmNvbTAeFw0wNjAyMjcxMzI3MThaFw0wNjAzMjkxMzI3MThaMHMxCzAJBgNV\r\n" - "BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExEjAQBgNVBAcTCVN0LiBKYWtvYjEP\r\n" - "MA0GA1UEChMGQXBwSW5mMQ8wDQYDVQQDEwZBcHBJbmYxGjAYBgkqhkiG9w0BCQEW\r\n" - "C2FwcEBpbmYuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsFXiPuicN\r\n" - "Im4oJwF8NuaFN+lgYwcZ6dAO3ILIR3kLA2PxF8HSQLfF8J8a4odZhLhctIMAKTxm\r\n" - "k0w8TW5qhL8QLdGzY9vzvkgdKOkan2t3sMeXJAfrM1AphTsmgntAQazGZjOj5p4W\r\n" - "jDnxQ+VXAylqwjHh49eSBxM3wgoscF4iLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GB\r\n" - "AIpfLdXiKchPvFMhQS8xTtXvrw5dVL3yImUMYs4GQi8RrjGmfGB3yMAR7B/b8v4a\r\n" - "+ztfusgWAWiUKuSGTk4S8YB0fsFlmOv0WDr+PyZ4Lui/a8opbyzGE7rqpnF/s0GO\r\n" - "M7uLCNNwIN7WhmxcWV0KZU1wTppoSWPJda1yTbBzF9XP\r\n" - "-----END CERTIFICATE-----\r\n" -); - - -RSATest::RSATest(const std::string& name): CppUnit::TestCase(name) -{ -} - - -RSATest::~RSATest() -{ -} - - -void RSATest::testNewKeys() -{ - RSAKey key(RSAKey::KL_1024, RSAKey::EXP_SMALL); - std::ostringstream strPub; - std::ostringstream strPriv; - key.save(&strPub, &strPriv, "testpwd"); - std::string pubKey = strPub.str(); - std::string privKey = strPriv.str(); - - // now do the round trip - std::istringstream iPub(pubKey); - std::istringstream iPriv(privKey); - RSAKey key2(&iPub, &iPriv, "testpwd"); - - std::istringstream iPriv2(privKey); - RSAKey key3(0, &iPriv2, "testpwd"); - std::ostringstream strPub3; - key3.save(&strPub3); - std::string pubFromPrivate = strPub3.str(); - assert (pubFromPrivate == pubKey); -} - - -void RSATest::testNewKeysNoPassphrase() -{ - RSAKey key(RSAKey::KL_1024, RSAKey::EXP_SMALL); - std::ostringstream strPub; - std::ostringstream strPriv; - key.save(&strPub, &strPriv); - std::string pubKey = strPub.str(); - std::string privKey = strPriv.str(); - - // now do the round trip - std::istringstream iPub(pubKey); - std::istringstream iPriv(privKey); - RSAKey key2(&iPub, &iPriv); - - std::istringstream iPriv2(privKey); - RSAKey key3(0, &iPriv2); - std::ostringstream strPub3; - key3.save(&strPub3); - std::string pubFromPrivate = strPub3.str(); - assert (pubFromPrivate == pubKey); -} - - -void RSATest::testSign() -{ - std::string msg("Test this sign message"); - RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE); - RSADigestEngine eng(key); - eng.update(msg.c_str(), static_cast(msg.length())); - const Poco::DigestEngine::Digest& sig = eng.signature(); - std::string hexDig = Poco::DigestEngine::digestToHex(sig); - - // verify - std::ostringstream strPub; - key.save(&strPub); - std::string pubKey = strPub.str(); - std::istringstream iPub(pubKey); - RSAKey keyPub(&iPub); - RSADigestEngine eng2(keyPub); - eng2.update(msg.c_str(), static_cast(msg.length())); - assert (eng2.verify(sig)); -} - - -void RSATest::testSignSha256() -{ - std::string msg("Test this sign message"); - RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE); - RSADigestEngine eng(key, "SHA256"); - eng.update(msg.c_str(), static_cast(msg.length())); - const Poco::DigestEngine::Digest& sig = eng.signature(); - std::string hexDig = Poco::DigestEngine::digestToHex(sig); - - // verify - std::ostringstream strPub; - key.save(&strPub); - std::string pubKey = strPub.str(); - std::istringstream iPub(pubKey); - RSAKey keyPub(&iPub); - RSADigestEngine eng2(keyPub, "SHA256"); - eng2.update(msg.c_str(), static_cast(msg.length())); - assert (eng2.verify(sig)); -} - - -void RSATest::testSignManipulated() -{ - std::string msg("Test this sign message"); - std::string msgManip("Test that sign message"); - RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE); - RSADigestEngine eng(key); - eng.update(msg.c_str(), static_cast(msg.length())); - const Poco::DigestEngine::Digest& sig = eng.signature(); - std::string hexDig = Poco::DigestEngine::digestToHex(sig); - - // verify - std::ostringstream strPub; - key.save(&strPub); - std::string pubKey = strPub.str(); - std::istringstream iPub(pubKey); - RSAKey keyPub(&iPub); - RSADigestEngine eng2(keyPub); - eng2.update(msgManip.c_str(), static_cast(msgManip.length())); - assert (!eng2.verify(sig)); -} - - -void RSATest::testRSACipher() -{ - Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL)); - for (std::size_t n = 1; n <= 1200; n++) - { - std::string val(n, 'x'); - std::string enc = pCipher->encryptString(val); - std::string dec = pCipher->decryptString(enc); - assert (dec == val); - } -} - - -void RSATest::testRSACipherLarge() -{ - std::vector sizes; - sizes.push_back (2047); - sizes.push_back (2048); - sizes.push_back (2049); - sizes.push_back (4095); - sizes.push_back (4096); - sizes.push_back (4097); - sizes.push_back (8191); - sizes.push_back (8192); - sizes.push_back (8193); - sizes.push_back (16383); - sizes.push_back (16384); - sizes.push_back (16385); - - Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL)); - for (std::vector::const_iterator it = sizes.begin(); it != sizes.end(); ++it) - { - std::string val(*it, 'x'); - std::string enc = pCipher->encryptString(val); - std::string dec = pCipher->decryptString(enc); - assert (dec == val); - } -} - - -void RSATest::testCertificate() -{ - std::istringstream str(anyPem); - X509Certificate cert(str); - RSAKey publicKey(cert); - std::istringstream str2(anyPem); - RSAKey privateKey(0, &str2, "test"); - Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey); - Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey); - std::string val("lets do some encryption"); - - std::string enc = pCipher->encryptString(val); - std::string dec = pCipher2->decryptString(enc); - assert (dec == val); -} - - -void RSATest::setUp() -{ -} - - -void RSATest::tearDown() -{ -} - - -CppUnit::Test* RSATest::suite() -{ - CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("RSATest"); - - CppUnit_addTest(pSuite, RSATest, testNewKeys); - CppUnit_addTest(pSuite, RSATest, testNewKeysNoPassphrase); - CppUnit_addTest(pSuite, RSATest, testSign); - CppUnit_addTest(pSuite, RSATest, testSignSha256); - CppUnit_addTest(pSuite, RSATest, testSignManipulated); - CppUnit_addTest(pSuite, RSATest, testRSACipher); - CppUnit_addTest(pSuite, RSATest, testRSACipherLarge); - CppUnit_addTest(pSuite, RSATest, testCertificate); - - return pSuite; -} diff --git a/contrib/libpoco/Crypto/testsuite/src/RSATest.h b/contrib/libpoco/Crypto/testsuite/src/RSATest.h deleted file mode 100644 index ebef2675349..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/RSATest.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// RSATest.h -// -// $Id: //poco/1.4/Crypto/testsuite/src/RSATest.h#1 $ -// -// Definition of the RSATest class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef RSATest_INCLUDED -#define RSATest_INCLUDED - - -#include "Poco/Crypto/Crypto.h" -#include "CppUnit/TestCase.h" - - -class RSATest: public CppUnit::TestCase -{ -public: - RSATest(const std::string& name); - ~RSATest(); - - void testNewKeys(); - void testNewKeysNoPassphrase(); - void testSign(); - void testSignSha256(); - void testSignManipulated(); - void testRSACipher(); - void testRSACipherLarge(); - void testCertificate(); - - void setUp(); - void tearDown(); - - static CppUnit::Test* suite(); - -private: -}; - - -#endif // RSATest_INCLUDED diff --git a/contrib/libpoco/Crypto/testsuite/src/WinCEDriver.cpp b/contrib/libpoco/Crypto/testsuite/src/WinCEDriver.cpp deleted file mode 100644 index 704c23157fd..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/WinCEDriver.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// -// WinCEDriver.cpp -// -// $Id: //poco/1.4/Crypto/testsuite/src/WinCEDriver.cpp#1 $ -// -// Console-based test driver for Windows CE. -// -// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "CppUnit/TestRunner.h" -#include "CryptoTestSuite.h" -#include "Poco/Crypto/Crypto.h" -#include - - -class CryptoInitializer -{ -public: - CryptoInitializer() - { - Poco::Crypto::initializeCrypto(); - } - - ~CryptoInitializer() - { - Poco::Crypto::uninitializeCrypto(); - } -}; - - -int _tmain(int argc, wchar_t* argv[]) -{ - CryptoInitializer ci; - - std::vector args; - for (int i = 0; i < argc; ++i) - { - char buffer[1024]; - std::wcstombs(buffer, argv[i], sizeof(buffer)); - args.push_back(std::string(buffer)); - } - CppUnit::TestRunner runner; - runner.addTest("CryptoTestSuite", CryptoTestSuite::suite()); - return runner.run(args) ? 0 : 1; -} diff --git a/contrib/libpoco/Crypto/testsuite/src/WinDriver.cpp b/contrib/libpoco/Crypto/testsuite/src/WinDriver.cpp deleted file mode 100644 index 7bbef8179ff..00000000000 --- a/contrib/libpoco/Crypto/testsuite/src/WinDriver.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -// WinDriver.cpp -// -// $Id: //poco/1.4/Crypto/testsuite/src/WinDriver.cpp#1 $ -// -// Windows test driver for Poco Crypto. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "WinTestRunner/WinTestRunner.h" -#include "CryptoTestSuite.h" -#include "Poco/Crypto/Crypto.h" - - -class CryptoInitializer -{ -public: - CryptoInitializer() - { - Poco::Crypto::initializeCrypto(); - } - - ~CryptoInitializer() - { - Poco::Crypto::uninitializeCrypto(); - } -}; - - -class TestDriver: public CppUnit::WinTestRunnerApp -{ - void TestMain() - { - CryptoInitializer ci; - - CppUnit::WinTestRunner runner; - runner.addTest(CryptoTestSuite::suite()); - runner.run(); - } -}; - - -TestDriver theDriver; diff --git a/contrib/libpoco/DLLVersion.rc b/contrib/libpoco/DLLVersion.rc deleted file mode 100644 index a8d63b5f652..00000000000 --- a/contrib/libpoco/DLLVersion.rc +++ /dev/null @@ -1,40 +0,0 @@ -#ifdef APSTUDIO_INVOKED - #error This file is not editable by Visual C++. -#endif //APSTUDIO_INVOKED - -#include "winres.h" - -#define POCO_VERSION 1,6,1,0 -#define POCO_VERSION_STR "1.6.1" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION POCO_VERSION - PRODUCTVERSION POCO_VERSION - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", "Applied Informatics Software Engineering GmbH" - VALUE "FileDescription", "This file is part of the POCO C++ Libraries." - VALUE "FileVersion", POCO_VERSION_STR - VALUE "InternalName", "POCO" - VALUE "LegalCopyright", "Copyright (C) 2004-2015, Applied Informatics Software Engineering GmbH and Contributors." - VALUE "ProductName", "POCO C++ Libraries - http://pocoproject.org" - VALUE "ProductVersion", POCO_VERSION_STR - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/contrib/libpoco/Data/CMakeLists.txt b/contrib/libpoco/Data/CMakeLists.txt deleted file mode 100644 index 41d36010156..00000000000 --- a/contrib/libpoco/Data/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -set(LIBNAME "PocoData") -set(POCO_LIBNAME "${LIBNAME}") - -# Sources -file(GLOB SRCS_G "src/*.cpp") -POCO_SOURCES_AUTO( SRCS ${SRCS_G}) - -# Headers -file(GLOB_RECURSE HDRS_G "include/*.h" ) -POCO_HEADERS_AUTO( SRCS ${HDRS_G}) - -if (NOT POCO_STATIC) - add_definitions(-DTHREADSAFE) -endif (NOT POCO_STATIC) - -if(MSVC AND NOT(MSVC_VERSION LESS 1400)) - set_source_files_properties(src/StatementImpl.cpp - PROPERTIES COMPILE_FLAGS "/bigobj") -endif() - -include_directories (BEFORE include) - -add_library( "${LIBNAME}" ${LIB_MODE} ${SRCS} ) -set_target_properties( "${LIBNAME}" - PROPERTIES - VERSION ${SHARED_LIBRARY_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION} - OUTPUT_NAME ${POCO_LIBNAME} - DEFINE_SYMBOL Data_EXPORTS - ) - -target_link_libraries( "${LIBNAME}" PocoFoundation) - -if(POCO_ENABLE_DATA_MYSQL) - find_package(MySQL) - if(MYSQL_FOUND) - include_directories("${MYSQL_INCLUDE_DIR}") - message(STATUS "MySQL Support Enabled") - add_subdirectory( MySQL ) - else() - message(STATUS "MySQL Support Disabled - no MySQL library") - endif(MYSQL_FOUND) -endif(POCO_ENABLE_DATA_MYSQL) - -if(POCO_ENABLE_DATA_ODBC) - find_package(ODBC) - if(WIN32 AND NOT WINCE) - set(ODBC_LIBRARIES "odbc32" "odbccp32") - message(STATUS "Windows native ODBC Support Enabled") - add_subdirectory( ODBC ) - else(WIN32 AND NOT WINCE) - if(ODBC_FOUND) - include_directories("${ODBC_INCLUDE_DIRECTORIES}") - message(STATUS "ODBC Support Enabled") - add_subdirectory( ODBC ) - else() - message(STATUS "ODBC Support Disabled - no ODBC runtime") - endif() - endif(WIN32 AND NOT WINCE) -endif(POCO_ENABLE_DATA_ODBC) - -if (POCO_ENABLE_TESTS) - add_subdirectory(samples) - add_subdirectory(testsuite) -endif () diff --git a/contrib/libpoco/Data/MySQL/CMakeLists.txt b/contrib/libpoco/Data/MySQL/CMakeLists.txt deleted file mode 100644 index 8b7f84db097..00000000000 --- a/contrib/libpoco/Data/MySQL/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -set(LIBNAME "Poco_DataMySQL") -set(POCO_LIBNAME "${LIBNAME}") - -# Sources -file(GLOB SRCS_G "src/*.cpp") -POCO_SOURCES_AUTO( MYSQL_SRCS ${SRCS_G}) - -# Headers -file(GLOB_RECURSE HDRS_G "include/*.h" ) -POCO_HEADERS_AUTO( MYSQL_SRCS ${HDRS_G}) - -add_definitions(-DTHREADSAFE -DNO_TCL) - -add_library( "${LIBNAME}" ${LIB_MODE} ${MYSQL_SRCS} ) -set_target_properties( "${LIBNAME}" - PROPERTIES - VERSION ${SHARED_LIBRARY_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION} - OUTPUT_NAME ${POCO_LIBNAME} - DEFINE_SYMBOL MySQL_EXPORTS - ) - -target_link_libraries( "${LIBNAME}" PocoFoundation PocoData ${MYSQL_LIB}) - -if (POCO_ENABLE_TESTS) - add_subdirectory(testsuite) -endif () diff --git a/contrib/libpoco/Data/MySQL/cmake/PocoDataMySQLConfig.cmake b/contrib/libpoco/Data/MySQL/cmake/PocoDataMySQLConfig.cmake deleted file mode 100644 index 092774b3d21..00000000000 --- a/contrib/libpoco/Data/MySQL/cmake/PocoDataMySQLConfig.cmake +++ /dev/null @@ -1,4 +0,0 @@ -include(CMakeFindDependencyMacro) -find_dependency(PocoFoundation) -find_dependency(PocoData) -include("${CMAKE_CURRENT_LIST_DIR}/PocoDataMySQLTargets.cmake") diff --git a/contrib/libpoco/Data/MySQL/include/Poco/Data/MySQL/Binder.h b/contrib/libpoco/Data/MySQL/include/Poco/Data/MySQL/Binder.h deleted file mode 100644 index 6f6374acd08..00000000000 --- a/contrib/libpoco/Data/MySQL/include/Poco/Data/MySQL/Binder.h +++ /dev/null @@ -1,260 +0,0 @@ -// -// Binder.h -// -// $Id: //poco/1.4/Data/MySQL/include/Poco/Data/MySQL/Binder.h#1 $ -// -// Library: Data -// Package: MySQL -// Module: Binder -// -// Definition of the Binder class. -// -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Data_MySQL_Binder_INCLUDED -#define Data_MySQL_Binder_INCLUDED - -#include "Poco/Data/MySQL/MySQL.h" -#include "Poco/Data/AbstractBinder.h" -#include "Poco/Data/LOB.h" -#include "Poco/Data/MySQL/MySQLException.h" -#include - -namespace Poco { -namespace Data { -namespace MySQL { - - -class MySQL_API Binder: public Poco::Data::AbstractBinder - /// Binds placeholders in the sql query to the provided values. Performs data types mapping. -{ -public: - typedef SharedPtr Ptr; - - Binder(); - /// Creates the Binder. - - virtual ~Binder(); - /// Destroys the Binder. - - virtual void bind(std::size_t pos, const Poco::Int8& val, Direction dir); - /// Binds an Int8. - - virtual void bind(std::size_t pos, const Poco::UInt8& val, Direction dir); - /// Binds an UInt8. - - virtual void bind(std::size_t pos, const Poco::Int16& val, Direction dir); - /// Binds an Int16. - - virtual void bind(std::size_t pos, const Poco::UInt16& val, Direction dir); - /// Binds an UInt16. - - virtual void bind(std::size_t pos, const Poco::Int32& val, Direction dir); - /// Binds an Int32. - - virtual void bind(std::size_t pos, const Poco::UInt32& val, Direction dir); - /// Binds an UInt32. - - virtual void bind(std::size_t pos, const Poco::Int64& val, Direction dir); - /// Binds an Int64. - - virtual void bind(std::size_t pos, const Poco::UInt64& val, Direction dir); - /// Binds an UInt64. - -#ifndef POCO_LONG_IS_64_BIT - - virtual void bind(std::size_t pos, const long& val, Direction dir = PD_IN); - /// Binds a long. - - virtual void bind(std::size_t pos, const unsigned long& val, Direction dir = PD_IN); - /// Binds an unsigned long. - -#endif // POCO_LONG_IS_64_BIT - - virtual void bind(std::size_t pos, const bool& val, Direction dir); - /// Binds a boolean. - - virtual void bind(std::size_t pos, const float& val, Direction dir); - /// Binds a float. - - virtual void bind(std::size_t pos, const double& val, Direction dir); - /// Binds a double. - - virtual void bind(std::size_t pos, const char& val, Direction dir); - /// Binds a single character. - - virtual void bind(std::size_t pos, const std::string& val, Direction dir); - /// Binds a string. - - virtual void bind(std::size_t pos, const Poco::Data::BLOB& val, Direction dir); - /// Binds a BLOB. - - virtual void bind(std::size_t pos, const Poco::Data::CLOB& val, Direction dir); - /// Binds a CLOB. - - virtual void bind(std::size_t pos, const DateTime& val, Direction dir); - /// Binds a DateTime. - - virtual void bind(std::size_t pos, const Date& val, Direction dir); - /// Binds a Date. - - virtual void bind(std::size_t pos, const Time& val, Direction dir); - /// Binds a Time. - - virtual void bind(std::size_t pos, const NullData& val, Direction dir); - /// Binds a null. - - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::deque& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::list& val, Direction dir = PD_IN); - - virtual void bind(std::size_t pos, const std::vector