diff --git a/.gitignore b/.gitignore index 39affa8f2..59cf60a56 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .vs out CMakeUserPresets.json +.vscode diff --git a/CMakeLists.txt b/CMakeLists.txt index 341ed2de7..3abc8ce7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,11 +271,35 @@ endif() # TODO: Fix these warnings. # -if(MSVC) +# TODO: Also cover linker warnings + +add_config_option(WERROR BOOL ADVANCED DEFAULT OFF + "Turn compile warnings into errors" +) + +# +# Note: If WERROR is enabled we change its value to be the actual compiler +# option to be used on the current platform. That is used for easier +# propagation to external builds. +# +# Note: In more recent cmake there is CMAKE_COMPILE_WARNING_AS_ERROR variable +# but at the moment we can't ensure using that recent cmake. +# + +if(WERROR) + set(WERROR -Werror) +endif() + +if(MSVC OR TOOLSET_MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS) if(CXX_FRONTEND_MSVC) + + if(WERROR) + set(WERROR /WX) # MSVC equivalent of -Werror + endif() + # Disable MSVC unreachable code warnings unless requested. add_compile_options(/wd4702) @@ -283,12 +307,14 @@ if(MSVC) # Seehttps://connect.microsoft.com/VisualStudio/feedback/details/897611/incorrect-warning-of-c4297-for-destructor-with-try-catch-statement add_compile_options(/wd4297) + endif() -endif() +elseif(SUNPRO) + # Note: For simplicity we do not handle WERROR on SunOS -if(SUNPRO) + set(WERROR) add_compile_options( -errtags=yes -erroff=hidevf,wvarhidemem @@ -296,10 +322,26 @@ if(SUNPRO) endif() -if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 12.0) +if(NOT WERROR) + # clear if WERROR was set to something like OFF or FALSE + # message(STATUS "WERROR: cleared") + unset(WERROR CACHE) +else() + # overwrite cache entry with changed value + set(WERROR "${WERROR}" CACHE INTERNAL "WERROR flags" FORCE) +endif() + +# message(STATUS "WERROR: ${WERROR}") +add_compile_options(${WERROR}) + + +if (GCC AND GCC VERSION_GREATER 11) # Silence a warning produced by a regression in GCC 12.0 and newer # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106199 + # Note: The stringop-overflow warnings are shown also during linking phase + # (observed with GCC 14.2) add_compile_options(-Wno-stringop-overflow) + add_link_options(-Wno-stringop-overflow) endif() @@ -380,7 +422,8 @@ if(MAINTAINER_MODE) # (and this is the case for MSVC 2015). # See: http://en.cppreference.com/w/cpp/language/copy_assignment - add_compile_options(/W4 /wd4512 /wd4127) + set_warnings_level(4) + add_compile_options(/wd4512 /wd4127) elseif(SUNPRO) else() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c1d376eb1..1f6990ba2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,33 +9,31 @@ Before reporting a new bug, please check first to see if a similar bug [exists]( Bug reports should be as complete as possible. Please try and include the following: * complete steps to reproduce the issue -* any information about platform and environment that could be specific to the bug +* any information about platform and environment that could be specific to + the bug * Specific version of the product you are using * Specific version of the server being used * C++ code to help reproduce the issue if possible +Please do NOT raise a GitHub Issue to report a security vulnerability. +See SECURITY.md for additional information. + ## Contributing Code -Contributing to this project is easy. You just need to follow these steps. +You need to follow these steps. -* Sign the Oracle Contributor Agreement. You can find instructions for doing that at [OCA Page](https://oca.opensource.oracle.com/) +* Make sure you have a user account at bugs.mysql.com. You'll need to reference + this user account when you submit your OCA (Oracle Contributor Agreement). +* Sign the Oracle Contributor Agreement. You can find instructions for doing + that at [OCA Page](https://oca.opensource.oracle.com/) * Develop your pull request - * Make sure you are aware of the requirements for the project (i.e. don't require C++17 if we are supporting C++11 and higher) -* Validate your pull request by including tests that sufficiently cover the functionality -* Verify that the entire test suite passes with your code applied +* Make sure you are aware of the requirements for the project (i.e. don't + require C++20 if we are supporting C++17 and higher) +* Validate your pull request by including tests that sufficiently cover + the functionality * Submit your pull request +* It is also possible to upload your changes using the 'contribution' tab to + a bug record in https://bugs.mysql.com. -## Running Tests - -Any contributed code should pass our unit tests. -To run the unit tests you need to perform the following steps: - -* Build the Connector/C++ with the cmake option enabling unit tests (-DWITH_TESTS=1) -* Run MySQL Server -* Set the following environment variables: - * XPLUGIN_PORT = - * XLPIGIN_USER = - * XPLUGIN_PASSWORD = -* In the OS command line enter the Connector/C++ build directory and run `ctest` utility - -At the end of `ctest` run the result should indicate 100% tests passed. +Only pull requests from committers that can be verified as having signed the OCA +can be accepted. diff --git a/LICENSE.txt b/LICENSE.txt index a584cb44f..8256a84c6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ Licensing Information User Manual -MySQL Connector/C++ 9.0.0 Community +MySQL Connector/C++ 9.3.0 Community __________________________________________________________________ Introduction @@ -8,18 +8,18 @@ Introduction This License Information User Manual contains Oracle's product license and other licensing information, including licensing information for third-party software which may be included in this distribution of - MySQL Connector/C++ 9.0.0 Community. + MySQL Connector/C++ 9.3.0 Community. - Last updated: May 2024 + Last updated: March 2025 Licensing Information - This release of MySQL Connector/C++ 9.0.0 Community is brought to you + This release of MySQL Connector/C++ 9.3.0 Community is brought to you by the MySQL team at Oracle. This software is released under version 2 of the GNU General Public License (GPLv2), as set forth below, with the following additional permissions: - This distribution of MySQL Connector/C++ 9.0.0 Community is designed to + This distribution of MySQL Connector/C++ 9.3.0 Community is designed to work with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in the license documentation. Without limiting your rights @@ -34,7 +34,7 @@ Licensing Information a copy of which is reproduced below and can also be found along with its FAQ at http://oss.oracle.com/licenses/universal-foss-exception. - Copyright (c) 2008, 2024, Oracle and/or its affiliates. + Copyright (c) 2008, 2025, Oracle and/or its affiliates. Election of GPLv2 @@ -570,6 +570,15 @@ documentation and/or software. Google Protocol Buffers +You may be receiving a copy of abseil-cpp as part of this product in object code + form. +The terms of the Oracle license do NOT apply to abseil-cpp. +abseil-cpp is licensed under the Apache 2.0 license, separate from the Oracle pr +oduct. +If you do not wish to install this library, you may remove it, but the Oracle pr +ogram +might not operate properly or at all without it. + Copyright 2008 Google Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -637,7 +646,14 @@ in the 'Standard Licenses' section. Kerberos5 -Kerberos5 +You may be receiving a copy of the kerberos documentation as part of this +product. The terms of the Oracle license do NOT apply to Kerberos documentation. + +Kerberos documentation is licensed under the CC-BY-SA 3.0 license, separate from + +the Oracle product. +If you do not wish to install this library, you may remove it, but +the Oracle program might not operate properly or at all without it. Copyright (C) 1985-2019 by the Massachusetts Institute of Technology. @@ -2126,49 +2142,20 @@ but the Oracle program might not operate properly or at all without it. // SPDX-License-Identifier: Apache-2.0 LICENSE: - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ -A copy of the Apache License v2.0, January 2004 license can be found -in the 'Standard Licenses' section. - - -4th party code included -======================= -exporters/etw -------------- -TraceLogging Dynamic for Windows - -Copyright (c) Microsoft Corporation. All rights reserved. -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ +A copy of the Apache License v2.0, January 2004 license can be found +in the 'Standard Licenses' section. -4th Party Libraries -=================== +4th Party Dependencies +====================== opentelemetry-proto ------------------- // Copyright 2019, OpenTelemetry Authors -// Copyright 2020, OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -2182,48 +2169,75 @@ opentelemetry-proto // See the License for the specific language governing permissions and // limitations under the License. -Apache License Text as listed above +Some files include +// Copyright 2020, OpenTelemetry Authors +(same license header) + +A copy of the Apache License v2.0, January 2004 license can be found +in the 'Standard Licenses' section. + +================================================================================ +== ------------------------------------------------------------------------------- protobuf -------- +COPYRIGHT AND PERMISSION NOTICE -Copyright 2008 Google Inc. All rights reserved. +Copyright (c) 1996 - 2024, Daniel Stenberg, , and many +contributors, see the THANKS file. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +All rights reserved. - * 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. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. -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. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. -Code generated by the Protocol Buffer compiler is owned by the owner -of the input file used when generating it. This code is not -standalone and requires a support library to be linked with it. This -support library is itself covered by the above license. +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. + +Protobuf dependency - abseil-cpp +-------------------------------- +=== Header in source files: +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// This header file contains C++11 versions of standard header +// abstractions available within C++14 and C++17, and are designed to be drop-in +// replacement for code compliant with C++14 and C++17. + +=== License File + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +A copy of the Apache License v2.0, January 2004 license can be found +in the 'Standard Licenses' section. +================================================================================ +== ------------------------------------------------------------------------------- json (nlohmann) ---- + MIT License Copyright (c) 2013-2022 Niels Lohmann @@ -2246,14 +2260,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- - +================================================================================ +== curl ---- COPYRIGHT AND PERMISSION NOTICE -Copyright (c) 1996 - 2023, Daniel Stenberg, , and many +Copyright (c) 1996 - 2024, Daniel Stenberg, , and many contributors, see the THANKS file. All rights reserved. diff --git a/README.txt b/README.txt index ffdc35cbe..d8d6abc47 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -Copyright (c) 2008, 2024, Oracle and/or its affiliates. +Copyright (c) 2008, 2025, Oracle and/or its affiliates. This is a release of MySQL Connector/C++, the C++ interface for communicating with MySQL servers. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..5066c11c7 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,29 @@ +# Reporting security vulnerabilities + +Oracle values the independent security research community and believes that +responsible disclosure of security vulnerabilities helps us ensure the security +and privacy of all our users. + +Please do NOT raise a GitHub Issue to report a security vulnerability. If you +believe you have found a security vulnerability, please submit a report to +secalert_us@oracle.com preferably with a proof of concept. Please review +some [additional information](https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html) +on how to report security vulnerabilities to Oracle. We encourage people who +contact Oracle Security to use email encryption using our [encryption key](https://www.oracle.com/security-alerts/encryptionkey.html). + +We ask that you do not use other channels or contact the project maintainers +directly. + +## Security updates, alerts and bulletins + +Security updates will be released on a regular cadence. Many of our projects +will typically release security fixes in conjunction with the Oracle Critical Patch +Update program. Additional information, including past advisories, is available +on our [security alerts page](https://www.oracle.com/security-alerts/). + +## Security-related information + +We will provide security related information such as a threat model, considerations +for secure use, or any known security issues in our documentation. Please note +that labs and sample code are intended to demonstrate a concept and may not be +sufficiently hardened for production use. diff --git a/buildinfo.cmake b/buildinfo.cmake index db73ce5bf..7a791671f 100644 --- a/buildinfo.cmake +++ b/buildinfo.cmake @@ -42,10 +42,10 @@ function(generate_cmake_config) ) install( - FILES + FILES "${CMAKE_BINARY_DIR}/mysql-concpp${suffix}.cmake" DESTINATION . - COMPONENT Readme + COMPONENT DevCommon ) endforeach() diff --git a/cdk/CMakeLists.txt b/cdk/CMakeLists.txt index dc8e3adc6..1e0fb41a7 100644 --- a/cdk/CMakeLists.txt +++ b/cdk/CMakeLists.txt @@ -28,9 +28,9 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.15) -cmake_policy(VERSION 3.0) +cmake_policy(VERSION 3.15) if(POLICY CMP0022) cmake_policy(SET CMP0022 NEW) # consistently use INTERFACE_LINK_LIBRARIES property @@ -150,7 +150,7 @@ IF(MSVC) # TODO: move to /Wall when code base is ready for this - add_compile_options(/W4) + set_warnings_level(4) # Note: We disable warnings related to C++11 language because we want this # to be pure C++ code. diff --git a/cdk/cmake/DepFindProtobuf.cmake b/cdk/cmake/DepFindProtobuf.cmake index 1fc785e31..6e020fc87 100644 --- a/cdk/cmake/DepFindProtobuf.cmake +++ b/cdk/cmake/DepFindProtobuf.cmake @@ -115,7 +115,7 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS) ELSEIF(MSVC) set_source_files_properties(${srcs} APPEND_STRING PROPERTY COMPILE_FLAGS - "/W1 /wd4018 /wd4996 /wd4244 /wd4267" + "/wd4018 /wd4996 /wd4244 /wd4267" ) ENDIF() diff --git a/cdk/cmake/compiler/MSVC.cmake b/cdk/cmake/compiler/MSVC.cmake index 5a6d3d80d..71e8e10c6 100644 --- a/cdk/cmake/compiler/MSVC.cmake +++ b/cdk/cmake/compiler/MSVC.cmake @@ -89,6 +89,16 @@ function(set_visibility) endfunction() +function(set_warnings_level N) + + # Note: The /Wn flag must be set only once, otherwise msvc shows warnings + + string(REGEX REPLACE "/W[123456789]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W${N}") + +endfunction() + + function(set_msvcrt TYPE) if(TYPE MATCHES "^(STATIC|Static|static)$") diff --git a/cdk/cmake/dependency.cmake b/cdk/cmake/dependency.cmake index e3fec4ee2..1f4410329 100644 --- a/cdk/cmake/dependency.cmake +++ b/cdk/cmake/dependency.cmake @@ -60,6 +60,7 @@ set(EXT_FWD CMAKE_SYSTEM_PROCESSOR CMAKE_C_COMPILER CMAKE_CXX_COMPILER MSVC + WERROR ) set(EXT_DIR ${CMAKE_CURRENT_LIST_DIR}/ext CACHE INTERNAL "external project utils location") @@ -129,7 +130,7 @@ function(add_ext NAME HEADER) "${EXT_LIB} library name" ) - + #show_config_options() # Handle non-path value of WITH_X option diff --git a/cdk/cmake/gtest.cmake b/cdk/cmake/gtest.cmake index 3a79ad3a3..3e53ba29a 100644 --- a/cdk/cmake/gtest.cmake +++ b/cdk/cmake/gtest.cmake @@ -32,9 +32,6 @@ # Set up gtest for use by targets in given folder and its sub-folders. # MACRO(SETUP_GTEST) - IF (WITH_GTEST) - INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS}) - ENDIF (WITH_GTEST) ENDMACRO(SETUP_GTEST) @@ -135,6 +132,14 @@ MESSAGE("gtest_main location: ${gtest_main_location}") add_library(gtest STATIC IMPORTED) add_library(gtest_main STATIC IMPORTED) +target_include_directories(gtest INTERFACE ${GTEST_INCLUDE_DIRS}) + +# See: https://stackoverflow.com/questions/42847103/stdtr1-with-visual-studio-2017 + +target_compile_definitions(gtest INTERFACE + -DGTEST_LANG_CXX11=1 +) + set_target_properties(gtest PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_LOCATION "${gtest_location}" diff --git a/cdk/cmake/platform.cmake b/cdk/cmake/platform.cmake index e76a45e7c..fc3fe6c00 100644 --- a/cdk/cmake/platform.cmake +++ b/cdk/cmake/platform.cmake @@ -115,6 +115,17 @@ macro(add_flags LANG) set(CMAKE_${LANG}_FLAGS "${CMAKE_${LANG}_FLAGS}" PARENT_SCOPE) endmacro() +include(CheckCXXCompilerFlag) + +# Set single compiler flag only if it is supported, ignore otherwise + +macro(set_compiler_flag FLAG) + unset(flag_supported CACHE) + CHECK_CXX_COMPILER_FLAG(${FLAG} flag_supported) + if(flag_supported) + add_compile_options(${FLAG}) + endif() +endmacro() # ----------------------------------------------------------------- diff --git a/cdk/cmake/testing.cmake b/cdk/cmake/testing.cmake index bfdc8d92c..662fba98d 100644 --- a/cdk/cmake/testing.cmake +++ b/cdk/cmake/testing.cmake @@ -144,6 +144,7 @@ IF(WITH_TESTS) set_global(test_tests ${test_tests}) add_library(${TEST} OBJECT ${ARGN}) + target_link_libraries(${TEST} gtest) set_target_properties(${TEST} PROPERTIES FOLDER "Tests") target_include_directories(${TEST} PRIVATE ${test_includes}) @@ -153,12 +154,11 @@ IF(WITH_TESTS) if (MSVC) target_compile_definitions(${TEST} PRIVATE + -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING ) target_compile_options(${TEST} PRIVATE - /W3 /wd4244 /wd4267 /wd4701 @@ -166,8 +166,6 @@ IF(WITH_TESTS) /wd4456 # declaration of hides previous local declaration ) - target_compile_options(${TEST} PUBLIC /std:c++14) - if(STATIC_TESTS_MSVCRT) target_compile_options(${TEST} PRIVATE $<$:/MTd> @@ -295,10 +293,7 @@ IF(WITH_TESTS) if (MSVC) - target_compile_definitions(${target_run_unit_tests} PRIVATE - -D_SCL_SECURE_NO_WARNINGS - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) + set_warnings_level(3) target_compile_options(${target_run_unit_tests} PRIVATE /wd4244 diff --git a/cdk/core/session.cc b/cdk/core/session.cc index 7a00cc1fe..feb642e8e 100644 --- a/cdk/core/session.cc +++ b/cdk/core/session.cc @@ -53,7 +53,7 @@ struct Session_builder struct ReportStatus { - //False if not able to connect, true if all is good. + // False if not able to connect, true if all is good. option_t m_status = false; Session_builder::ep_filter_t m_filter; size_t m_id; @@ -63,6 +63,12 @@ struct Session_builder , m_id(id) {} + /* + Note: The only reason for ReportStatus object is to use RAII to invoke + m_filter() on destruction to report session creation status. So this + is part of logic of methods that use such object and as such is allowed + to throw errors from the dtor. + */ ~ReportStatus() { @@ -481,7 +487,7 @@ Session::Session(ds::Unix_socket &ds, const ds::Unix_socket::Options &options) #endif //#ifndef WIN32 -Session::~Session() +Session::~Session() NOEXCEPT { delete m_session; delete m_connection; diff --git a/cdk/extra/lz4/CMakeLists.txt b/cdk/extra/lz4/CMakeLists.txt index 7e5db8567..ebcf76173 100644 --- a/cdk/extra/lz4/CMakeLists.txt +++ b/cdk/extra/lz4/CMakeLists.txt @@ -34,6 +34,10 @@ include(platform) enable_pic() +if(WERROR) + add_compile_options(${WERROR}) +endif() + add_library(lz4 STATIC lib/lz4.c lib/lz4frame.c diff --git a/cdk/extra/protobuf/CMakeLists.txt b/cdk/extra/protobuf/CMakeLists.txt index adc19f55d..a787985f5 100644 --- a/cdk/extra/protobuf/CMakeLists.txt +++ b/cdk/extra/protobuf/CMakeLists.txt @@ -73,6 +73,10 @@ SET(PROTO_SRC_DIR "${PROJECT_SOURCE_DIR}/protobuf-3.19.6") enable_pic() enable_cxx17() +if(WERROR) + add_compile_options(${WERROR}) +endif() + # -O3 using GCC on SPARC leds to segfault on protoc if(SPARC AND GCC) foreach(LANG C CXX) @@ -90,12 +94,22 @@ endif() set_visibility(hidden) -if(NOT TOOLSET_MSVC AND NOT APPLE) - add_compile_options(-Wno-stringop-overflow -Wno-stringop-overread) +if(GCC AND GCC VERSION_GREATER 11) + # See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106199 + set_compiler_flag(-Wno-stringop-overflow) + set_compiler_flag(-Wno-stringop-overread) +endif() + +if(NOT MSVC OR CLANG) + set_compiler_flag(-Wno-unused-const-variable) +endif() + +if(WIN32) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) endif() if(APPLE) - add_compile_options(-Wno-deprecated-declarations) + set_compiler_flag(-Wno-deprecated-declarations) endif() diff --git a/cdk/extra/zlib/CMakeLists.txt b/cdk/extra/zlib/CMakeLists.txt index a93b25f35..2c6928d25 100644 --- a/cdk/extra/zlib/CMakeLists.txt +++ b/cdk/extra/zlib/CMakeLists.txt @@ -1,51 +1,52 @@ -# Copyright (c) 2006, 2024, Oracle and/or its affiliates. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License, version 2.0, -# as published by the Free Software Foundation. -# -# This program is designed to work with certain software (including -# but not limited to OpenSSL) that is licensed under separate terms, as -# designated in a particular file or component or in included license -# documentation. The authors of MySQL hereby grant you an additional -# permission to link the program and your derivative works with the -# separately licensed software that they have either included with -# the program or referenced in the documentation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License, version 2.0, for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -cmake_minimum_required(VERSION 2.4.4) +cmake_minimum_required(VERSION 3.5) +cmake_policy(SET CMP0048 NEW) # allow VERSION specification in project() set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) -set(VERSION "1.2.13") - -IF(POLICY CMP0048) - CMAKE_POLICY(SET CMP0048 NEW) - project(zlib VERSION ${VERSION} LANGUAGES C) -ELSE() - project(zlib C) -ENDIF() +# project(zlib C) -IF(POLICY CMP0075) - CMAKE_POLICY(SET CMP0075 OLD) -ENDIF() +set(VERSION "1.3.1") +project(zlib VERSION ${VERSION} LANGUAGES C) include(../setup.cmake) include(platform) enable_pic() +if(WERROR) + add_compile_options(${WERROR}) +endif() + +if(WIN32) + + add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + + # warning triggered by one of the sources: + # The POSIX name for this item is deprecated. Instead, use the ISO C and C++ + # conformant name: _open. See online help for details. + + if(CLANG) + add_compile_options(-Wno-deprecated-declarations) + else() + add_compile_options(/wd4996) + endif() + +endif() + +option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" OFF) + +IF(DISABLE_THESE_LINES) +set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") +set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") +set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") +set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") +set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") +ENDIF(DISABLE_THESE_LINES) + include(CheckTypeSize) include(CheckFunctionExists) include(CheckIncludeFile) include(CheckCSourceCompiles) +# enable_testing() check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(stdint.h HAVE_STDINT_H) @@ -86,13 +87,40 @@ endif() # check_include_file(unistd.h Z_HAVE_UNISTD_H) +IF(DISABLE_THESE_LINES) +if(MSVC) + set(CMAKE_DEBUG_POSTFIX "d") + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +endif() + +if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) + # If we're doing an out of source build and the user has a zconf.h + # in their source tree... + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) + message(STATUS "Renaming") + message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h") + message(STATUS "to 'zconf.h.included' because this file is included with zlib") + message(STATUS "but CMake generates it automatically in the build directory.") + file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included) + endif() +endif() + +set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc) +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein + ${ZLIB_PC} @ONLY) +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein + ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) +ENDIF(DISABLE_THESE_LINES) -configure_file( +CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY ) -include_directories( - SYSTEM ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} +INCLUDE_DIRECTORIES( + BEFORE SYSTEM ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) @@ -144,40 +172,44 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) -# ------------------------------------------------------------------------- -# Disable compile warnings +add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -if(MSVC) +target_include_directories(zlib PUBLIC + ${PROJECT_BINARY_DIR} + ${PROJECT_SOURCE_DIR} +) - add_compile_options( - /wd4996 - /wd4267 - /wd4131 # old style declarator - /wd4127 # conditional expression is constant - /wd4244 # possible loss of data during conversion - /wd4245 # signed/unsigned missmatch - ) +set_target_properties(zlib PROPERTIES FOLDER "Misc") -endif() +export(TARGETS zlib NAMESPACE ext_ FILE ${PROJECT_BINARY_DIR}/exports.cmake) -if (APPLE) - # Disable warning for zlib 1.2.13. - # In zlib version 1.3 this problem should be fixed: - # https://github.com/madler/zlib/issues/633 - add_compile_options(-Wno-deprecated-non-prototype) -endif() +RETURN() -# ------------------------------------------------------------------------- +# Skip anything below. +################################################################ -ADD_LIBRARY(zlib STATIC - ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +if(MINGW) + # This gets us DLL resource information when compiling on MinGW. + if(NOT CMAKE_RC_COMPILER) + set(CMAKE_RC_COMPILER windres.exe) + endif() -target_include_directories(zlib PUBLIC - ${PROJECT_BINARY_DIR} - ${PROJECT_SOURCE_DIR} -) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj + COMMAND ${CMAKE_RC_COMPILER} + -D GCC_WINDRES + -I ${CMAKE_CURRENT_SOURCE_DIR} + -I ${CMAKE_CURRENT_BINARY_DIR} + -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj + -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) + set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) +endif(MINGW) -set_target_properties(zlib PROPERTIES FOLDER "Misc") +add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) +set_target_properties(zlib PROPERTIES SOVERSION 1) if(NOT CYGWIN) # This property causes shared libraries on Linux to have the full version @@ -190,18 +222,52 @@ if(NOT CYGWIN) set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) endif() -if(CMAKE_SYSTEM_NAME MATCHES "SunOS") +if(UNIX) # On unix-like platforms the library is almost always called libz - set_target_properties(zlib PROPERTIES OUTPUT_NAME z) -elseif(UNIX) - # On unix-like platforms the library is almost always called libz - set_target_properties(zlib PROPERTIES OUTPUT_NAME z) - if(NOT APPLE) + set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) + if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX)) set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") endif() +elseif(BUILD_SHARED_LIBS AND WIN32) + # Creates zlib1.dll when building shared library version + set_target_properties(zlib PROPERTIES SUFFIX "1.dll") endif() -#ADD_EXECUTABLE(try_zlib try.cc) -#TARGET_LINK_LIBRARIES(try_zlib zlib) +if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) + install(TARGETS zlib zlibstatic + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" + ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) +endif() +if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) + install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}") +endif() +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3") +endif() +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") +endif() -export(TARGETS zlib NAMESPACE ext_ FILE ${PROJECT_BINARY_DIR}/exports.cmake) +#============================================================================ +# Example binaries +#============================================================================ +if(ZLIB_BUILD_EXAMPLES) + add_executable(example test/example.c) + target_link_libraries(example zlib) + add_test(example example) + + add_executable(minigzip test/minigzip.c) + target_link_libraries(minigzip zlib) + + if(HAVE_OFF64_T) + add_executable(example64 test/example.c) + target_link_libraries(example64 zlib) + set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") + add_test(example64 example64) + + add_executable(minigzip64 test/minigzip.c) + target_link_libraries(minigzip64 zlib) + set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") + endif() +endif() diff --git a/cdk/extra/zlib/ChangeLog b/cdk/extra/zlib/ChangeLog index 457526bc6..b801a1031 100644 --- a/cdk/extra/zlib/ChangeLog +++ b/cdk/extra/zlib/ChangeLog @@ -1,6 +1,34 @@ ChangeLog file for zlib +Changes in 1.3.1 (22 Jan 2024) +- Reject overflows of zip header fields in minizip +- Fix bug in inflateSync() for data held in bit buffer +- Add LIT_MEM define to use more memory for a small deflate speedup +- Fix decision on the emission of Zip64 end records in minizip +- Add bounds checking to ERR_MSG() macro, used by zError() +- Neutralize zip file traversal attacks in miniunz +- Fix a bug in ZLIB_DEBUG compiles in check_match() +- Various portability and appearance improvements + +Changes in 1.3 (18 Aug 2023) +- Remove K&R function definitions and zlib2ansi +- Fix bug in deflateBound() for level 0 and memLevel 9 +- Fix bug when gzungetc() is used immediately after gzopen() +- Fix bug when using gzflush() with a very small buffer +- Fix crash when gzsetparams() attempted for transparent write +- Fix test/example.c to work with FORCE_STORED +- Rewrite of zran in examples (see zran.c version history) +- Fix minizip to allow it to open an empty zip file +- Fix reading disk number start on zip64 files in minizip +- Fix logic error in minizip argument processing +- Add minizip testing to Makefile +- Read multiple bytes instead of byte-by-byte in minizip unzip.c +- Add memory sanitizer to configure (--memory) +- Various portability improvements +- Various documentation improvements +- Various spelling and typo corrections + Changes in 1.2.13 (13 Oct 2022) - Fix configure issue that discarded provided CC definition - Correct incorrect inputs provided to the CRC functions @@ -1445,7 +1473,7 @@ Changes in 0.99 (27 Jan 96) - fix typo in Make_vms.com (f$trnlnm -> f$getsyi) - in fcalloc, normalize pointer if size > 65520 bytes - don't use special fcalloc for 32 bit Borland C++ -- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... +- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc. - use Z_BINARY instead of BINARY - document that gzclose after gzdopen will close the file - allow "a" as mode in gzopen diff --git a/cdk/extra/zlib/FAQ b/cdk/extra/zlib/FAQ index 99b7cf92e..92f5d3e29 100644 --- a/cdk/extra/zlib/FAQ +++ b/cdk/extra/zlib/FAQ @@ -4,7 +4,7 @@ If your question is not there, please check the zlib home page http://zlib.net/ which may have more recent information. -The lastest zlib FAQ is at http://zlib.net/zlib_faq.html +The latest zlib FAQ is at http://zlib.net/zlib_faq.html 1. Is zlib Y2K-compliant? @@ -14,8 +14,7 @@ The lastest zlib FAQ is at http://zlib.net/zlib_faq.html 2. Where can I get a Windows DLL version? The zlib sources can be compiled without change to produce a DLL. See the - file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the - precompiled DLL are found in the zlib web site at http://zlib.net/ . + file win32/DLL_FAQ.txt in the zlib distribution. 3. Where can I get a Visual Basic interface to zlib? diff --git a/cdk/extra/zlib/Makefile.in b/cdk/extra/zlib/Makefile.in index 7d2713f4c..cb8b00a9b 100644 --- a/cdk/extra/zlib/Makefile.in +++ b/cdk/extra/zlib/Makefile.in @@ -1,5 +1,5 @@ # Makefile for zlib -# Copyright (C) 1995-2017 Jean-loup Gailly, Mark Adler +# Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler # For conditions of distribution and use, see copyright notice in zlib.h # To compile and test, type: @@ -22,13 +22,13 @@ CFLAGS=-O SFLAGS=-O LDFLAGS= -TEST_LDFLAGS=$(LDFLAGS) -L. libz.a +TEST_LIBS=-L. libz.a LDSHARED=$(CC) CPP=$(CC) -E STATICLIB=libz.a SHAREDLIB=libz.so -SHAREDLIBV=libz.so.1.2.13 +SHAREDLIBV=libz.so.1.3.1 SHAREDLIBM=libz.so.1 LIBS=$(STATICLIB) $(SHAREDLIBV) @@ -282,10 +282,10 @@ placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a -@rmdir objs example$(EXE): example.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(TEST_LIBS) minigzip$(EXE): minigzip.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(TEST_LIBS) examplesh$(EXE): example.o $(SHAREDLIBV) $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) -L. $(SHAREDLIBV) @@ -294,10 +294,10 @@ minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) -L. $(SHAREDLIBV) example64$(EXE): example64.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ example64.o $(TEST_LIBS) minigzip64$(EXE): minigzip64.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip64.o $(TEST_LIBS) install-libs: $(LIBS) -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi @@ -359,8 +359,14 @@ zconf.h.cmakein: $(SRCDIR)zconf.h.in zconf: $(SRCDIR)zconf.h.in cp -p $(SRCDIR)zconf.h.in zconf.h +minizip-test: static + cd contrib/minizip && { CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; } + +minizip-clean: + cd contrib/minizip && { $(MAKE) clean ; cd ../.. ; } + mostlyclean: clean -clean: +clean: minizip-clean rm -f *.o *.lo *~ \ example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ example64$(EXE) minigzip64$(EXE) \ diff --git a/cdk/extra/zlib/README b/cdk/extra/zlib/README index ba34d1894..c5f917540 100644 --- a/cdk/extra/zlib/README +++ b/cdk/extra/zlib/README @@ -1,6 +1,6 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.2.13 is a general purpose data compression library. All the code is +zlib 1.3.1 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and @@ -29,18 +29,17 @@ PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. Mark Nelson wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at -http://marknelson.us/1997/01/01/zlib-engine/ . +https://marknelson.us/posts/1997/01/01/zlib-engine.html . -The changes made in version 1.2.13 are documented in the file ChangeLog. +The changes made in version 1.3.1 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . -zlib is available in Java using the java.util.zip package, documented at -http://java.sun.com/developer/technicalArticles/Programming/compression/ . +zlib is available in Java using the java.util.zip package. Follow the API +Documentation link at: https://docs.oracle.com/search/?q=java.util.zip . -A Perl interface to zlib written by Paul Marquess is available -at CPAN (Comprehensive Perl Archive Network) sites, including -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . +A Perl interface to zlib and bzip2 written by Paul Marquess +can be found at https://github.com/pmqs/IO-Compress . A Python interface to zlib written by A.M. Kuchling is available in Python 1.5 and later versions, see @@ -64,7 +63,7 @@ Notes for some targets: - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works when compiled with cc. -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is +- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is necessary to get gzprintf working correctly. This is done by configure. - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with @@ -84,7 +83,7 @@ Acknowledgments: Copyright notice: - (C) 1995-2022 Jean-loup Gailly and Mark Adler + (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/cdk/extra/zlib/adler32.c b/cdk/extra/zlib/adler32.c index d0be4380a..04b81d29b 100644 --- a/cdk/extra/zlib/adler32.c +++ b/cdk/extra/zlib/adler32.c @@ -7,8 +7,6 @@ #include "zutil.h" -local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); - #define BASE 65521U /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ @@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); #endif /* ========================================================================= */ -uLong ZEXPORT adler32_z(adler, buf, len) - uLong adler; - const Bytef *buf; - z_size_t len; -{ +uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) { unsigned long sum2; unsigned n; @@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z(adler, buf, len) } /* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) { return adler32_z(adler, buf, len); } /* ========================================================================= */ -local uLong adler32_combine_(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) { unsigned long sum1; unsigned long sum2; unsigned rem; @@ -169,18 +155,10 @@ local uLong adler32_combine_(adler1, adler2, len2) } /* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ +uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) { return adler32_combine_(adler1, adler2, len2); } -uLong ZEXPORT adler32_combine64(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ +uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) { return adler32_combine_(adler1, adler2, len2); } diff --git a/cdk/extra/zlib/compress.c b/cdk/extra/zlib/compress.c index 2ad5326c1..f43bacf7a 100644 --- a/cdk/extra/zlib/compress.c +++ b/cdk/extra/zlib/compress.c @@ -19,13 +19,8 @@ memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ -int ZEXPORT compress2(dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ +int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen, int level) { z_stream stream; int err; const uInt max = (uInt)-1; @@ -65,12 +60,8 @@ int ZEXPORT compress2(dest, destLen, source, sourceLen, level) /* =========================================================================== */ -int ZEXPORT compress(dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ +int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen) { return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); } @@ -78,9 +69,7 @@ int ZEXPORT compress(dest, destLen, source, sourceLen) If the default memLevel or windowBits for deflateInit() is changed, then this function needs to be updated. */ -uLong ZEXPORT compressBound(sourceLen) - uLong sourceLen; -{ +uLong ZEXPORT compressBound(uLong sourceLen) { return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13; } diff --git a/cdk/extra/zlib/configure b/cdk/extra/zlib/configure new file mode 100644 index 000000000..c55098afc --- /dev/null +++ b/cdk/extra/zlib/configure @@ -0,0 +1,929 @@ +#!/bin/sh +# configure script for zlib. +# +# Normally configure builds both a static and a shared library. +# If you want to build just a static library, use: ./configure --static +# +# To impose specific compiler or flags or install directory, use for example: +# prefix=$HOME CC=cc CFLAGS="-O4" ./configure +# or for csh/tcsh users: +# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure) + +# Incorrect settings of CC or CFLAGS may prevent creating a shared library. +# If you have problems, try without defining CC and CFLAGS before reporting +# an error. + +# start off configure.log +echo -------------------- >> configure.log +echo $0 $* >> configure.log +date >> configure.log + +# get source directory +SRCDIR=`dirname $0` +if test $SRCDIR = "."; then + ZINC="" + ZINCOUT="-I." + SRCDIR="" +else + ZINC='-I. -include zconf.h' + ZINCOUT='-I. -I$(SRCDIR)' + SRCDIR="$SRCDIR/" +fi + +# set command prefix for cross-compilation +if [ -n "${CHOST}" ]; then + uname=${CHOST} + mname=${CHOST} + CROSS_PREFIX="${CHOST}-" +else + mname=`(uname -a || echo unknown) 2>/dev/null` +fi + +# destination name for static library +STATICLIB=libz.a + +# extract zlib version numbers from zlib.h +VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h` +VER3=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\(\\.[0-9]\{1,\}\)\{1,2\}\).*/\1/p'` +VER1=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\)\\..*/\1/p'` + +# establish commands for library building +if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then + AR=${AR-"${CROSS_PREFIX}ar"} + test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log +else + AR=${AR-"ar"} + test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log +fi +ARFLAGS=${ARFLAGS-"rc"} +if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then + RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"} + test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log +else + RANLIB=${RANLIB-"ranlib"} +fi +if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then + NM=${NM-"${CROSS_PREFIX}nm"} + test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log +else + NM=${NM-"nm"} +fi + +# set defaults before processing command line options +LDCONFIG=${LDCONFIG-"ldconfig"} +LDSHAREDLIBC="${LDSHAREDLIBC--lc}" +ARCHS= +prefix=${prefix-/usr/local} +exec_prefix=${exec_prefix-'${prefix}'} +libdir=${libdir-'${exec_prefix}/lib'} +sharedlibdir=${sharedlibdir-'${libdir}'} +includedir=${includedir-'${prefix}/include'} +mandir=${mandir-'${prefix}/share/man'} +shared_ext='.so' +shared=1 +solo=0 +cover=0 +zprefix=0 +zconst=0 +build64=0 +gcc=0 +warn=0 +debug=0 +address=0 +memory=0 +old_cc="$CC" +old_cflags="$CFLAGS" +OBJC='$(OBJZ) $(OBJG)' +PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' + +# leave this script, optionally in a bad way +leave() +{ + if test "$*" != "0"; then + echo "** $0 aborting." | tee -a configure.log + fi + rm -rf $test.[co] $test $test$shared_ext $test.gcno $test.dSYM ./--version + echo -------------------- >> configure.log + echo >> configure.log + echo >> configure.log + exit $1 +} + +# process command line options +while test $# -ge 1 +do +case "$1" in + -h* | --help) + echo 'usage:' | tee -a configure.log + echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log + echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log + echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log + exit 0 ;; + -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;; + -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;; + -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;; + --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;; + -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;; + -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;; + -p* | --prefix) prefix="$2"; shift; shift ;; + -e* | --eprefix) exec_prefix="$2"; shift; shift ;; + -l* | --libdir) libdir="$2"; shift; shift ;; + -i* | --includedir) includedir="$2"; shift; shift ;; + -s* | --shared | --enable-shared) shared=1; shift ;; + -t | --static) shared=0; shift ;; + --solo) solo=1; shift ;; + --cover) cover=1; shift ;; + -z* | --zprefix) zprefix=1; shift ;; + -6* | --64) build64=1; shift ;; + -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;; + --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;; + --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;; + -c* | --const) zconst=1; shift ;; + -w* | --warn) warn=1; shift ;; + -d* | --debug) debug=1; shift ;; + --sanitize) address=1; shift ;; + --address) address=1; shift ;; + --memory) memory=1; shift ;; + *) + echo "unknown option: $1" | tee -a configure.log + echo "$0 --help for help" | tee -a configure.log + leave 1;; + esac +done + +# temporary file name +test=ztest$$ + +# put arguments in log, also put test file in log if used in arguments +show() +{ + case "$*" in + *$test.c*) + echo === $test.c === >> configure.log + cat $test.c >> configure.log + echo === >> configure.log;; + esac + echo $* >> configure.log +} + +# check for gcc vs. cc and set compile and link flags based on the system identified by uname +cat > $test.c </dev/null 2>&1; then + cc=${CROSS_PREFIX}gcc + else + cc=${CROSS_PREFIX}cc + fi +else + cc=${CC} +fi + +case "$cc" in + *gcc*) gcc=1 ;; + *clang*) gcc=1 ;; +esac +case `$cc -v 2>&1` in + *gcc*) gcc=1 ;; + *clang*) gcc=1 ;; +esac + +show $cc -c $test.c +if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then + echo ... using gcc >> configure.log + CC="$cc" + CFLAGS="${CFLAGS--O3}" + SFLAGS="${CFLAGS--O3} -fPIC" + if test "$ARCHS"; then + CFLAGS="${CFLAGS} ${ARCHS}" + LDFLAGS="${LDFLAGS} ${ARCHS}" + fi + if test $build64 -eq 1; then + CFLAGS="${CFLAGS} -m64" + SFLAGS="${SFLAGS} -m64" + fi + if test "$warn" -eq 1; then + if test "$zconst" -eq 1; then + CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST" + else + CFLAGS="${CFLAGS} -Wall -Wextra" + fi + fi + if test $address -eq 1; then + CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer" + fi + if test $memory -eq 1; then + CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer" + fi + if test $debug -eq 1; then + CFLAGS="${CFLAGS} -DZLIB_DEBUG" + SFLAGS="${SFLAGS} -DZLIB_DEBUG" + fi + if test -z "$uname"; then + uname=`(uname -s || echo unknown) 2>/dev/null` + fi + case "$uname" in + Linux* | linux* | *-linux* | GNU | GNU/* | solaris*) + case "$mname" in + *sparc*) + LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;; + esac + LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;; + *BSD | *bsd* | DragonFly) + LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} + LDCONFIG="ldconfig -m" ;; + CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*) + EXE='.exe' ;; + MINGW* | mingw* | *-mingw*) + rm -f $test.[co] $test $test$shared_ext + echo "If this doesn't work for you, try win32/Makefile.gcc." | tee -a configure.log + LDSHARED=${LDSHARED-"$cc -shared"} + LDSHAREDLIBC="" + EXE='.exe' ;; + QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 + # (alain.bonnefoy@icbt.com) + LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;; + HP-UX*) + LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} + case `(uname -m || echo unknown) 2>/dev/null` in + ia64) + shared_ext='.so' + SHAREDLIB='libz.so' ;; + *) + shared_ext='.sl' + SHAREDLIB='libz.sl' ;; + esac ;; + AIX*) + LDFLAGS="${LDFLAGS} -Wl,-brtl" ;; + Darwin* | darwin* | *-darwin*) + shared_ext='.dylib' + SHAREDLIB=libz$shared_ext + SHAREDLIBV=libz.$VER$shared_ext + SHAREDLIBM=libz.$VER1$shared_ext + LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} + if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then + AR="${CROSS_PREFIX}libtool" + elif libtool -V 2>&1 | grep Apple > /dev/null; then + AR="libtool" + else + AR="/usr/bin/libtool" + fi + ARFLAGS="-o" ;; + *) + LDSHARED=${LDSHARED-"$cc -shared"} ;; + esac +else + # find system name and corresponding cc options + CC=${CC-cc} + gcc=0 + echo ... using $CC >> configure.log + if test -z "$uname"; then + uname=`(uname -sr || echo unknown) 2>/dev/null` + fi + case "$uname" in + HP-UX*) SFLAGS=${CFLAGS-"-O +z"} + CFLAGS=${CFLAGS-"-O"} +# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} + LDSHARED=${LDSHARED-"ld -b"} + case `(uname -m || echo unknown) 2>/dev/null` in + ia64) + shared_ext='.so' + SHAREDLIB='libz.so' ;; + *) + shared_ext='.sl' + SHAREDLIB='libz.sl' ;; + esac ;; + IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} + CFLAGS=${CFLAGS-"-ansi -O2"} + LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; + OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"} + CFLAGS=${CFLAGS-"-O -std1"} + LDFLAGS="${LDFLAGS} -Wl,-rpath,." + LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;; + OSF1*) SFLAGS=${CFLAGS-"-O -std1"} + CFLAGS=${CFLAGS-"-O -std1"} + LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; + QNX*) SFLAGS=${CFLAGS-"-4 -O"} + CFLAGS=${CFLAGS-"-4 -O"} + LDSHARED=${LDSHARED-"cc"} + RANLIB=${RANLIB-"true"} + AR="cc" + ARFLAGS="-A" ;; + SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} + CFLAGS=${CFLAGS-"-O3"} + LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;; + SunOS\ 5* | solaris*) + LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"} + SFLAGS=${CFLAGS-"-fast -KPIC"} + CFLAGS=${CFLAGS-"-fast"} + if test $build64 -eq 1; then + # old versions of SunPRO/Workshop/Studio don't support -m64, + # but newer ones do. Check for it. + flag64=`$CC -flags | egrep -- '^-m64'` + if test x"$flag64" != x"" ; then + CFLAGS="${CFLAGS} -m64" + SFLAGS="${SFLAGS} -m64" + else + case `(uname -m || echo unknown) 2>/dev/null` in + i86*) + SFLAGS="$SFLAGS -xarch=amd64" + CFLAGS="$CFLAGS -xarch=amd64" ;; + *) + SFLAGS="$SFLAGS -xarch=v9" + CFLAGS="$CFLAGS -xarch=v9" ;; + esac + fi + fi + if test -n "$ZINC"; then + ZINC='-I- -I. -I$(SRCDIR)' + fi + ;; + SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} + CFLAGS=${CFLAGS-"-O2"} + LDSHARED=${LDSHARED-"ld"} ;; + SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"} + CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"} + LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;; + UNIX_System_V\ 4.2.0) + SFLAGS=${CFLAGS-"-KPIC -O"} + CFLAGS=${CFLAGS-"-O"} + LDSHARED=${LDSHARED-"cc -G"} ;; + UNIX_SV\ 4.2MP) + SFLAGS=${CFLAGS-"-Kconform_pic -O"} + CFLAGS=${CFLAGS-"-O"} + LDSHARED=${LDSHARED-"cc -G"} ;; + OpenUNIX\ 5) + SFLAGS=${CFLAGS-"-KPIC -O"} + CFLAGS=${CFLAGS-"-O"} + LDSHARED=${LDSHARED-"cc -G"} ;; + AIX*) # Courtesy of dbakker@arrayasolutions.com + SFLAGS=${CFLAGS-"-O -qmaxmem=8192"} + CFLAGS=${CFLAGS-"-O -qmaxmem=8192"} + LDSHARED=${LDSHARED-"xlc -G"} ;; + # send working options for other systems to zlib@gzip.org + *) SFLAGS=${CFLAGS-"-O"} + CFLAGS=${CFLAGS-"-O"} + LDSHARED=${LDSHARED-"cc -shared"} ;; + esac +fi + +# destination names for shared library if not defined above +SHAREDLIB=${SHAREDLIB-"libz$shared_ext"} +SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"} +SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"} + +echo >> configure.log + +# define functions for testing compiler and library characteristics and logging the results + +cat > $test.c </dev/null; then + try() + { + show $* + test "`( $* ) 2>&1 | tee -a configure.log`" = "" + } + echo - using any output from compiler to indicate an error >> configure.log +else + try() + { + show $* + got=`( $* ) 2>&1` + ret=$? + if test "$got" != ""; then + printf "%s\n" "$got" >> configure.log + fi + if test $ret -ne 0; then + echo "(exit code "$ret")" >> configure.log + fi + return $ret + } +fi + +tryboth() +{ + show $* + got=`( $* ) 2>&1` + ret=$? + if test "$got" != ""; then + printf "%s\n" "$got" >> configure.log + fi + if test $ret -ne 0; then + echo "(exit code "$ret")" >> configure.log + return $ret + fi + test "$got" = "" +} + +cat > $test.c << EOF +int foo() { return 0; } +EOF +echo "Checking for obsessive-compulsive compiler options..." >> configure.log +if try $CC -c $CFLAGS $test.c; then + : +else + echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log + leave 1 +fi + +echo >> configure.log + +# see if shared library build supported +cat > $test.c <> configure.log + +# check for size_t +cat > $test.c < +#include +size_t dummy = 0; +EOF +if try $CC -c $CFLAGS $test.c; then + echo "Checking for size_t... Yes." | tee -a configure.log +else + echo "Checking for size_t... No." | tee -a configure.log + # find a size_t integer type + # check for long long + cat > $test.c << EOF +long long dummy = 0; +EOF + if try $CC -c $CFLAGS $test.c; then + echo "Checking for long long... Yes." | tee -a configure.log + cat > $test.c < +int main(void) { + if (sizeof(void *) <= sizeof(int)) puts("int"); + else if (sizeof(void *) <= sizeof(long)) puts("long"); + else puts("z_longlong"); + return 0; +} +EOF + else + echo "Checking for long long... No." | tee -a configure.log + cat > $test.c < +int main(void) { + if (sizeof(void *) <= sizeof(int)) puts("int"); + else puts("long"); + return 0; +} +EOF + fi + if try $CC $CFLAGS -o $test $test.c; then + sizet=`./$test` + echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log + CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}" + SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}" + else + echo "Checking for a pointer-size integer type... not found." | tee -a configure.log + fi +fi + +echo >> configure.log + +# check for large file support, and if none, check for fseeko() +cat > $test.c < +off64_t dummy = 0; +EOF +if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then + CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1" + SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1" + ALL="${ALL} all64" + TEST="${TEST} test64" + echo "Checking for off64_t... Yes." | tee -a configure.log + echo "Checking for fseeko... Yes." | tee -a configure.log +else + echo "Checking for off64_t... No." | tee -a configure.log + echo >> configure.log + cat > $test.c < +int main(void) { + fseeko(NULL, 0, 0); + return 0; +} +EOF + if try $CC $CFLAGS -o $test $test.c; then + echo "Checking for fseeko... Yes." | tee -a configure.log + else + CFLAGS="${CFLAGS} -DNO_FSEEKO" + SFLAGS="${SFLAGS} -DNO_FSEEKO" + echo "Checking for fseeko... No." | tee -a configure.log + fi +fi + +echo >> configure.log + +# check for strerror() for use by gz* functions +cat > $test.c < +#include +int main() { return strlen(strerror(errno)); } +EOF +if try $CC $CFLAGS -o $test $test.c; then + echo "Checking for strerror... Yes." | tee -a configure.log +else + CFLAGS="${CFLAGS} -DNO_STRERROR" + SFLAGS="${SFLAGS} -DNO_STRERROR" + echo "Checking for strerror... No." | tee -a configure.log +fi + +# copy clean zconf.h for subsequent edits +cp -p ${SRCDIR}zconf.h.in zconf.h + +echo >> configure.log + +# check for unistd.h and save result in zconf.h +cat > $test.c < +int main() { return 0; } +EOF +if try $CC -c $CFLAGS $test.c; then + sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h + mv zconf.temp.h zconf.h + echo "Checking for unistd.h... Yes." | tee -a configure.log +else + echo "Checking for unistd.h... No." | tee -a configure.log +fi + +echo >> configure.log + +# check for stdarg.h and save result in zconf.h +cat > $test.c < +int main() { return 0; } +EOF +if try $CC -c $CFLAGS $test.c; then + sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h + mv zconf.temp.h zconf.h + echo "Checking for stdarg.h... Yes." | tee -a configure.log +else + echo "Checking for stdarg.h... No." | tee -a configure.log +fi + +# if the z_ prefix was requested, save that in zconf.h +if test $zprefix -eq 1; then + sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h + mv zconf.temp.h zconf.h + echo >> configure.log + echo "Using z_ prefix on all symbols." | tee -a configure.log +fi + +# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists +if test $solo -eq 1; then + sed '/#define ZCONF_H/a\ +#define Z_SOLO + +' < zconf.h > zconf.temp.h + mv zconf.temp.h zconf.h +OBJC='$(OBJZ)' +PIC_OBJC='$(PIC_OBJZ)' +fi + +# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X +if test $cover -eq 1; then + CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage" + if test -n "$GCC_CLASSIC"; then + CC=$GCC_CLASSIC + fi +fi + +echo >> configure.log + +# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions +# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a +# return value. The most secure result is vsnprintf() with a return value. snprintf() with a +# return value is secure as well, but then gzprintf() will be limited to 20 arguments. +cat > $test.c < +#include +#include "zconf.h" +int main() +{ +#ifndef STDC + choke me +#endif + return 0; +} +EOF +if try $CC -c $CFLAGS $test.c; then + echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log + + echo >> configure.log + cat > $test.c < +#include +int mytest(const char *fmt, ...) +{ + char buf[20]; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return 0; +} +int main() +{ + return (mytest("Hello%d\n", 1)); +} +EOF + if try $CC $CFLAGS -o $test $test.c; then + echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log + + echo >> configure.log + cat >$test.c < +#include +int mytest(const char *fmt, ...) +{ + int n; + char buf[20]; + va_list ap; + va_start(ap, fmt); + n = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return n; +} +int main() +{ + return (mytest("Hello%d\n", 1)); +} +EOF + + if try $CC -c $CFLAGS $test.c; then + echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log + else + CFLAGS="$CFLAGS -DHAS_vsnprintf_void" + SFLAGS="$SFLAGS -DHAS_vsnprintf_void" + echo "Checking for return value of vsnprintf()... No." | tee -a configure.log + echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log + echo " can build but will be open to possible string-format security" | tee -a configure.log + echo " vulnerabilities." | tee -a configure.log + fi + else + CFLAGS="$CFLAGS -DNO_vsnprintf" + SFLAGS="$SFLAGS -DNO_vsnprintf" + echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log + echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log + echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log + echo " vulnerabilities." | tee -a configure.log + + echo >> configure.log + cat >$test.c < +#include +int mytest(const char *fmt, ...) +{ + int n; + char buf[20]; + va_list ap; + va_start(ap, fmt); + n = vsprintf(buf, fmt, ap); + va_end(ap); + return n; +} +int main() +{ + return (mytest("Hello%d\n", 1)); +} +EOF + + if try $CC -c $CFLAGS $test.c; then + echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log + else + CFLAGS="$CFLAGS -DHAS_vsprintf_void" + SFLAGS="$SFLAGS -DHAS_vsprintf_void" + echo "Checking for return value of vsprintf()... No." | tee -a configure.log + echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log + echo " can build but will be open to possible string-format security" | tee -a configure.log + echo " vulnerabilities." | tee -a configure.log + fi + fi +else + echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log + + echo >> configure.log + cat >$test.c < +int mytest() +{ + char buf[20]; + snprintf(buf, sizeof(buf), "%s", "foo"); + return 0; +} +int main() +{ + return (mytest()); +} +EOF + + if try $CC $CFLAGS -o $test $test.c; then + echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log + + echo >> configure.log + cat >$test.c < +int mytest() +{ + char buf[20]; + return snprintf(buf, sizeof(buf), "%s", "foo"); +} +int main() +{ + return (mytest()); +} +EOF + + if try $CC -c $CFLAGS $test.c; then + echo "Checking for return value of snprintf()... Yes." | tee -a configure.log + else + CFLAGS="$CFLAGS -DHAS_snprintf_void" + SFLAGS="$SFLAGS -DHAS_snprintf_void" + echo "Checking for return value of snprintf()... No." | tee -a configure.log + echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log + echo " can build but will be open to possible string-format security" | tee -a configure.log + echo " vulnerabilities." | tee -a configure.log + fi + else + CFLAGS="$CFLAGS -DNO_snprintf" + SFLAGS="$SFLAGS -DNO_snprintf" + echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log + echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log + echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log + echo " vulnerabilities." | tee -a configure.log + + echo >> configure.log + cat >$test.c < +int mytest() +{ + char buf[20]; + return sprintf(buf, "%s", "foo"); +} +int main() +{ + return (mytest()); +} +EOF + + if try $CC -c $CFLAGS $test.c; then + echo "Checking for return value of sprintf()... Yes." | tee -a configure.log + else + CFLAGS="$CFLAGS -DHAS_sprintf_void" + SFLAGS="$SFLAGS -DHAS_sprintf_void" + echo "Checking for return value of sprintf()... No." | tee -a configure.log + echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log + echo " can build but will be open to possible string-format security" | tee -a configure.log + echo " vulnerabilities." | tee -a configure.log + fi + fi +fi + +# see if we can hide zlib internal symbols that are linked between separate source files +if test "$gcc" -eq 1; then + echo >> configure.log + cat > $test.c <> configure.log +echo ALL = $ALL >> configure.log +echo AR = $AR >> configure.log +echo ARFLAGS = $ARFLAGS >> configure.log +echo CC = $CC >> configure.log +echo CFLAGS = $CFLAGS >> configure.log +echo CPP = $CPP >> configure.log +echo EXE = $EXE >> configure.log +echo LDCONFIG = $LDCONFIG >> configure.log +echo LDFLAGS = $LDFLAGS >> configure.log +echo LDSHARED = $LDSHARED >> configure.log +echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log +echo OBJC = $OBJC >> configure.log +echo PIC_OBJC = $PIC_OBJC >> configure.log +echo RANLIB = $RANLIB >> configure.log +echo SFLAGS = $SFLAGS >> configure.log +echo SHAREDLIB = $SHAREDLIB >> configure.log +echo SHAREDLIBM = $SHAREDLIBM >> configure.log +echo SHAREDLIBV = $SHAREDLIBV >> configure.log +echo STATICLIB = $STATICLIB >> configure.log +echo TEST = $TEST >> configure.log +echo VER = $VER >> configure.log +echo SRCDIR = $SRCDIR >> configure.log +echo exec_prefix = $exec_prefix >> configure.log +echo includedir = $includedir >> configure.log +echo libdir = $libdir >> configure.log +echo mandir = $mandir >> configure.log +echo prefix = $prefix >> configure.log +echo sharedlibdir = $sharedlibdir >> configure.log +echo uname = $uname >> configure.log + +# update Makefile with the configure results +sed < ${SRCDIR}Makefile.in " +/^CC *=/s#=.*#=$CC# +/^CFLAGS *=/s#=.*#=$CFLAGS# +/^SFLAGS *=/s#=.*#=$SFLAGS# +/^LDFLAGS *=/s#=.*#=$LDFLAGS# +/^LDSHARED *=/s#=.*#=$LDSHARED# +/^CPP *=/s#=.*#=$CPP# +/^STATICLIB *=/s#=.*#=$STATICLIB# +/^SHAREDLIB *=/s#=.*#=$SHAREDLIB# +/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# +/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# +/^AR *=/s#=.*#=$AR# +/^ARFLAGS *=/s#=.*#=$ARFLAGS# +/^RANLIB *=/s#=.*#=$RANLIB# +/^LDCONFIG *=/s#=.*#=$LDCONFIG# +/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC# +/^EXE *=/s#=.*#=$EXE# +/^SRCDIR *=/s#=.*#=$SRCDIR# +/^ZINC *=/s#=.*#=$ZINC# +/^ZINCOUT *=/s#=.*#=$ZINCOUT# +/^prefix *=/s#=.*#=$prefix# +/^exec_prefix *=/s#=.*#=$exec_prefix# +/^libdir *=/s#=.*#=$libdir# +/^sharedlibdir *=/s#=.*#=$sharedlibdir# +/^includedir *=/s#=.*#=$includedir# +/^mandir *=/s#=.*#=$mandir# +/^OBJC *=/s#=.*#= $OBJC# +/^PIC_OBJC *=/s#=.*#= $PIC_OBJC# +/^all: */s#:.*#: $ALL# +/^test: */s#:.*#: $TEST# +" > Makefile + +# create zlib.pc with the configure results +sed < ${SRCDIR}zlib.pc.in " +/^CC *=/s#=.*#=$CC# +/^CFLAGS *=/s#=.*#=$CFLAGS# +/^CPP *=/s#=.*#=$CPP# +/^LDSHARED *=/s#=.*#=$LDSHARED# +/^STATICLIB *=/s#=.*#=$STATICLIB# +/^SHAREDLIB *=/s#=.*#=$SHAREDLIB# +/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# +/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# +/^AR *=/s#=.*#=$AR# +/^ARFLAGS *=/s#=.*#=$ARFLAGS# +/^RANLIB *=/s#=.*#=$RANLIB# +/^EXE *=/s#=.*#=$EXE# +/^prefix *=/s#=.*#=$prefix# +/^exec_prefix *=/s#=.*#=$exec_prefix# +/^libdir *=/s#=.*#=$libdir# +/^sharedlibdir *=/s#=.*#=$sharedlibdir# +/^includedir *=/s#=.*#=$includedir# +/^mandir *=/s#=.*#=$mandir# +/^LDFLAGS *=/s#=.*#=$LDFLAGS# +" | sed -e " +s/\@VERSION\@/$VER/g; +" > zlib.pc + +# done +leave 0 diff --git a/cdk/extra/zlib/crc32.c b/cdk/extra/zlib/crc32.c index f8357b083..6c38f5c04 100644 --- a/cdk/extra/zlib/crc32.c +++ b/cdk/extra/zlib/crc32.c @@ -103,19 +103,6 @@ # define ARMCRC32 #endif -/* Local functions. */ -local z_crc_t multmodp OF((z_crc_t a, z_crc_t b)); -local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); - -#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) - local z_word_t byte_swap OF((z_word_t word)); -#endif - -#if defined(W) && !defined(ARMCRC32) - local z_crc_t crc_word OF((z_word_t data)); - local z_word_t crc_word_big OF((z_word_t data)); -#endif - #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) /* Swap the bytes in a z_word_t to convert between little and big endian. Any @@ -123,9 +110,7 @@ local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); instruction, if one is available. This assumes that word_t is either 32 bits or 64 bits. */ -local z_word_t byte_swap(word) - z_word_t word; -{ +local z_word_t byte_swap(z_word_t word) { # if W == 8 return (word & 0xff00000000000000) >> 56 | @@ -146,24 +131,77 @@ local z_word_t byte_swap(word) } #endif +#ifdef DYNAMIC_CRC_TABLE +/* ========================================================================= + * Table of powers of x for combining CRC-32s, filled in by make_crc_table() + * below. + */ + local z_crc_t FAR x2n_table[32]; +#else +/* ========================================================================= + * Tables for byte-wise and braided CRC-32 calculations, and a table of powers + * of x for combining CRC-32s, all made by make_crc_table(). + */ +# include "crc32.h" +#endif + /* CRC polynomial. */ #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ -#ifdef DYNAMIC_CRC_TABLE +/* + Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, + reflected. For speed, this requires that a not be zero. + */ +local z_crc_t multmodp(z_crc_t a, z_crc_t b) { + z_crc_t m, p; + + m = (z_crc_t)1 << 31; + p = 0; + for (;;) { + if (a & m) { + p ^= b; + if ((a & (m - 1)) == 0) + break; + } + m >>= 1; + b = b & 1 ? (b >> 1) ^ POLY : b >> 1; + } + return p; +} +/* + Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been + initialized. + */ +local z_crc_t x2nmodp(z_off64_t n, unsigned k) { + z_crc_t p; + + p = (z_crc_t)1 << 31; /* x^0 == 1 */ + while (n) { + if (n & 1) + p = multmodp(x2n_table[k & 31], p); + n >>= 1; + k++; + } + return p; +} + +#ifdef DYNAMIC_CRC_TABLE +/* ========================================================================= + * Build the tables for byte-wise and braided CRC-32 calculations, and a table + * of powers of x for combining CRC-32s. + */ local z_crc_t FAR crc_table[256]; -local z_crc_t FAR x2n_table[32]; -local void make_crc_table OF((void)); #ifdef W local z_word_t FAR crc_big_table[256]; local z_crc_t FAR crc_braid_table[W][256]; local z_word_t FAR crc_braid_big_table[W][256]; - local void braid OF((z_crc_t [][256], z_word_t [][256], int, int)); + local void braid(z_crc_t [][256], z_word_t [][256], int, int); #endif #ifdef MAKECRCH - local void write_table OF((FILE *, const z_crc_t FAR *, int)); - local void write_table32hi OF((FILE *, const z_word_t FAR *, int)); - local void write_table64 OF((FILE *, const z_word_t FAR *, int)); + local void write_table(FILE *, const z_crc_t FAR *, int); + local void write_table32hi(FILE *, const z_word_t FAR *, int); + local void write_table64(FILE *, const z_word_t FAR *, int); #endif /* MAKECRCH */ /* @@ -176,7 +214,6 @@ local void make_crc_table OF((void)); /* Definition of once functionality. */ typedef struct once_s once_t; -local void once OF((once_t *, void (*)(void))); /* Check for the availability of atomics. */ #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ @@ -196,10 +233,7 @@ struct once_s { invoke once() at the same time. The state must be a once_t initialized with ONCE_INIT. */ -local void once(state, init) - once_t *state; - void (*init)(void); -{ +local void once(once_t *state, void (*init)(void)) { if (!atomic_load(&state->done)) { if (atomic_flag_test_and_set(&state->begun)) while (!atomic_load(&state->done)) @@ -222,10 +256,7 @@ struct once_s { /* Test and set. Alas, not atomic, but tries to minimize the period of vulnerability. */ -local int test_and_set OF((int volatile *)); -local int test_and_set(flag) - int volatile *flag; -{ +local int test_and_set(int volatile *flag) { int was; was = *flag; @@ -234,10 +265,7 @@ local int test_and_set(flag) } /* Run the provided init() function once. This is not thread-safe. */ -local void once(state, init) - once_t *state; - void (*init)(void); -{ +local void once(once_t *state, void (*init)(void)) { if (!state->done) { if (test_and_set(&state->begun)) while (!state->done) @@ -279,8 +307,7 @@ local once_t made = ONCE_INIT; combinations of CRC register values and incoming bytes. */ -local void make_crc_table() -{ +local void make_crc_table(void) { unsigned i, j, n; z_crc_t p; @@ -447,11 +474,7 @@ local void make_crc_table() Write the 32-bit values in table[0..k-1] to out, five per line in hexadecimal separated by commas. */ -local void write_table(out, table, k) - FILE *out; - const z_crc_t FAR *table; - int k; -{ +local void write_table(FILE *out, const z_crc_t FAR *table, int k) { int n; for (n = 0; n < k; n++) @@ -464,11 +487,7 @@ local void write_table(out, table, k) Write the high 32-bits of each value in table[0..k-1] to out, five per line in hexadecimal separated by commas. */ -local void write_table32hi(out, table, k) -FILE *out; -const z_word_t FAR *table; -int k; -{ +local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) { int n; for (n = 0; n < k; n++) @@ -484,11 +503,7 @@ int k; bits. If not, then the type cast and format string can be adjusted accordingly. */ -local void write_table64(out, table, k) - FILE *out; - const z_word_t FAR *table; - int k; -{ +local void write_table64(FILE *out, const z_word_t FAR *table, int k) { int n; for (n = 0; n < k; n++) @@ -498,8 +513,7 @@ local void write_table64(out, table, k) } /* Actually do the deed. */ -int main() -{ +int main(void) { make_crc_table(); return 0; } @@ -511,12 +525,7 @@ int main() Generate the little and big-endian braid tables for the given n and z_word_t size w. Each array must have room for w blocks of 256 elements. */ -local void braid(ltl, big, n, w) - z_crc_t ltl[][256]; - z_word_t big[][256]; - int n; - int w; -{ +local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) { int k; z_crc_t i, p, q; for (k = 0; k < w; k++) { @@ -531,69 +540,13 @@ local void braid(ltl, big, n, w) } #endif -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables for byte-wise and braided CRC-32 calculations, and a table of powers - * of x for combining CRC-32s, all made by make_crc_table(). - */ -#include "crc32.h" #endif /* DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Routines used for CRC calculation. Some are also required for the table - * generation above. - */ - -/* - Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, - reflected. For speed, this requires that a not be zero. - */ -local z_crc_t multmodp(a, b) - z_crc_t a; - z_crc_t b; -{ - z_crc_t m, p; - - m = (z_crc_t)1 << 31; - p = 0; - for (;;) { - if (a & m) { - p ^= b; - if ((a & (m - 1)) == 0) - break; - } - m >>= 1; - b = b & 1 ? (b >> 1) ^ POLY : b >> 1; - } - return p; -} - -/* - Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been - initialized. - */ -local z_crc_t x2nmodp(n, k) - z_off64_t n; - unsigned k; -{ - z_crc_t p; - - p = (z_crc_t)1 << 31; /* x^0 == 1 */ - while (n) { - if (n & 1) - p = multmodp(x2n_table[k & 31], p); - n >>= 1; - k++; - } - return p; -} - /* ========================================================================= * This function can be used by asm versions of crc32(), and to force the * generation of the CRC tables in a threaded application. */ -const z_crc_t FAR * ZEXPORT get_crc_table() -{ +const z_crc_t FAR * ZEXPORT get_crc_table(void) { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ @@ -619,11 +572,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table() #define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ #define Z_BATCH_MIN 800 /* fewest words in a final batch */ -unsigned long ZEXPORT crc32_z(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, + z_size_t len) { z_crc_t val; z_word_t crc1, crc2; const z_word_t *word; @@ -723,18 +673,14 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) least-significant byte of the word as the first byte of data, without any pre or post conditioning. This is used to combine the CRCs of each braid. */ -local z_crc_t crc_word(data) - z_word_t data; -{ +local z_crc_t crc_word(z_word_t data) { int k; for (k = 0; k < W; k++) data = (data >> 8) ^ crc_table[data & 0xff]; return (z_crc_t)data; } -local z_word_t crc_word_big(data) - z_word_t data; -{ +local z_word_t crc_word_big(z_word_t data) { int k; for (k = 0; k < W; k++) data = (data << 8) ^ @@ -745,11 +691,8 @@ local z_word_t crc_word_big(data) #endif /* ========================================================================= */ -unsigned long ZEXPORT crc32_z(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, + z_size_t len) { /* Return initial CRC, if requested. */ if (buf == Z_NULL) return 0; @@ -781,8 +724,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) words = (z_word_t const *)buf; /* Do endian check at execution time instead of compile time, since ARM - processors can change the endianess at execution time. If the - compiler knows what the endianess will be, it can optimize out the + processors can change the endianness at execution time. If the + compiler knows what the endianness will be, it can optimize out the check and the unused branch. */ endian = 1; if (*(unsigned char *)&endian) { @@ -1069,20 +1012,13 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) #endif /* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - uInt len; -{ +unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, + uInt len) { return crc32_z(crc, buf, len); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine64(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ +uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ @@ -1090,18 +1026,12 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2) } /* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ +uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) { return crc32_combine64(crc1, crc2, (z_off64_t)len2); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine_gen64(len2) - z_off64_t len2; -{ +uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ @@ -1109,17 +1039,11 @@ uLong ZEXPORT crc32_combine_gen64(len2) } /* ========================================================================= */ -uLong ZEXPORT crc32_combine_gen(len2) - z_off_t len2; -{ +uLong ZEXPORT crc32_combine_gen(z_off_t len2) { return crc32_combine_gen64((z_off64_t)len2); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine_op(crc1, crc2, op) - uLong crc1; - uLong crc2; - uLong op; -{ +uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) { return multmodp(op, crc1) ^ (crc2 & 0xffffffff); } diff --git a/cdk/extra/zlib/deflate.c b/cdk/extra/zlib/deflate.c index 4a689db35..012ea8148 100644 --- a/cdk/extra/zlib/deflate.c +++ b/cdk/extra/zlib/deflate.c @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.13 Copyright 1995-2022 Jean-loup Gailly and Mark Adler "; + " deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -60,9 +60,6 @@ const char deflate_copyright[] = copyright string in the executable of your product. */ -/* =========================================================================== - * Function prototypes. - */ typedef enum { need_more, /* block not completed, need more input or more output */ block_done, /* block flush performed */ @@ -70,29 +67,16 @@ typedef enum { finish_done /* finish done, accept no more input or output */ } block_state; -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +typedef block_state (*compress_func)(deflate_state *s, int flush); /* Compression function. Returns the block state after the call. */ -local int deflateStateCheck OF((z_streamp strm)); -local void slide_hash OF((deflate_state *s)); -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); +local block_state deflate_stored(deflate_state *s, int flush); +local block_state deflate_fast(deflate_state *s, int flush); #ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local block_state deflate_rle OF((deflate_state *s, int flush)); -local block_state deflate_huff OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -local uInt longest_match OF((deflate_state *s, IPos cur_match)); - -#ifdef ZLIB_DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); +local block_state deflate_slow(deflate_state *s, int flush); #endif +local block_state deflate_rle(deflate_state *s, int flush); +local block_state deflate_huff(deflate_state *s, int flush); /* =========================================================================== * Local data @@ -195,9 +179,12 @@ local const config configuration_table[10] = { * bit values at the expense of memory usage). We slide even when level == 0 to * keep the hash table consistent if we switch back to level > 0 later. */ -local void slide_hash(s) - deflate_state *s; -{ +#if defined(__has_feature) +# if __has_feature(memory_sanitizer) + __attribute__((no_sanitize("memory"))) +# endif +#endif +local void slide_hash(deflate_state *s) { unsigned n, m; Posf *p; uInt wsize = s->w_size; @@ -221,30 +208,177 @@ local void slide_hash(s) #endif } +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) { + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + zmemcpy(buf, strm->next_in, len); + if (strm->state->wrap == 1) { + strm->adler = adler32(strm->adler, buf, len); + } +#ifdef GZIP + else if (strm->state->wrap == 2) { + strm->adler = crc32(strm->adler, buf, len); + } +#endif + strm->next_in += len; + strm->total_in += len; + + return len; +} + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window(deflate_state *s) { + unsigned n; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (sizeof(int) <= 2) { + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if + * strstart == 0 && lookahead == 1 (input done a byte at time) + */ + more--; + } + } + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize + MAX_DIST(s)) { + + zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + if (s->insert > s->strstart) + s->insert = s->strstart; + slide_hash(s); + more += wsize; + } + if (s->strm->avail_in == 0) break; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead + s->insert >= MIN_MATCH) { + uInt str = s->strstart - s->insert; + s->ins_h = s->window[str]; + UPDATE_HASH(s, s->ins_h, s->window[str + 1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + while (s->insert) { + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); +#ifndef FASTEST + s->prev[str & s->w_mask] = s->head[s->ins_h]; +#endif + s->head[s->ins_h] = (Pos)str; + str++; + s->insert--; + if (s->lookahead + s->insert < MIN_MATCH) + break; + } + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); + + /* If the WIN_INIT bytes after the end of the current data have never been + * written, then zero those bytes in order to avoid memory check reports of + * the use of uninitialized (or uninitialised as Julian writes) bytes by + * the longest match routines. Update the high water mark for the next + * time through here. WIN_INIT is set to MAX_MATCH since the longest match + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. + */ + if (s->high_water < s->window_size) { + ulg curr = s->strstart + (ulg)(s->lookahead); + ulg init; + + if (s->high_water < curr) { + /* Previous high water mark below current data -- zero WIN_INIT + * bytes or up to end of window, whichever is less. + */ + init = s->window_size - curr; + if (init > WIN_INIT) + init = WIN_INIT; + zmemzero(s->window + curr, (unsigned)init); + s->high_water = curr + init; + } + else if (s->high_water < (ulg)curr + WIN_INIT) { + /* High water mark at or above current data, but below current data + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up + * to end of window, whichever is less. + */ + init = (ulg)curr + WIN_INIT - s->high_water; + if (init > s->window_size - s->high_water) + init = s->window_size - s->high_water; + zmemzero(s->window + s->high_water, (unsigned)init); + s->high_water += init; + } + } + + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, + "not enough room for search"); +} + /* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ +int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, + int stream_size) { return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size); /* To do: ignore strm->next_in if we use it as window */ } /* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ +int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, int strategy, + const char *version, int stream_size) { deflate_state *s; int wrap = 1; static const char my_version[] = ZLIB_VERSION; @@ -359,7 +493,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, * symbols from which it is being constructed. */ - s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4); + s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS); s->pending_buf_size = (ulg)s->lit_bufsize * 4; if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || @@ -369,8 +503,14 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, deflateEnd (strm); return Z_MEM_ERROR; } +#ifdef LIT_MEM + s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1)); + s->l_buf = s->pending_buf + (s->lit_bufsize << 2); + s->sym_end = s->lit_bufsize - 1; +#else s->sym_buf = s->pending_buf + s->lit_bufsize; s->sym_end = (s->lit_bufsize - 1) * 3; +#endif /* We avoid equality with lit_bufsize*3 because of wraparound at 64K * on 16 bit machines and because stored blocks are restricted to * 64K-1 bytes. @@ -386,9 +526,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, /* ========================================================================= * Check for a valid deflate stream state. Return 0 if ok, 1 if not. */ -local int deflateStateCheck(strm) - z_streamp strm; -{ +local int deflateStateCheck(z_streamp strm) { deflate_state *s; if (strm == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) @@ -409,11 +547,8 @@ local int deflateStateCheck(strm) } /* ========================================================================= */ -int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ +int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary, + uInt dictLength) { deflate_state *s; uInt str, n; int wrap; @@ -478,11 +613,8 @@ int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength) } /* ========================================================================= */ -int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength) - z_streamp strm; - Bytef *dictionary; - uInt *dictLength; -{ +int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary, + uInt *dictLength) { deflate_state *s; uInt len; @@ -500,9 +632,7 @@ int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength) } /* ========================================================================= */ -int ZEXPORT deflateResetKeep(strm) - z_streamp strm; -{ +int ZEXPORT deflateResetKeep(z_streamp strm) { deflate_state *s; if (deflateStateCheck(strm)) { @@ -537,10 +667,32 @@ int ZEXPORT deflateResetKeep(strm) return Z_OK; } +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init(deflate_state *s) { + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->insert = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +} + /* ========================================================================= */ -int ZEXPORT deflateReset(strm) - z_streamp strm; -{ +int ZEXPORT deflateReset(z_streamp strm) { int ret; ret = deflateResetKeep(strm); @@ -550,10 +702,7 @@ int ZEXPORT deflateReset(strm) } /* ========================================================================= */ -int ZEXPORT deflateSetHeader(strm, head) - z_streamp strm; - gz_headerp head; -{ +int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) { if (deflateStateCheck(strm) || strm->state->wrap != 2) return Z_STREAM_ERROR; strm->state->gzhead = head; @@ -561,11 +710,7 @@ int ZEXPORT deflateSetHeader(strm, head) } /* ========================================================================= */ -int ZEXPORT deflatePending(strm, pending, bits) - unsigned *pending; - int *bits; - z_streamp strm; -{ +int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) { if (deflateStateCheck(strm)) return Z_STREAM_ERROR; if (pending != Z_NULL) *pending = strm->state->pending; @@ -575,19 +720,21 @@ int ZEXPORT deflatePending(strm, pending, bits) } /* ========================================================================= */ -int ZEXPORT deflatePrime(strm, bits, value) - z_streamp strm; - int bits; - int value; -{ +int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { deflate_state *s; int put; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; +#ifdef LIT_MEM + if (bits < 0 || bits > 16 || + (uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3)) + return Z_BUF_ERROR; +#else if (bits < 0 || bits > 16 || s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3)) return Z_BUF_ERROR; +#endif do { put = Buf_size - s->bi_valid; if (put > bits) @@ -602,11 +749,7 @@ int ZEXPORT deflatePrime(strm, bits, value) } /* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ +int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { deflate_state *s; compress_func func; @@ -651,13 +794,8 @@ int ZEXPORT deflateParams(strm, level, strategy) } /* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ +int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, + int nice_length, int max_chain) { deflate_state *s; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -693,10 +831,7 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) * * Shifts are used to approximate divisions, for speed. */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ +uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { deflate_state *s; uLong fixedlen, storelen, wraplen; @@ -752,7 +887,8 @@ uLong ZEXPORT deflateBound(strm, sourceLen) /* if not default parameters, return one of the conservative bounds */ if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen; + return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) + + wraplen; /* default settings: return tight bound for that case -- ~0.03% overhead plus a small constant */ @@ -765,10 +901,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen) * IN assertion: the stream state is correct and there is enough room in * pending_buf. */ -local void putShortMSB(s, b) - deflate_state *s; - uInt b; -{ +local void putShortMSB(deflate_state *s, uInt b) { put_byte(s, (Byte)(b >> 8)); put_byte(s, (Byte)(b & 0xff)); } @@ -779,9 +912,7 @@ local void putShortMSB(s, b) * applications may wish to modify it to avoid allocating a large * strm->next_out buffer and copying into it. (See also read_buf()). */ -local void flush_pending(strm) - z_streamp strm; -{ +local void flush_pending(z_streamp strm) { unsigned len; deflate_state *s = strm->state; @@ -812,10 +943,7 @@ local void flush_pending(strm) } while (0) /* ========================================================================= */ -int ZEXPORT deflate(strm, flush) - z_streamp strm; - int flush; -{ +int ZEXPORT deflate(z_streamp strm, int flush) { int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; @@ -1127,9 +1255,7 @@ int ZEXPORT deflate(strm, flush) } /* ========================================================================= */ -int ZEXPORT deflateEnd(strm) - z_streamp strm; -{ +int ZEXPORT deflateEnd(z_streamp strm) { int status; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1153,11 +1279,10 @@ int ZEXPORT deflateEnd(strm) * To simplify the source, this is not supported for 16-bit MSDOS (which * doesn't have enough memory anyway to duplicate compression states). */ -int ZEXPORT deflateCopy(dest, source) - z_streamp dest; - z_streamp source; -{ +int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { #ifdef MAXSEG_64K + (void)dest; + (void)source; return Z_STREAM_ERROR; #else deflate_state *ds; @@ -1181,7 +1306,7 @@ int ZEXPORT deflateCopy(dest, source) ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4); + ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS); if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || ds->pending_buf == Z_NULL) { @@ -1192,10 +1317,15 @@ int ZEXPORT deflateCopy(dest, source) zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); +#ifdef LIT_MEM + ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1)); + ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2); +#else ds->sym_buf = ds->pending_buf + ds->lit_bufsize; +#endif ds->l_desc.dyn_tree = ds->dyn_ltree; ds->d_desc.dyn_tree = ds->dyn_dtree; @@ -1205,66 +1335,6 @@ int ZEXPORT deflateCopy(dest, source) #endif /* MAXSEG_64K */ } -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local unsigned read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - zmemcpy(buf, strm->next_in, len); - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, buf, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, buf, len); - } -#endif - strm->next_in += len; - strm->total_in += len; - - return len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init(s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->insert = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -} - #ifndef FASTEST /* =========================================================================== * Set match_start to the longest match starting at the given string and @@ -1275,10 +1345,7 @@ local void lm_init(s) * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 * OUT assertion: the match length is not greater than s->lookahead. */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ +local uInt longest_match(deflate_state *s, IPos cur_match) { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ @@ -1426,10 +1493,7 @@ local uInt longest_match(s, cur_match) /* --------------------------------------------------------------------------- * Optimized version for FASTEST only */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ +local uInt longest_match(deflate_state *s, IPos cur_match) { register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ register int len; /* length of current match */ @@ -1490,19 +1554,23 @@ local uInt longest_match(s, cur_match) /* =========================================================================== * Check that the match at match_start is indeed a match. */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ +local void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); + Bytef *back = s->window + (int)match, *here = s->window + start; + IPos len = length; + if (match == (IPos)-1) { + /* match starts one byte before the current window -- just compare the + subsequent length-1 bytes */ + back++; + here++; + len--; + } + if (zmemcmp(back, here, len) != EQUAL) { + fprintf(stderr, " start %u, match %d, length %d\n", + start, (int)match, length); do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); + fprintf(stderr, "(%02x %02x)", *back++, *here++); + } while (--len != 0); z_error("invalid match"); } if (z_verbose > 1) { @@ -1514,137 +1582,6 @@ local void check_match(s, start, match, length) # define check_match(s, start, match, length) #endif /* ZLIB_DEBUG */ -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - unsigned n; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize + MAX_DIST(s)) { - - zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - if (s->insert > s->strstart) - s->insert = s->strstart; - slide_hash(s); - more += wsize; - } - if (s->strm->avail_in == 0) break; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead + s->insert >= MIN_MATCH) { - uInt str = s->strstart - s->insert; - s->ins_h = s->window[str]; - UPDATE_HASH(s, s->ins_h, s->window[str + 1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - while (s->insert) { - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); -#ifndef FASTEST - s->prev[str & s->w_mask] = s->head[s->ins_h]; -#endif - s->head[s->ins_h] = (Pos)str; - str++; - s->insert--; - if (s->lookahead + s->insert < MIN_MATCH) - break; - } - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); - - /* If the WIN_INIT bytes after the end of the current data have never been - * written, then zero those bytes in order to avoid memory check reports of - * the use of uninitialized (or uninitialised as Julian writes) bytes by - * the longest match routines. Update the high water mark for the next - * time through here. WIN_INIT is set to MAX_MATCH since the longest match - * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. - */ - if (s->high_water < s->window_size) { - ulg curr = s->strstart + (ulg)(s->lookahead); - ulg init; - - if (s->high_water < curr) { - /* Previous high water mark below current data -- zero WIN_INIT - * bytes or up to end of window, whichever is less. - */ - init = s->window_size - curr; - if (init > WIN_INIT) - init = WIN_INIT; - zmemzero(s->window + curr, (unsigned)init); - s->high_water = curr + init; - } - else if (s->high_water < (ulg)curr + WIN_INIT) { - /* High water mark at or above current data, but below current data - * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up - * to end of window, whichever is less. - */ - init = (ulg)curr + WIN_INIT - s->high_water; - if (init > s->window_size - s->high_water) - init = s->window_size - s->high_water; - zmemzero(s->window + s->high_water, (unsigned)init); - s->high_water += init; - } - } - - Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, - "not enough room for search"); -} - /* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. @@ -1687,10 +1624,7 @@ local void fill_window(s) * copied. It is most efficient with large input and output buffers, which * maximizes the opportunities to have a single copy from next_in to next_out. */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_stored(deflate_state *s, int flush) { /* Smallest worthy block size when not flushing or finishing. By default * this is 32K. This can be as small as 507 bytes for memLevel == 1. For * large input and output buffers, the stored block size will be larger. @@ -1874,10 +1808,7 @@ local block_state deflate_stored(s, flush) * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_fast(deflate_state *s, int flush) { IPos hash_head; /* head of the hash chain */ int bflush; /* set if current block must be flushed */ @@ -1976,10 +1907,7 @@ local block_state deflate_fast(s, flush) * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_slow(deflate_state *s, int flush) { IPos hash_head; /* head of hash chain */ int bflush; /* set if current block must be flushed */ @@ -2107,10 +2035,7 @@ local block_state deflate_slow(s, flush) * one. Do not maintain a hash table. (It will be regenerated if this run of * deflate switches away from Z_RLE.) */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_rle(deflate_state *s, int flush) { int bflush; /* set if current block must be flushed */ uInt prev; /* byte at distance one to match */ Bytef *scan, *strend; /* scan goes up to strend for length of run */ @@ -2181,10 +2106,7 @@ local block_state deflate_rle(s, flush) * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. * (It will be regenerated if this run of deflate switches away from Huffman.) */ -local block_state deflate_huff(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_huff(deflate_state *s, int flush) { int bflush; /* set if current block must be flushed */ for (;;) { diff --git a/cdk/extra/zlib/deflate.h b/cdk/extra/zlib/deflate.h index 1a06cd5f2..300c6ada6 100644 --- a/cdk/extra/zlib/deflate.h +++ b/cdk/extra/zlib/deflate.h @@ -1,5 +1,5 @@ /* deflate.h -- internal compression state - * Copyright (C) 1995-2018 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -23,6 +23,10 @@ # define GZIP #endif +/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at + the cost of a larger memory footprint */ +/* #define LIT_MEM */ + /* =========================================================================== * Internal compression state. */ @@ -217,7 +221,14 @@ typedef struct internal_state { /* Depth of each subtree used as tie breaker for trees of equal frequency */ +#ifdef LIT_MEM +# define LIT_BUFS 5 + ushf *d_buf; /* buffer for distances */ + uchf *l_buf; /* buffer for literals/lengths */ +#else +# define LIT_BUFS 4 uchf *sym_buf; /* buffer for distances and literals/lengths */ +#endif uInt lit_bufsize; /* Size of match buffer for literals/lengths. There are 4 reasons for @@ -239,7 +250,7 @@ typedef struct internal_state { * - I can't count above 4 */ - uInt sym_next; /* running index in sym_buf */ + uInt sym_next; /* running index in symbol buffer */ uInt sym_end; /* symbol table full when sym_next reaches this */ ulg opt_len; /* bit length of current block with optimal trees */ @@ -291,14 +302,14 @@ typedef struct internal_state { memory checker errors from longest match routines */ /* in trees.c */ -void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); -void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); +void ZLIB_INTERNAL _tr_init(deflate_state *s); +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, + ulg stored_len, int last); +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); +void ZLIB_INTERNAL _tr_align(deflate_state *s); +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, + ulg stored_len, int last); #define d_code(dist) \ ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) @@ -318,6 +329,25 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, extern const uch ZLIB_INTERNAL _dist_code[]; #endif +#ifdef LIT_MEM +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->sym_next] = 0; \ + s->l_buf[s->sym_next++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (uch)(length); \ + ush dist = (ush)(distance); \ + s->d_buf[s->sym_next] = dist; \ + s->l_buf[s->sym_next++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +#else # define _tr_tally_lit(s, c, flush) \ { uch cc = (c); \ s->sym_buf[s->sym_next++] = 0; \ @@ -337,6 +367,7 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, s->dyn_dtree[d_code(dist)].Freq++; \ flush = (s->sym_next == s->sym_end); \ } +#endif #else # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) # define _tr_tally_dist(s, distance, length, flush) \ diff --git a/cdk/extra/zlib/gzclose.c b/cdk/extra/zlib/gzclose.c index caeb99a31..48d6a86f0 100644 --- a/cdk/extra/zlib/gzclose.c +++ b/cdk/extra/zlib/gzclose.c @@ -8,9 +8,7 @@ /* gzclose() is in a separate file so that it is linked in only if it is used. That way the other gzclose functions can be used instead to avoid linking in unneeded compression or decompression routines. */ -int ZEXPORT gzclose(file) - gzFile file; -{ +int ZEXPORT gzclose(gzFile file) { #ifndef NO_GZCOMPRESS gz_statep state; diff --git a/cdk/extra/zlib/gzguts.h b/cdk/extra/zlib/gzguts.h index 57faf3716..eba72085b 100644 --- a/cdk/extra/zlib/gzguts.h +++ b/cdk/extra/zlib/gzguts.h @@ -1,5 +1,5 @@ /* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004-2019 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -7,9 +7,8 @@ # ifndef _LARGEFILE_SOURCE # define _LARGEFILE_SOURCE 1 # endif -# ifdef _FILE_OFFSET_BITS -# undef _FILE_OFFSET_BITS -# endif +# undef _FILE_OFFSET_BITS +# undef _TIME_BITS #endif #ifdef HAVE_HIDDEN @@ -119,8 +118,8 @@ /* gz* functions always use library allocation functions */ #ifndef STDC - extern voidp malloc OF((uInt size)); - extern void free OF((voidpf ptr)); + extern voidp malloc(uInt size); + extern void free(voidpf ptr); #endif /* get errno and strerror definition */ @@ -138,10 +137,10 @@ /* provide prototypes for these when building zlib without LFS */ #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); #endif /* default memLevel */ @@ -203,17 +202,13 @@ typedef struct { typedef gz_state FAR *gz_statep; /* shared functions */ -void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); +void ZLIB_INTERNAL gz_error(gz_statep, int, const char *); #if defined UNDER_CE -char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); +char ZLIB_INTERNAL *gz_strwinerror(DWORD error); #endif /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t value -- needed when comparing unsigned to z_off64_t, which is signed (possible z_off64_t types off_t, off64_t, and long are all signed) */ -#ifdef INT_MAX -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) -#else -unsigned ZLIB_INTERNAL gz_intmax OF((void)); -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) -#endif +unsigned ZLIB_INTERNAL gz_intmax(void); +#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) diff --git a/cdk/extra/zlib/gzlib.c b/cdk/extra/zlib/gzlib.c index 55da46a45..983153cc8 100644 --- a/cdk/extra/zlib/gzlib.c +++ b/cdk/extra/zlib/gzlib.c @@ -1,5 +1,5 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004-2019 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -15,10 +15,6 @@ #endif #endif -/* Local functions */ -local void gz_reset OF((gz_statep)); -local gzFile gz_open OF((const void *, int, const char *)); - #if defined UNDER_CE /* Map the Windows error number in ERROR to a locale-dependent error message @@ -30,9 +26,7 @@ local gzFile gz_open OF((const void *, int, const char *)); The gz_strwinerror function does not change the current setting of GetLastError. */ -char ZLIB_INTERNAL *gz_strwinerror(error) - DWORD error; -{ +char ZLIB_INTERNAL *gz_strwinerror(DWORD error) { static char buf[1024]; wchar_t *msgbuf; @@ -72,9 +66,7 @@ char ZLIB_INTERNAL *gz_strwinerror(error) #endif /* UNDER_CE */ /* Reset gzip file state */ -local void gz_reset(state) - gz_statep state; -{ +local void gz_reset(gz_statep state) { state->x.have = 0; /* no output data available */ if (state->mode == GZ_READ) { /* for reading ... */ state->eof = 0; /* not at end of file */ @@ -90,11 +82,7 @@ local void gz_reset(state) } /* Open a gzip file either by name or file descriptor. */ -local gzFile gz_open(path, fd, mode) - const void *path; - int fd; - const char *mode; -{ +local gzFile gz_open(const void *path, int fd, const char *mode) { gz_statep state; z_size_t len; int oflag; @@ -269,26 +257,17 @@ local gzFile gz_open(path, fd, mode) } /* -- see zlib.h -- */ -gzFile ZEXPORT gzopen(path, mode) - const char *path; - const char *mode; -{ +gzFile ZEXPORT gzopen(const char *path, const char *mode) { return gz_open(path, -1, mode); } /* -- see zlib.h -- */ -gzFile ZEXPORT gzopen64(path, mode) - const char *path; - const char *mode; -{ +gzFile ZEXPORT gzopen64(const char *path, const char *mode) { return gz_open(path, -1, mode); } /* -- see zlib.h -- */ -gzFile ZEXPORT gzdopen(fd, mode) - int fd; - const char *mode; -{ +gzFile ZEXPORT gzdopen(int fd, const char *mode) { char *path; /* identifier for error messages */ gzFile gz; @@ -306,19 +285,13 @@ gzFile ZEXPORT gzdopen(fd, mode) /* -- see zlib.h -- */ #ifdef WIDECHAR -gzFile ZEXPORT gzopen_w(path, mode) - const wchar_t *path; - const char *mode; -{ +gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) { return gz_open(path, -2, mode); } #endif /* -- see zlib.h -- */ -int ZEXPORT gzbuffer(file, size) - gzFile file; - unsigned size; -{ +int ZEXPORT gzbuffer(gzFile file, unsigned size) { gz_statep state; /* get internal structure and check integrity */ @@ -335,16 +308,14 @@ int ZEXPORT gzbuffer(file, size) /* check and set requested size */ if ((size << 1) < size) return -1; /* need to be able to double it */ - if (size < 2) - size = 2; /* need two bytes to check magic header */ + if (size < 8) + size = 8; /* needed to behave well with flushing */ state->want = size; return 0; } /* -- see zlib.h -- */ -int ZEXPORT gzrewind(file) - gzFile file; -{ +int ZEXPORT gzrewind(gzFile file) { gz_statep state; /* get internal structure */ @@ -365,11 +336,7 @@ int ZEXPORT gzrewind(file) } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gzseek64(file, offset, whence) - gzFile file; - z_off64_t offset; - int whence; -{ +z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) { unsigned n; z_off64_t ret; gz_statep state; @@ -442,11 +409,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) } /* -- see zlib.h -- */ -z_off_t ZEXPORT gzseek(file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ +z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) { z_off64_t ret; ret = gzseek64(file, (z_off64_t)offset, whence); @@ -454,9 +417,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence) } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gztell64(file) - gzFile file; -{ +z_off64_t ZEXPORT gztell64(gzFile file) { gz_statep state; /* get internal structure and check integrity */ @@ -471,9 +432,7 @@ z_off64_t ZEXPORT gztell64(file) } /* -- see zlib.h -- */ -z_off_t ZEXPORT gztell(file) - gzFile file; -{ +z_off_t ZEXPORT gztell(gzFile file) { z_off64_t ret; ret = gztell64(file); @@ -481,9 +440,7 @@ z_off_t ZEXPORT gztell(file) } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gzoffset64(file) - gzFile file; -{ +z_off64_t ZEXPORT gzoffset64(gzFile file) { z_off64_t offset; gz_statep state; @@ -504,9 +461,7 @@ z_off64_t ZEXPORT gzoffset64(file) } /* -- see zlib.h -- */ -z_off_t ZEXPORT gzoffset(file) - gzFile file; -{ +z_off_t ZEXPORT gzoffset(gzFile file) { z_off64_t ret; ret = gzoffset64(file); @@ -514,9 +469,7 @@ z_off_t ZEXPORT gzoffset(file) } /* -- see zlib.h -- */ -int ZEXPORT gzeof(file) - gzFile file; -{ +int ZEXPORT gzeof(gzFile file) { gz_statep state; /* get internal structure and check integrity */ @@ -531,10 +484,7 @@ int ZEXPORT gzeof(file) } /* -- see zlib.h -- */ -const char * ZEXPORT gzerror(file, errnum) - gzFile file; - int *errnum; -{ +const char * ZEXPORT gzerror(gzFile file, int *errnum) { gz_statep state; /* get internal structure and check integrity */ @@ -552,9 +502,7 @@ const char * ZEXPORT gzerror(file, errnum) } /* -- see zlib.h -- */ -void ZEXPORT gzclearerr(file) - gzFile file; -{ +void ZEXPORT gzclearerr(gzFile file) { gz_statep state; /* get internal structure and check integrity */ @@ -578,11 +526,7 @@ void ZEXPORT gzclearerr(file) memory). Simply save the error message as a static string. If there is an allocation failure constructing the error message, then convert the error to out of memory. */ -void ZLIB_INTERNAL gz_error(state, err, msg) - gz_statep state; - int err; - const char *msg; -{ +void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { /* free previously allocated message and clear */ if (state->msg != NULL) { if (state->err != Z_MEM_ERROR) @@ -619,21 +563,20 @@ void ZLIB_INTERNAL gz_error(state, err, msg) #endif } -#ifndef INT_MAX /* portably return maximum value for an int (when limits.h presumed not available) -- we need to do this to cover cases where 2's complement not used, since C standard permits 1's complement and sign-bit representations, otherwise we could just use ((unsigned)-1) >> 1 */ -unsigned ZLIB_INTERNAL gz_intmax() -{ - unsigned p, q; - - p = 1; +unsigned ZLIB_INTERNAL gz_intmax(void) { +#ifdef INT_MAX + return INT_MAX; +#else + unsigned p = 1, q; do { q = p; p <<= 1; p++; } while (p > q); return q >> 1; -} #endif +} diff --git a/cdk/extra/zlib/gzread.c b/cdk/extra/zlib/gzread.c index dd7738159..4168cbc88 100644 --- a/cdk/extra/zlib/gzread.c +++ b/cdk/extra/zlib/gzread.c @@ -5,25 +5,12 @@ #include "gzguts.h" -/* Local functions */ -local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); -local int gz_avail OF((gz_statep)); -local int gz_look OF((gz_statep)); -local int gz_decomp OF((gz_statep)); -local int gz_fetch OF((gz_statep)); -local int gz_skip OF((gz_statep, z_off64_t)); -local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); - /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from state->fd, and update state->eof, state->err, and state->msg as appropriate. This function needs to loop on read(), since read() is not guaranteed to read the number of bytes requested, depending on the type of descriptor. */ -local int gz_load(state, buf, len, have) - gz_statep state; - unsigned char *buf; - unsigned len; - unsigned *have; -{ +local int gz_load(gz_statep state, unsigned char *buf, unsigned len, + unsigned *have) { int ret; unsigned get, max = ((unsigned)-1 >> 2) + 1; @@ -53,9 +40,7 @@ local int gz_load(state, buf, len, have) If strm->avail_in != 0, then the current data is moved to the beginning of the input buffer, and then the remainder of the buffer is loaded with the available data from the input file. */ -local int gz_avail(state) - gz_statep state; -{ +local int gz_avail(gz_statep state) { unsigned got; z_streamp strm = &(state->strm); @@ -88,9 +73,7 @@ local int gz_avail(state) case, all further file reads will be directly to either the output buffer or a user buffer. If decompressing, the inflate state will be initialized. gz_look() will return 0 on success or -1 on failure. */ -local int gz_look(state) - gz_statep state; -{ +local int gz_look(gz_statep state) { z_streamp strm = &(state->strm); /* allocate read buffers and inflate memory */ @@ -170,9 +153,7 @@ local int gz_look(state) data. If the gzip stream completes, state->how is reset to LOOK to look for the next gzip stream or raw data, once state->x.have is depleted. Returns 0 on success, -1 on failure. */ -local int gz_decomp(state) - gz_statep state; -{ +local int gz_decomp(gz_statep state) { int ret = Z_OK; unsigned had; z_streamp strm = &(state->strm); @@ -224,9 +205,7 @@ local int gz_decomp(state) looked for to determine whether to copy or decompress. Returns -1 on error, otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the end of the input file has been reached and all data has been processed. */ -local int gz_fetch(state) - gz_statep state; -{ +local int gz_fetch(gz_statep state) { z_streamp strm = &(state->strm); do { @@ -254,10 +233,7 @@ local int gz_fetch(state) } /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ -local int gz_skip(state, len) - gz_statep state; - z_off64_t len; -{ +local int gz_skip(gz_statep state, z_off64_t len) { unsigned n; /* skip over len bytes or reach end-of-file, whichever comes first */ @@ -289,11 +265,7 @@ local int gz_skip(state, len) input. Return the number of bytes read. If zero is returned, either the end of file was reached, or there was an error. state->err must be consulted in that case to determine which. */ -local z_size_t gz_read(state, buf, len) - gz_statep state; - voidp buf; - z_size_t len; -{ +local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) { z_size_t got; unsigned n; @@ -370,11 +342,7 @@ local z_size_t gz_read(state, buf, len) } /* -- see zlib.h -- */ -int ZEXPORT gzread(file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ +int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) { gz_statep state; /* get internal structure */ @@ -406,12 +374,7 @@ int ZEXPORT gzread(file, buf, len) } /* -- see zlib.h -- */ -z_size_t ZEXPORT gzfread(buf, size, nitems, file) - voidp buf; - z_size_t size; - z_size_t nitems; - gzFile file; -{ +z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) { z_size_t len; gz_statep state; @@ -442,9 +405,7 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file) #else # undef gzgetc #endif -int ZEXPORT gzgetc(file) - gzFile file; -{ +int ZEXPORT gzgetc(gzFile file) { unsigned char buf[1]; gz_statep state; @@ -469,17 +430,12 @@ int ZEXPORT gzgetc(file) return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; } -int ZEXPORT gzgetc_(file) -gzFile file; -{ +int ZEXPORT gzgetc_(gzFile file) { return gzgetc(file); } /* -- see zlib.h -- */ -int ZEXPORT gzungetc(c, file) - int c; - gzFile file; -{ +int ZEXPORT gzungetc(int c, gzFile file) { gz_statep state; /* get internal structure */ @@ -487,6 +443,10 @@ int ZEXPORT gzungetc(c, file) return -1; state = (gz_statep)file; + /* in case this was just opened, set up the input buffer */ + if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) + (void)gz_look(state); + /* check that we're reading and that there's no (serious) error */ if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR)) @@ -536,11 +496,7 @@ int ZEXPORT gzungetc(c, file) } /* -- see zlib.h -- */ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ +char * ZEXPORT gzgets(gzFile file, char *buf, int len) { unsigned left, n; char *str; unsigned char *eol; @@ -600,9 +556,7 @@ char * ZEXPORT gzgets(file, buf, len) } /* -- see zlib.h -- */ -int ZEXPORT gzdirect(file) - gzFile file; -{ +int ZEXPORT gzdirect(gzFile file) { gz_statep state; /* get internal structure */ @@ -620,9 +574,7 @@ int ZEXPORT gzdirect(file) } /* -- see zlib.h -- */ -int ZEXPORT gzclose_r(file) - gzFile file; -{ +int ZEXPORT gzclose_r(gzFile file) { int ret, err; gz_statep state; diff --git a/cdk/extra/zlib/gzwrite.c b/cdk/extra/zlib/gzwrite.c index eb8a0e589..435b4621b 100644 --- a/cdk/extra/zlib/gzwrite.c +++ b/cdk/extra/zlib/gzwrite.c @@ -5,18 +5,10 @@ #include "gzguts.h" -/* Local functions */ -local int gz_init OF((gz_statep)); -local int gz_comp OF((gz_statep, int)); -local int gz_zero OF((gz_statep, z_off64_t)); -local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); - /* Initialize state for writing a gzip file. Mark initialization by setting state->size to non-zero. Return -1 on a memory allocation failure, or 0 on success. */ -local int gz_init(state) - gz_statep state; -{ +local int gz_init(gz_statep state) { int ret; z_streamp strm = &(state->strm); @@ -70,10 +62,7 @@ local int gz_init(state) deflate() flush value. If flush is Z_FINISH, then the deflate() state is reset to start a new gzip stream. If gz->direct is true, then simply write to the output file without compressing, and ignore flush. */ -local int gz_comp(state, flush) - gz_statep state; - int flush; -{ +local int gz_comp(gz_statep state, int flush) { int ret, writ; unsigned have, put, max = ((unsigned)-1 >> 2) + 1; z_streamp strm = &(state->strm); @@ -151,10 +140,7 @@ local int gz_comp(state, flush) /* Compress len zeros to output. Return -1 on a write error or memory allocation failure by gz_comp(), or 0 on success. */ -local int gz_zero(state, len) - gz_statep state; - z_off64_t len; -{ +local int gz_zero(gz_statep state, z_off64_t len) { int first; unsigned n; z_streamp strm = &(state->strm); @@ -184,11 +170,7 @@ local int gz_zero(state, len) /* Write len bytes from buf to file. Return the number of bytes written. If the returned value is less than len, then there was an error. */ -local z_size_t gz_write(state, buf, len) - gz_statep state; - voidpc buf; - z_size_t len; -{ +local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) { z_size_t put = len; /* if len is zero, avoid unnecessary operations */ @@ -252,11 +234,7 @@ local z_size_t gz_write(state, buf, len) } /* -- see zlib.h -- */ -int ZEXPORT gzwrite(file, buf, len) - gzFile file; - voidpc buf; - unsigned len; -{ +int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { gz_statep state; /* get internal structure */ @@ -280,12 +258,8 @@ int ZEXPORT gzwrite(file, buf, len) } /* -- see zlib.h -- */ -z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) - voidpc buf; - z_size_t size; - z_size_t nitems; - gzFile file; -{ +z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, + gzFile file) { z_size_t len; gz_statep state; @@ -310,10 +284,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) } /* -- see zlib.h -- */ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ +int ZEXPORT gzputc(gzFile file, int c) { unsigned have; unsigned char buf[1]; gz_statep state; @@ -358,10 +329,7 @@ int ZEXPORT gzputc(file, c) } /* -- see zlib.h -- */ -int ZEXPORT gzputs(file, s) - gzFile file; - const char *s; -{ +int ZEXPORT gzputs(gzFile file, const char *s) { z_size_t len, put; gz_statep state; @@ -388,8 +356,7 @@ int ZEXPORT gzputs(file, s) #include /* -- see zlib.h -- */ -int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) -{ +int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { int len; unsigned left; char *next; @@ -460,8 +427,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) return len; } -int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) -{ +int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) { va_list va; int ret; @@ -474,13 +440,10 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) #else /* !STDC && !Z_HAVE_STDARG_H */ /* -- see zlib.h -- */ -int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ +int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3, + int a4, int a5, int a6, int a7, int a8, int a9, int a10, + int a11, int a12, int a13, int a14, int a15, int a16, + int a17, int a18, int a19, int a20) { unsigned len, left; char *next; gz_statep state; @@ -562,10 +525,7 @@ int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, #endif /* -- see zlib.h -- */ -int ZEXPORT gzflush(file, flush) - gzFile file; - int flush; -{ +int ZEXPORT gzflush(gzFile file, int flush) { gz_statep state; /* get internal structure */ @@ -594,11 +554,7 @@ int ZEXPORT gzflush(file, flush) } /* -- see zlib.h -- */ -int ZEXPORT gzsetparams(file, level, strategy) - gzFile file; - int level; - int strategy; -{ +int ZEXPORT gzsetparams(gzFile file, int level, int strategy) { gz_statep state; z_streamp strm; @@ -609,7 +565,7 @@ int ZEXPORT gzsetparams(file, level, strategy) strm = &(state->strm); /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) + if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct) return Z_STREAM_ERROR; /* if no change is requested, then do nothing */ @@ -636,9 +592,7 @@ int ZEXPORT gzsetparams(file, level, strategy) } /* -- see zlib.h -- */ -int ZEXPORT gzclose_w(file) - gzFile file; -{ +int ZEXPORT gzclose_w(gzFile file) { int ret = Z_OK; gz_statep state; diff --git a/cdk/extra/zlib/infback.c b/cdk/extra/zlib/infback.c index babeaf180..e7b25b307 100644 --- a/cdk/extra/zlib/infback.c +++ b/cdk/extra/zlib/infback.c @@ -15,9 +15,6 @@ #include "inflate.h" #include "inffast.h" -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - /* strm provides memory allocation functions in zalloc and zfree, or Z_NULL to use the library memory allocation functions. @@ -25,13 +22,9 @@ local void fixedtables OF((struct inflate_state FAR *state)); windowBits is in the range 8..15, and window is a user-supplied window and output buffer that is 2**windowBits bytes. */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ +int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, + unsigned char FAR *window, const char *version, + int stream_size) { struct inflate_state FAR *state; if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || @@ -80,9 +73,7 @@ int stream_size; used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ +local void fixedtables(struct inflate_state FAR *state) { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; @@ -248,13 +239,8 @@ struct inflate_state FAR *state; inflateBack() can also return Z_STREAM_ERROR if the input parameters are not correct, i.e. strm is Z_NULL or the state was not initialized. */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ +int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc) { struct inflate_state FAR *state; z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ @@ -632,9 +618,7 @@ void FAR *out_desc; return ret; } -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ +int ZEXPORT inflateBackEnd(z_streamp strm) { if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; ZFREE(strm, strm->state); diff --git a/cdk/extra/zlib/inffast.c b/cdk/extra/zlib/inffast.c index 1fec7f363..9354676e7 100644 --- a/cdk/extra/zlib/inffast.c +++ b/cdk/extra/zlib/inffast.c @@ -47,10 +47,7 @@ requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ -void ZLIB_INTERNAL inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) { struct inflate_state FAR *state; z_const unsigned char FAR *in; /* local strm->next_in */ z_const unsigned char FAR *last; /* have enough input while in < last */ diff --git a/cdk/extra/zlib/inffast.h b/cdk/extra/zlib/inffast.h index e5c1aa4ca..49c6d156c 100644 --- a/cdk/extra/zlib/inffast.h +++ b/cdk/extra/zlib/inffast.h @@ -8,4 +8,4 @@ subject to change. Applications should only use zlib.h. */ -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start); diff --git a/cdk/extra/zlib/inflate.c b/cdk/extra/zlib/inflate.c index 8acbef44e..94ecff015 100644 --- a/cdk/extra/zlib/inflate.c +++ b/cdk/extra/zlib/inflate.c @@ -91,20 +91,7 @@ # endif #endif -/* function prototypes */ -local int inflateStateCheck OF((z_streamp strm)); -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, - unsigned copy)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, - unsigned len)); - -local int inflateStateCheck(strm) -z_streamp strm; -{ +local int inflateStateCheck(z_streamp strm) { struct inflate_state FAR *state; if (strm == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) @@ -116,9 +103,7 @@ z_streamp strm; return 0; } -int ZEXPORT inflateResetKeep(strm) -z_streamp strm; -{ +int ZEXPORT inflateResetKeep(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -142,9 +127,7 @@ z_streamp strm; return Z_OK; } -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ +int ZEXPORT inflateReset(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -155,10 +138,7 @@ z_streamp strm; return inflateResetKeep(strm); } -int ZEXPORT inflateReset2(strm, windowBits) -z_streamp strm; -int windowBits; -{ +int ZEXPORT inflateReset2(z_streamp strm, int windowBits) { int wrap; struct inflate_state FAR *state; @@ -195,12 +175,8 @@ int windowBits; return inflateReset(strm); } -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ +int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size) { int ret; struct inflate_state FAR *state; @@ -239,22 +215,17 @@ int stream_size; return ret; } -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ +int ZEXPORT inflateInit_(z_streamp strm, const char *version, + int stream_size) { return inflateInit2_(strm, DEF_WBITS, version, stream_size); } -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ +int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + if (bits == 0) + return Z_OK; state = (struct inflate_state FAR *)strm->state; if (bits < 0) { state->hold = 0; @@ -278,9 +249,7 @@ int value; used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ +local void fixedtables(struct inflate_state FAR *state) { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; @@ -342,7 +311,7 @@ struct inflate_state FAR *state; a.out > inffixed.h */ -void makefixed() +void makefixed(void) { unsigned low, size; struct inflate_state state; @@ -396,11 +365,7 @@ void makefixed() output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ -local int updatewindow(strm, end, copy) -z_streamp strm; -const Bytef *end; -unsigned copy; -{ +local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) { struct inflate_state FAR *state; unsigned dist; @@ -622,10 +587,7 @@ unsigned copy; will return Z_BUF_ERROR if it has not reached the end of the stream. */ -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ +int ZEXPORT inflate(z_streamp strm, int flush) { struct inflate_state FAR *state; z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ @@ -1301,9 +1263,7 @@ int flush; return ret; } -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ +int ZEXPORT inflateEnd(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1315,11 +1275,8 @@ z_streamp strm; return Z_OK; } -int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) -z_streamp strm; -Bytef *dictionary; -uInt *dictLength; -{ +int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, + uInt *dictLength) { struct inflate_state FAR *state; /* check state */ @@ -1338,11 +1295,8 @@ uInt *dictLength; return Z_OK; } -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ +int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, + uInt dictLength) { struct inflate_state FAR *state; unsigned long dictid; int ret; @@ -1373,10 +1327,7 @@ uInt dictLength; return Z_OK; } -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ +int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) { struct inflate_state FAR *state; /* check state */ @@ -1401,11 +1352,8 @@ gz_headerp head; called again with more data and the *have state. *have is initialized to zero for the first call. */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -const unsigned char FAR *buf; -unsigned len; -{ +local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, + unsigned len) { unsigned got; unsigned next; @@ -1424,9 +1372,7 @@ unsigned len; return next; } -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ +int ZEXPORT inflateSync(z_streamp strm) { unsigned len; /* number of bytes to look at or looked at */ int flags; /* temporary to save header status */ unsigned long in, out; /* temporary to save total_in and total_out */ @@ -1441,7 +1387,7 @@ z_streamp strm; /* if first time, start search in bit buffer */ if (state->mode != SYNC) { state->mode = SYNC; - state->hold <<= state->bits & 7; + state->hold >>= state->bits & 7; state->bits -= state->bits & 7; len = 0; while (state->bits >= 8) { @@ -1482,9 +1428,7 @@ z_streamp strm; block. When decompressing, PPP checks that at the end of input packet, inflate is waiting for these length bytes. */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ +int ZEXPORT inflateSyncPoint(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1492,10 +1436,7 @@ z_streamp strm; return state->mode == STORED && state->bits == 0; } -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ +int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { struct inflate_state FAR *state; struct inflate_state FAR *copy; unsigned char FAR *window; @@ -1539,10 +1480,7 @@ z_streamp source; return Z_OK; } -int ZEXPORT inflateUndermine(strm, subvert) -z_streamp strm; -int subvert; -{ +int ZEXPORT inflateUndermine(z_streamp strm, int subvert) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1557,10 +1495,7 @@ int subvert; #endif } -int ZEXPORT inflateValidate(strm, check) -z_streamp strm; -int check; -{ +int ZEXPORT inflateValidate(z_streamp strm, int check) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1572,9 +1507,7 @@ int check; return Z_OK; } -long ZEXPORT inflateMark(strm) -z_streamp strm; -{ +long ZEXPORT inflateMark(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) @@ -1585,9 +1518,7 @@ z_streamp strm; (state->mode == MATCH ? state->was - state->length : 0)); } -unsigned long ZEXPORT inflateCodesUsed(strm) -z_streamp strm; -{ +unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return (unsigned long)-1; state = (struct inflate_state FAR *)strm->state; diff --git a/cdk/extra/zlib/inftrees.c b/cdk/extra/zlib/inftrees.c index 57d2793be..98cfe1644 100644 --- a/cdk/extra/zlib/inftrees.c +++ b/cdk/extra/zlib/inftrees.c @@ -1,5 +1,5 @@ /* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2022 Mark Adler + * Copyright (C) 1995-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.2.13 Copyright 1995-2022 Mark Adler "; + " inflate 1.3.1 Copyright 1995-2024 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -29,14 +29,9 @@ const char inflate_copyright[] = table index bits. It will differ if the request is greater than the longest code or if it is less than the shortest code. */ -int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work) { unsigned len; /* a code's length in bits */ unsigned sym; /* index of code symbols */ unsigned min, max; /* minimum and maximum code lengths */ @@ -62,7 +57,7 @@ unsigned short FAR *work; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 194, 65}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, diff --git a/cdk/extra/zlib/inftrees.h b/cdk/extra/zlib/inftrees.h index f53665311..396f74b5d 100644 --- a/cdk/extra/zlib/inftrees.h +++ b/cdk/extra/zlib/inftrees.h @@ -41,8 +41,8 @@ typedef struct { examples/enough.c found in the zlib distribution. The arguments to that program are the number of symbols, the initial root table size, and the maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 30 6 15" for distance codes returns 592. - The initial root table size (9 or 6) is found in the fifth argument of the + returns 852, and "enough 30 6 15" for distance codes returns 592. The + initial root table size (9 or 6) is found in the fifth argument of the inflate_table() calls in inflate.c and infback.c. If the root table size is changed, then these maximum sizes would be need to be recalculated and updated. */ @@ -57,6 +57,6 @@ typedef enum { DISTS } codetype; -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work); diff --git a/cdk/extra/zlib/old/visual-basic.txt b/cdk/extra/zlib/old/visual-basic.txt index 57efe5812..3c8d2a42d 100644 --- a/cdk/extra/zlib/old/visual-basic.txt +++ b/cdk/extra/zlib/old/visual-basic.txt @@ -115,7 +115,7 @@ SUCCESS Then ReDim Preserve bytaryCpr(lngCprSiz - 1) Open strCprPth For Binary Access Write As #1 Put #1, , bytaryCpr() - Put #1, , lngOriSiz 'Add the the original size value to the end + Put #1, , lngOriSiz 'Add the original size value to the end (last 4 bytes) Close #1 Else diff --git a/cdk/extra/zlib/os400/README400 b/cdk/extra/zlib/os400/README400 index c06fa8459..30ed5a12c 100644 --- a/cdk/extra/zlib/os400/README400 +++ b/cdk/extra/zlib/os400/README400 @@ -1,4 +1,4 @@ - ZLIB version 1.2.13 for OS/400 installation instructions + ZLIB version 1.3.1 for OS/400 installation instructions 1) Download and unpack the zlib tarball to some IFS directory. (i.e.: /path/to/the/zlib/ifs/source/directory) diff --git a/cdk/extra/zlib/os400/zlib.inc b/cdk/extra/zlib/os400/zlib.inc index c273c863c..744729ab9 100644 --- a/cdk/extra/zlib/os400/zlib.inc +++ b/cdk/extra/zlib/os400/zlib.inc @@ -1,7 +1,7 @@ * ZLIB.INC - Interface to the general purpose compression library * * ILE RPG400 version by Patrick Monnerat, DATASPHERE. - * Version 1.2.13 + * Version 1.3.1 * * * WARNING: @@ -22,12 +22,12 @@ * * Versioning information. * - D ZLIB_VERSION C '1.2.13' + D ZLIB_VERSION C '1.3.1' D ZLIB_VERNUM C X'12a0' D ZLIB_VER_MAJOR C 1 - D ZLIB_VER_MINOR C 2 + D ZLIB_VER_MINOR C 3 D ZLIB_VER_REVISION... - D C 13 + D C 1 D ZLIB_VER_SUBREVISION... D C 0 * diff --git a/cdk/extra/zlib/qnx/package.qpg b/cdk/extra/zlib/qnx/package.qpg index ba2f1a2d6..4877e0ef0 100644 --- a/cdk/extra/zlib/qnx/package.qpg +++ b/cdk/extra/zlib/qnx/package.qpg @@ -25,10 +25,10 @@ - - - - + + + + @@ -63,7 +63,7 @@ - 1.2.13 + 1.3.1 Medium Stable diff --git a/cdk/extra/zlib/test/example.c b/cdk/extra/zlib/test/example.c index 1470bc842..c3521dd59 100644 --- a/cdk/extra/zlib/test/example.c +++ b/cdk/extra/zlib/test/example.c @@ -34,37 +34,14 @@ static z_const char hello[] = "hello, hello!"; static const char dictionary[] = "hello"; static uLong dictId; /* Adler32 value of the dictionary */ -void test_deflate OF((Byte *compr, uLong comprLen)); -void test_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_large_deflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_large_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_flush OF((Byte *compr, uLong *comprLen)); -void test_sync OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_dict_deflate OF((Byte *compr, uLong comprLen)); -void test_dict_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -int main OF((int argc, char *argv[])); - - #ifdef Z_SOLO -void *myalloc OF((void *, unsigned, unsigned)); -void myfree OF((void *, void *)); - -void *myalloc(q, n, m) - void *q; - unsigned n, m; -{ +static void *myalloc(void *q, unsigned n, unsigned m) { (void)q; return calloc(n, m); } -void myfree(void *q, void *p) -{ +static void myfree(void *q, void *p) { (void)q; free(p); } @@ -77,18 +54,11 @@ static free_func zfree = myfree; static alloc_func zalloc = (alloc_func)0; static free_func zfree = (free_func)0; -void test_compress OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_gzio OF((const char *fname, - Byte *uncompr, uLong uncomprLen)); - /* =========================================================================== * Test compress() and uncompress() */ -void test_compress(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ +static void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, + uLong uncomprLen) { int err; uLong len = (uLong)strlen(hello)+1; @@ -111,11 +81,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) /* =========================================================================== * Test read/write of .gz files */ -void test_gzio(fname, uncompr, uncomprLen) - const char *fname; /* compressed file name */ - Byte *uncompr; - uLong uncomprLen; -{ +static void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) { #ifdef NO_GZCOMPRESS fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); #else @@ -197,10 +163,7 @@ void test_gzio(fname, uncompr, uncomprLen) /* =========================================================================== * Test deflate() with small buffers */ -void test_deflate(compr, comprLen) - Byte *compr; - uLong comprLen; -{ +static void test_deflate(Byte *compr, uLong comprLen) { z_stream c_stream; /* compression stream */ int err; uLong len = (uLong)strlen(hello)+1; @@ -235,10 +198,8 @@ void test_deflate(compr, comprLen) /* =========================================================================== * Test inflate() with small buffers */ -void test_inflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ +static void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, + uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -276,10 +237,8 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen) /* =========================================================================== * Test deflate() with large buffers and dynamic change of compression level */ -void test_large_deflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ +static void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, + uLong uncomprLen) { z_stream c_stream; /* compression stream */ int err; @@ -308,7 +267,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) /* Feed in already compressed data and switch to no compression: */ deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); c_stream.next_in = compr; - c_stream.avail_in = (uInt)comprLen/2; + c_stream.avail_in = (uInt)uncomprLen/2; err = deflate(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); @@ -331,10 +290,8 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) /* =========================================================================== * Test inflate() with large buffers */ -void test_large_inflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ +static void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, + uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -361,7 +318,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); - if (d_stream.total_out != 2*uncomprLen + comprLen/2) { + if (d_stream.total_out != 2*uncomprLen + uncomprLen/2) { fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); exit(1); } else { @@ -372,10 +329,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) /* =========================================================================== * Test deflate() with full flush */ -void test_flush(compr, comprLen) - Byte *compr; - uLong *comprLen; -{ +static void test_flush(Byte *compr, uLong *comprLen) { z_stream c_stream; /* compression stream */ int err; uInt len = (uInt)strlen(hello)+1; @@ -410,10 +364,8 @@ void test_flush(compr, comprLen) /* =========================================================================== * Test inflateSync() */ -void test_sync(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ +static void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, + uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -453,10 +405,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) /* =========================================================================== * Test deflate() with preset dictionary */ -void test_dict_deflate(compr, comprLen) - Byte *compr; - uLong comprLen; -{ +static void test_dict_deflate(Byte *compr, uLong comprLen) { z_stream c_stream; /* compression stream */ int err; @@ -490,10 +439,8 @@ void test_dict_deflate(compr, comprLen) /* =========================================================================== * Test inflate() with a preset dictionary */ -void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ +static void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, + uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -541,13 +488,10 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) * Usage: example [output.gz [input.gz]] */ -int main(argc, argv) - int argc; - char *argv[]; -{ +int main(int argc, char *argv[]) { Byte *compr, *uncompr; - uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ - uLong uncomprLen = comprLen; + uLong uncomprLen = 20000; + uLong comprLen = 3 * uncomprLen; static const char* myVersion = ZLIB_VERSION; if (zlibVersion()[0] != myVersion[0]) { @@ -590,7 +534,7 @@ int main(argc, argv) test_flush(compr, &comprLen); test_sync(compr, comprLen, uncompr, uncomprLen); - comprLen = uncomprLen; + comprLen = 3 * uncomprLen; test_dict_deflate(compr, comprLen); test_dict_inflate(compr, comprLen, uncompr, uncomprLen); diff --git a/cdk/extra/zlib/test/infcover.c b/cdk/extra/zlib/test/infcover.c index 2be01646c..8912c403d 100644 --- a/cdk/extra/zlib/test/infcover.c +++ b/cdk/extra/zlib/test/infcover.c @@ -373,7 +373,7 @@ local void cover_support(void) mem_setup(&strm); strm.avail_in = 0; strm.next_in = Z_NULL; - ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream)); + ret = inflateInit_(&strm, "!", (int)sizeof(z_stream)); assert(ret == Z_VERSION_ERROR); mem_done(&strm, "wrong version"); @@ -462,7 +462,8 @@ local unsigned pull(void *desc, unsigned char **buf) local int push(void *desc, unsigned char *buf, unsigned len) { - buf += len; + (void)buf; + (void)len; return desc != Z_NULL; /* force error if desc not null */ } diff --git a/cdk/extra/zlib/test/minigzip.c b/cdk/extra/zlib/test/minigzip.c index a649d2b3d..134e10e6c 100644 --- a/cdk/extra/zlib/test/minigzip.c +++ b/cdk/extra/zlib/test/minigzip.c @@ -59,7 +59,7 @@ #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ - extern int unlink OF((const char *)); + extern int unlink(const char *); #endif #endif @@ -149,20 +149,12 @@ static void pwinerror (s) # include /* for unlink() */ #endif -void *myalloc OF((void *, unsigned, unsigned)); -void myfree OF((void *, void *)); - -void *myalloc(q, n, m) - void *q; - unsigned n, m; -{ +static void *myalloc(void *q, unsigned n, unsigned m) { (void)q; return calloc(n, m); } -void myfree(q, p) - void *q, *p; -{ +static void myfree(void *q, void *p) { (void)q; free(p); } @@ -175,29 +167,7 @@ typedef struct gzFile_s { z_stream strm; } *gzFile; -gzFile gzopen OF((const char *, const char *)); -gzFile gzdopen OF((int, const char *)); -gzFile gz_open OF((const char *, int, const char *)); - -gzFile gzopen(path, mode) -const char *path; -const char *mode; -{ - return gz_open(path, -1, mode); -} - -gzFile gzdopen(fd, mode) -int fd; -const char *mode; -{ - return gz_open(NULL, fd, mode); -} - -gzFile gz_open(path, fd, mode) - const char *path; - int fd; - const char *mode; -{ +static gzFile gz_open(const char *path, int fd, const char *mode) { gzFile gz; int ret; @@ -231,13 +201,15 @@ gzFile gz_open(path, fd, mode) return gz; } -int gzwrite OF((gzFile, const void *, unsigned)); +static gzFile gzopen(const char *path, const char *mode) { + return gz_open(path, -1, mode); +} -int gzwrite(gz, buf, len) - gzFile gz; - const void *buf; - unsigned len; -{ +static gzFile gzdopen(int fd, const char *mode) { + return gz_open(NULL, fd, mode); +} + +static int gzwrite(gzFile gz, const void *buf, unsigned len) { z_stream *strm; unsigned char out[BUFLEN]; @@ -255,13 +227,7 @@ int gzwrite(gz, buf, len) return len; } -int gzread OF((gzFile, void *, unsigned)); - -int gzread(gz, buf, len) - gzFile gz; - void *buf; - unsigned len; -{ +static int gzread(gzFile gz, void *buf, unsigned len) { int ret; unsigned got; unsigned char in[1]; @@ -292,11 +258,7 @@ int gzread(gz, buf, len) return len - strm->avail_out; } -int gzclose OF((gzFile)); - -int gzclose(gz) - gzFile gz; -{ +static int gzclose(gzFile gz) { z_stream *strm; unsigned char out[BUFLEN]; @@ -321,12 +283,7 @@ int gzclose(gz) return Z_OK; } -const char *gzerror OF((gzFile, int *)); - -const char *gzerror(gz, err) - gzFile gz; - int *err; -{ +static const char *gzerror(gzFile gz, int *err) { *err = gz->err; return gz->msg; } @@ -335,67 +292,20 @@ const char *gzerror(gz, err) static char *prog; -void error OF((const char *msg)); -void gz_compress OF((FILE *in, gzFile out)); -#ifdef USE_MMAP -int gz_compress_mmap OF((FILE *in, gzFile out)); -#endif -void gz_uncompress OF((gzFile in, FILE *out)); -void file_compress OF((char *file, char *mode)); -void file_uncompress OF((char *file)); -int main OF((int argc, char *argv[])); - /* =========================================================================== * Display error message and exit */ -void error(msg) - const char *msg; -{ +static void error(const char *msg) { fprintf(stderr, "%s: %s\n", prog, msg); exit(1); } -/* =========================================================================== - * Compress input to output then close both files. - */ - -void gz_compress(in, out) - FILE *in; - gzFile out; -{ - local char buf[BUFLEN]; - int len; - int err; - -#ifdef USE_MMAP - /* Try first compressing with mmap. If mmap fails (minigzip used in a - * pipe), use the normal fread loop. - */ - if (gz_compress_mmap(in, out) == Z_OK) return; -#endif - for (;;) { - len = (int)fread(buf, 1, sizeof(buf), in); - if (ferror(in)) { - perror("fread"); - exit(1); - } - if (len == 0) break; - - if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); - } - fclose(in); - if (gzclose(out) != Z_OK) error("failed gzclose"); -} - #ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ /* Try compressing the input file at once using mmap. Return Z_OK if - * if success, Z_ERRNO otherwise. + * success, Z_ERRNO otherwise. */ -int gz_compress_mmap(in, out) - FILE *in; - gzFile out; -{ +static int gz_compress_mmap(FILE *in, gzFile out) { int len; int err; int ifd = fileno(in); @@ -424,13 +334,39 @@ int gz_compress_mmap(in, out) } #endif /* USE_MMAP */ +/* =========================================================================== + * Compress input to output then close both files. + */ + +static void gz_compress(FILE *in, gzFile out) { + local char buf[BUFLEN]; + int len; + int err; + +#ifdef USE_MMAP + /* Try first compressing with mmap. If mmap fails (minigzip used in a + * pipe), use the normal fread loop. + */ + if (gz_compress_mmap(in, out) == Z_OK) return; +#endif + for (;;) { + len = (int)fread(buf, 1, sizeof(buf), in); + if (ferror(in)) { + perror("fread"); + exit(1); + } + if (len == 0) break; + + if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); + } + fclose(in); + if (gzclose(out) != Z_OK) error("failed gzclose"); +} + /* =========================================================================== * Uncompress input to output then close both files. */ -void gz_uncompress(in, out) - gzFile in; - FILE *out; -{ +static void gz_uncompress(gzFile in, FILE *out) { local char buf[BUFLEN]; int len; int err; @@ -454,10 +390,7 @@ void gz_uncompress(in, out) * Compress the given file: create a corresponding .gz file and remove the * original. */ -void file_compress(file, mode) - char *file; - char *mode; -{ +static void file_compress(char *file, char *mode) { local char outfile[MAX_NAME_LEN]; FILE *in; gzFile out; @@ -493,9 +426,7 @@ void file_compress(file, mode) /* =========================================================================== * Uncompress the given file and remove the original. */ -void file_uncompress(file) - char *file; -{ +static void file_uncompress(char *file) { local char buf[MAX_NAME_LEN]; char *infile, *outfile; FILE *out; @@ -553,10 +484,7 @@ void file_uncompress(file) * -1 to -9 : compression level */ -int main(argc, argv) - int argc; - char *argv[]; -{ +int main(int argc, char *argv[]) { int copyout = 0; int uncompr = 0; gzFile file; diff --git a/cdk/extra/zlib/treebuild.xml b/cdk/extra/zlib/treebuild.xml index 0017a45d3..930b00be4 100644 --- a/cdk/extra/zlib/treebuild.xml +++ b/cdk/extra/zlib/treebuild.xml @@ -1,6 +1,6 @@ - - + + zip compression library diff --git a/cdk/extra/zlib/trees.c b/cdk/extra/zlib/trees.c index 5f305c472..6a523ef34 100644 --- a/cdk/extra/zlib/trees.c +++ b/cdk/extra/zlib/trees.c @@ -1,5 +1,5 @@ /* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2021 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * detect_data_type() function provided freely by Cosmin Truta, 2006 * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -122,39 +122,116 @@ struct static_tree_desc_s { int max_length; /* max bit length for the codes */ }; -local const static_tree_desc static_l_desc = +#ifdef NO_INIT_GLOBAL_POINTERS +# define TCONST +#else +# define TCONST const +#endif + +local TCONST static_tree_desc static_l_desc = {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; -local const static_tree_desc static_d_desc = +local TCONST static_tree_desc static_d_desc = {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; -local const static_tree_desc static_bl_desc = +local TCONST static_tree_desc static_bl_desc = {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; /* =========================================================================== - * Local (static) routines in this file. + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 */ +local unsigned bi_reverse(unsigned code, int len) { + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, const ct_data *ltree, - const ct_data *dtree)); -local int detect_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned code, int len)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush(deflate_state *s) { + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup(deflate_state *s) { + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef ZLIB_DEBUG + s->bits_sent = (s->bits_sent + 7) & ~7; +#endif +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) { + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + unsigned code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + code = (code + bl_count[bits - 1]) << 1; + next_code[bits] = (ush)code; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, + "inconsistent bit counts"); + Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); + + for (n = 0; n <= max_code; n++) { + int len = tree[n].Len; + if (len == 0) continue; + /* Now reverse the bits */ + tree[n].Code = (ush)bi_reverse(next_code[len]++, len); + + Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", + n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); + } +} #ifdef GEN_TREES_H -local void gen_trees_header OF((void)); +local void gen_trees_header(void); #endif #ifndef ZLIB_DEBUG @@ -167,27 +244,12 @@ local void gen_trees_header OF((void)); send_bits(s, tree[c].Code, tree[c].Len); } #endif -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - /* =========================================================================== * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ #ifdef ZLIB_DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ +local void send_bits(deflate_state *s, int value, int length) { Tracevv((stderr," l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); s->bits_sent += (ulg)length; @@ -229,8 +291,7 @@ local void send_bits(s, value, length) /* =========================================================================== * Initialize the various 'constant' tables. */ -local void tr_static_init() -{ +local void tr_static_init(void) { #if defined(GEN_TREES_H) || !defined(STDC) static int static_init_done = 0; int n; /* iterates over tree elements */ @@ -323,8 +384,7 @@ local void tr_static_init() ((i) == (last)? "\n};\n\n" : \ ((i) % (width) == (width) - 1 ? ",\n" : ", ")) -void gen_trees_header() -{ +void gen_trees_header(void) { FILE *header = fopen("trees.h", "w"); int i; @@ -373,12 +433,26 @@ void gen_trees_header() } #endif /* GEN_TREES_H */ +/* =========================================================================== + * Initialize a new block. + */ +local void init_block(deflate_state *s) { + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->sym_next = s->matches = 0; +} + /* =========================================================================== * Initialize the tree data structures for a new zlib stream. */ -void ZLIB_INTERNAL _tr_init(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_init(deflate_state *s) { tr_static_init(); s->l_desc.dyn_tree = s->dyn_ltree; @@ -401,24 +475,6 @@ void ZLIB_INTERNAL _tr_init(s) init_block(s); } -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->sym_next = s->matches = 0; -} - #define SMALLEST 1 /* Index within the heap array of least frequent node in the Huffman tree */ @@ -448,11 +504,7 @@ local void init_block(s) * when the heap property is re-established (each father smaller than its * two sons). */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ +local void pqdownheap(deflate_state *s, ct_data *tree, int k) { int v = s->heap[k]; int j = k << 1; /* left son of k */ while (j <= s->heap_len) { @@ -483,10 +535,7 @@ local void pqdownheap(s, tree, k) * The length opt_len is updated; static_len is also updated if stree is * not null. */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ +local void gen_bitlen(deflate_state *s, tree_desc *desc) { ct_data *tree = desc->dyn_tree; int max_code = desc->max_code; const ct_data *stree = desc->stat_desc->static_tree; @@ -561,48 +610,9 @@ local void gen_bitlen(s, desc) } } -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes(tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - unsigned code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - code = (code + bl_count[bits - 1]) << 1; - next_code[bits] = (ush)code; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, - "inconsistent bit counts"); - Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); - - for (n = 0; n <= max_code; n++) { - int len = tree[n].Len; - if (len == 0) continue; - /* Now reverse the bits */ - tree[n].Code = (ush)bi_reverse(next_code[len]++, len); - - Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", - n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); - } -} +#ifdef DUMP_BL_TREE +# include +#endif /* =========================================================================== * Construct one Huffman tree and assigns the code bit strings and lengths. @@ -612,10 +622,7 @@ local void gen_codes(tree, max_code, bl_count) * and corresponding code. The length opt_len is updated; static_len is * also updated if stree is not null. The field max_code is set. */ -local void build_tree(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ +local void build_tree(deflate_state *s, tree_desc *desc) { ct_data *tree = desc->dyn_tree; const ct_data *stree = desc->stat_desc->static_tree; int elems = desc->stat_desc->elems; @@ -700,11 +707,7 @@ local void build_tree(s, desc) * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. */ -local void scan_tree(s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ +local void scan_tree(deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ @@ -745,11 +748,7 @@ local void scan_tree(s, tree, max_code) * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */ -local void send_tree(s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ +local void send_tree(deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ @@ -796,9 +795,7 @@ local void send_tree(s, tree, max_code) * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ -local int build_bl_tree(s) - deflate_state *s; -{ +local int build_bl_tree(deflate_state *s) { int max_blindex; /* index of last bit length code of non zero freq */ /* Determine the bit length frequencies for literal and distance trees */ @@ -831,10 +828,8 @@ local int build_bl_tree(s) * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ +local void send_all_trees(deflate_state *s, int lcodes, int dcodes, + int blcodes) { int rank; /* index in bl_order */ Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); @@ -860,12 +855,8 @@ local void send_all_trees(s, lcodes, dcodes, blcodes) /* =========================================================================== * Send a stored block */ -void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, + ulg stored_len, int last) { send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */ bi_windup(s); /* align on byte boundary */ put_short(s, (ush)stored_len); @@ -884,9 +875,7 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) /* =========================================================================== * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) */ -void ZLIB_INTERNAL _tr_flush_bits(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) { bi_flush(s); } @@ -894,9 +883,7 @@ void ZLIB_INTERNAL _tr_flush_bits(s) * Send one empty static block to give enough lookahead for inflate. * This takes 10 bits, of which 7 may remain in the bit buffer. */ -void ZLIB_INTERNAL _tr_align(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_align(deflate_state *s) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); #ifdef ZLIB_DEBUG @@ -905,16 +892,108 @@ void ZLIB_INTERNAL _tr_align(s) bi_flush(s); } +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(deflate_state *s, const ct_data *ltree, + const ct_data *dtree) { + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned sx = 0; /* running index in symbol buffers */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->sym_next != 0) do { +#ifdef LIT_MEM + dist = s->d_buf[sx]; + lc = s->l_buf[sx++]; +#else + dist = s->sym_buf[sx++] & 0xff; + dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; + lc = s->sym_buf[sx++]; +#endif + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code + LITERALS + 1, ltree); /* send length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= (unsigned)base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check for no overlay of pending_buf on needed symbols */ +#ifdef LIT_MEM + Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow"); +#else + Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); +#endif + + } while (sx < s->sym_next); + + send_code(s, END_BLOCK, ltree); +} + +/* =========================================================================== + * Check if the data type is TEXT or BINARY, using the following algorithm: + * - TEXT if the two conditions below are satisfied: + * a) There are no non-portable control characters belonging to the + * "block list" (0..6, 14..25, 28..31). + * b) There is at least one printable character belonging to the + * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). + * - BINARY otherwise. + * - The following partially-portable control characters form a + * "gray list" that is ignored in this detection algorithm: + * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). + * IN assertion: the fields Freq of dyn_ltree are set. + */ +local int detect_data_type(deflate_state *s) { + /* block_mask is the bit mask of block-listed bytes + * set bits 0..6, 14..25, and 28..31 + * 0xf3ffc07f = binary 11110011111111111100000001111111 + */ + unsigned long block_mask = 0xf3ffc07fUL; + int n; + + /* Check for non-textual ("block-listed") bytes. */ + for (n = 0; n <= 31; n++, block_mask >>= 1) + if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) + return Z_BINARY; + + /* Check for textual ("allow-listed") bytes. */ + if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 + || s->dyn_ltree[13].Freq != 0) + return Z_TEXT; + for (n = 32; n < LITERALS; n++) + if (s->dyn_ltree[n].Freq != 0) + return Z_TEXT; + + /* There are no "block-listed" or "allow-listed" bytes: + * this stream either is empty or has tolerated ("gray-listed") bytes only. + */ + return Z_BINARY; +} + /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static * trees or store, and write out the encoded block. */ -void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, + ulg stored_len, int last) { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex = 0; /* index of last bit length code of non zero freq */ @@ -1011,14 +1090,15 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ -int ZLIB_INTERNAL _tr_tally(s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length - MIN_MATCH or unmatched char (dist==0) */ -{ +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { +#ifdef LIT_MEM + s->d_buf[s->sym_next] = (ush)dist; + s->l_buf[s->sym_next++] = (uch)lc; +#else s->sym_buf[s->sym_next++] = (uch)dist; s->sym_buf[s->sym_next++] = (uch)(dist >> 8); s->sym_buf[s->sym_next++] = (uch)lc; +#endif if (dist == 0) { /* lc is the unmatched char */ s->dyn_ltree[lc].Freq++; @@ -1035,147 +1115,3 @@ int ZLIB_INTERNAL _tr_tally(s, dist, lc) } return (s->sym_next == s->sym_end); } - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - const ct_data *ltree; /* literal tree */ - const ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned sx = 0; /* running index in sym_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->sym_next != 0) do { - dist = s->sym_buf[sx++] & 0xff; - dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; - lc = s->sym_buf[sx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code + LITERALS + 1, ltree); /* send length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= (unsigned)base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and sym_buf is ok: */ - Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); - - } while (sx < s->sym_next); - - send_code(s, END_BLOCK, ltree); -} - -/* =========================================================================== - * Check if the data type is TEXT or BINARY, using the following algorithm: - * - TEXT if the two conditions below are satisfied: - * a) There are no non-portable control characters belonging to the - * "block list" (0..6, 14..25, 28..31). - * b) There is at least one printable character belonging to the - * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). - * - BINARY otherwise. - * - The following partially-portable control characters form a - * "gray list" that is ignored in this detection algorithm: - * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local int detect_data_type(s) - deflate_state *s; -{ - /* block_mask is the bit mask of block-listed bytes - * set bits 0..6, 14..25, and 28..31 - * 0xf3ffc07f = binary 11110011111111111100000001111111 - */ - unsigned long block_mask = 0xf3ffc07fUL; - int n; - - /* Check for non-textual ("block-listed") bytes. */ - for (n = 0; n <= 31; n++, block_mask >>= 1) - if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) - return Z_BINARY; - - /* Check for textual ("allow-listed") bytes. */ - if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 - || s->dyn_ltree[13].Freq != 0) - return Z_TEXT; - for (n = 32; n < LITERALS; n++) - if (s->dyn_ltree[n].Freq != 0) - return Z_TEXT; - - /* There are no "block-listed" or "allow-listed" bytes: - * this stream either is empty or has tolerated ("gray-listed") bytes only. - */ - return Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef ZLIB_DEBUG - s->bits_sent = (s->bits_sent + 7) & ~7; -#endif -} diff --git a/cdk/extra/zlib/try.cc b/cdk/extra/zlib/try.cc deleted file mode 100644 index bd40bbd8f..000000000 --- a/cdk/extra/zlib/try.cc +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#include -#include "zlib.h" - -#define CHUNK 255 - -int main(int, char **) -{ - int ret; - unsigned len_uncompressed = 0, len_compressed = 0, i; - z_stream strm; - char in[CHUNK] = "ZIP compression Test example string"; - char out[CHUNK]; - unsigned char tbuff[CHUNK] = { 120,218,227,226,12,118,245,113,117,14,81,48,52,146,98,46,46,204,1,0,28,19,3,196 }; - - /* allocate deflate state */ - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - - ret = deflateInit(&strm, 9); - if (ret != Z_OK) - return ret; - - printf("Uncompressed buffer boundary: %ld", - deflateBound(&strm, 1000000)); - - len_uncompressed = (unsigned)strlen(in) + 1; // Compress \0 byte as well - strm.avail_in = len_uncompressed; - strm.next_in = (Bytef*)in; - strm.avail_out = CHUNK; - strm.next_out = (Bytef*)out; - ret = deflate(&strm, Z_FINISH); - assert(ret != Z_STREAM_ERROR); - - (void)deflateEnd(&strm); - printf("Compressing.....\n"); - printf("Input string: %s\n", in); - printf("Compressed data HEX: "); - len_compressed = CHUNK - strm.avail_out; - for (i = 0; i < len_compressed; ++i) - { - printf("%02X ", (unsigned char)out[i]); - } - printf("\n"); - memset(in, 0, sizeof(in)); - - printf("Uncompressing.....\n"); - - ret = inflateInit(&strm); - if (ret != Z_OK) - return ret; - - //strm.avail_in = CHUNK - strm.avail_out; - //strm.next_in = (Bytef*)out; - - strm.avail_in = 24; - strm.next_in = (Bytef*)tbuff; - - strm.avail_out = CHUNK; - memset(in, 0, 255); - strm.next_out = (Bytef*)in; - ret = inflate(&strm, Z_FINISH); - assert(ret != Z_STREAM_ERROR); - - len_uncompressed = CHUNK - strm.avail_out; - (void)inflateEnd(&strm); - //printf("Uncompressed data TEXT: %s", in); - - printf("\n\n"); - for (int z = 0; z < 24; ++z) - { - printf("%02X ", tbuff[z]); - } - return Z_OK; -} \ No newline at end of file diff --git a/cdk/extra/zlib/uncompr.c b/cdk/extra/zlib/uncompr.c index f9532f46c..5e256663b 100644 --- a/cdk/extra/zlib/uncompr.c +++ b/cdk/extra/zlib/uncompr.c @@ -24,12 +24,8 @@ Z_DATA_ERROR if the input data was corrupted, including if the input data is an incomplete zlib stream. */ -int ZEXPORT uncompress2(dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong *sourceLen; -{ +int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong *sourceLen) { z_stream stream; int err; const uInt max = (uInt)-1; @@ -83,11 +79,7 @@ int ZEXPORT uncompress2(dest, destLen, source, sourceLen) err; } -int ZEXPORT uncompress(dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ +int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen) { return uncompress2(dest, destLen, source, &sourceLen); } diff --git a/cdk/extra/zlib/win32/DLL_FAQ.txt b/cdk/extra/zlib/win32/DLL_FAQ.txt index 12c009018..d8cf5f31e 100644 --- a/cdk/extra/zlib/win32/DLL_FAQ.txt +++ b/cdk/extra/zlib/win32/DLL_FAQ.txt @@ -3,7 +3,7 @@ This document describes the design, the rationale, and the usage -of the official DLL build of zlib, named ZLIB1.DLL. If you have +of the common DLL build of zlib, named ZLIB1.DLL. If you have general questions about zlib, you should see the file "FAQ" found in the zlib distribution, or at the following location: http://www.gzip.org/zlib/zlib_faq.html @@ -11,13 +11,9 @@ in the zlib distribution, or at the following location: 1. What is ZLIB1.DLL, and how can I get it? - - ZLIB1.DLL is the official build of zlib as a DLL. + - ZLIB1.DLL is the common build of zlib as a DLL. (Please remark the character '1' in the name.) - Pointers to a precompiled ZLIB1.DLL can be found in the zlib - web site at: - http://www.zlib.net/ - Applications that link to ZLIB1.DLL can rely on the following specification: @@ -379,18 +375,6 @@ in the zlib distribution, or at the following location: code. But you can make your own private DLL build, under a different file name, as suggested in the previous answer. - -17. I made my own ZLIB1.DLL build. Can I test it for compliance? - - - We prefer that you download the official DLL from the zlib - web site. If you need something peculiar from this DLL, you - can send your suggestion to the zlib mailing list. - - However, in case you do rebuild the DLL yourself, you can run - it with the test programs found in the DLL distribution. - Running these test programs is not a guarantee of compliance, - but a failure can imply a detected problem. - ** This document is written and maintained by diff --git a/cdk/extra/zlib/win32/README-WIN32.txt b/cdk/extra/zlib/win32/README-WIN32.txt index 050197d80..14e6398ef 100644 --- a/cdk/extra/zlib/win32/README-WIN32.txt +++ b/cdk/extra/zlib/win32/README-WIN32.txt @@ -1,6 +1,6 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.2.13 is a general purpose data compression library. All the code is +zlib 1.3.1 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) @@ -16,13 +16,13 @@ is http://zlib.net/ . Before reporting a problem, please check this site to verify that you have the latest version of zlib; otherwise get the latest version and check whether the problem still exists or not. -PLEASE read DLL_FAQ.txt, and the the zlib FAQ http://zlib.net/zlib_faq.html -before asking for help. +PLEASE read DLL_FAQ.txt, and the zlib FAQ http://zlib.net/zlib_faq.html before +asking for help. Manifest: -The package zlib-1.2.13-win32-x86.zip will contain the following files: +The package zlib-1.3.1-win32-x86.zip will contain the following files: README-WIN32.txt This document ChangeLog Changes since previous zlib packages diff --git a/cdk/extra/zlib/zconf.h.cmakein b/cdk/extra/zlib/zconf.h.cmakein index 247ba2461..0abe3bc9d 100644 --- a/cdk/extra/zlib/zconf.h.cmakein +++ b/cdk/extra/zlib/zconf.h.cmakein @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -243,7 +243,11 @@ #endif #ifdef Z_SOLO - typedef unsigned long z_size_t; +# ifdef _WIN64 + typedef unsigned long long z_size_t; +# else + typedef unsigned long z_size_t; +# endif #else # define z_longlong long long # if defined(NO_SIZE_T) @@ -298,14 +302,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have @@ -522,7 +518,7 @@ typedef uLong FAR uLongf; #if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# if defined(_WIN32) && !defined(__GNUC__) # define z_off64_t __int64 # else # define z_off64_t z_off_t diff --git a/cdk/extra/zlib/zconf.h.in b/cdk/extra/zlib/zconf.h.in index bf977d3e7..62adc8d84 100644 --- a/cdk/extra/zlib/zconf.h.in +++ b/cdk/extra/zlib/zconf.h.in @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -241,7 +241,11 @@ #endif #ifdef Z_SOLO - typedef unsigned long z_size_t; +# ifdef _WIN64 + typedef unsigned long long z_size_t; +# else + typedef unsigned long z_size_t; +# endif #else # define z_longlong long long # if defined(NO_SIZE_T) @@ -296,14 +300,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have @@ -520,7 +516,7 @@ typedef uLong FAR uLongf; #if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# if defined(_WIN32) && !defined(__GNUC__) # define z_off64_t __int64 # else # define z_off64_t z_off_t diff --git a/cdk/extra/zlib/zlib.3 b/cdk/extra/zlib/zlib.3 index 6f6e91404..c716020ea 100644 --- a/cdk/extra/zlib/zlib.3 +++ b/cdk/extra/zlib/zlib.3 @@ -1,4 +1,4 @@ -.TH ZLIB 3 "13 Oct 2022" +.TH ZLIB 3 "22 Jan 2024" .SH NAME zlib \- compression/decompression library .SH SYNOPSIS @@ -105,9 +105,9 @@ before asking for help. Send questions and/or comments to zlib@gzip.org, or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). .SH AUTHORS AND LICENSE -Version 1.2.13 +Version 1.3.1 .LP -Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler +Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler .LP This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/cdk/extra/zlib/zlib.3.pdf b/cdk/extra/zlib/zlib.3.pdf index 8132d840c..b224532bd 100644 Binary files a/cdk/extra/zlib/zlib.3.pdf and b/cdk/extra/zlib/zlib.3.pdf differ diff --git a/cdk/extra/zlib/zlib.h b/cdk/extra/zlib/zlib.h index 953cb5012..8d4b932ea 100644 --- a/cdk/extra/zlib/zlib.h +++ b/cdk/extra/zlib/zlib.h @@ -1,7 +1,7 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.13, October 13th, 2022 + version 1.3.1, January 22nd, 2024 - Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,11 +37,11 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.13" -#define ZLIB_VERNUM 0x12d0 +#define ZLIB_VERSION "1.3.1" +#define ZLIB_VERNUM 0x1310 #define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 13 +#define ZLIB_VER_MINOR 3 +#define ZLIB_VER_REVISION 1 #define ZLIB_VER_SUBREVISION 0 /* @@ -78,8 +78,8 @@ extern "C" { even in the case of corrupted input. */ -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); +typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); +typedef void (*free_func)(voidpf opaque, voidpf address); struct internal_state; @@ -217,7 +217,7 @@ typedef gz_header FAR *gz_headerp; /* basic functions */ -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +ZEXTERN const char * ZEXPORT zlibVersion(void); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. This check @@ -225,12 +225,12 @@ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); */ /* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); +ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. + allocation functions. total_in, total_out, adler, and msg are initialized. The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all @@ -247,7 +247,7 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); */ -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce @@ -320,8 +320,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); with the same value of the flush parameter and more output space (updated avail_out), until the flush is complete (deflate returns with non-zero avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. + avail_out is greater than six when the flush marker begins, in order to avoid + repeated flush markers upon calling deflate() again when avail_out == 0. If the parameter flush is set to Z_FINISH, pending input is processed, pending output is flushed and deflate returns with Z_STREAM_END if there was @@ -360,7 +360,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); */ -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -375,7 +375,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateInit(z_streamp strm); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by @@ -383,7 +383,8 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); read or consumed. The allocation of a sliding window will be deferred to the first call of inflate (if the decompression does not complete on the first call). If zalloc and zfree are set to Z_NULL, inflateInit updates - them to use default allocation functions. + them to use default allocation functions. total_in, total_out, adler, and + msg are initialized. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the @@ -397,7 +398,7 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); */ -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce @@ -517,7 +518,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); */ -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -535,12 +536,12 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); */ /* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); +ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy); This is another version of deflateInit with more compression options. The fields zalloc, zfree and opaque must be initialized before by the caller. @@ -607,9 +608,9 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); +ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. When using the zlib format, this @@ -651,9 +652,9 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, not perform any compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); +ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); /* Returns the sliding dictionary being maintained by deflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied @@ -673,8 +674,8 @@ ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, stream state is inconsistent. */ -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); +ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, + z_streamp source); /* Sets the destination stream as a complete copy of the source stream. @@ -691,20 +692,20 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, destination. */ -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +ZEXTERN int ZEXPORT deflateReset(z_streamp strm); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate the internal compression state. The stream will leave the compression level and any other attributes that may have been - set unchanged. + set unchanged. total_in, total_out, adler, and msg are initialized. deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); +ZEXTERN int ZEXPORT deflateParams(z_streamp strm, + int level, + int strategy); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2(). This can be @@ -729,7 +730,7 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, Then no more input data should be provided before the deflateParams() call. If this is done, the old level and strategy will be applied to the data compressed before deflateParams(), and the new level and strategy will be - applied to the the data compressed after deflateParams(). + applied to the data compressed after deflateParams(). deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if @@ -740,11 +741,11 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, retried with more output space. */ -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); +ZEXTERN int ZEXPORT deflateTune(z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain); /* Fine tune deflate's internal compression parameters. This should only be used by someone who understands the algorithm used by zlib's deflate for @@ -757,8 +758,8 @@ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); +ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, + uLong sourceLen); /* deflateBound() returns an upper bound on the compressed size after deflation of sourceLen bytes. It must be called after deflateInit() or @@ -772,9 +773,9 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, than Z_FINISH or Z_NO_FLUSH are used. */ -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, - unsigned *pending, - int *bits)); +ZEXTERN int ZEXPORT deflatePending(z_streamp strm, + unsigned *pending, + int *bits); /* deflatePending() returns the number of bytes and bits of output that have been generated, but not yet provided in the available output. The bytes not @@ -787,9 +788,9 @@ ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, stream state was inconsistent. */ -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); +ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, + int bits, + int value); /* deflatePrime() inserts bits in the deflate output stream. The intent is that this function is used to start off the deflate output with the bits @@ -804,8 +805,8 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, source stream state was inconsistent. */ -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); +ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, + gz_headerp head); /* deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called @@ -821,16 +822,17 @@ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gzip file" and give up. If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). + the time set to zero, and os set to the current operating system, with no + extra, name, or comment fields. The gzip header is returned to the default + state by deflateReset(). deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); +ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, + int windowBits); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized @@ -883,9 +885,9 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, deferred until inflate() is called. */ -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); +ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate, @@ -906,9 +908,9 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, inflate(). */ -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); +ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); /* Returns the sliding dictionary being maintained by inflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied @@ -921,7 +923,7 @@ ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, stream state is inconsistent. */ -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateSync(z_streamp strm); /* Skips invalid compressed data until a possible full flush point (see above for the description of deflate with Z_FULL_FLUSH) can be found, or until all @@ -934,14 +936,14 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); inflateSync returns Z_OK if a possible full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. + In the success case, the application may save the current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. */ -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); +ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, + z_streamp source); /* Sets the destination stream as a complete copy of the source stream. @@ -956,18 +958,19 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, destination. */ -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateReset(z_streamp strm); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. + total_in, total_out, adler, and msg are initialized. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); +ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, + int windowBits); /* This function is the same as inflateReset, but it also permits changing the wrap and window size requests. The windowBits parameter is interpreted @@ -980,9 +983,9 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, the windowBits parameter is invalid. */ -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); +ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, + int bits, + int value); /* This function inserts bits in the inflate input stream. The intent is that this function is used to start inflating at a bit position in the @@ -1001,7 +1004,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, stream state was inconsistent. */ -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +ZEXTERN long ZEXPORT inflateMark(z_streamp strm); /* This function returns two values, one in the lower 16 bits of the return value, and the other in the remaining upper bits, obtained by shifting the @@ -1029,8 +1032,8 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); source stream state was inconsistent. */ -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); +ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, + gz_headerp head); /* inflateGetHeader() requests that gzip header information be stored in the provided gz_header structure. inflateGetHeader() may be called after @@ -1070,8 +1073,8 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, */ /* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); +ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, + unsigned char FAR *window); Initialize the internal stream state for decompression using inflateBack() calls. The fields zalloc, zfree and opaque in strm must be initialized @@ -1091,13 +1094,13 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, the version of the header file. */ -typedef unsigned (*in_func) OF((void FAR *, - z_const unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); +typedef unsigned (*in_func)(void FAR *, + z_const unsigned char FAR * FAR *); +typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); +ZEXTERN int ZEXPORT inflateBack(z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc); /* inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is potentially more efficient than @@ -1165,7 +1168,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, cannot return Z_OK. */ -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); /* All memory allocated by inflateBackInit() is freed. @@ -1173,7 +1176,7 @@ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); state was inconsistent. */ -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +ZEXTERN uLong ZEXPORT zlibCompileFlags(void); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: @@ -1226,8 +1229,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); you need special options. */ -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); +ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size @@ -1241,9 +1244,9 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, buffer. */ -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); +ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level); /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte @@ -1257,15 +1260,15 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, Z_STREAM_ERROR if the level parameter is invalid. */ -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); /* compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer. */ -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); +ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size @@ -1282,8 +1285,8 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, buffer with the uncompressed data up to that point. */ -ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong *sourceLen)); +ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong *sourceLen); /* Same as uncompress, except that sourceLen is a pointer, where the length of the source is *sourceLen. On return, *sourceLen is the number of @@ -1302,7 +1305,7 @@ ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ /* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); Open the gzip (.gz) file at path for reading and decompressing, or compressing and writing. The mode parameter is as in fopen ("rb" or "wb") @@ -1339,7 +1342,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); file could not be opened. */ -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); /* Associate a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (if the file has @@ -1362,7 +1365,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); will not detect if fd is invalid (unless fd is -1). */ -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); /* Set the internal buffer size used by this library's functions for file to size. The default buffer size is 8192 bytes. This function must be called @@ -1378,7 +1381,7 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); too late. */ -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); /* Dynamically update the compression level and strategy for file. See the description of deflateInit2 for the meaning of these parameters. Previously @@ -1389,7 +1392,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); or Z_MEM_ERROR if there is a memory allocation error. */ -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); /* Read and decompress up to len uncompressed bytes from file into buf. If the input file is not in gzip format, gzread copies the given number of @@ -1419,8 +1422,8 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); Z_STREAM_ERROR. */ -ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, - gzFile file)); +ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, + gzFile file); /* Read and decompress up to nitems items of size size from file into buf, otherwise operating as gzread() does. This duplicates the interface of @@ -1445,14 +1448,14 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, file, resetting and retrying on end-of-file, when size is not 1. */ -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); +ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); /* Compress and write the len uncompressed bytes at buf to file. gzwrite returns the number of uncompressed bytes written or 0 in case of error. */ -ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, - z_size_t nitems, gzFile file)); +ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, + z_size_t nitems, gzFile file); /* Compress and write nitems items of size size from buf to file, duplicating the interface of stdio's fwrite(), with size_t request and return types. If @@ -1465,7 +1468,7 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, is returned, and the error state is set to Z_STREAM_ERROR. */ -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); +ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); /* Convert, format, compress, and write the arguments (...) to file under control of the string format, as in fprintf. gzprintf returns the number of @@ -1480,7 +1483,7 @@ ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); This can be determined using zlibCompileFlags(). */ -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); /* Compress and write the given null-terminated string s to file, excluding the terminating null character. @@ -1488,7 +1491,7 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); gzputs returns the number of characters written, or -1 in case of error. */ -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); /* Read and decompress bytes from file into buf, until len-1 characters are read, or until a newline character is read and transferred to buf, or an @@ -1502,13 +1505,13 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); buf are indeterminate. */ -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +ZEXTERN int ZEXPORT gzputc(gzFile file, int c); /* Compress and write c, converted to an unsigned char, into file. gzputc returns the value that was written, or -1 in case of error. */ -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +ZEXTERN int ZEXPORT gzgetc(gzFile file); /* Read and decompress one byte from file. gzgetc returns this byte or -1 in case of end of file or error. This is implemented as a macro for speed. @@ -1517,7 +1520,7 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); points to has been clobbered or not. */ -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); /* Push c back onto the stream for file to be read as the first character on the next read. At least one character of push-back is always allowed. @@ -1529,7 +1532,7 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); gzseek() or gzrewind(). */ -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); /* Flush all pending output to file. The parameter flush is as in the deflate() function. The return value is the zlib error number (see function @@ -1545,8 +1548,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); */ /* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); +ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, + z_off_t offset, int whence); Set the starting position to offset relative to whence for the next gzread or gzwrite on file. The offset represents a number of bytes in the @@ -1564,7 +1567,7 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, would be before the current position. */ -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +ZEXTERN int ZEXPORT gzrewind(gzFile file); /* Rewind file. This function is supported only for reading. @@ -1572,7 +1575,7 @@ ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); */ /* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +ZEXTERN z_off_t ZEXPORT gztell(gzFile file); Return the starting position for the next gzread or gzwrite on file. This position represents a number of bytes in the uncompressed data stream, @@ -1583,7 +1586,7 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); */ /* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); +ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); Return the current compressed (actual) read or write offset of file. This offset includes the count of bytes that precede the gzip stream, for example @@ -1592,7 +1595,7 @@ ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); be used for a progress indicator. On error, gzoffset() returns -1. */ -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +ZEXTERN int ZEXPORT gzeof(gzFile file); /* Return true (1) if the end-of-file indicator for file has been set while reading, false (0) otherwise. Note that the end-of-file indicator is set @@ -1607,7 +1610,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file)); has grown since the previous end of file was detected. */ -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +ZEXTERN int ZEXPORT gzdirect(gzFile file); /* Return true (1) if file is being copied directly while reading, or false (0) if file is a gzip stream being decompressed. @@ -1628,7 +1631,7 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); gzip file reading and decompression, which may not be desired.) */ -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose(gzFile file); /* Flush all pending output for file, if necessary, close file and deallocate the (de)compression state. Note that once file is closed, you @@ -1641,8 +1644,8 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); last read ended in the middle of a gzip stream, or Z_OK on success. */ -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_r(gzFile file); +ZEXTERN int ZEXPORT gzclose_w(gzFile file); /* Same as gzclose(), but gzclose_r() is only for use when reading, and gzclose_w() is only for use when writing or appending. The advantage to @@ -1653,7 +1656,7 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); zlib library. */ -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); /* Return the error message for the last error which occurred on file. errnum is set to zlib error number. If an error occurred in the file system @@ -1669,7 +1672,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); functions above that do not distinguish those cases in their return values. */ -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +ZEXTERN void ZEXPORT gzclearerr(gzFile file); /* Clear the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip @@ -1686,7 +1689,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); library. */ -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. An Adler-32 value is in the range of a 32-bit @@ -1706,15 +1709,15 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); if (adler != original_adler) error(); */ -ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, - z_size_t len)); +ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, + z_size_t len); /* Same as adler32(), but with a size_t length. */ /* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); +ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, + z_off_t len2); Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for @@ -1724,7 +1727,7 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, negative, the result has no meaning or utility. */ -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. @@ -1742,30 +1745,30 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); if (crc != original_crc) error(); */ -ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf, - z_size_t len)); +ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, + z_size_t len); /* Same as crc32(), but with a size_t length. */ /* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); +ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. + len2. len2 must be non-negative. */ /* -ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2)); +ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); Return the operator corresponding to length len2, to be used with - crc32_combine_op(). + crc32_combine_op(). len2 must be non-negative. */ -ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); +ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); /* Give the same result as crc32_combine(), using op in place of len2. op is is generated from len2 by crc32_combine_gen(). This will be faster than @@ -1778,20 +1781,20 @@ ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); +ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, + const char *version, int stream_size); +ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size); +ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size); #ifdef Z_PREFIX_SET # define z_deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) @@ -1836,7 +1839,7 @@ struct gzFile_s { unsigned char *next; z_off64_t pos; }; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ +ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ #ifdef Z_PREFIX_SET # undef z_gzgetc # define z_gzgetc(g) \ @@ -1853,13 +1856,13 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ * without large file support, _LFS64_LARGEFILE must also be true */ #ifdef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); #endif #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) @@ -1881,50 +1884,50 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ # define crc32_combine_gen crc32_combine_gen64 # endif # ifndef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); # endif #else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); + ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); #endif #else /* Z_SOLO */ - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); #endif /* !Z_SOLO */ /* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); -ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); -ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF((z_streamp)); -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); +ZEXTERN const char * ZEXPORT zError(int); +ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); +ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); +ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); +ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); +ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); +ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); #if defined(_WIN32) && !defined(Z_SOLO) -ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, - const char *mode)); +ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, + const char *mode); #endif #if defined(STDC) || defined(Z_HAVE_STDARG_H) # ifndef Z_SOLO -ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, - const char *format, - va_list va)); +ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, + const char *format, + va_list va); # endif #endif diff --git a/cdk/extra/zlib/zlib2ansi b/cdk/extra/zlib/zlib2ansi deleted file mode 100755 index 23b2a1d5a..000000000 --- a/cdk/extra/zlib/zlib2ansi +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/perl - -# Transform K&R C function definitions into ANSI equivalent. -# -# Author: Paul Marquess -# Version: 1.0 -# Date: 3 October 2006 - -# TODO -# -# Assumes no function pointer parameters. unless they are typedefed. -# Assumes no literal strings that look like function definitions -# Assumes functions start at the beginning of a line - -use strict; -use warnings; - -local $/; -$_ = <>; - -my $sp = qr{ \s* (?: /\* .*? \*/ )? \s* }x; # assume no nested comments - -my $d1 = qr{ $sp (?: [\w\*\s]+ $sp)* $sp \w+ $sp [\[\]\s]* $sp }x ; -my $decl = qr{ $sp (?: \w+ $sp )+ $d1 }xo ; -my $dList = qr{ $sp $decl (?: $sp , $d1 )* $sp ; $sp }xo ; - - -while (s/^ - ( # Start $1 - ( # Start $2 - .*? # Minimal eat content - ( ^ \w [\w\s\*]+ ) # $3 -- function name - \s* # optional whitespace - ) # $2 - Matched up to before parameter list - - \( \s* # Literal "(" + optional whitespace - ( [^\)]+ ) # $4 - one or more anythings except ")" - \s* \) # optional whitespace surrounding a Literal ")" - - ( (?: $dList )+ ) # $5 - - $sp ^ { # literal "{" at start of line - ) # Remember to $1 - //xsom - ) -{ - my $all = $1 ; - my $prefix = $2; - my $param_list = $4 ; - my $params = $5; - - StripComments($params); - StripComments($param_list); - $param_list =~ s/^\s+//; - $param_list =~ s/\s+$//; - - my $i = 0 ; - my %pList = map { $_ => $i++ } - split /\s*,\s*/, $param_list; - my $pMatch = '(\b' . join('|', keys %pList) . '\b)\W*$' ; - - my @params = split /\s*;\s*/, $params; - my @outParams = (); - foreach my $p (@params) - { - if ($p =~ /,/) - { - my @bits = split /\s*,\s*/, $p; - my $first = shift @bits; - $first =~ s/^\s*//; - push @outParams, $first; - $first =~ /^(\w+\s*)/; - my $type = $1 ; - push @outParams, map { $type . $_ } @bits; - } - else - { - $p =~ s/^\s+//; - push @outParams, $p; - } - } - - - my %tmp = map { /$pMatch/; $_ => $pList{$1} } - @outParams ; - - @outParams = map { " $_" } - sort { $tmp{$a} <=> $tmp{$b} } - @outParams ; - - print $prefix ; - print "(\n" . join(",\n", @outParams) . ")\n"; - print "{" ; - -} - -# Output any trailing code. -print ; -exit 0; - - -sub StripComments -{ - - no warnings; - - # Strip C & C++ comments - # From the perlfaq - $_[0] =~ - - s{ - /\* ## Start of /* ... */ comment - [^*]*\*+ ## Non-* followed by 1-or-more *'s - ( - [^/*][^*]*\*+ - )* ## 0-or-more things which don't start with / - ## but do end with '*' - / ## End of /* ... */ comment - - | ## OR C++ Comment - // ## Start of C++ comment // - [^\n]* ## followed by 0-or-more non end of line characters - - | ## OR various things which aren't comments: - - ( - " ## Start of " ... " string - ( - \\. ## Escaped char - | ## OR - [^"\\] ## Non "\ - )* - " ## End of " ... " string - - | ## OR - - ' ## Start of ' ... ' string - ( - \\. ## Escaped char - | ## OR - [^'\\] ## Non '\ - )* - ' ## End of ' ... ' string - - | ## OR - - . ## Anything other char - [^/"'\\]* ## Chars which doesn't start a comment, string or escape - ) - }{$2}gxs; - -} diff --git a/cdk/extra/zlib/zutil.c b/cdk/extra/zlib/zutil.c index 9543ae825..b1c5d2d3c 100644 --- a/cdk/extra/zlib/zutil.c +++ b/cdk/extra/zlib/zutil.c @@ -24,13 +24,11 @@ z_const char * const z_errmsg[10] = { }; -const char * ZEXPORT zlibVersion() -{ +const char * ZEXPORT zlibVersion(void) { return ZLIB_VERSION; } -uLong ZEXPORT zlibCompileFlags() -{ +uLong ZEXPORT zlibCompileFlags(void) { uLong flags; flags = 0; @@ -121,9 +119,7 @@ uLong ZEXPORT zlibCompileFlags() # endif int ZLIB_INTERNAL z_verbose = verbose; -void ZLIB_INTERNAL z_error(m) - char *m; -{ +void ZLIB_INTERNAL z_error(char *m) { fprintf(stderr, "%s\n", m); exit(1); } @@ -132,9 +128,7 @@ void ZLIB_INTERNAL z_error(m) /* exported to allow conversion of error code to string for compress() and * uncompress() */ -const char * ZEXPORT zError(err) - int err; -{ +const char * ZEXPORT zError(int err) { return ERR_MSG(err); } @@ -148,22 +142,14 @@ const char * ZEXPORT zError(err) #ifndef HAVE_MEMCPY -void ZLIB_INTERNAL zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ +void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) { if (len == 0) return; do { *dest++ = *source++; /* ??? to be unrolled */ } while (--len != 0); } -int ZLIB_INTERNAL zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ +int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) { uInt j; for (j = 0; j < len; j++) { @@ -172,10 +158,7 @@ int ZLIB_INTERNAL zmemcmp(s1, s2, len) return 0; } -void ZLIB_INTERNAL zmemzero(dest, len) - Bytef* dest; - uInt len; -{ +void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) { if (len == 0) return; do { *dest++ = 0; /* ??? to be unrolled */ @@ -216,8 +199,7 @@ local ptr_table table[MAX_PTR]; * a protected system like OS/2. Use Microsoft C instead. */ -voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { voidpf buf; ulg bsize = (ulg)items*size; @@ -242,8 +224,7 @@ voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) return buf; } -void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { int n; (void)opaque; @@ -279,14 +260,12 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) # define _hfree hfree #endif -voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) { (void)opaque; return _halloc((long)items, size); } -void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { (void)opaque; _hfree(ptr); } @@ -299,25 +278,18 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); +extern voidp malloc(uInt size); +extern voidp calloc(uInt items, uInt size); +extern void free(voidpf ptr); #endif -voidpf ZLIB_INTERNAL zcalloc(opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { (void)opaque; return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : (voidpf)calloc(items, size); } -void ZLIB_INTERNAL zcfree(opaque, ptr) - voidpf opaque; - voidpf ptr; -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { (void)opaque; free(ptr); } diff --git a/cdk/extra/zlib/zutil.h b/cdk/extra/zlib/zutil.h index 0bc7f4ecd..48dd7feba 100644 --- a/cdk/extra/zlib/zutil.h +++ b/cdk/extra/zlib/zutil.h @@ -1,5 +1,5 @@ /* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -56,7 +56,7 @@ typedef unsigned long ulg; extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] +#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)] #define ERR_RETURN(strm,err) \ return (strm->msg = ERR_MSG(err), (err)) @@ -137,17 +137,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # endif #endif -#if defined(MACOS) || defined(TARGET_OS_MAC) +#if defined(MACOS) # define OS_CODE 7 -# ifndef Z_SOLO -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -# endif #endif #ifdef __acorn @@ -170,18 +161,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define OS_CODE 19 #endif -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - #if defined(__BORLANDC__) && !defined(MSDOS) #pragma warn -8004 #pragma warn -8008 @@ -191,9 +170,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* provide prototypes for these when building zlib without LFS */ #if !defined(_WIN32) && \ (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); #endif /* common defaults */ @@ -232,16 +211,16 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define zmemzero(dest, len) memset(dest, 0, len) # endif #else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); + void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len); + int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len); + void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len); #endif /* Diagnostic functions */ #ifdef ZLIB_DEBUG # include extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); + extern void ZLIB_INTERNAL z_error(char *m); # define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;} @@ -258,9 +237,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #endif #ifndef Z_SOLO - voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); - void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); + voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, + unsigned size); + void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr); #endif #define ZALLOC(strm, items, size) \ diff --git a/cdk/extra/zstd/CMakeLists.txt b/cdk/extra/zstd/CMakeLists.txt index 0ed58f630..af505f3b0 100644 --- a/cdk/extra/zstd/CMakeLists.txt +++ b/cdk/extra/zstd/CMakeLists.txt @@ -15,6 +15,16 @@ include(platform) enable_pic() +if(WERROR) + add_compile_options(${WERROR}) +endif() + +if(WIN32 AND CLANG) + # This warning shows only when building with clang on Win (clang 18): + # lib\compress\huf_compress.c(519,16): error : unused function 'HUF_isSorted' + set_compiler_flag(-Wno-unused-function) +endif() + SET(ZSTD_LIB_DIR "${PROJECT_SOURCE_DIR}/lib") diff --git a/cdk/foundation/connection_openssl.cc b/cdk/foundation/connection_openssl.cc index 24dc71469..e0f2e09aa 100644 --- a/cdk/foundation/connection_openssl.cc +++ b/cdk/foundation/connection_openssl.cc @@ -265,12 +265,12 @@ class connection_TLS_impl , m_options(options) {} - ~connection_TLS_impl() + ~connection_TLS_impl() NOEXCEPT { if (m_tls) { /* - Server is expecting a SSL quiet shutdown. + Server is expecting a SSL quiet shutdown. */ SSL_set_quiet_shutdown(m_tls, 1); SSL_shutdown(m_tls); @@ -697,7 +697,7 @@ class safe_X509 : m_X509(obj) {} - ~safe_X509() + ~safe_X509() NOEXCEPT { if (std::is_same::value) { diff --git a/cdk/foundation/connection_tcpip.cc b/cdk/foundation/connection_tcpip.cc index cb4374dd4..7a8bfe366 100644 --- a/cdk/foundation/connection_tcpip.cc +++ b/cdk/foundation/connection_tcpip.cc @@ -138,7 +138,7 @@ class Socket_system_initializer detail::initialize_socket_system(); } - ~Socket_system_initializer() + ~Socket_system_initializer() NOEXCEPT { try { diff --git a/cdk/foundation/connection_tcpip_base.h b/cdk/foundation/connection_tcpip_base.h index 6a4dc4cc0..9bfb12cb4 100644 --- a/cdk/foundation/connection_tcpip_base.h +++ b/cdk/foundation/connection_tcpip_base.h @@ -110,9 +110,9 @@ class Socket_base::Impl return detail::poll_one(m_sock, detail::POLL_MODE_WRITE, false) > 0; } - virtual ~Impl() + virtual ~Impl() NOEXCEPT { - close(); + try { close(); } catch (...) {} } virtual void do_connect() =0; diff --git a/cdk/foundation/socket_detail.cc b/cdk/foundation/socket_detail.cc index ffea5d61c..6663dc5c8 100644 --- a/cdk/foundation/socket_detail.cc +++ b/cdk/foundation/socket_detail.cc @@ -643,7 +643,7 @@ Socket connect(const char *host_name, unsigned short port, struct AddrInfoGuard { addrinfo* list; - ~AddrInfoGuard() { freeaddrinfo(list); } + ~AddrInfoGuard() NOEXCEPT { freeaddrinfo(list); } } guard = { host_list }; @@ -916,6 +916,13 @@ void recv(Socket socket, byte *buffer, size_t buffer_size) size_t bytes_received = 0; + /* + Note: In presence of timeouts recv_some() can return 0 which would lead + to an infinite loop here! See also bug#37278716. + + A solution would be to throw error if timeout was hit? + */ + while (bytes_received != buffer_size) bytes_received += recv_some(socket, buffer + bytes_received, buffer_size - bytes_received, true); } diff --git a/cdk/include/mysql/cdk/api/document.h b/cdk/include/mysql/cdk/api/document.h index ed76ff758..0fb456fa4 100644 --- a/cdk/include/mysql/cdk/api/document.h +++ b/cdk/include/mysql/cdk/api/document.h @@ -107,7 +107,7 @@ class Any_processor virtual Doc_prc* doc() =0; - virtual ~Any_processor() {} + virtual ~Any_processor() NOEXCEPT {} }; @@ -156,7 +156,7 @@ class Doc_processor */ virtual Any_prc* key_val(const string &key) =0; - virtual ~Doc_processor() {} + virtual ~Doc_processor() NOEXCEPT {} }; diff --git a/cdk/include/mysql/cdk/api/obj_ref.h b/cdk/include/mysql/cdk/api/obj_ref.h index 9f0ce2eaf..8c4747c44 100644 --- a/cdk/include/mysql/cdk/api/obj_ref.h +++ b/cdk/include/mysql/cdk/api/obj_ref.h @@ -47,7 +47,7 @@ class Ref_base { public: - virtual ~Ref_base() {} + virtual ~Ref_base() NOEXCEPT {} virtual const string name() const =0; virtual const string orig_name() const { return name(); } diff --git a/cdk/include/mysql/cdk/api/session.h b/cdk/include/mysql/cdk/api/session.h index 40dd4b9df..0460ef44b 100644 --- a/cdk/include/mysql/cdk/api/session.h +++ b/cdk/include/mysql/cdk/api/session.h @@ -44,7 +44,7 @@ class Session { public: - virtual ~Session() {} + virtual ~Session() NOEXCEPT {} // Check if given session is valid. Function is_valid() performs a lightweight, local check while // check_valid() might communicate with the data store to perform this check. diff --git a/cdk/include/mysql/cdk/codec.h b/cdk/include/mysql/cdk/codec.h index 2a37b0097..d960ee5b4 100644 --- a/cdk/include/mysql/cdk/codec.h +++ b/cdk/include/mysql/cdk/codec.h @@ -371,7 +371,7 @@ class Codec Codec(const Format_info &fi) : Codec_base(fi) {} - virtual ~Codec() {} + virtual ~Codec() NOEXCEPT {} virtual size_t from_bytes(bytes buf, float &val); virtual size_t from_bytes(bytes buf, double &val); diff --git a/cdk/include/mysql/cdk/common.h b/cdk/include/mysql/cdk/common.h index d0da13e60..1620175c4 100644 --- a/cdk/include/mysql/cdk/common.h +++ b/cdk/include/mysql/cdk/common.h @@ -414,7 +414,7 @@ class JSON_processor virtual void num(double) =0; virtual void yesno(bool) =0; - virtual ~JSON_processor() {} + virtual ~JSON_processor() NOEXCEPT {} }; typedef api::Doc_base JSON; diff --git a/cdk/include/mysql/cdk/data_source.h b/cdk/include/mysql/cdk/data_source.h index 99ae17eb3..420cefda6 100644 --- a/cdk/include/mysql/cdk/data_source.h +++ b/cdk/include/mysql/cdk/data_source.h @@ -52,7 +52,7 @@ namespace ds { struct Attr_processor { - virtual ~Attr_processor() {} + virtual ~Attr_processor() NOEXCEPT {} virtual void attr(const string &key, const string &val)=0; }; @@ -90,7 +90,7 @@ class Options } } - virtual ~Options() {} + virtual ~Options() NOEXCEPT {} virtual const string& user() const { return m_usr; } virtual const std::string* password() const @@ -171,7 +171,7 @@ class TCPIP throw_error("invalid empty host name"); } - virtual ~TCPIP() {} + virtual ~TCPIP() NOEXCEPT {} virtual unsigned short port() const { return m_port; } virtual const std::string& host() const { return m_host; } @@ -346,7 +346,7 @@ class Unix_socket throw_error("invalid empty socket path"); } - virtual ~Unix_socket() {} + virtual ~Unix_socket() NOEXCEPT {} virtual const std::string& path() const { return m_path; } }; @@ -386,7 +386,7 @@ class TCPIP : public cdk::ds::mysqlx::TCPIP : cdk::ds::mysqlx::TCPIP(_host, _port) {} - virtual ~TCPIP() {} + virtual ~TCPIP() NOEXCEPT {} typedef ds::Options Options; }; diff --git a/cdk/include/mysql/cdk/foundation/async.h b/cdk/include/mysql/cdk/foundation/async.h index 482cbdf2b..1bad184b4 100644 --- a/cdk/include/mysql/cdk/foundation/async.h +++ b/cdk/include/mysql/cdk/foundation/async.h @@ -50,7 +50,7 @@ class Async_op_base : nocopy { public: - virtual ~Async_op_base() {} + virtual ~Async_op_base() NOEXCEPT {} virtual bool is_completed() const =0; diff --git a/cdk/include/mysql/cdk/foundation/codec.h b/cdk/include/mysql/cdk/foundation/codec.h index 8310bb6ae..40314c0f9 100644 --- a/cdk/include/mysql/cdk/foundation/codec.h +++ b/cdk/include/mysql/cdk/foundation/codec.h @@ -71,7 +71,7 @@ class String_codec { public: - virtual ~String_codec() {} + virtual ~String_codec() NOEXCEPT {} //virtual size_t measure(const string&) =0; virtual size_t from_bytes(bytes, string&) =0; @@ -165,7 +165,7 @@ class Number_codec { public: - virtual ~Number_codec() {} + virtual ~Number_codec() NOEXCEPT {} virtual size_t from_bytes(bytes buf, int8_t &val) =0; virtual size_t from_bytes(bytes buf, int16_t &val) =0; @@ -220,8 +220,14 @@ static size_t convert(bytes buf, T &val) /* If buf size is smaller than sizeof(T), convert 1,2,4 or 8 initial bytes from the buffer: as much as fits into T. + + Note: We check here that buffer size is big enough to store given amount + of bytes but compilers still complain under -Warray-bounds (seen on + Solaris with gcc 11.4). */ +PUSH_ARRAY_BOUNDS_WARNING_CDK + if (buf.size() >= sizeof(T)) { val= *(T*)buf.begin(); @@ -252,6 +258,8 @@ static size_t convert(bytes buf, T &val) return 1; } +POP_ARRAY_BOUNDS_WARNING_CDK + // TODO: better error description throw_error(cdkerrc::conversion_error, "Number_codec: no data for conversion"); diff --git a/cdk/include/mysql/cdk/foundation/common.h b/cdk/include/mysql/cdk/foundation/common.h index c13abca42..0ec552799 100644 --- a/cdk/include/mysql/cdk/foundation/common.h +++ b/cdk/include/mysql/cdk/foundation/common.h @@ -42,7 +42,7 @@ #define DIAGNOSTIC_PUSH_CDK PRAGMA_CDK(warning (push)) #define DIAGNOSTIC_POP_CDK PRAGMA_CDK(warning (pop)) -#elif defined __GNUC__ || defined __clang__ +#elif defined __GNUC__ || defined __clang__ #define PRAGMA_CDK(X) _Pragma(#X) #define DISABLE_WARNING_CDK(W) PRAGMA_CDK(GCC diagnostic ignored #W) @@ -113,6 +113,25 @@ #define POP_SYS_WARNINGS_CDK DIAGNOSTIC_POP_CDK +/* + Macros to disable false positives from -Warray-bounds checks for lines + of code that were manually verified to be correct. +*/ + +#ifdef _MSC_VER + +#define PUSH_ARRAY_BOUNDS_WARNING_CDK DIAGNOSTIC_PUSH_CDK +#define POP_ARRAY_BOUNDS_WARNING_CDK DIAGNOSTIC_POP_CDK + +#else + +#define PUSH_ARRAY_BOUNDS_WARNING_CDK \ + DIAGNOSTIC_PUSH_CDK DISABLE_WARNING_CDK(-Warray-bounds) +#define POP_ARRAY_BOUNDS_WARNING_CDK DIAGNOSTIC_POP_CDK + +#endif + + // Avoid warnings from Protobuf includes #if defined _MSC_VER diff --git a/cdk/include/mysql/cdk/foundation/connection_tcpip.h b/cdk/include/mysql/cdk/foundation/connection_tcpip.h index 927c900c4..00a996719 100644 --- a/cdk/include/mysql/cdk/foundation/connection_tcpip.h +++ b/cdk/include/mysql/cdk/foundation/connection_tcpip.h @@ -107,7 +107,7 @@ class IO_error : public Error_class : Error_base(NULL, io_error(num)) {} - virtual ~IO_error() throw() {} + virtual ~IO_error() NOEXCEPT {} }; diff --git a/cdk/include/mysql/cdk/foundation/diagnostics.h b/cdk/include/mysql/cdk/foundation/diagnostics.h index 37ce41427..76abd671d 100644 --- a/cdk/include/mysql/cdk/foundation/diagnostics.h +++ b/cdk/include/mysql/cdk/foundation/diagnostics.h @@ -223,7 +223,7 @@ class Diagnostic_iterator : public api::Diagnostics::Iterator : m_entries(NULL), m_level(Severity::ERROR) {} - virtual ~Diagnostic_iterator() {} + virtual ~Diagnostic_iterator() NOEXCEPT {} const Entry& entry() { @@ -265,8 +265,10 @@ class Diagnostic_arena : m_it(m_entries, Severity::ERROR) {} - virtual ~Diagnostic_arena() - { clear(); } + virtual ~Diagnostic_arena() NOEXCEPT + { + try { clear(); } catch (...) {} + } /* diff --git a/cdk/include/mysql/cdk/foundation/error_category.h b/cdk/include/mysql/cdk/foundation/error_category.h index b38128c39..0d23c5c1c 100644 --- a/cdk/include/mysql/cdk/foundation/error_category.h +++ b/cdk/include/mysql/cdk/foundation/error_category.h @@ -144,7 +144,7 @@ const error_category& posix_error_category(); struct error_category_##EC : public cdk::foundation::error_category_base \ { \ error_category_##EC() {} \ - const char* name() const throw() { return "cdk-" #EC; } \ + const char* name() const NOEXCEPT { return "cdk-" #EC; } \ std::string message(int code) const \ { CDK_ERROR_SWITCH(NS, EC, code); } \ cdk::foundation::error_condition do_default_error_condition(int) const; \ diff --git a/cdk/include/mysql/cdk/foundation/opaque_impl.h b/cdk/include/mysql/cdk/foundation/opaque_impl.h index d074856c9..0f5d6fbc6 100644 --- a/cdk/include/mysql/cdk/foundation/opaque_impl.h +++ b/cdk/include/mysql/cdk/foundation/opaque_impl.h @@ -171,7 +171,7 @@ class opaque_impl protected: - virtual ~opaque_impl(); + virtual ~opaque_impl() NOEXCEPT; // Default constructor: uses default constructor of internal implementation type. diff --git a/cdk/include/mysql/cdk/foundation/opaque_impl.i b/cdk/include/mysql/cdk/foundation/opaque_impl.i index e62fda1c6..0ab2ffd40 100644 --- a/cdk/include/mysql/cdk/foundation/opaque_impl.i +++ b/cdk/include/mysql/cdk/foundation/opaque_impl.i @@ -129,7 +129,7 @@ namespace foundation { namespace cdk { \ namespace foundation { \ template<> \ - opaque_impl::~opaque_impl() { delete m_impl; } \ + opaque_impl::~opaque_impl() NOEXCEPT { delete m_impl; } \ }} // cdk::foundation #define IMPL_DEFAULT(X) \ diff --git a/cdk/include/mysql/cdk/foundation/stream.h b/cdk/include/mysql/cdk/foundation/stream.h index 1d2a6c037..f0533e22c 100644 --- a/cdk/include/mysql/cdk/foundation/stream.h +++ b/cdk/include/mysql/cdk/foundation/stream.h @@ -75,7 +75,7 @@ class Connection , public Output_stream { public: - virtual ~Connection() {} + virtual ~Connection() NOEXCEPT {} virtual void connect() =0; virtual void close() =0; virtual bool is_closed() const =0; diff --git a/cdk/include/mysql/cdk/foundation/variant.h b/cdk/include/mysql/cdk/foundation/variant.h index 03a105963..b7dcaa993 100644 --- a/cdk/include/mysql/cdk/foundation/variant.h +++ b/cdk/include/mysql/cdk/foundation/variant.h @@ -356,9 +356,9 @@ class variant return *this; } - ~variant() + ~variant() NOEXCEPT { - Base::destroy(); + try { Base::destroy(); } catch (...) {} } operator bool() diff --git a/cdk/include/mysql/cdk/mysqlx/common.h b/cdk/include/mysql/cdk/mysqlx/common.h index a1fd64e8b..9d7aa1f54 100644 --- a/cdk/include/mysql/cdk/mysqlx/common.h +++ b/cdk/include/mysql/cdk/mysqlx/common.h @@ -95,13 +95,13 @@ class Server_error typedef protocol::mysqlx::sql_state_t sql_state_t; - Server_error(unsigned num, sql_state_t, const string& desc = string()) throw() + Server_error(unsigned num, sql_state_t, const string& desc = string()) NOEXCEPT : Error_base(NULL, server_error(static_cast(num)), desc) { assert(num < (unsigned)std::numeric_limits::max()); } - virtual ~Server_error() throw() {} + virtual ~Server_error() NOEXCEPT {} }; @@ -115,7 +115,7 @@ class Server_prepare_error Server_prepare_error( unsigned num, sql_state_t sql_state, const string& desc = string() - ) throw() + ) NOEXCEPT : Error_base(NULL, num, sql_state , desc) {} }; @@ -128,7 +128,7 @@ class Server_expectation_error typedef protocol::mysqlx::sql_state_t sql_state_t; - Server_expectation_error(const string& desc) throw() + Server_expectation_error(const string& desc) NOEXCEPT : Error_base(NULL, 5168, sql_state_t("HY000") , desc) {} }; diff --git a/cdk/include/mysql/cdk/mysqlx/result.h b/cdk/include/mysql/cdk/mysqlx/result.h index ad4c5ebfe..0ffbaf016 100644 --- a/cdk/include/mysql/cdk/mysqlx/result.h +++ b/cdk/include/mysql/cdk/mysqlx/result.h @@ -446,12 +446,21 @@ class Stmt_op assert(m_session); } - virtual ~Stmt_op() + virtual ~Stmt_op() NOEXCEPT { - discard(); - wait(); - if (m_session) - m_session->deregister_stmt(this); + try + { + discard(); + wait(); + } + catch (...) {} + + try + { + if (m_session) + m_session->deregister_stmt(this); + } + catch (...) {} } Session& get_session() @@ -812,7 +821,7 @@ class Cursor public: Cursor(const std::shared_ptr &reply); - ~Cursor(); + ~Cursor() NOEXCEPT; void get_rows(mysqlx::Row_processor& rp); void get_rows(mysqlx::Row_processor& rp, row_count_t limit); diff --git a/cdk/include/mysql/cdk/mysqlx/session.h b/cdk/include/mysql/cdk/mysqlx/session.h index 6f9b5752d..85b8d962d 100755 --- a/cdk/include/mysql/cdk/mysqlx/session.h +++ b/cdk/include/mysql/cdk/mysqlx/session.h @@ -148,7 +148,7 @@ class SessionAuth public: SessionAuth(Session&, const char *method); - virtual ~SessionAuth() {} + virtual ~SessionAuth() NOEXCEPT {} /* Authentication data to be sent in the AuthenticateStart message, @@ -294,7 +294,7 @@ class Session */ Compression_type::value negotiate_compression(const std::vector& algorithms); - virtual ~Session(); + virtual ~Session() NOEXCEPT; /* Check if given session is valid. Function is_valid() performs diff --git a/cdk/include/mysql/cdk/protocol/mysqlx.h b/cdk/include/mysql/cdk/protocol/mysqlx.h index 18f345538..f10da5ca6 100644 --- a/cdk/include/mysql/cdk/protocol/mysqlx.h +++ b/cdk/include/mysql/cdk/protocol/mysqlx.h @@ -799,7 +799,7 @@ class Protocol::Stream Stream() {} - virtual ~Stream() + virtual ~Stream() NOEXCEPT {} virtual Op* read(const buffers&) =0; @@ -919,7 +919,7 @@ class Processor_base { public: - virtual ~Processor_base(){} + virtual ~Processor_base() NOEXCEPT {} typedef protocol::mysqlx::byte byte; typedef protocol::mysqlx::string string; @@ -1214,7 +1214,7 @@ class Update_processor virtual void target_path(const api::Doc_path&) = 0; virtual Expr_prc* update_op(update_op::value ) = 0; - virtual ~Update_processor() {} + virtual ~Update_processor() NOEXCEPT {} }; class Update_spec @@ -1282,7 +1282,7 @@ class Db_obj : public api::Db_obj return *this; } - virtual ~Db_obj() {} + virtual ~Db_obj() NOEXCEPT {} virtual const string& get_name() const { return m_name; }; diff --git a/cdk/include/mysql/cdk/protocol/mysqlx/expr.h b/cdk/include/mysql/cdk/protocol/mysqlx/expr.h index cda39ee10..43c8cbdfa 100644 --- a/cdk/include/mysql/cdk/protocol/mysqlx/expr.h +++ b/cdk/include/mysql/cdk/protocol/mysqlx/expr.h @@ -244,7 +244,7 @@ class Doc_path DOUBLE_ASTERISK = 5, }; - virtual ~Doc_path() {} + virtual ~Doc_path() NOEXCEPT {} // The "$" path which denotes the whole document. virtual bool is_whole_document() const = 0; diff --git a/cdk/include/mysql/cdk/session.h b/cdk/include/mysql/cdk/session.h index 6bd5e237c..bde0c3f2e 100644 --- a/cdk/include/mysql/cdk/session.h +++ b/cdk/include/mysql/cdk/session.h @@ -78,7 +78,7 @@ class Session const ds::Unix_socket::Options &options = ds::Unix_socket::Options()); #endif //_WIN32 - ~Session(); + ~Session() NOEXCEPT; // Core Session operations. diff --git a/cdk/mysqlx/CMakeLists.txt b/cdk/mysqlx/CMakeLists.txt index aa358f039..871740b82 100644 --- a/cdk/mysqlx/CMakeLists.txt +++ b/cdk/mysqlx/CMakeLists.txt @@ -31,14 +31,6 @@ ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN -DNOGDI) ADD_DEFINITIONS(-DNOMINMAX) ADD_DEFINITIONS(-DSIZEOF_LONG=${SIZEOF_LONG} -DSIZEOF_LONG_LONG=${SIZEOF_LONG_LONG}) -# TODO: Fix compile warnings in auth_mysql41.cc - -if(MSVC) - set_property(SOURCE auth_hash.cc - PROPERTY COMPILE_FLAGS "/W3" - ) -endif() - file(GLOB HEADERS *.h) ADD_LIBRARY(cdk_mysqlx STATIC diff --git a/cdk/mysqlx/converters.h b/cdk/mysqlx/converters.h index 3d378aa40..0e61c1a99 100644 --- a/cdk/mysqlx/converters.h +++ b/cdk/mysqlx/converters.h @@ -243,7 +243,7 @@ struct Expr_prc_converter_base //using Base::reset; //using Base::m_proc; - virtual ~Expr_prc_converter_base() {} + virtual ~Expr_prc_converter_base() NOEXCEPT {} Scalar_prc_converter m_scalar_conv; Args_prc* get_args_converter(Args_prc_to*); diff --git a/cdk/mysqlx/result.cc b/cdk/mysqlx/result.cc index 474e0c0e7..11bab8468 100644 --- a/cdk/mysqlx/result.cc +++ b/cdk/mysqlx/result.cc @@ -552,9 +552,9 @@ Cursor::Cursor(const std::shared_ptr &reply) } -Cursor::~Cursor() +Cursor::~Cursor() NOEXCEPT { - close(); + try { close(); } catch (...) {} } diff --git a/cdk/mysqlx/session.cc b/cdk/mysqlx/session.cc index 414d01ea2..fd97f7a89 100644 --- a/cdk/mysqlx/session.cc +++ b/cdk/mysqlx/session.cc @@ -660,7 +660,7 @@ void Session::authenticate(const Options &options, bool secure_conn) } -Session::~Session() +Session::~Session() NOEXCEPT { //TODO: add timeout to close session! try @@ -668,10 +668,7 @@ Session::~Session() close(); } catch (...) - { - // Something went wrong - do not try to use this session again. - m_isvalid = false; - } + {} } diff --git a/cdk/mysqlx/stmt.h b/cdk/mysqlx/stmt.h index c4f7176a7..4b265ff12 100644 --- a/cdk/mysqlx/stmt.h +++ b/cdk/mysqlx/stmt.h @@ -125,10 +125,15 @@ class Expectation } - ~Expectation() + ~Expectation() NOEXCEPT { - Base::discard(); - Base::wait(); + try + { + Base::discard(); + Base::wait(); + } + catch (...) + {} } @@ -791,7 +796,7 @@ class Order_prc_converter public: - virtual ~Order_prc_converter() {} + virtual ~Order_prc_converter() NOEXCEPT {} Expr_prc* sort_key(Sort_direction::value dir) { @@ -855,7 +860,7 @@ class Cmd_Select {} - virtual ~Cmd_Select() + virtual ~Cmd_Select() NOEXCEPT {} @@ -989,7 +994,7 @@ class Table_proj_prc_converter public: - virtual ~Table_proj_prc_converter() {} + virtual ~Table_proj_prc_converter() NOEXCEPT {} }; @@ -1125,7 +1130,7 @@ struct String_to_col_prc_converter m_proc->name(col); } - virtual ~String_to_col_prc_converter() + virtual ~String_to_col_prc_converter() NOEXCEPT {} }; @@ -1290,7 +1295,7 @@ class Cmd_ViewCrud view.process(*this); } - ~Cmd_ViewCrud() + ~Cmd_ViewCrud() NOEXCEPT { delete m_find; } @@ -1379,7 +1384,7 @@ class Update_prc_converter bool m_has_schema; string m_schema_name; - virtual ~Table() {} + virtual ~Table() NOEXCEPT {} //DB_OBJ const string& get_name() const @@ -1396,7 +1401,7 @@ class Update_prc_converter public: - virtual ~Update_prc_converter() {} + virtual ~Update_prc_converter() NOEXCEPT {} void set_data_model(cdk::protocol::mysqlx::Data_model dm) { diff --git a/cdk/protocol/mysqlx/builders.h b/cdk/protocol/mysqlx/builders.h index 36f7b3b20..d6f303a9e 100644 --- a/cdk/protocol/mysqlx/builders.h +++ b/cdk/protocol/mysqlx/builders.h @@ -285,7 +285,7 @@ struct Builder_base m_args_conv = conv; } - virtual ~Builder_base() {} + virtual ~Builder_base() NOEXCEPT {} }; @@ -1148,7 +1148,7 @@ class Placeholder_conv_imp unsigned m_offset = 0; public: - virtual ~Placeholder_conv_imp() {} + virtual ~Placeholder_conv_imp() NOEXCEPT {} void clear() { diff --git a/cdk/protocol/mysqlx/crud.cc b/cdk/protocol/mysqlx/crud.cc index 30bb27103..b3171d97b 100644 --- a/cdk/protocol/mysqlx/crud.cc +++ b/cdk/protocol/mysqlx/crud.cc @@ -708,9 +708,8 @@ class Update_builder , m_conv(conv) {} - ~Update_builder() - { - } + ~Update_builder() NOEXCEPT + {} virtual void target_name(const string &name) { diff --git a/cdk/protocol/mysqlx/protocol.cc b/cdk/protocol/mysqlx/protocol.cc index e09e416cc..6c5994305 100644 --- a/cdk/protocol/mysqlx/protocol.cc +++ b/cdk/protocol/mysqlx/protocol.cc @@ -163,7 +163,7 @@ Protocol_impl::Protocol_impl(Protocol::Stream *str, Protocol_side side) } -Protocol_impl::~Protocol_impl() +Protocol_impl::~Protocol_impl() NOEXCEPT { free(m_rd_buf); free(m_wr_buf); diff --git a/cdk/protocol/mysqlx/protocol.h b/cdk/protocol/mysqlx/protocol.h index b22939946..cfdf9d653 100644 --- a/cdk/protocol/mysqlx/protocol.h +++ b/cdk/protocol/mysqlx/protocol.h @@ -162,7 +162,7 @@ class Protocol_impl : public Processor_base protected: Protocol_impl(Protocol::Stream*, Protocol_side); - virtual ~Protocol_impl(); + virtual ~Protocol_impl() NOEXCEPT; public: @@ -973,12 +973,14 @@ class Msg_builder } } - ~Msg_builder() + ~Msg_builder() NOEXCEPT { if (m_stmt_id != 0) + try { Prepare_traits::release(m_prepare); } + catch (...) {} } diff --git a/cdk/protocol/mysqlx/protocol_compression.cc b/cdk/protocol/mysqlx/protocol_compression.cc index 95f38a1f2..ae3f18df6 100644 --- a/cdk/protocol/mysqlx/protocol_compression.cc +++ b/cdk/protocol/mysqlx/protocol_compression.cc @@ -137,7 +137,7 @@ size_t Compression_zlib::uncompress(byte *dst, } -Compression_zlib::~Compression_zlib() +Compression_zlib::~Compression_zlib() NOEXCEPT { if (m_zlib_inited) { @@ -256,7 +256,7 @@ size_t Compression_lz4::uncompress(byte *dst, } -Compression_lz4::~Compression_lz4() +Compression_lz4::~Compression_lz4() NOEXCEPT { if (m_dctx) LZ4F_freeDecompressionContext(m_dctx); @@ -338,7 +338,7 @@ size_t Compression_zstd::uncompress(byte *dst, } -Compression_zstd::~Compression_zstd() +Compression_zstd::~Compression_zstd() NOEXCEPT { if (m_u_zstd) ZSTD_freeDStream(m_u_zstd); @@ -456,7 +456,7 @@ void Protocol_compression::set_compression_type } -Protocol_compression::~Protocol_compression() +Protocol_compression::~Protocol_compression() NOEXCEPT { if (m_c_out_buf) free(m_c_out_buf); diff --git a/cdk/protocol/mysqlx/protocol_compression.h b/cdk/protocol/mysqlx/protocol_compression.h index a61b0f005..3a0f03047 100644 --- a/cdk/protocol/mysqlx/protocol_compression.h +++ b/cdk/protocol/mysqlx/protocol_compression.h @@ -67,7 +67,7 @@ class Compression_algorithm size_t compressed_size, size_t &bytes_consumed) = 0; - virtual ~Compression_algorithm() {} + virtual ~Compression_algorithm() NOEXCEPT {} }; @@ -88,7 +88,7 @@ class Compression_zlib : public Compression_algorithm size_t compress(byte *src, size_t len) override; size_t uncompress(byte *dst, size_t dest_size, size_t compressed_size, size_t &bytes_consumed) override; - ~Compression_zlib(); + ~Compression_zlib() NOEXCEPT; }; @@ -109,7 +109,7 @@ class Compression_lz4 : public Compression_algorithm size_t compress(byte *src, size_t len) override; size_t uncompress(byte *dst, size_t dest_size, size_t compressed_size, size_t &bytes_consumed) override; - ~Compression_lz4(); + ~Compression_lz4() NOEXCEPT; }; @@ -129,7 +129,7 @@ class Compression_zstd : public Compression_algorithm size_t compress(byte *src, size_t len) override; size_t uncompress(byte *dst, size_t dest_size, size_t compressed_size, size_t &bytes_consumed) override; - ~Compression_zstd(); + ~Compression_zstd() NOEXCEPT; }; @@ -159,7 +159,7 @@ class Protocol_compression Protocol_compression(); - ~Protocol_compression(); + ~Protocol_compression() NOEXCEPT; /* Returns pointer to internal buffer for compressed input diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 587340e3e..2114b6ede 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -29,6 +29,26 @@ file(GLOB HEADERS *.h) +#TODO: Remove -Wno-delete-non-abstract-non-virtual-dtor when bumping ABI and +# adding virtual destructor for DbDoc, Value and Column_detail + +if(CLANG) + +set_compiler_flag(-Wno-delete-non-abstract-non-virtual-dtor) + + # Note: GCC/clang and MSVC compilers have different rules for resolving + # relative paths in #include "..." directives [1]. The clang-cl compiler + # understands both conventions but gives warning when using MSVC rules. Since + # headers included by this code trigger the warning we disable it here (this + # is about version_info.h included from nysqlx/common_constants.h) + # + # [1] https://stackoverflow.com/questions/48538707/include-search-paths-from-included-header-varies-for-different-compilers + + set_compiler_flag(-Wno-microsoft-include) + +endif() + + add_library(common STATIC session.cc result.cc collection.cc value.cc ${HEADERS} @@ -36,13 +56,6 @@ add_library(common STATIC target_link_libraries(common cdk) -#TODO: Remove -Wno-delete-non-abstract-non-virtual-dtor when bumping ABI and - # adding virtual destructor for DbDoc, Value and Column_detail -if(CLANG) - target_compile_options(common PRIVATE - -Wno-delete-non-abstract-non-virtual-dtor - ) -endif() # # Note: generated version_info.h is placed in the build location diff --git a/common/op_impl.h b/common/op_impl.h index 86a0bf281..0c1d0d66b 100644 --- a/common/op_impl.h +++ b/common/op_impl.h @@ -141,11 +141,15 @@ class Op_base virtual ~Op_base() override { - // Let's aquire lock so that any remaingin replies are consumed on ~Reply - // and this way avoid race conditions with Client::close() - auto lock = m_sess->lock(); - release_stmt_id(); - m_reply.reset(); + try { + // Let's aquire lock so that any remaingin replies are consumed on ~Reply + // and this way avoid race conditions with Client::close() + auto lock = m_sess->lock(); + release_stmt_id(); + m_reply.reset(); + } + catch (...) + {} } cdk::Session& get_cdk_session() diff --git a/common/tests/CMakeLists.txt b/common/tests/CMakeLists.txt index a70e13164..aac020043 100644 --- a/common/tests/CMakeLists.txt +++ b/common/tests/CMakeLists.txt @@ -36,14 +36,6 @@ set_property( PROPERTY COMPILE_DEFINITIONS "" ) -if(WIN32) - add_definitions( - -D_CRT_SECURE_NO_WARNINGS - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) - -endif() - #Add cdk includes because we are using their source tests add_test_includes(${PROJECT_SOURCE_DIR}/cdk/include) add_test_includes(${PROJECT_SOURCE_DIR}/cdk/extra/rapidjson/include) diff --git a/devapi/impl.h b/devapi/impl.h index e1056fa25..351e6a55a 100644 --- a/devapi/impl.h +++ b/devapi/impl.h @@ -369,7 +369,7 @@ class DbDoc::Impl friend Value::Access; public: - virtual ~Impl(){} + virtual ~Impl() NOEXCEPT {} }; diff --git a/devapi/result.cc b/devapi/result.cc index 9bd8d0f26..ca940490c 100644 --- a/devapi/result.cc +++ b/devapi/result.cc @@ -488,7 +488,7 @@ Result_detail::Result_detail(Result_init &init) } -Result_detail::~Result_detail() +Result_detail::~Result_detail() NOEXCEPT { try { if (m_owns_impl) diff --git a/devapi/session.cc b/devapi/session.cc index 7e8bc75af..6bf853836 100644 --- a/devapi/session.cc +++ b/devapi/session.cc @@ -370,7 +370,7 @@ mysqlx::string Session_detail::get_default_schema_name() */ -Query_src::~Query_src() +Query_src::~Query_src() NOEXCEPT { delete m_res; } diff --git a/devapi/tests/CMakeLists.txt b/devapi/tests/CMakeLists.txt index 6c71501d4..d1201867f 100644 --- a/devapi/tests/CMakeLists.txt +++ b/devapi/tests/CMakeLists.txt @@ -38,13 +38,6 @@ set_property( PROPERTY COMPILE_DEFINITIONS "" ) -if(WIN32) - add_definitions( - -D_CRT_SECURE_NO_WARNINGS - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) - -endif() # # If linking with connector statically, define macro that indicates this diff --git a/doc/devapi_ref.txt b/doc/devapi_ref.txt index f44cd6944..0523bae4b 100644 --- a/doc/devapi_ref.txt +++ b/doc/devapi_ref.txt @@ -20,7 +20,7 @@ To get started, check out some of the main X DevAPI classes: the `mysqlx::Collection` or `mysqlx::Table` class, such as [`find()`](@ref mysqlx::abi2::r0::Collection::find). They are executed with - the [`execute()`](@ref mysqlx::abi2::r0::CollectionFind::execute) method. + the [`execute()`](@ref mysqlx::abi2::r0::Executable::execute) method. - Results of a query are examined using `mysqlx::DocResult` or `mysqlx::RowResult` instances returned from `execute()` method. Method diff --git a/doc/doxygen.cfg b/doc/doxygen.cfg index 7bf32bcf1..495d48568 100644 --- a/doc/doxygen.cfg +++ b/doc/doxygen.cfg @@ -25,7 +25,6 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - # Doxyfile 1.8.10 # This file describes the settings to be used by the documentation system @@ -40,16 +39,26 @@ # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). +# +# Note: +# +# Use doxygen to compare the used configuration file with the template +# configuration file: +# doxygen -x [configFile] +# Use doxygen to compare the used configuration file with the template +# configuration file without replacing the environment variables or CMake type +# replacement variables: +# doxygen -x_noenv [configFile] #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 @@ -66,7 +75,7 @@ PROJECT_NAME = "MySQL Connector/C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 8.0.23 +PROJECT_NUMBER = 9.3.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -88,16 +97,28 @@ PROJECT_LOGO = OUTPUT_DIRECTORY = $(OUTPUT_DIRECTORY) -# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 +# sub-directories (in 2 levels) under the output directory of each output format +# and will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes -# performance problems for the file system. +# performance problems for the file system. Adapt CREATE_SUBDIRS_LEVEL to +# control the number of sub-directories. # The default value is: NO. CREATE_SUBDIRS = NO +# Controls the number of sub-directories that will be created when +# CREATE_SUBDIRS tag is set to YES. Level 0 represents 16 directories, and every +# level increment doubles the number of directories, resulting in 4096 +# directories at level 8 which is the default and also the maximum value. The +# sub-directories are organized in 2 levels, the first level always has a fixed +# number of 16 directories. +# Minimum value: 0, maximum value: 8, default value: 8. +# This tag requires that the tag CREATE_SUBDIRS is set to YES. + +CREATE_SUBDIRS_LEVEL = 8 + # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode @@ -109,14 +130,14 @@ ALLOW_UNICODE_NAMES = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Bulgarian, +# Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, English +# (United States), Esperanto, Farsi (Persian), Finnish, French, German, Greek, +# Hindi, Hungarian, Indonesian, Italian, Japanese, Japanese-en (Japanese with +# English messages), Korean, Korean-en (Korean with English messages), Latvian, +# Lithuanian, Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, +# Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, +# Swedish, Turkish, Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English @@ -207,6 +228,16 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = YES +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus @@ -227,6 +258,14 @@ QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. @@ -250,19 +289,19 @@ TAB_SIZE = 4 # the documentation. An alias has the form: # name=value # For example adding -# "sideeffect=@par Side Effects:\n" +# "sideeffect=@par Side Effects:^^" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. +# "Side Effects:". Note that you cannot put \n's in the value part of an alias +# to insert newlines (in the resulting output). You can put ^^ in the value part +# of an alias to insert a newline as if a physical newline was in the original +# file. When you need a literal { or } or , in the value part of an alias you +# have to escape them by means of a backslash (\), this can lead to conflicts +# with the commands \{ and \} for these it is advised to use the version @{ and +# @} or use a double escape (\\{ and \\}) -ALIASES = "copyright_line=Copyright (c) 2015, 2020, Oracle and/or its affiliates." - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = +ALIASES += "copyright_line=Copyright (c) 2015, 2024, Oracle and/or its affiliates." +ALIASES += "ver_major=9" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -292,28 +331,40 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice, +# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. EXTENSION_MAPPING = txt=md # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. +# documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. @@ -321,6 +372,15 @@ EXTENSION_MAPPING = txt=md MARKDOWN_SUPPORT = YES +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or @@ -346,7 +406,7 @@ BUILTIN_STL_SUPPORT = YES CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. @@ -432,6 +492,19 @@ TYPEDEF_HIDES_STRUCT = YES LOOKUP_CACHE_SIZE = 0 +# The NUM_PROC_THREADS specifies the number of threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which effectively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -452,6 +525,12 @@ EXTRACT_ALL = NO EXTRACT_PRIVATE = NO +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. @@ -489,6 +568,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -500,14 +586,15 @@ HIDE_UNDOC_MEMBERS = YES # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option -# has no effect if EXTRACT_ALL is enabled. +# will also hide undocumented C++ concepts if enabled. This option has no effect +# if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. +# declarations. If set to NO, these declarations will be included in the +# documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = YES @@ -526,14 +613,21 @@ HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = NO +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# Possible values are: SYSTEM, NO and YES. +# The default value is: SYSTEM. +# CASE_SENSE_NAMES = SYSTEM # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the @@ -549,6 +643,12 @@ HIDE_SCOPE_NAMES = YES HIDE_COMPOUND_REFERENCE= NO +# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class +# will show which file needs to be included to use the class. +# The default value is: YES. + +SHOW_HEADERFILE = YES + # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. @@ -706,7 +806,8 @@ FILE_VERSION_FILTER = # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. +# will be used as the name of the layout file. See also section "Changing the +# layout of pages" for information. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE @@ -717,7 +818,7 @@ LAYOUT_FILE = $(OUTPUT_DIRECTORY)/DoxygenLayout.xml # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. @@ -752,34 +853,81 @@ WARNINGS = YES WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. +# potential errors in the documentation, such as documenting some parameters in +# a documented function twice, or documenting parameters that don't exist or +# using markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES +# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete +# function parameter documentation. If set to NO, doxygen will accept that some +# parameters have no documentation without warning. +# The default value is: YES. + +WARN_IF_INCOMPLETE_DOC = YES + # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return -# value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. +# value. If set to NO, doxygen will only warn about wrong parameter +# documentation, but not about the absence of documentation. If EXTRACT_ALL is +# set to YES then this flag will automatically be disabled. See also +# WARN_IF_INCOMPLETE_DOC # The default value is: NO. WARN_NO_PARAMDOC = NO +# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about +# undocumented enumeration values. If set to NO, doxygen will accept +# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: NO. + +WARN_IF_UNDOC_ENUM_VAL = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS_PRINT then doxygen behaves +# like FAIL_ON_WARNINGS but in case no WARN_LOGFILE is defined doxygen will not +# write the warning messages in between other messages but write them at the end +# of a run, in case a WARN_LOGFILE is defined the warning messages will be +# besides being in the defined file also be shown at the end of a run, unless +# the WARN_LOGFILE is defined as - i.e. standard outpyt (stdout) in that case +# the behavior will remain as with the setting FAIL_ON_WARNINGS. +# Possible values are: NO, YES, FAIL_ON_WARNINGS and FAIL_ON_WARNINGS_PRINT. +# The default value is: NO. + +WARN_AS_ERROR = NO + # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) +# See also: WARN_LINE_FORMAT # The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" +# In the $text part of the WARN_FORMAT command it is possible that a reference +# to a more specific place is given. To make it easier to jump to this place +# (outside of doxygen) the user can define a custom "cut" / "paste" string. +# Example: +# WARN_LINE_FORMAT = "'vi $file +$line'" +# See also: WARN_FORMAT +# The default value is: at line $line of file $file. + +WARN_LINE_FORMAT = "at line $line of file $file" + # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard -# error (stderr). +# error (stderr). In case the file specified cannot be opened for writing the +# warning and error messages are written to standard error. When as file - is +# specified the warning and error messages are written to standard output +# (stdout). WARN_LOGFILE = @@ -798,12 +946,23 @@ INPUT = include doc # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# See also: INPUT_FILE_ENCODING # The default value is: UTF-8. INPUT_ENCODING = UTF-8 +# This tag can be used to specify the character encoding of the source files +# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify +# character encoding on a per file pattern basis. Doxygen will compare the file +# name with each pattern and apply the encoding instead of the default +# INPUT_ENCODING) if there is a match. The character encodings are a list of the +# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding +# "INPUT_ENCODING" for further information on supported encodings. + +INPUT_FILE_ENCODING = + # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. @@ -812,11 +971,15 @@ INPUT_ENCODING = UTF-8 # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, -# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, -# *.vhdl, *.ucf, *.qsf, *.as and *.js. +# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, +# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C +# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. FILE_PATTERNS = *.cc *.c *.h *.txt @@ -855,7 +1018,7 @@ EXCLUDE_PATTERNS = */CMakeLists.txt # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test +# ANamespace::AClass, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* @@ -902,6 +1065,15 @@ IMAGE_PATH = # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. +# +# Note that doxygen will use the data processed and written to standard output +# for further processing, therefore nothing else, like debug statements or used +# commands (so in case of a Windows batch file always use @echo OFF), should be +# written to standard output. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. INPUT_FILTER = @@ -911,6 +1083,10 @@ INPUT_FILTER = # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. FILTER_PATTERNS = @@ -936,6 +1112,15 @@ FILTER_SOURCE_PATTERNS = USE_MDFILE_AS_MAINPAGE = doc/index.txt +# The Fortran standard specifies that for fixed formatted Fortran code all +# characters from position 72 are to be considered as comment. A common +# extension is to allow longer lines before the automatic comment starts. The +# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can +# be processed before the automatic comment starts. +# Minimum value: 7, maximum value: 10000, default value: 72. + +FORTRAN_COMMENT_AFTER = 72 + #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- @@ -963,7 +1148,7 @@ INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. +# entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO @@ -995,12 +1180,12 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version +# (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # @@ -1023,15 +1208,26 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. # Note: The availability of this option depends on whether or not doxygen was -# compiled with the --with-libclang option. +# generated with the -Duse_libclang=ON option for CMake. # The default value is: NO. -CLANG_ASSISTED_PARSING = NO +# Note: I could not make it work, triggers errors like below +# > error: /usr/include/wchar.h:35:10: fatal error: 'stddef.h' file not found [clang] + +CLANG_ASSISTED_PARSING = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES and the CLANG_ADD_INC_PATHS +# tag is set to YES then doxygen will add the directory of each input to the +# include path. +# The default value is: YES. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_ADD_INC_PATHS = YES # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that @@ -1041,6 +1237,19 @@ CLANG_ASSISTED_PARSING = NO #CLANG_OPTIONS = -Wno-unknown-pragmas +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -1052,17 +1261,11 @@ CLANG_ASSISTED_PARSING = NO ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. +# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) +# that should be ignored while generating the index headers. The IGNORE_PREFIX +# tag works for classes, function and member names. The entity will be placed in +# the alphabetical list under the first letter of the entity name that remains +# after removing the prefix. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = mysqlx_ @@ -1141,7 +1344,12 @@ HTML_STYLESHEET = # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. +# list). +# Note: Since the styling of scrollbars can currently not be overruled in +# Webkit/Chromium, the styling will be left out of the default doxygen.css if +# one or more extra stylesheets have been specified. So if scrollbar +# customization is desired it has to be added explicitly. For an example see the +# documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = @@ -1156,10 +1364,23 @@ HTML_EXTRA_STYLESHEET = HTML_EXTRA_FILES = +# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output +# should be rendered with a dark or light theme. +# Possible values are: LIGHT always generate light mode output, DARK always +# generate dark mode output, AUTO_LIGHT automatically set the mode according to +# the user preference, use light mode if no preference is set (the default), +# AUTO_DARK automatically set the mode according to the user preference, use +# dark mode if no preference is set and TOGGLE allow to user to switch between +# light and dark mode via a button. +# The default value is: AUTO_LIGHT. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE = AUTO_LIGHT + # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# this color. Hue is specified as an angle on a color-wheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. @@ -1168,7 +1389,7 @@ HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A +# in the HTML output. For a value of 0 the output will use gray-scales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1195,6 +1416,17 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. @@ -1218,13 +1450,14 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1238,6 +1471,13 @@ GENERATE_DOCSET = NO DOCSET_FEEDNAME = "Doxygen generated docs" +# This tag determines the URL of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDURL = + # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. @@ -1263,8 +1503,12 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. +# on Windows. In the beginning of 2021 Microsoft took the original page, with +# a.o. the download links, offline the HTML help workshop was already many years +# in maintenance mode). You can download the HTML help workshop from the web +# archives at Installation executable (see: +# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo +# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe). # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML @@ -1294,7 +1538,7 @@ CHM_FILE = HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). +# (YES) or that it should be included in the main .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1339,7 +1583,8 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1347,8 +1592,8 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1356,30 +1601,30 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = @@ -1422,16 +1667,28 @@ DISABLE_INDEX = NO # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. +# further fine tune the look of the index (see "Fine-tuning the output"). As an +# example, the default style sheet generated by doxygen has an example that +# shows how to put an image at the root of the tree instead of the PROJECT_NAME. +# Since the tree basically has the same information as the tab index, you could +# consider setting DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO +# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the +# FULL_SIDEBAR option determines if the side bar is limited to only the treeview +# area (value NO) or if it should extend to the full height of the window (value +# YES). Setting this to YES gives a layout similar to +# https://docs.readthedocs.io with more room for contents, but less room for the +# project logo, title, and description. If either GENERATE_TREEVIEW or +# DISABLE_INDEX is set to NO, this option has no effect. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FULL_SIDEBAR = NO + # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # @@ -1456,6 +1713,24 @@ TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email +# addresses. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +OBFUSCATE_EMAILS = YES + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML @@ -1465,19 +1740,14 @@ EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. -FORMULA_TRANSPARENT = YES +FORMULA_MACROFILE = # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering +# https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1487,11 +1757,29 @@ FORMULA_TRANSPARENT = YES USE_MATHJAX = NO +# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. +# Note that the different versions of MathJax have different requirements with +# regards to the different settings, so it is possible that also other MathJax +# settings have to be changed when switching between the different MathJax +# versions. +# Possible values are: MathJax_2 and MathJax_3. +# The default value is: MathJax_2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_VERSION = MathJax_2 + # When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# the MathJax output. For more details about the output format see MathJax +# version 2 (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3 +# (see: +# http://docs.mathjax.org/en/latest/web/components/output.html). # Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. +# compatibility. This is the name for Mathjax version 2, for MathJax version 3 +# this will be translated into chtml), NativeMML (i.e. MathML. Only supported +# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This +# is the name for Mathjax version 3, for MathJax version 2 this will be +# translated into HTML-CSS) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1504,22 +1792,29 @@ MATHJAX_FORMAT = HTML-CSS # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. +# MathJax from https://www.mathjax.org before deployment. The default value is: +# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2 +# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3 # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_RELPATH = # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example +# for MathJax version 2 (see +# https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-extensions): # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# For example for MathJax version 3 (see +# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): +# MATHJAX_EXTENSIONS = ams # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1547,7 +1842,7 @@ MATHJAX_CODEFILE = SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There +# implemented using a web server instead of a web client using JavaScript. There # are two flavors of web server based searching depending on the EXTERNAL_SEARCH # setting. When disabled, doxygen will generate a PHP script for searching and # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing @@ -1566,7 +1861,8 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). +# Xapian (see: +# https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1579,8 +1875,9 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and -# Searching" for details. +# Xapian (see: +# https://xapian.org/). See the section "External Indexing and Searching" for +# details. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHENGINE_URL = @@ -1631,21 +1928,35 @@ LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. # -# Note that when enabling USE_PDFLATEX this option is only used for generating -# bitmaps for formulas in the HTML output, but not in the Makefile that is -# written to the output directory. -# The default file is: latex. +# Note that when not enabling USE_PDFLATEX the default is latex when enabling +# USE_PDFLATEX the default is pdflatex and when in the later case latex is +# chosen this is overwritten by pdflatex. For specific output languages the +# default can have been set differently, this depends on the implementation of +# the output language. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_CMD_NAME = latex +LATEX_CMD_NAME = # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate # index for LaTeX. +# Note: This tag is used in the Makefile / make.bat. +# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file +# (.tex). # The default file is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. MAKEINDEX_CMD_NAME = makeindex +# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to +# generate index for LaTeX. In case there is no backslash (\) as first character +# it will be automatically added in the LaTeX code. +# Note: This tag is used in the generated output file (.tex). +# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. +# The default value is: makeindex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_MAKEINDEX_CMD = makeindex + # If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX # documents. This may be useful for small projects and may help to save some # trees in general. @@ -1675,29 +1986,31 @@ PAPER_TYPE = a4 EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the -# generated LaTeX document. The header should contain everything until the first -# chapter. If it is left blank doxygen will generate a standard header. See -# section "Doxygen usage" for information on how to let doxygen write the -# default header to a separate file. +# The LATEX_HEADER tag can be used to specify a user-defined LaTeX header for +# the generated LaTeX document. The header should contain everything until the +# first chapter. If it is left blank doxygen will generate a standard header. It +# is highly recommended to start with a default header using +# doxygen -w latex new_header.tex new_footer.tex new_stylesheet.sty +# and then modify the file new_header.tex. See also section "Doxygen usage" for +# information on how to generate the default header that doxygen normally uses. # -# Note: Only use a user-defined header if you know what you are doing! The -# following commands have a special meaning inside the header: $title, -# $datetime, $date, $doxygenversion, $projectname, $projectnumber, -# $projectbrief, $projectlogo. Doxygen will replace $title with the empty -# string, for the replacement values of the other commands the user is referred -# to HTML_HEADER. +# Note: Only use a user-defined header if you know what you are doing! +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. The following +# commands have a special meaning inside the header (and footer): For a +# description of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_HEADER = -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the -# generated LaTeX document. The footer should contain everything after the last -# chapter. If it is left blank doxygen will generate a standard footer. See +# The LATEX_FOOTER tag can be used to specify a user-defined LaTeX footer for +# the generated LaTeX document. The footer should contain everything after the +# last chapter. If it is left blank doxygen will generate a standard footer. See # LATEX_HEADER for more information on how to generate a default footer and what -# special commands can be used inside the footer. -# -# Note: Only use a user-defined footer if you know what you are doing! +# special commands can be used inside the footer. See also section "Doxygen +# usage" for information on how to generate the default footer that doxygen +# normally uses. Note: Only use a user-defined footer if you know what you are +# doing! # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_FOOTER = @@ -1730,9 +2043,11 @@ LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES, to get a -# higher quality PDF documentation. +# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as +# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX +# files. Set this option to YES, to get a higher quality PDF documentation. +# +# See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1740,8 +2055,7 @@ USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode # command to the generated LaTeX files. This will instruct LaTeX to keep running -# if errors occur, instead of asking the user for help. This option is also used -# when generating formulas in HTML. +# if errors occur, instead of asking the user for help. # The default value is: NO. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1754,24 +2068,30 @@ LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO -# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source -# code with syntax highlighting in the LaTeX output. -# -# Note that which sources are shown also depends on other settings such as -# SOURCE_BROWSER. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_SOURCE_CODE = NO - # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_BIB_STYLE = plain +# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_TIMESTAMP = NO + +# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) +# path from which the emoji images will be read. If a relative path is entered, +# it will be relative to the LATEX_OUTPUT directory. If left blank the +# LATEX_OUTPUT directory will be used. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EMOJI_DIRECTORY = + #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -1811,9 +2131,9 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's config -# file, i.e. a series of assignments. You only have to provide replacements, -# missing definitions are set to their default value. +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# configuration file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. # # See also section "Doxygen usage" for information on how to generate the # default style sheet that doxygen normally uses. @@ -1822,22 +2142,12 @@ RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is -# similar to doxygen's config file. A template extensions file can be generated -# using doxygen -e rtf extensionFile. +# similar to doxygen's configuration file. A template extensions file can be +# generated using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_EXTENSIONS_FILE = -# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code -# with syntax highlighting in the RTF output. -# -# Note that which sources are shown also depends on other settings such as -# SOURCE_BROWSER. -# The default value is: NO. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_SOURCE_CODE = NO - #--------------------------------------------------------------------------- # Configuration options related to the man page output #--------------------------------------------------------------------------- @@ -1890,7 +2200,7 @@ MAN_LINKS = NO # captures the structure of the code including all documentation. # The default value is: NO. -GENERATE_XML = No +GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of @@ -1909,6 +2219,13 @@ XML_OUTPUT = xml XML_PROGRAMLISTING = YES +# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include +# namespace members in file scope as well, matching the HTML output. +# The default value is: NO. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_NS_MEMB_FILE_SCOPE = NO + #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- @@ -1927,23 +2244,14 @@ GENERATE_DOCBOOK = NO DOCBOOK_OUTPUT = docbook -# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the -# program listings (including syntax highlighting and cross-referencing -# information) to the DOCBOOK output. Note that enabling this will significantly -# increase the size of the DOCBOOK output. -# The default value is: NO. -# This tag requires that the tag GENERATE_DOCBOOK is set to YES. - -DOCBOOK_PROGRAMLISTING = NO - #--------------------------------------------------------------------------- # Configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an -# AutoGen Definitions (see http://autogen.sf.net) file that captures the -# structure of the code including all documentation. Note that this feature is -# still experimental and incomplete at the moment. +# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures +# the structure of the code including all documentation. Note that this feature +# is still experimental and incomplete at the moment. # The default value is: NO. GENERATE_AUTOGEN_DEF = NO @@ -2022,7 +2330,8 @@ SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by the -# preprocessor. +# preprocessor. Note that the INCLUDE_PATH is not recursive, so the setting of +# RECURSIVE has no effect here. # This tag requires that the tag SEARCH_INCLUDES is set to YES. INCLUDE_PATH = @@ -2110,34 +2419,10 @@ EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of 'which perl'). -# The default file (with absolute path) is: /usr/bin/perl. - -PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram -# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to -# NO turns the diagrams off. Note that this option also works with HAVE_DOT -# disabled, but it is recommended to install and use dot, since it yields more -# powerful graphs. -# The default value is: YES. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see: -# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. @@ -2170,35 +2455,50 @@ HAVE_DOT = NO DOT_NUM_THREADS = 0 -# When you want a differently looking font in the dot files that doxygen -# generates you can specify the font name using DOT_FONTNAME. You need to make -# sure dot is able to find the font, which can be done by putting it in a -# standard location or by setting the DOTFONTPATH environment variable or by -# setting DOT_FONTPATH to the directory containing the font. -# The default value is: Helvetica. +# DOT_COMMON_ATTR is common attributes for nodes, edges and labels of +# subgraphs. When you want a differently looking font in the dot files that +# doxygen generates you can specify fontname, fontcolor and fontsize attributes. +# For details please see Node, +# Edge and Graph Attributes specification You need to make sure dot is able +# to find the font, which can be done by putting it in a standard location or by +# setting the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. Default graphviz fontsize is 14. +# The default value is: fontname=Helvetica,fontsize=10. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_COMMON_ATTR = "fontname=Helvetica,fontsize=10" + +# DOT_EDGE_ATTR is concatenated with DOT_COMMON_ATTR. For elegant style you can +# add 'arrowhead=open, arrowtail=open, arrowsize=0.5'. Complete documentation about +# arrows shapes. +# The default value is: labelfontname=Helvetica,labelfontsize=10. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTNAME = Helvetica +DOT_EDGE_ATTR = "labelfontname=Helvetica,labelfontsize=10" -# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of -# dot graphs. -# Minimum value: 4, maximum value: 24, default value: 10. +# DOT_NODE_ATTR is concatenated with DOT_COMMON_ATTR. For view without boxes +# around nodes set 'shape=plain' or 'shape=plaintext' Shapes specification +# The default value is: shape=box,height=0.2,width=0.4. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTSIZE = 10 +DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4" -# By default doxygen will tell dot to use the default font as specified with -# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set -# the path where dot can find it using this tag. +# You can set the path where dot can find font specified with fontname in +# DOT_COMMON_ATTR and others dot attributes. # This tag requires that the tag HAVE_DOT is set to YES. DOT_FONTPATH = -# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for -# each documented class showing the direct and indirect inheritance relations. -# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO. +# If the CLASS_GRAPH tag is set to YES (or GRAPH) then doxygen will generate a +# graph for each documented class showing the direct and indirect inheritance +# relations. In case HAVE_DOT is set as well dot will be used to draw the graph, +# otherwise the built-in generator will be used. If the CLASS_GRAPH tag is set +# to TEXT the direct and indirect inheritance relations will be shown as texts / +# links. +# Possible values are: NO, YES, TEXT and GRAPH. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. CLASS_GRAPH = NO @@ -2212,7 +2512,8 @@ CLASS_GRAPH = NO COLLABORATION_GRAPH = NO # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for -# groups, showing the direct groups dependencies. +# groups, showing the direct groups dependencies. See also the chapter Grouping +# in the manual. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. @@ -2235,10 +2536,32 @@ UML_LOOK = NO # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. +# This tag requires that the tag UML_LOOK is set to YES. UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2305,6 +2628,13 @@ GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES +# The DIR_GRAPH_MAX_DEPTH tag can be used to limit the maximum number of levels +# of child directories generated in directory dependency graphs by dot. +# Minimum value: 1, maximum value: 25, default value: 1. +# This tag requires that the tag DIRECTORY_GRAPH is set to YES. + +DIR_GRAPH_MAX_DEPTH = 1 + # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. For an explanation of the image formats see the section # output formats in the documentation of the dot tool (Graphviz (see: @@ -2358,13 +2688,18 @@ MSCFILE_DIRS = DIAFILE_DIRS = # When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the -# path where java can find the plantuml.jar file. If left blank, it is assumed -# PlantUML is not used or called during a preprocessing step. Doxygen will -# generate a warning when it encounters a \startuml command in this case and -# will not generate output for the diagram. +# path where java can find the plantuml.jar file or to the filename of jar file +# to be used. If left blank, it is assumed PlantUML is not used or called during +# a preprocessing step. Doxygen will generate a warning when it encounters a +# \startuml command in this case and will not generate output for the diagram. PLANTUML_JAR_PATH = +# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a +# configuration file for plantuml. + +PLANTUML_CFG_FILE = + # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. @@ -2394,18 +2729,6 @@ DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not seem -# to support this out of the box. -# -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_TRANSPARENT = NO - # Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) support @@ -2418,14 +2741,18 @@ DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page # explaining the meaning of the various boxes and arrows in the dot generated # graphs. +# Note: This tag requires that UML_LOOK isn't set, i.e. the doxygen internal +# graphical representation for inheritance and collaboration diagrams is used. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate # files that are used to generate the various graphs. +# +# Note: This setting is not only used for dot files but also for msc temporary +# files. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES diff --git a/doc/doxygen.cfg.in b/doc/doxygen.cfg.in index 4dd1fbca3..d35a4209f 100644 --- a/doc/doxygen.cfg.in +++ b/doc/doxygen.cfg.in @@ -75,7 +75,7 @@ PROJECT_NAME = "MySQL Connector/C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = @CONCPP_PACKAGE_NUMERIC_VERSION@ +PROJECT_NUMBER = @CONCPP_VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -300,7 +300,8 @@ TAB_SIZE = 4 # with the commands \{ and \} for these it is advised to use the version @{ and # @} or use a double escape (\\{ and \\}) -ALIASES = "copyright_line=Copyright (c) 2015, 2020, Oracle and/or its affiliates." +ALIASES += "copyright_line=Copyright (c) 2015, 2024, Oracle and/or its affiliates." +ALIASES += "ver_major=@CONCPP_VERSION_MAJOR@" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -626,8 +627,7 @@ INTERNAL_DOCS = NO # YES. # Possible values are: SYSTEM, NO and YES. # The default value is: SYSTEM. - -CASE_SENSE_NAMES = SYSTEM +# CASE_SENSE_NAMES = SYSTEM # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the diff --git a/doc/index.txt b/doc/index.txt index 3bd73733a..110c40ede 100644 --- a/doc/index.txt +++ b/doc/index.txt @@ -2,7 +2,7 @@ MySQL Connector/C++ Documentation {#mainpage} ============================================== MySQL Connector/C++ is a library for applications written in C or C++ that -communicate with MySQL database servers. Version 8 of Connector/C++ +communicate with MySQL database servers. Version @ver_major of Connector/C++ implements three different APIs which can be used by applications: - The [X DevAPI](@ref devapi_example) for applications written in C++. diff --git a/doc/usage.txt b/doc/usage.txt index 2f6d9cb58..cc331857b 100644 --- a/doc/usage.txt +++ b/doc/usage.txt @@ -6,7 +6,7 @@ uses Connector/C++ it is enough to link that target with the `mysql::concpp` target defined after loading the `mysql-concpp` module into the project, as in this example: ~~~~~~ - find_module(mysql-concpp REQUIRED) + find_package(mysql-concpp REQUIRED) add_executable(my-target ...) target_link_libraries(my-target mysql::concpp) @@ -14,14 +14,14 @@ in this example: This ensures correct compiler and linker flags when building `my-target` so that connector public headers, the libraries and their dependencies are found when compiling and linking the target. See the CMake documentation -for more information on `find_module()` command and on using CMake modules. +for more information on `find_package()` command and on using CMake modules. We focus here on the scenario where Connector/C++ is installed from a package published by MySQL. There are two variants of this scenario. Either the connector is installed system-wide via package manager such as RPM or DEB, or it is installed locally from TGZ or ZIP package. In case of system-wide installation connector components are installed to default locations and things -are expected to work out-of-the-box. In this case `find_module(mysql-concpp)` +are expected to work out-of-the-box. In this case `find_package(mysql-concpp)` command should work without any further configuration. In case of local installation you need to tell CMake where to look for @@ -29,7 +29,7 @@ the `mysql-concpp` module. This can be done by setting the `mysql-concpp_DIR` variable to the top-level Connector/C++ install location: ~~~~~~ set(mysql-concpp_DIR "/path/to/concpp/install") - find_module(mysql-concpp) + find_package(mysql-concpp) ~~~~~~ (Alternatively the variable can be set when invoking `cmake` using `-Dmysql-concpp_DIR=/path/to/concpp/install` option). @@ -193,7 +193,7 @@ When loading the `mysql-concpp` module a "debug" component can be required so that cmake will report error if debug variants of connector libraries are not found: ~~~~~~ - find_module(mysql-concpp REQUIRE debug) + find_package(mysql-concpp REQUIRE debug) ~~~~~~ Regardless of whether the "debug" component was required or not, the module will set variable `MYSQL_CONCPP_DEBUG_FOUND` to true if debug libraries were @@ -218,7 +218,7 @@ For example: find_package(mysql-concpp) ~~~~ Note that `mysql::openssl` target must be defined before invoking -`find_module(mysql-concpp)` in order to replace the default OpenSSL instance +`find_package(mysql-concpp)` in order to replace the default OpenSSL instance used by the module. diff --git a/include/mysqlx/common.h b/include/mysqlx/common.h index a52429d45..ac97ea710 100644 --- a/include/mysqlx/common.h +++ b/include/mysqlx/common.h @@ -44,6 +44,8 @@ kept in the common/ folder, either as headers or source files. */ +#define NOEXCEPT noexcept + #include "common_constants.h" #include "common/api.h" #include "common/error.h" diff --git a/include/mysqlx/common/op_if.h b/include/mysqlx/common/op_if.h index b17cb7bad..685a43342 100644 --- a/include/mysqlx/common/op_if.h +++ b/include/mysqlx/common/op_if.h @@ -100,7 +100,7 @@ struct Executable_if virtual Executable_if *clone() const = 0; - virtual ~Executable_if() {} + virtual ~Executable_if() NOEXCEPT {} }; diff --git a/include/mysqlx/devapi/detail/result.h b/include/mysqlx/devapi/detail/result.h index ad64dc7b7..83be19583 100644 --- a/include/mysqlx/devapi/detail/result.h +++ b/include/mysqlx/devapi/detail/result.h @@ -94,7 +94,7 @@ class PUBLIC_API Result_detail Result_detail& operator=(Result_detail&&); Result_detail() = default; - virtual ~Result_detail(); + virtual ~Result_detail() NOEXCEPT; Impl& get_impl(); diff --git a/include/mysqlx/devapi/detail/session.h b/include/mysqlx/devapi/detail/session.h index cf4f6d426..b15087062 100644 --- a/include/mysqlx/devapi/detail/session.h +++ b/include/mysqlx/devapi/detail/session.h @@ -85,7 +85,7 @@ class PUBLIC_API Db_obj_base : m_sess(sess), m_name(name) {} - virtual ~Db_obj_base() + virtual ~Db_obj_base() NOEXCEPT {} }; @@ -144,7 +144,7 @@ struct PUBLIC_API Query_src Query_src(const Query_src&) = delete; - virtual ~Query_src(); + virtual ~Query_src() NOEXCEPT; virtual void iterator_start() { @@ -247,6 +247,9 @@ using SQL_statement_cmd = Executable; struct SQL_statement : public Bind_placeholders< SQL_statement_cmd > { + ~SQL_statement() NOEXCEPT + {} + SQL_statement(Session *sess, const string &query) { assert(sess); @@ -372,7 +375,7 @@ struct PUBLIC_API Session_detail Session_detail(common::Settings_impl&); Session_detail(common::Shared_session_pool&); - virtual ~Session_detail() + virtual ~Session_detail() NOEXCEPT { try { if (m_impl) diff --git a/include/mysqlx/devapi/document.h b/include/mysqlx/devapi/document.h index 442dab71c..95c29358f 100644 --- a/include/mysqlx/devapi/document.h +++ b/include/mysqlx/devapi/document.h @@ -360,6 +360,7 @@ class Value CATCH_AND_WRAP } + virtual ~Value() {} public: diff --git a/include/mysqlx/devapi/executable.h b/include/mysqlx/devapi/executable.h index 22f7e763a..2d0fb0536 100644 --- a/include/mysqlx/devapi/executable.h +++ b/include/mysqlx/devapi/executable.h @@ -121,7 +121,7 @@ class Executable operator=(std::move(other)); } - virtual ~Executable() {} + virtual ~Executable() NOEXCEPT {} Executable& operator=(const Executable &other) diff --git a/include/mysqlx/devapi/result.h b/include/mysqlx/devapi/result.h index 3c9e4f971..904636e74 100644 --- a/include/mysqlx/devapi/result.h +++ b/include/mysqlx/devapi/result.h @@ -484,6 +484,9 @@ class Column public: + virtual ~Column() + {} + friend RowResult; struct INTERNAL Access; friend Access; diff --git a/jdbc/CMakeLists.txt b/jdbc/CMakeLists.txt index d80030896..11fc3e4e1 100644 --- a/jdbc/CMakeLists.txt +++ b/jdbc/CMakeLists.txt @@ -79,7 +79,7 @@ if(jdbc_stand_alone) ) add_config_option(BUNDLE_DEPENDENCIES BOOL ADVANCED DEFAULT OFF - "copy dependencies to install location" + "copy dependencies to the install location" ) endif(jdbc_stand_alone) @@ -215,10 +215,8 @@ if(NOT SHOW_JDBC_WARNINGS) else() - add_compile_options( - -Wno-unused-parameter - -Wno-deprecated-declarations - ) + set_compiler_flag(-Wno-unused-parameter) + set_compiler_flag(-Wno-deprecated-declarations) endif() @@ -266,25 +264,12 @@ add_version_info(connector-jdbc "Implements MySQL Connector/C++ legacy JDBC API." ) +# Note: The MySQL::client target works (and is needed) both when linking +# to the MySQL client library dynamically and statically. In the latter case +# it brings additional linker options that are required (e.g. to resolve +# dependencies of the client library code). - -# Note: When connector links statically to the client library, targets using -# the connector must be able to find dependencies of the client library, such -# as openssl libs. The MYSQL_EXTERNAL_SEARCHPATH variable set by DepFindMySQL. -# cmake stores detected locations where client library dependencies that -# are bundled with it can be found. We add it here as interface property -# so that other targets that link with the connector will have library search -# path correctly set in the compile line. -# -# TODO: Modify merge_libraries() logic to autmatically detect transitive link -# directory path properties of merged targets and then set them on the merged -# library target. - -if(MYSQLCLIENT_STATIC_LINKING) - target_link_directories(connector-jdbc INTERFACE - ${MYSQL_EXTERNAL_SEARCHPATH} - ) -endif() +target_link_libraries(connector-jdbc PUBLIC MySQL::client) # @@ -429,6 +414,7 @@ endif() set(AUTH_PLUGINS ldap_sasl oci + openid_connect ) if(NOT CMAKE_SYSTEM_NAME MATCHES "SunOS") @@ -477,8 +463,12 @@ endif() # additional client-side plugins (if any) +# +# Note: The native password authentication plugin is not listed in AUTH_PLUGIN +# list because its name does not follow the common auth_XXX_client pattern +# -set(PLUGINS) +set(PLUGINS mysql_native_password) # additional bundled dependencies of the client library other than the openssl # libraries that are handled separately (in DepFindSSL.cmake) @@ -490,6 +480,33 @@ set(IGNORED_PLUGINS # note: we have our own telemetry code, not using the client library plugin telemetry_client authentication_fido_client # note: replaced by webauthn plugin + # server-side plugins, starting with authentication ones + auth$ auth_socket + authentication_ldap_simple$ authentication_pam$ authentication_windows$ + component_ + libtest_ + keyring_ + semisync_ + adt_null + audit_log + conflicting_variables + connection_control + data_masking + firewall + locking_service + mypluglib + mysql_clone + mysql_no_login + thread_pool + validate_password + version_token + ha_ + qa_ + .*replication + .*rewrite + .*example + .*test + .*mecab ) set(IGNORED_LIBS @@ -541,6 +558,18 @@ function(bundle_lib lib) DESTINATION "${INSTALL_LIB_DIR}" COMPONENT JDBCDll ) + # Symlinks need to be created to allow authenticating + # plugins to load dependencies in MacOS + # + # NOTE: in Linux the dependencies are adressed in + # a different way + install(CODE " + execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink ../${lib_name} ${lib_name} + WORKING_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/plugin\" + ) + ") + else() install(FILES ${lib} DESTINATION "${INSTALL_LIB_DIR}/private" @@ -631,6 +660,26 @@ macro(bundle_libs to_bundle ignored) endforeach() + if(APPLE) + # Create symlinks for OpenSSL dependencies in MacOS. + # The actual OpenSSL libraries should already be + # installed with XDevAPI connector. + # Other dependencies such as fido2 already have symlinks + # created at this stage. + install(CODE " + foreach(openssl_lib ssl crypto) + file(GLOB found_libs \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/lib\${openssl_lib}.*dylib\") + foreach(lib_file \${found_libs}) + get_filename_component(openssl_lib_name \${lib_file} NAME) + execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink ../\${openssl_lib_name} \${openssl_lib_name} + WORKING_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/plugin\" + ) + endforeach(lib_file) + endforeach(openssl_lib) + ") + endif() + endmacro(bundle_libs) @@ -651,11 +700,7 @@ macro(bundle_plugins ignored) get_filename_component(lib_name ${lib} NAME_WE) - if(NOT lib_name MATCHES "_client") - continue() - endif() - - #message("== looking at client-side plugin: ${lib_name}") + #message("== looking at plugin: ${lib_name}") # Match plugin name against names in PLUGINS list and in case of match # remove that name from the list @@ -761,8 +806,10 @@ if(BUNDLE_DEPENDENCIES) # add authentication plugins to the list of plugins foreach(auth ${AUTH_PLUGINS}) - set(plugin "authentication_${auth}") + set(plugin "authentication_${auth}_client") list(APPEND PLUGINS ${plugin}) + # Note: ignore server-side plugin + list(APPEND IGNORED_PLUGINS "authentication_${auth}$") set(DEPS_${plugin} ${AUTH_DEPS_${auth}}) list(APPEND IGNORED_LIBS ${DEPS_${plugin}}) endforeach() @@ -775,7 +822,18 @@ if(BUNDLE_DEPENDENCIES) if(MAINTAINER_MODE) foreach(plugin ${PLUGINS}) - message(SEND_ERROR "known client-side plugin not found and not bundled: ${plugin}") + + # Note: In some RE builds we use a modified build of the client library + # which does not ship the native password authentication plugin but has + # it built-in. Therefore we don't complain if the plugin was not found + # assuming that in this case it is built-in and needs not to be bundled. + + if(NOT plugin STREQUAL "mysql_native_password") + message(SEND_ERROR + "known client-side plugin not found and not bundled: ${plugin}" + ) + endif() + endforeach() foreach(plugin ${IGNORED_PLUGINS}) diff --git a/jdbc/cmake/DepFindMySQL.cmake b/jdbc/cmake/DepFindMySQL.cmake index 096f96712..c94b770cd 100644 --- a/jdbc/cmake/DepFindMySQL.cmake +++ b/jdbc/cmake/DepFindMySQL.cmake @@ -297,7 +297,6 @@ function(main) if(MYSQL_LIB_STATIC) target_link_libraries(mysql-client-if INTERFACE MySQL::client-static) - target_link_libraries(mysql-client-if INTERFACE OpenSSL::SSL) else() target_link_libraries(mysql-client-if INTERFACE MySQL::client-shared) endif() @@ -379,7 +378,7 @@ function(main) # # If external dependencies were found, add them to the static target - # as any code that liks to static library should also link with the + # as any code that links to static library should also link with the # external dependencies. # @@ -492,15 +491,18 @@ function(use_mysql_config) _mysql_conf(MYSQL_INCLUDE_DIR --variable=pkgincludedir) _mysql_conf(MYSQL_LIB_DIR --variable=pkglibdir) - _mysql_conf(MYSQL_PLUGIN_DIR --variable=plugindir) file(TO_CMAKE_PATH "${MYSQL_INCLUDE_DIR}" MYSQL_INCLUDE_DIR) file(TO_CMAKE_PATH "${MYSQL_LIB_DIR}" MYSQL_LIB_DIR) - file(TO_CMAKE_PATH "${MYSQL_PLUGIN_DIR}" MYSQL_PLUGIN_DIR) set(MYSQL_INCLUDE_DIR "${MYSQL_INCLUDE_DIR}" PARENT_SCOPE) set(MYSQL_LIB_DIR "${MYSQL_LIB_DIR}" PARENT_SCOPE) - set(MYSQL_PLUGIN_DIR "${MYSQL_PLUGIN_DIR}" PARENT_SCOPE) + + if(NOT MYSQL_PLUGIN_DIR) + _mysql_conf(MYSQL_PLUGIN_DIR --variable=plugindir) + file(TO_CMAKE_PATH "${MYSQL_PLUGIN_DIR}" MYSQL_PLUGIN_DIR) + set(MYSQL_PLUGIN_DIR "${MYSQL_PLUGIN_DIR}" PARENT_SCOPE) + endif() # client library version (note: it will be cleaned up in get_version()) @@ -528,7 +530,8 @@ function(use_mysql_config) # option. if(NOT lib MATCHES - "(mysqlclient|libmysql|^stdc|^gcc|^CrunG3|^c$|^statomic|^ssl|^crypto)" + "(mysqlclient|libmysql|^stdc|^gcc|^CrunG3|^c$|^statomic)" + #|^ssl|^crypto)" ) list(APPEND MYSQL_EXTERNAL_DEPENDENCIES ${lib}) diff --git a/jdbc/cppconn/callback.h b/jdbc/cppconn/callback.h index af555326b..0ff7f3aa1 100644 --- a/jdbc/cppconn/callback.h +++ b/jdbc/cppconn/callback.h @@ -133,6 +133,8 @@ class WebAuthn_Callback ActionRequested(msg); } + virtual ~WebAuthn_Callback() {} + }; @@ -188,6 +190,8 @@ class Fido_Callback FidoActionRequested(msg); } + virtual ~Fido_Callback() {} + friend class mysql::MySQL_Connection; friend class mysql::MySQL_Driver; }; diff --git a/jdbc/cppconn/connection.h b/jdbc/cppconn/connection.h index b33f3ce1a..7c4db2e3e 100644 --- a/jdbc/cppconn/connection.h +++ b/jdbc/cppconn/connection.h @@ -138,6 +138,8 @@ #define OPT_AUTHENTICATION_KERBEROS_CLIENT_MODE \ "OPT_AUTHENTICATION_KERBEROS_CLIENT_MODE" #define OPT_OCI_CLIENT_CONFIG_PROFILE "OPT_OCI_CLIENT_CONFIG_PROFILE" +#define OPT_OPENID_TOKEN_FILE "OPT_OPENID_TOKEN_FILE" +#define OPT_WEBAUTHN_DEVICE_NUMBER "OPT_WEBAUTHN_DEVICE_NUMBER" /* Telemetry options diff --git a/jdbc/driver/CMakeLists.txt b/jdbc/driver/CMakeLists.txt index 13f16a92e..f9ffa2cc3 100755 --- a/jdbc/driver/CMakeLists.txt +++ b/jdbc/driver/CMakeLists.txt @@ -193,14 +193,22 @@ IF(WIN32) ENDIF(WIN32) +if(DEFINED DEFAULT_PLUGIN_DIR) + add_compile_definitions(DEFAULT_PLUGIN_DIR="${DEFAULT_PLUGIN_DIR}") +endif() + + #----------------- add_library(jdbc STATIC ${MYSQLCPPCONN_SOURCES}) IF(WIN32) target_link_libraries(jdbc PRIVATE Dnsapi) -ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - target_link_libraries(jdbc PRIVATE resolv) +ELSE() + target_link_libraries(jdbc PRIVATE pthread) + IF(NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + target_link_libraries(jdbc PRIVATE resolv) + ENDIF() ENDIF() if (MYSQLCLIENT_STATIC_BINDING) diff --git a/jdbc/driver/mysql_connection.cpp b/jdbc/driver/mysql_connection.cpp index 990ffa0ed..5b933d139 100644 --- a/jdbc/driver/mysql_connection.cpp +++ b/jdbc/driver/mysql_connection.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #ifdef HAVE_STDINT_H #include #endif @@ -96,7 +97,11 @@ #endif -bool oci_plugin_is_loaded = false; +#ifdef DEFAULT_PLUGIN_DIR +std::string default_plugin_dir(DEFAULT_PLUGIN_DIR); +#else +std::string default_plugin_dir; +#endif namespace sql @@ -314,6 +319,16 @@ static const String2IntMap stringOptions[]= {OPT_LOAD_DATA_LOCAL_DIR, MYSQL_OPT_LOAD_DATA_LOCAL_DIR, false} }; +static const std::unordered_set stringPluginOptions = { + OPT_OCI_CONFIG_FILE, + OPT_AUTHENTICATION_KERBEROS_CLIENT_MODE, + OPT_OCI_CLIENT_CONFIG_PROFILE, + OPT_OPENID_TOKEN_FILE +}; + +static const std::unordered_set intPluginOptions = { + OPT_WEBAUTHN_DEVICE_NUMBER +}; //Option conversion for libmysqlclient < 80011 @@ -421,130 +436,182 @@ struct Prio }; -/* - A callback setter object arranges for WebAuthn/Fido authentication - callbacks to be used by the WebAuthn clientlib authentication plugin. +sql::mysql::MySQL_Driver *MySQL_Connection::PluginGuard::callback_drv + = nullptr; - If a user has registered a callback with a driver that creates a connection - then a callback function is registered with authentication plugin which will - call the callback stored in the driver. +MySQL_Connection::PluginGuard::state +MySQL_Connection::PluginGuard::webauthn_plugin_state + = state::NONE; - The callback function registered with authentication plugin must be changed - depending on which driver is used to create a connection. A callback setter - object makes necessary changes when it detects that the current driver passed - to its ctor is different from the one used last time. +MySQL_Connection::PluginGuard::PluginGuard(MySQL_Connection *c) +: prx{c->proxy} +{ + //assert(c); + if (!prx.expired()) + prx.lock()->lock_plugin(true); +} - While exists, callback setter also prevents modification of authentication - plugin callbacks by concurrent threads. + +/* + This method arranges for the WebAuthN authentication plugin callback to be + set in agreement with the webauthn callback function specified by the given + driver: + + 1. If driver's callback is set then that callback should be called by + the plugin (if the plugin is used during authentication). + + 2. Otherwise, if there is no driver specific callback, the plugin should + use its default callback. */ -struct MySQL_Driver::WebAuthn_Callback_Setter +void MySQL_Connection::PluginGuard::register_webauthn_callback(MySQL_Driver &drv) { - using Proxy = NativeAPI::NativeConnectionWrapper; + std::string plugin = "authentication_webauthn_client"; + std::string opt = "plugin_authentication_webauthn_client_messages_callback"; + + if (prx.expired()) + return; + + auto proxy = prx.lock(); + + /* + Compute desired plugin state based on its current state nad driver settings. + + Returns NONE if plugin is already in correct state, DEFAULT if plugin's + default callback should be restored or CALLER if plugin should + be configured to call driver's callback. + */ - WebAuthn_Callback_Setter(MySQL_Driver &drv, Proxy *prx) - : lock{mutex} + auto target_state = [&]() -> state { /* - Note: Meaning of callback type value: + If no WebAuthN callback is registered in the driver but + the plugin was configured to call driver's callback + ( webauthn_plugin_state == CALLER ) we must reset plugin to use its + default callback. + + Note that nothing needs to be done if plugin is not loaded at the moment + ( webauthn_plugin_state == NONE ) because in that case if the plugin + is loaded during authentication it will use its default callback as + required. + */ - 0 or 3 = no callback - 1 or 4 = webauthn only callback - 2 or 5 = webauthn and fido callback + if (!drv.webauthn_callback && webauthn_plugin_state == state::CALLER) + return state::DEFAULT; - Values 3,4,5 indicate that the callback function has been already - (de-)registered with the plugin(s). + /* + If driver has a WebAuthN callback but the plugin is not configured + to call it ( webauthn_plugin_state != CALLER ) or the driver whose + callback would be called is not correct ( callback_drv != &drv ) we must + configure the plugin accordingly. */ - auto callback_type = reinterpret_cast(drv.fido_callback); + if ( + drv.webauthn_callback + && (webauthn_plugin_state != state::CALLER || callback_drv != &drv) + ) + return state::CALLER; + // If neither of the above then the plugin is already in the correct state. + + return state::NONE; + }; + + + try + { /* - Do nothing if we use the same driver as last time nad (de-)registration - was already done. + There is nothing to be done if the plugin is already correctly + configured. We also know that no concurrent thread that makes + a connection can change plugin configuration because to do so it would + need to first grab an exclusive plugin lock (see below) and that is + not possible while this thread holds a shared lock. */ - if ((2 < callback_type) && (driver == &drv)) + if (state::NONE == target_state()) return; - driver = &drv; // Set current driver. - /* - Note: A webauthn callback (callback_type 2 or 5) is registered with - "webauthn" plugin as well as fido callback (callback_type 1 or 4). - If user did not register any callback (callback_type 0 or 3) then - plugin callback is re-set to null. + Current plugin configuration is not as needed nad we must change it + accordingly. To do so we first grab an exclusive plugin lock to ensure + that we don't change the current plugin configuration while another + thread is making connection and relying on it. */ - register_callback(prx, (callback_type % 3) > 0); + proxy->lock_plugin_exclusive(); /* - Note: This will be reset to value 0-2 when user deregisters - the callback or registers a new one. + Note that while upgrading the lock to an exclusive one other threads can + get it before this thread and can change the plugin configuration that + was present during first `target_state()` call above. For that reason we + call `target_state()` again to re-evaluate the required changes and act + accordingly. */ - drv.fido_callback = reinterpret_cast(callback_type + 3); - } - - private: + switch (target_state()) + { + case state::DEFAULT: + { + /* + Note: setting callback option to nullptr restores plugin's default + callback. + */ + proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN, + plugin, opt, nullptr); + webauthn_plugin_state = state::DEFAULT; + } + break; - // The driver whose callback will be called by authentication plugins. + case state::CALLER: + { + proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN, + plugin, opt, (const void*)callback_caller); + callback_drv = &drv; + webauthn_plugin_state = state::CALLER; + } + break; - static sql::mysql::MySQL_Driver * driver; - /* - Callback function to be registered with authentication plugins. - If the current driver has a stored callback then it is being called. - */ + default: break; + } - static void callback_func(const char* msg) + /* + At this point we have plugin configured as required by the diver callback + settings and we know this will not change as long as we hold the plugin + lock. + */ + } + catch (sql::MethodNotImplementedException &) { - if (!driver || !driver->fido_callback) + // Note: Ignore errors when re-setting the callback + if(!drv.webauthn_callback) return; - driver->webauthn_callback(msg); - } - static std::mutex mutex; - std::lock_guard lock; - - static - void register_callback(Proxy *proxy, bool set_or_reset) + } + catch (sql::InvalidArgumentException &e) { - std::string plugin = "authentication_webauthn_client"; - std::string opt = "plugin_authentication_webauthn_client"; - - try - { - proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN, - plugin.c_str(), opt.c_str(), - set_or_reset ? (const void*)callback_func : nullptr - ); - } - catch (sql::MethodNotImplementedException &) - { - // Note: Ignore errors when re-setting the callback - - if(!set_or_reset) - return; - - } - catch (sql::InvalidArgumentException &e) - { - if(!set_or_reset) - return; - - throw ::sql::SQLException( - "Failed to set fido message callback for " - + plugin + " plugin"); - } - }; + if(!drv.webauthn_callback) + return; -}; + throw ::sql::SQLException( + "Failed to set fido message callback for " + + plugin + " plugin"); + } +} -std::mutex MySQL_Driver::WebAuthn_Callback_Setter::mutex; -sql::mysql::MySQL_Driver *MySQL_Driver::WebAuthn_Callback_Setter::driver - = nullptr; +void MySQL_Connection::PluginGuard::callback_caller(const char* msg) +{ + if (!callback_drv || !callback_drv->webauthn_callback) + return; + callback_drv->webauthn_callback(msg); +} +MySQL_Connection::PluginGuard::~PluginGuard() +{ + if (!prx.expired()) + prx.lock()->lock_plugin(false); +} /* We support : @@ -774,6 +841,7 @@ void MySQL_Connection::init(ConnectOptionsMap & properties) { sql::SQLString plugin_dir; it = properties.find(OPT_PLUGIN_DIR); + p_s = nullptr; if (it != properties.end()) { try { @@ -782,21 +850,10 @@ void MySQL_Connection::init(ConnectOptionsMap & properties) throw sql::InvalidArgumentException("Wrong type passed for pluginDir expected sql::SQLString"); } } -#if(_WIN32 && CONCPP_BUILD_SHARED) - else { - /* - Note: For DLL in Windows we will try to set the plugin directory - based on driver_dll_path. - */ - plugin_dir = driver_dll_path; -#ifdef _DEBUG - // Debug dll is placed inside debug subdirectory - plugin_dir.append("..\\"); -#endif - plugin_dir.append("plugin"); + else if(!default_plugin_dir.empty()) { + plugin_dir = default_plugin_dir; p_s = &plugin_dir; } -#endif if (p_s) { proxy->options(sql::mysql::MYSQL_PLUGIN_DIR, *p_s); @@ -1255,68 +1312,6 @@ void MySQL_Connection::init(ConnectOptionsMap & properties) proxy->options(MYSQL_OPT_SSL_MODE, &ssl_mode_val); #endif - } else if (!it->first.compare(OPT_OCI_CONFIG_FILE)) { - try { - p_s= (it->second).get(); - } catch (sql::InvalidArgumentException&) { - throw sql::InvalidArgumentException("Wrong type passed for OPT_OCI_CONFIG_FILE. Expected sql::SQLString."); - } - - try { - proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN, - "authentication_oci_client", - "oci-config-file", - *p_s); - oci_plugin_is_loaded = true; - } catch (sql::InvalidArgumentException &e) { - throw ::sql::SQLUnsupportedOptionException( - "Failed to set config file for authentication_oci_client plugin", - OPT_OCI_CONFIG_FILE - ); - } - } else if (!it->first.compare(OPT_OCI_CLIENT_CONFIG_PROFILE)) { - try { - p_s = (it->second).get(); - } catch (sql::InvalidArgumentException &) { - throw sql::InvalidArgumentException( - "Wrong type passed for OPT_OCI_CLIENT_CONFIG_PROFILE. Expected " - "sql::SQLString."); - } - - try { - proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN, - "authentication_oci_client", - "authentication-oci-client-config-profile", *p_s); - oci_plugin_is_loaded = true; - } catch (sql::InvalidArgumentException &e) { - throw ::sql::SQLUnsupportedOptionException( - "Failed to set config profile for authentication_oci_client plugin", - OPT_OCI_CLIENT_CONFIG_PROFILE); - } - - } else if (!it->first.compare(OPT_AUTHENTICATION_KERBEROS_CLIENT_MODE)) { -#if defined(_WIN32) - try { - p_s = (it->second).get(); - } catch (sql::InvalidArgumentException &) { - throw sql::InvalidArgumentException( - "Wrong type passed for OPT_AUTHENTICATION_KERBEROS_CLIENT_MODE. " - "Expected sql::SQLString."); - } - - try { - proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN, - "authentication_kerberos_client", - "plugin_authentication_kerberos_client_mode", - *p_s); - } catch (sql::InvalidArgumentException &e) { - throw ::sql::SQLUnsupportedOptionException( - "Failed to set config file for authentication_kerberos_client " - "plugin", - OPT_AUTHENTICATION_KERBEROS_CLIENT_MODE); - } -#endif // defined(_WIN32) - } else if (!it->first.compare(OPT_PLUGIN_DIR)) { // Nothing to do here: this option was handeld before the loop @@ -1342,34 +1337,188 @@ void MySQL_Connection::init(ConnectOptionsMap & properties) } /* End of cycle on connection options map */ - if (oci_plugin_is_loaded) { - if (properties.find(OPT_OCI_CONFIG_FILE) == properties.end()) { - // If OCI plugin is loaded, but oci-config-file is not explicitly set - // the option value needs resetting. - try { - proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN, - "authentication_oci_client", - "oci-config-file", - nullptr); - } catch (sql::InvalidArgumentException &) { - // Do nothing, the exception is expected. + + /* + Setting plugin options. + + Note that plugins are shared between different drivers but each driver and + each connection can have its own plugin settings. For that reason plugin + options are set here, before making a connection, to the values specified + by this connection and driver. + + The guard is needed to prevent overwriting plugin options by another + connection while this connection is being established. + + Note: If connection options do not specify a value for a plugin option that + plugin option is set to null which resets it to its default value (which + could be overwritten by other connections). + + TODO: Move setting of plugin options later in the connection process, after + any other options which can take long time to set (e.g. OpenSSL options or + options involving DNS resolution). This is because setting plugin options + can potentially block other connection and this blocking should be as short + as possible. + */ + + MySQL_Connection::PluginGuard guard{this}; + + /* + Set option `option` of plugin `plugin_name` of type `plugin_type` to + the value given by connection option `con_opt_name` if it is specified. + Otherwise (if the connection option is not specified) reset plugin option + value to the default value given by `default_val`. + + If plugin option value could not be set throw error with description given + by `err_msg` (not if the plugin option is set to its default value). + + Note that for most plugin options the default value is restored when + the option is set to null. + */ + + auto set_plugin_option = [this, &properties] ( + const ::sql::SQLString con_opt_name, + int plugin_type, + const ::sql::SQLString & plugin_name, + const ::sql::SQLString & option, + const char * err_msg, + const void* default_val = nullptr + ) + { + sql::SQLString *p_s = nullptr; + const void* val = nullptr; + + auto opt = properties.find(con_opt_name); + if (opt != properties.end()) + { + if (stringPluginOptions.count(con_opt_name)) + { + try + { + p_s = (opt->second).get(); + if (!p_s) + throw sql::InvalidArgumentException{ + "No string value passed for " + con_opt_name + }; + val = p_s->c_str(); + } + catch (sql::InvalidArgumentException&) + { + throw sql::InvalidArgumentException( + "Wrong type passed for " + con_opt_name + + ". Expected sql::SQLString."); + } + } + else if (intPluginOptions.count(con_opt_name)) + { + try + { + val = (opt->second).get(); + if (!val) + throw sql::InvalidArgumentException{ + "No int value passed for " + con_opt_name + }; + } + catch (sql::InvalidArgumentException&) + { + throw sql::InvalidArgumentException( + "Wrong type passed for " + con_opt_name + + ". Expected int."); + } + } + else + { + /* + We end up here only if below this lambda is called with connection + option that is not a plugin option (not listed in + `stringPluginOptions` or `intPluginOptions` -- that should never + happen. + */ + assert(false); } } - if (properties.find(OPT_OCI_CLIENT_CONFIG_PROFILE) == properties.end()) { - // If OCI plugin is loaded, but oci-config-profile is not explicitly set - // the option value needs resetting. - try { - proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN, - "authentication_oci_client", - "authentication-oci-client-config-profile", - nullptr); - } catch (sql::InvalidArgumentException &) { - // Do nothing, the exception is expected. - } + try + { + /* + Note: `val` is null if the connection option was not set. In that case + we reset plugin option to the default value as given by `default_val` + parameter. The last argument of `plugin_option()` informs that the + option set is the default one which is the case when `val` is null. + */ + + proxy->plugin_option( + plugin_type, plugin_name, option, + val ? val : default_val, val == nullptr + ); } + catch (sql::InvalidArgumentException &e) + { + if (val) + // Throw only when setting to a non-default value + throw ::sql::SQLUnsupportedOptionException(err_msg, + con_opt_name.asStdString()); + } + }; + + + set_plugin_option(OPT_OCI_CONFIG_FILE, + MYSQL_CLIENT_AUTHENTICATION_PLUGIN, + "authentication_oci_client", + "oci-config-file", + "Failed to set config file for authentication_oci_client plugin" + ); + + set_plugin_option(OPT_OCI_CLIENT_CONFIG_PROFILE, + MYSQL_CLIENT_AUTHENTICATION_PLUGIN, + "authentication_oci_client", + "authentication-oci-client-config-profile", + "Failed to set config profile for authentication_oci_client plugin" + ); + +#if defined(_WIN32) + set_plugin_option(OPT_AUTHENTICATION_KERBEROS_CLIENT_MODE, + MYSQL_CLIENT_AUTHENTICATION_PLUGIN, + "authentication_kerberos_client", + "plugin_authentication_kerberos_client_mode", + "Failed to set config file for authentication_kerberos_client plugin" + ); +#endif + + set_plugin_option(OPT_OPENID_TOKEN_FILE, + MYSQL_CLIENT_AUTHENTICATION_PLUGIN, + "authentication_openid_connect_client", + "id-token-file", + "Failed to set token file for authentication_openid_connect_client plugin" + ); + + // Note: The default value for WebAuthN "device" option is 0. + + const int webauthn_device_default_val = 0; + + set_plugin_option(OPT_WEBAUTHN_DEVICE_NUMBER, + MYSQL_CLIENT_AUTHENTICATION_PLUGIN, + "authentication_webauthn_client", + "device", + "Failed to set a WebAuthn authentication device", + &webauthn_device_default_val + ); + + /* + Setting webauthn callback functions. + + The callback is an option of the webauthn authentication plugin that + is configured on the driver level (as opposed to plugin options above, + which are configured on per-connection basis). Correctly setting the option + based on driver configuration is handled by register_webauthn_callback() + function of PluginGuard class. The option will be set only if needed. + + Note: If register_webauthn_callback() sets a callback then the plugin + options guard ensures that this callback function is not modified by other + connections while being used. + */ + + guard.register_webauthn_callback(*static_cast(driver)); - } #undef PROCESS_CONNSTR_OPTION @@ -1542,16 +1691,6 @@ void MySQL_Connection::init(ConnectOptionsMap & properties) } - /* - Note: If needed the setter will update callback functions registered with - webauthn/fido authentication plugins to call the callback stored - in the driver. It also protects the callbacks from being modified while - connection is being made. - */ - - MySQL_Driver::WebAuthn_Callback_Setter - setter{*static_cast(driver), proxy.get()}; - //Connect loop { bool connected = false; diff --git a/jdbc/driver/mysql_connection.h b/jdbc/driver/mysql_connection.h index 7b78202d1..dd4aa23bf 100644 --- a/jdbc/driver/mysql_connection.h +++ b/jdbc/driver/mysql_connection.h @@ -39,6 +39,7 @@ #if(_WIN32 && CONCPP_BUILD_SHARED) extern std::string driver_dll_path; #endif +extern std::string default_plugin_dir; namespace sql { @@ -72,6 +73,8 @@ class MySQL_Prepared_Statement; namespace NativeAPI { class NativeConnectionWrapper; +struct st_mysql_client_plugin; +extern std::map <::sql::SQLString, st_mysql_client_plugin*> plugins_cache; } class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection @@ -82,13 +85,15 @@ class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection MySQL_Statement * createServiceStmt(); public: - MySQL_Connection(Driver * _driver, - ::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy, + + using Proxy = ::sql::mysql::NativeAPI::NativeConnectionWrapper; + + MySQL_Connection(Driver * _driver, Proxy& _proxy, const sql::SQLString& hostName, const sql::SQLString& userName, const sql::SQLString& password); - MySQL_Connection(Driver * _driver, ::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy, + MySQL_Connection(Driver * _driver, Proxy & _proxy, std::map< sql::SQLString, sql::ConnectPropertyVal > & options); virtual ~MySQL_Connection(); @@ -192,7 +197,7 @@ class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection #pragma warning(push) #pragma warning(disable: 4251) #endif - std::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy; + std::shared_ptr proxy; #ifdef _WIN32 #pragma warning(pop) #endif @@ -216,6 +221,57 @@ class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection /* Prevent use of these */ MySQL_Connection(const MySQL_Connection &); void operator=(MySQL_Connection &); + + struct PluginGuard; +}; + +class MySQL_Driver; + +/* + A PluginGuard instance is used to lock plugin options so that no other + connections can set them while the guard exists. + + It also manages the callback setting of the WebAuthN authentication + plugin -- see register_webauthn_callback() method. +*/ + +struct MySQL_Connection::PluginGuard +{ + std::weak_ptr prx; + + PluginGuard(MySQL_Connection *c); + ~PluginGuard(); + + /* + Depending on whether user has set the WebAuthN callback + for the driver or not, this method arranges for either + the driver's callback or the default callback be called + in case WebAuthN authentication is used while making + a connection. + */ + void register_webauthn_callback(MySQL_Driver &drv); + + private: + + /* + State of the WebAuthN plugin: + + NONE -- plugin is not loaded; + DEFAULT -- plugin is loaded and uses default callback; + CALLER -- plugin is loaded and its callback is set to + the `callback_caller()` function. + */ + static + enum class state { NONE, DEFAULT, CALLER } webauthn_plugin_state; + + // The driver whose callback is called by `callback_caller()` + static sql::mysql::MySQL_Driver * callback_drv; + + /* + Callback function to be registered with WebAuthN authentication plugin. + It calls the callback function of `callback_drv` if that is present. + */ + static void callback_caller(const char* msg); }; } /* namespace mysql */ diff --git a/jdbc/driver/mysql_driver.cpp b/jdbc/driver/mysql_driver.cpp index 19f790ef1..b2c1b57fb 100644 --- a/jdbc/driver/mysql_driver.cpp +++ b/jdbc/driver/mysql_driver.cpp @@ -207,15 +207,15 @@ void MySQL_Driver::setCallBack(sql::WebAuthn_Callback& cb) /* - Note: Values 1 and 4 of `fido_callback` mean that user has set a WebAuthn + Note: Value 1 of `fido_callback` means that user has set a WebAuthn callback before and it can not be overwritten by Fido one. If later user - de-registers a WebAuthn callaback then `fido_callback` becomes 0 or 4 and + de-registers a WebAuthn callaback then `fido_callback` becomes 0 and error will not be thrown -- user can set a new Fido callback in this situation. */ #define CHECK_FIDO_ERROR \ - if (1 == (reinterpret_cast(fido_callback) % 3)) \ + if (1 == reinterpret_cast(fido_callback)) \ throw sql::SQLException{ \ "You are trying to overwrithe WebAuthn callback with FIDO one. " \ "FIDO authentication plugin and the corresponding callback type " \ @@ -271,6 +271,19 @@ BOOL WINAPI DllMain( GetModuleFileNameA(hmodule, _driver_dll_path, sizeof(_driver_dll_path)); driver_dll_path = _driver_dll_path; driver_dll_path = driver_dll_path.substr(0, driver_dll_path.find_last_of('\\') + 1); + + /* + Note: For DLL in Windows we will try to set the plugin directory + based on driver_dll_path. + */ + + default_plugin_dir = driver_dll_path; +#ifdef _DEBUG + // Debug dll is placed inside debug subdirectory + default_plugin_dir.append("..\\"); +#endif + default_plugin_dir.append("plugin"); + return true; } #endif diff --git a/jdbc/driver/mysql_driver.h b/jdbc/driver/mysql_driver.h index f764304fc..3e25db3ea 100644 --- a/jdbc/driver/mysql_driver.h +++ b/jdbc/driver/mysql_driver.h @@ -52,7 +52,6 @@ namespace NativeAPI class NativeDriverWrapper; } -//class sql::mysql::NativeAPI::NativeDriverWrapper; class CPPCONN_PUBLIC_FUNC MySQL_Driver : public sql::Driver { @@ -66,9 +65,10 @@ class CPPCONN_PUBLIC_FUNC MySQL_Driver : public sql::Driver #endif /* - Note: With current implementation `fido_callback` and `fido_callback_store` - are not really used and should be removed after deprecation of Fido - authentication plugin and when ABI can be changed. + Note: Currently we do not have a separate FIDO authentication plugin and + a callback for it. However, we keep `fido_callback` and + `fido_callback_store` members to not break ABI. The `fido_callback` is also + re-used as a flag in the logic of `setCallback()` methods (see there). */ ::sql::Fido_Callback* fido_callback = nullptr; @@ -77,9 +77,6 @@ class CPPCONN_PUBLIC_FUNC MySQL_Driver : public sql::Driver /* Callback function to be called by WebAuthn authentication plugin to notify the user. - - Note: The `fido_callback` pointer is re-used as a flag to indicate if - the callback was set by a user and its type (WebAuthn vs. Fido). */ std::function webauthn_callback; @@ -102,6 +99,20 @@ class CPPCONN_PUBLIC_FUNC MySQL_Driver : public sql::Driver const sql::SQLString & getName() override; + /* + We do not have a FIDO authentication plugin any more but for backward + compatibility user can still set a Fido_Callback and it will be used with + the WebAuthN plugin instead. + + New code should use only WebAuthn_Callback -- there is no need to use + the deprecated Fido_Callback other than in old code that was not yet aware + of WebAuthN authentication. + + An attempt to use both types of callbacks and overwrite earlier + WebAuthn_Callback with Fido_Callback will throw an error (it is still OK + to overwrite earlier Fido_Callback with WebAuthn_Callback though). + */ + void setCallBack(sql::Fido_Callback &cb) override; void setCallBack(sql::Fido_Callback &&cb) override; diff --git a/jdbc/driver/nativeapi/mysql_native_connection_wrapper.cpp b/jdbc/driver/nativeapi/mysql_native_connection_wrapper.cpp index 2e5e73e40..b86c0aec4 100644 --- a/jdbc/driver/nativeapi/mysql_native_connection_wrapper.cpp +++ b/jdbc/driver/nativeapi/mysql_native_connection_wrapper.cpp @@ -34,6 +34,7 @@ #include #include +#include #include "../mysql_util.h" #include "../mysql_connection_options.h" @@ -52,6 +53,9 @@ namespace mysql namespace NativeAPI { +std::shared_mutex plugins_cache_mutex; +std::map <::sql::SQLString, st_mysql_client_plugin*> plugins_cache; + /* Function to convert sql::mysql::MySQL_Connection_Options to libmysqlclient mysql_option @@ -452,21 +456,143 @@ MySQL_NativeConnectionWrapper::get_option(::sql::mysql::MySQL_Connection_Options } /* }}} */ + +/* + Accessing plugin options. +*/ + +void MySQL_NativeConnectionWrapper::lock_plugin_impl(lock_type type) +{ + switch (type) + { + case lock_type::GUARD: + case lock_type::SHARED: + // Note: We don't take shared lock if exclusive lock is in place + if (!plugins_ex_lock.owns_lock() && !plugins_sh_lock.owns_lock()) + plugins_sh_lock.lock(); + + if (!plugin_guard) + plugin_guard = (lock_type::GUARD == type); + break; + + case lock_type::EXCLUSIVE: + // Nothing to do if we already hold an exclusive lock + if (plugins_ex_lock.owns_lock()) + break; + // Before taking exclusive lock we need to release the shared lock + if (plugins_sh_lock.owns_lock()) + plugins_sh_lock.unlock(); + // This will wait until no other connection holds a lock + plugins_ex_lock.lock(); + break; + + case lock_type::UNLOCK: + // UNLOCK has no effect if GUARD lock was taken + if (plugin_guard) + break; + // Otherwise UNLOCK and UNGUARD are the same + // FALLTHROUGH + case lock_type::UNGUARD: + if (plugins_sh_lock.owns_lock()) + plugins_sh_lock.unlock(); + if (plugins_ex_lock.owns_lock()) + plugins_ex_lock.unlock(); + break; + } +} + +struct MySQL_NativeConnectionWrapper::PluginGuard +{ + using ConWrapper = MySQL_NativeConnectionWrapper; + + ConWrapper *conn; + + PluginGuard(ConWrapper *c) + : conn{c} + { + conn->lock_plugin_impl(lock_type::SHARED); + } + + ~PluginGuard() + { + // Note: This will do nothing if external guard was created + conn->lock_plugin_impl(lock_type::UNLOCK); + } + + // Upgrade initial shared lock to exclusive one + + void lock() + { + conn->lock_plugin_impl(lock_type::EXCLUSIVE); + } + + /* + Find a plugin in the plugin cache. If `load` is true then loads the plugin + into cache if not already there; otherwise null is returned if the plugin + was not found. + + Throws error if loading of the plugin failed. + */ + + st_mysql_client_plugin* + get_plugin(int plugin_type, SQLString const &name, bool load) + { + /* + Note: Shared plugin lock is held when this method is called (taken in + the constructor). + */ + + if (plugins_cache.count(name) > 0) + return plugins_cache.at(name); + else if (load) + { + /* load client authentication plugin if required */ + auto *plugin = conn->api->client_find_plugin(conn->mysql, name.c_str(), plugin_type); + + lock(); // Upgrade to exclusive lock before writing to cache + + plugins_cache.emplace(name, plugin); + + return plugin; + } + else + return nullptr; + } +}; + + int MySQL_NativeConnectionWrapper::plugin_option( - int plugin_type, - const ::sql::SQLString & plugin_name, - const ::sql::SQLString & option, - const void * value) -try{ - - /* load client authentication plugin if required */ - struct st_mysql_client_plugin *plugin = - api->client_find_plugin(mysql, plugin_name.c_str(), plugin_type); + int plugin_type, + const ::sql::SQLString & plugin_name, + const ::sql::SQLString & option, + const void * value, + bool default_value +) +try +{ + PluginGuard guard{this}; + + /* + Note: Try to load plugin into cache only if the option is set to + a non-default value. + */ + + struct st_mysql_client_plugin *plugin + = guard.get_plugin(plugin_type, plugin_name, !default_value); + + /* + Note: `plugin` can be null here only if we are setting option to + the default value and the plugin was not found in the cache. Otherwise + an attempt to load the plugin will be made and error will be thrown if + it could not be done. + */ + + if (!plugin) + return 0; - /* set option value in plugin */ + guard.lock(); // Note: Only now an exclusive lock is required return api->plugin_options(plugin, option.c_str(), value); - } catch(sql::InvalidArgumentException &e) { @@ -475,41 +601,32 @@ catch(sql::InvalidArgumentException &e) throw sql::InvalidArgumentException(err); } + int MySQL_NativeConnectionWrapper::plugin_option( - int plugin_type, - const ::sql::SQLString & plugin_name, - const ::sql::SQLString & option, - const ::sql::SQLString & value) -try{ - - /* load client authentication plugin if required */ - struct st_mysql_client_plugin *plugin = - api->client_find_plugin(mysql, plugin_name.c_str(), plugin_type); - - /* set option value in plugin */ - return api->plugin_options(plugin, option.c_str(), value.c_str()); - -} -catch(sql::InvalidArgumentException &e) + int plugin_type, + const ::sql::SQLString & plugin_name, + const ::sql::SQLString & option, + const ::sql::SQLString & value, + bool default_value +) { - std::string err(e.what()); - err+= " for plugin " + plugin_name; - throw sql::InvalidArgumentException(err); + return plugin_option( + plugin_type, plugin_name, option, value.c_str(), default_value + ); } + int MySQL_NativeConnectionWrapper::get_plugin_option( int plugin_type, const ::sql::SQLString & plugin_name, const ::sql::SQLString & option, const ::sql::SQLString & value) { - + PluginGuard guard{this}; /* load client authentication plugin if required */ - struct st_mysql_client_plugin *plugin = - api->client_find_plugin(mysql, plugin_name.c_str(), - plugin_type); + struct st_mysql_client_plugin *plugin = guard.get_plugin(plugin_type, plugin_name, true); /* get option value from plugin */ return api->plugin_get_option(plugin, option.c_str(), (void*)value.c_str()); diff --git a/jdbc/driver/nativeapi/mysql_native_connection_wrapper.h b/jdbc/driver/nativeapi/mysql_native_connection_wrapper.h index 865302ae1..04f63e2fe 100644 --- a/jdbc/driver/nativeapi/mysql_native_connection_wrapper.h +++ b/jdbc/driver/nativeapi/mysql_native_connection_wrapper.h @@ -37,7 +37,8 @@ #include #include - +#include +#include namespace sql { @@ -53,12 +54,12 @@ inline const char * nullIfEmpty(const ::sql::SQLString & str) return str.length() > 0 ? str.c_str() : NULL; } +extern std::shared_mutex plugins_cache_mutex; class MySQL_NativeConnectionWrapper : public NativeConnectionWrapper { /* api should be declared before mysql here */ std::shared_ptr api; - bool reconnect = false; ::sql::SQLString m_host; ::sql::SQLString m_user; @@ -140,12 +141,15 @@ struct st_mysql* mysql; int get_option(::sql::mysql::MySQL_Connection_Options, const bool &) override; int get_option(::sql::mysql::MySQL_Connection_Options, const int &) override; - int plugin_option(int plugin_type, const ::sql::SQLString &plugin_name, - const ::sql::SQLString &option, const void *) override; + int plugin_option( + int plugin_type, const ::sql::SQLString &plugin_name, + const ::sql::SQLString &option, const void *, bool + ) override; - int plugin_option(int plugin_type, const ::sql::SQLString &plugin_name, - const ::sql::SQLString &option, - const ::sql::SQLString &value) override; + int plugin_option( + int plugin_type, const ::sql::SQLString &plugin_name, + const ::sql::SQLString &option, const ::sql::SQLString &value, bool + ) override; int get_plugin_option(int plugin_type, const ::sql::SQLString &plugin_name, const ::sql::SQLString &option, @@ -176,6 +180,65 @@ struct st_mysql* mysql; NativeStatementWrapper &stmt_init() override; unsigned int warning_count() override; + + void lock_plugin(bool lock_or_unlock) override + { + lock_plugin_impl(lock_or_unlock ? lock_type::GUARD : lock_type::UNGUARD); + } + + void lock_plugin_exclusive() override + { + lock_plugin_impl(lock_type::EXCLUSIVE); + } + + /* + Implementation of plugin locking. + + There are the following lock request that can be made with + lock_plugin_impl() method: + + - SHARED lock can be taken if there are no EXCLUSIVE locks present (when + requested it watis until this is the case), existence of other SHARED + (or GUARD) locks does not prevent SHARED lock to be taken; + + - GUARD lock is like a SHARED lock but it prevents locks to be released + by UNLOCK request (see below). + + - EXCLUSIVE lock can be taken only when no other connection holds any type + of lock (when requested it waits until this is the case). EXCLUSIVE lock + can be requested while holding SHARED or GUARD lock. + + The UNLOCK request is used to remove SHARED or EXCLUSIVE locks provided + that no GUARD lock was taken. If GUARD lock was taken then an UNLOCK + request has no effect -- any locks taken remain in place. Only UNGUARD + request can be used to remove locks after GUARD request -- either + the original GUARD lock or an EXCLUSIVE lock to which it was upgraded. + + If connection already holds a plugin lock then another request to get + a lock has the following effect depending on the requested lock type: + + - EXCLUSIVE - upgrade shared lock to exclusive one + - GUARD - keep existing locks until UNGUARD request is made + - SHARED - no effect + */ + + enum class lock_type {GUARD, SHARED, EXCLUSIVE, UNLOCK, UNGUARD}; + + void lock_plugin_impl(lock_type); + + // These are used by lock_plugin_impl() + + std::shared_lock plugins_sh_lock{plugins_cache_mutex, std::defer_lock}; + std::unique_lock plugins_ex_lock{plugins_cache_mutex, std::defer_lock}; + bool plugin_guard = false; + + /* + This class handles locking of plugin when plugin options are set + (in plugin_option() methods) as well as implements access to the plugin + cache. + */ + + struct PluginGuard; }; } /* namespace NativeAPI */ diff --git a/jdbc/driver/nativeapi/native_connection_wrapper.h b/jdbc/driver/nativeapi/native_connection_wrapper.h index e1d517265..6efb8b425 100644 --- a/jdbc/driver/nativeapi/native_connection_wrapper.h +++ b/jdbc/driver/nativeapi/native_connection_wrapper.h @@ -69,6 +69,7 @@ enum Protocol_Type PROTOCOL_COUNT }; + class NativeConnectionWrapper : public util::nocopy { public: @@ -139,20 +140,34 @@ class NativeConnectionWrapper : public util::nocopy virtual int get_option(::sql::mysql::MySQL_Connection_Options, const int &) = 0; - virtual int plugin_option(int plugin_type, - const ::sql::SQLString & plugin_name, - const ::sql::SQLString & option, - const void * value) = 0; - - virtual int plugin_option(int plugin_type, - const ::sql::SQLString & plugin_name, - const ::sql::SQLString & option, - const ::sql::SQLString & value) = 0; - - virtual int get_plugin_option(int plugin_type, - const ::sql::SQLString & plugin_name, - const ::sql::SQLString & option, - const ::sql::SQLString & value) = 0; + /* + Note: The `default_value` flag informs whether the value to which option + is set is its default value. This can be used to avoid unnecessary loading + of the plugin. + */ + + virtual int plugin_option( + int plugin_type, + const ::sql::SQLString & plugin_name, + const ::sql::SQLString & option, + const void * value, + bool default_value = false + ) = 0; + + virtual int plugin_option( + int plugin_type, + const ::sql::SQLString & plugin_name, + const ::sql::SQLString & option, + const ::sql::SQLString & value, + bool default_value = false + ) = 0; + + virtual int get_plugin_option( + int plugin_type, + const ::sql::SQLString & plugin_name, + const ::sql::SQLString & option, + const ::sql::SQLString & value + ) = 0; virtual bool has_query_attributes() = 0; @@ -180,6 +195,43 @@ class NativeConnectionWrapper : public util::nocopy virtual unsigned int warning_count() = 0; + /* + This method is used to lock plugin options. + + After lock_plugin(true) call other connections that try to set plugin + options using plugin_option() methods will wait until lock_plugin(false) + is called on this connection. + */ + + virtual void lock_plugin(bool) = 0; + + /* + This method is used to lock plugin options exclusively before making any + plugin_option() call. + + Normally a thread takes an exclusive lock on plugin options only when it + calls `plugin_option()` method to modify one. This might however lead to + a race condition in a situation like this: + + lock_plugin(true); // lock plugin options + val = get_plugin_option(...); // read some option <1> + plugin_option(...); // write other option <2> + + If in <2> we want to set option X based on the value `val` of another + option Y that was read in step <1> there is no guarantee that at the time + of setting option X option Y has still the same value `val` that we saw + before. This is because while plugin_option() waits for exclusive access + to the options another thread can get that exclusive access first and + modify the value of Y. To avoid such race condition the code should grab + an exclusive lock on plugin options up-front rather than during + `plugin_option()` call: + + lock_plugin_exclusive(); + val = get_plugin_option(...); + plugin_option(...); + */ + + virtual void lock_plugin_exclusive() = 0; }; } /* namespace NativeAPI */ diff --git a/jdbc/extra/otel/CMakeLists.txt b/jdbc/extra/otel/CMakeLists.txt index bbed9bdf4..0d3708fa7 100644 --- a/jdbc/extra/otel/CMakeLists.txt +++ b/jdbc/extra/otel/CMakeLists.txt @@ -19,6 +19,14 @@ if(NOT (WIN32 OR APPLE OR CMAKE_SYSTEM_NAME MATCHES "SunOS")) if(WIN32) # Note: warning C4996 is triggered by OTel headers (as of version 1.10.0) target_compile_definitions(otel_api INTERFACE _SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING) + + else() + + # Note: warning triggered by OTel headers reported by clang 18: + # builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead + + target_compile_options(otel_api INTERFACE -Wno-deprecated-builtins) + endif() endif() diff --git a/jdbc/test/CMakeLists.txt b/jdbc/test/CMakeLists.txt index a8ee26532..c8259b973 100644 --- a/jdbc/test/CMakeLists.txt +++ b/jdbc/test/CMakeLists.txt @@ -41,6 +41,33 @@ INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/include") INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/include/jdbc") INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/include/jdbc/cppconn") +set(MY_TARGET_LINK_LIBRARIES connector-jdbc) + + +# Note: Some unit tests use std::filesystem part of the standard C++ library +# and for some versions of the standard library its implementation is in +# additional library stdc++fs. + +if(NOT WIN32) + + set(check_src "${CMAKE_CURRENT_BINARY_DIR}/filesystem_chk.cc") + file(WRITE "${check_src}" + "#include \n" + "int main() { (void)std::filesystem::current_path(); }" + ) + + try_compile(COMPILE_RESULT + ${CMAKE_CURRENT_BINARY_DIR} "${check_src}" + # OUTPUT_VARIABLE build_log + ) + + if(NOT COMPILE_RESULT) + list(APPEND MY_TARGET_LINK_LIBRARIES -lstdc++fs) + endif() + +endif() + + IF(MSBUILD) IF(CMAKE_BUILD_TYPE STREQUAL "Debug") LINK_DIRECTORIES(${MYSQL_DIR}/lib/debug) @@ -50,15 +77,8 @@ IF(MSBUILD) ADD_DEFINITIONS("-D_SCL_SECURE_NO_WARNINGS") ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS") - - SET(MY_TARGET_LINK_LIBRARIES connector-jdbc) -ELSEIF(NOT MSBUILD) - SET(MY_TARGET_LINK_LIBRARIES connector-jdbc) ENDIF() -if(NOT MYSQLCLIENT_STATIC_LINKING) - list(APPEND MY_TARGET_LINK_LIBRARIES MySQL::client) -endif() IF(CMAKE_COMPILER_IS_GNUCC AND MYSQLCPPCONN_GCOV_ENABLE) SET(MY_GCOV_LINK_LIBRARIES gcov) diff --git a/jdbc/test/unit/CMakeLists.txt b/jdbc/test/unit/CMakeLists.txt index 0fa38be18..29b7f7be8 100644 --- a/jdbc/test/unit/CMakeLists.txt +++ b/jdbc/test/unit/CMakeLists.txt @@ -26,12 +26,13 @@ # along with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +list(APPEND MY_TARGET_LINK_LIBRARIES test_framework) + IF(WIN32) if(MSBUILD) LINK_DIRECTORIES(${MYSQL_DIR}/lib/$(ConfigurationName)) LINK_DIRECTORIES(../framework/$(ConfigurationName)) endif() - SET(MY_TARGET_LINK_LIBRARIES connector-jdbc test_framework) SET(MY_TARGET_LINK_LIBRARIES_STATIC_CPPLIB connector-jdbc-static test_framework) # ADD_DEFINITIONS("-D_SECURE_SCL") ADD_DEFINITIONS("-D_SCL_SECURE_NO_WARNINGS") @@ -64,7 +65,6 @@ IF(WIN32) ) ELSEIF(NOT WIN32) - SET(MY_TARGET_LINK_LIBRARIES connector-jdbc test_framework) FIND_LIBRARY(MYSQLCPPCONN_DYNLOAD_MYSQL_LIB NAMES libmysqlclient_r.so @@ -95,9 +95,6 @@ ELSEIF(NOT WIN32) ) ENDIF(WIN32) -if(NOT MYSQLCLIENT_STATIC_LINKING) - list(APPEND MY_TARGET_LINK_LIBRARIES MySQL::client) -endif() IF(CMAKE_COMPILER_IS_GNUCC AND MYSQLCPPCONN_GCOV_ENABLE) SET(MY_GCOV_LINK_LIBRARIES gcov) diff --git a/jdbc/test/unit/classes/CMakeLists.txt b/jdbc/test/unit/classes/CMakeLists.txt index 3e8725549..a3e1477e5 100644 --- a/jdbc/test/unit/classes/CMakeLists.txt +++ b/jdbc/test/unit/classes/CMakeLists.txt @@ -205,3 +205,26 @@ IF(WIN32) ENDIF(WIN32) add_unit_test(variant) + +# Install tokens for OpenID authentication +foreach (token + openid_token_correct.txt + openid_token_empty.txt + openid_token_expired.txt + openid_token_invalid.txt + openid_token_issuer2.txt + openid_token_key2.txt + openid_token_user2.txt +) + # Copy tokens to build dir + file(COPY tokens/${token} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + + # Install tokens + install( + FILES tokens/${token} + DESTINATION tests/jdbc + COMPONENT JDBCTests + EXCLUDE_FROM_ALL + ) + +endforeach() diff --git a/jdbc/test/unit/classes/connection.cpp b/jdbc/test/unit/classes/connection.cpp index 7c3cdb8c6..182cec77f 100644 --- a/jdbc/test/unit/classes/connection.cpp +++ b/jdbc/test/unit/classes/connection.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #ifdef _WIN32 #pragma warning (disable : 4996) @@ -3985,8 +3986,18 @@ void connection::tls_deprecation() 4. Set env variable MYSQL_WEBAUTHN to non-empty value */ -/* Variable value will be changed by callbacks */ -int callback_variable = -1; +/* + Variable value will be changed by callbacks. + We want to use thread local variable to avoid theoretical race condition + when after a connection is made and before the check is done another + thread might modify the variable value. + + The aim of the test is to make sure the correct callback is called inside + each thread. If the wrong callback is called the local thread variable + will have unexpected value. Hence we can detect if the driver incorrectly + handles setting of callbacks. +*/ +thread_local int callback_variable = -1; void my_callback(sql::SQLString s) { @@ -4034,14 +4045,30 @@ void connection::test_fido_webauthn(sql::ConnectOptionsMap &opt, bool callback_i if (getenv("PLUGIN_DIR")) opt[OPT_PLUGIN_DIR] = getenv("PLUGIN_DIR"); + /* + This is for extra testing of WEBAUTHN_DEVICE_NUMBER option in various + scenarios of Webauthn authentication. + */ + + { + char *opt_val = getenv("WEBAUTHN_DEVICE_NUMBER"); + if (opt_val) + opt[OPT_WEBAUTHN_DEVICE_NUMBER] = std::atoi(opt_val); + } + sql::Driver * driver = sql::mysql::get_driver_instance(); auto test_connection_drv = [&opt](int expected, sql::Driver *drv) { callback_variable = 0; - cout << "Before connect: " << callback_variable << endl; - Connection fido_connection(drv->connect(opt)); - cout << "After connect: " << callback_variable << endl; + cout << "Before connect: " << callback_variable << + " Expected: " << expected << + " DRIVER=" << drv << " THREAD=" << std::this_thread::get_id() << endl; + auto cn = drv->connect(opt); + Connection fido_connection(cn); + cout << "After connect: " << callback_variable << + " Expected: " << expected << + " DRIVER=" << drv << " THREAD=" << std::this_thread::get_id() << endl; ASSERT_EQUALS(expected, callback_variable); }; @@ -4052,7 +4079,6 @@ void connection::test_fido_webauthn(sql::ConnectOptionsMap &opt, bool callback_i try { - cout << endl << "Default callback (0)" << endl; test_connection(0); @@ -4085,46 +4111,66 @@ void connection::test_fido_webauthn(sql::ConnectOptionsMap &opt, bool callback_i cout << endl << "Multi driver tests: " << endl; - auto multi_drv_test = [test_connection_drv]() + /* + The driver instances should be created before they are + used inside the multi-thread test. + */ + sql::Driver *driver1 = sql::mysql::get_driver_instance_by_name("drv1"); + sql::Driver *driver2 = sql::mysql::get_driver_instance_by_name("drv2"); + + auto multi_drv_test = [test_connection_drv, driver1, driver2]() { - sql::Driver * driver1 = sql::mysql::get_driver_instance_by_name("drv1"); - driver1->setCallBack(CB{[](sql::SQLString msg) { - cout << "Driver 1 Callback : " << msg << endl; + driver1->setCallBack(CB{[driver1](sql::SQLString msg) { + cout << "Driver 1 Callback : " << msg << " DRIVER=" << + driver1 << " THREAD=" << std::this_thread::get_id() << endl; callback_variable = 111; }}); - sql::Driver * driver2 = sql::mysql::get_driver_instance_by_name("drv2"); - driver2->setCallBack(CB{[](sql::SQLString msg) { - cout << "Driver 2 Callback : " << msg << endl; + driver2->setCallBack(CB{[driver2](sql::SQLString msg) { + cout << "Driver 2 Callback : " << msg << " DRIVER=" << + driver2 << " THREAD=" << std::this_thread::get_id() << endl; callback_variable = 222; }}); test_connection_drv(111, driver1); test_connection_drv(222, driver2); - // Multi-driver callbacks have to be reset too. - // Otherwise they will remain set in the next test. - driver1->setCallBack(CB{nullptr}); - driver2->setCallBack(CB{nullptr}); }; multi_drv_test(); + /* + Multi-driver callbacks have to be reset too. + Otherwise they will remain set in the next test. + */ + + driver1->setCallBack(CB{nullptr}); + driver2->setCallBack(CB{nullptr}); + cout << endl << "Multithread driver tests: " << endl; { std::vector workers; - for (int i = 0; i < 3; ++i) - { + for (int i = 0; i < 3; ++i) { workers.push_back(std::thread{multi_drv_test}); } - for (auto &w : workers) - { + for (auto &w : workers) { w.join(); } } + + /* + Multi-driver callbacks have to be reset after all threads finish. + Otherwise, resetting a callback for a driver after one thread + is finished, but another one is still running will result in + premature disabling of the callbacks. + */ + + driver1->setCallBack(CB{nullptr}); + driver2->setCallBack(CB{nullptr}); + } catch (sql::SQLException &e) { @@ -4310,5 +4356,131 @@ void connection::macro_version() #endif } +void connection::openid_token() +{ + try { + stmt->execute("UNINSTALL PLUGIN authentication_openid_connect"); + } catch (...) {} + + bool plugin_installed = false; + + // Try every known shared lib extension. If any of them succeeds + // we can go with the test. + for (sql::SQLString extension : { ".so", ".dylib", ".sl", ".dll", "" }) { + try { + stmt->execute("INSTALL PLUGIN authentication_openid_connect " + "SONAME 'authentication_openid_connect" + extension + "'"); + + // Plugin is installed if the execution reached these lines. + // So, the loop can be exited. + plugin_installed = true; + break; + } catch (...) { } + } + + if (!plugin_installed) + SKIP("Server doesn't support auth test plugin authentication_openid_connect"); + + std::cout << "Plugin installed\n"; + + #define L1Q "\"" + #define L2Q "\\\"" + #define L3Q "\\\\\\\"" + + stmt->execute("SET GLOBAL authentication_openid_connect_configuration = " + L1Q "JSON://{" + L2Q "myissuer" L2Q ":" L2Q "{" + L3Q "kid" L3Q ":" L3Q "b50071d7-e2f0-4e5e-9ae8-c71ac21d16bd" L3Q "," + L3Q "kty" L3Q ":" L3Q "RSA" L3Q "," + L3Q "alg" L3Q ":" L3Q "RS256" L3Q "," + L3Q "use" L3Q ":" L3Q "sig" L3Q "," + L3Q "e" L3Q ":" L3Q "AQAB" L3Q "," + L3Q "name" L3Q ":" L3Q "https://myissuer.com/" L3Q "," + L3Q "n" L3Q ":" L3Q "09bia-SkqQHWNDZzYoHQtOLUDESzzsjU0rqnyen9o9LG" + "DNLGFCFiz0XDOTQhu5ZL7XcHB_IEY9kFdewIC7Kcm8pDJOp7hkXMOeopNP3SlH_lg" + "nVSjf6OSWdtAdeL4oW_8zryGoCCy2IksNY53lOF_zDg3DH1qSvCl1VXK50MIwe0BW" + "jT71VX_tkK_iXPzMxEPXol8hKU5djWfxGRjaKDqsffDt_UJudOHIH_O81oMpT82UQ" + "SOzmZBCwcf6jemLAWKDDo6mBxwXAHp8is_mvbisuU9QgKKjsG6FXmIQaj-jXR4IHg" + "lhV-aN_jqi8Y9ab0EANpDqAqbwdBQeL9BTp9fsW32gOTY_a7_gLOwZpCIBkalrGW9" + "E6zA0pBiypSuA0Ag5lB8dddRE486zsxxFYIBpDhMzK_CQ9Kq-3B44yJOheBdRRHYo" + "EXWfuXTKIbzDoctVw_TBBD3Qh3cV5FSs9lTUAU_eFhbYdoTR9FyTXHMDCo8Axxc66" + "IU6EdyUk6xLV9PtyCVWGoM_mFBvEwf7-btJYo73Xqw74T3eVZeTdLAHPHTojMybc5" + "OYt_UhpwDlI2lDGUAEEWsn5_XBhJeXc_GEGdEOowieWdwcRYgNFERkvH6-XSbZ0ii" + "Zxyi_Ri4DrYK1pm-WDxrFB-RuG1evcLG7rmacIDo1LPApMtpnHkYxc" L3Q + "}" L2Q + "}" L1Q ";" + ); + + std::cout << "Server configured\n"; + + stmt->execute("DROP USER IF EXISTS 'MySQLUser'@'%'"); + + stmt->execute("CREATE USER 'MySQLUser'@'%' IDENTIFIED WITH " + "'authentication_openid_connect' AS " + "'{\"identity_provider\" : \"myissuer\", \"user\" : \"mysubj\"}'"); + + std::cout << "User created\n"; + + sql::SQLString cur_path = std::filesystem::current_path().string() + + std::string(1, std::filesystem::path::preferred_separator); + + // If token parameter is not specified it will be given via map + // as a non-path (non-string parameter) + auto connect_func = [&cur_path, this](sql::SQLString *token, bool is_ok, + sql::ConnectOptionsMap map = {}) + { + sql::ConnectOptionsMap opts = map; + opts[OPT_USERNAME] = "MySQLUser"; + opts["hostName"] = url; + + if (getenv("PLUGIN_DIR")) + opts[OPT_PLUGIN_DIR] = getenv("PLUGIN_DIR"); + + + if (token) + { + if (token->length()) { + opts[OPT_OPENID_TOKEN_FILE] = cur_path + *token; + std::cout << "Using token " << *token << std::endl; + } else { + std::cout << "Token not given" << std::endl; + } + } else { + std::cout << "Using token which is not a path" << std::endl; + } + + try{ + Connection con(driver->connect(opts)); + if (!is_ok) + FAIL("Connection was expected to fail"); + } catch(sql::SQLException &e) { + if (is_ok) + throw e; + } + }; + + sql::SQLString correct_token = "openid_token_correct.txt"; + + // OK with correct token + connect_func(&correct_token, true); + + // FAIL with correct token, but disabled SSL + connect_func(&correct_token, false, + {{OPT_SSL_MODE , sql::SSL_MODE_DISABLED}}); + + // FAIL with token not being a path + connect_func(nullptr, false, + {{OPT_OPENID_TOKEN_FILE, 100}}); + + // FAIL with all token values + for (sql::SQLString t : { "", "non_existing", "openid_token_empty.txt", + "openid_token_invalid.txt", "openid_token_user2.txt", + "openid_token_key2.txt", "openid_token_issuer2.txt", + "openid_token_expired.txt"}) { + connect_func(&t, false); + } + +} + } /* namespace connection */ } /* namespace testsuite */ diff --git a/jdbc/test/unit/classes/connection.h b/jdbc/test/unit/classes/connection.h index 3de8631bc..c82841870 100644 --- a/jdbc/test/unit/classes/connection.h +++ b/jdbc/test/unit/classes/connection.h @@ -62,6 +62,7 @@ class connection : public unit_fixture * TODO: enable it when DNS+SRV works in docker TEST_CASE(checkDnsSrv); */ + TEST_CASE(openid_token); TEST_CASE(getClientInfo); TEST_CASE(getClientOption); TEST_CASE(getSessionVariable); @@ -103,7 +104,6 @@ class connection : public unit_fixture TEST_CASE(webauthn_test); TEST_CASE(normalize_ssl_options); TEST_CASE(macro_version); - } /** @@ -330,6 +330,12 @@ class connection : public unit_fixture * */ void macro_version(); + + /* + * Test OPT_OPENID_TOKEN_FILE option. + * + */ + void openid_token(); }; REGISTER_FIXTURE(connection); diff --git a/jdbc/test/unit/classes/tokens/openid_token_correct.txt b/jdbc/test/unit/classes/tokens/openid_token_correct.txt new file mode 100644 index 000000000..51953f9fd --- /dev/null +++ b/jdbc/test/unit/classes/tokens/openid_token_correct.txt @@ -0,0 +1 @@ +eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJteXN1YmoiLCJpc3MiOiJodHRwczovL215aXNzdWVyLmNvbSIsImV4cCI6MjE0MTE5OTA0OH0.giP_mwjDhr-FvcNBJzzQsSqEUOJLm3nJRWOSFRQiywZaRutap8y4vJC9DJWiM4hNngE3jtMd3SkR1ScYqTkZ6TuyOfBZE76lt5e6U-0mVHwPHjyTVaUPZ6izJMv_itITVh3BQYEPYvW42t8o0xZcMPTtE7bEr3ozFiVJSq8kQu34wThGYnT-Ro2ZRKwtowHXwcOA7rj09BeuR21Yk0YZXM5eYkL6eAGAUhWkdv4ary5tGTovWMJ3x5wmEG9RwzGd5F_DcecZFlTGKWE0UINa0p7sHE0HSfZKvW_vB7C5sEgSEQ1bOxu9Gm0UuLWOTjplTScSclJjMqUEkGQoSkYJFD3We-6JmrpvambzYY5OyGVZ71aPErb2Qv2VKUMKr0X-dmYF-kfbR4cS7Ba1PvqL4NsxidotqKivxdr0KtqOBpxTIF0cBWPewarvXbTj7ImH4i6mrKUBBRM6dYYr9x2pCdJRJ3OAwRoOmg1bFY5EJl5Ren43dVdIvfVEnLqmtrLc1MiGdrSz1jKM4ZHEhSP_PKgNcx3c2Q8fqS7KnmXZiLNPwTQ57ogEFmWR_5KTJnN3Xw6ecyhHIOmVzpjF6pYb3QTMvJHVfGkiUdaaYA6ZpU5FmAOEWmhfuqlLNYj7ZabPHyoIR0KfhB_PVB05ITIBWdTVckjh2S5qOMGl4C0UkV4 \ No newline at end of file diff --git a/jdbc/test/unit/classes/tokens/openid_token_empty.txt b/jdbc/test/unit/classes/tokens/openid_token_empty.txt new file mode 100644 index 000000000..e69de29bb diff --git a/jdbc/test/unit/classes/tokens/openid_token_expired.txt b/jdbc/test/unit/classes/tokens/openid_token_expired.txt new file mode 100644 index 000000000..8a81d1f74 --- /dev/null +++ b/jdbc/test/unit/classes/tokens/openid_token_expired.txt @@ -0,0 +1 @@ +eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJteXN1YmoiLCJpc3MiOiJodHRwczovL215aXNzdWVyLmNvbSIsImV4cCI6MTcyMTE5OTEzMH0.QabeeIDGvIoWPzHO8lXi6vzeR0Appq0RVQXNHQBDjMvTfcwyaPjr7cA1JTO36aNZkAO0fdHxKRkG76gteudSKhkg-jGq5C5rkyLjQ-Uau3ZQPt2cgYTYVR13eIMkXGwDrK-Pq6n7P_GtdWs5pgT3cVSJu5QjKby5DFt1MSVTGqr35ZijGcDuBU_E9MV7ypligU8tp9-dzbqtJy8W_0F_LBQstEIZsWTDedEpuoYVPopyReB229t-OGxrWe16q1oOXxKGWDe248-ztXSDnM_89dp_j26w0WXA-lE4uIbx6xVR0EpP9orSjz4ue0m2vvBdyqdGygUJHkoHcM60JPVkl6k2nuZWfJlxTB6ynzqgQfGOaFsOh3VPQ7ONT9H0vr0zAD7psTdK834Oz3aL6fnfbyVH4k8Kk6GQUbOsxcpRxptFCk6D2KmSPnN0U9PX6PKFSyJMLSq_pwA8BuE7lLZUaffwxUPvve0X_0FwMCLo3bJMJewPVoJHe0cEK9PaUWjixj4F0LDD8BpW_et7WO-fozZT0IgDI6J6UdEVNFwiKFrKGMDZ48Gbanve761zfEFEG6ZpPYpgTXC2WYk59_joo1MJlddyh5SUlJd2L-z9YBgv5p2bGB2H7MDCxV14aJBTnxeGbwNfsRYmwxQA6WtFtj58b4EBUK_S9t0Rf2z366w \ No newline at end of file diff --git a/jdbc/test/unit/classes/tokens/openid_token_invalid.txt b/jdbc/test/unit/classes/tokens/openid_token_invalid.txt new file mode 100644 index 000000000..acf9485b0 --- /dev/null +++ b/jdbc/test/unit/classes/tokens/openid_token_invalid.txt @@ -0,0 +1 @@ +hjkGHTJRHNGBFAHJ$^&EHRTGBSDHGMJ#$^%WHGBSNDHGFBVFHGJEHNSFBGHMG diff --git a/jdbc/test/unit/classes/tokens/openid_token_issuer2.txt b/jdbc/test/unit/classes/tokens/openid_token_issuer2.txt new file mode 100644 index 000000000..9e384a0c7 --- /dev/null +++ b/jdbc/test/unit/classes/tokens/openid_token_issuer2.txt @@ -0,0 +1 @@ +eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJteXN1YmoiLCJpc3MiOiJodHRwczovL215aXNzdWVyMi5jb20iLCJleHAiOjIxNDExOTkyODl9.X6xCRzw_FDC4NJ6PEb11JJdsyb7bpkqsXBvOUkjvLfKzDtuFpZ5gGETUz_65pOraXsZAlwD_r645_AczL0MJgA880JtHmWqzzEORT-rNIwlHdZ2BZH4A6BCj-xslWwDKgzkETKe2AEQ5X8aHFO0fF1QwwyPxUUGR0TFaGyOrzL7e02Q0bsu8zvpusx1-WcJSxBRfLDUJN3M-eJo-daU2YZSelj8OxSLZ6FpedJPPrBBWLHwj_jxITp5OkJLsvdivPyuVMdu2acN5gB97P9a3A0Wr0G-uyPNyUj7N2ru0C0bC_B4wUqbPLdrT9U3bFPVA3OCFnt3PzlubU5JYVQUHIXQpZinIpkQQs5zia-e82YghW7Q6GLtWkWTbxOQ3Zgc2jYM_qbTuN8iL4sgmagFgZNV1Zd7rCew2cbTRaL1McdI8H4swkh5i5gfV55bj_t7X9Ow93LmMdayMnm-fQMs8qrp7PXMS2D1YImkg01443wxqAnpdqXHNLxXE_EyfnxbSNTG7y15_-B3CPfbX8srBJQVO9OdrwfLEmP4N6uon2EuNt29kyJtbA7QrEUVT7fNjcdl4FL-Arcc5N9uViPC6W4WerrgkUgHIsgOjfGICr4OY0P9pIX62n7GUrse2HmHpTFcMIwOuqs3nEW_c6JEtfUuDpXwKCMI_Xu7I1k4oAQg \ No newline at end of file diff --git a/jdbc/test/unit/classes/tokens/openid_token_key2.txt b/jdbc/test/unit/classes/tokens/openid_token_key2.txt new file mode 100644 index 000000000..14d083a11 --- /dev/null +++ b/jdbc/test/unit/classes/tokens/openid_token_key2.txt @@ -0,0 +1 @@ +eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJteXN1YmoiLCJpc3MiOiJodHRwczovL215aXNzdWVyLmNvbSIsImV4cCI6MjE0MTE5OTQxOH0.IZtN1cTBTN2gWf7OjUwNwWe0C1E2zgcTh-3E27CIG2NXofk1KgoqhVEs2lqmcHfl8vnYLKOBpxNWuS6sXgsO-HaGVksbDv-N-XeuM4_EJXq5Dx4QxQkDMS2d99yR7o-xTlKf8IS5iRvw6Lgh5U35fOIQeeRWfWwPIz2EQ2Bpwr8IPttkUPy0-n6uFLIhsO8nhZopXGZdWW5WIL96qsPDgnw-P-ogdPAwOMPXwxIkMsngNkE_1dApwnkfwW4e-woox_OpIglt8vTHZGYjJZtFJEJFL0KFlmzRwjZ4gnxyluaiG9dn4F2FoiuPcLwJcEQn0U7m31Cj-dYSIGdPlBxQt229usXXO1Cw7Ls6sEz4sIpyPqZu_UIU-SHwHDIp5duJJakvzy97WicF8hd3iaVbepXKo3B41SWC8zqXfE8J1OZUnwS9JIi1Sfa9T8307q94DM6j76QJ3IhJYwFVmCI9gYoRuxlvmYyS7Y_4lBHRX1_bCaVZPKJyW7IK1GNOTR7SXbGh9ZXotL24ATtCQXploAxjK7JZzqLnI1_aIZbCTK90m9Ty90AW2SU-LkEYhqTToxSCUxC5uBWJvM6gFscfp_bx0fH8uBmXg5hejoMsZjQtPHs2LfaYpTwHOW2uG_zfik2D95Nc5J_Y6hZiCaZW6H1Mps6oyv9nZgK3TIY7_N4 \ No newline at end of file diff --git a/jdbc/test/unit/classes/tokens/openid_token_user2.txt b/jdbc/test/unit/classes/tokens/openid_token_user2.txt new file mode 100644 index 000000000..1ec8ecd1c --- /dev/null +++ b/jdbc/test/unit/classes/tokens/openid_token_user2.txt @@ -0,0 +1 @@ +eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJteXN1YmoyIiwiaXNzIjoiaHR0cHM6Ly9teWlzc3Vlci5jb20iLCJleHAiOjIxNDExOTkzMzl9.PIeiYp0eS3dO2QBh2UAqq48zAxZ5C-snBQmXw1n4zvgc90ZnAfJnJWUeOQxkjU7uQoNA84QuMLH7UV0VXNefscx5YIimOygIh9vwC4stxqUu9sdd3uUiZ-TBABKINz5Li18rRpDpSxWaOYTQ3gkg71BCJ8W1ndUQPtBgP_Yq1d0Fe83ypMF0ukorunAXhqX494wufrxqHjmmf82NpkPoGr4PGm6VwRUHMD46_-sisuxkleYkKYa7KSACjx6YhZRzeWh3iC6j40aMiKETKqVTjPhYskV59PjYjoAykpVegj7HYTx-wBclA0NHyyOVceeSNQ6yMdZAHrJO3axZzD_fQPBNmoIkeem2FSYlV1qZ0t5nIhZqdnSWewkj_tB3AbVHkJyZLPHCfmc3Cye8TQX49tgOwV-slI4xbRGhOXC5dj1vPEmuYYaClzFdsna0wN0spVsCj2v1NS4hGfIC9v8mDBAfBV6k3XGtgwnCU9GtGLWrBWHm5INbbKAid7RNbMECj-nmuUQG9jm59ukVgW_OaX8C0wF8M0-itlW71o0kQASw1CEDK64j0QeFLCGbDiHm3wo5rS-DVVINyNvARpdfZ9u4HorV2eod8cs6b_RN-tYVcR_KdPNYHJjVoleHYO6yQlC0yshP7v55TowL5AwKL0iWafafHq082Ad7KQtwd4A \ No newline at end of file diff --git a/mysql-concpp-config.cmake.in b/mysql-concpp-config.cmake.in index e1469eefb..a6cbf3b8f 100644 --- a/mysql-concpp-config.cmake.in +++ b/mysql-concpp-config.cmake.in @@ -46,16 +46,24 @@ # Also, the following variables are set: # # - Xxx_FOUND -# - Xxx_DEBUG_FOUND, Xxx_debug_FOUND -- (1) +# - Xxx_JDBC_FOUND, Xxx_jdbc_FOUND -- (1a) +# - Xxx_DEBUG_FOUND, Xxx_debug_FOUND -- (1b) +# - Xxx_RELEASE_FOUND, Xxx_release_FOUND -- (1b) # - Xxx_VERSION, Xxx_VERSION_CC # - Xxx_ROOT_DIR -- (2) # - Xxx_RUNTIME_LIBRARY_DIRS, Xxx_RUNTIME_LIBRARY_DIR -- (2,3) -# - Xxx_PLUGIN_DIR -- (4) +# - Xxx_RUNTIME_LIBRARY_DIRS_DEBUG, Xxx_RUNTIME_LIBRARY_DIR_DEBUG -- (4a) +# - Xxx_RUNTIME_LIBRARY_DIRS_RELEASE, Xxx_RUNTIME_LIBRARY_DIR_RELEASE -- (4b) +# - Xxx_PLUGIN_DIR -- (5a,5b) # # In these variable names Xxx is either `MYSQL_CONCPP` or `mysql-concpp`, # CC is version component: one of `MAJOR`, `MINOR` or `PATCH`. # -# Note (1): These are set to true if debug libraries are available +# Note (1a): Set to true if the classic JDBC connector libraries were found and +# the -jdbc targets are defined. It must be the case if `REQUIRE jdbc` clause +# was used in the cmake `find_package()` command. +# +# Note (1b): These are set to true if debug/release libraries are available # (see below). # # Note (2): Set only in case of a monolithic install (TGZ, ZIP, MSI). @@ -67,13 +75,28 @@ # case the _RUNTIME_LIBRARY_DIR(S) variable gives the location where shared # connector libraries can be found. # -# Note (4): The JDBC connector might require loading of authentication plugins -# at connection time (depending on authentication mechaism being used). These +# Note (4a): If debug variants of connector libraries were found these +# variables are set to their location. +# +# Note (4b): For consistency, these variables are set if release variants +# of connector libraries were found and in that case they are equal +# to _RUNTIME_LIBRARY_DIR(S) ones. +# +# Note (5a): The JDBC connector might require loading of authentication plugins +# at connection time (depending on authentication mechanism being used). These # plugins are in the location given by _PLUGIN_DIR variable. Depending on # the installation type it might be necessary to specify this location # with connection configuration options for plugins to be correctly found # at runtime (see: https://dev.mysql.com/doc/connector-cpp/8.2/en/connector-cpp-authentication.html) # +# Note (5b): Authentication plugins are bundled with the connector and +# the _PLUGIN_DIR variable is set only when the JDBC connector links the MySQL +# client library statically (which is the typical case). It is also possible +# to build JDBC connector with dynamic linking to the MySQL client library. +# In that case plugins are not bundled with the connector and _PLUGIN_DIR +# variable is not set -- if needed the plugins that come with the MySQL client +# library should be used in that case. +# # Note: The variables are put in the cache but if Xxx_FOUND is not set or # is false then the module will be re-loaded and the other variables in # the cache will be overwritten with newly detected values. @@ -81,14 +104,15 @@ # Note: If mysql-concpp_FIND_VERBOSE is true when loading package diagnostic # messages will be printed by this script. # +# # OpenSSL dependency # ------------------ # -# Connector/C++ requires OpenSSL libraires. Depending on the platform and +# Connector/C++ requires OpenSSL libraries. Depending on the platform and # the installation type it is either expected that OpenSSL will be installed # on the system or these libraries are bundled in the connector package. # Connector library targets are configured to use OpenSSL from appropriate -# locations. This can be overriden by user -- if `mysql::openssl` target +# locations. This can be overridden by user -- if `mysql::openssl` target # is defined prior to loading `mysql-concpp` package then this target is used # to resolve dependency on the OpenSSL library. # @@ -119,11 +143,26 @@ # clause of `find_package()` command. If this is done then `find_package()` # will fail if debug libraries were not found. # +# When using custom builds of Connector/C++ it is possible to have +# an installation with only debug libraries. On Windows, in such situation, +# the connector targets created here will work only for debug builds. +# On non-Windows platforms debug libraries can and will be used for building +# in any mode. Presence of release libraries is indicated by _RELEASE_FOUND +# variable. One can use `REQUIRE release` clause of `find_package()` command +# to ensure that release variants of the libraries are present. +# # Note: Debug libraries are needed and used only on Windows. For Linux # separate packages with debug symbols are available that can be used -# to debug connector libraries but only release builds of these libararies +# to debug connector libraries but only release builds of these libraries # are distributed. # +# Note: When only debug libraries are available the _RUNTIME_LIBRARY_DIR(S) +# variables point at the location of these debug libraries on non-Windows +# platforms (because they are used by other build types). However, on Windows +# the _RUNTIME_LIBRARY_DIR(S) variables still point to the location where +# release variants of the libraries should be installed (but are not present). +# The libraries can be located using _RUNTIME_LIBRARY_DIR(S)_DEBUG variables +# in such scenario. # message(STATUS "mysql-concpp module config (${MYSQL_CONCPP_FOUND}, ${mysql-concpp_FOUND})") @@ -138,62 +177,65 @@ function(message_info) message(STATUS "mysql-concpp: " ${ARGV}) endfunction() +function(set_warning) + set(warning_message ${ARGV} CACHE INTERNAL "warning message") +endfunction() + # -# If WITH_MYSQL is not false then it is assumed that the `concpp-jdbc-static` -# target depends on the MySQL client library. Additionally, if WITH_MYSQL is a -# path pointing at MySQL install location, the library path will be extended so -# that linker looks for the client library at that location. -# -# Note: The default value is set based on whether the JDBC connector was -# statically linked with the client library or not. +# JDBC_MYSQL_DEP tells whether JDBC connector library depends on the MySQL +# client library. This is not the case when the connector library links +# the client library statically. However, if WITH_MYSQL option is defined +# and not false then JDBC targets are always configured to depend on the client +# library. Additionally, if WITH_MYSQL is a path pointing at MySQL install +# location, the library path will be extended so that linker looks for the +# client library at that location. # -if(NOT @MYSQLCLIENT_STATIC_LINKING@) +set(JDBC_MYSQL_DEP OFF) +if(WITH_MYSQL OR NOT @MYSQLCLIENT_STATIC_LINKING@) set(JDBC_MYSQL_DEP ON) -else() - set(JDBC_MYSQL_DEP OFF) endif() -set(WITH_MYSQL ${JDBC_MYSQL_DEP} - CACHE INTERNAL - "MySQL install location (to find the client library)" -) - macro(main) - # Set paths to look for headers and libraries either relative to this file - # or in system-wide locations. - # - # FIXME: lib64/ or lib/ as appropriate for the platform - + # We can have two types of installations -- in case of RPM/DEB install + # connector files are installed to system-wide locations (system-wide + # install), in other cases all connector files are installed into a single + # root directory (monolithic install). if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/include/mysqlx/xdevapi.h") # Case of monolithic install + set(monolithic 1) + set(MYSQL_CONCPP_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}") - set(LIB_PATH "${MYSQL_CONCPP_ROOT_DIR}/@INSTALL_LIB_DIR@") message_info("Module installed at: ${MYSQL_CONCPP_ROOT_DIR}") - set(INCLUDE_PATH "${MYSQL_CONCPP_ROOT_DIR}/include") + + set(INCLUDE_DIR "${MYSQL_CONCPP_ROOT_DIR}/include") + set(LIBRARY_DIR "${MYSQL_CONCPP_ROOT_DIR}/@INSTALL_LIB_DIR@") + + set(fail_message "Could NOT find MySQL Connector/C++ libraries at ${MYSQL_CONCPP_ROOT_DIR}.") else() # System-wide install, DEB or RPM layout. - set(INCLUDE_PATH "/usr/include/mysql-cppconn") - get_filename_component(LIB_PATH "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) + set(monolithic 0) - file(GLOB found "${LIB_PATH}/*libmysqlcppconn*") + set(INCLUDE_DIR "/usr/include/mysql-cppconn") - if(NOT found) - # Note: Use RPM layout as fallback - set(LIB_PATH "/usr/@INSTALL_LIB_DIR@") - endif() + # We do not set LIBRARY_DIR because in this case we will search for the libraries in system-wide locations. + + set(fail_message + "Could NOT find MySQL Connector/C++ libraries at system-wide locations." + ) endif() + # Headers must always be found first. find_includes() @@ -208,25 +250,109 @@ macro(main) message_info("Include path: ${MYSQL_CONCPP_INCLUDE_DIR}") - # Note: On windows we look for the import library, not the DLL. This import - # library normally is in a ./vsNN subfolder of the library path. + # This suffix is used to locate static and import libraries on Windows - unset(vs_suffix) + set(vs_suffix) if(WIN32) set(vs_suffix vs14) endif() - # Find required dependencies. Currtently this looks for OpenSSL and defines + # Find required dependencies. Currently this looks for OpenSSL and defines # `mysql::openssl` interface library for it if found. find_deps() # Find connector libraries and define interface targets for the ones that - # were found. + # were found. This will set/update LIBRARY_DIR to the location where + # libraries were found and will also set RELEASE/DEBUG_FOUND flags + # if the corresponding variant of the libraries was found. + + set(DEBUG_FOUND 0) + set(RELEASE_FOUND 0) find_connector(XDevAPI) find_connector(JDBC) + + set(MYSQL_CONCPP_DEBUG_FOUND ${DEBUG_FOUND}) + set(MYSQL_CONCPP_RELEASE_FOUND ${RELEASE_FOUND}) + + if(monolithic) + + # Set MYSQL_CONCPP_RUNTIME_LIBRARY_DIR_*. Variables based on LIBRARY_DIR + # determined above. + + if(DEBUG_FOUND) + + set(MYSQL_CONCPP_RUNTIME_LIBRARY_DIR_DEBUG "${LIBRARY_DIR}/debug") + + elseif(WIN32) + + set_warning( + "Debug variants of connector libraries were not found" + "at the install location -- building in debug mode will not work" + ) + + endif() + + + if(RELEASE_FOUND) + + set(MYSQL_CONCPP_RUNTIME_LIBRARY_DIR_RELEASE "${LIBRARY_DIR}") + set(MYSQL_CONCPP_RUNTIME_LIBRARY_DIR "${LIBRARY_DIR}") + + elseif(NOT WIN32) + + # If release libraries were not found and we are on non-Win platform we + # will use debug libraries also for release builds. + + message_info( + "Using debug variants of connector libraries for release builds because" + " release variants are not found at the install location" + ) + + set( + MYSQL_CONCPP_RUNTIME_LIBRARY_DIR + "${MYSQL_CONCPP_RUNTIME_LIBRARY_DIR_DEBUG}" + ) + + else() + + # On Windows one can not mix release and debug code. The targets created + # above have only debug-mode paths defined. We set + # MYSQL_CONCPP_RUNTIME_LIBRARY_DIR to the path where release libraries + # would be expected even if they were not found there. + + set_warning( + "Release variants of connector libraries were not found" + "at the install location -- building in release mode will not work" + ) + + set(MYSQL_CONCPP_RUNTIME_LIBRARY_DIR "${LIBRARY_DIR}") + + endif() + + # Note: Set plugin dir location only if connector has client library + # statically linked in (does not depend on external one). + + if(NOT JDBC_MYSQL_DEP) + set(MYSQL_CONCPP_PLUGIN_DIR "${LIBRARY_DIR}/plugin") + endif() + + else() + + # Note: In system-wide install case we do not set _RUNTIME_LIBRARY_DIR_* + # variables as libraries are installed at system-wide locations. + + if(NOT JDBC_MYSQL_DEP) + set(MYSQL_CONCPP_PLUGIN_DIR + "${LIBRARY_DIR}/mysql/libmysqlcppconn@JDBC_ABI_VERSION_MAJOR@/plugin" + ) + endif() + + endif() + + # Aliases for -xdevapi* targets. foreach(suffix "" "-static" "-debug" "-static-debug") @@ -236,15 +362,17 @@ macro(main) add_library(mysql::concpp${suffix} ALIAS mysql::concpp-xdevapi${suffix}) endif() - endforeach() + if(TARGET mysql::concpp-jdbc${suffix}) + set(MYSQL_CONCPP_JDBC_FOUND 1) + endif() + +endforeach() # Build the NOT_FOUND message. # Note: The different find_xxx() functions set the specific part # of the message, such as ${fail_message_devapi}, in case of failure. - set(fail_message "Could NOT find MySQL Connector/C++ at ${MYSQL_CONCPP_RUNTIME_LIBRARY_DIR}.") - if(fail_message_devapi) # AND MYSQL_CONCPP_FIND_REQUIRED_devapi) list(APPEND fail_message ${fail_message_devapi}) elseif(fail_message_jdbc) # AND MYSQL_CONCPP_FIND_REQUIRED_jdbc) @@ -253,37 +381,73 @@ macro(main) set_not_found(${fail_message}) + # Build the success message which can optionally contain warnings + # TODO: Warnings about missing debug/release library variants + + set(MYSQL_CONCPP_FOUND_MSG ${MYSQL_CONCPP_INCLUDE_DIR}) + if(warning_message) + string(JOIN " " warning_message ${warning_message}) + set(MYSQL_CONCPP_FOUND_MSG + "${MYSQL_CONCPP_FOUND_MSG} WARNING: ${warning_message}" + ) + endif() + include(FindPackageHandleStandardArgs) + # Note: The _FOUND variable name expected by FPHSA for component CCC + # is mysql-concpp_CCC_FOUND + + set(mysql-concpp_jdbc_FOUND ${MYSQL_CONCPP_JDBC_FOUND}) + set(mysql-concpp_debug_FOUND ${MYSQL_CONCPP_DEBUG_FOUND}) + set(mysql-concpp_release_FOUND ${MYSQL_CONCPP_RELEASE_FOUND}) + find_package_handle_standard_args(mysql-concpp REQUIRED_VARS - mysql-concpp_VERSION - MYSQL_CONCPP_FOUND + MYSQL_CONCPP_FOUND_MSG MYSQL_CONCPP_INCLUDE_DIR + MYSQL_CONCPP_FOUND VERSION_VAR mysql-concpp_VERSION - # HANDLE_COMPONENTS + HANDLE_COMPONENTS FAIL_MESSAGE "${mysql-concpp_NOT_FOUND_MESSAGE}" ) # Set alternative variables + set(MYSQL_CONCPP_jdbc_FOUND ${MYSQL_CONCPP_JDBC_FOUND}) + set(MYSQL_CONCPP_debug_FOUND ${MYSQL_CONCPP_DEBUG_FOUND}) + set(MYSQL_CONCPP_release_FOUND ${MYSQL_CONCPP_RELEASE_FOUND}) + foreach(var - ROOT_DIR PLUGIN_DIR RUNTIME_LIBRARY_DIR RUNTIME_LIBRARY_DIRS DEBUG_FOUND + ROOT_DIR PLUGIN_DIR + RUNTIME_LIBRARY_DIR RUNTIME_LIBRARY_DIRS + RUNTIME_LIBRARY_DIR_DEBUG RUNTIME_LIBRARY_DIRS_DEBUG + RUNTIME_LIBRARY_DIR_RELEASE RUNTIME_LIBRARY_DIRS_RELEASE + DEBUG_FOUND debug_FOUND RELEASE_FOUND release_FOUND + JDBC_FOUND jdbc_FOUND ) if(NOT DEFINED MYSQL_CONCPP_${var}) continue() endif() - set(mysql-concpp_${var} ${MYSQL_CONCPP_${var}} CACHE INTERNAL "mysql-concpp module config variable" FORCE) - set(MYSQL_CONCPP_${var} ${MYSQL_CONCPP_${var}} CACHE INTERNAL "mysql-concpp module config variable" FORCE) + # handle _DIR_ and _DIRS_ variants if(var STREQUAL "RUNTIME_LIBRARY_DIR") - set(MYSQL_CONCPP_RUNTIME_LIBRARY_DIRS - "${MYSQL_CONCPP_RUNTIME_LIBRARY_DIR}" - ) + foreach(suffix "" "_RELEASE" "_DEBUG") + if(NOT DEFINED MYSQL_CONCPP_RUNTIME_LIBRARY_DIR${suffix}) + continue() + endif() + set( + MYSQL_CONCPP_RUNTIME_LIBRARY_DIRS${suffix} + "${MYSQL_CONCPP_RUNTIME_LIBRARY_DIR${suffix}}" + ) + endforeach() endif() + set(mysql-concpp_${var} ${MYSQL_CONCPP_${var}} CACHE INTERNAL "mysql-concpp module config variable" FORCE) + set(MYSQL_CONCPP_${var} ${MYSQL_CONCPP_${var}} CACHE INTERNAL "mysql-concpp module config variable" FORCE) + + endforeach(var) foreach(ver "" _MAJOR _MINOR _PATCH _TWEAK _COUNT) @@ -313,23 +477,24 @@ endfunction() function(find_includes) - #message(STATUS "Looking for headers at: ${INCLUDE_PATH}") + #message(STATUS "Looking for headers at: ${INCLUDE_DIR}") + unset(MYSQL_CONCPP_INCLUDE_DIR CACHE) find_path(MYSQL_CONCPP_INCLUDE_DIR NAMES mysqlx/xdevapi.h - PATHS ${INCLUDE_PATH} + PATHS ${INCLUDE_DIR} NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE # Note: requires cmake 3.21 ) if(NOT MYSQL_CONCPP_INCLUDE_DIR) if(MYSQL_CONCPP_ROOT_DIR) set(fail_message_includes - "at MYSQL_CONCPP_ROOT_DIR: ${INCLUDE_PATH}" + "at MYSQL_CONCPP_ROOT_DIR: ${INCLUDE_DIR}" ) else() - set(fail_message_includes "at ${INCLUDE_PATH}") + set(fail_message_includes "at ${INCLUDE_DIR}") endif() set_parent(fail_message_includes) @@ -344,47 +509,31 @@ endfunction() # Find XDevAPI or JDBC connector libraries, as specified by parameter `which` # and create interface library targets for them. Both shared and static -# variants are searched for. +# variants are searched for. If some libraries are not found the corresponding +# targets are not created. +# +# If LIBRARY_DIR is set the libraries are searched in that location, otherwise +# they are searched in system-wide locations. In either case LIBRARY_DIR is +# set/updated to the location where libraries were found. # -# TODO: Currently this will fail if release libraries are not found, even -# if debug ones are present. Should this be changed? +# Flags RELEASE_FOUND and DEBUG_FOUND are set if the corresponding variants +# of the libraries were found. function(find_connector which) if(which STREQUAL "JDBC") set(base_name "mysqlcppconn") - set(target_name "concpp-jdbc") + set(target_name "jdbc") else() set(base_name "mysqlcppconnx") - set(target_name "concpp-xdevapi") + set(target_name "xdevapi") endif() - # Set location of shared libraries or DLLs in case of Win (if not already - # done). - - if(NOT MYSQL_CONCPP_RUNTIME_LIBRARY_DIR) - - set(MYSQL_CONCPP_RUNTIME_LIBRARY_DIR "${LIB_PATH}") - - # Note: set MYSQL_CONCPP_RUNTIME_LIBRARY_DIR as output variable only - # in case of monolithic install. - - if(MYSQL_CONCPP_ROOT_DIR) - - message_info( - "Runtime library folder: ${MYSQL_CONCPP_RUNTIME_LIBRARY_DIR}" - ) - set_parent(MYSQL_CONCPP_RUNTIME_LIBRARY_DIR) - - endif() - - set( - MYSQL_CONCPP_PLUGIN_DIR "${MYSQL_CONCPP_RUNTIME_LIBRARY_DIR}/plugin" - PARENT_SCOPE - ) - - endif() + # Look for the connector library and if found create the import target for + # it. Sets ${target_name}_RELEASE and ${target_name}_DEBUG to indicate + # whether release/debug variant of the library was found. Also sets + # or updates LIBRARY_DIR to the location where the library was found. add_connector_target(${which} ${target_name} ${base_name}) @@ -396,27 +545,48 @@ function(find_connector which) add_connector_target(${which} ${target_name}-static ${base_name}-static) endif() - set_parent(MYSQL_CONCPP_DEBUG_FOUND) + # Process targets created above to do consistency checks and declare required + # dependencies. Also sets DEBUG/RELEASE_FOUND flags as needed. foreach(tgt ${target_name} ${target_name}-static) - if(NOT TARGET mysql::${tgt}) + if(${tgt}_RELEASE) + set_parent(RELEASE_FOUND 1) + endif() + + if(${tgt}_DEBUG) + set_parent(DEBUG_FOUND 1) + endif() + + if(NOT TARGET mysql::concpp-${tgt}) continue() endif() + if(DEBUG_FOUND AND NOT ${tgt}_DEBUG) + list(APPEND DEBUG_MISSING ${tgt}) + endif() + set_parent(DEBUG_MISSING) + + if(RELEASE_FOUND AND NOT ${tgt}_RELEASE) + list(APPEND RELEASE_MISSING ${tgt}) + endif() + set_parent(RELEASE_MISSING) + unset(libs) - # JDBC dependency on the client library if specified via WITH_MYSQL + # JDBC dependency on the client library - if(target_name MATCHES "-jdbc" AND WITH_MYSQL) + if(tgt MATCHES "jdbc" AND JDBC_MYSQL_DEP) - list(APPEND libs mysqlclient) + if(NOT WIN32) + list(APPEND libs mysqlclient) + endif() - if(EXISTS "${WITH_MYSQL}/lib") + if(DEFINED WITH_MYSQL AND EXISTS "${WITH_MYSQL}/lib") message_info("Client library path: ${WITH_MYSQL}/lib") - target_link_directories(mysql::${tgt} + target_link_directories(mysql::concpp-${tgt} INTERFACE "${WITH_MYSQL}/lib" ) @@ -426,7 +596,7 @@ function(find_connector which) # OpenSSL dependency (target `mysql::openssl` is defined by find_deps()) # - # Note: Even though legacy connector does not use OpenSSL directly it migth + # Note: Even though JDBC connector does not use OpenSSL directly it might # have the client library statically linked in and get dependency # on OpenSSL that way. @@ -436,7 +606,7 @@ function(find_connector which) if(tgt MATCHES "-static") - set_target_properties(mysql::${tgt} PROPERTIES + set_target_properties(mysql::concpp-${tgt} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES CXX INTERFACE_COMPILE_DEFINITIONS STATIC_CONCPP ) @@ -467,98 +637,218 @@ function(find_connector which) endif() - target_link_libraries(mysql::${tgt} INTERFACE ${libs}) + target_link_libraries(mysql::concpp-${tgt} INTERFACE ${libs}) - string(JOIN " " libs ${libs}) - message_info("Link libraries for target ${tgt}: ${libs}") + if(libs) + string(JOIN " " libs ${libs}) + message_info("Link libraries for target ${tgt}: ${libs}") + endif() endforeach(tgt) endfunction(find_connector) -# Create connector library import target named ${tgt} and pointing at library -# with base name ${base_name}. Target is not created if the library could -# not be found. If debug variant of library is found then it is used -# for IMPORT_LOCATION_DEBUG. In this case _DEBUG_FOUND variable is set to 1. +# Create connector library import target named ${tgt} pointing at library +# with base name ${base_name} if it was found. +# +# If LIBRARY_DIR is set the library is searched in that location, otherwise it +# is searched in system-wide locations. If the library is found, LIBRARY_DIR +# is set/updated to the location where it was found. +# +# Both release and debug variants of the library are searched for. Flags +# ${tgt}_RELEASE and ${tgt}_DEBUG are set to tell which variant was found. +# +# Note: The which parameter, either "XDevAPI" or "JDBC", is used for +# diagnostics only. function(add_connector_target which tgt base_name) + set(lib_name "${base_name}") set(type "SHARED") + set(static 0) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) + if(tgt MATCHES "-static") set(type "STATIC") + set(static 1) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) + endif() + + set(XDevAPI_abi @ABI_VERSION_MAJOR@) + set(JDBC_abi @JDBC_ABI_VERSION_MAJOR@) + set(find_lib_paths) + set(win_opts) + + if(LIBRARY_DIR) + set(find_lib_paths PATHS "${LIBRARY_DIR}" NO_DEFAULT_PATH) endif() + if(WIN32) + if(static) + set(win_opts PATH_SUFFIXES ${vs_suffix}) + else() + set(lib_name "${base_name}-${${which}_abi}-vs14") + endif() + endif() + + #message("!!! looking for ${lib_name} with options: ${find_lib_opts}") + unset(lib_path CACHE) find_library(lib_path - NAMES ${base_name} - PATHS ${MYSQL_CONCPP_RUNTIME_LIBRARY_DIR}/${vs_suffix} - NO_DEFAULT_PATH - NO_CACHE + NAMES ${lib_name} + ${find_lib_paths} ${win_opts} + # NO_CACHE ) - if(NOT lib_path) - message_info("Did not find ${which} ${type} library") - return() - endif() + if(lib_path) - message_info("${which} ${type} library at: ${lib_path}") - #message(STATUS "Creating target: mysql::${tgt}") + message_info( + "Found ${which} ${type} library at: ${lib_path}" + ) - add_library(mysql::${tgt} ${type} IMPORTED GLOBAL) + set_parent(${tgt}_RELEASE 1) - target_compile_features(mysql::${tgt} INTERFACE cxx_std_11) + # Note: LIBRARY_DIR is not yet set here if we were looking for the library + # in system-wide locations. In any case we set/update LIBRARY_DIR to + # the actual location of the library that was found. - set_target_properties(mysql::${tgt} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${MYSQL_CONCPP_INCLUDE_DIR}" - ) + get_filename_component(LIBRARY_DIR "${lib_path}" DIRECTORY) + set_parent(LIBRARY_DIR) - # TODO: On Win set IMPORTED_LOCATION to the DLL path rather than the import library... + if(WIN32 AND NOT static) + find_imp_lib(imp_lib_path ${base_name} "${lib_path}") + endif() - set_target_properties(mysql::${tgt} PROPERTIES - IMPORTED_LOCATION "${lib_path}" - ) + endif() - if(WIN32) - set_target_properties(mysql::${tgt} PROPERTIES - IMPORTED_IMPLIB "${lib_path}" + # Look for debug variant of the library if LIBRARY_DIR is set. This is + # the case in one of these situations: + # + # a) the release library was found at LIBRARY_DIR above; + # + # b) we have monolithic connector install and LIBRARY_DIR is the library + # location inside that monolithic install. + # + # Case (b) is if we have not found the release library inside a monolithic + # connector installation but we still can find a debug library there. + + if(LIBRARY_DIR) + + unset(lib_path_debug CACHE) + find_library(lib_path_debug + NAMES ${lib_name} + PATHS "${LIBRARY_DIR}/debug" + ${win_opts} + NO_DEFAULT_PATH + # NO_CACHE ) - endif() - # Look for debug variant of the library. + if(lib_path_debug) - unset(lib_path_debug CACHE) - find_library(lib_path_debug - NAMES ${base_name} - PATHS ${MYSQL_CONCPP_RUNTIME_LIBRARY_DIR}/debug/${vs_suffix} - NO_DEFAULT_PATH - NO_CACHE - ) + message_info( + "Found debug variant of ${which} ${type} library at: ${lib_path_debug}" + ) - if(lib_path_debug) + set_parent(${tgt}_DEBUG 1) + + if(WIN32 AND NOT static) + find_imp_lib(imp_lib_path_debug ${base_name} "${lib_path_debug}") + endif() + + endif() + + endif() - message_info( - "Found debug variant of ${which} ${type} library at: ${lib_path_debug}" - ) - set(MYSQL_CONCPP_DEBUG_FOUND 1 PARENT_SCOPE) + if(NOT lib_path AND NOT lib_path_debug) + + message_info("Did not find ${which} ${type} library") + return() endif() - # Note: On non-Windows platforms we set the debug location of the connector - # target only if the debug library variant was found so that if it was - # not found then the release variant will be used. # - # However, on Windows it is not possible to mix debug and release code. - # Therefore we always set the debug location of the connector target - # on Windows so that if it is used in debug builds and the debug library - # variant is not present a linker error will be reported. + # Note: At this point we know that either the release or the debug connector + # was found. + # + # On non-Windows platforms the release connector can be used for debug + # builds if the debug connector was not found and vice-versa, the debug + # connector can be used for release builds if the release connector was + # not found. + # + # However, on Windows it is not possible to mix debug and release code which + # is reflected in the logic below. + # - if(WIN32) + if(WIN32 AND NOT lib_path_debug) + + # If debug connector was not found on Windows we still set debug path to its + # expected location so that: + # + # 1. If debug connector is added later it will be used in debug builds. + # + # 2. If debug connector is not present then debug builds will fail which + # is what we want in that case (rather than incorrectly using the release + # variant of the library). + # + # Note: LIBRARY_DIR must be defined because the release library must have + # been found above. set(lib_path_debug - "${MYSQL_CONCPP_RUNTIME_LIBRARY_DIR}/debug/${vs_suffix}/${base_name}.lib" + "${LIBRARY_DIR}/debug/${lib_name}.dll" ) + set(imp_lib_path_debug + "${LIBRARY_DIR}/debug/${vs_suffix}/${base_name}.lib" + ) + + # Note: If debug connector was not found on non-Windows platform then + # lib_path_debug remains undefined which means that the import target will + # not have a _DEBUG location defined. Therefore the main (release) location + # will be used also in debug builds as we want in that case. + + elseif(WIN32 AND NOT lib_path) + + # If release connector was not found on Windows we still set the release + # path to its expected location so that release builds will fail (because + # the release library will be not found at the location) or, if release + # connector is added later release builds will start working. + + set(lib_path "${LIBRARY_DIR}/${lib_name}.dll") + set(imp_lib_path "${LIBRARY_DIR}/${vs_suffix}/${base_name}.lib") + + elseif(NOT WIN32 AND NOT lib_path) + + # If we are on non-Windows platform and the release connector was not found + # then use the debug connector as a replacement. + + set(lib_path "${lib_path_debug}") + + endif() + + + set(tgt "concpp-${tgt}") + #message(STATUS "Creating target: mysql::${tgt}") + + add_library(mysql::${tgt} ${type} IMPORTED GLOBAL) + target_compile_features(mysql::${tgt} INTERFACE cxx_std_11) + + set_target_properties(mysql::${tgt} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MYSQL_CONCPP_INCLUDE_DIR}" + ) + + + if(lib_path) + + set_target_properties(mysql::${tgt} PROPERTIES + IMPORTED_LOCATION "${lib_path}" + ) + + if(WIN32 AND imp_lib_path) + set_target_properties(mysql::${tgt} PROPERTIES + IMPORTED_IMPLIB "${imp_lib_path}" + ) + endif() endif() @@ -568,9 +858,9 @@ function(add_connector_target which tgt base_name) IMPORTED_LOCATION_DEBUG "${lib_path_debug}" ) - if(WIN32) + if(WIN32 AND imp_lib_path_debug) set_target_properties(mysql::${tgt} PROPERTIES - IMPORTED_IMPLIB_DEBUG "${lib_path_debug}" + IMPORTED_IMPLIB_DEBUG "${imp_lib_path_debug}" ) endif() @@ -579,6 +869,36 @@ function(add_connector_target which tgt base_name) endfunction(add_connector_target) +# On Windows find import library for the DLL library at the given `path` with +# given `base_name`. The location of the import library is stored in variable +# named by `var`. +# +# Note: Not finding an import library for a DLL is a fatal error. + +function(find_imp_lib var base_name path) + + get_filename_component(base_path ${path} DIRECTORY) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib) + + #message("!!! Looking for import library for: ${path}") + unset(${var} CACHE) + find_library(${var} + NAMES ${base_name} + PATHS ${base_path} + PATH_SUFFIXES ${vs_suffix} + NO_DEFAULT_PATH + # NO_CACHE + ) + + if(NOT ${var}) + message(FATAL_ERROR "Could not find import library for ${path}") + endif() + + set_parent(${var}) + +endfunction(find_imp_lib) + + function(find_deps) if(TARGET mysql::openssl) @@ -600,19 +920,19 @@ function(find_deps) unset(ssl_lib CACHE) find_library(ssl_lib NAMES ssl libssl - PATHS ${LIB_PATH} + PATHS ${LIBRARY_DIR} PATH_SUFFIXES private ${vs_suffix} NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE ) unset(ssl_crypto CACHE) find_library(ssl_crypto NAMES crypto libcrypto - PATHS ${LIB_PATH} + PATHS ${LIBRARY_DIR} PATH_SUFFIXES private ${vs_suffix} NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE ) if(NOT ssl_lib OR NOT ssl_crypto) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index b082261d3..7a86eed8e 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -26,6 +26,88 @@ # along with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Note: Version 3.15 is required becausae package build instructions +# depend on cmake recognizing --install opton. + +cmake_minimum_required(VERSION 3.15) + +project(MySQL_CONCPP_Packages) + +# Note: version.cmake can be already included if this is used as part of +# the top-level project. + +if(NOT DEFINED CONCPP_VERSION) + include(${CMAKE_CURRENT_SOURCE_DIR}/../version.cmake) +endif() + +include(PackageSpecs.cmake) + + +# ====================================================================== +# RPM/DEB package specifications +# ====================================================================== + + +add_subdirectory(deb-in) + +# RPM stuff + +find_program(RPM rpm) + +if(RPM) + + # Get RPM version + + execute_process(COMMAND ${RPM} "--version" + RESULT_VARIABLE res + OUTPUT_VARIABLE RPM_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(res) + message(FATAL_ERROR "Could not determine RPM version (${RPM} --version command failed)") + endif() + + # Set RPM_VER_NUM to version number in XYYZZ format + + string(REGEX REPLACE "^RPM version *" "" RPM_VERSION ${RPM_VERSION}) + string(REPLACE "." ";" ver ${RPM_VERSION}) + list(GET ver 0 ver_major) + list(GET ver 1 ver_minor) + list(GET ver 2 ver_patch) + string(REGEX MATCH "..$" ver_minor "0${ver_minor}") + string(REGEX MATCH "..$" ver_patch "0${ver_patch}") + set(RPM_VER_NUM "${ver_major}${ver_minor}${ver_patch}") + + message(STATUS "Using RPM tools version: ${RPM_VERSION} (${RPM_VER_NUM})") + +endif() + + +# Gnerate RPM specification + +if(PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME) + set(rpm_spec "${CMAKE_CURRENT_BINARY_DIR}/SPECS/mysql-connector-c++.spec") + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/SOURCES) +else() + # Note: Preserve old behavior when included from the main CMakeLists.txt + set(rpm_spec "${CMAKE_CURRENT_BINARY_DIR}/mysql-connector-c++.spec") +endif() + +configure_file(mysql-connector-c++.spec.in "${rpm_spec}" @ONLY) + + +# +# If building this project stand-alone we stop here after generating RPM/DEB +# package specifications. Otherwise the rest of the project contains +# specifications for building packages using CPack (works with TGZ generator). +# + +if(PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME) + return() +endif() + + # ====================================================================== # Install manifest # ====================================================================== @@ -37,16 +119,20 @@ if(DEFINED INSTALL_MANIFEST) -add_custom_target(generate_manifest - ALL - COMMAND ${CMAKE_COMMAND} - -D MANIFEST_FILE=${INSTALL_MANIFEST} - -D BUILD_DIR=${PROJECT_BINARY_DIR} - -D CONFIG=$ - -P "${CMAKE_CURRENT_SOURCE_DIR}/install_manifest.cmake" - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMENT "Generating install manifest" -) + if(NOT MySQL_CONCPP_BINARY_DIR) + abort("Top-level binary dir unknown...") + endif() + + add_custom_target(generate_manifest + ALL + COMMAND ${CMAKE_COMMAND} + -D MANIFEST_FILE=${INSTALL_MANIFEST} + -D BUILD_DIR=${MySQL_CONCPP_BINARY_DIR} + -D CONFIG=$ + -P "${CMAKE_CURRENT_SOURCE_DIR}/install_manifest.cmake" + WORKING_DIRECTORY ${MySQL_CONCPP_BINARY_DIR} + COMMENT "Generating install manifest" + ) endif() @@ -81,13 +167,9 @@ foreach(file ${info_files}) endforeach() -set(CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/README${info_ext}") -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/${LIC_FILE}${info_ext}") -#set(CPACK_RESOURCE_FILE_INSTALL "...") # FIXME - # ====================================================================== -# Package specifications +# Package definitions # ====================================================================== if(APPLE AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -95,12 +177,12 @@ if(APPLE AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() -include(PackageSpecs.cmake) # Note: must be included before CPack +include(CPack) -CONFIGURE_FILE(mysql-connector-c++.spec.in ${CMAKE_CURRENT_BINARY_DIR}/mysql-connector-c++.spec @ONLY) -ADD_SUBDIRECTORY(deb-in) +set(CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/README${info_ext}") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/${LIC_FILE}${info_ext}") +#set(CPACK_RESOURCE_FILE_INSTALL "...") # FIXME -include(CPack) # Define install component groups. @@ -108,6 +190,7 @@ cpack_add_component_group(main) cpack_add_component_group(tests) cpack_add_component_group(debug) +cpack_add_component(DevCommon GROUP main) cpack_add_component(XDevAPIDev GROUP main) cpack_add_component(XDevAPIDll GROUP main) cpack_add_component(JDBCDev GROUP main) diff --git a/packaging/WiX/CMakeLists.txt b/packaging/WiX/CMakeLists.txt index 16e0b7ba6..ee7517a3d 100644 --- a/packaging/WiX/CMakeLists.txt +++ b/packaging/WiX/CMakeLists.txt @@ -514,33 +514,21 @@ function(make_wix_identifier STR VAR) set(${VAR} "${STR}.${out}" PARENT_SCOPE) endfunction() + # # Generate UUIDs # -find_program(UUIDGEN_COMMAND uuidgen) - -if(NOT UUIDGEN_COMMAND) - message(FATAL_ERROR "Could not find uuidgen executable") -endif() - function(generate_guid VAR) - EXECUTE_PROCESS( - COMMAND ${UUIDGEN_COMMAND} -c - RESULT_VARIABLE res - OUTPUT_VARIABLE guid - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - if(res) - message(FATAL_ERROR "Could not generate UUID: ${res}") - endif() - + string(RANDOM x) + string(UUID guid NAMESPACE "96122528-4F58-40F8-AB22-96F9853460F8" NAME "${x}" TYPE MD5 UPPER) + # message(STATUS "generated guid: ${guid}") set(${VAR} ${guid} PARENT_SCOPE) endfunction() + # # Convert path into a list # diff --git a/packaging/WiX/connector-cpp.wxs.in b/packaging/WiX/connector-cpp.wxs.in index fbb9fbaf4..9aa4ec2fc 100644 --- a/packaging/WiX/connector-cpp.wxs.in +++ b/packaging/WiX/connector-cpp.wxs.in @@ -115,8 +115,26 @@ - + + + + + + @@ -125,8 +143,10 @@ + + @@ -136,8 +156,10 @@ + + @@ -147,27 +169,6 @@ - - - - - - - - diff --git a/packaging/compat.patch b/packaging/compat.patch new file mode 100644 index 000000000..5b4befee7 --- /dev/null +++ b/packaging/compat.patch @@ -0,0 +1,62 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8b960402..37fac11d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -326,12 +326,6 @@ add_subdirectory(testing) + # CDK + # + +-add_subdirectory(cdk) +- +-foreach(T cdk cdk_foundation cdk_mysqlx cdk_proto_mysqlx cdk_parser) +- set_target_properties(${T} PROPERTIES FOLDER "CDK") +-endforeach() +- + # + # Project's public headers + # +@@ -344,7 +338,7 @@ INCLUDE_DIRECTORIES(include) + # Note: it is included before setting higher warning levels. + # + +-add_config_option(WITH_JDBC BOOL DEFAULT OFF ++add_config_option(WITH_JDBC BOOL DEFAULT ON + "Whether to build a variant of connector library which implements legacy JDBC API" + ) + +@@ -363,6 +357,7 @@ if(WITH_JDBC) + + endif() + ++return() + + # + # Set higher warning level for the main connector code. +diff --git a/doc/doxygen.cfg b/doc/doxygen.cfg +index 7bf32bcf..b3f2bee6 100644 +--- a/doc/doxygen.cfg ++++ b/doc/doxygen.cfg +@@ -66,7 +66,7 @@ PROJECT_NAME = "MySQL Connector/C++" + # could be handy for archiving the generated documentation or if some version + # control system is used. + +-PROJECT_NUMBER = 8.0.23 ++PROJECT_NUMBER = 9.3.0 + + # Using the PROJECT_BRIEF tag one can provide an optional one line description + # for a project that appears at the top of each page and should give viewer a +diff --git a/version.cmake b/version.cmake +index 53f8f540..7e589341 100644 +--- a/version.cmake ++++ b/version.cmake +@@ -34,8 +34,8 @@ set(COPYRIGHT_YEAR "2024" CACHE INTERNAL "version info") + # Connector/C++ version + # + +-set(CONCPP_VERSION_MAJOR 8 CACHE INTERNAL "version info") +-set(CONCPP_VERSION_MINOR 4 CACHE INTERNAL "version info") ++set(CONCPP_VERSION_MAJOR 9 CACHE INTERNAL "version info") ++set(CONCPP_VERSION_MINOR 3 CACHE INTERNAL "version info") + set(CONCPP_VERSION_MICRO 0 CACHE INTERNAL "version info") + # Level is "-alpha", "-beta", empty if GA + set(CONCPP_VERSION_LEVEL "" CACHE INTERNAL "version info") diff --git a/packaging/deb-in/CMakeLists.txt b/packaging/deb-in/CMakeLists.txt index b745f445a..b54dceecf 100644 --- a/packaging/deb-in/CMakeLists.txt +++ b/packaging/deb-in/CMakeLists.txt @@ -26,9 +26,18 @@ # along with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") - RETURN() -ENDIF() +if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") + message("Skipping DEB package configuration: not a Linux system") + return() +endif() + +find_program(LSB_RELEASE lsb_release) +if(NOT LSB_RELEASE) + message("Skipping DEB package configuration: lsb_release was not found") + return() +endif() + + IF (NOT DEFINED DEB_CODENAME) execute_process( COMMAND lsb_release -cs @@ -76,8 +85,29 @@ IF(DEB_CODENAME STREQUAL "sid") SET (DEB_PLATFORMRELEASE "debianunstable") ENDIF() +# Determine multiarch library install location + +execute_process( + COMMAND dpkg-architecture -q DEB_TARGET_MULTIARCH + OUTPUT_VARIABLE DEB_TARGET_MULTIARCH + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE res +) + +if(res) + message(FATAL_ERROR "Failed to execute dpkg-architecture") +endif() + +set(LIB_DIR "/usr/lib/${DEB_TARGET_MULTIARCH}") +message(STATUS "multiarch lib location: ${LIB_DIR}") + + #Follow MYSQLCLIENT_STATIC_LINKING option on packaging -SET (DEB_CMAKE_EXTRAS "${DEB_CMAKE_EXTRAS} -DMYSQLCLIENT_STATIC_LINKING=${MYSQLCLIENT_STATIC_LINKING}") +if(DEFINED MYSQLCLIENT_STATIC_LINKING) + set(DEB_CMAKE_EXTRAS + "${DEB_CMAKE_EXTRAS} -DMYSQLCLIENT_STATIC_LINKING=${MYSQLCLIENT_STATIC_LINKING}" + ) +endif() # Timestamp for use in debian/changelog IF (NOT DEFINED DEB_CHANGELOG_TIMESTAMP) @@ -96,19 +126,18 @@ IF (DEB_PRODUCT STREQUAL "commercial") SET (DEB_LICENSENAME "Commercial") SET (DEB_VERSION "+commercial-1") SET (DEB_SERVERPRODUCT "commercial") - SET (JDBC_RECOMMENDS_AND_SUGGESTS "Recommends: mysql-commercial-client-plugins") ELSE() SET (DEB_COPYRIGHT_UPSTREAMNAME "MySQL ${MYSQL_BASE_VERSION}") SET (DEB_PRODUCTNAME "") SET (DEB_LICENSENAME "GPL") SET (DEB_VERSION "-1") SET (DEB_SERVERPRODUCT "community") - SET (JDBC_RECOMMENDS_AND_SUGGESTS "Suggests: mysql-community-client-plugins") ENDIF() # All files are configured and copied to the debian/ directory, which is used # by debuild to make the packages -SET (DEB_ROOT ${CMAKE_SOURCE_DIR}/packaging/deb-in) + +SET (DEB_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/debian) foreach(CF changelog control rules compat copyright) @@ -143,4 +172,3 @@ endforeach() EXECUTE_PROCESS( COMMAND chmod +x ${CMAKE_BINARY_DIR}/debian/rules ) - diff --git a/packaging/deb-in/control.in b/packaging/deb-in/control.in index a932d025e..268f695e0 100644 --- a/packaging/deb-in/control.in +++ b/packaging/deb-in/control.in @@ -4,7 +4,7 @@ Section: database Priority: optional Standards-Version: 3.9.8 Homepage: https://dev.mysql.com/doc/connector-cpp/en/ -Build-Depends: cmake, debhelper (>= 10), libboost-dev, libmysqlclient-dev, libssl-dev +Build-Depends: cmake (>= 3.15.0), debhelper (>= 10), libboost-dev, libmysqlclient-dev, libssl-dev, chrpath Package: libmysqlcppconnx@ABI_VERSION_MAJOR@ Architecture: any @@ -22,7 +22,7 @@ Section: libs Pre-Depends: ${misc:Pre-Depends} Multi-Arch: same Depends: ${shlibs:Depends}, ${misc:Depends} -@JDBC_RECOMMENDS_AND_SUGGESTS@ +Suggests: libkrb5-3, libsasl2-2, libgssapi-krb5-2, libfido2-1, libssl3 Description: MySQL Driver for C++ which mimics the JDBC 4.0 API This MySQL Driver for C++ mimics the JDBC 4.0 API. diff --git a/packaging/deb-in/copyright.in b/packaging/deb-in/copyright.in index 3977c6f7a..b6ef630aa 100644 --- a/packaging/deb-in/copyright.in +++ b/packaging/deb-in/copyright.in @@ -4,7 +4,7 @@ Upstream-Contact: MySQL Release Engineering Source: https://dev.mysql.com/doc/connector-cpp/en/ Files: * -Copyright: 2008, 2024, Oracle and/or its affiliates. +Copyright: 2008, 2025, Oracle and/or its affiliates. License: @DEB_LICENSENAME@ This is a release of MySQL Connector/C++, the C++ interface for communicating with MySQL servers. diff --git a/packaging/deb-in/jdbc.install.in b/packaging/deb-in/jdbc.install.in index 83bea598a..7d1010beb 100644 --- a/packaging/deb-in/jdbc.install.in +++ b/packaging/deb-in/jdbc.install.in @@ -23,6 +23,9 @@ usr/lib/*/libmysqlcppconn.so.@JDBC_ABI_VERSION_MAJOR@* +# Plugins +usr/lib/*/mysql/libmysqlcppconn@JDBC_ABI_VERSION_MAJOR@/plugin/ + # Build info /usr/INFO_SRC /usr/share/doc/@PACKAGE_BASE_NAME@ /usr/INFO_BIN /usr/share/doc/@PACKAGE_BASE_NAME@ diff --git a/packaging/deb-in/rules.in b/packaging/deb-in/rules.in index 517ce13d5..1506767f6 100644 --- a/packaging/deb-in/rules.in +++ b/packaging/deb-in/rules.in @@ -30,65 +30,70 @@ export DH_VERBOSE=1 export CFLAGS= export CXXFLAGS= -override_dh_auto_configure: - @echo "RULES.$@" +export LIB_DIR = @LIB_DIR@ +export PLUGIN_DIR = $(LIB_DIR)/mysql/libmysqlcppconn@JDBC_ABI_VERSION_MAJOR@/plugin - mkdir release && cd release && \ - cmake .. \ +export CMAKE_OPTS= \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DINSTALL_LIB_DIR=lib/$(DEB_HOST_MULTIARCH) \ + -DINSTALL_LIB_DIR=.$(LIB_DIR) \ + -DINSTALL_INCLUDE_DIR=./usr/include \ + -DINSTALL_DOC_DIR=./usr \ -DWITH_JDBC=ON \ + -DMYSQLCLIENT_STATIC_LINKING=ON \ + -DDEFAULT_PLUGIN_DIR=$(PLUGIN_DIR) \ -DWITH_SSL=system \ + -DBUNDLE_DEPENDENCIES=ON \ @DEB_CMAKE_EXTRAS@ - mkdir static && cd static && \ - cmake .. \ - -DBUILD_STATIC=ON \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DINSTALL_LIB_DIR_STATIC=lib/$(DEB_HOST_MULTIARCH) \ - -DWITH_JDBC=ON \ - -DWITH_SSL=system \ - @DEB_CMAKE_EXTRAS@ +override_dh_auto_configure: + @echo "RULES.$@" + @echo "cmake options: $(CMAKE_OPTS)" + + rm -rf release && mkdir -p release + cmake -Brelease -S. $(CMAKE_OPTS) + + rm -rf static && mkdir -p static + cmake -Bstatic -S. $(CMAKE_OPTS) -DBUILD_STATIC=ON + + # touch $@ - touch $@ override_dh_auto_build: @echo "RULES.$@" - @DEB_RULES_DEBUG_MAKE@ - cd release && \ - $(MAKE) -j8 VERBOSE=1 - cd static && \ - $(MAKE) -j8 VERBOSE=1 - touch $@ + cmake --build release --verbose + cmake --build static --verbose + # touch $@ + +# Note: Disable testing override_dh_auto_test: - @echo "RULES.$@" - export CTEST_OUTPUT_ON_FAILURE=1 - cd release && \ - make test || true - touch $@ @DEB_RULES_STRIP@ override_dh_auto_install: - @echo "RULES.$@" + # complete install first - cd release && \ - $(MAKE) install DESTDIR=../debian/tmp - cd static && \ - $(MAKE) install DESTDIR=../debian/tmp + cmake --install static --prefix ./debian/tmp + cmake --install release --prefix ./debian/tmp + install README.txt debian/tmp/usr/README.txt install LICENSE.txt debian/tmp/usr/LICENSE.txt - install -d -m 0755 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/cmake - install -d -m 0755 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/mysql-concpp - install debian/tmp/usr/mysql-concpp-config.cmake debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/mysql-concpp/mysql-concpp-config.cmake - install debian/tmp/usr/mysql-concpp-config-version.cmake debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/mysql-concpp/mysql-concpp-config-version.cmake - rm debian/tmp/usr/mysql-concpp-config.cmake - rm debian/tmp/usr/mysql-concpp-config-version.cmake - touch $@ + + install -d -m 0755 debian/tmp/.$(LIB_DIR)/cmake + install -d -m 0755 debian/tmp/.$(LIB_DIR)/cmake/mysql-concpp + install debian/tmp/mysql-concpp-config.cmake debian/tmp/.$(LIB_DIR)/cmake/mysql-concpp/mysql-concpp-config.cmake + install debian/tmp/mysql-concpp-config-version.cmake debian/tmp/.$(LIB_DIR)/cmake/mysql-concpp/mysql-concpp-config-version.cmake + rm debian/tmp/mysql-concpp-config.cmake + rm debian/tmp/mysql-concpp-config-version.cmake + + install -d -m 0755 debian/tmp/.$(PLUGIN_DIR) + mv -v debian/tmp/.$(LIB_DIR)/plugin/* debian/tmp/.$(PLUGIN_DIR)/ + # Note: Remove custom RPATH in plugins -- we want them to use OS-wide dependencies + chrpath --delete debian/tmp/.$(PLUGIN_DIR)/* + rm -rf debian/tmp/.$(LIB_DIR)/plugin + rm -rf debian/tmp/.$(LIB_DIR)/private + # touch $@ override_dh_installinit: @echo "RULES.$@" @@ -96,3 +101,9 @@ override_dh_installinit: override_dh_install: dh_install --fail-missing + + +# Note: Exclude plugins from calculating package dependencies + +override_dh_shlibdeps: + dh_shlibdeps -Xmysql_native_password -Xauthentication_ diff --git a/packaging/deb-in/xdevapi.postinst.in b/packaging/deb-in/xdevapi.postinst.in index 202d5266b..75512836e 100644 --- a/packaging/deb-in/xdevapi.postinst.in +++ b/packaging/deb-in/xdevapi.postinst.in @@ -1,9 +1,7 @@ #! /bin/sh set -e -LIBDIR=/usr/lib/`dpkg-architecture -q DEB_TARGET_MULTIARCH` - -cd ${LIBDIR} +cd @LIB_DIR@ # Do nothing if old name is already present test -e libmysqlcppconn8.so.2 && return 0 diff --git a/packaging/mysql-connector-c++.spec.in b/packaging/mysql-connector-c++.spec.in index 7ba66f230..c2bffc469 100644 --- a/packaging/mysql-connector-c++.spec.in +++ b/packaging/mysql-connector-c++.spec.in @@ -26,26 +26,22 @@ # along with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +############################################### # Arguments that can be given to rpmbuild: # # mysql_dir Path to the MySQL installation, where to find the client lib # commercial If set, is a commercial build +# with_compat If set the -compat package is built +############################################### + %{?mysql_dir: %global mysql_opt -DMYSQL_DIR=%{mysql_dir}} %{!?commercial: %global license_type GPLv2} %{?commercial: %global license_type Commercial} %{?commercial: %global product_suffix -commercial} %{!?commercial: %global product_suffix %{nil}} -%{?el6:%global __strip /opt/rh/devtoolset-8/root/usr/bin/strip} -%{?el6:%global gcc_toolset devtoolset-8} -%ifarch aarch64 -%{?el7:%global gcc_toolset devtoolset-10} -%else -%{?el7:%global gcc_toolset devtoolset-11} -%endif +%global cmake_cmd cmake%{?el6:3}%{?el7:3} -%{?el8:%global gcc_toolset gcc-toolset-13} -%{?el9:%global gcc_toolset gcc-toolset-13} %if 0%{?suse_version} == 1315 %global dist .sles12 %endif @@ -54,58 +50,114 @@ %endif %global source_date_epoch_from_changelog 0 + +%global lib_base_name libmysqlcppconnx@ABI_VERSION_MAJOR@ +%global lib_base_name_jdbc libmysqlcppconn@JDBC_ABI_VERSION_MAJOR@ + +# TODO: use %rpmversion if available, note that it is in the format X.Y.Z.Y +# and the current logic requires numeric format XYYZZ. + +%global rpm_ver_num @RPM_VER_NUM@ + + +############################################### +# Package specifications +############################################### + +# Note: Double "obsoletes" entries have no effect for GPL packages but +# for commercial ones they ensure that a commercial package replaces GPL one. + Summary: MySQL database connector for C++ Name: mysql-connector-c++%{?product_suffix} Version: @CONCPP_VERSION@ Release: 1%{?commercial:.1}%{?dist} License: %{license_type} URL: https://dev.mysql.com/doc/connector-cpp/en/ -Source0: https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++%{?product_suffix}-%{version}-src.tar.gz # Note: This connector is compatible with the 8.x series. -Provides: libmysqlcppconn8.so.2()(%{?__isa_bits}bit) = %{version}-%{release} -BuildRequires: cmake%{?el6:3}%{?el7:3} -%if 0%{?fedora} || 0%{?suse_version} +Provides: libmysqlcppconn8.so.2()(%{?__isa_bits}bit) = %{version}-%{release} +Obsoletes: mysql-connector-c++%{?product_suffix} < %{version}-%{release} +Obsoletes: mysql-connector-c++ < %{version}-%{release} + +Source0: https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++%{?product_suffix}-%{version}-src.tar.gz +%if 0%{?with_compat} +Source1: https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++%{?product_suffix}-8.4.0-src.tar.gz +%endif + +BuildRequires: %{cmake_cmd} >= 3.15.0 BuildRequires: gcc BuildRequires: gcc-c++ -%endif -%{?gcc_toolset:BuildRequires: %{gcc_toolset}-gcc} -%{?gcc_toolset:BuildRequires: %{gcc_toolset}-gcc-c++} -%{!?mysql_dir:BuildRequires: mysql-devel} BuildRequires: openssl-devel -%{?commercial:Obsoletes: mysql-connector-c++ < %{version}-%{release}} + %description A C++ interface for communicating with MySQL servers. + %package jdbc Summary: MySQL Driver for C++ which mimics the JDBC 4.0 API -%{?commercial:Obsoletes: mysql-connector-c++-jdbc < %{version}-%{release}} -Obsoletes: libmysqlcppconn9 < %{version}-%{release} -Obsoletes: libmysqlcppconn-devel < %{version}-%{release} -Provides: libmysqlcppconn9 = %{version}-%{release} -Provides: libmysqlcppconn-devel = %{version}-%{release} +Provides: %{lib_base_name_jdbc} = %{version}-%{release} +# Note: Field `Suggests` is recognized by RPM 4.13 and later +%if %{rpm_ver_num} >= 41300 +Suggests: krb5-libs, cyrus-sasl-lib, libfido2 +%endif +Obsoletes: %{lib_base_name_jdbc} < %{version}-%{release} +Obsoletes: mysql-connector-c++%{?product_suffix}-jdbc < %{version}-%{release} +Obsoletes: mysql-connector-c++-jdbc < %{version}-%{release} %description jdbc This MySQL Driver for C++ mimics the JDBC 4.0 API. + +%if 0%{?with_compat} +%package compat +Summary: MySQL Connector/C++ -- backward compatibility libraries +Provides: libmysqlcppconn9 = %{version}-%{release} +Obsoletes: libmysqlcppconn9 < %{version}-%{release} +Obsoletes: mysql-connector-c++%{?product_suffix}-compat < %{version}-%{release} +Obsoletes: mysql-connector-c++-compat < %{version}-%{release} +Obsoletes: mysql-connector-c++%{?product_suffix}-jdbc < 9.0.0 +Obsoletes: mysql-connector-c++-jdbc < 9.0.0 +%description compat +MySQL Connector/C++ -- backward compatibility libraries +%endif + %package devel Summary: Development header files and libraries for MySQL C++ client applications -%if 0%{?commercial} -Requires: mysql-connector-c++-commercial = %{version}-%{release} -Requires: mysql-connector-c++-commercial-jdbc = %{version}-%{release} +Requires: mysql-connector-c++%{?product_suffix} = %{version}-%{release} +Requires: mysql-connector-c++%{?product_suffix}-jdbc = %{version}-%{release} +Obsoletes: mysql-connector-c++%{?product_suffix}-devel < %{version}-%{release} Obsoletes: mysql-connector-c++-devel < %{version}-%{release} -%else -Requires: mysql-connector-c++ = %{version}-%{release} -Requires: mysql-connector-c++-jdbc = %{version}-%{release} -%endif %description devel This package contains the development header files and libraries necessary to develop MySQL client applications in C++. + +############################################### +# Build instructions +############################################### + %prep -%setup -q -n mysql-connector-c++%{product_suffix}-%{version}-src +%setup -q %{?with_compat:-b1} -n %{name}-%{version}-src + +SRC=`pwd` +SRC1=%{name}-8.4.0-src + +cd ${RPM_BUILD_DIR} + +%if 0%{?with_compat} + +# Patch compatiblity sources: +git apply --directory ${SRC1} ${SRC}/packaging/compat.patch + +%endif + %build -%{?gcc_toolset:source /opt/rh/%{gcc_toolset}/enable} +SRC=`pwd` +SRC1=%{name}-8.4.0-src + +cd ${RPM_BUILD_DIR} + +%global plugin_dir %{_libdir}/mysql/%{lib_base_name_jdbc}/plugin %if 0%{?with_tests:1} && 0%{?with_gtest:1} %global __cmake_test_opts -DWITH_TESTS=1 -DWITH_GTEST=%{with_gtest} @@ -113,69 +165,128 @@ to develop MySQL client applications in C++. %global __cmake_test_opts %{nil} %endif %global __cmake_explicit_opts -DCMAKE_INSTALL_PREFIX="%_prefix" -DCMAKE_C_FLAGS:STRING="%optflags" -DCMAKE_CXX_FLAGS:STRING="%optflags" -%global __cmake_common_opts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir}/mysql-cppconn -DWITH_JDBC=ON -DMYSQLCLIENT_STATIC_LINKING=1 -DWITH_SSL=system %{__cmake_test_opts} %{?mysql_opt} -DDEBUG_PREFIX_MAP=OFF -%global __cmake_cmd cmake%{?el6:3}%{?el7:3} %{__cmake_common_opts} %{__cmake_explicit_opts} .. -mkdir build-dynamic && pushd build-dynamic -pwd -%__cmake_cmd -make %{?_smp_mflags} VERBOSE=1 -popd -mkdir build-static && pushd build-static -%__cmake_cmd -DBUILD_STATIC=ON -make %{?_smp_mflags} VERBOSE=1 -popd + +# Note: use relative paths for CMAKE_INSTALL_XXX options + +%global __cmake_common_opts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_LIBDIR=.%{_libdir} -DCMAKE_INSTALL_INCLUDEDIR=.%{_includedir}/mysql-cppconn -DWITH_SSL=system -DDEFAULT_PLUGIN_DIR=%{plugin_dir} -DWITH_JDBC=1 -DMYSQLCLIENT_STATIC_LINKING=1 -DBUNDLE_DEPENDENCIES=1 %{?mysql_opt} %{__cmake_test_opts} -DDEBUG_PREFIX_MAP=OFF +%global __cmake_config %{cmake_cmd} %{__cmake_common_opts} %{__cmake_explicit_opts} + +%if 0%{?with_compat} +rm -rf build-compat && mkdir build-compat +%{__cmake_config} -S ${SRC1} -B build-compat +%{cmake_cmd} --build build-compat --verbose +%endif + +rm -rf build-static && mkdir build-static +%{__cmake_config} -S ${SRC} -B build-static -DBUILD_STATIC=1 +%{cmake_cmd} --build build-static --verbose + +rm -rf build-dynamic && mkdir build-dynamic +%{__cmake_config} -S ${SRC} -B build-dynamic -DBUILD_STATIC=0 +%{cmake_cmd} --build build-dynamic --verbose + %install -%{?gcc_toolset:source /opt/rh/%{gcc_toolset}/enable} +cd ${RPM_BUILD_DIR} -pushd build-dynamic -make DESTDIR=%{buildroot} install -popd -pushd build-static -make DESTDIR=%{buildroot} install -popd +# Note: order of installations is important! + +%if 0%{?with_compat} +%{cmake_cmd} --install build-compat --prefix %{buildroot} +%endif +%{cmake_cmd} --install build-static --prefix %{buildroot} +%{cmake_cmd} --install build-dynamic --prefix %{buildroot} # Remove unwanted files -rm %{buildroot}/usr/{INFO_SRC,INFO_BIN} +rm %{buildroot}/{INFO_SRC,INFO_BIN} # Add compatibility link cd %{buildroot}%{_libdir} && ln -s libmysqlcppconnx.so.2 libmysqlcppconn8.so.2 # Add CMake files to the right location, and remove the incorrect ones mkdir -p %{buildroot}%{_libdir}/cmake/mysql-concpp/ -install -D -m 0644 %{buildroot}/usr/*.cmake %{buildroot}%{_libdir}/cmake/mysql-concpp/ -rm %{buildroot}/usr/*.cmake +install -D -m 0644 %{buildroot}/*.cmake %{buildroot}%{_libdir}/cmake/mysql-concpp/ +rm %{buildroot}/*.cmake + +# Bundled plugins +mkdir -p %{buildroot}%{plugin_dir} +mv -v %{buildroot}%{_libdir}/plugin/* %{buildroot}%{plugin_dir} +rm -rf %{buildroot}%{_libdir}/{plugin,private} + +%pretrans devel +test -L /usr/include/mysql-cppconn && rm -f /usr/include/mysql-cppconn || true -%post -p /sbin/ldconfig +%post +/sbin/ldconfig -%postun -p /sbin/ldconfig +%postun +/sbin/ldconfig -%post jdbc -p /sbin/ldconfig +%post jdbc +/sbin/ldconfig -%postun jdbc -p /sbin/ldconfig +%postun jdbc +/sbin/ldconfig + + +############################################### +# Package contents +# +# TODO: use %license for LICENSE.txt? But then it gets installed into +# /usr/share/licenses/ instead of /usr/share/doc/ +############################################### %files -%doc README.txt LICENSE.txt build-dynamic/INFO_SRC build-dynamic/INFO_BIN +%doc LICENSE.txt +# Note: doc files are specified relative to the main source directory +%doc README.txt ../build-dynamic/INFO_SRC ../build-dynamic/INFO_BIN %{_libdir}/libmysqlcppconnx.so.@ABI_VERSION_MAJOR@* %{_libdir}/libmysqlcppconn8.so.2 %files jdbc -%doc README.txt LICENSE.txt build-dynamic/INFO_SRC build-dynamic/INFO_BIN +%doc LICENSE.txt +%doc README.txt ../build-dynamic/INFO_SRC ../build-dynamic/INFO_BIN %{_libdir}/libmysqlcppconn.so.@JDBC_ABI_VERSION_MAJOR@* +%{plugin_dir} + +%if 0%{?with_compat} +%files compat +%doc LICENSE.txt +%doc README.txt +%{_libdir}/libmysqlcppconn.so.9* +%endif %files devel -%doc README.txt LICENSE.txt build-dynamic/INFO_SRC build-dynamic/INFO_BIN +%doc LICENSE.txt +%doc README.txt ../build-dynamic/INFO_SRC ../build-dynamic/INFO_BIN %{_libdir}/libmysqlcppconn.so %{_libdir}/libmysqlcppconn-static.a %{_libdir}/libmysqlcppconnx.so %{_libdir}/libmysqlcppconnx-static.a %{_libdir}/cmake/mysql-concpp/mysql-concpp-config-version.cmake %{_libdir}/cmake/mysql-concpp/mysql-concpp-config.cmake +%dir %{_includedir}/mysql-cppconn %{_includedir}/mysql-cppconn + +############################################### +# Changelog +############################################### + %changelog -* Mon May 12 2024 Gipson Pulla - 9.0.0-1 + +* Thu Sep 12 2024 Rafal Somla - 9.1.0-1 +- Add definitions for -compat package (WL#16462) + +* Fri Aug 09 2024 Rafal Somla - 9.1.0-1 +- Bundle authentication plugins in the -jdbc package (WL#16458) + +* Thu Jul 11 2024 Rafal Somla - 9.1.0-1 +- Fixed provides/obsoletes information +- Updates to configure/build/install logic + +* Sun May 12 2024 Gipson Pulla - 9.0.0-1 - Bumped the version to 9.0.0 series. * Fri Nov 03 2023 Sreedhar Sreedhargadda - 8.2.0-1 diff --git a/testapp/CMakeLists.txt b/testapp/CMakeLists.txt index 6eb221018..2942c7693 100644 --- a/testapp/CMakeLists.txt +++ b/testapp/CMakeLists.txt @@ -60,12 +60,42 @@ PROJECT(MySQL_CONCPP_TEST) # ======================================================================== # Dependencies +function(find_openssl where) + + if(where STREQUAL "bundled") + if(mysql-concpp_DIR) + set(WITH_SSL "${mysql-concpp_DIR}") + else() + message(WARNING + "A request to use bundled OpenSSL libraries was made but" + " Connector/C++ install location was not explicitly given" + " via mysql-concpp_DIR or WITH_CONCPP setting." + ) + return() + endif() + endif() -if(WITH_SSL) + unset(openssl CACHE) + find_library(openssl + NAMES ssl + PATHS "${WITH_SSL}" + PATH_SUFFIXES "" "lib" "lib64" + NO_DEFAULT_PATH + # NO_CACHE # Note: requires cmake 3.21 + ) + + if(NOT openssl) + message(WARNING + "OpenSSL libraries not found at specified location: ${WITH_SSL}" + ) + return() + endif() + get_filename_component(WITH_SSL "${openssl}" DIRECTORY CACHE) message(STATUS "Using custom OpenSSL libraries at: ${WITH_SSL}") add_library(openssl INTERFACE) + # TODO: Is this path correct also on non-Win platforms? target_link_directories(openssl INTERFACE "${WITH_SSL}") if(WIN32) @@ -77,12 +107,16 @@ if(WITH_SSL) target_link_libraries(openssl INTERFACE ${ssl_libs}) add_library(mysql::openssl ALIAS openssl) -endif() +endfunction() + if(NOT DEFINED mysql-concpp_DIR AND DEFINED WITH_CONCPP) set(mysql-concpp_DIR "${WITH_CONCPP}") endif() +if(WITH_SSL) + find_openssl("${WITH_SSL}") +endif() find_package(mysql-concpp REQUIRED ${REQUIRED_COMPONENTS}) diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 73c901b69..b8d76e616 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -49,25 +49,13 @@ endif() add_library(test_harness STATIC test_harness.cc) set_target_properties(test_harness PROPERTIES FOLDER "Tests") +target_link_libraries(test_harness PUBLIC gtest) + add_test_libraries(test_harness connector) add_test_includes(${CMAKE_CURRENT_SOURCE_DIR}) -if(MSVC) - - set(TEST_COMPILE_FLAGS - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - -D_CRT_SECURE_NO_WARNINGS - -D_SCL_SECURE_NO_WARNINGS - ) - - target_compile_definitions(test_harness PUBLIC - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) - - target_compile_options(test_harness PUBLIC /std:c++14) - -else() +if(NOT MSVC) set(TEST_COMPILE_FLAGS -Wno-sign-compare diff --git a/testing/find_package/CMakeLists.txt b/testing/find_package/CMakeLists.txt index e92ea2127..7135f04d3 100644 --- a/testing/find_package/CMakeLists.txt +++ b/testing/find_package/CMakeLists.txt @@ -124,11 +124,12 @@ macro(add_version_tests) if(WITH_CONCPP) - find_file(INFO_SRC + unset(INFO_SRC CACHE) + find_file(INFO_SRC NAME INFO_SRC PATHS ${WITH_CONCPP} NO_DEFAULT_PATH - NO_CACHE + #NO_CACHE # Note: requires cmake 3.21 ) else() @@ -210,7 +211,7 @@ macro(add_version_tests) # Prepare options for run_test.cmake - set(test_opts + set(test_opts "-DVERSION=${VERSION_${A}}" "-DWITH_DEBUG=${WITH_DEBUG}" ) @@ -256,12 +257,13 @@ macro(add_tests) if(WITH_SSL) + unset(openssl_lib CACHE) find_library(openssl_lib NAMES ssl libssl PATHS ${WITH_SSL} PATH_SUFFIXES lib NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE ) endif() @@ -287,8 +289,8 @@ macro(add_tests) # Note: On Windows scenarios which build in Debug mode with static # connector library are added only if debug package is available. - if(WIN32 - AND A STREQUAL "static" + if(WIN32 + AND A STREQUAL "static" AND B STREQUAL "Debug" AND NOT WITH_DEBUG ) @@ -332,7 +334,7 @@ macro(add_tests) # # They are implemented by run_test.cmake -- see there. - add_test("config_${name_suffix}" + add_test("config_${name_suffix}" ${CMAKE_COMMAND} "-DCDK_DIR=${CDK_DIR}" "-DCONCPP_SRC_DIR=${HOME_DIR}/../.." @@ -347,7 +349,7 @@ macro(add_tests) FIXTURES_SETUP "${name_suffix}_configured" ) - add_test("build_${name_suffix}" + add_test("build_${name_suffix}" ${CMAKE_COMMAND} "-DCDK_DIR=${CDK_DIR}" "-DCONCPP_SRC_DIR=${HOME_DIR}/../.." @@ -365,7 +367,7 @@ macro(add_tests) message(STATUS "# added test: build_${name_suffix}") - add_test("check_${name_suffix}" + add_test("check_${name_suffix}" ${CMAKE_COMMAND} "-DCDK_DIR=${CDK_DIR}" "-DCONCPP_SRC_DIR=${HOME_DIR}/../.." diff --git a/testing/find_package/run_test.cmake b/testing/find_package/run_test.cmake index d4a2e0550..f3ca4b7bf 100644 --- a/testing/find_package/run_test.cmake +++ b/testing/find_package/run_test.cmake @@ -182,11 +182,11 @@ function(action_check) foreach(exec devapi_test xapi_test jdbc_test) set(exec_path) - find_program(exec_path + find_program(exec_path NAMES ${exec} PATHS "config_test/${out_dir}" NO_DEFAULT_PATH - NO_CACHE + # NO_CACHE # note: requires cmake 3.21 ) if(NOT EXISTS "${exec_path}") diff --git a/testing/tests.cmake b/testing/tests.cmake index 5258ce48a..edd8b7e3e 100644 --- a/testing/tests.cmake +++ b/testing/tests.cmake @@ -191,7 +191,12 @@ if(NOT DEFINED ABI_CHECK AND MSVC AND MAINTAINER_MODE) set(ABI_CHECK 1) endif() -if(ABI_CHECK) +# Note: The machinery we use to perform ABI checks works only +# with the original MSVC compiler which can produce required +# export map file, not with clang-cl (for which MSVC is also +# defined) + +if(ABI_CHECK AND MSVC AND NOT CLANG) add_abi_check() endif() diff --git a/version.cmake b/version.cmake index 4cdffa758..11a196aad 100644 --- a/version.cmake +++ b/version.cmake @@ -28,14 +28,14 @@ # Note: To be used in copyright notes of generated files -set(COPYRIGHT_YEAR "2024" CACHE INTERNAL "version info") +set(COPYRIGHT_YEAR "2025" CACHE INTERNAL "version info") # # Connector/C++ version # set(CONCPP_VERSION_MAJOR 9 CACHE INTERNAL "version info") -set(CONCPP_VERSION_MINOR 0 CACHE INTERNAL "version info") +set(CONCPP_VERSION_MINOR 3 CACHE INTERNAL "version info") set(CONCPP_VERSION_MICRO 0 CACHE INTERNAL "version info") # Level is "-alpha", "-beta", empty if GA set(CONCPP_VERSION_LEVEL "" CACHE INTERNAL "version info") diff --git a/xapi/tests/CMakeLists.txt b/xapi/tests/CMakeLists.txt index 1beda2812..5b1220455 100644 --- a/xapi/tests/CMakeLists.txt +++ b/xapi/tests/CMakeLists.txt @@ -36,12 +36,6 @@ set_property( PROPERTY COMPILE_DEFINITIONS "" ) -IF(WIN32) - add_definitions( - -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - ) -ENDIF() - if(BUILD_STATIC) add_definitions(-DSTATIC_CONCPP) endif() diff --git a/xapi/tests/xapi-t.cc b/xapi/tests/xapi-t.cc index 11d22dcb4..95b2ec206 100644 --- a/xapi/tests/xapi-t.cc +++ b/xapi/tests/xapi-t.cc @@ -67,13 +67,15 @@ void check_compress(mysqlx_session_t *sess) buf_len = 65536; memset(buf, 0, buf_len); - EXPECT_NE(nullptr, row = mysqlx_row_fetch_one(res)); + row = mysqlx_row_fetch_one(res); + EXPECT_FALSE(nullptr == row); EXPECT_EQ(RESULT_OK, mysqlx_get_bytes(row, 0, 0, buf, &buf_len)); test_row("Test ", buf); buf_len = 65536; memset(buf, 0, buf_len); - EXPECT_NE(nullptr, row = mysqlx_row_fetch_one(res)); + row = mysqlx_row_fetch_one(res); + EXPECT_FALSE(nullptr == row); EXPECT_EQ(RESULT_OK, mysqlx_get_bytes(row, 0, 0, buf, &buf_len)); test_row("0123 ", buf); @@ -2552,7 +2554,6 @@ TEST_F(xapi, dns_srv) //Specifying a port number with DNS SRV lookup is not allowed. { - EXPECT_EQ(nullptr, mysqlx_get_client_from_url("mysqlx+srv://root@_mysqlx._tcp.localhost:33060", nullptr, &error)); std::cout << "Expected Error: " << mysqlx_error_message(error) << std::endl; @@ -2949,7 +2950,7 @@ TEST_F(xapi, tls_ver_ciphers) error = NULL; sess = mysqlx_get_session_from_options(opt, &error); mysqlx_free(error); - EXPECT_NE(NULL, sess); + EXPECT_FALSE(NULL == sess); mysqlx_session_close(sess); diff --git a/xapi/tests/xapi_crud-t.cc b/xapi/tests/xapi_crud-t.cc index 211ab8e50..82809858f 100644 --- a/xapi/tests/xapi_crud-t.cc +++ b/xapi/tests/xapi_crud-t.cc @@ -754,7 +754,7 @@ TEST_F(xapi, basic) const char *col_schema = mysqlx_column_get_schema(res, i); const char *col_cat = mysqlx_column_get_catalog(res, i); - EXPECT_NE(nullptr, col_cat); + EXPECT_FALSE(nullptr == col_cat); printf("\n Column # %d", i + 1); printf("\n * name: %s, orig name: %s, table: %s, orig table: %s, schema: %s, catalog: %s",