Use nullptr in C++ code (solves #4348) (#5043)

* chore(CppParser): 0, NULL --> nullptr

* chore(Crypto): 0, NULL --> nullptr

* chore(DNSSD): 0, NULL --> nullptr

* chore(Encodings): 0, NULL --> nullptr

* chore(CppUnit): Correct indentation.

* chore(Foundation): 0, NULL --> nullptr

* chore(CMake): Always warn about wrong nullptr usage when compiling with GCC or CLang

* chore(Net): 0, NULL --> nullptr

* chore(Foundation): 0, NULL --> nullptr

* chore(Data): 0, NULL --> nullptr

* chore(macOS): 0, NULL --> nullptr

* chore(XML): 0, NULL --> nullptr

* chore(Zip): 0, NULL --> nullptr

* chore(Util): 0, NULL --> nullptr

* chore(Net/NetSSL): 0, NULL --> nullptr

* chore(Bonjour): 0, NULL --> nullptr

* chore(MongoDB, Redis): 0, NULL --> nullptr

* chore(Poco): 0, NULL --> nullptr

* chore(Win32): 0, NULL --> nullptr

* chore(CMake): Only warn about nullptr when verbose warnings are enabled.

* Potential fix for code scanning alert no. 1634: Guarded Free

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* chore(Net): Fix warning reported by gitlab.

* chore(gitlab CI): attempt to clean to gain disk space on the runner.

* chore(gitlab CI): Run build with  --parallel 4, correct docker cleanup.

---------

Co-authored-by: Aleksandar Fabijanic <aleks-f@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
Matej Kenda
2025-10-30 15:20:53 +01:00
committed by GitHub
parent 3e10fb2b0f
commit 8a4a2955d5
480 changed files with 10963 additions and 10932 deletions

View File

@@ -35,7 +35,7 @@ jobs:
export CXX=clang++-20 export CXX=clang++-20
cmake -S . -B build -G Ninja -DPOCO_BUILD_MODULES=ON cmake -S . -B build -G Ninja -DPOCO_BUILD_MODULES=ON
- name: Build - name: Build
run: cmake --build build run: cmake --build build --parallel 4
android-arm64-v8a-ndk-latest-cmake: android-arm64-v8a-ndk-latest-cmake:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
@@ -82,7 +82,7 @@ jobs:
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_MINIMAL_BUILD=TRUE cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_MINIMAL_BUILD=TRUE
-DENABLE_NET=ON -DENABLE_JSON=ON -DENABLE_XML=ON -DENABLE_ZIP=ON -DENABLE_NET=ON -DENABLE_JSON=ON -DENABLE_XML=ON -DENABLE_ZIP=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
linux-gcc-cmake-cross-armhf: linux-gcc-cmake-cross-armhf:
# Converted from a make job, what is essentially different from the above? # Converted from a make job, what is essentially different from the above?
@@ -100,14 +100,14 @@ jobs:
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_MINIMAL_BUILD=TRUE cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_MINIMAL_BUILD=TRUE
-DENABLE_NET=ON -DENABLE_JSON=ON -DENABLE_XML=ON -DENABLE_ZIP=ON -DENABLE_NET=ON -DENABLE_JSON=ON -DENABLE_XML=ON -DENABLE_ZIP=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
linux-gcc-cmake: linux-gcc-cmake:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: sudo apt -y update && sudo apt -y install cmake ninja-build libssl-dev unixodbc-dev libmysqlclient-dev redis-server - run: sudo apt -y update && sudo apt -y install cmake ninja-build libssl-dev unixodbc-dev libmysqlclient-dev redis-server
- run: cmake -S. -Bcmake-build -GNinja -DENABLE_PDF=OFF -DENABLE_TESTS=ON && cmake --build cmake-build --target all - run: cmake -S. -Bcmake-build -GNinja -DENABLE_PDF=OFF -DENABLE_TESTS=ON && cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -126,7 +126,7 @@ jobs:
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DCMAKE_CXX_VISIBILITY_PRESET=hidden cmake -S. -Bcmake-build -GNinja -DCMAKE_CXX_VISIBILITY_PRESET=hidden
-DENABLE_PDF=ON -DENABLE_TESTS=ON -DENABLE_DATA_MYSQL=ON -DENABLE_DATA_ODBC=ON -DENABLE_PDF=ON -DENABLE_TESTS=ON -DENABLE_DATA_MYSQL=ON -DENABLE_DATA_ODBC=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -147,7 +147,7 @@ jobs:
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_UNBUNDLED=ON cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_UNBUNDLED=ON
-DENABLE_DATA_MYSQL=ON -DENABLE_PDF=ON -DENABLE_XML=ON -DENABLE_DATA_MYSQL=ON -DENABLE_PDF=ON -DENABLE_XML=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -168,7 +168,7 @@ jobs:
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_UNBUNDLED=ON -DBUILD_SHARED_LIBS=OFF cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_UNBUNDLED=ON -DBUILD_SHARED_LIBS=OFF
-DENABLE_DATA_MYSQL=ON -DENABLE_PDF=ON -DENABLE_XML=ON -DENABLE_DATA_MYSQL=ON -DENABLE_PDF=ON -DENABLE_XML=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -186,7 +186,7 @@ jobs:
- run: sudo apt -y update && sudo apt -y install libssl-dev - run: sudo apt -y update && sudo apt -y install libssl-dev
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_TRACE=ON -DENABLE_TESTS=ON cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_TRACE=ON -DENABLE_TESTS=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -219,7 +219,7 @@ jobs:
-DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON -DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON
-DENABLE_REDIS=OFF -DENABLE_MONGODB=OFF -DENABLE_REDIS=OFF -DENABLE_MONGODB=OFF
-DENABLE_DATA=OFF -DENABLE_DATA_ODBC=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA=OFF -DENABLE_DATA_ODBC=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_DATA_MYSQL=OFF
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -252,7 +252,7 @@ jobs:
-DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON -DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON
-DENABLE_REDIS=OFF -DENABLE_MONGODB=OFF -DENABLE_REDIS=OFF -DENABLE_MONGODB=OFF
-DENABLE_DATA=OFF -DENABLE_DATA_ODBC=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA=OFF -DENABLE_DATA_ODBC=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_DATA_MYSQL=OFF
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -279,7 +279,7 @@ jobs:
-DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON -DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON
-DENABLE_REDIS=OFF -DENABLE_MONGODB=OFF -DENABLE_REDIS=OFF -DENABLE_MONGODB=OFF
-DENABLE_DATA=OFF -DENABLE_DATA_ODBC=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA=OFF -DENABLE_DATA_ODBC=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_DATA_MYSQL=OFF
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -314,7 +314,7 @@ jobs:
-DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON -DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON
-DENABLE_REDIS=OFF -DENABLE_MONGODB=OFF -DENABLE_REDIS=OFF -DENABLE_MONGODB=OFF
-DENABLE_DATA=OFF -DENABLE_DATA_ODBC=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA=OFF -DENABLE_DATA_ODBC=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_DATA_MYSQL=OFF
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -346,7 +346,7 @@ jobs:
- run: >- - run: >-
emcmake cmake -H. -B cmake-build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DENABLE_ACTIVERECORD_COMPILER=OFF emcmake cmake -H. -B cmake-build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DENABLE_ACTIVERECORD_COMPILER=OFF
-DENABLE_PAGECOMPILER=OFF -DENABLE_PAGECOMPILER_FILE2PAGE=off -DENABLE_PAGECOMPILER=OFF -DENABLE_PAGECOMPILER_FILE2PAGE=off
- run: emmake cmake --build cmake-build --target all -j6 - run: emmake cmake --build cmake-build --target all --parallel 4
# TODO: How to run unit tests in emscripten? # TODO: How to run unit tests in emscripten?
# - uses: ./.github/actions/retry-action # - uses: ./.github/actions/retry-action
# with: # with:
@@ -696,7 +696,7 @@ jobs:
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev mysql-client - run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev mysql-client
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_DATA_MYSQL=ON -DENABLE_TESTS=ON cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_DATA_MYSQL=ON -DENABLE_TESTS=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -723,7 +723,7 @@ jobs:
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev odbc-postgresql - run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev odbc-postgresql
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_DATA_POSTGRESQL=ON -DENABLE_TESTS=ON cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_DATA_POSTGRESQL=ON -DENABLE_TESTS=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -746,7 +746,7 @@ jobs:
sudo apt-get -y install redis sudo apt-get -y install redis
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_REDIS=ON -DENABLE_TESTS=ON cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_REDIS=ON -DENABLE_TESTS=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -765,7 +765,7 @@ jobs:
- run: sudo apt -y update && sudo apt -y install libssl-dev - run: sudo apt -y update && sudo apt -y install libssl-dev
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_MONGODB=ON -DENABLE_TESTS=ON cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_MONGODB=ON -DENABLE_TESTS=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
@@ -817,6 +817,17 @@ jobs:
# wget https://dev.mysql.com/get/Downloads/Connector-ODBC/8.2/mysql-connector-odbc_8.2.0-1ubuntu22.04_amd64.deb # wget https://dev.mysql.com/get/Downloads/Connector-ODBC/8.2/mysql-connector-odbc_8.2.0-1ubuntu22.04_amd64.deb
# wget https://dev.mysql.com/get/Downloads/MySQL-8.2/mysql-community-client-plugins_8.2.0-1ubuntu22.04_amd64.deb # wget https://dev.mysql.com/get/Downloads/MySQL-8.2/mysql-community-client-plugins_8.2.0-1ubuntu22.04_amd64.deb
# sudo dpkg -i mysql-community-client-plugins_8.2.0-1ubuntu22.04_amd64.deb mysql-connector-odbc_8.2.0-1ubuntu22.04_amd64.deb # sudo dpkg -i mysql-community-client-plugins_8.2.0-1ubuntu22.04_amd64.deb mysql-connector-odbc_8.2.0-1ubuntu22.04_amd64.deb
- name: Free disk space
run: |
sudo df
sudo apt autopurge
sudo apt clean
sudo du -s /usr/local/lib/*
sudo du -s /opt/*
sudo rm -rf /usr/share/dotnet
sudo docker system prune -a --force
sudo df
- name: Setup Oracle ODBC connector - name: Setup Oracle ODBC connector
run: | run: |
wget https://www.devart.com/odbc/oracle/devartodbcoracle_amd64.deb wget https://www.devart.com/odbc/oracle/devartodbcoracle_amd64.deb
@@ -833,7 +844,7 @@ jobs:
- run: ls -l /etc/apt/sources.list.d/ - run: ls -l /etc/apt/sources.list.d/
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_DATA_ODBC=ON -DENABLE_TESTS=ON cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_DATA_ODBC=ON -DENABLE_TESTS=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:
timeout_minutes: 90 timeout_minutes: 90
@@ -853,7 +864,7 @@ jobs:
- run: >- - run: >-
cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_DATA_SQLITE=ON cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_DATA_SQLITE=ON
-DPOCO_DATA_NO_SQL_PARSER=ON -DENABLE_TESTS=ON -DPOCO_DATA_NO_SQL_PARSER=ON -DENABLE_TESTS=ON
- run: cmake --build cmake-build --target all - run: cmake --build cmake-build --target all --parallel 4
- uses: ./.github/actions/retry-action - uses: ./.github/actions/retry-action
with: with:

View File

@@ -164,7 +164,7 @@ void ApacheConnector::log(const char* file, int line, int level, int status, con
// ap_log_error() has undergone significant changes in Apache 2.4. // ap_log_error() has undergone significant changes in Apache 2.4.
// Validate Apache version for using a proper ap_log_error() version. // Validate Apache version for using a proper ap_log_error() version.
#if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4 #if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4
ap_log_error(file, line, level, 0, NULL, "%s", text); ap_log_error(file, line, level, 0, nullptr, "%s", text);
#else #else
ap_log_error(file, line, level, 0, 0, 0, text); ap_log_error(file, line, level, 0, 0, 0, text);
#endif #endif
@@ -245,7 +245,7 @@ extern "C" int ApacheConnector_handler(request_rec *r)
extern "C" void ApacheConnector_register_hooks(apr_pool_t *p) extern "C" void ApacheConnector_register_hooks(apr_pool_t *p)
{ {
ap_hook_handler(ApacheConnector_handler, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_handler(ApacheConnector_handler, nullptr, nullptr, APR_HOOK_MIDDLE);
} }
@@ -290,26 +290,26 @@ extern "C" const command_rec ApacheConnector_cmds[] =
AP_INIT_RAW_ARGS( AP_INIT_RAW_ARGS(
"AddPocoRequestHandler", "AddPocoRequestHandler",
reinterpret_cast<cmd_func>(ApacheConnector_uris), reinterpret_cast<cmd_func>(ApacheConnector_uris),
NULL, nullptr,
RSRC_CONF, RSRC_CONF,
"POCO RequestHandlerFactory class name followed by shared library path followed by a list of ' ' separated URIs that must be handled by this module."), "POCO RequestHandlerFactory class name followed by shared library path followed by a list of ' ' separated URIs that must be handled by this module."),
AP_INIT_RAW_ARGS( AP_INIT_RAW_ARGS(
"AddPocoConfig", "AddPocoConfig",
reinterpret_cast<cmd_func>(ApacheConnector_config), reinterpret_cast<cmd_func>(ApacheConnector_config),
NULL, nullptr,
RSRC_CONF, RSRC_CONF,
"Path of the POCO configuration file."), "Path of the POCO configuration file."),
{ NULL } { nullptr }
}; };
module AP_MODULE_DECLARE_DATA poco_module = module AP_MODULE_DECLARE_DATA poco_module =
{ {
STANDARD20_MODULE_STUFF, STANDARD20_MODULE_STUFF,
NULL, nullptr,
NULL, nullptr,
NULL, nullptr,
NULL, nullptr,
ApacheConnector_cmds, ApacheConnector_cmds,
ApacheConnector_register_hooks ApacheConnector_register_hooks
}; };

View File

@@ -41,7 +41,7 @@ public:
NameSpace(); NameSpace();
/// Creates the NameSpace. /// Creates the NameSpace.
NameSpace(const std::string& name, NameSpace* pNameSpace = 0); NameSpace(const std::string& name, NameSpace* pNameSpace = nullptr);
/// Creates the NameSpace. /// Creates the NameSpace.
~NameSpace(); ~NameSpace();

View File

@@ -62,7 +62,7 @@ public:
/// Creates the Symbol and assigns the symbol /// Creates the Symbol and assigns the symbol
/// a unique ID. /// a unique ID.
Symbol(const std::string& name, NameSpace* pNameSpace = 0); Symbol(const std::string& name, NameSpace* pNameSpace = nullptr);
/// Creates the Symbol and assigns the symbol /// Creates the Symbol and assigns the symbol
/// a unique ID. /// a unique ID.

View File

@@ -670,13 +670,13 @@ void NumberLiteralToken::finishSuffix(std::istream& istr, int next)
int NumberLiteralToken::asInteger() const int NumberLiteralToken::asInteger() const
{ {
return static_cast<int>(std::strtol(_value.c_str(), 0, 0)); return static_cast<int>(std::strtol(_value.c_str(), nullptr, 0));
} }
double NumberLiteralToken::asFloat() const double NumberLiteralToken::asFloat() const
{ {
return std::strtod(_value.c_str(), 0); return std::strtod(_value.c_str(), nullptr);
} }

View File

@@ -213,7 +213,7 @@ bool Function::isVirtual() const
Struct* pClass = dynamic_cast<Struct*>(nameSpace()); Struct* pClass = dynamic_cast<Struct*>(nameSpace());
return pClass && pClass->hasVirtualDestructor(); return pClass && pClass->hasVirtualDestructor();
} }
else return getOverridden() != 0; else return getOverridden() != nullptr;
} }
@@ -235,7 +235,7 @@ Function* Function::getOverridden() const
} }
} }
} }
return 0; return nullptr;
} }

View File

@@ -94,7 +94,7 @@ Symbol* NameSpace::lookup(const std::string& name) const
Symbol* NameSpace::lookup(const std::string& name, std::set<const NameSpace*>& alreadyVisited) const Symbol* NameSpace::lookup(const std::string& name, std::set<const NameSpace*>& alreadyVisited) const
{ {
Symbol* pSymbol = 0; Symbol* pSymbol = nullptr;
if (name.empty()) if (name.empty())
return pSymbol; return pSymbol;
@@ -125,7 +125,7 @@ Symbol* NameSpace::lookup(const std::string& name, std::set<const NameSpace*>& a
if (pNS) if (pNS)
pSymbol = static_cast<NameSpace*>(pSymbol)->lookup(tail, alreadyVisited); pSymbol = static_cast<NameSpace*>(pSymbol)->lookup(tail, alreadyVisited);
else else
pSymbol = 0; pSymbol = nullptr;
} }
} }
else if (tail.empty()) else if (tail.empty())

View File

@@ -29,7 +29,7 @@ int Parameter::_count(0);
Parameter::Parameter(const std::string& decl, Function* /*pFunction*/): Parameter::Parameter(const std::string& decl, Function* /*pFunction*/):
Decl(handleDecl(decl), 0), // handle init values Decl(handleDecl(decl), nullptr), // handle init values
_type(), _type(),
_isRef(false), _isRef(false),
_isPointer(false), _isPointer(false),

View File

@@ -52,7 +52,7 @@ Parser::Parser(NameSpace::SymbolTable& gst, const std::string& file, std::istrea
_tokenizer(_istr), _tokenizer(_istr),
_file(file), _file(file),
_inFile(false), _inFile(false),
_pCurrentSymbol(0), _pCurrentSymbol(nullptr),
_access(Symbol::ACC_PUBLIC) _access(Symbol::ACC_PUBLIC)
{ {
Path p(file); Path p(file);
@@ -235,7 +235,7 @@ const Token* Parser::parseNameSpace(const Token* pNext)
fullName += name; fullName += name;
NameSpace* pNS = dynamic_cast<NameSpace*>(currentNameSpace()->lookup(fullName)); NameSpace* pNS = dynamic_cast<NameSpace*>(currentNameSpace()->lookup(fullName));
bool undefined = (pNS == 0); bool undefined = (pNS == nullptr);
if (undefined) pNS = new NameSpace(name, currentNameSpace()); if (undefined) pNS = new NameSpace(name, currentNameSpace());
pushNameSpace(pNS, -1, undefined); pushNameSpace(pNS, -1, undefined);
pNext = next(); pNext = next();
@@ -287,7 +287,7 @@ const Token* Parser::parseClass(const Token* pNext, std::string& decl)
{ {
poco_assert (isKeyword(pNext, IdentifierToken::KW_CLASS) || isKeyword(pNext, IdentifierToken::KW_STRUCT) || isKeyword(pNext, IdentifierToken::KW_UNION)); poco_assert (isKeyword(pNext, IdentifierToken::KW_CLASS) || isKeyword(pNext, IdentifierToken::KW_STRUCT) || isKeyword(pNext, IdentifierToken::KW_UNION));
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
bool isClass = isKeyword(pNext, IdentifierToken::KW_CLASS); bool isClass = isKeyword(pNext, IdentifierToken::KW_CLASS);
int line = static_cast<int>(_istr.getCurrentLineNumber()); int line = static_cast<int>(_istr.getCurrentLineNumber());
Symbol::Access prevAccess = _access; Symbol::Access prevAccess = _access;
@@ -324,7 +324,7 @@ const Token* Parser::parseClass(const Token* pNext, std::string& decl)
expectOperator(pNext, OperatorToken::OP_SEMICOLON, ";"); expectOperator(pNext, OperatorToken::OP_SEMICOLON, ";");
pNext = next(); pNext = next();
_access = prevAccess; _access = prevAccess;
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
return pNext; return pNext;
} }
if (isOperator(pNext, OperatorToken::OP_COLON) || isOperator(pNext, OperatorToken::OP_OPENBRACE)) if (isOperator(pNext, OperatorToken::OP_COLON) || isOperator(pNext, OperatorToken::OP_OPENBRACE))
@@ -346,7 +346,7 @@ const Token* Parser::parseClass(const Token* pNext, std::string& decl)
} }
pNext = next(); pNext = next();
_access = prevAccess; _access = prevAccess;
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
return pNext; return pNext;
} }
@@ -495,7 +495,7 @@ const Token* Parser::parseTypeDef(const Token* pNext)
{ {
poco_assert (isKeyword(pNext, IdentifierToken::KW_TYPEDEF)); poco_assert (isKeyword(pNext, IdentifierToken::KW_TYPEDEF));
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
int line = static_cast<int>(_istr.getCurrentLineNumber()); int line = static_cast<int>(_istr.getCurrentLineNumber());
std::string decl; std::string decl;
while (!isOperator(pNext, OperatorToken::OP_SEMICOLON) && !isEOF(pNext)) while (!isOperator(pNext, OperatorToken::OP_SEMICOLON) && !isEOF(pNext))
@@ -507,7 +507,7 @@ const Token* Parser::parseTypeDef(const Token* pNext)
addSymbol(pTypeDef, line); addSymbol(pTypeDef, line);
pNext = next(); pNext = next();
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
return pNext; return pNext;
} }
@@ -516,7 +516,7 @@ const Token* Parser::parseUsing(const Token* pNext)
{ {
poco_assert (isKeyword(pNext, IdentifierToken::KW_USING)); poco_assert (isKeyword(pNext, IdentifierToken::KW_USING));
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
int line = static_cast<int>(_istr.getCurrentLineNumber()); int line = static_cast<int>(_istr.getCurrentLineNumber());
pNext = next(); pNext = next();
if (isKeyword(pNext, IdentifierToken::KW_NAMESPACE)) if (isKeyword(pNext, IdentifierToken::KW_NAMESPACE))
@@ -560,7 +560,7 @@ const Token* Parser::parseUsing(const Token* pNext)
if (!isOperator(pNext, OperatorToken::OP_SEMICOLON)) if (!isOperator(pNext, OperatorToken::OP_SEMICOLON))
syntaxError("semicolon"); syntaxError("semicolon");
pNext = next(); pNext = next();
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
return pNext; return pNext;
} }
@@ -589,7 +589,7 @@ const Token* Parser::parseVarFunc(const Token* pNext)
const Token* Parser::parseVarFunc(const Token* pNext, std::string& decl) const Token* Parser::parseVarFunc(const Token* pNext, std::string& decl)
{ {
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
std::string attrs; std::string attrs;
if (isOperator(pNext, OperatorToken::OP_DBL_OPENBRACKET)) if (isOperator(pNext, OperatorToken::OP_DBL_OPENBRACKET))
{ {
@@ -642,7 +642,7 @@ const Token* Parser::parseVarFunc(const Token* pNext, std::string& decl)
pNext = parseFunc(pNext, attrs, decl); pNext = parseFunc(pNext, attrs, decl);
} }
} }
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
return pNext; return pNext;
} }
@@ -674,7 +674,7 @@ const Token* Parser::parseFunc(const Token* pNext, const std::string& attrs, std
poco_assert (isOperator(pNext, OperatorToken::OP_OPENPARENT)); poco_assert (isOperator(pNext, OperatorToken::OP_OPENPARENT));
int line = static_cast<int>(_istr.getCurrentLineNumber()); int line = static_cast<int>(_istr.getCurrentLineNumber());
Function* pFunc = 0; Function* pFunc = nullptr;
std::string name = Symbol::extractName(decl); std::string name = Symbol::extractName(decl);
if (name.find(':') == std::string::npos) if (name.find(':') == std::string::npos)
{ {
@@ -836,7 +836,7 @@ const Token* Parser::parseEnum(const Token* pNext)
std::string baseType; std::string baseType;
int flags = 0; int flags = 0;
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
int line = static_cast<int>(_istr.getCurrentLineNumber()); int line = static_cast<int>(_istr.getCurrentLineNumber());
pNext = next(); pNext = next();
@@ -883,14 +883,14 @@ const Token* Parser::parseEnum(const Token* pNext)
pNext = next(); pNext = next();
expectOperator(pNext, OperatorToken::OP_SEMICOLON, ";"); expectOperator(pNext, OperatorToken::OP_SEMICOLON, ";");
pNext = next(); pNext = next();
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
return pNext; return pNext;
} }
const Token* Parser::parseEnumValue(const Token* pNext, Enum* pEnum) const Token* Parser::parseEnumValue(const Token* pNext, Enum* pEnum)
{ {
_pCurrentSymbol = 0; _pCurrentSymbol = nullptr;
_doc.clear(); _doc.clear();
int line = static_cast<int>(_istr.getCurrentLineNumber()); int line = static_cast<int>(_istr.getCurrentLineNumber());
std::string name = pNext->tokenString(); std::string name = pNext->tokenString();

View File

@@ -58,7 +58,7 @@ void Struct::addBase(const std::string& name, Symbol::Access access, bool isVirt
base.name = name; base.name = name;
base.access = access; base.access = access;
base.isVirtual = isVirtual; base.isVirtual = isVirtual;
base.pClass = 0; base.pClass = nullptr;
_bases.push_back(base); _bases.push_back(base);
} }
@@ -154,7 +154,7 @@ Function* Struct::destructor() const
if (pFunc && pFunc->isDestructor()) if (pFunc && pFunc->isDestructor())
return pFunc; return pFunc;
} }
return 0; return nullptr;
} }
@@ -220,7 +220,7 @@ Function* Struct::findFunction(const std::string& signature) const
if (pFunc) return pFunc; if (pFunc) return pFunc;
} }
} }
return 0; return nullptr;
} }

View File

@@ -29,7 +29,7 @@ int Symbol::_nextId = 0;
Symbol::Symbol(): Symbol::Symbol():
_id(_nextId++), _id(_nextId++),
_pNameSpace(0), _pNameSpace(nullptr),
_access(ACC_PUBLIC), _access(ACC_PUBLIC),
_line(-1), _line(-1),
_order(0) _order(0)

View File

@@ -119,7 +119,7 @@ inline std::string& getError(std::string& msg)
while ((err = ERR_get_error())) while ((err = ERR_get_error()))
{ {
if (!msg.empty()) msg.append(1, '\n'); if (!msg.empty()) msg.append(1, '\n');
msg.append(ERR_error_string(err, 0)); msg.append(ERR_error_string(err, nullptr));
} }
return msg; return msg;
} }

View File

@@ -65,7 +65,7 @@ public:
/// If a private key is specified, you don't need to specify a public key file. /// If a private key is specified, you don't need to specify a public key file.
/// OpenSSL will auto-create the public key from the private key. /// OpenSSL will auto-create the public key from the private key.
ECKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = ""); ECKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream = nullptr, const std::string& privateKeyPassphrase = "");
/// Creates the ECKey, by reading public and private key from the given streams and /// Creates the ECKey, by reading public and private key from the given streams and
/// using the given passphrase for the private key. /// using the given passphrase for the private key.
/// ///

View File

@@ -95,7 +95,7 @@ public:
/// is not exported. /// is not exported.
void save(std::ostream* pPublicKeyStream, void save(std::ostream* pPublicKeyStream,
std::ostream* pPrivateKeyStream = 0, std::ostream* pPrivateKeyStream = nullptr,
const std::string& privateKeyPassphrase = "") const; const std::string& privateKeyPassphrase = "") const;
/// Exports the public and private key to the given streams. /// Exports the public and private key to the given streams.
/// ///

View File

@@ -149,7 +149,7 @@ public:
/// If an empty filename is specified, the corresponding key /// If an empty filename is specified, the corresponding key
/// is not exported. /// is not exported.
void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "") const; void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = nullptr, const std::string& privateKeyPassphrase = "") const;
/// Exports the public and/or private key to the given streams. /// Exports the public and/or private key to the given streams.
/// ///
/// If a null pointer is passed for a stream, the corresponding /// If a null pointer is passed for a stream, the corresponding
@@ -218,7 +218,7 @@ private:
poco_check_ptr (ppKey); poco_check_ptr (ppKey);
poco_assert_dbg (!*ppKey); poco_assert_dbg (!*ppKey);
FILE* pFile = 0; FILE* pFile = nullptr;
if (!keyFile.empty()) if (!keyFile.empty())
{ {
if (!getFunc) *ppKey = (K*)EVP_PKEY_new(); if (!getFunc) *ppKey = (K*)EVP_PKEY_new();
@@ -236,11 +236,11 @@ private:
if (pFile) if (pFile)
{ {
pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)0 : &passCB; pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)nullptr : &passCB;
void* pPassword = pass.empty() ? (void*)0 : (void*)pass.c_str(); void* pPassword = pass.empty() ? (void*)nullptr : (void*)pass.c_str();
if (readFunc(pFile, &pKey, pCB, pPassword)) if (readFunc(pFile, &pKey, pCB, pPassword))
{ {
fclose(pFile); pFile = 0; fclose(pFile); pFile = nullptr;
if(getFunc) if(getFunc)
{ {
*ppKey = (K*)getFunc(pKey); *ppKey = (K*)getFunc(pKey);
@@ -288,7 +288,7 @@ private:
poco_check_ptr(ppKey); poco_check_ptr(ppKey);
poco_assert_dbg(!*ppKey); poco_assert_dbg(!*ppKey);
BIO* pBIO = 0; BIO* pBIO = nullptr;
if (pIstr) if (pIstr)
{ {
std::ostringstream ostr; std::ostringstream ostr;
@@ -301,11 +301,11 @@ private:
EVP_PKEY* pKey = getFunc ? EVP_PKEY_new() : (EVP_PKEY*)*ppKey; EVP_PKEY* pKey = getFunc ? EVP_PKEY_new() : (EVP_PKEY*)*ppKey;
if (pKey) if (pKey)
{ {
pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)0 : &passCB; pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)nullptr : &passCB;
void* pPassword = pass.empty() ? (void*)0 : (void*)pass.c_str(); void* pPassword = pass.empty() ? (void*)nullptr : (void*)pass.c_str();
if (readFunc(pBIO, &pKey, pCB, pPassword)) if (readFunc(pBIO, &pKey, pCB, pPassword))
{ {
BIO_free(pBIO); pBIO = 0; BIO_free(pBIO); pBIO = nullptr;
if (getFunc) if (getFunc)
{ {
*ppKey = (K*)getFunc(pKey); *ppKey = (K*)getFunc(pKey);
@@ -335,7 +335,7 @@ private:
throw OpenSSLException(msg); throw OpenSSLException(msg);
} }
EVP_PKEY* _pEVPPKey = 0; EVP_PKEY* _pEVPPKey = nullptr;
static const std::map<int, std::string> KNOWN_TYPES; static const std::map<int, std::string> KNOWN_TYPES;
friend class ECKeyImpl; friend class ECKeyImpl;

View File

@@ -44,7 +44,7 @@ public:
KT_EC = KeyPairImpl::KT_EC_IMPL KT_EC = KeyPairImpl::KT_EC_IMPL
}; };
explicit KeyPair(KeyPairImpl::Ptr pKeyPairImpl = 0); explicit KeyPair(KeyPairImpl::Ptr pKeyPairImpl = nullptr);
/// Extracts the RSA public key from the given certificate. /// Extracts the RSA public key from the given certificate.
KeyPair(const KeyPair& other); KeyPair(const KeyPair& other);
@@ -74,7 +74,7 @@ public:
/// is not exported. /// is not exported.
virtual void save(std::ostream* pPublicKeyPairStream, virtual void save(std::ostream* pPublicKeyPairStream,
std::ostream* pPrivateKeyPairStream = 0, std::ostream* pPrivateKeyPairStream = nullptr,
const std::string& privateKeyPairPassphrase = "") const; const std::string& privateKeyPairPassphrase = "") const;
/// Exports the public and private key to the given streams. /// Exports the public and private key to the given streams.
/// ///

View File

@@ -62,7 +62,7 @@ public:
/// is not exported. /// is not exported.
virtual void save(std::ostream* pPublicKeyStream, virtual void save(std::ostream* pPublicKeyStream,
std::ostream* pPrivateKeyStream = 0, std::ostream* pPrivateKeyStream = nullptr,
const std::string& privateKeyPassphrase = "") const = 0; const std::string& privateKeyPassphrase = "") const = 0;
/// Exports the public and private key to the given streams. /// Exports the public and private key to the given streams.
/// ///

View File

@@ -103,7 +103,7 @@ private:
inline bool PKCS12Container::hasX509Certificate() const inline bool PKCS12Container::hasX509Certificate() const
{ {
return _pX509Cert.get() != 0; return _pX509Cert.get() != nullptr;
} }
@@ -135,7 +135,7 @@ inline const PKCS12Container::CANameList& PKCS12Container::getFriendlyNamesCA()
inline bool PKCS12Container::hasKey() const inline bool PKCS12Container::hasKey() const
{ {
return _pKey != 0; return _pKey != nullptr;
} }

View File

@@ -103,7 +103,7 @@ public:
/// is not exported. /// is not exported.
void save(std::ostream* pPublicKeyStream, void save(std::ostream* pPublicKeyStream,
std::ostream* pPrivateKeyStream = 0, std::ostream* pPrivateKeyStream = nullptr,
const std::string& privateKeyPassphrase = "") const; const std::string& privateKeyPassphrase = "") const;
/// Exports the public and private key to the given streams. /// Exports the public and private key to the given streams.
/// ///

View File

@@ -34,8 +34,8 @@ namespace Crypto {
CipherFactory::CipherFactory() CipherFactory::CipherFactory()
{ {
#if OPENSSL_VERSION_NUMBER >= 0x30000000L #if OPENSSL_VERSION_NUMBER >= 0x30000000L
OSSL_PROVIDER_load(NULL, "default"); OSSL_PROVIDER_load(nullptr, "default");
OSSL_PROVIDER_load(NULL, "legacy"); OSSL_PROVIDER_load(nullptr, "legacy");
#endif #endif
} }

View File

@@ -34,7 +34,7 @@ namespace
{ {
if (!msg.empty()) if (!msg.empty())
msg.append("; "); msg.append("; ");
msg.append(ERR_error_string(err, 0)); msg.append(ERR_error_string(err, nullptr));
} }
throw Poco::IOException(msg); throw Poco::IOException(msg);
@@ -103,7 +103,7 @@ namespace
_pContext, _pContext,
_pCipher, _pCipher,
&_key[0], &_key[0],
_iv.empty() ? 0 : &_iv[0], _iv.empty() ? nullptr : &_iv[0],
(dir == DIR_ENCRYPT) ? 1 : 0); (dir == DIR_ENCRYPT) ? 1 : 0);
#else #else
int rc = EVP_CipherInit( int rc = EVP_CipherInit(
@@ -119,9 +119,9 @@ namespace
if (_iv.size() != EVP_CIPHER_iv_length(_pCipher) && EVP_CIPHER_mode(_pCipher) == EVP_CIPH_GCM_MODE) if (_iv.size() != EVP_CIPHER_iv_length(_pCipher) && EVP_CIPHER_mode(_pCipher) == EVP_CIPH_GCM_MODE)
{ {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L #if OPENSSL_VERSION_NUMBER >= 0x10100000L
int rc = EVP_CIPHER_CTX_ctrl(_pContext, EVP_CTRL_GCM_SET_IVLEN, static_cast<int>(_iv.size()), NULL); int rc = EVP_CIPHER_CTX_ctrl(_pContext, EVP_CTRL_GCM_SET_IVLEN, static_cast<int>(_iv.size()), nullptr);
#else #else
int rc = EVP_CIPHER_CTX_ctrl(&_context, EVP_CTRL_GCM_SET_IVLEN, static_cast<int>(_iv.size()), NULL); int rc = EVP_CIPHER_CTX_ctrl(&_context, EVP_CTRL_GCM_SET_IVLEN, static_cast<int>(_iv.size()), nullptr);
#endif #endif
if (rc == 0) throwError(); if (rc == 0) throwError();
} }

View File

@@ -32,7 +32,7 @@ namespace
{ {
if (!msg.empty()) if (!msg.empty())
msg.append("; "); msg.append("; ");
msg.append(ERR_error_string(err, 0)); msg.append(ERR_error_string(err, nullptr));
} }
throw Poco::IOException(msg); throw Poco::IOException(msg);
@@ -49,8 +49,8 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name,
const std::string& salt, const std::string& salt,
int iterationCount, int iterationCount,
const std::string& digest): const std::string& digest):
_pCipher(0), _pCipher(nullptr),
_pDigest(0), _pDigest(nullptr),
_name(name), _name(name),
_key(), _key(),
_iv() _iv()
@@ -76,8 +76,8 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name,
CipherKeyImpl::CipherKeyImpl(const std::string& name, CipherKeyImpl::CipherKeyImpl(const std::string& name,
const ByteVec& key, const ByteVec& key,
const ByteVec& iv): const ByteVec& iv):
_pCipher(0), _pCipher(nullptr),
_pDigest(0), _pDigest(nullptr),
_name(name), _name(name),
_key(key), _key(key),
_iv(iv) _iv(iv)
@@ -92,8 +92,8 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name,
CipherKeyImpl::CipherKeyImpl(const std::string& name): CipherKeyImpl::CipherKeyImpl(const std::string& name):
_pCipher(0), _pCipher(nullptr),
_pDigest(0), _pDigest(nullptr),
_name(name), _name(name),
_key(), _key(),
_iv() _iv()
@@ -198,7 +198,7 @@ void CipherKeyImpl::generateKey(
int keySize = EVP_BytesToKey( int keySize = EVP_BytesToKey(
_pCipher, _pCipher,
_pDigest ? _pDigest : EVP_md5(), _pDigest ? _pDigest : EVP_md5(),
(salt.empty() ? 0 : saltBytes), (salt.empty() ? nullptr : saltBytes),
reinterpret_cast<const unsigned char*>(password.data()), reinterpret_cast<const unsigned char*>(password.data()),
static_cast<int>(password.size()), static_cast<int>(password.size()),
iterationCount, iterationCount,

View File

@@ -36,7 +36,7 @@ CryptoStreamBuf::CryptoStreamBuf(std::istream& istr, CryptoTransform::Ptr pTrans
Poco::BufferedStreamBuf(bufferSize, std::ios::in), Poco::BufferedStreamBuf(bufferSize, std::ios::in),
_pTransform(pTransform), _pTransform(pTransform),
_pIstr(&istr), _pIstr(&istr),
_pOstr(0), _pOstr(nullptr),
_eof(false), _eof(false),
_buffer(static_cast<std::size_t>(bufferSize)) _buffer(static_cast<std::size_t>(bufferSize))
{ {
@@ -48,7 +48,7 @@ CryptoStreamBuf::CryptoStreamBuf(std::istream& istr, CryptoTransform::Ptr pTrans
CryptoStreamBuf::CryptoStreamBuf(std::ostream& ostr, CryptoTransform::Ptr pTransform, std::streamsize bufferSize): CryptoStreamBuf::CryptoStreamBuf(std::ostream& ostr, CryptoTransform::Ptr pTransform, std::streamsize bufferSize):
Poco::BufferedStreamBuf(bufferSize, std::ios::out), Poco::BufferedStreamBuf(bufferSize, std::ios::out),
_pTransform(pTransform), _pTransform(pTransform),
_pIstr(0), _pIstr(nullptr),
_pOstr(&ostr), _pOstr(&ostr),
_eof(false), _eof(false),
_buffer(static_cast<std::size_t>(bufferSize)) _buffer(static_cast<std::size_t>(bufferSize))
@@ -76,7 +76,7 @@ void CryptoStreamBuf::close()
if (_pIstr) if (_pIstr)
{ {
_pIstr = 0; _pIstr = nullptr;
} }
else if (_pOstr) else if (_pOstr)
{ {
@@ -84,7 +84,7 @@ void CryptoStreamBuf::close()
// sure that we call finalize() only once, even if an exception is // sure that we call finalize() only once, even if an exception is
// thrown. // thrown.
std::ostream* pOstr = _pOstr; std::ostream* pOstr = _pOstr;
_pOstr = 0; _pOstr = nullptr;
// Finalize transformation. // Finalize transformation.
std::streamsize n = _pTransform->finalize(_buffer.begin(), static_cast<std::streamsize>(_buffer.size())); std::streamsize n = _pTransform->finalize(_buffer.begin(), static_cast<std::streamsize>(_buffer.size()));

View File

@@ -26,7 +26,7 @@ DigestEngine::DigestEngine(const std::string& name):
{ {
const EVP_MD* md = EVP_get_digestbyname(_name.c_str()); const EVP_MD* md = EVP_get_digestbyname(_name.c_str());
if (!md) throw Poco::NotFoundException(_name); if (!md) throw Poco::NotFoundException(_name);
EVP_DigestInit_ex(_pContext, md, NULL); EVP_DigestInit_ex(_pContext, md, nullptr);
} }
@@ -60,7 +60,7 @@ void DigestEngine::reset()
#endif #endif
const EVP_MD* md = EVP_get_digestbyname(_name.c_str()); const EVP_MD* md = EVP_get_digestbyname(_name.c_str());
if (!md) throw Poco::NotFoundException(_name); if (!md) throw Poco::NotFoundException(_name);
EVP_DigestInit_ex(_pContext, md, NULL); EVP_DigestInit_ex(_pContext, md, nullptr);
} }

View File

@@ -114,7 +114,7 @@ ECDSASignature::ECDSASignature(const ByteVec& derSignature)
poco_assert (!derSignature.empty()); poco_assert (!derSignature.empty());
const unsigned char* p = &derSignature[0]; const unsigned char* p = &derSignature[0];
_pSig = d2i_ECDSA_SIG(0, &p, static_cast<long>(derSignature.size())); _pSig = d2i_ECDSA_SIG(nullptr, &p, static_cast<long>(derSignature.size()));
if (!_pSig) if (!_pSig)
throw OpenSSLException(); throw OpenSSLException();
} }
@@ -131,12 +131,12 @@ ECDSASignature::ECDSASignature(const ByteVec& rawR, const ByteVec& rawS):
{ {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L #if OPENSSL_VERSION_NUMBER >= 0x10100000L
ECDSA_SIG_set0(_pSig, ECDSA_SIG_set0(_pSig,
BN_bin2bn(&rawR[0], static_cast<long>(rawR.size()), 0), BN_bin2bn(&rawR[0], static_cast<long>(rawR.size()), nullptr),
BN_bin2bn(&rawS[0], static_cast<long>(rawS.size()), 0)); BN_bin2bn(&rawS[0], static_cast<long>(rawS.size()), nullptr));
const BIGNUM* pR = 0; const BIGNUM* pR = nullptr;
const BIGNUM* pS = 0; const BIGNUM* pS = nullptr;
ECDSA_SIG_get0(_pSig, &pR, &pS); ECDSA_SIG_get0(_pSig, &pR, &pS);
if (pR == 0 || pS == 0) if (pR == nullptr || pS == nullptr)
throw Poco::Crypto::CryptoException("failed to decode R and S values"); throw Poco::Crypto::CryptoException("failed to decode R and S values");
#else #else
if (!BN_bin2bn(&rawR[0], rawR.size(), _pSig->r)) if (!BN_bin2bn(&rawR[0], rawR.size(), _pSig->r))
@@ -161,7 +161,7 @@ ECDSASignature::~ECDSASignature()
ECDSASignature::ByteVec ECDSASignature::toDER() const ECDSASignature::ByteVec ECDSASignature::toDER() const
{ {
int size = i2d_ECDSA_SIG(_pSig, 0); int size = i2d_ECDSA_SIG(_pSig, nullptr);
if (size > 0) if (size > 0)
{ {
ByteVec buffer(size); ByteVec buffer(size);

View File

@@ -38,7 +38,7 @@ ECKeyImpl::ECKeyImpl(const EVPPKey& key):
ECKeyImpl::ECKeyImpl(const X509Certificate& cert): ECKeyImpl::ECKeyImpl(const X509Certificate& cert):
KeyPairImpl("ec", KT_EC_IMPL), KeyPairImpl("ec", KT_EC_IMPL),
_pEC(0) _pEC(nullptr)
{ {
const X509* pCert = cert.certificate(); const X509* pCert = cert.certificate();
if (pCert) if (pCert)
@@ -78,7 +78,7 @@ ECKeyImpl::ECKeyImpl(int curve):
ECKeyImpl::ECKeyImpl(const std::string& publicKeyFile, ECKeyImpl::ECKeyImpl(const std::string& publicKeyFile,
const std::string& privateKeyFile, const std::string& privateKeyFile,
const std::string& privateKeyPassphrase): KeyPairImpl("ec", KT_EC_IMPL), _pEC(0) const std::string& privateKeyPassphrase): KeyPairImpl("ec", KT_EC_IMPL), _pEC(nullptr)
{ {
if (EVPPKey::loadKey(&_pEC, PEM_read_PrivateKey, EVP_PKEY_get1_EC_KEY, privateKeyFile, privateKeyPassphrase)) if (EVPPKey::loadKey(&_pEC, PEM_read_PrivateKey, EVP_PKEY_get1_EC_KEY, privateKeyFile, privateKeyPassphrase))
{ {
@@ -101,7 +101,7 @@ ECKeyImpl::ECKeyImpl(const std::string& publicKeyFile,
ECKeyImpl::ECKeyImpl(std::istream* pPublicKeyStream, ECKeyImpl::ECKeyImpl(std::istream* pPublicKeyStream,
std::istream* pPrivateKeyStream, std::istream* pPrivateKeyStream,
const std::string& privateKeyPassphrase): KeyPairImpl("ec", KT_EC_IMPL), _pEC(0) const std::string& privateKeyPassphrase): KeyPairImpl("ec", KT_EC_IMPL), _pEC(nullptr)
{ {
if (EVPPKey::loadKey(&_pEC, PEM_read_bio_PrivateKey, EVP_PKEY_get1_EC_KEY, pPrivateKeyStream, privateKeyPassphrase)) if (EVPPKey::loadKey(&_pEC, PEM_read_bio_PrivateKey, EVP_PKEY_get1_EC_KEY, pPrivateKeyStream, privateKeyPassphrase))
{ {
@@ -141,7 +141,7 @@ void ECKeyImpl::freeEC()
if (_pEC) if (_pEC)
{ {
EC_KEY_free(_pEC); EC_KEY_free(_pEC);
_pEC = 0; _pEC = nullptr;
} }
} }
@@ -181,7 +181,7 @@ int ECKeyImpl::groupId() const
std::string ECKeyImpl::getCurveName(int nid) std::string ECKeyImpl::getCurveName(int nid)
{ {
std::string curveName; std::string curveName;
size_t len = EC_get_builtin_curves(NULL, 0); size_t len = EC_get_builtin_curves(nullptr, 0);
EC_builtin_curve* pCurves = EC_builtin_curve* pCurves =
(EC_builtin_curve*) OPENSSL_malloc(sizeof(EC_builtin_curve) * len); (EC_builtin_curve*) OPENSSL_malloc(sizeof(EC_builtin_curve) * len);
if (!pCurves) return curveName; if (!pCurves) return curveName;
@@ -206,7 +206,7 @@ std::string ECKeyImpl::getCurveName(int nid)
int ECKeyImpl::getCurveNID(std::string& name) int ECKeyImpl::getCurveNID(std::string& name)
{ {
std::string curveName; std::string curveName;
size_t len = EC_get_builtin_curves(NULL, 0); size_t len = EC_get_builtin_curves(nullptr, 0);
EC_builtin_curve* pCurves = EC_builtin_curve* pCurves =
(EC_builtin_curve*)OPENSSL_malloc(static_cast<int>(sizeof(EC_builtin_curve) * len)); (EC_builtin_curve*)OPENSSL_malloc(static_cast<int>(sizeof(EC_builtin_curve) * len));
if (!pCurves) return -1; if (!pCurves) return -1;

View File

@@ -33,7 +33,7 @@ namespace
while ((err = ERR_get_error())) while ((err = ERR_get_error()))
{ {
if (!msg.empty()) msg.append("; "); if (!msg.empty()) msg.append("; ");
msg.append(ERR_error_string(err, 0)); msg.append(ERR_error_string(err, nullptr));
} }
throw Poco::IOException(msg); throw Poco::IOException(msg);
@@ -43,7 +43,7 @@ namespace
{ {
public: public:
EVPPKeyContext() = delete; EVPPKeyContext() = delete;
EVPPKeyContext(const EVP_PKEY* pEVP) : _pCtx(EVP_PKEY_CTX_new(const_cast<EVP_PKEY*>(pEVP), NULL)) EVPPKeyContext(const EVP_PKEY* pEVP) : _pCtx(EVP_PKEY_CTX_new(const_cast<EVP_PKEY*>(pEVP), nullptr))
{ {
if (!_pCtx) if (!_pCtx)
{ {
@@ -73,7 +73,7 @@ namespace
_pEVP(pEVP), _pEVP(pEVP),
_pCtx(_pEVP), _pCtx(_pEVP),
_pos(0), _pos(0),
_pBuf(0) _pBuf(nullptr)
{ {
std::string fmt = "EVPEncryptImpl():%s()"; std::string fmt = "EVPEncryptImpl():%s()";
poco_check_ptr(_pEVP); poco_check_ptr(_pEVP);
@@ -126,7 +126,7 @@ namespace
{ {
poco_assert (outputLength >= evpSize); poco_assert (outputLength >= evpSize);
std::size_t outLen; std::size_t outLen;
if (EVP_PKEY_encrypt(_pCtx, NULL, &outLen, _pBuf, static_cast<std::size_t>(maxSize)) <= 0) if (EVP_PKEY_encrypt(_pCtx, nullptr, &outLen, _pBuf, static_cast<std::size_t>(maxSize)) <= 0)
throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt(NULL)"))); throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt(NULL)")));
if (EVP_PKEY_encrypt(_pCtx, output, &outLen, _pBuf, static_cast<std::size_t>(maxSize)) <= 0) if (EVP_PKEY_encrypt(_pCtx, output, &outLen, _pBuf, static_cast<std::size_t>(maxSize)) <= 0)
throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt"))); throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt")));
@@ -156,7 +156,7 @@ namespace
std::size_t outLen = 0; std::size_t outLen = 0;
if (_pos > 0) if (_pos > 0)
{ {
if (EVP_PKEY_encrypt(_pCtx, NULL, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0) if (EVP_PKEY_encrypt(_pCtx, nullptr, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0)
throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt"))); throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt")));
if (EVP_PKEY_encrypt(_pCtx, output, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0) if (EVP_PKEY_encrypt(_pCtx, output, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0)
throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt"))); throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt")));
@@ -169,7 +169,7 @@ namespace
{ {
std::string fmt = "EVPEncryptImpl::maxDataSize():%s()"; std::string fmt = "EVPEncryptImpl::maxDataSize():%s()";
std::size_t outLength = 0; std::size_t outLength = 0;
if (EVP_PKEY_encrypt(_pCtx, NULL, &outLength, pIO, length) <= 0) if (EVP_PKEY_encrypt(_pCtx, nullptr, &outLength, pIO, length) <= 0)
throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt"))); throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt")));
return outLength; return outLength;
} }
@@ -189,7 +189,7 @@ namespace
_pEVP(pEVP), _pEVP(pEVP),
_pCtx(_pEVP), _pCtx(_pEVP),
_pos(0), _pos(0),
_pBuf(0) _pBuf(nullptr)
{ {
std::string fmt = "EVPDecryptImpl():%s()"; std::string fmt = "EVPDecryptImpl():%s()";
poco_check_ptr(_pEVP); poco_check_ptr(_pEVP);
@@ -237,7 +237,7 @@ namespace
if (missing == 0) if (missing == 0)
{ {
std::size_t outLen = 0; std::size_t outLen = 0;
if (EVP_PKEY_decrypt(_pCtx, NULL, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0) if (EVP_PKEY_decrypt(_pCtx, nullptr, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0)
throwError(Poco::format(fmt, std::string("EVP_PKEY_decrypt(NULL)"))); throwError(Poco::format(fmt, std::string("EVP_PKEY_decrypt(NULL)")));
if (EVP_PKEY_decrypt(_pCtx, output, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0) if (EVP_PKEY_decrypt(_pCtx, output, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0)
throwError(Poco::format(fmt, std::string("EVP_PKEY_decrypt"))); throwError(Poco::format(fmt, std::string("EVP_PKEY_decrypt")));
@@ -263,7 +263,7 @@ namespace
poco_assert (length >= _blockSize); poco_assert (length >= _blockSize);
std::string fmt = "EVPDecryptImpl::finalize():%s()"; std::string fmt = "EVPDecryptImpl::finalize():%s()";
std::size_t outLen = 0; std::size_t outLen = 0;
if (EVP_PKEY_decrypt(_pCtx, NULL, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0) if (EVP_PKEY_decrypt(_pCtx, nullptr, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0)
throwError(Poco::format(fmt, std::string("EVP_PKEY_decrypt(NULL)"))); throwError(Poco::format(fmt, std::string("EVP_PKEY_decrypt(NULL)")));
poco_assert (length >= outLen); poco_assert (length >= outLen);
if (_pos > 0) if (_pos > 0)

View File

@@ -39,7 +39,7 @@ const std::map<int, std::string> EVPPKey::KNOWN_TYPES =
}; };
EVPPKey::EVPPKey(const std::string& ecCurveName): _pEVPPKey(0) EVPPKey::EVPPKey(const std::string& ecCurveName) : _pEVPPKey(nullptr)
{ {
newECKey(ecCurveName.c_str()); newECKey(ecCurveName.c_str());
poco_check_ptr(_pEVPPKey); poco_check_ptr(_pEVPPKey);
@@ -47,7 +47,7 @@ EVPPKey::EVPPKey(const std::string& ecCurveName): _pEVPPKey(0)
} }
EVPPKey::EVPPKey(const char* ecCurveName): _pEVPPKey(0) EVPPKey::EVPPKey(const char* ecCurveName) : _pEVPPKey(nullptr)
{ {
newECKey(ecCurveName); newECKey(ecCurveName);
poco_check_ptr(_pEVPPKey); poco_check_ptr(_pEVPPKey);
@@ -55,8 +55,7 @@ EVPPKey::EVPPKey(const char* ecCurveName): _pEVPPKey(0)
} }
EVPPKey::EVPPKey(const X509Certificate& cert): EVPPKey::EVPPKey(const X509Certificate& cert): _pEVPPKey(X509_get_pubkey(const_cast<X509*>(cert.certificate())))
_pEVPPKey(X509_get_pubkey(const_cast<X509*>(cert.certificate())))
{ {
poco_check_ptr(_pEVPPKey); poco_check_ptr(_pEVPPKey);
checkType(); checkType();
@@ -138,7 +137,7 @@ void EVPPKey::setKeyFromParameters(OSSL_PARAM* parameters)
throw OpenSSLException("EVPPKey cannot init create key"); throw OpenSSLException("EVPPKey cannot init create key");
} }
if (_pEVPPKey != 0) EVP_PKEY_free(_pEVPPKey); if (_pEVPPKey != nullptr) EVP_PKEY_free(_pEVPPKey);
if (EVP_PKEY_fromdata(ctx, &_pEVPPKey, EVP_PKEY_KEYPAIR, parameters) <= 0) if (EVP_PKEY_fromdata(ctx, &_pEVPPKey, EVP_PKEY_KEYPAIR, parameters) <= 0)
{ {
OSSL_PARAM_free(parameters); OSSL_PARAM_free(parameters);
@@ -150,7 +149,7 @@ void EVPPKey::setKeyFromParameters(OSSL_PARAM* parameters)
} }
EVPPKey::EVPPKey(const std::vector<unsigned char>* public_key, const std::vector<unsigned char>* private_key, unsigned long exponent, int type) : _pEVPPKey(0) EVPPKey::EVPPKey(const std::vector<unsigned char>* public_key, const std::vector<unsigned char>* private_key, unsigned long exponent, int type) : _pEVPPKey(nullptr)
{ {
if ((EVP_PKEY_RSA != type) || (RSA_F4 != exponent)) if ((EVP_PKEY_RSA != type) || (RSA_F4 != exponent))
{ {
@@ -175,10 +174,10 @@ EVPPKey::EVPPKey(const std::vector<unsigned char>* public_key, const std::vector
#if OPENSSL_VERSION_NUMBER >= 0x10000000L #if OPENSSL_VERSION_NUMBER >= 0x10000000L
EVPPKey::EVPPKey(int type, int param): _pEVPPKey(0) EVPPKey::EVPPKey(int type, int param) : _pEVPPKey(nullptr)
{ {
EVP_PKEY_CTX *pCtx = EVP_PKEY_CTX_new_id(type, NULL); EVP_PKEY_CTX* pCtx = EVP_PKEY_CTX_new_id(type, nullptr);
if (NULL == pCtx) if (nullptr == pCtx)
{ {
std::string msg = Poco::format( std::string msg = Poco::format(
"EVPPKey(%d, %d):EVP_PKEY_CTX_new_id()\n", type, param); "EVPPKey(%d, %d):EVP_PKEY_CTX_new_id()\n", type, param);
@@ -236,7 +235,7 @@ EVPPKey::EVPPKey(int type, int param): _pEVPPKey(0)
#endif // OPENSSL_VERSION_NUMBER >= 0x10000000L #endif // OPENSSL_VERSION_NUMBER >= 0x10000000L
EVPPKey::EVPPKey(EVP_PKEY* pEVPPKey): _pEVPPKey(0) EVPPKey::EVPPKey(EVP_PKEY* pEVPPKey) : _pEVPPKey(nullptr)
{ {
duplicate(pEVPPKey, &_pEVPPKey); duplicate(pEVPPKey, &_pEVPPKey);
poco_check_ptr(_pEVPPKey); poco_check_ptr(_pEVPPKey);
@@ -244,19 +243,16 @@ EVPPKey::EVPPKey(EVP_PKEY* pEVPPKey): _pEVPPKey(0)
} }
EVPPKey::EVPPKey(const std::string& publicKeyFile, EVPPKey::EVPPKey(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase) : _pEVPPKey(nullptr)
const std::string& privateKeyFile,
const std::string& privateKeyPassphrase): _pEVPPKey(0)
{ {
if (loadKey(&_pEVPPKey, PEM_read_PrivateKey, (EVP_PKEY_get_Key_fn)0, privateKeyFile, privateKeyPassphrase)) if (loadKey(&_pEVPPKey, PEM_read_PrivateKey, (EVP_PKEY_get_Key_fn) nullptr, privateKeyFile, privateKeyPassphrase))
{ {
poco_check_ptr(_pEVPPKey); poco_check_ptr(_pEVPPKey);
return; // private key is enough return; // private key is enough
} }
// no private key, this must be public key only, otherwise throw // no private key, this must be public key only, otherwise throw
if (!loadKey(&_pEVPPKey, PEM_read_PUBKEY, (EVP_PKEY_get_Key_fn)0, publicKeyFile)) if (!loadKey(&_pEVPPKey, PEM_read_PUBKEY, (EVP_PKEY_get_Key_fn) nullptr, publicKeyFile)) {
{
std::string msg = "EVPPKey(const string&, const string&, const string&)\n"; std::string msg = "EVPPKey(const string&, const string&, const string&)\n";
throw OpenSSLException(getError(msg)); throw OpenSSLException(getError(msg));
} }
@@ -265,19 +261,16 @@ EVPPKey::EVPPKey(const std::string& publicKeyFile,
} }
EVPPKey::EVPPKey(std::istream* pPublicKeyStream, EVPPKey::EVPPKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase) : _pEVPPKey(nullptr)
std::istream* pPrivateKeyStream,
const std::string& privateKeyPassphrase): _pEVPPKey(0)
{ {
if (loadKey(&_pEVPPKey, PEM_read_bio_PrivateKey, (EVP_PKEY_get_Key_fn)0, pPrivateKeyStream, privateKeyPassphrase)) if (loadKey(&_pEVPPKey, PEM_read_bio_PrivateKey, (EVP_PKEY_get_Key_fn) nullptr, pPrivateKeyStream, privateKeyPassphrase))
{ {
poco_check_ptr(_pEVPPKey); poco_check_ptr(_pEVPPKey);
return; // private key is enough return; // private key is enough
} }
// no private key, this must be public key only, otherwise throw // no private key, this must be public key only, otherwise throw
if (!loadKey(&_pEVPPKey, PEM_read_bio_PUBKEY, (EVP_PKEY_get_Key_fn)0, pPublicKeyStream)) if (!loadKey(&_pEVPPKey, PEM_read_bio_PUBKEY, (EVP_PKEY_get_Key_fn) nullptr, pPublicKeyStream)) {
{
std::string msg = "EVPPKey(istream* ,istream* const string&)\n"; std::string msg = "EVPPKey(istream* ,istream* const string&)\n";
throw OpenSSLException(getError(msg)); throw OpenSSLException(getError(msg));
} }
@@ -416,13 +409,13 @@ void EVPPKey::save(const std::string& publicKeyFile, const std::string& privateK
int rc = 0; int rc = 0;
if (privateKeyPassphrase.empty()) if (privateKeyPassphrase.empty())
{ {
rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, 0, 0, 0, 0, 0); rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, nullptr, nullptr, 0, nullptr, nullptr);
} }
else else
{ {
rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, EVP_des_ede3_cbc(), rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, EVP_des_ede3_cbc(),
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())), reinterpret_cast<unsigned char *>( const_cast<char *>( privateKeyPassphrase.c_str())),
static_cast<int>(privateKeyPassphrase.length()), 0, 0); static_cast<int>(privateKeyPassphrase.length()), nullptr, nullptr);
} }
if (!rc) if (!rc)
{ {
@@ -483,11 +476,11 @@ void EVPPKey::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStre
} }
int rc = 0; int rc = 0;
if (privateKeyPassphrase.empty()) if (privateKeyPassphrase.empty())
rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, 0, 0, 0, 0, 0); rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, nullptr, nullptr, 0, nullptr, nullptr);
else else
rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, EVP_des_ede3_cbc(), rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, EVP_des_ede3_cbc(),
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())), reinterpret_cast<unsigned char *>( const_cast<char *>(privateKeyPassphrase.c_str())),
static_cast<int>(privateKeyPassphrase.length()), 0, 0); static_cast<int>(privateKeyPassphrase.length()), nullptr, nullptr);
if (!rc) if (!rc)
{ {
std::string msg = "EVPPKey::save(ostream*, ostream*, const string&)\n"; std::string msg = "EVPPKey::save(ostream*, ostream*, const string&)\n";

View File

@@ -65,7 +65,7 @@ void Envelope::addKey(const EVPPKey& key)
const Envelope::ByteVec& Envelope::seal(const ByteVec& plainData) const Envelope::ByteVec& Envelope::seal(const ByteVec& plainData)
{ {
std::vector<Byte*> pEncKeys(_encKeys.size(), 0); std::vector<Byte *> pEncKeys(_encKeys.size(), nullptr);
std::vector<int> encKeysSizes(_encKeys.size(), 0); std::vector<int> encKeysSizes(_encKeys.size(), 0);
int i = 0; int i = 0;
for (const auto& k : _encKeys) for (const auto& k : _encKeys)
@@ -153,7 +153,7 @@ void Envelope::handleErrors(std::string&& msg)
while ((err = ERR_get_error())) while ((err = ERR_get_error()))
{ {
if (!msg.empty()) msg.append("\n"); if (!msg.empty()) msg.append("\n");
msg.append(ERR_error_string(err, 0)); msg.append(ERR_error_string(err, nullptr));
} }
throw CryptoException(msg); throw CryptoException(msg);
} }

View File

@@ -66,8 +66,8 @@ Poco::FastMutex* OpenSSLInitializer::_mutexes(0);
#endif #endif
#if OPENSSL_VERSION_NUMBER >= 0x30000000L #if OPENSSL_VERSION_NUMBER >= 0x30000000L
OSSL_PROVIDER* OpenSSLInitializer::_defaultProvider(0); OSSL_PROVIDER* OpenSSLInitializer::_defaultProvider(nullptr);
OSSL_PROVIDER* OpenSSLInitializer::_legacyProvider(0); OSSL_PROVIDER* OpenSSLInitializer::_legacyProvider(nullptr);
#endif #endif
@@ -95,9 +95,9 @@ void OpenSSLInitializer::initialize()
if (++_rc == 1) if (++_rc == 1)
{ {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L #if OPENSSL_VERSION_NUMBER >= 0x10100000L
CONF_modules_load(NULL, NULL, 0); CONF_modules_load(nullptr, nullptr, 0);
#else #else
OPENSSL_config(NULL); OPENSSL_config(nullptr);
#endif #endif
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L
@@ -131,12 +131,12 @@ void OpenSSLInitializer::initialize()
#if OPENSSL_VERSION_NUMBER >= 0x30000000L #if OPENSSL_VERSION_NUMBER >= 0x30000000L
if (!_defaultProvider) if (!_defaultProvider)
{ {
_defaultProvider = OSSL_PROVIDER_load(NULL, "default"); _defaultProvider = OSSL_PROVIDER_load(nullptr, "default");
if (!_defaultProvider) throw CryptoException("Failed to load OpenSSL default provider"); if (!_defaultProvider) throw CryptoException("Failed to load OpenSSL default provider");
} }
if (!_legacyProvider) if (!_legacyProvider)
{ {
_legacyProvider = OSSL_PROVIDER_load(NULL, "legacy"); _legacyProvider = OSSL_PROVIDER_load(nullptr, "legacy");
// Note: use haveLegacyProvider() to check if legacy provider has been loaded // Note: use haveLegacyProvider() to check if legacy provider has been loaded
} }
#endif #endif

View File

@@ -19,7 +19,6 @@
#include "Poco/Crypto/PKCS12Container.h" #include "Poco/Crypto/PKCS12Container.h"
#include "Poco/NumberFormatter.h"
#include "Poco/StreamCopier.h" #include "Poco/StreamCopier.h"
#include <sstream> #include <sstream>
#include <openssl/err.h> #include <openssl/err.h>
@@ -29,7 +28,7 @@ namespace Poco {
namespace Crypto { namespace Crypto {
PKCS12Container::PKCS12Container(std::istream& istr, const std::string& password): _pKey(0) PKCS12Container::PKCS12Container(std::istream& istr, const std::string& password) : _pKey(nullptr)
{ {
std::ostringstream ostr; std::ostringstream ostr;
Poco::StreamCopier::copyStream(istr, ostr); Poco::StreamCopier::copyStream(istr, ostr);
@@ -38,7 +37,7 @@ PKCS12Container::PKCS12Container(std::istream& istr, const std::string& password
BIO *pBIO = BIO_new_mem_buf(const_cast<char*>(cont.data()), static_cast<int>(cont.size())); BIO *pBIO = BIO_new_mem_buf(const_cast<char*>(cont.data()), static_cast<int>(cont.size()));
if (pBIO) if (pBIO)
{ {
PKCS12* pPKCS12 = 0; PKCS12* pPKCS12 = nullptr;
d2i_PKCS12_bio(pBIO, &pPKCS12); d2i_PKCS12_bio(pBIO, &pPKCS12);
BIO_free(pBIO); BIO_free(pBIO);
if (!pPKCS12) throw OpenSSLException("PKCS12Container(istream&, const string&)"); if (!pPKCS12) throw OpenSSLException("PKCS12Container(istream&, const string&)");
@@ -51,12 +50,12 @@ PKCS12Container::PKCS12Container(std::istream& istr, const std::string& password
} }
PKCS12Container::PKCS12Container(const std::string& path, const std::string& password): _pKey(0) PKCS12Container::PKCS12Container(const std::string& path, const std::string& password) : _pKey(nullptr)
{ {
FILE* pFile = fopen(path.c_str(), "rb"); FILE* pFile = fopen(path.c_str(), "rb");
if (pFile) if (pFile)
{ {
PKCS12* pPKCS12 = d2i_PKCS12_fp(pFile, NULL); PKCS12* pPKCS12 = d2i_PKCS12_fp(pFile, nullptr);
fclose (pFile); fclose (pFile);
if (!pPKCS12) throw OpenSSLException("PKCS12Container(const string&, const string&)"); if (!pPKCS12) throw OpenSSLException("PKCS12Container(const string&, const string&)");
load(pPKCS12, password); load(pPKCS12, password);
@@ -145,8 +144,8 @@ void PKCS12Container::load(PKCS12* pPKCS12, const std::string& password)
{ {
if (pPKCS12) if (pPKCS12)
{ {
X509* pCert = 0; X509* pCert = nullptr;
STACK_OF(X509)* pCA = 0; STACK_OF(X509)* pCA = nullptr;
if (PKCS12_parse(pPKCS12, password.c_str(), &_pKey, &pCert, &pCA)) if (PKCS12_parse(pPKCS12, password.c_str(), &_pKey, &pCert, &pCA))
{ {
if (pCert) if (pCert)

View File

@@ -35,7 +35,7 @@ namespace
{ {
if (!msg.empty()) if (!msg.empty())
msg.append("; "); msg.append("; ");
msg.append(ERR_error_string(err, 0)); msg.append(ERR_error_string(err, nullptr));
} }
throw Poco::IOException(msg); throw Poco::IOException(msg);
@@ -90,7 +90,7 @@ namespace
_pRSA(pRSA), _pRSA(pRSA),
_paddingMode(paddingMode), _paddingMode(paddingMode),
_pos(0), _pos(0),
_pBuf(0) _pBuf(nullptr)
{ {
_pBuf = new unsigned char[blockSize()]; _pBuf = new unsigned char[blockSize()];
} }
@@ -223,11 +223,11 @@ namespace
}; };
RSADecryptImpl::RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode): RSADecryptImpl::RSADecryptImpl(const RSA *pRSA, RSAPaddingMode paddingMode) :
_pRSA(pRSA), _pRSA(pRSA),
_paddingMode(paddingMode), _paddingMode(paddingMode),
_pos(0), _pos(0),
_pBuf(0) _pBuf(nullptr)
{ {
_pBuf = new unsigned char[blockSize()]; _pBuf = new unsigned char[blockSize()];
} }

View File

@@ -15,9 +15,7 @@
#include "Poco/Crypto/RSAKeyImpl.h" #include "Poco/Crypto/RSAKeyImpl.h"
#include "Poco/Crypto/X509Certificate.h" #include "Poco/Crypto/X509Certificate.h"
#include "Poco/Crypto/PKCS12Container.h" #include "Poco/Crypto/PKCS12Container.h"
#include "Poco/FileStream.h"
#include "Poco/StreamCopier.h" #include "Poco/StreamCopier.h"
#include <sstream>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/rsa.h> #include <openssl/rsa.h>
#include <openssl/evp.h> #include <openssl/evp.h>
@@ -38,7 +36,7 @@ RSAKeyImpl::RSAKeyImpl(const EVPPKey& key):
RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert): RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert):
KeyPairImpl("rsa", KT_RSA_IMPL), KeyPairImpl("rsa", KT_RSA_IMPL),
_pRSA(0) _pRSA(nullptr)
{ {
const X509* pCert = cert.certificate(); const X509* pCert = cert.certificate();
EVP_PKEY* pKey = X509_get_pubkey(const_cast<X509*>(pCert)); EVP_PKEY* pKey = X509_get_pubkey(const_cast<X509*>(pCert));
@@ -54,24 +52,24 @@ RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert):
RSAKeyImpl::RSAKeyImpl(const PKCS12Container& cont): RSAKeyImpl::RSAKeyImpl(const PKCS12Container& cont):
KeyPairImpl("rsa", KT_RSA_IMPL), KeyPairImpl("rsa", KT_RSA_IMPL),
_pRSA(0) _pRSA(nullptr)
{ {
EVPPKey key = cont.getKey(); EVPPKey key = cont.getKey();
_pRSA = EVP_PKEY_get1_RSA(key); _pRSA = EVP_PKEY_get1_RSA(key);
} }
RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent): KeyPairImpl("rsa", KT_RSA_IMPL), RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent) : KeyPairImpl("rsa", KT_RSA_IMPL),
_pRSA(0) _pRSA(nullptr)
{ {
_pRSA = RSA_new(); _pRSA = RSA_new();
int ret = 0; int ret = 0;
BIGNUM* bn = 0; BIGNUM* bn = nullptr;
try try
{ {
bn = BN_new(); bn = BN_new();
BN_set_word(bn, exponent); BN_set_word(bn, exponent);
ret = RSA_generate_key_ex(_pRSA, keyLength, bn, 0); ret = RSA_generate_key_ex(_pRSA, keyLength, bn, nullptr);
BN_free(bn); BN_free(bn);
} }
catch (...) catch (...)
@@ -83,12 +81,11 @@ RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent): KeyPairImpl("rsa"
} }
RSAKeyImpl::RSAKeyImpl(const std::string& publicKeyFile, RSAKeyImpl::RSAKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase):
const std::string& privateKeyFile, KeyPairImpl("rsa", KT_RSA_IMPL),
const std::string& privateKeyPassphrase): KeyPairImpl("rsa", KT_RSA_IMPL), _pRSA(nullptr)
_pRSA(0)
{ {
poco_assert_dbg(_pRSA == 0); poco_assert_dbg(_pRSA == nullptr);
_pRSA = RSA_new(); _pRSA = RSA_new();
if (!publicKeyFile.empty()) if (!publicKeyFile.empty())
@@ -98,14 +95,14 @@ RSAKeyImpl::RSAKeyImpl(const std::string& publicKeyFile,
int rc = BIO_read_filename(bio, publicKeyFile.c_str()); int rc = BIO_read_filename(bio, publicKeyFile.c_str());
if (rc) if (rc)
{ {
RSA* pubKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0); RSA* pubKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, nullptr, nullptr);
if (!pubKey) if (!pubKey)
{ {
int rc = BIO_reset(bio); int rc = BIO_reset(bio);
// BIO_reset() normally returns 1 for success and 0 or -1 for failure. // BIO_reset() normally returns 1 for success and 0 or -1 for failure.
// File BIOs are an exception, they return 0 for success and -1 for failure. // File BIOs are an exception, they return 0 for success and -1 for failure.
if (rc != 0) throw Poco::FileException("Failed to load public key", publicKeyFile); if (rc != 0) throw Poco::FileException("Failed to load public key", publicKeyFile);
pubKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, 0, 0); pubKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, nullptr, nullptr);
} }
BIO_free(bio); BIO_free(bio);
if (!pubKey) if (!pubKey)
@@ -128,11 +125,11 @@ RSAKeyImpl::RSAKeyImpl(const std::string& publicKeyFile,
int rc = BIO_read_filename(bio, privateKeyFile.c_str()); int rc = BIO_read_filename(bio, privateKeyFile.c_str());
if (rc) if (rc)
{ {
RSA* privKey = 0; RSA* privKey = nullptr;
if (privateKeyPassphrase.empty()) if (privateKeyPassphrase.empty())
privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, 0); privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, nullptr, nullptr);
else else
privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, const_cast<char*>(privateKeyPassphrase.c_str())); privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, nullptr, const_cast<char *>( privateKeyPassphrase.c_str()));
BIO_free(bio); BIO_free(bio);
if (!privKey) if (!privKey)
{ {
@@ -149,12 +146,11 @@ RSAKeyImpl::RSAKeyImpl(const std::string& publicKeyFile,
} }
RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream, RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase):
std::istream* pPrivateKeyStream, KeyPairImpl("rsa", KT_RSA_IMPL),
const std::string& privateKeyPassphrase): KeyPairImpl("rsa", KT_RSA_IMPL), _pRSA(nullptr)
_pRSA(0)
{ {
poco_assert_dbg(_pRSA == 0); poco_assert_dbg(_pRSA == nullptr);
_pRSA = RSA_new(); _pRSA = RSA_new();
if (pPublicKeyStream) if (pPublicKeyStream)
@@ -163,14 +159,14 @@ RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream,
Poco::StreamCopier::copyToString(*pPublicKeyStream, publicKeyData); Poco::StreamCopier::copyToString(*pPublicKeyStream, publicKeyData);
BIO* bio = BIO_new_mem_buf(const_cast<char*>(publicKeyData.data()), static_cast<int>(publicKeyData.size())); BIO* bio = BIO_new_mem_buf(const_cast<char*>(publicKeyData.data()), static_cast<int>(publicKeyData.size()));
if (!bio) throw Poco::IOException("Cannot create BIO for reading public key"); if (!bio) throw Poco::IOException("Cannot create BIO for reading public key");
RSA* publicKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0); RSA* publicKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, nullptr, nullptr);
if (!publicKey) if (!publicKey)
{ {
int rc = BIO_reset(bio); int rc = BIO_reset(bio);
// BIO_reset() normally returns 1 for success and 0 or -1 for failure. // BIO_reset() normally returns 1 for success and 0 or -1 for failure.
// File BIOs are an exception, they return 0 for success and -1 for failure. // File BIOs are an exception, they return 0 for success and -1 for failure.
if (rc != 1) throw Poco::FileException("Failed to load public key"); if (rc != 1) throw Poco::FileException("Failed to load public key");
publicKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, 0, 0); publicKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, nullptr, nullptr);
} }
BIO_free(bio); BIO_free(bio);
if (!publicKey) if (!publicKey)
@@ -186,11 +182,11 @@ RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream,
Poco::StreamCopier::copyToString(*pPrivateKeyStream, privateKeyData); Poco::StreamCopier::copyToString(*pPrivateKeyStream, privateKeyData);
BIO* bio = BIO_new_mem_buf(const_cast<char*>(privateKeyData.data()), static_cast<int>(privateKeyData.size())); BIO* bio = BIO_new_mem_buf(const_cast<char*>(privateKeyData.data()), static_cast<int>(privateKeyData.size()));
if (!bio) throw Poco::IOException("Cannot create BIO for reading private key"); if (!bio) throw Poco::IOException("Cannot create BIO for reading private key");
RSA* privateKey = 0; RSA* privateKey = nullptr;
if (privateKeyPassphrase.empty()) if (privateKeyPassphrase.empty())
privateKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, 0); privateKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, nullptr, nullptr);
else else
privateKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, const_cast<char*>(privateKeyPassphrase.c_str())); privateKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, nullptr, const_cast<char *>(privateKeyPassphrase.c_str()));
BIO_free(bio); BIO_free(bio);
if (!privateKey) if (!privateKey)
{ {
@@ -210,7 +206,7 @@ RSAKeyImpl::~RSAKeyImpl()
void RSAKeyImpl::freeRSA() void RSAKeyImpl::freeRSA()
{ {
if (_pRSA) RSA_free(_pRSA); if (_pRSA) RSA_free(_pRSA);
_pRSA = 0; _pRSA = nullptr;
} }
@@ -223,9 +219,9 @@ int RSAKeyImpl::size() const
RSAKeyImpl::ByteVec RSAKeyImpl::modulus() const RSAKeyImpl::ByteVec RSAKeyImpl::modulus() const
{ {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L #if OPENSSL_VERSION_NUMBER >= 0x10100000L
const BIGNUM* n = 0; const BIGNUM* n = nullptr;
const BIGNUM* e = 0; const BIGNUM* e = nullptr;
const BIGNUM* d = 0; const BIGNUM* d = nullptr;
RSA_get0_key(_pRSA, &n, &e, &d); RSA_get0_key(_pRSA, &n, &e, &d);
return convertToByteVec(n); return convertToByteVec(n);
#else #else
@@ -237,9 +233,9 @@ RSAKeyImpl::ByteVec RSAKeyImpl::modulus() const
RSAKeyImpl::ByteVec RSAKeyImpl::encryptionExponent() const RSAKeyImpl::ByteVec RSAKeyImpl::encryptionExponent() const
{ {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L #if OPENSSL_VERSION_NUMBER >= 0x10100000L
const BIGNUM* n = 0; const BIGNUM* n = nullptr;
const BIGNUM* e = 0; const BIGNUM* e = nullptr;
const BIGNUM* d = 0; const BIGNUM* d = nullptr;
RSA_get0_key(_pRSA, &n, &e, &d); RSA_get0_key(_pRSA, &n, &e, &d);
return convertToByteVec(e); return convertToByteVec(e);
#else #else
@@ -251,9 +247,9 @@ RSAKeyImpl::ByteVec RSAKeyImpl::encryptionExponent() const
RSAKeyImpl::ByteVec RSAKeyImpl::decryptionExponent() const RSAKeyImpl::ByteVec RSAKeyImpl::decryptionExponent() const
{ {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L #if OPENSSL_VERSION_NUMBER >= 0x10100000L
const BIGNUM* n = 0; const BIGNUM* n = nullptr;
const BIGNUM* e = 0; const BIGNUM* e = nullptr;
const BIGNUM* d = 0; const BIGNUM* d = nullptr;
RSA_get0_key(_pRSA, &n, &e, &d); RSA_get0_key(_pRSA, &n, &e, &d);
return convertToByteVec(d); return convertToByteVec(d);
#else #else
@@ -297,11 +293,11 @@ void RSAKeyImpl::save(const std::string& publicKeyFile,
{ {
int rc = 0; int rc = 0;
if (privateKeyPassphrase.empty()) if (privateKeyPassphrase.empty())
rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, 0, 0, 0, 0, 0); rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, nullptr, nullptr, 0, nullptr, nullptr);
else else
rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(), rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(),
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())), reinterpret_cast<unsigned char *>( const_cast<char *>( privateKeyPassphrase.c_str())),
static_cast<int>(privateKeyPassphrase.length()), 0, 0); static_cast<int>(privateKeyPassphrase.length()), nullptr, nullptr);
if (!rc) throw Poco::FileException("Failed to write private key to file", privateKeyFile); if (!rc) throw Poco::FileException("Failed to write private key to file", privateKeyFile);
} }
else throw Poco::CreateFileException("Cannot create private key file", privateKeyFile); else throw Poco::CreateFileException("Cannot create private key file", privateKeyFile);
@@ -341,11 +337,12 @@ void RSAKeyImpl::save(std::ostream* pPublicKeyStream,
if (!bio) throw Poco::IOException("Cannot create BIO for writing public key"); if (!bio) throw Poco::IOException("Cannot create BIO for writing public key");
int rc = 0; int rc = 0;
if (privateKeyPassphrase.empty()) if (privateKeyPassphrase.empty())
rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, 0, 0, 0, 0, 0); rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, nullptr, nullptr, 0, nullptr, nullptr);
else else
rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(), rc = PEM_write_bio_RSAPrivateKey(bio,
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())), _pRSA, EVP_des_ede3_cbc(),
static_cast<int>(privateKeyPassphrase.length()), 0, 0); reinterpret_cast<unsigned char *>( const_cast<char *>(privateKeyPassphrase.c_str())),
static_cast<int>(privateKeyPassphrase.length()), nullptr, nullptr);
if (!rc) if (!rc)
{ {
BIO_free(bio); BIO_free(bio);

View File

@@ -15,7 +15,6 @@
#include "Poco/Crypto/X509Certificate.h" #include "Poco/Crypto/X509Certificate.h"
#include "Poco/Crypto/CryptoException.h" #include "Poco/Crypto/CryptoException.h"
#include "Poco/StreamCopier.h" #include "Poco/StreamCopier.h"
#include "Poco/String.h"
#include "Poco/DateTimeParser.h" #include "Poco/DateTimeParser.h"
#include "Poco/Format.h" #include "Poco/Format.h"
#include <sstream> #include <sstream>
@@ -41,15 +40,13 @@ namespace Poco {
namespace Crypto { namespace Crypto {
X509Certificate::X509Certificate(std::istream& istr): X509Certificate::X509Certificate(std::istream& istr) : _pCert(nullptr)
_pCert(0)
{ {
load(istr); load(istr);
} }
X509Certificate::X509Certificate(const std::string& path): X509Certificate::X509Certificate(const std::string& path) : _pCert(nullptr)
_pCert(0)
{ {
load(path); load(path);
} }
@@ -147,7 +144,7 @@ void X509Certificate::load(std::istream& istr)
BIO *pBIO = BIO_new_mem_buf(const_cast<char*>(cert.data()), static_cast<int>(cert.size())); BIO *pBIO = BIO_new_mem_buf(const_cast<char*>(cert.data()), static_cast<int>(cert.size()));
if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate"); if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate");
_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0); _pCert = PEM_read_bio_X509(pBIO, nullptr, nullptr, nullptr);
BIO_free(pBIO); BIO_free(pBIO);
if (!_pCert) throw Poco::IOException("Failed to load certificate from stream"); if (!_pCert) throw Poco::IOException("Failed to load certificate from stream");
@@ -168,7 +165,7 @@ void X509Certificate::load(const std::string& path)
throw Poco::OpenFileException("Cannot open certificate file for reading", path); throw Poco::OpenFileException("Cannot open certificate file for reading", path);
} }
_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0); _pCert = PEM_read_bio_X509(pBIO, nullptr, nullptr, nullptr);
BIO_free(pBIO); BIO_free(pBIO);
if (!_pCert) throw Poco::ReadFileException("Faild to load certificate from", path); if (!_pCert) throw Poco::ReadFileException("Faild to load certificate from", path);
@@ -239,7 +236,7 @@ void X509Certificate::init()
{ {
_issuerName = _X509_NAME_oneline_utf8(X509_get_issuer_name(_pCert)); _issuerName = _X509_NAME_oneline_utf8(X509_get_issuer_name(_pCert));
_subjectName = _X509_NAME_oneline_utf8(X509_get_subject_name(_pCert)); _subjectName = _X509_NAME_oneline_utf8(X509_get_subject_name(_pCert));
BIGNUM* pBN = ASN1_INTEGER_to_BN(X509_get_serialNumber(const_cast<X509*>(_pCert)), 0); BIGNUM* pBN = ASN1_INTEGER_to_BN(X509_get_serialNumber(const_cast<X509 *>(_pCert)), nullptr);
if (pBN) if (pBN)
{ {
char* pSN = BN_bn2hex(pBN); char* pSN = BN_bn2hex(pBN);
@@ -286,8 +283,7 @@ std::string X509Certificate::subjectName(NID nid) const
void X509Certificate::extractNames(std::string& cmnName, std::set<std::string>& domainNames) const void X509Certificate::extractNames(std::string& cmnName, std::set<std::string>& domainNames) const
{ {
domainNames.clear(); domainNames.clear();
if (STACK_OF(GENERAL_NAME)* names = static_cast<STACK_OF(GENERAL_NAME)*>(X509_get_ext_d2i(_pCert, NID_subject_alt_name, 0, 0))) if (STACK_OF(GENERAL_NAME) *names = static_cast<STACK_OF(GENERAL_NAME) *>( X509_get_ext_d2i(_pCert, NID_subject_alt_name, nullptr, nullptr))) {
{
for (int i = 0; i < sk_GENERAL_NAME_num(names); ++i) for (int i = 0; i < sk_GENERAL_NAME_num(names); ++i)
{ {
const GENERAL_NAME* name = sk_GENERAL_NAME_value(names, i); const GENERAL_NAME* name = sk_GENERAL_NAME_value(names, i);
@@ -416,8 +412,9 @@ X509Certificate::List X509Certificate::readPEM(const std::string& pemFileName)
{ {
List caCertList; List caCertList;
BIO* pBIO = BIO_new_file(pemFileName.c_str(), "r"); BIO* pBIO = BIO_new_file(pemFileName.c_str(), "r");
if (pBIO == NULL) throw OpenFileException(Poco::format("X509Certificate::readPEM(%s)", pemFileName)); if (pBIO == nullptr)
X509* x = PEM_read_bio_X509(pBIO, NULL, 0, NULL); throw OpenFileException(Poco::format("X509Certificate::readPEM(%s)", pemFileName));
X509* x = PEM_read_bio_X509(pBIO, nullptr, nullptr, nullptr);
if (!x) if (!x)
{ {
BIO_free(pBIO); BIO_free(pBIO);
@@ -426,7 +423,7 @@ X509Certificate::List X509Certificate::readPEM(const std::string& pemFileName)
while (x) while (x)
{ {
caCertList.push_back(X509Certificate(x)); caCertList.push_back(X509Certificate(x));
x = PEM_read_bio_X509(pBIO, NULL, 0, NULL); x = PEM_read_bio_X509(pBIO, nullptr, nullptr, nullptr);
} }
BIO_free(pBIO); BIO_free(pBIO);
return caCertList; return caCertList;
@@ -436,7 +433,7 @@ X509Certificate::List X509Certificate::readPEM(const std::string& pemFileName)
void X509Certificate::writePEM(const std::string& pemFileName, const List& list) void X509Certificate::writePEM(const std::string& pemFileName, const List& list)
{ {
BIO* pBIO = BIO_new_file(pemFileName.c_str(), "a"); BIO* pBIO = BIO_new_file(pemFileName.c_str(), "a");
if (pBIO == NULL) throw OpenFileException(Poco::format("X509Certificate::writePEM(%s)", pemFileName)); if (pBIO == nullptr) throw OpenFileException(Poco::format("X509Certificate::writePEM(%s)", pemFileName));
List::const_iterator it = list.begin(); List::const_iterator it = list.begin();
List::const_iterator end = list.end(); List::const_iterator end = list.end();
for (; it != end; ++it) for (; it != end; ++it)

View File

@@ -123,7 +123,7 @@ void EVPTest::testRSAEVPPKey()
BIO* bioPriv1 = BIO_new(BIO_s_mem()); BIO* bioPriv1 = BIO_new(BIO_s_mem());
BIO* bioPub1 = BIO_new(BIO_s_mem()); BIO* bioPub1 = BIO_new(BIO_s_mem());
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv1, *pKey, NULL, NULL, 0, 0, NULL)); assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv1, *pKey, nullptr, nullptr, 0, nullptr, nullptr));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub1, *pKey)); assertTrue (0 != PEM_write_bio_PUBKEY(bioPub1, *pKey));
char* pPrivData1; char* pPrivData1;
long sizePriv1 = BIO_get_mem_data(bioPriv1, &pPrivData1); long sizePriv1 = BIO_get_mem_data(bioPriv1, &pPrivData1);
@@ -138,7 +138,7 @@ void EVPTest::testRSAEVPPKey()
BIO* bioPriv2 = BIO_new(BIO_s_mem()); BIO* bioPriv2 = BIO_new(BIO_s_mem());
BIO* bioPub2 = BIO_new(BIO_s_mem()); BIO* bioPub2 = BIO_new(BIO_s_mem());
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey, NULL, NULL, 0, 0, NULL)); assertTrue ( 0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey, nullptr, nullptr, 0, nullptr, nullptr));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey)); assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey));
char* pPrivData2; char* pPrivData2;
long sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2); long sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
@@ -158,7 +158,7 @@ void EVPTest::testRSAEVPPKey()
assertTrue (evpPKey2.type() == EVP_PKEY_RSA); assertTrue (evpPKey2.type() == EVP_PKEY_RSA);
bioPriv2 = BIO_new(BIO_s_mem()); bioPriv2 = BIO_new(BIO_s_mem());
bioPub2 = BIO_new(BIO_s_mem()); bioPub2 = BIO_new(BIO_s_mem());
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey2, NULL, NULL, 0, 0, NULL)); assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey2, nullptr, nullptr, 0, nullptr, nullptr));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey2)); assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey2));
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2); sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2); sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
@@ -176,7 +176,7 @@ void EVPTest::testRSAEVPPKey()
assertTrue (evpPKey3.type() == EVP_PKEY_RSA); assertTrue (evpPKey3.type() == EVP_PKEY_RSA);
bioPriv2 = BIO_new(BIO_s_mem()); bioPriv2 = BIO_new(BIO_s_mem());
bioPub2 = BIO_new(BIO_s_mem()); bioPub2 = BIO_new(BIO_s_mem());
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey3, NULL, NULL, 0, 0, NULL)); assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey3, nullptr, nullptr, 0, nullptr, nullptr));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey3)); assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey3));
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2); sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2); sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
@@ -229,7 +229,7 @@ void EVPTest::testRSAEVPSaveLoadStream()
assertTrue (strPub2.str() == pubKey); assertTrue (strPub2.str() == pubKey);
std::istringstream iPriv2(strPriv2.str()); std::istringstream iPriv2(strPriv2.str());
EVPPKey key3(0, &iPriv2, "testpwd"); EVPPKey key3(nullptr, &iPriv2, "testpwd");
std::ostringstream strPub3; std::ostringstream strPub3;
key3.save(&strPub3); key3.save(&strPub3);
assertTrue (strPub3.str() == pubKey); assertTrue (strPub3.str() == pubKey);
@@ -261,7 +261,7 @@ void EVPTest::testRSAEVPSaveLoadStreamNoPass()
assertTrue (!(key2 == keyNE)); assertTrue (!(key2 == keyNE));
std::istringstream iPriv2(privKey); std::istringstream iPriv2(privKey);
EVPPKey key3(0, &iPriv2); EVPPKey key3(nullptr, &iPriv2);
std::ostringstream strPub3; std::ostringstream strPub3;
key3.save(&strPub3); key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str(); std::string pubFromPrivate = strPub3.str();
@@ -277,7 +277,7 @@ void EVPTest::testECEVPPKey()
if (!curveName.empty()) if (!curveName.empty())
{ {
EVPPKey* pKey = new EVPPKey(curveName); EVPPKey* pKey = new EVPPKey(curveName);
assertTrue (pKey != 0); assertTrue(pKey != nullptr);
assertTrue (!pKey->isSupported(0)); assertTrue (!pKey->isSupported(0));
assertTrue (!pKey->isSupported(-1)); assertTrue (!pKey->isSupported(-1));
assertTrue (pKey->isSupported(pKey->type())); assertTrue (pKey->isSupported(pKey->type()));
@@ -285,7 +285,7 @@ void EVPTest::testECEVPPKey()
BIO* bioPriv1 = BIO_new(BIO_s_mem()); BIO* bioPriv1 = BIO_new(BIO_s_mem());
BIO* bioPub1 = BIO_new(BIO_s_mem()); BIO* bioPub1 = BIO_new(BIO_s_mem());
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv1, *pKey, NULL, NULL, 0, 0, NULL)); assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv1, *pKey, nullptr, nullptr, 0, nullptr, nullptr));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub1, *pKey)); assertTrue (0 != PEM_write_bio_PUBKEY(bioPub1, *pKey));
char* pPrivData1; char* pPrivData1;
long sizePriv1 = BIO_get_mem_data(bioPriv1, &pPrivData1); long sizePriv1 = BIO_get_mem_data(bioPriv1, &pPrivData1);
@@ -300,7 +300,7 @@ void EVPTest::testECEVPPKey()
BIO* bioPriv2 = BIO_new(BIO_s_mem()); BIO* bioPriv2 = BIO_new(BIO_s_mem());
BIO* bioPub2 = BIO_new(BIO_s_mem()); BIO* bioPub2 = BIO_new(BIO_s_mem());
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey, NULL, NULL, 0, 0, NULL)); assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey, nullptr, nullptr, 0, nullptr, nullptr));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey)); assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey));
char* pPrivData2; char* pPrivData2;
long sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2); long sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
@@ -320,7 +320,7 @@ void EVPTest::testECEVPPKey()
assertTrue (evpPKey2.type() == EVP_PKEY_EC); assertTrue (evpPKey2.type() == EVP_PKEY_EC);
bioPriv2 = BIO_new(BIO_s_mem()); bioPriv2 = BIO_new(BIO_s_mem());
bioPub2 = BIO_new(BIO_s_mem()); bioPub2 = BIO_new(BIO_s_mem());
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey2, NULL, NULL, 0, 0, NULL)); assertTrue (0 != PEM_write_bio_PrivateKey( bioPriv2, evpPKey2, nullptr, nullptr, 0, nullptr, nullptr));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey2)); assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey2));
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2); sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2); sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
@@ -338,7 +338,7 @@ void EVPTest::testECEVPPKey()
assertTrue (evpPKey3.type() == EVP_PKEY_EC); assertTrue (evpPKey3.type() == EVP_PKEY_EC);
bioPriv2 = BIO_new(BIO_s_mem()); bioPriv2 = BIO_new(BIO_s_mem());
bioPub2 = BIO_new(BIO_s_mem()); bioPub2 = BIO_new(BIO_s_mem());
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey3, NULL, NULL, 0, 0, NULL)); assertTrue(0 != PEM_write_bio_PrivateKey( bioPriv2, evpPKey3, nullptr, nullptr, 0, nullptr, nullptr));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey3)); assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey3));
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2); sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2); sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
@@ -402,7 +402,7 @@ void EVPTest::testECEVPSaveLoadStream()
assertTrue (strPub2.str() == pubKey); assertTrue (strPub2.str() == pubKey);
std::istringstream iPriv2(strPriv2.str()); std::istringstream iPriv2(strPriv2.str());
EVPPKey key3(0, &iPriv2, "testpwd"); EVPPKey key3(nullptr, &iPriv2, "testpwd");
std::ostringstream strPub3; std::ostringstream strPub3;
key3.save(&strPub3); key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str(); std::string pubFromPrivate = strPub3.str();
@@ -458,7 +458,7 @@ void EVPTest::testECEVPSaveLoadStreamNoPass()
assertTrue (strPriv2.str() == privKey); assertTrue (strPriv2.str() == privKey);
std::istringstream iPriv2(privKey); std::istringstream iPriv2(privKey);
EVPPKey key3(0, &iPriv2); EVPPKey key3(nullptr, &iPriv2);
std::ostringstream strPub3; std::ostringstream strPub3;
key3.save(&strPub3); key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str(); std::string pubFromPrivate = strPub3.str();
@@ -577,7 +577,7 @@ void EVPTest::testRSAEVPKeyFromX509()
X509Certificate cert(str); X509Certificate cert(str);
EVPPKey publicKey(cert); EVPPKey publicKey(cert);
std::istringstream str2(anyPemRSA); std::istringstream str2(anyPemRSA);
EVPPKey privateKey(0, &str2, "test"); EVPPKey privateKey(nullptr, &str2, "test");
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey); Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey);
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey); Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey);
std::string val("lets do some encryption"); std::string val("lets do some encryption");
@@ -631,7 +631,7 @@ void EVPTest::testRSAEVPKeyByLength()
assertTrue (!(key2 == keyNE)); assertTrue (!(key2 == keyNE));
std::istringstream iPriv2(privKey); std::istringstream iPriv2(privKey);
EVPPKey key3(0, &iPriv2); EVPPKey key3(nullptr, &iPriv2);
std::ostringstream strPub3; std::ostringstream strPub3;
key3.save(&strPub3); key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str(); std::string pubFromPrivate = strPub3.str();
@@ -672,7 +672,7 @@ void EVPTest::testECEVPKeyByLength()
assertTrue (!(key2 == keyNE)); assertTrue (!(key2 == keyNE));
std::istringstream iPriv2(privKey); std::istringstream iPriv2(privKey);
EVPPKey key3(0, &iPriv2); EVPPKey key3(nullptr, &iPriv2);
std::ostringstream strPub3; std::ostringstream strPub3;
key3.save(&strPub3); key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str(); std::string pubFromPrivate = strPub3.str();

View File

@@ -101,7 +101,7 @@ void RSATest::testNewKeys()
RSAKey key2(&iPub, &iPriv, "testpwd"); RSAKey key2(&iPub, &iPriv, "testpwd");
std::istringstream iPriv2(privKey); std::istringstream iPriv2(privKey);
RSAKey key3(0, &iPriv2, "testpwd"); RSAKey key3(nullptr, &iPriv2, "testpwd");
std::ostringstream strPub3; std::ostringstream strPub3;
key3.save(&strPub3); key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str(); std::string pubFromPrivate = strPub3.str();
@@ -124,7 +124,7 @@ void RSATest::testNewKeysNoPassphrase()
RSAKey key2(&iPub, &iPriv); RSAKey key2(&iPub, &iPriv);
std::istringstream iPriv2(privKey); std::istringstream iPriv2(privKey);
RSAKey key3(0, &iPriv2); RSAKey key3(nullptr, &iPriv2);
std::ostringstream strPub3; std::ostringstream strPub3;
key3.save(&strPub3); key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str(); std::string pubFromPrivate = strPub3.str();
@@ -269,7 +269,7 @@ void RSATest::testCertificate()
X509Certificate cert(str); X509Certificate cert(str);
RSAKey publicKey(cert); RSAKey publicKey(cert);
std::istringstream str2(anyPem); std::istringstream str2(anyPem);
RSAKey privateKey(0, &str2, "test"); RSAKey privateKey(nullptr, &str2, "test");
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey); Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey);
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey); Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey);
std::string val("lets do some encryption"); std::string val("lets do some encryption");

View File

@@ -205,7 +205,10 @@ BrowseHandle AvahiBrowserImpl::browse(const std::string& regType, const std::str
AvahiResponderImpl::ScopedLock lock(_responder); AvahiResponderImpl::ScopedLock lock(_responder);
AvahiIfIndex ifIndex = networkInterface == 0 ? AVAHI_IF_UNSPEC : networkInterface; AvahiIfIndex ifIndex = networkInterface == 0 ? AVAHI_IF_UNSPEC : networkInterface;
AvahiServiceBrowser* browser = avahi_service_browser_new(_responder._avahiClient, ifIndex, AVAHI_PROTO_UNSPEC, regType.c_str(), domain.empty() ? NULL : domain.c_str(), (AvahiLookupFlags) 0, Poco::DNSSD::Avahi::onBrowseReply, this); AvahiServiceBrowser* browser = avahi_service_browser_new(
_responder._avahiClient, ifIndex, AVAHI_PROTO_UNSPEC, regType.c_str(),
domain.empty() ? nullptr : domain.c_str(), (AvahiLookupFlags) 0, Poco::DNSSD::Avahi::onBrowseReply, this
);
if (!browser) if (!browser)
{ {
int error = avahi_client_errno(_responder._avahiClient); int error = avahi_client_errno(_responder._avahiClient);
@@ -235,13 +238,19 @@ BrowseHandle AvahiBrowserImpl::enumerateBrowseDomains(Poco::Int32 networkInterfa
AvahiResponderImpl::ScopedLock lock(_responder); AvahiResponderImpl::ScopedLock lock(_responder);
AvahiIfIndex ifIndex = networkInterface == 0 ? AVAHI_IF_UNSPEC : networkInterface; AvahiIfIndex ifIndex = networkInterface == 0 ? AVAHI_IF_UNSPEC : networkInterface;
AvahiDomainBrowser* browser = avahi_domain_browser_new(_responder._avahiClient, ifIndex, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, (AvahiLookupFlags) 0, Poco::DNSSD::Avahi::onEnumerateBrowseDomainsReply, this); AvahiDomainBrowser* browser = avahi_domain_browser_new(
_responder._avahiClient, ifIndex, AVAHI_PROTO_UNSPEC, nullptr,
AVAHI_DOMAIN_BROWSER_BROWSE, (AvahiLookupFlags) 0, Poco::DNSSD::Avahi::onEnumerateBrowseDomainsReply, this
);
if (!browser) if (!browser)
{ {
int error = avahi_client_errno(_responder._avahiClient); int error = avahi_client_errno(_responder._avahiClient);
throw Poco::DNSSD::DNSSDException("Failed to enumerate browse domains", AvahiResponderImpl::describeError(error), error); throw Poco::DNSSD::DNSSDException("Failed to enumerate browse domains", AvahiResponderImpl::describeError(error), error);
} }
AvahiDomainBrowser* defaultBrowser = avahi_domain_browser_new(_responder._avahiClient, ifIndex, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE_DEFAULT, (AvahiLookupFlags) 0, Poco::DNSSD::Avahi::onEnumerateDefaultBrowseDomainsReply, this); AvahiDomainBrowser* defaultBrowser = avahi_domain_browser_new(
_responder._avahiClient, ifIndex, AVAHI_PROTO_UNSPEC, nullptr,
AVAHI_DOMAIN_BROWSER_BROWSE_DEFAULT, (AvahiLookupFlags) 0, Poco::DNSSD::Avahi::onEnumerateDefaultBrowseDomainsReply, this
);
if (!defaultBrowser) if (!defaultBrowser)
{ {
int error = avahi_client_errno(_responder._avahiClient); int error = avahi_client_errno(_responder._avahiClient);
@@ -257,13 +266,19 @@ BrowseHandle AvahiBrowserImpl::enumerateRegistrationDomains(Poco::Int32 networkI
AvahiResponderImpl::ScopedLock lock(_responder); AvahiResponderImpl::ScopedLock lock(_responder);
AvahiIfIndex ifIndex = networkInterface == 0 ? AVAHI_IF_UNSPEC : networkInterface; AvahiIfIndex ifIndex = networkInterface == 0 ? AVAHI_IF_UNSPEC : networkInterface;
AvahiDomainBrowser* browser = avahi_domain_browser_new(_responder._avahiClient, ifIndex, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_REGISTER, (AvahiLookupFlags) 0, Poco::DNSSD::Avahi::onEnumerateRegistrationDomainsReply, this); AvahiDomainBrowser* browser = avahi_domain_browser_new(
_responder._avahiClient, ifIndex, AVAHI_PROTO_UNSPEC, nullptr,
AVAHI_DOMAIN_BROWSER_REGISTER, (AvahiLookupFlags) 0, Poco::DNSSD::Avahi::onEnumerateRegistrationDomainsReply, this
);
if (!browser) if (!browser)
{ {
int error = avahi_client_errno(_responder._avahiClient); int error = avahi_client_errno(_responder._avahiClient);
throw Poco::DNSSD::DNSSDException("Failed to enumerate registration domains", AvahiResponderImpl::describeError(error), error); throw Poco::DNSSD::DNSSDException("Failed to enumerate registration domains", AvahiResponderImpl::describeError(error), error);
} }
AvahiDomainBrowser* defaultBrowser = avahi_domain_browser_new(_responder._avahiClient, ifIndex, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_REGISTER_DEFAULT, (AvahiLookupFlags) 0, Poco::DNSSD::Avahi::onEnumerateDefaultRegistrationDomainsReply, this); AvahiDomainBrowser* defaultBrowser = avahi_domain_browser_new(
_responder._avahiClient, ifIndex, AVAHI_PROTO_UNSPEC, nullptr,
AVAHI_DOMAIN_BROWSER_REGISTER_DEFAULT, (AvahiLookupFlags) 0, Poco::DNSSD::Avahi::onEnumerateDefaultRegistrationDomainsReply, this
);
if (!defaultBrowser) if (!defaultBrowser)
{ {
int error = avahi_client_errno(_responder._avahiClient); int error = avahi_client_errno(_responder._avahiClient);

View File

@@ -66,8 +66,8 @@ extern "C" void onGroupStateChange(AvahiEntryGroup* avahiGroup, AvahiEntryGroupS
AvahiResponderImpl::AvahiResponderImpl(Poco::DNSSD::DNSSDResponder& owner): AvahiResponderImpl::AvahiResponderImpl(Poco::DNSSD::DNSSDResponder& owner):
_owner(owner), _owner(owner),
_browser(*this), _browser(*this),
_avahiPoll(0), _avahiPoll(nullptr),
_avahiClient(0), _avahiClient(nullptr),
_running(false), _running(false),
_nextRecordId(1) _nextRecordId(1)
{ {
@@ -299,8 +299,8 @@ void AvahiResponderImpl::setupEntryGroup(AvahiEntryGroup* avahiGroup, const Serv
} }
std::string name(service.name()); std::string name(service.name());
if (name.empty()) name = avahi_client_get_host_name(_avahiClient); if (name.empty()) name = avahi_client_get_host_name(_avahiClient);
const char* domain = service.domain().empty() ? 0 : service.domain().c_str(); const char* domain = service.domain().empty() ? nullptr : service.domain().c_str();
const char* host = service.host().empty() ? 0 : service.host().c_str(); const char* host = service.host().empty() ? nullptr : service.host().c_str();
int error = rename ? AVAHI_ERR_COLLISION : avahi_entry_group_add_service_strlst( int error = rename ? AVAHI_ERR_COLLISION : avahi_entry_group_add_service_strlst(
avahiGroup, avahiGroup,
@@ -390,7 +390,7 @@ void AvahiResponderImpl::setupEntryGroup(AvahiEntryGroup* avahiGroup, const Serv
AvahiStringList* AvahiResponderImpl::createTXTRecord(const Service::Properties& properties) AvahiStringList* AvahiResponderImpl::createTXTRecord(const Service::Properties& properties)
{ {
AvahiStringList* avahiList = 0; AvahiStringList* avahiList = nullptr;
Service::Properties::ConstIterator itVers = properties.find("txtvers"); Service::Properties::ConstIterator itVers = properties.find("txtvers");
Service::Properties::ConstIterator itEnd = properties.end(); Service::Properties::ConstIterator itEnd = properties.end();
std::string entry; std::string entry;
@@ -399,7 +399,7 @@ AvahiStringList* AvahiResponderImpl::createTXTRecord(const Service::Properties&
std::string entry(itVers->first); std::string entry(itVers->first);
entry += '='; entry += '=';
entry += itVers->second; entry += itVers->second;
avahiList = avahi_string_list_new(entry.c_str(), NULL); avahiList = avahi_string_list_new(entry.c_str(), nullptr);
} }
Service::Properties::ConstIterator it = properties.begin(); Service::Properties::ConstIterator it = properties.begin();
@@ -409,7 +409,11 @@ AvahiStringList* AvahiResponderImpl::createTXTRecord(const Service::Properties&
{ {
if (avahiList) if (avahiList)
{ {
avahiList = avahi_string_list_add_pair_arbitrary(avahiList, it->first.c_str(), reinterpret_cast<const uint8_t*>(it->second.empty() ? NULL : it->second.c_str()), it->second.size()); avahiList = avahi_string_list_add_pair_arbitrary(
avahiList, it->first.c_str(), reinterpret_cast<const uint8_t*>(it->second.empty() ?
nullptr :
it->second.c_str()), it->second.size()
);
} }
else else
{ {
@@ -419,7 +423,7 @@ AvahiStringList* AvahiResponderImpl::createTXTRecord(const Service::Properties&
entry += '='; entry += '=';
entry += it->second; entry += it->second;
} }
avahiList = avahi_string_list_new(entry.c_str(), NULL); avahiList = avahi_string_list_new(entry.c_str(), nullptr);
} }
} }
} }

View File

@@ -174,7 +174,7 @@ BrowseHandle BonjourBrowserImpl::browse(const std::string& regType, const std::s
{ {
DNSServiceRef sdRef(nullptr); DNSServiceRef sdRef(nullptr);
EventLoop::ScopedLock lock(_eventLoop); EventLoop::ScopedLock lock(_eventLoop);
DNSServiceErrorType err = DNSServiceBrowse(&sdRef, 0, networkInterface, regType.c_str(), domain.empty() ? 0 : domain.c_str(), Poco::DNSSD::Bonjour::onBrowseReply, this); DNSServiceErrorType err = DNSServiceBrowse(&sdRef, 0, networkInterface, regType.c_str(), domain.empty() ? nullptr : domain.c_str(), Poco::DNSSD::Bonjour::onBrowseReply, this);
if (err == kDNSServiceErr_NoError) if (err == kDNSServiceErr_NoError)
{ {
_eventLoop.add(sdRef); _eventLoop.add(sdRef);
@@ -186,7 +186,7 @@ BrowseHandle BonjourBrowserImpl::browse(const std::string& regType, const std::s
BrowseHandle BonjourBrowserImpl::resolve(const Service& service, int options) BrowseHandle BonjourBrowserImpl::resolve(const Service& service, int options)
{ {
DNSServiceRef sdRef(0); DNSServiceRef sdRef(nullptr);
Poco::Int32 ifIndex = (options & RESOLVE_ON_ALL_INTERFACES) ? 0 : service.networkInterface(); Poco::Int32 ifIndex = (options & RESOLVE_ON_ALL_INTERFACES) ? 0 : service.networkInterface();
EventLoop::ScopedLock lock(_eventLoop); EventLoop::ScopedLock lock(_eventLoop);
DNSServiceErrorType err = DNSServiceResolve(&sdRef, 0, ifIndex, service.name().c_str(), service.type().c_str(), service.domain().c_str(), Poco::DNSSD::Bonjour::onResolveReply, this); DNSServiceErrorType err = DNSServiceResolve(&sdRef, 0, ifIndex, service.name().c_str(), service.type().c_str(), service.domain().c_str(), Poco::DNSSD::Bonjour::onResolveReply, this);
@@ -202,7 +202,7 @@ BrowseHandle BonjourBrowserImpl::resolve(const Service& service, int options)
BrowseHandle BonjourBrowserImpl::enumerateBrowseDomains(Poco::Int32 networkInterface) BrowseHandle BonjourBrowserImpl::enumerateBrowseDomains(Poco::Int32 networkInterface)
{ {
DNSServiceRef sdRef(0); DNSServiceRef sdRef(nullptr);
EventLoop::ScopedLock lock(_eventLoop); EventLoop::ScopedLock lock(_eventLoop);
DNSServiceErrorType err = DNSServiceEnumerateDomains(&sdRef, kDNSServiceFlagsBrowseDomains, networkInterface, Poco::DNSSD::Bonjour::onEnumerateBrowseDomainsReply, this); DNSServiceErrorType err = DNSServiceEnumerateDomains(&sdRef, kDNSServiceFlagsBrowseDomains, networkInterface, Poco::DNSSD::Bonjour::onEnumerateBrowseDomainsReply, this);
if (err == kDNSServiceErr_NoError) if (err == kDNSServiceErr_NoError)
@@ -216,7 +216,7 @@ BrowseHandle BonjourBrowserImpl::enumerateBrowseDomains(Poco::Int32 networkInter
BrowseHandle BonjourBrowserImpl::enumerateRegistrationDomains(Poco::Int32 networkInterface) BrowseHandle BonjourBrowserImpl::enumerateRegistrationDomains(Poco::Int32 networkInterface)
{ {
DNSServiceRef sdRef(0); DNSServiceRef sdRef(nullptr);
EventLoop::ScopedLock lock(_eventLoop); EventLoop::ScopedLock lock(_eventLoop);
DNSServiceErrorType err = DNSServiceEnumerateDomains(&sdRef, kDNSServiceFlagsRegistrationDomains, networkInterface, Poco::DNSSD::Bonjour::onEnumerateRegistrationDomainsReply, this); DNSServiceErrorType err = DNSServiceEnumerateDomains(&sdRef, kDNSServiceFlagsRegistrationDomains, networkInterface, Poco::DNSSD::Bonjour::onEnumerateRegistrationDomainsReply, this);
if (err == kDNSServiceErr_NoError) if (err == kDNSServiceErr_NoError)
@@ -247,7 +247,7 @@ BrowseHandle BonjourBrowserImpl::queryRecord(const std::string& name, Poco::UInt
BrowseHandle BonjourBrowserImpl::resolveHost(const std::string& host, int options, Poco::Int32 networkInterface) BrowseHandle BonjourBrowserImpl::resolveHost(const std::string& host, int options, Poco::Int32 networkInterface)
{ {
DNSServiceRef sdRef(0); DNSServiceRef sdRef(nullptr);
DNSServiceFlags flags(0); DNSServiceFlags flags(0);
if (options & BROWSE_FORCE_MULTICAST) flags |= kDNSServiceFlagsForceMulticast; if (options & BROWSE_FORCE_MULTICAST) flags |= kDNSServiceFlagsForceMulticast;
EventLoop::ScopedLock lock(_eventLoop); EventLoop::ScopedLock lock(_eventLoop);

View File

@@ -85,7 +85,13 @@ ServiceHandle BonjourResponderImpl::registerService(const Service& service, int
if (options & DNSSDResponder::REG_NON_BROWSABLE) flags |= kDNSServiceFlagsNonBrowsable; if (options & DNSSDResponder::REG_NON_BROWSABLE) flags |= kDNSServiceFlagsNonBrowsable;
#endif #endif
std::string txtRecord = createTXTRecord(service.properties()); std::string txtRecord = createTXTRecord(service.properties());
DNSServiceErrorType err = DNSServiceRegister(&sdRef, flags, intf, service.name().empty() ? 0 : service.name().c_str(), service.type().c_str(), service.domain().empty() ? 0 : service.domain().c_str(), service.host().empty() ? 0 : service.host().c_str(), Poco::ByteOrder::toNetwork(service.port()), txtRecord.size(), txtRecord.empty() ? 0 : txtRecord.data(), Poco::DNSSD::Bonjour::onRegisterServiceReply, this); DNSServiceErrorType err = DNSServiceRegister(
&sdRef, flags, intf,
service.name().empty() ? nullptr : service.name().c_str(),
service.type().c_str(), service.domain().empty() ? nullptr : service.domain().c_str(),
service.host().empty() ? nullptr : service.host().c_str(),
Poco::ByteOrder::toNetwork(service.port()), txtRecord.size(), txtRecord.empty() ? nullptr : txtRecord.data(),
Poco::DNSSD::Bonjour::onRegisterServiceReply, this);
if (err == kDNSServiceErr_NoError) if (err == kDNSServiceErr_NoError)
{ {
_eventLoop.add(sdRef); _eventLoop.add(sdRef);
@@ -105,7 +111,7 @@ void BonjourResponderImpl::unregisterService(ServiceHandle& serviceHandle)
RecordHandle BonjourResponderImpl::addRecord(ServiceHandle serviceHandle, const Record& record) RecordHandle BonjourResponderImpl::addRecord(ServiceHandle serviceHandle, const Record& record)
{ {
DNSRecordRef recRef(0); DNSRecordRef recRef(nullptr);
EventLoop::ScopedLock lock(_eventLoop); EventLoop::ScopedLock lock(_eventLoop);
DNSServiceErrorType err = DNSServiceAddRecord(serviceHandle.cast<DNSServiceRef>(), &recRef, 0, record.type(), record.length(), record.data(), record.ttl()); DNSServiceErrorType err = DNSServiceAddRecord(serviceHandle.cast<DNSServiceRef>(), &recRef, 0, record.type(), record.length(), record.data(), record.ttl());
if (err == kDNSServiceErr_NoError) if (err == kDNSServiceErr_NoError)
@@ -119,7 +125,9 @@ RecordHandle BonjourResponderImpl::addRecord(ServiceHandle serviceHandle, const
void BonjourResponderImpl::updateRecord(ServiceHandle serviceHandle, RecordHandle recordHandle, const Record& record) void BonjourResponderImpl::updateRecord(ServiceHandle serviceHandle, RecordHandle recordHandle, const Record& record)
{ {
EventLoop::ScopedLock lock(_eventLoop); EventLoop::ScopedLock lock(_eventLoop);
DNSServiceErrorType err = DNSServiceUpdateRecord(serviceHandle.cast<DNSServiceRef>(), recordHandle.cast<DNSRecordRef>(), 0, record.length(), record.data(), record.ttl()); DNSServiceErrorType err = DNSServiceUpdateRecord(
serviceHandle.cast<DNSServiceRef>(), recordHandle.cast<DNSRecordRef>(), 0,
record.length(), record.data(), record.ttl());
if (err != kDNSServiceErr_NoError) if (err != kDNSServiceErr_NoError)
{ {
throw Poco::DNSSD::DNSSDException("Failed to update record " + record.name(), describeError(err), err); throw Poco::DNSSD::DNSSDException("Failed to update record " + record.name(), describeError(err), err);
@@ -268,7 +276,7 @@ std::string BonjourResponderImpl::createTXTRecord(const Service::Properties& pro
if (itVers != itEnd) if (itVers != itEnd)
{ {
Poco::UInt8 valueSize = static_cast<Poco::UInt8>(itVers->second.size()); Poco::UInt8 valueSize = static_cast<Poco::UInt8>(itVers->second.size());
TXTRecordSetValue(&ref, itVers->first.c_str(), valueSize, valueSize == 0 ? 0 : itVers->second.c_str()); TXTRecordSetValue(&ref, itVers->first.c_str(), valueSize, valueSize == 0 ? nullptr : itVers->second.c_str());
} }
it = properties.begin(); it = properties.begin();
@@ -277,7 +285,7 @@ std::string BonjourResponderImpl::createTXTRecord(const Service::Properties& pro
if (it != itVers) if (it != itVers)
{ {
Poco::UInt8 valueSize = static_cast<Poco::UInt8>(it->second.size()); Poco::UInt8 valueSize = static_cast<Poco::UInt8>(it->second.size());
TXTRecordSetValue(&ref, it->first.c_str(), valueSize, valueSize == 0 ? 0 : it->second.c_str()); TXTRecordSetValue(&ref, it->first.c_str(), valueSize, valueSize == 0 ? nullptr : it->second.c_str());
} }
} }
const void* txtRecord = TXTRecordGetBytesPtr(&ref); const void* txtRecord = TXTRecordGetBytesPtr(&ref);

View File

@@ -108,7 +108,7 @@ public:
if (request.getURI() == "/") if (request.getURI() == "/")
return new TimeRequestHandler(_format); return new TimeRequestHandler(_format);
else else
return 0; return nullptr;
} }
private: private:

View File

@@ -23,11 +23,11 @@ namespace Poco {
namespace DNSSD { namespace DNSSD {
DNSSDResponderImplFactory* DNSSDResponder::_pImplFactory(0); DNSSDResponderImplFactory* DNSSDResponder::_pImplFactory(nullptr);
DNSSDResponder::DNSSDResponder(): DNSSDResponder::DNSSDResponder():
_pImpl(0) _pImpl(nullptr)
{ {
if (_pImplFactory) if (_pImplFactory)
{ {
@@ -102,7 +102,7 @@ void DNSSDResponder::registerImplFactory(DNSSDResponderImplFactory& factory)
void DNSSDResponder::unregisterImplFactory() void DNSSDResponder::unregisterImplFactory()
{ {
_pImplFactory = 0; _pImplFactory = nullptr;
} }

View File

@@ -26,7 +26,7 @@ Record::Record():
_type(0), _type(0),
_clazz(0), _clazz(0),
_length(0), _length(0),
_data(0), _data(nullptr),
_ttl(0) _ttl(0)
{ {
} }

View File

@@ -37,7 +37,7 @@ public:
~SessionHandle(); ~SessionHandle();
/// Destroy handle, close connection /// Destroy handle, close connection
void init(MYSQL* mysql = 0); void init(MYSQL* mysql = nullptr);
/// Initializes the handle iff not initialized. /// Initializes the handle iff not initialized.
void options(mysql_option opt); void options(mysql_option opt);

View File

@@ -30,7 +30,7 @@ Binder::~Binder()
for (std::vector<MYSQL_TIME*>::iterator it = _dates.begin(); it != _dates.end(); ++it) for (std::vector<MYSQL_TIME*>::iterator it = _dates.begin(); it != _dates.end(); ++it)
{ {
delete *it; delete *it;
*it = 0; *it = nullptr;
} }
} }
@@ -220,7 +220,7 @@ void Binder::bind(std::size_t pos, const UUID& val, Direction dir)
void Binder::bind(std::size_t pos, const NullData&, Direction dir) void Binder::bind(std::size_t pos, const NullData&, Direction dir)
{ {
poco_assert(dir == PD_IN); poco_assert(dir == PD_IN);
realBind(pos, MYSQL_TYPE_NULL, 0, 0); realBind(pos, MYSQL_TYPE_NULL, nullptr, 0);
} }
@@ -234,7 +234,7 @@ MYSQL_BIND* Binder::getBindArray() const
{ {
if (_bindArray.size() == 0) if (_bindArray.size() == 0)
{ {
return 0; return nullptr;
} }
return const_cast<MYSQL_BIND*>(&_bindArray[0]); return const_cast<MYSQL_BIND*>(&_bindArray[0]);
@@ -286,7 +286,7 @@ void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer
std::memset(&_bindArray[s], 0, sizeof(MYSQL_BIND) * (_bindArray.size() - s)); std::memset(&_bindArray[s], 0, sizeof(MYSQL_BIND) * (_bindArray.size() - s));
} }
MYSQL_BIND b = {0}; MYSQL_BIND b = {nullptr};
b.buffer_type = type; b.buffer_type = type;
b.buffer = const_cast<void*>(buffer); b.buffer = const_cast<void*>(buffer);

View File

@@ -52,7 +52,7 @@ Poco::AutoPtr<Poco::Data::SessionImpl> Connector::createSession(const std::strin
void Connector::registerConnector() void Connector::registerConnector()
{ {
if (mysql_library_init(0, 0, 0) != 0) if (mysql_library_init(0, nullptr, nullptr) != 0)
{ {
throw Exception("mysql_library_init error"); throw Exception("mysql_library_init error");
} }

View File

@@ -265,7 +265,7 @@ void Extractor::reset()
bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, bool isUnsigned) bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, bool isUnsigned)
{ {
MYSQL_BIND bind = {0}; MYSQL_BIND bind = {nullptr};
my_bool isNull = 0; my_bool isNull = 0;
bind.is_null = &isNull; bind.is_null = &isNull;

View File

@@ -116,7 +116,7 @@ std::string StatementException::compose(const std::string& text, MYSQL_STMT* h,
str += "[Comment]: "; str += "[Comment]: ";
str += text; str += text;
if (h != 0) if (h != nullptr)
{ {
str += "\t[mysql_stmt_error]: "; str += "\t[mysql_stmt_error]: ";
str += mysql_stmt_error(h); str += mysql_stmt_error(h);

View File

@@ -67,7 +67,7 @@ private:
#endif #endif
SessionHandle::SessionHandle(MYSQL* mysql): _pHandle(0) SessionHandle::SessionHandle(MYSQL* mysql): _pHandle(nullptr)
{ {
init(mysql); init(mysql);
#ifdef POCO_OS_FAMILY_UNIX #ifdef POCO_OS_FAMILY_UNIX
@@ -95,7 +95,7 @@ SessionHandle::~SessionHandle()
void SessionHandle::options(mysql_option opt) void SessionHandle::options(mysql_option opt)
{ {
if (mysql_options(_pHandle, opt, 0) != 0) if (mysql_options(_pHandle, opt, nullptr) != 0)
throw ConnectionException("mysql_options error", _pHandle); throw ConnectionException("mysql_options error", _pHandle);
} }
@@ -130,7 +130,7 @@ void SessionHandle::options(mysql_option opt, unsigned int i)
void SessionHandle::connect(const char* host, const char* user, const char* password, const char* db, unsigned int port) void SessionHandle::connect(const char* host, const char* user, const char* password, const char* db, unsigned int port)
{ {
#ifdef HAVE_MYSQL_REAL_CONNECT #ifdef HAVE_MYSQL_REAL_CONNECT
if (!mysql_real_connect(_pHandle, host, user, password, db, port, 0, 0)) if (!mysql_real_connect(_pHandle, host, user, password, db, port, nullptr, 0))
throw ConnectionFailedException(mysql_error(_pHandle)); throw ConnectionFailedException(mysql_error(_pHandle));
#else #else
if (!mysql_connect(_pHandle, host, user, password)) if (!mysql_connect(_pHandle, host, user, password))
@@ -144,7 +144,7 @@ void SessionHandle::close()
if (_pHandle) if (_pHandle)
{ {
mysql_close(_pHandle); mysql_close(_pHandle);
_pHandle = 0; _pHandle = nullptr;
} }
} }

View File

@@ -48,7 +48,7 @@ const std::string SessionImpl::MYSQL_SERIALIZABLE = "SERIALIZABLE";
SessionImpl::SessionImpl(const std::string& connectionString, std::size_t loginTimeout) : SessionImpl::SessionImpl(const std::string& connectionString, std::size_t loginTimeout) :
Poco::Data::AbstractSessionImpl<SessionImpl>(connectionString, loginTimeout), Poco::Data::AbstractSessionImpl<SessionImpl>(connectionString, loginTimeout),
_connector("MySQL"), _connector("MySQL"),
_handle(0), _handle(nullptr),
_reset(false), _reset(false),
_connected(false), _connected(false),
_inTransaction(false), _inTransaction(false),
@@ -120,7 +120,7 @@ void SessionImpl::open(const std::string& connect)
if (options["user"].empty()) if (options["user"].empty())
throw MySQLException("create session: specify user name"); throw MySQLException("create session: specify user name");
const char * db = NULL; const char * db = nullptr;
if (!options["db"].empty()) if (!options["db"].empty())
db = options["db"].c_str(); db = options["db"].c_str();

View File

@@ -76,7 +76,7 @@ void StatementExecutor::bindParams(MYSQL_BIND* params, std::size_t count)
throw StatementException("Statement is not compiled yet"); throw StatementException("Statement is not compiled yet");
if (count != mysql_stmt_param_count(_pHandle)) if (count != mysql_stmt_param_count(_pHandle))
throw StatementException("wrong bind parameters count", 0, _query); throw StatementException("wrong bind parameters count", nullptr, _query);
if (count == 0) return; if (count == 0) return;

View File

@@ -37,8 +37,8 @@ using Poco::Nullable;
using Poco::Tuple; using Poco::Tuple;
using Poco::NamedTuple; using Poco::NamedTuple;
Poco::SharedPtr<Poco::Data::Session> MySQLTest::_pSession = 0; Poco::SharedPtr<Poco::Data::Session> MySQLTest::_pSession = nullptr;
Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor = 0; Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor = nullptr;
// //
// Parameters for barebone-test // Parameters for barebone-test
@@ -936,7 +936,7 @@ CppUnit::Test* MySQLTest::suite()
catch (ConnectionFailedException& ex) catch (ConnectionFailedException& ex)
{ {
std::cout << ex.displayText() << std::endl; std::cout << ex.displayText() << std::endl;
return 0; return nullptr;
} }
} }

View File

@@ -158,14 +158,14 @@ SQLExecutor::~SQLExecutor()
void SQLExecutor::bareboneMySQLTest(const char* host, const char* user, const char* pwd, const char* db, int port, const char* tableCreateString) void SQLExecutor::bareboneMySQLTest(const char* host, const char* user, const char* pwd, const char* db, int port, const char* tableCreateString)
{ {
int rc; int rc;
MYSQL* hsession = mysql_init(0); MYSQL* hsession = mysql_init(nullptr);
assertTrue (hsession != 0); assertTrue (hsession != nullptr);
MYSQL* tmp = mysql_real_connect(hsession, host, user, pwd, db, port, 0, 0); MYSQL* tmp = mysql_real_connect(hsession, host, user, pwd, db, port, nullptr, 0);
assertTrue (tmp == hsession); assertTrue (tmp == hsession);
MYSQL_STMT* hstmt = mysql_stmt_init(hsession); MYSQL_STMT* hstmt = mysql_stmt_init(hsession);
assertTrue (hstmt != 0); assertTrue (hstmt != nullptr);
std::string sql = "DROP TABLE Test"; std::string sql = "DROP TABLE Test";
mysql_real_query(hsession, sql.c_str(), static_cast<unsigned long>(sql.length())); mysql_real_query(hsession, sql.c_str(), static_cast<unsigned long>(sql.length()));
@@ -185,7 +185,7 @@ void SQLExecutor::bareboneMySQLTest(const char* host, const char* user, const ch
int fourth = 4; int fourth = 4;
float fifth = 1.5; float fifth = 1.5;
MYSQL_BIND bind_param[5] = {{0}}; MYSQL_BIND bind_param[5] = {{nullptr}};
bind_param[0].buffer = const_cast<char*>(str[0].c_str()); bind_param[0].buffer = const_cast<char*>(str[0].c_str());
bind_param[0].buffer_length = static_cast<unsigned long>(str[0].length()); bind_param[0].buffer_length = static_cast<unsigned long>(str[0].length());
@@ -225,7 +225,7 @@ void SQLExecutor::bareboneMySQLTest(const char* host, const char* user, const ch
fourth = 0; fourth = 0;
fifth = 0.0f; fifth = 0.0f;
MYSQL_BIND bind_result[5] = {{0}}; MYSQL_BIND bind_result[5] = {{nullptr}};
bind_result[0].buffer = chr[0]; bind_result[0].buffer = chr[0];
bind_result[0].buffer_length = sizeof(chr[0]); bind_result[0].buffer_length = sizeof(chr[0]);

View File

@@ -71,7 +71,7 @@ public:
Binder(const StatementHandle& rStmt, Binder(const StatementHandle& rStmt,
std::size_t maxFieldSize, std::size_t maxFieldSize,
ParameterBinding dataBinding = PB_IMMEDIATE, ParameterBinding dataBinding = PB_IMMEDIATE,
const TypeInfo* pDataTypes = 0, const TypeInfo* pDataTypes = nullptr,
Poco::TextEncoding::Ptr pFromEncoding = nullptr, Poco::TextEncoding::Ptr pFromEncoding = nullptr,
Poco::TextEncoding::Ptr pDBEncoding = nullptr); Poco::TextEncoding::Ptr pDBEncoding = nullptr);
/// Creates the Binder. /// Creates the Binder.
@@ -427,7 +427,7 @@ private:
getColSizeAndPrecision(pos, cDataType, colSize, decDigits); getColSizeAndPrecision(pos, cDataType, colSize, decDigits);
_lengthIndicator.push_back(0); _lengthIndicator.push_back(nullptr);
if (Utility::isError(SQLBindParameter(_rStmt, if (Utility::isError(SQLBindParameter(_rStmt,
(SQLUSMALLINT) pos + 1, (SQLUSMALLINT) pos + 1,
@@ -436,7 +436,7 @@ private:
Utility::sqlDataType(cDataType), Utility::sqlDataType(cDataType),
colSize, colSize,
decDigits, decDigits,
(SQLPOINTER) &val, 0, 0))) (SQLPOINTER) &val, 0, nullptr)))
{ {
throw StatementException(_rStmt, "ODBC::Binder::SQLBindParameter()"); throw StatementException(_rStmt, "ODBC::Binder::SQLBindParameter()");
} }
@@ -492,7 +492,7 @@ private:
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length); _vecLengthIndicator[pos] = new LengthVec(length);
} }
@@ -544,7 +544,7 @@ private:
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length); _vecLengthIndicator[pos] = new LengthVec(length);
} }
@@ -582,7 +582,7 @@ private:
if (PB_IMMEDIATE != _paramBinding) if (PB_IMMEDIATE != _paramBinding)
throw InvalidAccessException("Containers can only be bound immediately."); throw InvalidAccessException("Containers can only be bound immediately.");
const C* pVal = 0; const C* pVal = nullptr;
if (!transcodeRequired()) pVal = &valC; if (!transcodeRequired()) pVal = &valC;
else else
{ {
@@ -614,12 +614,12 @@ private:
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1, SQL_NTS); _vecLengthIndicator[pos] = new LengthVec(length ? length : 1, SQL_NTS);
} }
if (_charPtrs.size() <= pos) if (_charPtrs.size() <= pos)
_charPtrs.resize(pos + 1, 0); _charPtrs.resize(pos + 1, nullptr);
_charPtrs[pos] = (char*) std::calloc(pVal->size() * size, sizeof(char)); _charPtrs[pos] = (char*) std::calloc(pVal->size() * size, sizeof(char));
@@ -685,12 +685,12 @@ private:
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1, SQL_NTS); _vecLengthIndicator[pos] = new LengthVec(length ? length : 1, SQL_NTS);
} }
if (_utf16CharPtrs.size() <= pos) if (_utf16CharPtrs.size() <= pos)
_utf16CharPtrs.resize(pos + 1, 0); _utf16CharPtrs.resize(pos + 1, nullptr);
_utf16CharPtrs[pos] = (UTF16Char*)std::calloc(val.size() * size, sizeof(UTF16Char)); _utf16CharPtrs[pos] = (UTF16Char*)std::calloc(val.size() * size, sizeof(UTF16Char));
@@ -745,7 +745,7 @@ private:
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1); _vecLengthIndicator[pos] = new LengthVec(length ? length : 1);
} }
@@ -760,7 +760,7 @@ private:
} }
if (_charPtrs.size() <= pos) if (_charPtrs.size() <= pos)
_charPtrs.resize(pos + 1, 0); _charPtrs.resize(pos + 1, nullptr);
_charPtrs[pos] = (char*) std::calloc(val.size() * size, sizeof(CharType)); _charPtrs[pos] = (char*) std::calloc(val.size() * size, sizeof(CharType));
poco_check_ptr (_charPtrs[pos]); poco_check_ptr (_charPtrs[pos]);
@@ -811,13 +811,13 @@ private:
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1); _vecLengthIndicator[pos] = new LengthVec(length ? length : 1);
} }
if (_dateVecVec.size() <= pos) if (_dateVecVec.size() <= pos)
{ {
_dateVecVec.resize(pos + 1, 0); _dateVecVec.resize(pos + 1, nullptr);
_dateVecVec[pos] = new DateVec(length ? length : 1); _dateVecVec[pos] = new DateVec(length ? length : 1);
} }
@@ -859,13 +859,13 @@ private:
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1); _vecLengthIndicator[pos] = new LengthVec(length ? length : 1);
} }
if (_timeVecVec.size() <= pos) if (_timeVecVec.size() <= pos)
{ {
_timeVecVec.resize(pos + 1, 0); _timeVecVec.resize(pos + 1, nullptr);
_timeVecVec[pos] = new TimeVec(length ? length : 1); _timeVecVec[pos] = new TimeVec(length ? length : 1);
} }
@@ -908,13 +908,13 @@ private:
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1); _vecLengthIndicator[pos] = new LengthVec(length ? length : 1);
} }
if (_dateTimeVecVec.size() <= pos) if (_dateTimeVecVec.size() <= pos)
{ {
_dateTimeVecVec.resize(pos + 1, 0); _dateTimeVecVec.resize(pos + 1, nullptr);
_dateTimeVecVec[pos] = new DateTimeVec(length ? length : 1); _dateTimeVecVec[pos] = new DateTimeVec(length ? length : 1);
} }
@@ -958,12 +958,12 @@ private:
SQLINTEGER size = 16; // UUID is fixed 16 bytes SQLINTEGER size = 16; // UUID is fixed 16 bytes
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1, size); _vecLengthIndicator[pos] = new LengthVec(length ? length : 1, size);
} }
if (_charPtrs.size() <= pos) if (_charPtrs.size() <= pos)
_charPtrs.resize(pos + 1, 0); _charPtrs.resize(pos + 1, nullptr);
_charPtrs[pos] = (char*)std::calloc(val.size() * size, sizeof(char)); _charPtrs[pos] = (char*)std::calloc(val.size() * size, sizeof(char));
std::size_t offset = 0; std::size_t offset = 0;
@@ -1015,7 +1015,7 @@ private:
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length, SQL_NULL_DATA); _vecLengthIndicator[pos] = new LengthVec(length, SQL_NULL_DATA);
} }
@@ -1030,7 +1030,7 @@ private:
TypeInfo::sqlDataType<SQL_C_CHAR>(), TypeInfo::sqlDataType<SQL_C_CHAR>(),
colSize, colSize,
decDigits, decDigits,
0, nullptr,
0, 0,
&(*_vecLengthIndicator[pos])[0]))) &(*_vecLengthIndicator[pos])[0])))
{ {
@@ -1057,7 +1057,7 @@ private:
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
{ {
_vecLengthIndicator.resize(pos + 1, 0); _vecLengthIndicator.resize(pos + 1, nullptr);
_vecLengthIndicator[pos] = new LengthVec(length, SQL_NULL_DATA); _vecLengthIndicator[pos] = new LengthVec(length, SQL_NULL_DATA);
auto valIt = val.begin(), valEnd = val.end(); auto valIt = val.begin(), valEnd = val.end();
auto lenIt = _vecLengthIndicator[pos]->begin(), lenEnd = _vecLengthIndicator[pos]->end(); auto lenIt = _vecLengthIndicator[pos]->begin(), lenEnd = _vecLengthIndicator[pos]->end();
@@ -1080,7 +1080,7 @@ private:
TypeInfo::sqlDataType<SQL_C_CHAR>(), TypeInfo::sqlDataType<SQL_C_CHAR>(),
colSize, colSize,
decDigits, decDigits,
0, nullptr,
0, 0,
&(*_vecLengthIndicator[pos])[0]))) &(*_vecLengthIndicator[pos])[0])))
{ {

View File

@@ -41,7 +41,7 @@ class Handle
public: public:
Handle(const ConnectionHandle& rConnection): Handle(const ConnectionHandle& rConnection):
_rConnection(rConnection), _rConnection(rConnection),
_handle(0) _handle(nullptr)
/// Creates the Handle. /// Creates the Handle.
{ {
if (Utility::isError(SQLAllocHandle(handleType, if (Utility::isError(SQLAllocHandle(handleType,

View File

@@ -428,7 +428,7 @@ private:
Preparator& operator = (const Preparator&); Preparator& operator = (const Preparator&);
template <typename C> template <typename C>
void prepareImpl(std::size_t pos, const C* pVal = 0) void prepareImpl(std::size_t pos, const C* pVal = nullptr)
/// Utility function to prepare Any and Dynamic::Var. /// Utility function to prepare Any and Dynamic::Var.
{ {
ODBCMetaColumn col(_rStmt, pos); ODBCMetaColumn col(_rStmt, pos);

View File

@@ -70,7 +70,7 @@ public:
SQLSMALLINT> TypeInfoTup; SQLSMALLINT> TypeInfoTup;
typedef std::vector<TypeInfoTup> TypeInfoVec; typedef std::vector<TypeInfoTup> TypeInfoVec;
explicit TypeInfo(SQLHDBC* pHDBC=0); explicit TypeInfo(SQLHDBC* pHDBC=nullptr);
/// Creates the TypeInfo. /// Creates the TypeInfo.
~TypeInfo(); ~TypeInfo();

View File

@@ -114,7 +114,7 @@ void Binder::freeMemory()
void Binder::bind(std::size_t pos, const std::string& val, Direction dir) void Binder::bind(std::size_t pos, const std::string& val, Direction dir)
{ {
char* pTCVal = 0; char* pTCVal = nullptr;
SQLINTEGER size = 0; SQLINTEGER size = 0;
if (transcodeRequired()) if (transcodeRequired())
{ {
@@ -125,7 +125,7 @@ void Binder::bind(std::size_t pos, const std::string& val, Direction dir)
std::memcpy(pTCVal, tcVal.data(), size); std::memcpy(pTCVal, tcVal.data(), size);
} }
else size = static_cast<SQLINTEGER>(val.size()); else size = static_cast<SQLINTEGER>(val.size());
SQLPOINTER pVal = 0; SQLPOINTER pVal = nullptr;
SQLINTEGER colSize = 0; SQLINTEGER colSize = 0;
SQLSMALLINT decDigits = 0; SQLSMALLINT decDigits = 0;
getColSizeAndPrecision(pos, SQL_C_CHAR, colSize, decDigits, val.size()); getColSizeAndPrecision(pos, SQL_C_CHAR, colSize, decDigits, val.size());
@@ -183,7 +183,7 @@ void Binder::bind(std::size_t pos, const UTF16String& val, Direction dir)
{ {
typedef UTF16String::value_type CharT; typedef UTF16String::value_type CharT;
SQLPOINTER pVal = 0; SQLPOINTER pVal = nullptr;
SQLINTEGER size = (SQLINTEGER)(val.size() * sizeof(CharT)); SQLINTEGER size = (SQLINTEGER)(val.size() * sizeof(CharT));
SQLINTEGER colSize = 0; SQLINTEGER colSize = 0;
SQLSMALLINT decDigits = 0; SQLSMALLINT decDigits = 0;
@@ -366,7 +366,7 @@ void Binder::bind(std::size_t pos, const NullData& val, Direction dir)
if (isOutBound(dir) || !isInBound(dir)) if (isOutBound(dir) || !isInBound(dir))
throw NotImplementedException("NULL parameter type can only be inbound."); throw NotImplementedException("NULL parameter type can only be inbound.");
_inParams.insert(ParamMap::value_type(SQLPOINTER(0), SQLINTEGER(0))); _inParams.insert(ParamMap::value_type(SQLPOINTER(nullptr), SQLINTEGER(0)));
SQLLEN* pLenIn = new SQLLEN; SQLLEN* pLenIn = new SQLLEN;
*pLenIn = SQL_NULL_DATA; *pLenIn = SQL_NULL_DATA;
@@ -384,7 +384,7 @@ void Binder::bind(std::size_t pos, const NullData& val, Direction dir)
TypeInfo::sqlDataType<SQL_C_CHAR>(), TypeInfo::sqlDataType<SQL_C_CHAR>(),
colSize, colSize,
decDigits, decDigits,
0, nullptr,
0, 0,
_lengthIndicator.back()))) _lengthIndicator.back())))
{ {

View File

@@ -72,7 +72,7 @@ bool Extractor::extractBoundImpl<UTF16String>(std::size_t pos, UTF16String& val)
typedef UTF16String::value_type CharT; typedef UTF16String::value_type CharT;
if (isNull(pos)) return false; if (isNull(pos)) return false;
std::size_t dataSize = _pPreparator->actualDataSize(pos); std::size_t dataSize = _pPreparator->actualDataSize(pos);
CharT* sp = 0; CharT* sp = nullptr;
UTF16String us; UTF16String us;
const std::type_info& ti = _pPreparator->at(pos).type(); const std::type_info& ti = _pPreparator->at(pos).type();
if (ti == typeid(CharT*)) if (ti == typeid(CharT*))

View File

@@ -64,9 +64,9 @@ bool ODBCMetaColumn::isUnsigned() const
if (Utility::isError(Poco::Data::ODBC::SQLColAttribute(_rStmt, if (Utility::isError(Poco::Data::ODBC::SQLColAttribute(_rStmt,
(SQLUSMALLINT)position() + 1, // ODBC columns are 1-based (SQLUSMALLINT)position() + 1, // ODBC columns are 1-based
SQL_DESC_UNSIGNED, SQL_DESC_UNSIGNED,
nullptr,
0, 0,
0, nullptr,
0,
&val))) &val)))
{ {
throw StatementException(_rStmt, "ODBCMetaColumn::isUnsigned()"); throw StatementException(_rStmt, "ODBCMetaColumn::isUnsigned()");
@@ -82,9 +82,9 @@ void ODBCMetaColumn::init()
if (Utility::isError(Poco::Data::ODBC::SQLColAttribute(_rStmt, if (Utility::isError(Poco::Data::ODBC::SQLColAttribute(_rStmt,
(SQLUSMALLINT) position() + 1, // ODBC columns are 1-based (SQLUSMALLINT) position() + 1, // ODBC columns are 1-based
SQL_DESC_LENGTH, SQL_DESC_LENGTH,
nullptr,
0, 0,
0, nullptr,
0,
&_dataLength))) &_dataLength)))
{ {
throw StatementException(_rStmt, "ODBCMetaColumn::init()"); throw StatementException(_rStmt, "ODBCMetaColumn::init()");

View File

@@ -92,7 +92,7 @@ void ODBCStatementImpl::compileImpl()
Binder::ParameterBinding bind = session().getFeature("autoBind") ? Binder::ParameterBinding bind = session().getFeature("autoBind") ?
Binder::PB_IMMEDIATE : Binder::PB_AT_EXEC; Binder::PB_IMMEDIATE : Binder::PB_AT_EXEC;
const TypeInfo* pDT = 0; const TypeInfo* pDT = nullptr;
try try
{ {
Poco::Any dti = session().getProperty("dataTypeInfo"); Poco::Any dti = session().getProperty("dataTypeInfo");
@@ -194,7 +194,7 @@ void ODBCStatementImpl::doPrepare()
"SQLSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE)"); "SQLSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE)");
} }
AbstractPreparation::Ptr pAP = 0; AbstractPreparation::Ptr pAP = nullptr;
Poco::Data::AbstractPreparator::Ptr pP = _preparations[curDataSet]; Poco::Data::AbstractPreparator::Ptr pP = _preparations[curDataSet];
for (std::size_t pos = 0; it != itEnd; ++it) for (std::size_t pos = 0; it != itEnd; ++it)
{ {
@@ -295,7 +295,7 @@ void ODBCStatementImpl::execDirectImpl(const std::string& query)
void ODBCStatementImpl::putData() void ODBCStatementImpl::putData()
{ {
SQLPOINTER pParam = 0; SQLPOINTER pParam = nullptr;
SQLINTEGER dataSize = 0; SQLINTEGER dataSize = 0;
SQLRETURN rc; SQLRETURN rc;
@@ -433,7 +433,7 @@ std::string ODBCStatementImpl::nativeSQL()
SQLINTEGER length = (SQLINTEGER) statement.size() * 2; SQLINTEGER length = (SQLINTEGER) statement.size() * 2;
char* pNative = 0; char* pNative = nullptr;
SQLINTEGER retlen = length; SQLINTEGER retlen = length;
do do
{ {

View File

@@ -170,7 +170,7 @@ void SessionImpl::open(const std::string& connect)
&SessionImpl::setDataTypeInfo, &SessionImpl::setDataTypeInfo,
&SessionImpl::dataTypeInfo); &SessionImpl::dataTypeInfo);
Poco::Data::ODBC::SQLSetConnectAttr(_db, SQL_ATTR_QUIET_MODE, 0, 0); Poco::Data::ODBC::SQLSetConnectAttr(_db, SQL_ATTR_QUIET_MODE, nullptr, 0);
if (!canTransact()) autoCommit("", true); if (!canTransact()) autoCommit("", true);
} }
@@ -227,7 +227,7 @@ inline Poco::Any SessionImpl::getCursorUse(const std::string&) const
#pragma warning (disable : 4995) // ignore marked as deprecated #pragma warning (disable : 4995) // ignore marked as deprecated
#endif #endif
SQLUINTEGER curUse = 0; SQLUINTEGER curUse = 0;
Poco::Data::ODBC::SQLGetConnectAttr(_db, SQL_ATTR_ODBC_CURSORS, &curUse, SQL_IS_UINTEGER, 0); Poco::Data::ODBC::SQLGetConnectAttr(_db, SQL_ATTR_ODBC_CURSORS, &curUse, SQL_IS_UINTEGER, nullptr);
switch (curUse) switch (curUse)
{ {
case SQL_CUR_USE_ODBC: case SQL_CUR_USE_ODBC:
@@ -263,7 +263,7 @@ bool SessionImpl::canTransact() const
if (ODBC_TXN_CAPABILITY_UNKNOWN == _canTransact) if (ODBC_TXN_CAPABILITY_UNKNOWN == _canTransact)
{ {
SQLUSMALLINT ret; SQLUSMALLINT ret;
checkError(Poco::Data::ODBC::SQLGetInfo(_db, SQL_TXN_CAPABLE, &ret, 0, 0), checkError(Poco::Data::ODBC::SQLGetInfo(_db, SQL_TXN_CAPABLE, &ret, 0, nullptr),
"Failed to obtain transaction capability info."); "Failed to obtain transaction capability info.");
_canTransact = (SQL_TC_NONE != ret) ? _canTransact = (SQL_TC_NONE != ret) ?
@@ -318,7 +318,7 @@ bool SessionImpl::getMultiActiveResultset(const std::string&) const
{ {
#ifdef POCO_DATA_ODBC_HAVE_SQL_SERVER_EXT #ifdef POCO_DATA_ODBC_HAVE_SQL_SERVER_EXT
SQLINTEGER mars; SQLINTEGER mars;
Poco::Data::ODBC::SQLGetConnectAttr(_db, SQL_COPT_SS_MARS_ENABLED, &mars, SQL_IS_INTEGER, 0); Poco::Data::ODBC::SQLGetConnectAttr(_db, SQL_COPT_SS_MARS_ENABLED, &mars, SQL_IS_INTEGER, nullptr);
return mars == SQL_MARS_ENABLED_YES; return mars == SQL_MARS_ENABLED_YES;
#else #else
return false; return false;
@@ -332,7 +332,7 @@ Poco::UInt32 SessionImpl::getTransactionIsolation() const
checkError(SQLGetConnectAttr(_db, SQL_ATTR_TXN_ISOLATION, checkError(SQLGetConnectAttr(_db, SQL_ATTR_TXN_ISOLATION,
&isolation, &isolation,
0, 0,
0)); nullptr));
return transactionIsolation(isolation); return transactionIsolation(isolation);
} }
@@ -359,7 +359,7 @@ Poco::UInt32 SessionImpl::getDefaultTransactionIsolation() const
checkError(SQLGetInfo(_db, SQL_DEFAULT_TXN_ISOLATION, checkError(SQLGetInfo(_db, SQL_DEFAULT_TXN_ISOLATION,
&isolation, &isolation,
0, 0,
0)); nullptr));
return transactionIsolation(isolation); return transactionIsolation(isolation);
} }
@@ -418,7 +418,7 @@ bool SessionImpl::isAutoCommit(const std::string&) const
SQL_ATTR_AUTOCOMMIT, SQL_ATTR_AUTOCOMMIT,
&value, &value,
0, 0,
0)); nullptr));
return (0 != value); return (0 != value);
} }
@@ -433,7 +433,7 @@ bool SessionImpl::isTransaction() const
SQL_ATTR_AUTOCOMMIT, SQL_ATTR_AUTOCOMMIT,
&value, &value,
0, 0,
0)); nullptr));
if (0 == value) return _inTransaction; if (0 == value) return _inTransaction;
else return false; else return false;
@@ -505,7 +505,7 @@ int SessionImpl::maxStatementLength() const
SQL_MAXIMUM_STATEMENT_LENGTH, SQL_MAXIMUM_STATEMENT_LENGTH,
(SQLPOINTER) &info, (SQLPOINTER) &info,
0, 0,
0))) nullptr)))
{ {
throw ConnectionException(_db, throw ConnectionException(_db,
"SQLGetInfo(SQL_MAXIMUM_STATEMENT_LENGTH)"); "SQLGetInfo(SQL_MAXIMUM_STATEMENT_LENGTH)");

View File

@@ -35,7 +35,7 @@ using Poco::format;
using Poco::NotFoundException; using Poco::NotFoundException;
Session* ODBCAccessTest::_pSession = 0; Session* ODBCAccessTest::_pSession = nullptr;
std::string ODBCAccessTest::_dbConnString; std::string ODBCAccessTest::_dbConnString;
Poco::Data::ODBC::Utility::DriverMap ODBCAccessTest::_drivers; Poco::Data::ODBC::Utility::DriverMap ODBCAccessTest::_drivers;
@@ -209,5 +209,5 @@ CppUnit::Test* ODBCAccessTest::suite()
return pSuite; return pSuite;
} }
return 0; return nullptr;
} }

View File

@@ -681,5 +681,5 @@ CppUnit::Test* ODBCDB2Test::suite()
return pSuite; return pSuite;
} }
return 0; return nullptr;
} }

View File

@@ -506,5 +506,5 @@ CppUnit::Test* ODBCMySQLTest::suite()
return pSuite; return pSuite;
} }
return 0; return nullptr;
} }

View File

@@ -1024,5 +1024,5 @@ CppUnit::Test* ODBCOracleTest::suite()
return pSuite; return pSuite;
} }
return 0; return nullptr;
} }

View File

@@ -687,5 +687,5 @@ CppUnit::Test* ODBCPostgreSQLTest::suite()
return pSuite; return pSuite;
} }
return 0; return nullptr;
} }

View File

@@ -1211,5 +1211,5 @@ CppUnit::Test* ODBCSQLServerTest::suite()
return pSuite; return pSuite;
} }
return 0; return nullptr;
} }

View File

@@ -398,5 +398,5 @@ CppUnit::Test* ODBCSQLiteTest::suite()
return pSuite; return pSuite;
} }
return 0; return nullptr;
} }

View File

@@ -1454,7 +1454,7 @@ ODBCTest::SessionPtr ODBCTest::init(const std::string& driver,
const std::string& dbEncoding) const std::string& dbEncoding)
{ {
Utility::drivers(_drivers); Utility::drivers(_drivers);
if (!canConnect(driver, dsn, uid, pwd, dbConnString, db)) return 0; if (!canConnect(driver, dsn, uid, pwd, dbConnString, db)) return nullptr;
try try
{ {
@@ -1466,6 +1466,6 @@ ODBCTest::SessionPtr ODBCTest::init(const std::string& driver,
}catch (ConnectionFailedException& ex) }catch (ConnectionFailedException& ex)
{ {
std::cout << ex.displayText() << std::endl; std::cout << ex.displayText() << std::endl;
return 0; return nullptr;
} }
} }

View File

@@ -172,7 +172,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
SQLCHAR connectOutput[1024] = {0}; SQLCHAR connectOutput[1024] = {0};
SQLSMALLINT result; SQLSMALLINT result;
rc = SQLDriverConnect(hdbc rc = SQLDriverConnect(hdbc
, NULL , nullptr
,(SQLCHAR*) dbConnString.c_str() ,(SQLCHAR*) dbConnString.c_str()
,(SQLSMALLINT) SQL_NTS ,(SQLSMALLINT) SQL_NTS
, connectOutput , connectOutput
@@ -307,7 +307,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
0, 0,
(SQLPOINTER) &fourth, (SQLPOINTER) &fourth,
0, 0,
0); nullptr);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLBindParameter(hstmt, rc = SQLBindParameter(hstmt,
@@ -319,7 +319,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
1, 1,
(SQLPOINTER) &fifth, (SQLPOINTER) &fifth,
0, 0,
0); nullptr);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
if (dateTimeColSize == 0 || dateTimeDecDigits == -1) if (dateTimeColSize == 0 || dateTimeDecDigits == -1)
@@ -354,7 +354,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
dateTimeDecDigits, dateTimeDecDigits,
(SQLPOINTER) &sixth, (SQLPOINTER) &sixth,
0, 0,
0); nullptr);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLExecute(hstmt); rc = SQLExecute(hstmt);
@@ -362,7 +362,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
if (SQL_NEED_DATA == rc) if (SQL_NEED_DATA == rc)
{ {
SQLPOINTER pParam = 0; SQLPOINTER pParam = nullptr;
while (SQL_NEED_DATA == (rc = SQLParamData(hstmt, &pParam))) while (SQL_NEED_DATA == (rc = SQLParamData(hstmt, &pParam)))
{ {
SQLINTEGER dataSize = 0; SQLINTEGER dataSize = 0;
@@ -600,7 +600,7 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
SQLCHAR connectOutput[512] = {0}; SQLCHAR connectOutput[512] = {0};
SQLSMALLINT result; SQLSMALLINT result;
rc = SQLDriverConnect(hdbc rc = SQLDriverConnect(hdbc
, NULL , nullptr
,(SQLCHAR*) dbConnString.c_str() ,(SQLCHAR*) dbConnString.c_str()
,(SQLSMALLINT) SQL_NTS ,(SQLSMALLINT) SQL_NTS
, connectOutput , connectOutput
@@ -822,7 +822,7 @@ void SQLExecutor::bareboneODBCStoredFuncTest(const std::string& dbConnString,
SQLCHAR connectOutput[1024] = { 0 }; SQLCHAR connectOutput[1024] = { 0 };
SQLSMALLINT result; SQLSMALLINT result;
rc = SQLDriverConnect(hdbc rc = SQLDriverConnect(hdbc
, NULL , nullptr
, (SQLCHAR*)dbConnString.c_str() , (SQLCHAR*)dbConnString.c_str()
, (SQLSMALLINT)SQL_NTS , (SQLSMALLINT)SQL_NTS
, connectOutput , connectOutput
@@ -944,7 +944,7 @@ void SQLExecutor::bareboneODBCStoredFuncTest(const std::string& dbConnString,
if (SQL_NEED_DATA == rc) if (SQL_NEED_DATA == rc)
{ {
SQLPOINTER pParam = 0; SQLPOINTER pParam = nullptr;
while (SQL_NEED_DATA == (rc = SQLParamData(hstmt, &pParam))) while (SQL_NEED_DATA == (rc = SQLParamData(hstmt, &pParam)))
{ {
if ((pParam != (SQLPOINTER)retVal) && if ((pParam != (SQLPOINTER)retVal) &&

View File

@@ -428,7 +428,7 @@ private:
// //
inline bool BinaryExtractor::isColumnNull(const OutputParameter& anOutputParameter) const inline bool BinaryExtractor::isColumnNull(const OutputParameter& anOutputParameter) const
{ {
return anOutputParameter.isNull() || 0 == anOutputParameter.pData(); return anOutputParameter.isNull() || nullptr == anOutputParameter.pData();
} }

View File

@@ -448,7 +448,7 @@ private:
// //
inline bool Extractor::isColumnNull(const OutputParameter& outputParameter) const inline bool Extractor::isColumnNull(const OutputParameter& outputParameter) const
{ {
return outputParameter.isNull() || 0 == outputParameter.pData(); return outputParameter.isNull() || nullptr == outputParameter.pData();
} }

View File

@@ -194,16 +194,16 @@ inline InputParameter::InputParameter(Poco::Data::MetaColumn::ColumnDataType fie
_pData(aDataPtr), _pData(aDataPtr),
_size(theSize), _size(theSize),
_isBinary(Poco::Data::MetaColumn::FDT_BLOB == _fieldType || Poco::Data::MetaColumn::FDT_CLOB == _fieldType), _isBinary(Poco::Data::MetaColumn::FDT_BLOB == _fieldType || Poco::Data::MetaColumn::FDT_CLOB == _fieldType),
_pNonStringVersionRepresentation(0) _pNonStringVersionRepresentation(nullptr)
{ {
} }
inline InputParameter::InputParameter(): _fieldType(Poco::Data::MetaColumn::FDT_UNKNOWN), inline InputParameter::InputParameter(): _fieldType(Poco::Data::MetaColumn::FDT_UNKNOWN),
_pData(0), _pData(nullptr),
_size(0), _size(0),
_isBinary(false), _isBinary(false),
_pNonStringVersionRepresentation(0) _pNonStringVersionRepresentation(nullptr)
{ {
} }
@@ -239,7 +239,7 @@ inline bool InputParameter::isBinary() const
inline void InputParameter::setStringVersionRepresentation(const std::string& aString) inline void InputParameter::setStringVersionRepresentation(const std::string& aString)
{ {
_pNonStringVersionRepresentation = 0; _pNonStringVersionRepresentation = nullptr;
_stringVersionRepresentation = aString; _stringVersionRepresentation = aString;
_size = _stringVersionRepresentation.size(); _size = _stringVersionRepresentation.size();
} }
@@ -281,7 +281,7 @@ inline const void* InputParameter::pInternalRepresentation() const
case Poco::Data::MetaColumn::FDT_UNKNOWN: case Poco::Data::MetaColumn::FDT_UNKNOWN:
default: default:
return 0; return nullptr;
} }
} }
@@ -306,7 +306,7 @@ inline OutputParameter::OutputParameter():
_fieldType(Poco::Data::MetaColumn::FDT_UNKNOWN), _fieldType(Poco::Data::MetaColumn::FDT_UNKNOWN),
_internalFieldType(static_cast<Oid>(-1)), _internalFieldType(static_cast<Oid>(-1)),
_rowNumber(0), _rowNumber(0),
_pData(0), _pData(nullptr),
_size(0), _size(0),
_isNull(true) _isNull(true)
{ {
@@ -381,7 +381,7 @@ inline PQConnectionInfoOptionsFree::~PQConnectionInfoOptionsFree()
if (_pConnectionInfoOption) if (_pConnectionInfoOption)
{ {
PQconninfoFree(_pConnectionInfoOption); PQconninfoFree(_pConnectionInfoOption);
_pConnectionInfoOption = 0; _pConnectionInfoOption = nullptr;
} }
} }
@@ -397,7 +397,7 @@ inline PQResultClear::~PQResultClear()
if (_pPQResult) if (_pPQResult)
{ {
PQclear(_pPQResult); PQclear(_pPQResult);
_pPQResult = 0; _pPQResult = nullptr;
} }
} }
@@ -415,7 +415,7 @@ inline PGCancelFree::~PGCancelFree()
if (_pPGCancel) if (_pPGCancel)
{ {
PQfreeCancel(_pPGCancel); PQfreeCancel(_pPGCancel);
_pPGCancel = 0; _pPGCancel = nullptr;
} }
} }

View File

@@ -186,7 +186,7 @@ void Binder::bind(std::size_t pos, const UUID& val, Direction dir)
void Binder::bind(std::size_t pos, const NullData&, Direction dir) void Binder::bind(std::size_t pos, const NullData&, Direction dir)
{ {
poco_assert(dir == PD_IN); poco_assert(dir == PD_IN);
realBind(pos, Poco::Data::MetaColumn::FDT_UNKNOWN, 0, 0); realBind(pos, Poco::Data::MetaColumn::FDT_UNKNOWN, nullptr, 0);
} }

View File

@@ -34,7 +34,7 @@ const std::string SessionHandle::POSTGRESQL_SERIALIZABLE = "SERIALIZABLE";
SessionHandle::SessionHandle(): SessionHandle::SessionHandle():
_pConnection(0), _pConnection(nullptr),
_inTransaction(false), _inTransaction(false),
_isAsynchronousCommit(false), _isAsynchronousCommit(false),
_tranactionIsolationLevel(Session::TRANSACTION_READ_COMMITTED) _tranactionIsolationLevel(Session::TRANSACTION_READ_COMMITTED)
@@ -86,7 +86,7 @@ void SessionHandle::connect(const std::string& aConnectionString)
{ {
// free bad connection // free bad connection
PQfinish(_pConnection); PQfinish(_pConnection);
_pConnection = 0; _pConnection = nullptr;
} }
_pConnection = PQconnectdb(aConnectionString.c_str()); _pConnection = PQconnectdb(aConnectionString.c_str());
@@ -97,7 +97,7 @@ void SessionHandle::connect(const std::string& aConnectionString)
if (_pConnection) if (_pConnection)
{ {
PQfinish(_pConnection); PQfinish(_pConnection);
_pConnection = 0; _pConnection = nullptr;
} }
throw ConnectionFailedException(msg); throw ConnectionFailedException(msg);
} }
@@ -152,7 +152,7 @@ void SessionHandle::disconnect()
{ {
PQfinish(_pConnection); PQfinish(_pConnection);
_pConnection = 0; _pConnection = nullptr;
_connectionString = std::string(); _connectionString = std::string();
_inTransaction= false; _inTransaction= false;
@@ -197,7 +197,7 @@ std::string SessionHandle::lastError() const
std::string SessionHandle::lastErrorNoLock() const std::string SessionHandle::lastErrorNoLock() const
{ {
// DO NOT ACQUIRE THE MUTEX IN PRIVATE METHODS // DO NOT ACQUIRE THE MUTEX IN PRIVATE METHODS
std::string lastErrorString (0 != _pConnection ? PQerrorMessage(_pConnection) : "not connected"); std::string lastErrorString (nullptr != _pConnection ? PQerrorMessage(_pConnection) : "not connected");
return lastErrorString; return lastErrorString;
} }
@@ -328,7 +328,7 @@ void SessionHandle::cancel()
PGCancelFree cancelFreer(ptrPGCancel); PGCancelFree cancelFreer(ptrPGCancel);
PQcancel(ptrPGCancel, 0, 0); // no error buffer PQcancel(ptrPGCancel, nullptr, 0); // no error buffer
} }
@@ -565,7 +565,7 @@ SessionParametersMap SessionHandle::connectionParameters() const
throw NotConnectedException(); throw NotConnectedException();
} }
PQconninfoOption* ptrConnInfoOptions = 0; PQconninfoOption* ptrConnInfoOptions = nullptr;
{ {
Poco::FastMutex::ScopedLock mutexLocker(_sessionMutex); Poco::FastMutex::ScopedLock mutexLocker(_sessionMutex);

View File

@@ -76,7 +76,7 @@ StatementExecutor::StatementExecutor(SessionHandle& sessionHandle, bool binaryEx
_sessionHandle(sessionHandle), _sessionHandle(sessionHandle),
_binaryExtraction(binaryExtraction), _binaryExtraction(binaryExtraction),
_state(STMT_INITED), _state(STMT_INITED),
_pResultHandle(0), _pResultHandle(nullptr),
_countPlaceholdersInSQLStatement(0), _countPlaceholdersInSQLStatement(0),
_currentRow(0), _currentRow(0),
_affectedRowCount(0) _affectedRowCount(0)
@@ -133,13 +133,13 @@ void StatementExecutor::prepare(const std::string& aSQLStatement)
std::replace(statementName.begin(), statementName.end(), '-', 'p'); // PostgreSQL doesn't like dashes in prepared statement names std::replace(statementName.begin(), statementName.end(), '-', 'p'); // PostgreSQL doesn't like dashes in prepared statement names
const char* pStatementName = statementName.c_str(); const char* pStatementName = statementName.c_str();
PGresult* ptrPGResult = 0; PGresult* ptrPGResult = nullptr;
{ {
Poco::FastMutex::ScopedLock mutexLocker(_sessionHandle.mutex()); Poco::FastMutex::ScopedLock mutexLocker(_sessionHandle.mutex());
// prepare the statement - temporary PGresult returned // prepare the statement - temporary PGresult returned
ptrPGResult = PQprepare(_sessionHandle, pStatementName, ptrCSQLStatement, (int)countPlaceholdersInSQLStatement, 0); ptrPGResult = PQprepare(_sessionHandle, pStatementName, ptrCSQLStatement, (int)countPlaceholdersInSQLStatement, nullptr);
} }
{ {
@@ -254,15 +254,15 @@ void StatementExecutor::execute()
// clear out any result data. One way or another it is now obsolete. // clear out any result data. One way or another it is now obsolete.
clearResults(); clearResults();
PGresult* ptrPGResult = 0; PGresult* ptrPGResult = nullptr;
{ {
Poco::FastMutex::ScopedLock mutexLocker(_sessionHandle.mutex()); Poco::FastMutex::ScopedLock mutexLocker(_sessionHandle.mutex());
ptrPGResult = PQexecPrepared(_sessionHandle, ptrPGResult = PQexecPrepared(_sessionHandle,
_preparedStatementName.c_str(), (int)_countPlaceholdersInSQLStatement, _preparedStatementName.c_str(), (int)_countPlaceholdersInSQLStatement,
_inputParameterVector.size() != 0 ? &pParameterVector[ 0 ] : 0, _inputParameterVector.size() != 0 ? &pParameterVector[ 0 ] : nullptr,
_inputParameterVector.size() != 0 ? &parameterLengthVector[ 0 ] : 0, _inputParameterVector.size() != 0 ? &parameterLengthVector[ 0 ] : nullptr,
_inputParameterVector.size() != 0 ? &parameterFormatVector[ 0 ] : 0, _inputParameterVector.size() != 0 ? &parameterFormatVector[ 0 ] : nullptr,
_binaryExtraction ? 1 : 0); _binaryExtraction ? 1 : 0);
} }
@@ -308,7 +308,7 @@ void StatementExecutor::execute()
{ // non Select DML statments also have an affected row count. { // non Select DML statments also have an affected row count.
// unfortunately PostgreSQL offers up this count as a char * - go figure! // unfortunately PostgreSQL offers up this count as a char * - go figure!
const char * pNonSelectAffectedRowCountString = PQcmdTuples(_pResultHandle); const char * pNonSelectAffectedRowCountString = PQcmdTuples(_pResultHandle);
if (0 != pNonSelectAffectedRowCountString) if (nullptr != pNonSelectAffectedRowCountString)
{ {
if ( Poco::NumberParser::tryParse(pNonSelectAffectedRowCountString, affectedRowCount) if ( Poco::NumberParser::tryParse(pNonSelectAffectedRowCountString, affectedRowCount)
&& affectedRowCount >= 0 && affectedRowCount >= 0

View File

@@ -41,8 +41,8 @@ using Poco::NamedTuple;
using Poco::Environment; using Poco::Environment;
Poco::SharedPtr<Poco::Data::Session> PostgreSQLTest::_pSession = 0; Poco::SharedPtr<Poco::Data::Session> PostgreSQLTest::_pSession = nullptr;
Poco::SharedPtr<SQLExecutor> PostgreSQLTest::_pExecutor = 0; Poco::SharedPtr<SQLExecutor> PostgreSQLTest::_pExecutor = nullptr;
// //
@@ -1254,7 +1254,7 @@ CppUnit::Test* PostgreSQLTest::suite()
catch (ConnectionFailedException& ex) catch (ConnectionFailedException& ex)
{ {
std::cout << ex.displayText() << std::endl; std::cout << ex.displayText() << std::endl;
return 0; return nullptr;
} }
std::cout << "*** Connected to [" << "PostgreSQL" << "] test database." << std::endl; std::cout << "*** Connected to [" << "PostgreSQL" << "] test database." << std::endl;

View File

@@ -174,13 +174,13 @@ void SQLExecutor::oidPostgreSQLTest(std::string host, std::string user, std::str
connectionString.append("port="); connectionString.append("port=");
connectionString.append(port); connectionString.append(port);
PGconn * pConnection = 0; PGconn * pConnection = nullptr;
pConnection = PQconnectdb(connectionString.c_str()); pConnection = PQconnectdb(connectionString.c_str());
assertTrue (PQstatus(pConnection) == CONNECTION_OK); assertTrue (PQstatus(pConnection) == CONNECTION_OK);
PGresult * pResult = 0; PGresult * pResult = nullptr;
std::string sql = "DROP TABLE IF EXISTS Test"; std::string sql = "DROP TABLE IF EXISTS Test";
pResult = PQexec(pConnection, sql.c_str()); pResult = PQexec(pConnection, sql.c_str());
@@ -203,7 +203,7 @@ void SQLExecutor::oidPostgreSQLTest(std::string host, std::string user, std::str
sql = "SELECT * FROM Test"; sql = "SELECT * FROM Test";
std::string selectStatementName = "SELECT Statement"; std::string selectStatementName = "SELECT Statement";
pResult = PQprepare(pConnection, selectStatementName.c_str(), sql.c_str(), 0, 0); pResult = PQprepare(pConnection, selectStatementName.c_str(), sql.c_str(), 0, nullptr);
assertTrue (PQresultStatus(pResult) == PGRES_COMMAND_OK); assertTrue (PQresultStatus(pResult) == PGRES_COMMAND_OK);
PQclear(pResult); PQclear(pResult);
@@ -273,20 +273,20 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
connectionString.append("port="); connectionString.append("port=");
connectionString.append(port); connectionString.append(port);
PGconn * pConnection = 0; PGconn * pConnection = nullptr;
pConnection = PQconnectdb(connectionString.c_str()); pConnection = PQconnectdb(connectionString.c_str());
assertTrue (PQstatus(pConnection) == CONNECTION_OK); assertTrue (PQstatus(pConnection) == CONNECTION_OK);
PGresult * pResult = 0; PGresult * pResult = nullptr;
std::string sql = "DROP TABLE IF EXISTS Test"; std::string sql = "DROP TABLE IF EXISTS Test";
pResult = PQexec(pConnection, sql.c_str()); pResult = PQexec(pConnection, sql.c_str());
std::cout << "Drop Table Test Result: " << PQresStatus(PQresultStatus(pResult)) << " statement: "<< sql.c_str() << std::endl; std::cout << "Drop Table Test Result: " << PQresStatus(PQresultStatus(pResult)) << " statement: "<< sql.c_str() << std::endl;
assertTrue ( PQresultStatus(pResult) == PGRES_COMMAND_OK assertTrue (PQresultStatus(pResult) == PGRES_COMMAND_OK
|| PQresultStatus(pResult) == PGRES_FATAL_ERROR); || PQresultStatus(pResult) == PGRES_FATAL_ERROR);
PQclear(pResult); PQclear(pResult);
@@ -306,7 +306,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
insertStatementName.c_str(), insertStatementName.c_str(),
sql.c_str(), sql.c_str(),
5, 5,
0 nullptr
); );
assertTrue (PQresultStatus(pResult) == PGRES_COMMAND_OK); assertTrue (PQresultStatus(pResult) == PGRES_COMMAND_OK);
@@ -316,7 +316,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
int fourth = ByteOrder::toNetwork((Poco::UInt32) 4); int fourth = ByteOrder::toNetwork((Poco::UInt32) 4);
float fifth = 1.5; float fifth = 1.5;
const char *paramValues[5] = { 0 }; const char *paramValues[5] = { nullptr };
int paramLengths[5] = { 0 }; int paramLengths[5] = { 0 };
int paramFormats[5] = { 0 }; int paramFormats[5] = { 0 };
@@ -364,7 +364,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
assertTrue (PQntuples(pResult) == 1); assertTrue (PQntuples(pResult) == 1);
char* pSelectResult[5] = { 0 }; char* pSelectResult[5] = { nullptr };
int pResultLengths[5] = { 0 }; int pResultLengths[5] = { 0 };
// column 0 // column 0
@@ -377,7 +377,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
0, 0,
0 0
); );
assertTrue (pSelectResult[ 0 ] != 0); assertTrue (pSelectResult[ 0 ] != nullptr);
assertTrue (pResultLengths[ 0 ] != 0); assertTrue (pResultLengths[ 0 ] != 0);
// column 1 // column 1
@@ -390,7 +390,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
0, 0,
1 1
); );
assertTrue (pSelectResult[ 1 ] != 0); assertTrue (pSelectResult[ 1 ] != nullptr);
assertTrue (pResultLengths[ 1 ] != 0); assertTrue (pResultLengths[ 1 ] != 0);
// column 2 // column 2
@@ -403,7 +403,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
0, 0,
2 2
); );
assertTrue (pSelectResult[ 2 ] != 0); assertTrue (pSelectResult[ 2 ] != nullptr);
assertTrue (pResultLengths[ 2 ] != 0); assertTrue (pResultLengths[ 2 ] != 0);
// column 3 // column 3
@@ -416,7 +416,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
0, 0,
3 3
); );
assertTrue (pSelectResult[ 3 ] != 0); assertTrue (pSelectResult[ 3 ] != nullptr);
assertTrue (pResultLengths[ 3 ] != 0); assertTrue (pResultLengths[ 3 ] != 0);
// column 4 // column 4
@@ -429,7 +429,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
0, 0,
4 4
); );
assertTrue (pSelectResult[ 4 ] != 0); assertTrue (pSelectResult[ 4 ] != nullptr);
assertTrue (pResultLengths[ 4 ] != 0); assertTrue (pResultLengths[ 4 ] != 0);
/* /*

View File

@@ -148,7 +148,7 @@ public:
static CBMap retMap; static CBMap retMap;
T* pRet = reinterpret_cast<T*>(eventHookRegister(pDB, callbackFn, pParam)); T* pRet = reinterpret_cast<T*>(eventHookRegister(pDB, callbackFn, pParam));
if (pRet == 0) if (pRet == nullptr)
{ {
if (retMap.find(pDB) == retMap.end()) if (retMap.find(pDB) == retMap.end())
{ {
@@ -161,8 +161,8 @@ public:
CBMapItPair retMapRange = retMap.equal_range(pDB); CBMapItPair retMapRange = retMap.equal_range(pDB);
for (CBMapIt it = retMapRange.first; it != retMapRange.second; ++it) for (CBMapIt it = retMapRange.first; it != retMapRange.second; ++it)
{ {
poco_assert (it->second.first != 0); poco_assert (it->second.first != nullptr);
if ((callbackFn == 0) && (*pRet == *it->second.second)) if ((callbackFn == nullptr) && (*pRet == *it->second.second))
{ {
retMap.erase(it); retMap.erase(it);
return true; return true;

View File

@@ -69,7 +69,7 @@ bool Notifier::disableUpdate()
{ {
Poco::Mutex::ScopedLock l(_mutex); Poco::Mutex::ScopedLock l(_mutex);
if (Utility::registerUpdateHandler(Utility::dbHandle(_session), (Utility::UpdateCallbackType) 0, this)) if (Utility::registerUpdateHandler(Utility::dbHandle(_session), (Utility::UpdateCallbackType) nullptr, this))
_enabledEvents &= ~SQLITE_NOTIFY_UPDATE; _enabledEvents &= ~SQLITE_NOTIFY_UPDATE;
return !updateEnabled(); return !updateEnabled();
@@ -97,7 +97,7 @@ bool Notifier::disableCommit()
{ {
Poco::Mutex::ScopedLock l(_mutex); Poco::Mutex::ScopedLock l(_mutex);
if (Utility::registerUpdateHandler(Utility::dbHandle(_session), (Utility::CommitCallbackType) 0, this)) if (Utility::registerUpdateHandler(Utility::dbHandle(_session), (Utility::CommitCallbackType) nullptr, this))
_enabledEvents &= ~SQLITE_NOTIFY_COMMIT; _enabledEvents &= ~SQLITE_NOTIFY_COMMIT;
return !commitEnabled(); return !commitEnabled();
@@ -125,7 +125,7 @@ bool Notifier::disableRollback()
{ {
Poco::Mutex::ScopedLock l(_mutex); Poco::Mutex::ScopedLock l(_mutex);
if (Utility::registerUpdateHandler(Utility::dbHandle(_session), (Utility::RollbackCallbackType) 0, this)) if (Utility::registerUpdateHandler(Utility::dbHandle(_session), (Utility::RollbackCallbackType) nullptr, this))
_enabledEvents &= ~SQLITE_NOTIFY_ROLLBACK; _enabledEvents &= ~SQLITE_NOTIFY_ROLLBACK;
return !rollbackEnabled(); return !rollbackEnabled();

View File

@@ -32,7 +32,7 @@ const int SQLiteStatementImpl::POCO_SQLITE_INV_ROW_CNT = -1;
SQLiteStatementImpl::SQLiteStatementImpl(Poco::Data::SessionImpl& rSession, sqlite3* pDB): SQLiteStatementImpl::SQLiteStatementImpl(Poco::Data::SessionImpl& rSession, sqlite3* pDB):
StatementImpl(rSession), StatementImpl(rSession),
_pDB(pDB), _pDB(pDB),
_pStmt(0), _pStmt(nullptr),
_stepCalled(false), _stepCalled(false),
_nextResponse(0), _nextResponse(0),
_affectedRowCount(POCO_SQLITE_INV_ROW_CNT), _affectedRowCount(POCO_SQLITE_INV_ROW_CNT),
@@ -66,14 +66,14 @@ void SQLiteStatementImpl::compileImpl()
std::string statement(toString()); std::string statement(toString());
sqlite3_stmt* pStmt = 0; sqlite3_stmt* pStmt = nullptr;
const char* pSql = _pLeftover ? _pLeftover->c_str() : statement.c_str(); const char* pSql = _pLeftover ? _pLeftover->c_str() : statement.c_str();
if (0 == std::strlen(pSql)) if (0 == std::strlen(pSql))
throw InvalidSQLStatementException("Empty statements are illegal"); throw InvalidSQLStatementException("Empty statements are illegal");
int rc = SQLITE_OK; int rc = SQLITE_OK;
const char* pLeftover = 0; const char* pLeftover = nullptr;
bool queryFound = false; bool queryFound = false;
do do
@@ -82,7 +82,7 @@ void SQLiteStatementImpl::compileImpl()
if (rc != SQLITE_OK) if (rc != SQLITE_OK)
{ {
if (pStmt) sqlite3_finalize(pStmt); if (pStmt) sqlite3_finalize(pStmt);
pStmt = 0; pStmt = nullptr;
std::string errMsg = sqlite3_errmsg(_pDB); std::string errMsg = sqlite3_errmsg(_pDB);
Utility::throwException(_pDB, rc, errMsg); Utility::throwException(_pDB, rc, errMsg);
} }
@@ -149,7 +149,7 @@ void SQLiteStatementImpl::bindImpl()
{ {
_stepCalled = false; _stepCalled = false;
_nextResponse = 0; _nextResponse = 0;
if (_pStmt == 0) return; if (_pStmt == nullptr) return;
sqlite3_reset(_pStmt); sqlite3_reset(_pStmt);
@@ -217,9 +217,9 @@ void SQLiteStatementImpl::clear()
if (_pStmt) if (_pStmt)
{ {
sqlite3_finalize(_pStmt); sqlite3_finalize(_pStmt);
_pStmt=0; _pStmt=nullptr;
} }
_pLeftover = 0; _pLeftover = nullptr;
} }
@@ -229,7 +229,7 @@ bool SQLiteStatementImpl::hasNext()
return (_nextResponse == SQLITE_ROW); return (_nextResponse == SQLITE_ROW);
// _pStmt is allowed to be null for conditional SQL statements // _pStmt is allowed to be null for conditional SQL statements
if (_pStmt == 0) if (_pStmt == nullptr)
{ {
_stepCalled = true; _stepCalled = true;
_nextResponse = SQLITE_DONE; _nextResponse = SQLITE_DONE;
@@ -305,7 +305,7 @@ const MetaColumn& SQLiteStatementImpl::metaColumn(std::size_t pos) const
int SQLiteStatementImpl::affectedRowCount() const int SQLiteStatementImpl::affectedRowCount() const
{ {
if (_affectedRowCount != POCO_SQLITE_INV_ROW_CNT) return _affectedRowCount; if (_affectedRowCount != POCO_SQLITE_INV_ROW_CNT) return _affectedRowCount;
return _pStmt == 0 || sqlite3_stmt_readonly(_pStmt) ? 0 : sqlite3_changes(_pDB); return _pStmt == nullptr || sqlite3_stmt_readonly(_pStmt) ? 0 : sqlite3_changes(_pDB);
} }

View File

@@ -62,7 +62,7 @@ Utility::TypeMap Utility::_types;
Poco::Mutex Utility::_mutex; Poco::Mutex Utility::_mutex;
Utility::SQLiteMutex::SQLiteMutex(sqlite3* pDB): _pMutex((pDB) ? sqlite3_db_mutex(pDB) : 0) Utility::SQLiteMutex::SQLiteMutex(sqlite3* pDB): _pMutex((pDB) ? sqlite3_db_mutex(pDB) : nullptr)
{ {
if (_pMutex) if (_pMutex)
sqlite3_mutex_enter(_pMutex); sqlite3_mutex_enter(_pMutex);
@@ -256,7 +256,7 @@ bool Utility::fileToMemory(sqlite3* pInMemory, const std::string& fileName)
// Note: SQLITE_OPEN_READWRITE is required to correctly handle an existing hot journal. // Note: SQLITE_OPEN_READWRITE is required to correctly handle an existing hot journal.
// See #3135 // See #3135
rc = sqlite3_open_v2(fileName.c_str(), &pFile, SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI, NULL); rc = sqlite3_open_v2(fileName.c_str(), &pFile, SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI, nullptr);
if(rc == SQLITE_OK ) if(rc == SQLITE_OK )
{ {
pBackup = sqlite3_backup_init(pInMemory, "main", pFile, "main"); pBackup = sqlite3_backup_init(pInMemory, "main", pFile, "main");
@@ -279,7 +279,7 @@ bool Utility::memoryToFile(const std::string& fileName, sqlite3* pInMemory)
sqlite3* pFile; sqlite3* pFile;
sqlite3_backup* pBackup; sqlite3_backup* pBackup;
rc = sqlite3_open_v2(fileName.c_str(), &pFile, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL); rc = sqlite3_open_v2(fileName.c_str(), &pFile, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, nullptr);
if(rc == SQLITE_OK ) if(rc == SQLITE_OK )
{ {
pBackup = sqlite3_backup_init(pFile, "main", pInMemory, "main"); pBackup = sqlite3_backup_init(pFile, "main", pInMemory, "main");

View File

@@ -476,7 +476,7 @@ void SQLiteTest::testNullCharPointer()
try try
{ {
const char* pc = 0; const char* pc = nullptr;
tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :age)", tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :age)",
bind("lastname"), bind("lastname"),
bind("firstname"), bind("firstname"),
@@ -506,7 +506,7 @@ void SQLiteTest::testInsertCharPointer()
tmp << "DROP TABLE IF EXISTS Person", now; tmp << "DROP TABLE IF EXISTS Person", now;
tmp << "CREATE TABLE IF NOT EXISTS Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3))", now; tmp << "CREATE TABLE IF NOT EXISTS Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3))", now;
const char* pc = 0; const char* pc = nullptr;
try try
{ {
tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :age)", bind(pc), now; tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :age)", bind(pc), now;
@@ -522,7 +522,7 @@ void SQLiteTest::testInsertCharPointer()
bind("Address"), bind("Address"),
bind(133132)); bind(133132));
std::free((void*) pc); pc = 0; std::free((void*) pc); pc = nullptr;
assertTrue (1 == stmt.execute()); assertTrue (1 == stmt.execute());
tmp << "SELECT COUNT(*) FROM PERSON", into(count), now; tmp << "SELECT COUNT(*) FROM PERSON", into(count), now;
@@ -3005,7 +3005,7 @@ void SQLiteTest::testUpdateCallback()
assertTrue (_deleteCounter == 1); assertTrue (_deleteCounter == 1);
// disarm callback and do the same drill // disarm callback and do the same drill
assertTrue (Utility::registerUpdateHandler(tmp, (Utility::UpdateCallbackType) 0, &val)); assertTrue (Utility::registerUpdateHandler(tmp, (Utility::UpdateCallbackType) nullptr, &val));
tmp << "DROP TABLE IF EXISTS Person", now; tmp << "DROP TABLE IF EXISTS Person", now;
tmp << "CREATE TABLE IF NOT EXISTS Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3))", now; tmp << "CREATE TABLE IF NOT EXISTS Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3))", now;
@@ -3074,7 +3074,7 @@ void SQLiteTest::testCommitCallback()
tmp.commit(); tmp.commit();
assertTrue (val == 2); assertTrue (val == 2);
assertTrue (Utility::registerUpdateHandler(tmp, (Utility::CommitCallbackType) 0, &val)); assertTrue (Utility::registerUpdateHandler(tmp, (Utility::CommitCallbackType) nullptr, &val));
val = 0; val = 0;
tmp.begin(); tmp.begin();
tmp << "DROP TABLE IF EXISTS Person", now; tmp << "DROP TABLE IF EXISTS Person", now;
@@ -3115,7 +3115,7 @@ void SQLiteTest::testRollbackCallback()
tmp.rollback(); tmp.rollback();
assertTrue (val == 2); assertTrue (val == 2);
assertTrue (Utility::registerUpdateHandler(tmp, (Utility::RollbackCallbackType) 0, &val)); assertTrue (Utility::registerUpdateHandler(tmp, (Utility::RollbackCallbackType) nullptr, &val));
val = 0; val = 0;
tmp.begin(); tmp.begin();
tmp << "DROP TABLE IF EXISTS Person", now; tmp << "DROP TABLE IF EXISTS Person", now;

View File

@@ -136,7 +136,7 @@ public:
/// If the LOB is empty, returns NULL. /// If the LOB is empty, returns NULL.
{ {
if (_pContent->empty()) if (_pContent->empty())
return 0; return nullptr;
else else
return _pContent->data(); return _pContent->data();
} }
@@ -147,7 +147,7 @@ public:
/// If the LOB is empty, returns NULL. /// If the LOB is empty, returns NULL.
{ {
if (_pContent->empty()) if (_pContent->empty())
return 0; return nullptr;
else else
return _pContent->data(); return _pContent->data();
} }
@@ -294,7 +294,7 @@ public:
val.assign(_val.begin(), _val.end()); val.assign(_val.begin(), _val.end());
} }
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const
{ {
return cloneHolder(pVarHolder, _val); return cloneHolder(pVarHolder, _val);
} }
@@ -332,7 +332,7 @@ public:
val.assign(_val.begin(), _val.end()); val.assign(_val.begin(), _val.end());
} }
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const
{ {
return cloneHolder(pVarHolder, _val); return cloneHolder(pVarHolder, _val);
} }

View File

@@ -78,12 +78,12 @@ public:
static const std::size_t UNKNOWN_TOTAL_ROW_COUNT; static const std::size_t UNKNOWN_TOTAL_ROW_COUNT;
explicit RecordSet(const Statement& rStatement, explicit RecordSet(const Statement& rStatement,
RowFormatter::Ptr pRowFormatter = 0); RowFormatter::Ptr pRowFormatter = nullptr);
/// Creates the RecordSet. /// Creates the RecordSet.
RecordSet(Session& rSession, RecordSet(Session& rSession,
const std::string& query, const std::string& query,
RowFormatter::Ptr pRowFormatter = 0); RowFormatter::Ptr pRowFormatter = nullptr);
/// Creates the RecordSet. /// Creates the RecordSet.
RecordSet(Session& rSession, RecordSet(Session& rSession,

View File

@@ -82,12 +82,12 @@ public:
/// Creates the Row. /// Creates the Row.
Row(NameVecPtr pNames, Row(NameVecPtr pNames,
const RowFormatter::Ptr& pFormatter = 0); const RowFormatter::Ptr& pFormatter = nullptr);
/// Creates the Row. /// Creates the Row.
Row(NameVecPtr pNames, Row(NameVecPtr pNames,
const SortMapPtr& pSortMap, const SortMapPtr& pSortMap,
const RowFormatter::Ptr& pFormatter = 0); const RowFormatter::Ptr& pFormatter = nullptr);
/// Creates the Row. /// Creates the Row.
~Row(); ~Row();
@@ -200,14 +200,14 @@ public:
const ValueVec& values() const; const ValueVec& values() const;
/// Returns the const reference to values vector. /// Returns the const reference to values vector.
void setFormatter(const RowFormatter::Ptr& pFormatter = 0); void setFormatter(const RowFormatter::Ptr& pFormatter = nullptr);
/// Sets the formatter for this row and takes the /// Sets the formatter for this row and takes the
/// shared ownership of it. /// shared ownership of it.
const RowFormatter& getFormatter() const; const RowFormatter& getFormatter() const;
/// Returns the reference to the formatter. /// Returns the reference to the formatter.
void setSortMap(const SortMapPtr& pSortMap = 0); void setSortMap(const SortMapPtr& pSortMap = nullptr);
/// Adds the sorting fields entry and takes the /// Adds the sorting fields entry and takes the
/// shared ownership of it. /// shared ownership of it.

View File

@@ -37,7 +37,7 @@ class Data_API Transaction
/// See Transaction for more details and purpose of this template. /// See Transaction for more details and purpose of this template.
{ {
public: public:
Transaction(Poco::Data::Session& session, Poco::Logger* pLogger = 0); Transaction(Poco::Data::Session& session, Poco::Logger* pLogger = nullptr);
/// Creates the Transaction and starts it, using the given database session and logger. /// Creates the Transaction and starts it, using the given database session and logger.
Transaction(Poco::Data::Session& session, bool start); Transaction(Poco::Data::Session& session, bool start);
@@ -46,7 +46,7 @@ public:
/// to start the transaction. /// to start the transaction.
template <typename T> template <typename T>
Transaction(Poco::Data::Session& rSession, T& t, Poco::Logger* pLogger = 0): Transaction(Poco::Data::Session& rSession, T& t, Poco::Logger* pLogger = nullptr):
_rSession(rSession), _rSession(rSession),
_pLogger(pLogger) _pLogger(pLogger)
/// Creates the Transaction, using the given database session, transactor and logger. /// Creates the Transaction, using the given database session, transactor and logger.

View File

@@ -88,7 +88,7 @@ class WebSocketRequestHandler: public HTTPRequestHandler
/// Handler for the WebSocket connection. /// Handler for the WebSocket connection.
{ {
public: public:
WebSocketRequestHandler() : _pWS(0), _flags(0) WebSocketRequestHandler() : _pWS(nullptr), _flags(0)
{ {
} }
@@ -165,7 +165,7 @@ class RequestHandlerFactory: public HTTPRequestHandlerFactory
/// Web request handler factory. /// Web request handler factory.
{ {
public: public:
RequestHandlerFactory() : _pHandler(0) RequestHandlerFactory() : _pHandler(nullptr)
{ {
} }
@@ -185,7 +185,7 @@ public:
if (uri != "/favicon.ico") if (uri != "/favicon.ico")
std::cout << "Unknown URI: " << uri << std::endl; std::cout << "Unknown URI: " << uri << std::endl;
return 0; return nullptr;
} }
WebSocketRequestHandler& handler() WebSocketRequestHandler& handler()

View File

@@ -22,7 +22,7 @@ namespace Data {
AbstractBinding::AbstractBinding(const std::string& name, AbstractBinding::AbstractBinding(const std::string& name,
Direction direction, Direction direction,
Poco::UInt32 bulkSize): Poco::UInt32 bulkSize):
_pBinder(0), _pBinder(nullptr),
_name(name), _name(name),
_direction(direction), _direction(direction),
_bulkSize(bulkSize) _bulkSize(bulkSize)

View File

@@ -22,7 +22,7 @@ namespace Data {
AbstractExtraction::AbstractExtraction(Poco::UInt32 limit, AbstractExtraction::AbstractExtraction(Poco::UInt32 limit,
Poco::UInt32 position, Poco::UInt32 position,
bool bulk): bool bulk):
_pExtractor(0), _pExtractor(nullptr),
_limit(limit), _limit(limit),
_position(position), _position(position),
_bulk(bulk), _bulk(bulk),

View File

@@ -130,9 +130,9 @@ RecordSet& RecordSet::operator = (RecordSet&& other) noexcept
void RecordSet::reset(const Statement& stmt) void RecordSet::reset(const Statement& stmt)
{ {
delete _pBegin; delete _pBegin;
_pBegin = 0; _pBegin = nullptr;
delete _pEnd; delete _pEnd;
_pEnd = 0; _pEnd = nullptr;
_currentRow = 0; _currentRow = 0;
_totalRowCount = UNKNOWN_TOTAL_ROW_COUNT; _totalRowCount = UNKNOWN_TOTAL_ROW_COUNT;
@@ -473,7 +473,7 @@ Row& RecordSet::row(std::size_t pos)
throw RangeException("Invalid recordset row requested."); throw RangeException("Invalid recordset row requested.");
RowMap::const_iterator it = _rowMap.find(pos); RowMap::const_iterator it = _rowMap.find(pos);
Row* pRow = 0; Row* pRow = nullptr;
std::size_t columns = columnCount(); std::size_t columns = columnCount();
if (it == _rowMap.end()) if (it == _rowMap.end())
{ {

View File

@@ -30,7 +30,7 @@ std::ostream& operator << (std::ostream &os, const Row& row)
Row::Row(): Row::Row():
_pNames(0), _pNames(nullptr),
_pSortMap(new SortMap), _pSortMap(new SortMap),
_pFormatter(new SimpleRowFormatter) _pFormatter(new SimpleRowFormatter)
{ {
@@ -41,7 +41,7 @@ Row::Row(NameVecPtr pNames,
const RowFormatter::Ptr& pFormatter): _pNames(pNames) const RowFormatter::Ptr& pFormatter): _pNames(pNames)
{ {
if (!_pNames) throw NullPointerException(); if (!_pNames) throw NullPointerException();
init(0, pFormatter); init(nullptr, pFormatter);
} }

View File

@@ -32,7 +32,7 @@ RowFilter::RowFilter(RecordSet* pRecordSet): _pRecordSet(pRecordSet), _not(false
} }
RowFilter::RowFilter(Ptr pParent, LogicOperator op): _pRecordSet(0), RowFilter::RowFilter(Ptr pParent, LogicOperator op): _pRecordSet(nullptr),
_pParent(pParent), _pParent(pParent),
_not(false) _not(false)
{ {
@@ -61,7 +61,7 @@ RowFilter::~RowFilter()
{ {
try try
{ {
if (_pRecordSet) _pRecordSet->filter(0); if (_pRecordSet) _pRecordSet->filter(nullptr);
if (_pParent && _pParent->has(this)) if (_pParent && _pParent->has(this))
_pParent->removeFilter(this); _pParent->removeFilter(this);
release(); release();
@@ -89,7 +89,7 @@ bool RowFilter::isAllowed(std::size_t row) const
if (_comparisonMap.find(name) == _comparisonMap.end()) continue; if (_comparisonMap.find(name) == _comparisonMap.end()) continue;
Poco::Dynamic::Var ret; Poco::Dynamic::Var ret;
CompT compOp = 0; CompT compOp = nullptr;
Poco::Dynamic::Var val = rs.value(col, row, false); Poco::Dynamic::Var val = rs.value(col, row, false);
switch (it->second.get<1>()) switch (it->second.get<1>())
@@ -180,8 +180,8 @@ void RowFilter::removeFilter(Ptr pFilter)
_pRecordSet->moveFirst(); _pRecordSet->moveFirst();
_filterMap.erase(pFilter); _filterMap.erase(pFilter);
pFilter->_pRecordSet = 0; pFilter->_pRecordSet = nullptr;
pFilter->_pParent = 0; pFilter->_pParent = nullptr;
} }

View File

@@ -30,7 +30,7 @@ Transaction::Transaction(Poco::Data::Session& rSession, Poco::Logger* pLogger):
Transaction::Transaction(Poco::Data::Session& rSession, bool start): Transaction::Transaction(Poco::Data::Session& rSession, bool start):
_rSession(rSession), _rSession(rSession),
_pLogger(0) _pLogger(nullptr)
{ {
if (start) begin(); if (start) begin();
} }

View File

@@ -24,12 +24,12 @@ SessionImpl::SessionImpl(const std::string& init, std::size_t timeout):
_connected(true) _connected(true)
{ {
addFeature("f1", &SessionImpl::setF, &SessionImpl::getF); addFeature("f1", &SessionImpl::setF, &SessionImpl::getF);
addFeature("f2", 0, &SessionImpl::getF); addFeature("f2", nullptr, &SessionImpl::getF);
addFeature("f3", &SessionImpl::setF, 0); addFeature("f3", &SessionImpl::setF, nullptr);
addFeature("throwOnHasNext", &SessionImpl::setThrowOnHasNext, &SessionImpl::getThrowOnHasNext); addFeature("throwOnHasNext", &SessionImpl::setThrowOnHasNext, &SessionImpl::getThrowOnHasNext);
addFeature("connected", &SessionImpl::setConnected, &SessionImpl::getConnected); addFeature("connected", &SessionImpl::setConnected, &SessionImpl::getConnected);
addProperty("p1", &SessionImpl::setP, &SessionImpl::getP); addProperty("p1", &SessionImpl::setP, &SessionImpl::getP);
addProperty("p2", 0, &SessionImpl::getP); addProperty("p2", nullptr, &SessionImpl::getP);
addProperty("p3", &SessionImpl::setP, &SessionImpl::getP); addProperty("p3", &SessionImpl::setP, &SessionImpl::getP);
setDBMSName("Test"); setDBMSName("Test");
} }

View File

@@ -21,7 +21,6 @@
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/DateTime.h" #include "Poco/DateTime.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include "Poco/Path.h"
#include "Poco/Net/HTTPStreamFactory.h" #include "Poco/Net/HTTPStreamFactory.h"
#include "Poco/Net/FTPStreamFactory.h" #include "Poco/Net/FTPStreamFactory.h"
#include <iostream> #include <iostream>
@@ -367,7 +366,7 @@ const std::string TextEncodingCompiler::IMPL_TEMPLATE(
"const char* ${CLASS}::_names[] =\n" "const char* ${CLASS}::_names[] =\n"
"{\n" "{\n"
"${ENCODING_NAMES}" "${ENCODING_NAMES}"
" NULL\n" " nullptr\n"
"};\n" "};\n"
"\n" "\n"
"\n" "\n"

View File

@@ -65,7 +65,7 @@ protected:
/// { /// {
/// "myencoding", /// "myencoding",
/// "MyEncoding", /// "MyEncoding",
/// NULL /// nullptr
/// }; /// };
/// ///
/// The first entry in names must be the canonical name. /// The first entry in names must be the canonical name.

View File

@@ -23,7 +23,7 @@ const char* ISO8859_10Encoding::_names[] =
"ISO-8859-10", "ISO-8859-10",
"Latin6", "Latin6",
"Latin-6", "Latin-6",
NULL nullptr
}; };

View File

@@ -21,7 +21,7 @@ namespace Poco {
const char* ISO8859_11Encoding::_names[] = const char* ISO8859_11Encoding::_names[] =
{ {
"ISO-8859-11", "ISO-8859-11",
NULL nullptr
}; };

Some files were not shown because too many files have changed in this diff Show More