mirror of
https://github.com/pocoproject/poco.git
synced 2025-12-08 03:57:21 +01:00
* 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:
49
.github/workflows/ci.yml
vendored
49
.github/workflows/ci.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
export CXX=clang++-20
|
||||
cmake -S . -B build -G Ninja -DPOCO_BUILD_MODULES=ON
|
||||
- name: Build
|
||||
run: cmake --build build
|
||||
run: cmake --build build --parallel 4
|
||||
|
||||
android-arm64-v8a-ndk-latest-cmake:
|
||||
runs-on: ubuntu-22.04
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
- run: >-
|
||||
cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_MINIMAL_BUILD=TRUE
|
||||
-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:
|
||||
# Converted from a make job, what is essentially different from the above?
|
||||
@@ -100,14 +100,14 @@ jobs:
|
||||
- run: >-
|
||||
cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_MINIMAL_BUILD=TRUE
|
||||
-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:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- 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: 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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -126,7 +126,7 @@ jobs:
|
||||
- run: >-
|
||||
cmake -S. -Bcmake-build -GNinja -DCMAKE_CXX_VISIBILITY_PRESET=hidden
|
||||
-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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -147,7 +147,7 @@ jobs:
|
||||
- run: >-
|
||||
cmake -S. -Bcmake-build -GNinja -DENABLE_TESTS=ON -DPOCO_UNBUNDLED=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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -168,7 +168,7 @@ jobs:
|
||||
- run: >-
|
||||
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
|
||||
- run: cmake --build cmake-build --target all
|
||||
- run: cmake --build cmake-build --target all --parallel 4
|
||||
- uses: ./.github/actions/retry-action
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -186,7 +186,7 @@ jobs:
|
||||
- run: sudo apt -y update && sudo apt -y install libssl-dev
|
||||
- run: >-
|
||||
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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -219,7 +219,7 @@ jobs:
|
||||
-DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON
|
||||
-DENABLE_REDIS=OFF -DENABLE_MONGODB=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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -252,7 +252,7 @@ jobs:
|
||||
-DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON
|
||||
-DENABLE_REDIS=OFF -DENABLE_MONGODB=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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -279,7 +279,7 @@ jobs:
|
||||
-DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON
|
||||
-DENABLE_REDIS=OFF -DENABLE_MONGODB=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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -314,7 +314,7 @@ jobs:
|
||||
-DENABLE_PAGECOMPILER=ON -DENABLE_POCODOC=ON -DENABLE_PAGECOMPILER_FILE2PAGE=ON
|
||||
-DENABLE_REDIS=OFF -DENABLE_MONGODB=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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -346,7 +346,7 @@ jobs:
|
||||
- run: >-
|
||||
emcmake cmake -H. -B cmake-build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DENABLE_ACTIVERECORD_COMPILER=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?
|
||||
# - uses: ./.github/actions/retry-action
|
||||
# with:
|
||||
@@ -696,7 +696,7 @@ jobs:
|
||||
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev mysql-client
|
||||
- run: >-
|
||||
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
|
||||
with:
|
||||
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: >-
|
||||
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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -746,7 +746,7 @@ jobs:
|
||||
sudo apt-get -y install redis
|
||||
- run: >-
|
||||
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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -765,7 +765,7 @@ jobs:
|
||||
- run: sudo apt -y update && sudo apt -y install libssl-dev
|
||||
- run: >-
|
||||
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
|
||||
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/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
|
||||
|
||||
- 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
|
||||
run: |
|
||||
wget https://www.devart.com/odbc/oracle/devartodbcoracle_amd64.deb
|
||||
@@ -833,7 +844,7 @@ jobs:
|
||||
- run: ls -l /etc/apt/sources.list.d/
|
||||
- run: >-
|
||||
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
|
||||
with:
|
||||
timeout_minutes: 90
|
||||
@@ -853,7 +864,7 @@ jobs:
|
||||
- run: >-
|
||||
cmake -S. -Bcmake-build -GNinja -DPOCO_MINIMAL_BUILD=ON -DENABLE_DATA_SQLITE=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
|
||||
with:
|
||||
|
||||
@@ -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.
|
||||
// Validate Apache version for using a proper ap_log_error() version.
|
||||
#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
|
||||
ap_log_error(file, line, level, 0, 0, 0, text);
|
||||
#endif
|
||||
@@ -186,27 +186,27 @@ extern "C" int ApacheConnector_handler(request_rec *r)
|
||||
if (!app.factory().mustHandle(r->uri))
|
||||
return DECLINED;
|
||||
|
||||
apr_status_t rv;
|
||||
apr_status_t rv;
|
||||
if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)))
|
||||
return rv;
|
||||
|
||||
// The properties conn_rec->remote_ip and conn_rec->remote_addr have undergone significant changes in Apache 2.4.
|
||||
// Validate Apache version for using conn_rec->remote_ip and conn_rec->remote_addr proper versions.
|
||||
// The properties conn_rec->remote_ip and conn_rec->remote_addr have undergone significant changes in Apache 2.4.
|
||||
// Validate Apache version for using conn_rec->remote_ip and conn_rec->remote_addr proper versions.
|
||||
#if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4
|
||||
const char* clientIp = r->connection->remote_ip;
|
||||
apr_port_t clientPort = r->connection->remote_addr->port;
|
||||
const char* clientIp = r->connection->remote_ip;
|
||||
apr_port_t clientPort = r->connection->remote_addr->port;
|
||||
#else
|
||||
const char* clientIp = r->connection->client_ip;
|
||||
apr_port_t clientPort = r->connection->client_addr->port;
|
||||
const char* clientIp = r->connection->client_ip;
|
||||
apr_port_t clientPort = r->connection->client_addr->port;
|
||||
#endif
|
||||
std::unique_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
|
||||
&rec,
|
||||
r->connection->local_ip,
|
||||
r->connection->local_addr->port,
|
||||
clientIp,
|
||||
clientPort));
|
||||
std::unique_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
|
||||
&rec,
|
||||
r->connection->local_ip,
|
||||
r->connection->local_addr->port,
|
||||
clientIp,
|
||||
clientPort));
|
||||
|
||||
std::unique_ptr<ApacheServerResponse> pResponse(new ApacheServerResponse(pRequest.get()));
|
||||
std::unique_ptr<ApacheServerResponse> pResponse(new ApacheServerResponse(pRequest.get()));
|
||||
|
||||
// add header information to request
|
||||
rec.copyHeaders(*pRequest);
|
||||
@@ -245,7 +245,7 @@ extern "C" int ApacheConnector_handler(request_rec *r)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ extern "C" const char* ApacheConnector_uris(cmd_parms *cmd, void *in_dconf, cons
|
||||
{
|
||||
ApacheConnector::log(__FILE__, __LINE__, ApacheConnector::PRIO_ERROR, 0, "Unknown exception");
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -281,35 +281,35 @@ extern "C" const char* ApacheConnector_config(cmd_parms *cmd, void *in_dconf, co
|
||||
{
|
||||
ApacheConnector::log(__FILE__, __LINE__, ApacheConnector::PRIO_ERROR, 0, "Unknown exception");
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
extern "C" const command_rec ApacheConnector_cmds[] =
|
||||
{
|
||||
AP_INIT_RAW_ARGS(
|
||||
AP_INIT_RAW_ARGS(
|
||||
"AddPocoRequestHandler",
|
||||
reinterpret_cast<cmd_func>(ApacheConnector_uris),
|
||||
NULL,
|
||||
nullptr,
|
||||
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."),
|
||||
AP_INIT_RAW_ARGS(
|
||||
AP_INIT_RAW_ARGS(
|
||||
"AddPocoConfig",
|
||||
reinterpret_cast<cmd_func>(ApacheConnector_config),
|
||||
NULL,
|
||||
nullptr,
|
||||
RSRC_CONF,
|
||||
"Path of the POCO configuration file."),
|
||||
{ NULL }
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
|
||||
module AP_MODULE_DECLARE_DATA poco_module =
|
||||
{
|
||||
STANDARD20_MODULE_STUFF,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
ApacheConnector_cmds,
|
||||
ApacheConnector_register_hooks
|
||||
};
|
||||
|
||||
@@ -22,8 +22,8 @@ ApacheServerRequest::ApacheServerRequest(
|
||||
const char* clientName,
|
||||
int clientPort):
|
||||
_pApacheRequest(pApacheRequest),
|
||||
_pResponse(0),
|
||||
_pStream(new ApacheInputStream(_pApacheRequest)),
|
||||
_pResponse(0),
|
||||
_pStream(new ApacheInputStream(_pApacheRequest)),
|
||||
_serverAddress(serverName, serverPort),
|
||||
_clientAddress(clientName, clientPort)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
NameSpace();
|
||||
/// Creates the NameSpace.
|
||||
|
||||
NameSpace(const std::string& name, NameSpace* pNameSpace = 0);
|
||||
NameSpace(const std::string& name, NameSpace* pNameSpace = nullptr);
|
||||
/// Creates the NameSpace.
|
||||
|
||||
~NameSpace();
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
/// Creates the Symbol and assigns the symbol
|
||||
/// 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
|
||||
/// a unique ID.
|
||||
|
||||
|
||||
@@ -353,8 +353,8 @@ bool IdentifierToken::start(char c, std::istream& /*istr*/)
|
||||
{
|
||||
_value = c;
|
||||
return (c >= 'A' && c <= 'Z') ||
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c == '_' || c == '$');
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c == '_' || c == '$');
|
||||
}
|
||||
|
||||
|
||||
@@ -522,7 +522,7 @@ bool NumberLiteralToken::start(char c, std::istream& istr)
|
||||
_value = c;
|
||||
int next = istr.peek();
|
||||
return (c >= '0' && c <= '9') ||
|
||||
(c == '.' && next >= '0' && next <= '9');
|
||||
(c == '.' && next >= '0' && next <= '9');
|
||||
}
|
||||
|
||||
|
||||
@@ -670,13 +670,13 @@ void NumberLiteralToken::finishSuffix(std::istream& istr, int next)
|
||||
|
||||
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
|
||||
{
|
||||
return std::strtod(_value.c_str(), 0);
|
||||
return std::strtod(_value.c_str(), nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ bool Function::isVirtual() const
|
||||
Struct* pClass = dynamic_cast<Struct*>(nameSpace());
|
||||
return pClass && pClass->hasVirtualDestructor();
|
||||
}
|
||||
else return getOverridden() != 0;
|
||||
else return getOverridden() != nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ Function* Function::getOverridden() const
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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* pSymbol = 0;
|
||||
Symbol* pSymbol = nullptr;
|
||||
|
||||
if (name.empty())
|
||||
return pSymbol;
|
||||
@@ -125,7 +125,7 @@ Symbol* NameSpace::lookup(const std::string& name, std::set<const NameSpace*>& a
|
||||
if (pNS)
|
||||
pSymbol = static_cast<NameSpace*>(pSymbol)->lookup(tail, alreadyVisited);
|
||||
else
|
||||
pSymbol = 0;
|
||||
pSymbol = nullptr;
|
||||
}
|
||||
}
|
||||
else if (tail.empty())
|
||||
|
||||
@@ -29,7 +29,7 @@ int Parameter::_count(0);
|
||||
|
||||
|
||||
Parameter::Parameter(const std::string& decl, Function* /*pFunction*/):
|
||||
Decl(handleDecl(decl), 0), // handle init values
|
||||
Decl(handleDecl(decl), nullptr), // handle init values
|
||||
_type(),
|
||||
_isRef(false),
|
||||
_isPointer(false),
|
||||
|
||||
@@ -52,7 +52,7 @@ Parser::Parser(NameSpace::SymbolTable& gst, const std::string& file, std::istrea
|
||||
_tokenizer(_istr),
|
||||
_file(file),
|
||||
_inFile(false),
|
||||
_pCurrentSymbol(0),
|
||||
_pCurrentSymbol(nullptr),
|
||||
_access(Symbol::ACC_PUBLIC)
|
||||
{
|
||||
Path p(file);
|
||||
@@ -235,7 +235,7 @@ const Token* Parser::parseNameSpace(const Token* pNext)
|
||||
fullName += name;
|
||||
|
||||
NameSpace* pNS = dynamic_cast<NameSpace*>(currentNameSpace()->lookup(fullName));
|
||||
bool undefined = (pNS == 0);
|
||||
bool undefined = (pNS == nullptr);
|
||||
if (undefined) pNS = new NameSpace(name, currentNameSpace());
|
||||
pushNameSpace(pNS, -1, undefined);
|
||||
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));
|
||||
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
bool isClass = isKeyword(pNext, IdentifierToken::KW_CLASS);
|
||||
int line = static_cast<int>(_istr.getCurrentLineNumber());
|
||||
Symbol::Access prevAccess = _access;
|
||||
@@ -324,7 +324,7 @@ const Token* Parser::parseClass(const Token* pNext, std::string& decl)
|
||||
expectOperator(pNext, OperatorToken::OP_SEMICOLON, ";");
|
||||
pNext = next();
|
||||
_access = prevAccess;
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
return pNext;
|
||||
}
|
||||
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();
|
||||
_access = prevAccess;
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
return pNext;
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ const Token* Parser::parseTypeDef(const Token* pNext)
|
||||
{
|
||||
poco_assert (isKeyword(pNext, IdentifierToken::KW_TYPEDEF));
|
||||
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
int line = static_cast<int>(_istr.getCurrentLineNumber());
|
||||
std::string decl;
|
||||
while (!isOperator(pNext, OperatorToken::OP_SEMICOLON) && !isEOF(pNext))
|
||||
@@ -507,7 +507,7 @@ const Token* Parser::parseTypeDef(const Token* pNext)
|
||||
addSymbol(pTypeDef, line);
|
||||
|
||||
pNext = next();
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
return pNext;
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ const Token* Parser::parseUsing(const Token* pNext)
|
||||
{
|
||||
poco_assert (isKeyword(pNext, IdentifierToken::KW_USING));
|
||||
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
int line = static_cast<int>(_istr.getCurrentLineNumber());
|
||||
pNext = next();
|
||||
if (isKeyword(pNext, IdentifierToken::KW_NAMESPACE))
|
||||
@@ -560,7 +560,7 @@ const Token* Parser::parseUsing(const Token* pNext)
|
||||
if (!isOperator(pNext, OperatorToken::OP_SEMICOLON))
|
||||
syntaxError("semicolon");
|
||||
pNext = next();
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
return pNext;
|
||||
}
|
||||
|
||||
@@ -589,7 +589,7 @@ const Token* Parser::parseVarFunc(const Token* pNext)
|
||||
|
||||
const Token* Parser::parseVarFunc(const Token* pNext, std::string& decl)
|
||||
{
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
std::string attrs;
|
||||
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);
|
||||
}
|
||||
}
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
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));
|
||||
|
||||
int line = static_cast<int>(_istr.getCurrentLineNumber());
|
||||
Function* pFunc = 0;
|
||||
Function* pFunc = nullptr;
|
||||
std::string name = Symbol::extractName(decl);
|
||||
if (name.find(':') == std::string::npos)
|
||||
{
|
||||
@@ -836,7 +836,7 @@ const Token* Parser::parseEnum(const Token* pNext)
|
||||
|
||||
std::string baseType;
|
||||
int flags = 0;
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
int line = static_cast<int>(_istr.getCurrentLineNumber());
|
||||
pNext = next();
|
||||
|
||||
@@ -883,14 +883,14 @@ const Token* Parser::parseEnum(const Token* pNext)
|
||||
pNext = next();
|
||||
expectOperator(pNext, OperatorToken::OP_SEMICOLON, ";");
|
||||
pNext = next();
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
return pNext;
|
||||
}
|
||||
|
||||
|
||||
const Token* Parser::parseEnumValue(const Token* pNext, Enum* pEnum)
|
||||
{
|
||||
_pCurrentSymbol = 0;
|
||||
_pCurrentSymbol = nullptr;
|
||||
_doc.clear();
|
||||
int line = static_cast<int>(_istr.getCurrentLineNumber());
|
||||
std::string name = pNext->tokenString();
|
||||
|
||||
@@ -58,7 +58,7 @@ void Struct::addBase(const std::string& name, Symbol::Access access, bool isVirt
|
||||
base.name = name;
|
||||
base.access = access;
|
||||
base.isVirtual = isVirtual;
|
||||
base.pClass = 0;
|
||||
base.pClass = nullptr;
|
||||
_bases.push_back(base);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ Function* Struct::destructor() const
|
||||
if (pFunc && pFunc->isDestructor())
|
||||
return pFunc;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ Function* Struct::findFunction(const std::string& signature) const
|
||||
if (pFunc) return pFunc;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ int Symbol::_nextId = 0;
|
||||
|
||||
Symbol::Symbol():
|
||||
_id(_nextId++),
|
||||
_pNameSpace(0),
|
||||
_pNameSpace(nullptr),
|
||||
_access(ACC_PUBLIC),
|
||||
_line(-1),
|
||||
_order(0)
|
||||
|
||||
@@ -21,17 +21,17 @@ class CppUnit_API CppUnitException: public std::exception
|
||||
{
|
||||
public:
|
||||
CppUnitException(const std::string& message = "",
|
||||
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CPPUNIT_UNKNOWNFILENAME);
|
||||
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CPPUNIT_UNKNOWNFILENAME);
|
||||
CppUnitException(const std::string& message,
|
||||
long lineNumber,
|
||||
long data1lineNumber,
|
||||
const std::string& fileName);
|
||||
long lineNumber,
|
||||
long data1lineNumber,
|
||||
const std::string& fileName);
|
||||
CppUnitException(const std::string& message,
|
||||
long lineNumber,
|
||||
long data1lineNumber,
|
||||
long data2lineNumber,
|
||||
const std::string& fileName);
|
||||
long lineNumber,
|
||||
long data1lineNumber,
|
||||
long data2lineNumber,
|
||||
const std::string& fileName);
|
||||
CppUnitException(const CppUnitException& other);
|
||||
~CppUnitException() noexcept override;
|
||||
|
||||
@@ -58,11 +58,11 @@ private:
|
||||
|
||||
inline CppUnitException::CppUnitException(const CppUnitException& other): exception (other)
|
||||
{
|
||||
_message = other._message;
|
||||
_lineNumber = other._lineNumber;
|
||||
_data1lineNumber = other._data1lineNumber;
|
||||
_data2lineNumber = other._data2lineNumber;
|
||||
_fileName = other._fileName;
|
||||
_message = other._message;
|
||||
_lineNumber = other._lineNumber;
|
||||
_data1lineNumber = other._data1lineNumber;
|
||||
_data2lineNumber = other._data2lineNumber;
|
||||
_fileName = other._fileName;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,15 +90,15 @@ inline CppUnitException& CppUnitException::operator = (const CppUnitException& o
|
||||
{
|
||||
exception::operator= (other);
|
||||
|
||||
if (&other != this)
|
||||
{
|
||||
_message = other._message;
|
||||
_lineNumber = other._lineNumber;
|
||||
_data1lineNumber = other._data1lineNumber;
|
||||
_data2lineNumber = other._data2lineNumber;
|
||||
_fileName = other._fileName;
|
||||
}
|
||||
return *this;
|
||||
if (&other != this)
|
||||
{
|
||||
_message = other._message;
|
||||
_lineNumber = other._lineNumber;
|
||||
_data1lineNumber = other._data1lineNumber;
|
||||
_data2lineNumber = other._data2lineNumber;
|
||||
_fileName = other._fileName;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
ClassUnderTest call(ClassUnderTest object);
|
||||
ClassUnderTest call(ClassUnderTest object);
|
||||
void runTest () override;
|
||||
};
|
||||
|
||||
@@ -63,29 +63,29 @@ protected:
|
||||
template <class ClassUnderTest>
|
||||
void Orthodox<ClassUnderTest>::runTest()
|
||||
{
|
||||
// make sure we have a default constructor
|
||||
ClassUnderTest a, b, c;
|
||||
// make sure we have a default constructor
|
||||
ClassUnderTest a, b, c;
|
||||
|
||||
// make sure we have an equality operator
|
||||
assert (a == b);
|
||||
// make sure we have an equality operator
|
||||
assert (a == b);
|
||||
|
||||
// check the inverse
|
||||
b.operator= (a.operator! ());
|
||||
assert (a != b);
|
||||
// check the inverse
|
||||
b.operator= (a.operator! ());
|
||||
assert (a != b);
|
||||
|
||||
// double inversion
|
||||
b = !!a;
|
||||
assert (a == b);
|
||||
// double inversion
|
||||
b = !!a;
|
||||
assert (a == b);
|
||||
|
||||
// invert again
|
||||
b = !a;
|
||||
// invert again
|
||||
b = !a;
|
||||
|
||||
// check calls
|
||||
c = a;
|
||||
assert (c == call (a));
|
||||
// check calls
|
||||
c = a;
|
||||
assert (c == call (a));
|
||||
|
||||
c = b;
|
||||
assert (c == call (b));
|
||||
c = b;
|
||||
assert (c == call (b));
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ void Orthodox<ClassUnderTest>::runTest()
|
||||
template <class ClassUnderTest>
|
||||
ClassUnderTest Orthodox<ClassUnderTest>::call(ClassUnderTest object)
|
||||
{
|
||||
return object;
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class TestResult;
|
||||
*/
|
||||
class CppUnit_API TestCase: public Test
|
||||
{
|
||||
REFERENCEOBJECT (TestCase)
|
||||
REFERENCEOBJECT (TestCase)
|
||||
|
||||
public:
|
||||
TestCase(const std::string& name, Test::Type testType = Test::Normal);
|
||||
@@ -108,55 +108,55 @@ protected:
|
||||
TestResult* defaultResult();
|
||||
|
||||
void assertImplementation(bool condition,
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void loop1assertImplementation(bool condition,
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long dataLineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long dataLineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void loop2assertImplementation(bool condition,
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long data1LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long data2LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long data1LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long data2LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
template <typename T1, typename T2,
|
||||
typename = std::enable_if_t<std::is_arithmetic_v<T1>, T1>,
|
||||
typename = std::enable_if_t<std::is_arithmetic_v<T2>, T2>>
|
||||
void assertEquals(T1 expected,
|
||||
T2 actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME)
|
||||
T2 actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME)
|
||||
{
|
||||
if (expected != actual)
|
||||
assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName);
|
||||
}
|
||||
|
||||
void assertEquals(double expected,
|
||||
double actual,
|
||||
double delta,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
double actual,
|
||||
double delta,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(const std::string& expected,
|
||||
const std::string& actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
const std::string& actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(const char* expected,
|
||||
const std::string& actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
const std::string& actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(const void* expected,
|
||||
const void* actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
const void* actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
template <typename T1, typename T2,
|
||||
typename = std::enable_if_t<std::is_arithmetic_v<T1>, T1>,
|
||||
@@ -170,22 +170,22 @@ protected:
|
||||
std::string notEqualsMessage(const std::string& expected, const std::string& actual);
|
||||
|
||||
void assertNotNull(const void* pointer,
|
||||
const std::string& pointerExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
const std::string& pointerExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertNull(const void* pointer,
|
||||
const std::string& pointerExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
const std::string& pointerExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void fail(const std::string& message = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void warn(const std::string& message = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -34,7 +34,7 @@ TestRunner::~TestRunner()
|
||||
|
||||
void TestRunner::printBanner()
|
||||
{
|
||||
_ostr
|
||||
_ostr
|
||||
<< "Usage: driver [-all] [-ignore <file> ] [-long] [-print] [-wait] [name] ..." << std::endl
|
||||
<< " where name is the name of a test case class" << std::endl;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ bool TestRunner::run(const std::vector<std::string>& args, const Test::Callback&
|
||||
std::vector<std::string> setup;
|
||||
|
||||
std::vector<Test*> tests;
|
||||
for (std::size_t i = 1; i < args.size(); i++)
|
||||
for (std::size_t i = 1; i < args.size(); i++)
|
||||
{
|
||||
const std::string& arg = args[i];
|
||||
if (arg == "-wait")
|
||||
|
||||
@@ -167,12 +167,12 @@ void TextTestResult::printErrors(std::ostream& stream)
|
||||
CppUnitException* e = failure->thrownException();
|
||||
|
||||
stream << std::setw(2) << i
|
||||
<< ": "
|
||||
<< failure->failedTest()->toString() << "\n"
|
||||
<< ": "
|
||||
<< failure->failedTest()->toString() << "\n"
|
||||
<< " \"" << (e ? e->what() : "") << "\"\n"
|
||||
<< " in \""
|
||||
<< (e ? e->fileName() : std::string())
|
||||
<< "\", line ";
|
||||
<< " in \""
|
||||
<< (e ? e->fileName() : std::string())
|
||||
<< "\", line ";
|
||||
if (e == nullptr)
|
||||
{
|
||||
stream << "0";
|
||||
@@ -183,7 +183,7 @@ void TextTestResult::printErrors(std::ostream& stream)
|
||||
if (e->data2LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER)
|
||||
{
|
||||
stream << " data lines " << e->data1LineNumber()
|
||||
<< ", " << e->data2LineNumber();
|
||||
<< ", " << e->data2LineNumber();
|
||||
}
|
||||
else if (e->data1LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER)
|
||||
{
|
||||
@@ -214,12 +214,12 @@ void TextTestResult::printFailures(std::ostream& stream)
|
||||
CppUnitException* e = failure->thrownException();
|
||||
|
||||
stream << std::setw(2) << i
|
||||
<< ": "
|
||||
<< failure->failedTest()->toString() << "\n"
|
||||
<< " \"" << (e ? e->what() : "") << "\"\n"
|
||||
<< " in \""
|
||||
<< (e ? e->fileName() : std::string())
|
||||
<< "\", line ";
|
||||
<< ": "
|
||||
<< failure->failedTest()->toString() << "\n"
|
||||
<< " \"" << (e ? e->what() : "") << "\"\n"
|
||||
<< " in \""
|
||||
<< (e ? e->fileName() : std::string())
|
||||
<< "\", line ";
|
||||
if (e == nullptr)
|
||||
{
|
||||
stream << "0";
|
||||
@@ -230,8 +230,8 @@ void TextTestResult::printFailures(std::ostream& stream)
|
||||
if (e->data2LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER)
|
||||
{
|
||||
stream << " data lines "
|
||||
<< e->data1LineNumber()
|
||||
<< ", " << e->data2LineNumber();
|
||||
<< e->data1LineNumber()
|
||||
<< ", " << e->data2LineNumber();
|
||||
}
|
||||
else if (e->data1LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER)
|
||||
{
|
||||
@@ -258,17 +258,17 @@ void TextTestResult::printHeader(std::ostream& stream)
|
||||
stream << "\n\n";
|
||||
if (wasSuccessful())
|
||||
stream << "OK ("
|
||||
<< runTests() << " tests)"
|
||||
<< std::endl;
|
||||
<< runTests() << " tests)"
|
||||
<< std::endl;
|
||||
else
|
||||
stream << "!!!FAILURES!!!" << "\n"
|
||||
<< "Runs: "
|
||||
<< runTests ()
|
||||
<< " Failures: "
|
||||
<< testFailures ()
|
||||
<< " Errors: "
|
||||
<< testErrors ()
|
||||
<< std::endl;
|
||||
<< "Runs: "
|
||||
<< runTests ()
|
||||
<< " Failures: "
|
||||
<< testFailures ()
|
||||
<< " Errors: "
|
||||
<< testErrors ()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ private:
|
||||
void generateKey(const std::string& passphrase,
|
||||
const std::string& salt,
|
||||
int iterationCount);
|
||||
/// Generates key and IV from a password and optional salt string.
|
||||
/// Generates key and IV from a password and optional salt string.
|
||||
|
||||
void generateKey();
|
||||
/// Generates key and IV from random data.
|
||||
|
||||
@@ -119,7 +119,7 @@ inline std::string& getError(std::string& msg)
|
||||
while ((err = ERR_get_error()))
|
||||
{
|
||||
if (!msg.empty()) msg.append(1, '\n');
|
||||
msg.append(ERR_error_string(err, 0));
|
||||
msg.append(ERR_error_string(err, nullptr));
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
/// 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.
|
||||
|
||||
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
|
||||
/// using the given passphrase for the private key.
|
||||
///
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
/// is not exported.
|
||||
|
||||
void save(std::ostream* pPublicKeyStream,
|
||||
std::ostream* pPrivateKeyStream = 0,
|
||||
std::ostream* pPrivateKeyStream = nullptr,
|
||||
const std::string& privateKeyPassphrase = "") const;
|
||||
/// Exports the public and private key to the given streams.
|
||||
///
|
||||
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
/// If an empty filename is specified, the corresponding key
|
||||
/// is not exported.
|
||||
|
||||
void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "") 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.
|
||||
///
|
||||
/// If a null pointer is passed for a stream, the corresponding
|
||||
@@ -218,7 +218,7 @@ private:
|
||||
poco_check_ptr (ppKey);
|
||||
poco_assert_dbg (!*ppKey);
|
||||
|
||||
FILE* pFile = 0;
|
||||
FILE* pFile = nullptr;
|
||||
if (!keyFile.empty())
|
||||
{
|
||||
if (!getFunc) *ppKey = (K*)EVP_PKEY_new();
|
||||
@@ -236,11 +236,11 @@ private:
|
||||
|
||||
if (pFile)
|
||||
{
|
||||
pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)0 : &passCB;
|
||||
void* pPassword = pass.empty() ? (void*)0 : (void*)pass.c_str();
|
||||
pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)nullptr : &passCB;
|
||||
void* pPassword = pass.empty() ? (void*)nullptr : (void*)pass.c_str();
|
||||
if (readFunc(pFile, &pKey, pCB, pPassword))
|
||||
{
|
||||
fclose(pFile); pFile = 0;
|
||||
fclose(pFile); pFile = nullptr;
|
||||
if(getFunc)
|
||||
{
|
||||
*ppKey = (K*)getFunc(pKey);
|
||||
@@ -288,7 +288,7 @@ private:
|
||||
poco_check_ptr(ppKey);
|
||||
poco_assert_dbg(!*ppKey);
|
||||
|
||||
BIO* pBIO = 0;
|
||||
BIO* pBIO = nullptr;
|
||||
if (pIstr)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
@@ -301,11 +301,11 @@ private:
|
||||
EVP_PKEY* pKey = getFunc ? EVP_PKEY_new() : (EVP_PKEY*)*ppKey;
|
||||
if (pKey)
|
||||
{
|
||||
pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)0 : &passCB;
|
||||
void* pPassword = pass.empty() ? (void*)0 : (void*)pass.c_str();
|
||||
pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)nullptr : &passCB;
|
||||
void* pPassword = pass.empty() ? (void*)nullptr : (void*)pass.c_str();
|
||||
if (readFunc(pBIO, &pKey, pCB, pPassword))
|
||||
{
|
||||
BIO_free(pBIO); pBIO = 0;
|
||||
BIO_free(pBIO); pBIO = nullptr;
|
||||
if (getFunc)
|
||||
{
|
||||
*ppKey = (K*)getFunc(pKey);
|
||||
@@ -335,7 +335,7 @@ private:
|
||||
throw OpenSSLException(msg);
|
||||
}
|
||||
|
||||
EVP_PKEY* _pEVPPKey = 0;
|
||||
EVP_PKEY* _pEVPPKey = nullptr;
|
||||
static const std::map<int, std::string> KNOWN_TYPES;
|
||||
|
||||
friend class ECKeyImpl;
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
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.
|
||||
|
||||
KeyPair(const KeyPair& other);
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
/// is not exported.
|
||||
|
||||
virtual void save(std::ostream* pPublicKeyPairStream,
|
||||
std::ostream* pPrivateKeyPairStream = 0,
|
||||
std::ostream* pPrivateKeyPairStream = nullptr,
|
||||
const std::string& privateKeyPairPassphrase = "") const;
|
||||
/// Exports the public and private key to the given streams.
|
||||
///
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
/// is not exported.
|
||||
|
||||
virtual void save(std::ostream* pPublicKeyStream,
|
||||
std::ostream* pPrivateKeyStream = 0,
|
||||
std::ostream* pPrivateKeyStream = nullptr,
|
||||
const std::string& privateKeyPassphrase = "") const = 0;
|
||||
/// Exports the public and private key to the given streams.
|
||||
///
|
||||
|
||||
@@ -103,7 +103,7 @@ private:
|
||||
|
||||
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
|
||||
{
|
||||
return _pKey != 0;
|
||||
return _pKey != nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
/// is not exported.
|
||||
|
||||
void save(std::ostream* pPublicKeyStream,
|
||||
std::ostream* pPrivateKeyStream = 0,
|
||||
std::ostream* pPrivateKeyStream = nullptr,
|
||||
const std::string& privateKeyPassphrase = "") const;
|
||||
/// Exports the public and private key to the given streams.
|
||||
///
|
||||
@@ -138,4 +138,4 @@ inline const RSA* RSAKeyImpl::getRSA() const
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_RSAKeyImplImpl_INCLUDED
|
||||
#endif // Crypto_RSAKeyImplImpl_INCLUDED
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace Crypto {
|
||||
CipherFactory::CipherFactory()
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
OSSL_PROVIDER_load(NULL, "default");
|
||||
OSSL_PROVIDER_load(NULL, "legacy");
|
||||
OSSL_PROVIDER_load(nullptr, "default");
|
||||
OSSL_PROVIDER_load(nullptr, "legacy");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace
|
||||
{
|
||||
if (!msg.empty())
|
||||
msg.append("; ");
|
||||
msg.append(ERR_error_string(err, 0));
|
||||
msg.append(ERR_error_string(err, nullptr));
|
||||
}
|
||||
|
||||
throw Poco::IOException(msg);
|
||||
@@ -103,7 +103,7 @@ namespace
|
||||
_pContext,
|
||||
_pCipher,
|
||||
&_key[0],
|
||||
_iv.empty() ? 0 : &_iv[0],
|
||||
_iv.empty() ? nullptr : &_iv[0],
|
||||
(dir == DIR_ENCRYPT) ? 1 : 0);
|
||||
#else
|
||||
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 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
|
||||
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
|
||||
if (rc == 0) throwError();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace
|
||||
{
|
||||
if (!msg.empty())
|
||||
msg.append("; ");
|
||||
msg.append(ERR_error_string(err, 0));
|
||||
msg.append(ERR_error_string(err, nullptr));
|
||||
}
|
||||
|
||||
throw Poco::IOException(msg);
|
||||
@@ -49,8 +49,8 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name,
|
||||
const std::string& salt,
|
||||
int iterationCount,
|
||||
const std::string& digest):
|
||||
_pCipher(0),
|
||||
_pDigest(0),
|
||||
_pCipher(nullptr),
|
||||
_pDigest(nullptr),
|
||||
_name(name),
|
||||
_key(),
|
||||
_iv()
|
||||
@@ -76,8 +76,8 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name,
|
||||
CipherKeyImpl::CipherKeyImpl(const std::string& name,
|
||||
const ByteVec& key,
|
||||
const ByteVec& iv):
|
||||
_pCipher(0),
|
||||
_pDigest(0),
|
||||
_pCipher(nullptr),
|
||||
_pDigest(nullptr),
|
||||
_name(name),
|
||||
_key(key),
|
||||
_iv(iv)
|
||||
@@ -92,8 +92,8 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name,
|
||||
|
||||
|
||||
CipherKeyImpl::CipherKeyImpl(const std::string& name):
|
||||
_pCipher(0),
|
||||
_pDigest(0),
|
||||
_pCipher(nullptr),
|
||||
_pDigest(nullptr),
|
||||
_name(name),
|
||||
_key(),
|
||||
_iv()
|
||||
@@ -198,7 +198,7 @@ void CipherKeyImpl::generateKey(
|
||||
int keySize = EVP_BytesToKey(
|
||||
_pCipher,
|
||||
_pDigest ? _pDigest : EVP_md5(),
|
||||
(salt.empty() ? 0 : saltBytes),
|
||||
(salt.empty() ? nullptr : saltBytes),
|
||||
reinterpret_cast<const unsigned char*>(password.data()),
|
||||
static_cast<int>(password.size()),
|
||||
iterationCount,
|
||||
|
||||
@@ -36,7 +36,7 @@ CryptoStreamBuf::CryptoStreamBuf(std::istream& istr, CryptoTransform::Ptr pTrans
|
||||
Poco::BufferedStreamBuf(bufferSize, std::ios::in),
|
||||
_pTransform(pTransform),
|
||||
_pIstr(&istr),
|
||||
_pOstr(0),
|
||||
_pOstr(nullptr),
|
||||
_eof(false),
|
||||
_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):
|
||||
Poco::BufferedStreamBuf(bufferSize, std::ios::out),
|
||||
_pTransform(pTransform),
|
||||
_pIstr(0),
|
||||
_pIstr(nullptr),
|
||||
_pOstr(&ostr),
|
||||
_eof(false),
|
||||
_buffer(static_cast<std::size_t>(bufferSize))
|
||||
@@ -76,7 +76,7 @@ void CryptoStreamBuf::close()
|
||||
|
||||
if (_pIstr)
|
||||
{
|
||||
_pIstr = 0;
|
||||
_pIstr = nullptr;
|
||||
}
|
||||
else if (_pOstr)
|
||||
{
|
||||
@@ -84,7 +84,7 @@ void CryptoStreamBuf::close()
|
||||
// sure that we call finalize() only once, even if an exception is
|
||||
// thrown.
|
||||
std::ostream* pOstr = _pOstr;
|
||||
_pOstr = 0;
|
||||
_pOstr = nullptr;
|
||||
|
||||
// Finalize transformation.
|
||||
std::streamsize n = _pTransform->finalize(_buffer.begin(), static_cast<std::streamsize>(_buffer.size()));
|
||||
|
||||
@@ -26,7 +26,7 @@ DigestEngine::DigestEngine(const std::string& name):
|
||||
{
|
||||
const EVP_MD* md = EVP_get_digestbyname(_name.c_str());
|
||||
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
|
||||
const EVP_MD* md = EVP_get_digestbyname(_name.c_str());
|
||||
if (!md) throw Poco::NotFoundException(_name);
|
||||
EVP_DigestInit_ex(_pContext, md, NULL);
|
||||
EVP_DigestInit_ex(_pContext, md, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ ECDSASignature::ECDSASignature(const ByteVec& derSignature)
|
||||
poco_assert (!derSignature.empty());
|
||||
|
||||
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)
|
||||
throw OpenSSLException();
|
||||
}
|
||||
@@ -131,12 +131,12 @@ ECDSASignature::ECDSASignature(const ByteVec& rawR, const ByteVec& rawS):
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
ECDSA_SIG_set0(_pSig,
|
||||
BN_bin2bn(&rawR[0], static_cast<long>(rawR.size()), 0),
|
||||
BN_bin2bn(&rawS[0], static_cast<long>(rawS.size()), 0));
|
||||
const BIGNUM* pR = 0;
|
||||
const BIGNUM* pS = 0;
|
||||
BN_bin2bn(&rawR[0], static_cast<long>(rawR.size()), nullptr),
|
||||
BN_bin2bn(&rawS[0], static_cast<long>(rawS.size()), nullptr));
|
||||
const BIGNUM* pR = nullptr;
|
||||
const BIGNUM* pS = nullptr;
|
||||
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");
|
||||
#else
|
||||
if (!BN_bin2bn(&rawR[0], rawR.size(), _pSig->r))
|
||||
@@ -161,7 +161,7 @@ ECDSASignature::~ECDSASignature()
|
||||
|
||||
ECDSASignature::ByteVec ECDSASignature::toDER() const
|
||||
{
|
||||
int size = i2d_ECDSA_SIG(_pSig, 0);
|
||||
int size = i2d_ECDSA_SIG(_pSig, nullptr);
|
||||
if (size > 0)
|
||||
{
|
||||
ByteVec buffer(size);
|
||||
|
||||
@@ -38,7 +38,7 @@ ECKeyImpl::ECKeyImpl(const EVPPKey& key):
|
||||
|
||||
ECKeyImpl::ECKeyImpl(const X509Certificate& cert):
|
||||
KeyPairImpl("ec", KT_EC_IMPL),
|
||||
_pEC(0)
|
||||
_pEC(nullptr)
|
||||
{
|
||||
const X509* pCert = cert.certificate();
|
||||
if (pCert)
|
||||
@@ -78,7 +78,7 @@ ECKeyImpl::ECKeyImpl(int curve):
|
||||
|
||||
ECKeyImpl::ECKeyImpl(const std::string& publicKeyFile,
|
||||
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))
|
||||
{
|
||||
@@ -101,7 +101,7 @@ ECKeyImpl::ECKeyImpl(const std::string& publicKeyFile,
|
||||
|
||||
ECKeyImpl::ECKeyImpl(std::istream* pPublicKeyStream,
|
||||
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))
|
||||
{
|
||||
@@ -141,7 +141,7 @@ void ECKeyImpl::freeEC()
|
||||
if (_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 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*) OPENSSL_malloc(sizeof(EC_builtin_curve) * len);
|
||||
if (!pCurves) return curveName;
|
||||
@@ -206,7 +206,7 @@ std::string ECKeyImpl::getCurveName(int nid)
|
||||
int ECKeyImpl::getCurveNID(std::string& name)
|
||||
{
|
||||
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*)OPENSSL_malloc(static_cast<int>(sizeof(EC_builtin_curve) * len));
|
||||
if (!pCurves) return -1;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace
|
||||
while ((err = ERR_get_error()))
|
||||
{
|
||||
if (!msg.empty()) msg.append("; ");
|
||||
msg.append(ERR_error_string(err, 0));
|
||||
msg.append(ERR_error_string(err, nullptr));
|
||||
}
|
||||
|
||||
throw Poco::IOException(msg);
|
||||
@@ -43,7 +43,7 @@ namespace
|
||||
{
|
||||
public:
|
||||
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)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ namespace
|
||||
_pEVP(pEVP),
|
||||
_pCtx(_pEVP),
|
||||
_pos(0),
|
||||
_pBuf(0)
|
||||
_pBuf(nullptr)
|
||||
{
|
||||
std::string fmt = "EVPEncryptImpl():%s()";
|
||||
poco_check_ptr(_pEVP);
|
||||
@@ -82,7 +82,7 @@ namespace
|
||||
throwError(Poco::format(fmt, std::string("EVP_PKEY_CTX_new")));
|
||||
|
||||
if (EVP_PKEY_encrypt_init(_pCtx) <= 0)
|
||||
throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt_init")));
|
||||
throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt_init")));
|
||||
|
||||
_blockSize = EVP_PKEY_size(const_cast<EVP_PKEY*>(_pEVP));
|
||||
if (!_blockSize)
|
||||
@@ -126,7 +126,7 @@ namespace
|
||||
{
|
||||
poco_assert (outputLength >= evpSize);
|
||||
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)")));
|
||||
if (EVP_PKEY_encrypt(_pCtx, output, &outLen, _pBuf, static_cast<std::size_t>(maxSize)) <= 0)
|
||||
throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt")));
|
||||
@@ -156,7 +156,7 @@ namespace
|
||||
std::size_t outLen = 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")));
|
||||
if (EVP_PKEY_encrypt(_pCtx, output, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0)
|
||||
throwError(Poco::format(fmt, std::string("EVP_PKEY_encrypt")));
|
||||
@@ -169,7 +169,7 @@ namespace
|
||||
{
|
||||
std::string fmt = "EVPEncryptImpl::maxDataSize():%s()";
|
||||
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")));
|
||||
return outLength;
|
||||
}
|
||||
@@ -189,13 +189,13 @@ namespace
|
||||
_pEVP(pEVP),
|
||||
_pCtx(_pEVP),
|
||||
_pos(0),
|
||||
_pBuf(0)
|
||||
_pBuf(nullptr)
|
||||
{
|
||||
std::string fmt = "EVPDecryptImpl():%s()";
|
||||
poco_check_ptr(_pEVP);
|
||||
|
||||
if (EVP_PKEY_decrypt_init(_pCtx) <= 0)
|
||||
throwError(Poco::format(fmt, std::string("EVP_PKEY_decrypt_init")));
|
||||
throwError(Poco::format(fmt, std::string("EVP_PKEY_decrypt_init")));
|
||||
|
||||
_blockSize = EVP_PKEY_size(const_cast<EVP_PKEY*>(_pEVP));
|
||||
if (!_blockSize)
|
||||
@@ -237,7 +237,7 @@ namespace
|
||||
if (missing == 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)")));
|
||||
if (EVP_PKEY_decrypt(_pCtx, output, &outLen, _pBuf, static_cast<std::size_t>(_pos)) <= 0)
|
||||
throwError(Poco::format(fmt, std::string("EVP_PKEY_decrypt")));
|
||||
@@ -263,7 +263,7 @@ namespace
|
||||
poco_assert (length >= _blockSize);
|
||||
std::string fmt = "EVPDecryptImpl::finalize():%s()";
|
||||
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)")));
|
||||
poco_assert (length >= outLen);
|
||||
if (_pos > 0)
|
||||
|
||||
@@ -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());
|
||||
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);
|
||||
poco_check_ptr(_pEVPPKey);
|
||||
@@ -55,8 +55,7 @@ EVPPKey::EVPPKey(const char* ecCurveName): _pEVPPKey(0)
|
||||
}
|
||||
|
||||
|
||||
EVPPKey::EVPPKey(const X509Certificate& cert):
|
||||
_pEVPPKey(X509_get_pubkey(const_cast<X509*>(cert.certificate())))
|
||||
EVPPKey::EVPPKey(const X509Certificate& cert): _pEVPPKey(X509_get_pubkey(const_cast<X509*>(cert.certificate())))
|
||||
{
|
||||
poco_check_ptr(_pEVPPKey);
|
||||
checkType();
|
||||
@@ -138,7 +137,7 @@ void EVPPKey::setKeyFromParameters(OSSL_PARAM* parameters)
|
||||
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)
|
||||
{
|
||||
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))
|
||||
{
|
||||
@@ -172,13 +171,13 @@ EVPPKey::EVPPKey(const std::vector<unsigned char>* public_key, const std::vector
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#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);
|
||||
if (NULL == pCtx)
|
||||
EVP_PKEY_CTX* pCtx = EVP_PKEY_CTX_new_id(type, nullptr);
|
||||
if (nullptr == pCtx)
|
||||
{
|
||||
std::string msg = Poco::format(
|
||||
"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
|
||||
|
||||
|
||||
EVPPKey::EVPPKey(EVP_PKEY* pEVPPKey): _pEVPPKey(0)
|
||||
EVPPKey::EVPPKey(EVP_PKEY* pEVPPKey) : _pEVPPKey(nullptr)
|
||||
{
|
||||
duplicate(pEVPPKey, &_pEVPPKey);
|
||||
poco_check_ptr(_pEVPPKey);
|
||||
@@ -244,19 +243,16 @@ EVPPKey::EVPPKey(EVP_PKEY* pEVPPKey): _pEVPPKey(0)
|
||||
}
|
||||
|
||||
|
||||
EVPPKey::EVPPKey(const std::string& publicKeyFile,
|
||||
const std::string& privateKeyFile,
|
||||
const std::string& privateKeyPassphrase): _pEVPPKey(0)
|
||||
EVPPKey::EVPPKey(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase) : _pEVPPKey(nullptr)
|
||||
{
|
||||
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);
|
||||
return; // private key is enough
|
||||
}
|
||||
|
||||
// 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";
|
||||
throw OpenSSLException(getError(msg));
|
||||
}
|
||||
@@ -265,19 +261,16 @@ EVPPKey::EVPPKey(const std::string& publicKeyFile,
|
||||
}
|
||||
|
||||
|
||||
EVPPKey::EVPPKey(std::istream* pPublicKeyStream,
|
||||
std::istream* pPrivateKeyStream,
|
||||
const std::string& privateKeyPassphrase): _pEVPPKey(0)
|
||||
EVPPKey::EVPPKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase) : _pEVPPKey(nullptr)
|
||||
{
|
||||
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);
|
||||
return; // private key is enough
|
||||
}
|
||||
|
||||
// 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";
|
||||
throw OpenSSLException(getError(msg));
|
||||
}
|
||||
@@ -416,13 +409,13 @@ void EVPPKey::save(const std::string& publicKeyFile, const std::string& privateK
|
||||
int rc = 0;
|
||||
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
|
||||
{
|
||||
rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, EVP_des_ede3_cbc(),
|
||||
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())),
|
||||
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)
|
||||
{
|
||||
@@ -483,11 +476,11 @@ void EVPPKey::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStre
|
||||
}
|
||||
int rc = 0;
|
||||
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
|
||||
rc = PEM_write_bio_PrivateKey(bio, _pEVPPKey, EVP_des_ede3_cbc(),
|
||||
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())),
|
||||
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)
|
||||
{
|
||||
std::string msg = "EVPPKey::save(ostream*, ostream*, const string&)\n";
|
||||
|
||||
@@ -65,7 +65,7 @@ void Envelope::addKey(const EVPPKey& key)
|
||||
|
||||
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);
|
||||
int i = 0;
|
||||
for (const auto& k : _encKeys)
|
||||
@@ -92,7 +92,7 @@ const Envelope::ByteVec& Envelope::seal(const ByteVec& plainData)
|
||||
|
||||
int cipherTextLen = 0, len = 0;
|
||||
int plainDataSize = static_cast<int>(plainData.size());
|
||||
_encContent.resize(plainDataSize + blockSize());
|
||||
_encContent.resize(plainDataSize + blockSize());
|
||||
if (1 != EVP_SealUpdate(_pCtx, &_encContent[0], &len, &plainData[0], plainDataSize))
|
||||
handleErrors(std::string("Envelope::seal():EVP_SealUpdate()"));
|
||||
|
||||
@@ -153,7 +153,7 @@ void Envelope::handleErrors(std::string&& msg)
|
||||
while ((err = ERR_get_error()))
|
||||
{
|
||||
if (!msg.empty()) msg.append("\n");
|
||||
msg.append(ERR_error_string(err, 0));
|
||||
msg.append(ERR_error_string(err, nullptr));
|
||||
}
|
||||
throw CryptoException(msg);
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ Poco::FastMutex* OpenSSLInitializer::_mutexes(0);
|
||||
#endif
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
OSSL_PROVIDER* OpenSSLInitializer::_defaultProvider(0);
|
||||
OSSL_PROVIDER* OpenSSLInitializer::_legacyProvider(0);
|
||||
OSSL_PROVIDER* OpenSSLInitializer::_defaultProvider(nullptr);
|
||||
OSSL_PROVIDER* OpenSSLInitializer::_legacyProvider(nullptr);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -95,9 +95,9 @@ void OpenSSLInitializer::initialize()
|
||||
if (++_rc == 1)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
CONF_modules_load(NULL, NULL, 0);
|
||||
CONF_modules_load(nullptr, nullptr, 0);
|
||||
#else
|
||||
OPENSSL_config(NULL);
|
||||
OPENSSL_config(nullptr);
|
||||
#endif
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
@@ -131,12 +131,12 @@ void OpenSSLInitializer::initialize()
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
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 (!_legacyProvider)
|
||||
{
|
||||
_legacyProvider = OSSL_PROVIDER_load(NULL, "legacy");
|
||||
_legacyProvider = OSSL_PROVIDER_load(nullptr, "legacy");
|
||||
// Note: use haveLegacyProvider() to check if legacy provider has been loaded
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
|
||||
#include "Poco/Crypto/PKCS12Container.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include <sstream>
|
||||
#include <openssl/err.h>
|
||||
@@ -29,7 +28,7 @@ namespace Poco {
|
||||
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;
|
||||
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()));
|
||||
if (pBIO)
|
||||
{
|
||||
PKCS12* pPKCS12 = 0;
|
||||
PKCS12* pPKCS12 = nullptr;
|
||||
d2i_PKCS12_bio(pBIO, &pPKCS12);
|
||||
BIO_free(pBIO);
|
||||
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");
|
||||
if (pFile)
|
||||
{
|
||||
PKCS12* pPKCS12 = d2i_PKCS12_fp(pFile, NULL);
|
||||
PKCS12* pPKCS12 = d2i_PKCS12_fp(pFile, nullptr);
|
||||
fclose (pFile);
|
||||
if (!pPKCS12) throw OpenSSLException("PKCS12Container(const string&, const string&)");
|
||||
load(pPKCS12, password);
|
||||
@@ -145,8 +144,8 @@ void PKCS12Container::load(PKCS12* pPKCS12, const std::string& password)
|
||||
{
|
||||
if (pPKCS12)
|
||||
{
|
||||
X509* pCert = 0;
|
||||
STACK_OF(X509)* pCA = 0;
|
||||
X509* pCert = nullptr;
|
||||
STACK_OF(X509)* pCA = nullptr;
|
||||
if (PKCS12_parse(pPKCS12, password.c_str(), &_pKey, &pCert, &pCA))
|
||||
{
|
||||
if (pCert)
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace
|
||||
{
|
||||
if (!msg.empty())
|
||||
msg.append("; ");
|
||||
msg.append(ERR_error_string(err, 0));
|
||||
msg.append(ERR_error_string(err, nullptr));
|
||||
}
|
||||
|
||||
throw Poco::IOException(msg);
|
||||
@@ -76,7 +76,7 @@ namespace
|
||||
unsigned char* output,
|
||||
std::streamsize outputLength);
|
||||
|
||||
std::streamsize finalize(unsigned char* output, std::streamsize length);
|
||||
std::streamsize finalize(unsigned char* output, std::streamsize length);
|
||||
|
||||
private:
|
||||
const RSA* _pRSA;
|
||||
@@ -90,7 +90,7 @@ namespace
|
||||
_pRSA(pRSA),
|
||||
_paddingMode(paddingMode),
|
||||
_pos(0),
|
||||
_pBuf(0)
|
||||
_pBuf(nullptr)
|
||||
{
|
||||
_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),
|
||||
_paddingMode(paddingMode),
|
||||
_pos(0),
|
||||
_pBuf(0)
|
||||
_pBuf(nullptr)
|
||||
{
|
||||
_pBuf = new unsigned char[blockSize()];
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ const DigestEngine::Digest& RSADigestEngine::signature()
|
||||
if (sigLen < _signature.size())
|
||||
_signature.resize(sigLen);
|
||||
}
|
||||
return _signature;
|
||||
return _signature;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
#include "Poco/Crypto/RSAKeyImpl.h"
|
||||
#include "Poco/Crypto/X509Certificate.h"
|
||||
#include "Poco/Crypto/PKCS12Container.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include <sstream>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/evp.h>
|
||||
@@ -38,7 +36,7 @@ RSAKeyImpl::RSAKeyImpl(const EVPPKey& key):
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert):
|
||||
KeyPairImpl("rsa", KT_RSA_IMPL),
|
||||
_pRSA(0)
|
||||
_pRSA(nullptr)
|
||||
{
|
||||
const X509* pCert = cert.certificate();
|
||||
EVP_PKEY* pKey = X509_get_pubkey(const_cast<X509*>(pCert));
|
||||
@@ -54,24 +52,24 @@ RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert):
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(const PKCS12Container& cont):
|
||||
KeyPairImpl("rsa", KT_RSA_IMPL),
|
||||
_pRSA(0)
|
||||
_pRSA(nullptr)
|
||||
{
|
||||
EVPPKey key = cont.getKey();
|
||||
_pRSA = EVP_PKEY_get1_RSA(key);
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent): KeyPairImpl("rsa", KT_RSA_IMPL),
|
||||
_pRSA(0)
|
||||
RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent) : KeyPairImpl("rsa", KT_RSA_IMPL),
|
||||
_pRSA(nullptr)
|
||||
{
|
||||
_pRSA = RSA_new();
|
||||
int ret = 0;
|
||||
BIGNUM* bn = 0;
|
||||
BIGNUM* bn = nullptr;
|
||||
try
|
||||
{
|
||||
bn = BN_new();
|
||||
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);
|
||||
}
|
||||
catch (...)
|
||||
@@ -83,12 +81,11 @@ RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent): KeyPairImpl("rsa"
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(const std::string& publicKeyFile,
|
||||
const std::string& privateKeyFile,
|
||||
const std::string& privateKeyPassphrase): KeyPairImpl("rsa", KT_RSA_IMPL),
|
||||
_pRSA(0)
|
||||
RSAKeyImpl::RSAKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase):
|
||||
KeyPairImpl("rsa", KT_RSA_IMPL),
|
||||
_pRSA(nullptr)
|
||||
{
|
||||
poco_assert_dbg(_pRSA == 0);
|
||||
poco_assert_dbg(_pRSA == nullptr);
|
||||
|
||||
_pRSA = RSA_new();
|
||||
if (!publicKeyFile.empty())
|
||||
@@ -98,14 +95,14 @@ RSAKeyImpl::RSAKeyImpl(const std::string& publicKeyFile,
|
||||
int rc = BIO_read_filename(bio, publicKeyFile.c_str());
|
||||
if (rc)
|
||||
{
|
||||
RSA* pubKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0);
|
||||
RSA* pubKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, nullptr, nullptr);
|
||||
if (!pubKey)
|
||||
{
|
||||
int rc = BIO_reset(bio);
|
||||
// BIO_reset() normally returns 1 for success and 0 or -1 for failure.
|
||||
// File BIOs are an exception, they return 0 for success and -1 for failure.
|
||||
if (rc != 0) throw Poco::FileException("Failed to load public key", publicKeyFile);
|
||||
pubKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, 0, 0);
|
||||
pubKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, nullptr, nullptr);
|
||||
}
|
||||
BIO_free(bio);
|
||||
if (!pubKey)
|
||||
@@ -128,11 +125,11 @@ RSAKeyImpl::RSAKeyImpl(const std::string& publicKeyFile,
|
||||
int rc = BIO_read_filename(bio, privateKeyFile.c_str());
|
||||
if (rc)
|
||||
{
|
||||
RSA* privKey = 0;
|
||||
RSA* privKey = nullptr;
|
||||
if (privateKeyPassphrase.empty())
|
||||
privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, 0);
|
||||
privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, nullptr, nullptr);
|
||||
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);
|
||||
if (!privKey)
|
||||
{
|
||||
@@ -149,12 +146,11 @@ RSAKeyImpl::RSAKeyImpl(const std::string& publicKeyFile,
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream,
|
||||
std::istream* pPrivateKeyStream,
|
||||
const std::string& privateKeyPassphrase): KeyPairImpl("rsa", KT_RSA_IMPL),
|
||||
_pRSA(0)
|
||||
RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase):
|
||||
KeyPairImpl("rsa", KT_RSA_IMPL),
|
||||
_pRSA(nullptr)
|
||||
{
|
||||
poco_assert_dbg(_pRSA == 0);
|
||||
poco_assert_dbg(_pRSA == nullptr);
|
||||
|
||||
_pRSA = RSA_new();
|
||||
if (pPublicKeyStream)
|
||||
@@ -163,14 +159,14 @@ RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream,
|
||||
Poco::StreamCopier::copyToString(*pPublicKeyStream, publicKeyData);
|
||||
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");
|
||||
RSA* publicKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0);
|
||||
RSA* publicKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, nullptr, nullptr);
|
||||
if (!publicKey)
|
||||
{
|
||||
int rc = BIO_reset(bio);
|
||||
// BIO_reset() normally returns 1 for success and 0 or -1 for failure.
|
||||
// File BIOs are an exception, they return 0 for success and -1 for failure.
|
||||
if (rc != 1) throw Poco::FileException("Failed to load public key");
|
||||
publicKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, 0, 0);
|
||||
publicKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, nullptr, nullptr);
|
||||
}
|
||||
BIO_free(bio);
|
||||
if (!publicKey)
|
||||
@@ -186,11 +182,11 @@ RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream,
|
||||
Poco::StreamCopier::copyToString(*pPrivateKeyStream, privateKeyData);
|
||||
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");
|
||||
RSA* privateKey = 0;
|
||||
RSA* privateKey = nullptr;
|
||||
if (privateKeyPassphrase.empty())
|
||||
privateKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, 0);
|
||||
privateKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, nullptr, nullptr);
|
||||
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);
|
||||
if (!privateKey)
|
||||
{
|
||||
@@ -210,7 +206,7 @@ RSAKeyImpl::~RSAKeyImpl()
|
||||
void RSAKeyImpl::freeRSA()
|
||||
{
|
||||
if (_pRSA) RSA_free(_pRSA);
|
||||
_pRSA = 0;
|
||||
_pRSA = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -223,9 +219,9 @@ int RSAKeyImpl::size() const
|
||||
RSAKeyImpl::ByteVec RSAKeyImpl::modulus() const
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
const BIGNUM* n = 0;
|
||||
const BIGNUM* e = 0;
|
||||
const BIGNUM* d = 0;
|
||||
const BIGNUM* n = nullptr;
|
||||
const BIGNUM* e = nullptr;
|
||||
const BIGNUM* d = nullptr;
|
||||
RSA_get0_key(_pRSA, &n, &e, &d);
|
||||
return convertToByteVec(n);
|
||||
#else
|
||||
@@ -237,9 +233,9 @@ RSAKeyImpl::ByteVec RSAKeyImpl::modulus() const
|
||||
RSAKeyImpl::ByteVec RSAKeyImpl::encryptionExponent() const
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
const BIGNUM* n = 0;
|
||||
const BIGNUM* e = 0;
|
||||
const BIGNUM* d = 0;
|
||||
const BIGNUM* n = nullptr;
|
||||
const BIGNUM* e = nullptr;
|
||||
const BIGNUM* d = nullptr;
|
||||
RSA_get0_key(_pRSA, &n, &e, &d);
|
||||
return convertToByteVec(e);
|
||||
#else
|
||||
@@ -251,9 +247,9 @@ RSAKeyImpl::ByteVec RSAKeyImpl::encryptionExponent() const
|
||||
RSAKeyImpl::ByteVec RSAKeyImpl::decryptionExponent() const
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
const BIGNUM* n = 0;
|
||||
const BIGNUM* e = 0;
|
||||
const BIGNUM* d = 0;
|
||||
const BIGNUM* n = nullptr;
|
||||
const BIGNUM* e = nullptr;
|
||||
const BIGNUM* d = nullptr;
|
||||
RSA_get0_key(_pRSA, &n, &e, &d);
|
||||
return convertToByteVec(d);
|
||||
#else
|
||||
@@ -297,11 +293,11 @@ void RSAKeyImpl::save(const std::string& publicKeyFile,
|
||||
{
|
||||
int rc = 0;
|
||||
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
|
||||
rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(),
|
||||
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())),
|
||||
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) throw Poco::FileException("Failed to write private key to 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");
|
||||
int rc = 0;
|
||||
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
|
||||
rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(),
|
||||
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())),
|
||||
static_cast<int>(privateKeyPassphrase.length()), 0, 0);
|
||||
rc = PEM_write_bio_RSAPrivateKey(bio,
|
||||
_pRSA, EVP_des_ede3_cbc(),
|
||||
reinterpret_cast<unsigned char *>( const_cast<char *>(privateKeyPassphrase.c_str())),
|
||||
static_cast<int>(privateKeyPassphrase.length()), nullptr, nullptr);
|
||||
if (!rc)
|
||||
{
|
||||
BIO_free(bio);
|
||||
@@ -376,4 +373,4 @@ RSAKeyImpl::ByteVec RSAKeyImpl::convertToByteVec(const BIGNUM* bn)
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "Poco/Crypto/X509Certificate.h"
|
||||
#include "Poco/Crypto/CryptoException.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/DateTimeParser.h"
|
||||
#include "Poco/Format.h"
|
||||
#include <sstream>
|
||||
@@ -41,15 +40,13 @@ namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(std::istream& istr):
|
||||
_pCert(0)
|
||||
X509Certificate::X509Certificate(std::istream& istr) : _pCert(nullptr)
|
||||
{
|
||||
load(istr);
|
||||
}
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(const std::string& path):
|
||||
_pCert(0)
|
||||
X509Certificate::X509Certificate(const std::string& path) : _pCert(nullptr)
|
||||
{
|
||||
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()));
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0);
|
||||
_pCert = PEM_read_bio_X509(pBIO, nullptr, nullptr, nullptr);
|
||||
BIO_free(pBIO);
|
||||
|
||||
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));
|
||||
_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)
|
||||
{
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
const GENERAL_NAME* name = sk_GENERAL_NAME_value(names, i);
|
||||
@@ -416,8 +412,9 @@ X509Certificate::List X509Certificate::readPEM(const std::string& pemFileName)
|
||||
{
|
||||
List caCertList;
|
||||
BIO* pBIO = BIO_new_file(pemFileName.c_str(), "r");
|
||||
if (pBIO == NULL) throw OpenFileException(Poco::format("X509Certificate::readPEM(%s)", pemFileName));
|
||||
X509* x = PEM_read_bio_X509(pBIO, NULL, 0, NULL);
|
||||
if (pBIO == nullptr)
|
||||
throw OpenFileException(Poco::format("X509Certificate::readPEM(%s)", pemFileName));
|
||||
X509* x = PEM_read_bio_X509(pBIO, nullptr, nullptr, nullptr);
|
||||
if (!x)
|
||||
{
|
||||
BIO_free(pBIO);
|
||||
@@ -426,7 +423,7 @@ X509Certificate::List X509Certificate::readPEM(const std::string& pemFileName)
|
||||
while (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);
|
||||
return caCertList;
|
||||
@@ -436,7 +433,7 @@ X509Certificate::List X509Certificate::readPEM(const std::string& pemFileName)
|
||||
void X509Certificate::writePEM(const std::string& pemFileName, const List& list)
|
||||
{
|
||||
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 end = list.end();
|
||||
for (; it != end; ++it)
|
||||
|
||||
@@ -123,7 +123,7 @@ void EVPTest::testRSAEVPPKey()
|
||||
|
||||
BIO* bioPriv1 = 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));
|
||||
char* pPrivData1;
|
||||
long sizePriv1 = BIO_get_mem_data(bioPriv1, &pPrivData1);
|
||||
@@ -138,7 +138,7 @@ void EVPTest::testRSAEVPPKey()
|
||||
|
||||
BIO* bioPriv2 = 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));
|
||||
char* pPrivData2;
|
||||
long sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
|
||||
@@ -158,7 +158,7 @@ void EVPTest::testRSAEVPPKey()
|
||||
assertTrue (evpPKey2.type() == EVP_PKEY_RSA);
|
||||
bioPriv2 = 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));
|
||||
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
|
||||
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
|
||||
@@ -176,7 +176,7 @@ void EVPTest::testRSAEVPPKey()
|
||||
assertTrue (evpPKey3.type() == EVP_PKEY_RSA);
|
||||
bioPriv2 = 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));
|
||||
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
|
||||
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
|
||||
@@ -229,7 +229,7 @@ void EVPTest::testRSAEVPSaveLoadStream()
|
||||
assertTrue (strPub2.str() == pubKey);
|
||||
|
||||
std::istringstream iPriv2(strPriv2.str());
|
||||
EVPPKey key3(0, &iPriv2, "testpwd");
|
||||
EVPPKey key3(nullptr, &iPriv2, "testpwd");
|
||||
std::ostringstream strPub3;
|
||||
key3.save(&strPub3);
|
||||
assertTrue (strPub3.str() == pubKey);
|
||||
@@ -261,7 +261,7 @@ void EVPTest::testRSAEVPSaveLoadStreamNoPass()
|
||||
assertTrue (!(key2 == keyNE));
|
||||
|
||||
std::istringstream iPriv2(privKey);
|
||||
EVPPKey key3(0, &iPriv2);
|
||||
EVPPKey key3(nullptr, &iPriv2);
|
||||
std::ostringstream strPub3;
|
||||
key3.save(&strPub3);
|
||||
std::string pubFromPrivate = strPub3.str();
|
||||
@@ -277,7 +277,7 @@ void EVPTest::testECEVPPKey()
|
||||
if (!curveName.empty())
|
||||
{
|
||||
EVPPKey* pKey = new EVPPKey(curveName);
|
||||
assertTrue (pKey != 0);
|
||||
assertTrue(pKey != nullptr);
|
||||
assertTrue (!pKey->isSupported(0));
|
||||
assertTrue (!pKey->isSupported(-1));
|
||||
assertTrue (pKey->isSupported(pKey->type()));
|
||||
@@ -285,7 +285,7 @@ void EVPTest::testECEVPPKey()
|
||||
|
||||
BIO* bioPriv1 = 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));
|
||||
char* pPrivData1;
|
||||
long sizePriv1 = BIO_get_mem_data(bioPriv1, &pPrivData1);
|
||||
@@ -300,7 +300,7 @@ void EVPTest::testECEVPPKey()
|
||||
|
||||
BIO* bioPriv2 = 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));
|
||||
char* pPrivData2;
|
||||
long sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
|
||||
@@ -320,7 +320,7 @@ void EVPTest::testECEVPPKey()
|
||||
assertTrue (evpPKey2.type() == EVP_PKEY_EC);
|
||||
bioPriv2 = 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));
|
||||
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
|
||||
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
|
||||
@@ -338,7 +338,7 @@ void EVPTest::testECEVPPKey()
|
||||
assertTrue (evpPKey3.type() == EVP_PKEY_EC);
|
||||
bioPriv2 = 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));
|
||||
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
|
||||
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
|
||||
@@ -402,7 +402,7 @@ void EVPTest::testECEVPSaveLoadStream()
|
||||
assertTrue (strPub2.str() == pubKey);
|
||||
|
||||
std::istringstream iPriv2(strPriv2.str());
|
||||
EVPPKey key3(0, &iPriv2, "testpwd");
|
||||
EVPPKey key3(nullptr, &iPriv2, "testpwd");
|
||||
std::ostringstream strPub3;
|
||||
key3.save(&strPub3);
|
||||
std::string pubFromPrivate = strPub3.str();
|
||||
@@ -458,7 +458,7 @@ void EVPTest::testECEVPSaveLoadStreamNoPass()
|
||||
assertTrue (strPriv2.str() == privKey);
|
||||
|
||||
std::istringstream iPriv2(privKey);
|
||||
EVPPKey key3(0, &iPriv2);
|
||||
EVPPKey key3(nullptr, &iPriv2);
|
||||
std::ostringstream strPub3;
|
||||
key3.save(&strPub3);
|
||||
std::string pubFromPrivate = strPub3.str();
|
||||
@@ -577,7 +577,7 @@ void EVPTest::testRSAEVPKeyFromX509()
|
||||
X509Certificate cert(str);
|
||||
EVPPKey publicKey(cert);
|
||||
std::istringstream str2(anyPemRSA);
|
||||
EVPPKey privateKey(0, &str2, "test");
|
||||
EVPPKey privateKey(nullptr, &str2, "test");
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey);
|
||||
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey);
|
||||
std::string val("lets do some encryption");
|
||||
@@ -631,7 +631,7 @@ void EVPTest::testRSAEVPKeyByLength()
|
||||
assertTrue (!(key2 == keyNE));
|
||||
|
||||
std::istringstream iPriv2(privKey);
|
||||
EVPPKey key3(0, &iPriv2);
|
||||
EVPPKey key3(nullptr, &iPriv2);
|
||||
std::ostringstream strPub3;
|
||||
key3.save(&strPub3);
|
||||
std::string pubFromPrivate = strPub3.str();
|
||||
@@ -672,7 +672,7 @@ void EVPTest::testECEVPKeyByLength()
|
||||
assertTrue (!(key2 == keyNE));
|
||||
|
||||
std::istringstream iPriv2(privKey);
|
||||
EVPPKey key3(0, &iPriv2);
|
||||
EVPPKey key3(nullptr, &iPriv2);
|
||||
std::ostringstream strPub3;
|
||||
key3.save(&strPub3);
|
||||
std::string pubFromPrivate = strPub3.str();
|
||||
@@ -689,10 +689,10 @@ void EVPTest::testEVPKeyByModulus()
|
||||
{
|
||||
std::string e = "AQAB";
|
||||
std::string n = "ylJgMkU_bDwCLzMlo47igdZ-AC8oUbtGJUOUHnuJdjflpim7FOxw0zXYf9m0tzND0Bt1y7MPyVtf-3rwInvdgi65CZEJ3kt5PE0g6trPbvyW6hJcVeOsQvSErj33mY6RsjndLhNE-RY36G8o603au64lTOYSb9HjzzRFo4F_faEgQ02jpEYkLIWwf7PboExDbd6NGMV0uume8YA6eB3z5BwfMMHyRZA0FcIzj6F0V-hDqBaJkWegpJsukgpfO7JDKaU5rlor7j6CdbfLaWorYTCUH3F-bXZ1ojBe0wHRGEgEZBNa46A3clgNohQuuNzf4K12NFGnEl_TIFRcLm6M0Q";
|
||||
try
|
||||
try
|
||||
{
|
||||
unsigned long exponent = 0;
|
||||
if ((e == "AQAB") || (e == "AAEAAQ"))
|
||||
if ((e == "AQAB") || (e == "AAEAAQ"))
|
||||
{
|
||||
exponent = RSA_F4; //Poco::Crypto::RSAKey::Exponent::EXP_LARGE
|
||||
}
|
||||
@@ -715,7 +715,7 @@ void EVPTest::testEVPKeyByModulus()
|
||||
{
|
||||
std::cerr << ex.displayText() << std::endl;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // OPENSSL_VERSION_NUMBER >= 0x30000000
|
||||
|
||||
@@ -101,7 +101,7 @@ void RSATest::testNewKeys()
|
||||
RSAKey key2(&iPub, &iPriv, "testpwd");
|
||||
|
||||
std::istringstream iPriv2(privKey);
|
||||
RSAKey key3(0, &iPriv2, "testpwd");
|
||||
RSAKey key3(nullptr, &iPriv2, "testpwd");
|
||||
std::ostringstream strPub3;
|
||||
key3.save(&strPub3);
|
||||
std::string pubFromPrivate = strPub3.str();
|
||||
@@ -124,7 +124,7 @@ void RSATest::testNewKeysNoPassphrase()
|
||||
RSAKey key2(&iPub, &iPriv);
|
||||
|
||||
std::istringstream iPriv2(privKey);
|
||||
RSAKey key3(0, &iPriv2);
|
||||
RSAKey key3(nullptr, &iPriv2);
|
||||
std::ostringstream strPub3;
|
||||
key3.save(&strPub3);
|
||||
std::string pubFromPrivate = strPub3.str();
|
||||
@@ -219,17 +219,17 @@ void RSATest::testRSACipher()
|
||||
strPub.close();
|
||||
strPriv.close();
|
||||
|
||||
Poco::Crypto::RSAKey encryptKey(pubKeyFile);
|
||||
Poco::Crypto::RSAKey encryptKey(pubKeyFile);
|
||||
Poco::Crypto::RSAKey decryptKey(pubKeyFile, privKeyFile);
|
||||
|
||||
Poco::Crypto::CipherFactory factory;
|
||||
auto iengine = factory.createCipher(encryptKey);
|
||||
auto oengine = factory.createCipher(decryptKey);
|
||||
Poco::Crypto::CipherFactory factory;
|
||||
auto iengine = factory.createCipher(encryptKey);
|
||||
auto oengine = factory.createCipher(decryptKey);
|
||||
|
||||
std::string ss = "test_str";
|
||||
auto enc = iengine->encryptString(ss);
|
||||
auto dec = oengine->decryptString(enc);
|
||||
assertEqual (ss, dec);
|
||||
std::string ss = "test_str";
|
||||
auto enc = iengine->encryptString(ss);
|
||||
auto dec = oengine->decryptString(enc);
|
||||
assertEqual (ss, dec);
|
||||
|
||||
delete iengine;
|
||||
delete oengine;
|
||||
@@ -269,7 +269,7 @@ void RSATest::testCertificate()
|
||||
X509Certificate cert(str);
|
||||
RSAKey publicKey(cert);
|
||||
std::istringstream str2(anyPem);
|
||||
RSAKey privateKey(0, &str2, "test");
|
||||
RSAKey privateKey(nullptr, &str2, "test");
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey);
|
||||
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey);
|
||||
std::string val("lets do some encryption");
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
void onResolveReply(AvahiServiceResolver* resolver, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char* name, const char* type, const char* domain, const char* host, const AvahiAddress* a, uint16_t port, AvahiStringList* txt, AvahiLookupResultFlags flags);
|
||||
void onEnumerateBrowseDomainsReply(AvahiDomainBrowser* browser, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char* domain, AvahiLookupResultFlags flags, bool isDefault);
|
||||
void onEnumerateRegistrationDomainsReply(AvahiDomainBrowser* browser, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char* domain, AvahiLookupResultFlags flags, bool isDefault);
|
||||
void onQueryRecordReply(AvahiRecordBrowser* browser, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char* name, uint16_t clazz, uint16_t type, const void* data, std::size_t size, AvahiLookupResultFlags flags);
|
||||
void onQueryRecordReply(AvahiRecordBrowser* browser, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char* name, uint16_t clazz, uint16_t type, const void* data, std::size_t size, AvahiLookupResultFlags flags);
|
||||
|
||||
protected:
|
||||
enum HandleTypes
|
||||
|
||||
@@ -205,7 +205,10 @@ BrowseHandle AvahiBrowserImpl::browse(const std::string& regType, const std::str
|
||||
AvahiResponderImpl::ScopedLock lock(_responder);
|
||||
|
||||
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)
|
||||
{
|
||||
int error = avahi_client_errno(_responder._avahiClient);
|
||||
@@ -235,13 +238,19 @@ BrowseHandle AvahiBrowserImpl::enumerateBrowseDomains(Poco::Int32 networkInterfa
|
||||
AvahiResponderImpl::ScopedLock lock(_responder);
|
||||
|
||||
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)
|
||||
{
|
||||
int error = avahi_client_errno(_responder._avahiClient);
|
||||
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)
|
||||
{
|
||||
int error = avahi_client_errno(_responder._avahiClient);
|
||||
@@ -257,13 +266,19 @@ BrowseHandle AvahiBrowserImpl::enumerateRegistrationDomains(Poco::Int32 networkI
|
||||
AvahiResponderImpl::ScopedLock lock(_responder);
|
||||
|
||||
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)
|
||||
{
|
||||
int error = avahi_client_errno(_responder._avahiClient);
|
||||
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)
|
||||
{
|
||||
int error = avahi_client_errno(_responder._avahiClient);
|
||||
|
||||
@@ -66,8 +66,8 @@ extern "C" void onGroupStateChange(AvahiEntryGroup* avahiGroup, AvahiEntryGroupS
|
||||
AvahiResponderImpl::AvahiResponderImpl(Poco::DNSSD::DNSSDResponder& owner):
|
||||
_owner(owner),
|
||||
_browser(*this),
|
||||
_avahiPoll(0),
|
||||
_avahiClient(0),
|
||||
_avahiPoll(nullptr),
|
||||
_avahiClient(nullptr),
|
||||
_running(false),
|
||||
_nextRecordId(1)
|
||||
{
|
||||
@@ -299,8 +299,8 @@ void AvahiResponderImpl::setupEntryGroup(AvahiEntryGroup* avahiGroup, const Serv
|
||||
}
|
||||
std::string name(service.name());
|
||||
if (name.empty()) name = avahi_client_get_host_name(_avahiClient);
|
||||
const char* domain = service.domain().empty() ? 0 : service.domain().c_str();
|
||||
const char* host = service.host().empty() ? 0 : service.host().c_str();
|
||||
const char* domain = service.domain().empty() ? nullptr : service.domain().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(
|
||||
avahiGroup,
|
||||
@@ -390,7 +390,7 @@ void AvahiResponderImpl::setupEntryGroup(AvahiEntryGroup* avahiGroup, const Serv
|
||||
|
||||
AvahiStringList* AvahiResponderImpl::createTXTRecord(const Service::Properties& properties)
|
||||
{
|
||||
AvahiStringList* avahiList = 0;
|
||||
AvahiStringList* avahiList = nullptr;
|
||||
Service::Properties::ConstIterator itVers = properties.find("txtvers");
|
||||
Service::Properties::ConstIterator itEnd = properties.end();
|
||||
std::string entry;
|
||||
@@ -399,7 +399,7 @@ AvahiStringList* AvahiResponderImpl::createTXTRecord(const Service::Properties&
|
||||
std::string entry(itVers->first);
|
||||
entry += '=';
|
||||
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();
|
||||
@@ -409,7 +409,11 @@ AvahiStringList* AvahiResponderImpl::createTXTRecord(const Service::Properties&
|
||||
{
|
||||
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
|
||||
{
|
||||
@@ -419,7 +423,7 @@ AvahiStringList* AvahiResponderImpl::createTXTRecord(const Service::Properties&
|
||||
entry += '=';
|
||||
entry += it->second;
|
||||
}
|
||||
avahiList = avahi_string_list_new(entry.c_str(), NULL);
|
||||
avahiList = avahi_string_list_new(entry.c_str(), nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
void onResolveReply(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char* fullName, const char* host, uint16_t port, uint16_t txtLen, const unsigned char* txtRecord);
|
||||
void onEnumerateBrowseDomainsReply(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char* replyDomain);
|
||||
void onEnumerateRegistrationDomainsReply(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char* replyDomain);
|
||||
void onQueryRecordReply(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char* fullName, uint16_t rrtype, uint16_t rrclass, uint16_t rdlen, const void* rdata, uint32_t ttl);
|
||||
void onQueryRecordReply(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char* fullName, uint16_t rrtype, uint16_t rrclass, uint16_t rdlen, const void* rdata, uint32_t ttl);
|
||||
void onResolveHostReply(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char* hostname, const struct sockaddr* address, uint32_t ttl);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -77,12 +77,12 @@ extern "C" void DNSSD_API onResolveReply(
|
||||
|
||||
|
||||
extern "C" void DNSSD_API onEnumerateBrowseDomainsReply(
|
||||
DNSServiceRef sdRef,
|
||||
DNSServiceFlags flags,
|
||||
uint32_t interfaceIndex,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* replyDomain,
|
||||
void* context)
|
||||
DNSServiceRef sdRef,
|
||||
DNSServiceFlags flags,
|
||||
uint32_t interfaceIndex,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* replyDomain,
|
||||
void* context)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -96,12 +96,12 @@ extern "C" void DNSSD_API onEnumerateBrowseDomainsReply(
|
||||
|
||||
|
||||
extern "C" void DNSSD_API onEnumerateRegistrationDomainsReply(
|
||||
DNSServiceRef sdRef,
|
||||
DNSServiceFlags flags,
|
||||
uint32_t interfaceIndex,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* replyDomain,
|
||||
void* context)
|
||||
DNSServiceRef sdRef,
|
||||
DNSServiceFlags flags,
|
||||
uint32_t interfaceIndex,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* replyDomain,
|
||||
void* context)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -115,17 +115,17 @@ extern "C" void DNSSD_API onEnumerateRegistrationDomainsReply(
|
||||
|
||||
|
||||
extern "C" void DNSSD_API onQueryRecordReply(
|
||||
DNSServiceRef sdRef,
|
||||
DNSServiceFlags flags,
|
||||
uint32_t interfaceIndex,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* fullName,
|
||||
uint16_t rrtype,
|
||||
uint16_t rrclass,
|
||||
uint16_t rdlen,
|
||||
const void* rdata,
|
||||
uint32_t ttl,
|
||||
void* context)
|
||||
DNSServiceRef sdRef,
|
||||
DNSServiceFlags flags,
|
||||
uint32_t interfaceIndex,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* fullName,
|
||||
uint16_t rrtype,
|
||||
uint16_t rrclass,
|
||||
uint16_t rdlen,
|
||||
const void* rdata,
|
||||
uint32_t ttl,
|
||||
void* context)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -174,7 +174,7 @@ BrowseHandle BonjourBrowserImpl::browse(const std::string& regType, const std::s
|
||||
{
|
||||
DNSServiceRef sdRef(nullptr);
|
||||
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)
|
||||
{
|
||||
_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)
|
||||
{
|
||||
DNSServiceRef sdRef(0);
|
||||
DNSServiceRef sdRef(nullptr);
|
||||
Poco::Int32 ifIndex = (options & RESOLVE_ON_ALL_INTERFACES) ? 0 : service.networkInterface();
|
||||
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);
|
||||
@@ -202,7 +202,7 @@ BrowseHandle BonjourBrowserImpl::resolve(const Service& service, int options)
|
||||
|
||||
BrowseHandle BonjourBrowserImpl::enumerateBrowseDomains(Poco::Int32 networkInterface)
|
||||
{
|
||||
DNSServiceRef sdRef(0);
|
||||
DNSServiceRef sdRef(nullptr);
|
||||
EventLoop::ScopedLock lock(_eventLoop);
|
||||
DNSServiceErrorType err = DNSServiceEnumerateDomains(&sdRef, kDNSServiceFlagsBrowseDomains, networkInterface, Poco::DNSSD::Bonjour::onEnumerateBrowseDomainsReply, this);
|
||||
if (err == kDNSServiceErr_NoError)
|
||||
@@ -216,7 +216,7 @@ BrowseHandle BonjourBrowserImpl::enumerateBrowseDomains(Poco::Int32 networkInter
|
||||
|
||||
BrowseHandle BonjourBrowserImpl::enumerateRegistrationDomains(Poco::Int32 networkInterface)
|
||||
{
|
||||
DNSServiceRef sdRef(0);
|
||||
DNSServiceRef sdRef(nullptr);
|
||||
EventLoop::ScopedLock lock(_eventLoop);
|
||||
DNSServiceErrorType err = DNSServiceEnumerateDomains(&sdRef, kDNSServiceFlagsRegistrationDomains, networkInterface, Poco::DNSSD::Bonjour::onEnumerateRegistrationDomainsReply, this);
|
||||
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)
|
||||
{
|
||||
DNSServiceRef sdRef(0);
|
||||
DNSServiceRef sdRef(nullptr);
|
||||
DNSServiceFlags flags(0);
|
||||
if (options & BROWSE_FORCE_MULTICAST) flags |= kDNSServiceFlagsForceMulticast;
|
||||
EventLoop::ScopedLock lock(_eventLoop);
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace Bonjour {
|
||||
|
||||
|
||||
extern "C" void DNSSD_API onRegisterServiceReply(
|
||||
DNSServiceRef sdRef,
|
||||
DNSServiceFlags flags,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* name,
|
||||
const char* regtype,
|
||||
const char* domain,
|
||||
void *context)
|
||||
DNSServiceRef sdRef,
|
||||
DNSServiceFlags flags,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* name,
|
||||
const char* regtype,
|
||||
const char* domain,
|
||||
void *context)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -85,7 +85,13 @@ ServiceHandle BonjourResponderImpl::registerService(const Service& service, int
|
||||
if (options & DNSSDResponder::REG_NON_BROWSABLE) flags |= kDNSServiceFlagsNonBrowsable;
|
||||
#endif
|
||||
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)
|
||||
{
|
||||
_eventLoop.add(sdRef);
|
||||
@@ -105,7 +111,7 @@ void BonjourResponderImpl::unregisterService(ServiceHandle& serviceHandle)
|
||||
|
||||
RecordHandle BonjourResponderImpl::addRecord(ServiceHandle serviceHandle, const Record& record)
|
||||
{
|
||||
DNSRecordRef recRef(0);
|
||||
DNSRecordRef recRef(nullptr);
|
||||
EventLoop::ScopedLock lock(_eventLoop);
|
||||
DNSServiceErrorType err = DNSServiceAddRecord(serviceHandle.cast<DNSServiceRef>(), &recRef, 0, record.type(), record.length(), record.data(), record.ttl());
|
||||
if (err == kDNSServiceErr_NoError)
|
||||
@@ -119,7 +125,9 @@ RecordHandle BonjourResponderImpl::addRecord(ServiceHandle serviceHandle, const
|
||||
void BonjourResponderImpl::updateRecord(ServiceHandle serviceHandle, RecordHandle recordHandle, const Record& record)
|
||||
{
|
||||
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)
|
||||
{
|
||||
throw Poco::DNSSD::DNSSDException("Failed to update record " + record.name(), describeError(err), err);
|
||||
@@ -164,67 +172,67 @@ const char* BonjourResponderImpl::describeError(int code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case kDNSServiceErr_Unknown:
|
||||
return "Unknown";
|
||||
case kDNSServiceErr_NoSuchName:
|
||||
return "No such name";
|
||||
case kDNSServiceErr_NoMemory:
|
||||
return "No memory";
|
||||
case kDNSServiceErr_BadParam:
|
||||
return "Bad parameter";
|
||||
case kDNSServiceErr_BadReference:
|
||||
return "Bad reference";
|
||||
case kDNSServiceErr_BadState:
|
||||
return "Bad state";
|
||||
case kDNSServiceErr_BadFlags:
|
||||
return "Bad flags";
|
||||
case kDNSServiceErr_Unsupported:
|
||||
return "Unsupported";
|
||||
case kDNSServiceErr_NotInitialized:
|
||||
return "Not initialized";
|
||||
case kDNSServiceErr_AlreadyRegistered:
|
||||
return "Already registered";
|
||||
case kDNSServiceErr_NameConflict:
|
||||
return "Name conflict";
|
||||
case kDNSServiceErr_Invalid:
|
||||
return "Invalid";
|
||||
case kDNSServiceErr_Firewall:
|
||||
return "Firewall";
|
||||
case kDNSServiceErr_Incompatible:
|
||||
return "Client library incompatible with daemon";
|
||||
case kDNSServiceErr_BadInterfaceIndex:
|
||||
return "Bad interface index";
|
||||
case kDNSServiceErr_Refused:
|
||||
return "Refused";
|
||||
case kDNSServiceErr_NoSuchRecord:
|
||||
return "No such record";
|
||||
case kDNSServiceErr_NoAuth:
|
||||
return "No auth";
|
||||
case kDNSServiceErr_NoSuchKey:
|
||||
return "No such key";
|
||||
case kDNSServiceErr_NATTraversal:
|
||||
return "NAT traversal";
|
||||
case kDNSServiceErr_DoubleNAT:
|
||||
return "Double NAT";
|
||||
case kDNSServiceErr_BadTime:
|
||||
return "Bad time";
|
||||
case kDNSServiceErr_BadSig:
|
||||
return "Bad signature";
|
||||
case kDNSServiceErr_BadKey:
|
||||
return "Bad key";
|
||||
case kDNSServiceErr_Transient:
|
||||
return "Transient error";
|
||||
case kDNSServiceErr_ServiceNotRunning:
|
||||
return "Service not running";
|
||||
case kDNSServiceErr_NATPortMappingUnsupported:
|
||||
return "NAT port mapping not supported";
|
||||
case kDNSServiceErr_NATPortMappingDisabled:
|
||||
return "NAT port mapping disabled";
|
||||
case kDNSServiceErr_Unknown:
|
||||
return "Unknown";
|
||||
case kDNSServiceErr_NoSuchName:
|
||||
return "No such name";
|
||||
case kDNSServiceErr_NoMemory:
|
||||
return "No memory";
|
||||
case kDNSServiceErr_BadParam:
|
||||
return "Bad parameter";
|
||||
case kDNSServiceErr_BadReference:
|
||||
return "Bad reference";
|
||||
case kDNSServiceErr_BadState:
|
||||
return "Bad state";
|
||||
case kDNSServiceErr_BadFlags:
|
||||
return "Bad flags";
|
||||
case kDNSServiceErr_Unsupported:
|
||||
return "Unsupported";
|
||||
case kDNSServiceErr_NotInitialized:
|
||||
return "Not initialized";
|
||||
case kDNSServiceErr_AlreadyRegistered:
|
||||
return "Already registered";
|
||||
case kDNSServiceErr_NameConflict:
|
||||
return "Name conflict";
|
||||
case kDNSServiceErr_Invalid:
|
||||
return "Invalid";
|
||||
case kDNSServiceErr_Firewall:
|
||||
return "Firewall";
|
||||
case kDNSServiceErr_Incompatible:
|
||||
return "Client library incompatible with daemon";
|
||||
case kDNSServiceErr_BadInterfaceIndex:
|
||||
return "Bad interface index";
|
||||
case kDNSServiceErr_Refused:
|
||||
return "Refused";
|
||||
case kDNSServiceErr_NoSuchRecord:
|
||||
return "No such record";
|
||||
case kDNSServiceErr_NoAuth:
|
||||
return "No auth";
|
||||
case kDNSServiceErr_NoSuchKey:
|
||||
return "No such key";
|
||||
case kDNSServiceErr_NATTraversal:
|
||||
return "NAT traversal";
|
||||
case kDNSServiceErr_DoubleNAT:
|
||||
return "Double NAT";
|
||||
case kDNSServiceErr_BadTime:
|
||||
return "Bad time";
|
||||
case kDNSServiceErr_BadSig:
|
||||
return "Bad signature";
|
||||
case kDNSServiceErr_BadKey:
|
||||
return "Bad key";
|
||||
case kDNSServiceErr_Transient:
|
||||
return "Transient error";
|
||||
case kDNSServiceErr_ServiceNotRunning:
|
||||
return "Service not running";
|
||||
case kDNSServiceErr_NATPortMappingUnsupported:
|
||||
return "NAT port mapping not supported";
|
||||
case kDNSServiceErr_NATPortMappingDisabled:
|
||||
return "NAT port mapping disabled";
|
||||
#if _DNS_SD_H+0 >= 2580000
|
||||
case kDNSServiceErr_NoRouter:
|
||||
return "No router";
|
||||
case kDNSServiceErr_PollingMode:
|
||||
return "Polling mode";
|
||||
case kDNSServiceErr_NoRouter:
|
||||
return "No router";
|
||||
case kDNSServiceErr_PollingMode:
|
||||
return "Polling mode";
|
||||
#endif
|
||||
default:
|
||||
return "Error";
|
||||
@@ -268,7 +276,7 @@ std::string BonjourResponderImpl::createTXTRecord(const Service::Properties& pro
|
||||
if (itVers != itEnd)
|
||||
{
|
||||
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();
|
||||
@@ -277,7 +285,7 @@ std::string BonjourResponderImpl::createTXTRecord(const Service::Properties& pro
|
||||
if (it != itVers)
|
||||
{
|
||||
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);
|
||||
@@ -290,12 +298,12 @@ std::string BonjourResponderImpl::createTXTRecord(const Service::Properties& pro
|
||||
|
||||
|
||||
void BonjourResponderImpl::onRegisterServiceReply(
|
||||
DNSServiceRef sdRef,
|
||||
DNSServiceFlags flags,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* name,
|
||||
const char* regtype,
|
||||
const char* domain)
|
||||
DNSServiceRef sdRef,
|
||||
DNSServiceFlags flags,
|
||||
DNSServiceErrorType errorCode,
|
||||
const char* name,
|
||||
const char* regtype,
|
||||
const char* domain)
|
||||
{
|
||||
if (errorCode == kDNSServiceErr_NoError)
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
if (request.getURI() == "/")
|
||||
return new TimeRequestHandler(_format);
|
||||
else
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace Poco {
|
||||
namespace DNSSD {
|
||||
|
||||
|
||||
DNSSDResponderImplFactory* DNSSDResponder::_pImplFactory(0);
|
||||
DNSSDResponderImplFactory* DNSSDResponder::_pImplFactory(nullptr);
|
||||
|
||||
|
||||
DNSSDResponder::DNSSDResponder():
|
||||
_pImpl(0)
|
||||
_pImpl(nullptr)
|
||||
{
|
||||
if (_pImplFactory)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ void DNSSDResponder::registerImplFactory(DNSSDResponderImplFactory& factory)
|
||||
|
||||
void DNSSDResponder::unregisterImplFactory()
|
||||
{
|
||||
_pImplFactory = 0;
|
||||
_pImplFactory = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Record::Record():
|
||||
_type(0),
|
||||
_clazz(0),
|
||||
_length(0),
|
||||
_data(0),
|
||||
_data(nullptr),
|
||||
_ttl(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
~SessionHandle();
|
||||
/// Destroy handle, close connection
|
||||
|
||||
void init(MYSQL* mysql = 0);
|
||||
void init(MYSQL* mysql = nullptr);
|
||||
/// Initializes the handle iff not initialized.
|
||||
|
||||
void options(mysql_option opt);
|
||||
|
||||
@@ -30,7 +30,7 @@ Binder::~Binder()
|
||||
for (std::vector<MYSQL_TIME*>::iterator it = _dates.begin(); it != _dates.end(); ++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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
MYSQL_BIND b = {0};
|
||||
MYSQL_BIND b = {nullptr};
|
||||
|
||||
b.buffer_type = type;
|
||||
b.buffer = const_cast<void*>(buffer);
|
||||
|
||||
@@ -52,7 +52,7 @@ Poco::AutoPtr<Poco::Data::SessionImpl> Connector::createSession(const std::strin
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ void Extractor::reset()
|
||||
|
||||
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;
|
||||
|
||||
bind.is_null = &isNull;
|
||||
|
||||
@@ -116,7 +116,7 @@ std::string StatementException::compose(const std::string& text, MYSQL_STMT* h,
|
||||
str += "[Comment]: ";
|
||||
str += text;
|
||||
|
||||
if (h != 0)
|
||||
if (h != nullptr)
|
||||
{
|
||||
str += "\t[mysql_stmt_error]: ";
|
||||
str += mysql_stmt_error(h);
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
#endif
|
||||
|
||||
|
||||
SessionHandle::SessionHandle(MYSQL* mysql): _pHandle(0)
|
||||
SessionHandle::SessionHandle(MYSQL* mysql): _pHandle(nullptr)
|
||||
{
|
||||
init(mysql);
|
||||
#ifdef POCO_OS_FAMILY_UNIX
|
||||
@@ -95,7 +95,7 @@ SessionHandle::~SessionHandle()
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
#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));
|
||||
#else
|
||||
if (!mysql_connect(_pHandle, host, user, password))
|
||||
@@ -144,7 +144,7 @@ void SessionHandle::close()
|
||||
if (_pHandle)
|
||||
{
|
||||
mysql_close(_pHandle);
|
||||
_pHandle = 0;
|
||||
_pHandle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ const std::string SessionImpl::MYSQL_SERIALIZABLE = "SERIALIZABLE";
|
||||
SessionImpl::SessionImpl(const std::string& connectionString, std::size_t loginTimeout) :
|
||||
Poco::Data::AbstractSessionImpl<SessionImpl>(connectionString, loginTimeout),
|
||||
_connector("MySQL"),
|
||||
_handle(0),
|
||||
_handle(nullptr),
|
||||
_reset(false),
|
||||
_connected(false),
|
||||
_inTransaction(false),
|
||||
@@ -120,7 +120,7 @@ void SessionImpl::open(const std::string& connect)
|
||||
if (options["user"].empty())
|
||||
throw MySQLException("create session: specify user name");
|
||||
|
||||
const char * db = NULL;
|
||||
const char * db = nullptr;
|
||||
if (!options["db"].empty())
|
||||
db = options["db"].c_str();
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ void StatementExecutor::bindParams(MYSQL_BIND* params, std::size_t count)
|
||||
throw StatementException("Statement is not compiled yet");
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ using Poco::Nullable;
|
||||
using Poco::Tuple;
|
||||
using Poco::NamedTuple;
|
||||
|
||||
Poco::SharedPtr<Poco::Data::Session> MySQLTest::_pSession = 0;
|
||||
Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor = 0;
|
||||
Poco::SharedPtr<Poco::Data::Session> MySQLTest::_pSession = nullptr;
|
||||
Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor = nullptr;
|
||||
|
||||
//
|
||||
// Parameters for barebone-test
|
||||
@@ -936,7 +936,7 @@ CppUnit::Test* MySQLTest::suite()
|
||||
catch (ConnectionFailedException& ex)
|
||||
{
|
||||
std::cout << ex.displayText() << std::endl;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
int rc;
|
||||
MYSQL* hsession = mysql_init(0);
|
||||
assertTrue (hsession != 0);
|
||||
MYSQL* hsession = mysql_init(nullptr);
|
||||
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);
|
||||
|
||||
MYSQL_STMT* hstmt = mysql_stmt_init(hsession);
|
||||
assertTrue (hstmt != 0);
|
||||
assertTrue (hstmt != nullptr);
|
||||
|
||||
std::string sql = "DROP TABLE Test";
|
||||
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;
|
||||
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_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;
|
||||
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_length = sizeof(chr[0]);
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
Binder(const StatementHandle& rStmt,
|
||||
std::size_t maxFieldSize,
|
||||
ParameterBinding dataBinding = PB_IMMEDIATE,
|
||||
const TypeInfo* pDataTypes = 0,
|
||||
const TypeInfo* pDataTypes = nullptr,
|
||||
Poco::TextEncoding::Ptr pFromEncoding = nullptr,
|
||||
Poco::TextEncoding::Ptr pDBEncoding = nullptr);
|
||||
/// Creates the Binder.
|
||||
@@ -427,7 +427,7 @@ private:
|
||||
|
||||
getColSizeAndPrecision(pos, cDataType, colSize, decDigits);
|
||||
|
||||
_lengthIndicator.push_back(0);
|
||||
_lengthIndicator.push_back(nullptr);
|
||||
|
||||
if (Utility::isError(SQLBindParameter(_rStmt,
|
||||
(SQLUSMALLINT) pos + 1,
|
||||
@@ -436,7 +436,7 @@ private:
|
||||
Utility::sqlDataType(cDataType),
|
||||
colSize,
|
||||
decDigits,
|
||||
(SQLPOINTER) &val, 0, 0)))
|
||||
(SQLPOINTER) &val, 0, nullptr)))
|
||||
{
|
||||
throw StatementException(_rStmt, "ODBC::Binder::SQLBindParameter()");
|
||||
}
|
||||
@@ -492,7 +492,7 @@ private:
|
||||
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length);
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ private:
|
||||
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length);
|
||||
}
|
||||
|
||||
@@ -582,7 +582,7 @@ private:
|
||||
if (PB_IMMEDIATE != _paramBinding)
|
||||
throw InvalidAccessException("Containers can only be bound immediately.");
|
||||
|
||||
const C* pVal = 0;
|
||||
const C* pVal = nullptr;
|
||||
if (!transcodeRequired()) pVal = &valC;
|
||||
else
|
||||
{
|
||||
@@ -614,12 +614,12 @@ private:
|
||||
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1, SQL_NTS);
|
||||
}
|
||||
|
||||
if (_charPtrs.size() <= pos)
|
||||
_charPtrs.resize(pos + 1, 0);
|
||||
_charPtrs.resize(pos + 1, nullptr);
|
||||
|
||||
_charPtrs[pos] = (char*) std::calloc(pVal->size() * size, sizeof(char));
|
||||
|
||||
@@ -685,12 +685,12 @@ private:
|
||||
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1, SQL_NTS);
|
||||
}
|
||||
|
||||
if (_utf16CharPtrs.size() <= pos)
|
||||
_utf16CharPtrs.resize(pos + 1, 0);
|
||||
_utf16CharPtrs.resize(pos + 1, nullptr);
|
||||
|
||||
_utf16CharPtrs[pos] = (UTF16Char*)std::calloc(val.size() * size, sizeof(UTF16Char));
|
||||
|
||||
@@ -745,7 +745,7 @@ private:
|
||||
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1);
|
||||
}
|
||||
|
||||
@@ -760,7 +760,7 @@ private:
|
||||
}
|
||||
|
||||
if (_charPtrs.size() <= pos)
|
||||
_charPtrs.resize(pos + 1, 0);
|
||||
_charPtrs.resize(pos + 1, nullptr);
|
||||
|
||||
_charPtrs[pos] = (char*) std::calloc(val.size() * size, sizeof(CharType));
|
||||
poco_check_ptr (_charPtrs[pos]);
|
||||
@@ -811,13 +811,13 @@ private:
|
||||
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1);
|
||||
}
|
||||
|
||||
if (_dateVecVec.size() <= pos)
|
||||
{
|
||||
_dateVecVec.resize(pos + 1, 0);
|
||||
_dateVecVec.resize(pos + 1, nullptr);
|
||||
_dateVecVec[pos] = new DateVec(length ? length : 1);
|
||||
}
|
||||
|
||||
@@ -859,13 +859,13 @@ private:
|
||||
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1);
|
||||
}
|
||||
|
||||
if (_timeVecVec.size() <= pos)
|
||||
{
|
||||
_timeVecVec.resize(pos + 1, 0);
|
||||
_timeVecVec.resize(pos + 1, nullptr);
|
||||
_timeVecVec[pos] = new TimeVec(length ? length : 1);
|
||||
}
|
||||
|
||||
@@ -908,13 +908,13 @@ private:
|
||||
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1);
|
||||
}
|
||||
|
||||
if (_dateTimeVecVec.size() <= pos)
|
||||
{
|
||||
_dateTimeVecVec.resize(pos + 1, 0);
|
||||
_dateTimeVecVec.resize(pos + 1, nullptr);
|
||||
_dateTimeVecVec[pos] = new DateTimeVec(length ? length : 1);
|
||||
}
|
||||
|
||||
@@ -958,12 +958,12 @@ private:
|
||||
SQLINTEGER size = 16; // UUID is fixed 16 bytes
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length ? length : 1, size);
|
||||
}
|
||||
|
||||
if (_charPtrs.size() <= pos)
|
||||
_charPtrs.resize(pos + 1, 0);
|
||||
_charPtrs.resize(pos + 1, nullptr);
|
||||
|
||||
_charPtrs[pos] = (char*)std::calloc(val.size() * size, sizeof(char));
|
||||
std::size_t offset = 0;
|
||||
@@ -1015,7 +1015,7 @@ private:
|
||||
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length, SQL_NULL_DATA);
|
||||
}
|
||||
|
||||
@@ -1030,7 +1030,7 @@ private:
|
||||
TypeInfo::sqlDataType<SQL_C_CHAR>(),
|
||||
colSize,
|
||||
decDigits,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
&(*_vecLengthIndicator[pos])[0])))
|
||||
{
|
||||
@@ -1057,7 +1057,7 @@ private:
|
||||
|
||||
if (_vecLengthIndicator.size() <= pos)
|
||||
{
|
||||
_vecLengthIndicator.resize(pos + 1, 0);
|
||||
_vecLengthIndicator.resize(pos + 1, nullptr);
|
||||
_vecLengthIndicator[pos] = new LengthVec(length, SQL_NULL_DATA);
|
||||
auto valIt = val.begin(), valEnd = val.end();
|
||||
auto lenIt = _vecLengthIndicator[pos]->begin(), lenEnd = _vecLengthIndicator[pos]->end();
|
||||
@@ -1080,7 +1080,7 @@ private:
|
||||
TypeInfo::sqlDataType<SQL_C_CHAR>(),
|
||||
colSize,
|
||||
decDigits,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
&(*_vecLengthIndicator[pos])[0])))
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ class Handle
|
||||
public:
|
||||
Handle(const ConnectionHandle& rConnection):
|
||||
_rConnection(rConnection),
|
||||
_handle(0)
|
||||
_handle(nullptr)
|
||||
/// Creates the Handle.
|
||||
{
|
||||
if (Utility::isError(SQLAllocHandle(handleType,
|
||||
|
||||
@@ -63,9 +63,9 @@ private:
|
||||
void init();
|
||||
|
||||
SQLSMALLINT _dataType;
|
||||
SQLULEN _columnSize;
|
||||
SQLSMALLINT _decimalDigits;
|
||||
SQLSMALLINT _isNullable;
|
||||
SQLULEN _columnSize;
|
||||
SQLSMALLINT _decimalDigits;
|
||||
SQLSMALLINT _isNullable;
|
||||
|
||||
const StatementHandle& _rStmt;
|
||||
std::size_t _number;
|
||||
|
||||
@@ -428,7 +428,7 @@ private:
|
||||
Preparator& operator = (const Preparator&);
|
||||
|
||||
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.
|
||||
{
|
||||
ODBCMetaColumn col(_rStmt, pos);
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
SQLSMALLINT> TypeInfoTup;
|
||||
typedef std::vector<TypeInfoTup> TypeInfoVec;
|
||||
|
||||
explicit TypeInfo(SQLHDBC* pHDBC=0);
|
||||
explicit TypeInfo(SQLHDBC* pHDBC=nullptr);
|
||||
/// Creates the TypeInfo.
|
||||
|
||||
~TypeInfo();
|
||||
|
||||
@@ -114,7 +114,7 @@ void Binder::freeMemory()
|
||||
|
||||
void Binder::bind(std::size_t pos, const std::string& val, Direction dir)
|
||||
{
|
||||
char* pTCVal = 0;
|
||||
char* pTCVal = nullptr;
|
||||
SQLINTEGER size = 0;
|
||||
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);
|
||||
}
|
||||
else size = static_cast<SQLINTEGER>(val.size());
|
||||
SQLPOINTER pVal = 0;
|
||||
SQLPOINTER pVal = nullptr;
|
||||
SQLINTEGER colSize = 0;
|
||||
SQLSMALLINT decDigits = 0;
|
||||
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;
|
||||
|
||||
SQLPOINTER pVal = 0;
|
||||
SQLPOINTER pVal = nullptr;
|
||||
SQLINTEGER size = (SQLINTEGER)(val.size() * sizeof(CharT));
|
||||
SQLINTEGER colSize = 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))
|
||||
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;
|
||||
*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>(),
|
||||
colSize,
|
||||
decDigits,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
_lengthIndicator.back())))
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ bool Extractor::extractBoundImpl<UTF16String>(std::size_t pos, UTF16String& val)
|
||||
typedef UTF16String::value_type CharT;
|
||||
if (isNull(pos)) return false;
|
||||
std::size_t dataSize = _pPreparator->actualDataSize(pos);
|
||||
CharT* sp = 0;
|
||||
CharT* sp = nullptr;
|
||||
UTF16String us;
|
||||
const std::type_info& ti = _pPreparator->at(pos).type();
|
||||
if (ti == typeid(CharT*))
|
||||
|
||||
@@ -64,9 +64,9 @@ bool ODBCMetaColumn::isUnsigned() const
|
||||
if (Utility::isError(Poco::Data::ODBC::SQLColAttribute(_rStmt,
|
||||
(SQLUSMALLINT)position() + 1, // ODBC columns are 1-based
|
||||
SQL_DESC_UNSIGNED,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
&val)))
|
||||
{
|
||||
throw StatementException(_rStmt, "ODBCMetaColumn::isUnsigned()");
|
||||
@@ -82,9 +82,9 @@ void ODBCMetaColumn::init()
|
||||
if (Utility::isError(Poco::Data::ODBC::SQLColAttribute(_rStmt,
|
||||
(SQLUSMALLINT) position() + 1, // ODBC columns are 1-based
|
||||
SQL_DESC_LENGTH,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
&_dataLength)))
|
||||
{
|
||||
throw StatementException(_rStmt, "ODBCMetaColumn::init()");
|
||||
|
||||
@@ -92,7 +92,7 @@ void ODBCStatementImpl::compileImpl()
|
||||
Binder::ParameterBinding bind = session().getFeature("autoBind") ?
|
||||
Binder::PB_IMMEDIATE : Binder::PB_AT_EXEC;
|
||||
|
||||
const TypeInfo* pDT = 0;
|
||||
const TypeInfo* pDT = nullptr;
|
||||
try
|
||||
{
|
||||
Poco::Any dti = session().getProperty("dataTypeInfo");
|
||||
@@ -194,7 +194,7 @@ void ODBCStatementImpl::doPrepare()
|
||||
"SQLSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE)");
|
||||
}
|
||||
|
||||
AbstractPreparation::Ptr pAP = 0;
|
||||
AbstractPreparation::Ptr pAP = nullptr;
|
||||
Poco::Data::AbstractPreparator::Ptr pP = _preparations[curDataSet];
|
||||
for (std::size_t pos = 0; it != itEnd; ++it)
|
||||
{
|
||||
@@ -295,7 +295,7 @@ void ODBCStatementImpl::execDirectImpl(const std::string& query)
|
||||
|
||||
void ODBCStatementImpl::putData()
|
||||
{
|
||||
SQLPOINTER pParam = 0;
|
||||
SQLPOINTER pParam = nullptr;
|
||||
SQLINTEGER dataSize = 0;
|
||||
SQLRETURN rc;
|
||||
|
||||
@@ -433,7 +433,7 @@ std::string ODBCStatementImpl::nativeSQL()
|
||||
|
||||
SQLINTEGER length = (SQLINTEGER) statement.size() * 2;
|
||||
|
||||
char* pNative = 0;
|
||||
char* pNative = nullptr;
|
||||
SQLINTEGER retlen = length;
|
||||
do
|
||||
{
|
||||
|
||||
@@ -170,7 +170,7 @@ void SessionImpl::open(const std::string& connect)
|
||||
&SessionImpl::setDataTypeInfo,
|
||||
&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);
|
||||
}
|
||||
@@ -227,7 +227,7 @@ inline Poco::Any SessionImpl::getCursorUse(const std::string&) const
|
||||
#pragma warning (disable : 4995) // ignore marked as deprecated
|
||||
#endif
|
||||
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)
|
||||
{
|
||||
case SQL_CUR_USE_ODBC:
|
||||
@@ -263,7 +263,7 @@ bool SessionImpl::canTransact() const
|
||||
if (ODBC_TXN_CAPABILITY_UNKNOWN == _canTransact)
|
||||
{
|
||||
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.");
|
||||
|
||||
_canTransact = (SQL_TC_NONE != ret) ?
|
||||
@@ -318,7 +318,7 @@ bool SessionImpl::getMultiActiveResultset(const std::string&) const
|
||||
{
|
||||
#ifdef POCO_DATA_ODBC_HAVE_SQL_SERVER_EXT
|
||||
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;
|
||||
#else
|
||||
return false;
|
||||
@@ -332,7 +332,7 @@ Poco::UInt32 SessionImpl::getTransactionIsolation() const
|
||||
checkError(SQLGetConnectAttr(_db, SQL_ATTR_TXN_ISOLATION,
|
||||
&isolation,
|
||||
0,
|
||||
0));
|
||||
nullptr));
|
||||
|
||||
return transactionIsolation(isolation);
|
||||
}
|
||||
@@ -359,7 +359,7 @@ Poco::UInt32 SessionImpl::getDefaultTransactionIsolation() const
|
||||
checkError(SQLGetInfo(_db, SQL_DEFAULT_TXN_ISOLATION,
|
||||
&isolation,
|
||||
0,
|
||||
0));
|
||||
nullptr));
|
||||
|
||||
return transactionIsolation(isolation);
|
||||
}
|
||||
@@ -418,7 +418,7 @@ bool SessionImpl::isAutoCommit(const std::string&) const
|
||||
SQL_ATTR_AUTOCOMMIT,
|
||||
&value,
|
||||
0,
|
||||
0));
|
||||
nullptr));
|
||||
|
||||
return (0 != value);
|
||||
}
|
||||
@@ -433,7 +433,7 @@ bool SessionImpl::isTransaction() const
|
||||
SQL_ATTR_AUTOCOMMIT,
|
||||
&value,
|
||||
0,
|
||||
0));
|
||||
nullptr));
|
||||
|
||||
if (0 == value) return _inTransaction;
|
||||
else return false;
|
||||
@@ -505,7 +505,7 @@ int SessionImpl::maxStatementLength() const
|
||||
SQL_MAXIMUM_STATEMENT_LENGTH,
|
||||
(SQLPOINTER) &info,
|
||||
0,
|
||||
0)))
|
||||
nullptr)))
|
||||
{
|
||||
throw ConnectionException(_db,
|
||||
"SQLGetInfo(SQL_MAXIMUM_STATEMENT_LENGTH)");
|
||||
|
||||
@@ -35,7 +35,7 @@ using Poco::format;
|
||||
using Poco::NotFoundException;
|
||||
|
||||
|
||||
Session* ODBCAccessTest::_pSession = 0;
|
||||
Session* ODBCAccessTest::_pSession = nullptr;
|
||||
std::string ODBCAccessTest::_dbConnString;
|
||||
Poco::Data::ODBC::Utility::DriverMap ODBCAccessTest::_drivers;
|
||||
|
||||
@@ -209,5 +209,5 @@ CppUnit::Test* ODBCAccessTest::suite()
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -681,5 +681,5 @@ CppUnit::Test* ODBCDB2Test::suite()
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -506,5 +506,5 @@ CppUnit::Test* ODBCMySQLTest::suite()
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1024,5 +1024,5 @@ CppUnit::Test* ODBCOracleTest::suite()
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -687,5 +687,5 @@ CppUnit::Test* ODBCPostgreSQLTest::suite()
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1211,5 +1211,5 @@ CppUnit::Test* ODBCSQLServerTest::suite()
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -398,5 +398,5 @@ CppUnit::Test* ODBCSQLiteTest::suite()
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1454,7 +1454,7 @@ ODBCTest::SessionPtr ODBCTest::init(const std::string& driver,
|
||||
const std::string& dbEncoding)
|
||||
{
|
||||
Utility::drivers(_drivers);
|
||||
if (!canConnect(driver, dsn, uid, pwd, dbConnString, db)) return 0;
|
||||
if (!canConnect(driver, dsn, uid, pwd, dbConnString, db)) return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1466,6 +1466,6 @@ ODBCTest::SessionPtr ODBCTest::init(const std::string& driver,
|
||||
}catch (ConnectionFailedException& ex)
|
||||
{
|
||||
std::cout << ex.displayText() << std::endl;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
SQLCHAR connectOutput[1024] = {0};
|
||||
SQLSMALLINT result;
|
||||
rc = SQLDriverConnect(hdbc
|
||||
, NULL
|
||||
, nullptr
|
||||
,(SQLCHAR*) dbConnString.c_str()
|
||||
,(SQLSMALLINT) SQL_NTS
|
||||
, connectOutput
|
||||
@@ -307,7 +307,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
0,
|
||||
(SQLPOINTER) &fourth,
|
||||
0,
|
||||
0);
|
||||
nullptr);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLBindParameter(hstmt,
|
||||
@@ -319,7 +319,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
1,
|
||||
(SQLPOINTER) &fifth,
|
||||
0,
|
||||
0);
|
||||
nullptr);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
if (dateTimeColSize == 0 || dateTimeDecDigits == -1)
|
||||
@@ -354,7 +354,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
dateTimeDecDigits,
|
||||
(SQLPOINTER) &sixth,
|
||||
0,
|
||||
0);
|
||||
nullptr);
|
||||
poco_odbc_check_stmt (rc, hstmt);
|
||||
|
||||
rc = SQLExecute(hstmt);
|
||||
@@ -362,7 +362,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
|
||||
|
||||
if (SQL_NEED_DATA == rc)
|
||||
{
|
||||
SQLPOINTER pParam = 0;
|
||||
SQLPOINTER pParam = nullptr;
|
||||
while (SQL_NEED_DATA == (rc = SQLParamData(hstmt, &pParam)))
|
||||
{
|
||||
SQLINTEGER dataSize = 0;
|
||||
@@ -600,7 +600,7 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
|
||||
SQLCHAR connectOutput[512] = {0};
|
||||
SQLSMALLINT result;
|
||||
rc = SQLDriverConnect(hdbc
|
||||
, NULL
|
||||
, nullptr
|
||||
,(SQLCHAR*) dbConnString.c_str()
|
||||
,(SQLSMALLINT) SQL_NTS
|
||||
, connectOutput
|
||||
@@ -822,7 +822,7 @@ void SQLExecutor::bareboneODBCStoredFuncTest(const std::string& dbConnString,
|
||||
SQLCHAR connectOutput[1024] = { 0 };
|
||||
SQLSMALLINT result;
|
||||
rc = SQLDriverConnect(hdbc
|
||||
, NULL
|
||||
, nullptr
|
||||
, (SQLCHAR*)dbConnString.c_str()
|
||||
, (SQLSMALLINT)SQL_NTS
|
||||
, connectOutput
|
||||
@@ -944,7 +944,7 @@ void SQLExecutor::bareboneODBCStoredFuncTest(const std::string& dbConnString,
|
||||
|
||||
if (SQL_NEED_DATA == rc)
|
||||
{
|
||||
SQLPOINTER pParam = 0;
|
||||
SQLPOINTER pParam = nullptr;
|
||||
while (SQL_NEED_DATA == (rc = SQLParamData(hstmt, &pParam)))
|
||||
{
|
||||
if ((pParam != (SQLPOINTER)retVal) &&
|
||||
|
||||
@@ -428,7 +428,7 @@ private:
|
||||
//
|
||||
inline bool BinaryExtractor::isColumnNull(const OutputParameter& anOutputParameter) const
|
||||
{
|
||||
return anOutputParameter.isNull() || 0 == anOutputParameter.pData();
|
||||
return anOutputParameter.isNull() || nullptr == anOutputParameter.pData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -448,7 +448,7 @@ private:
|
||||
//
|
||||
inline bool Extractor::isColumnNull(const OutputParameter& outputParameter) const
|
||||
{
|
||||
return outputParameter.isNull() || 0 == outputParameter.pData();
|
||||
return outputParameter.isNull() || nullptr == outputParameter.pData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ private:
|
||||
PQConnectionInfoOptionsFree& operator = (const PQConnectionInfoOptionsFree&);
|
||||
|
||||
private:
|
||||
PQconninfoOption* _pConnectionInfoOption;
|
||||
PQconninfoOption* _pConnectionInfoOption;
|
||||
};
|
||||
|
||||
|
||||
@@ -194,16 +194,16 @@ inline InputParameter::InputParameter(Poco::Data::MetaColumn::ColumnDataType fie
|
||||
_pData(aDataPtr),
|
||||
_size(theSize),
|
||||
_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),
|
||||
_pData(0),
|
||||
_pData(nullptr),
|
||||
_size(0),
|
||||
_isBinary(false),
|
||||
_pNonStringVersionRepresentation(0)
|
||||
_pNonStringVersionRepresentation(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ inline InputParameter::~InputParameter()
|
||||
|
||||
inline const void* InputParameter::pData() const
|
||||
{
|
||||
return _pData;
|
||||
return _pData;
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ inline bool InputParameter::isBinary() const
|
||||
|
||||
inline void InputParameter::setStringVersionRepresentation(const std::string& aString)
|
||||
{
|
||||
_pNonStringVersionRepresentation = 0;
|
||||
_pNonStringVersionRepresentation = nullptr;
|
||||
_stringVersionRepresentation = aString;
|
||||
_size = _stringVersionRepresentation.size();
|
||||
}
|
||||
@@ -281,8 +281,8 @@ inline const void* InputParameter::pInternalRepresentation() const
|
||||
|
||||
case Poco::Data::MetaColumn::FDT_UNKNOWN:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ inline OutputParameter::OutputParameter():
|
||||
_fieldType(Poco::Data::MetaColumn::FDT_UNKNOWN),
|
||||
_internalFieldType(static_cast<Oid>(-1)),
|
||||
_rowNumber(0),
|
||||
_pData(0),
|
||||
_pData(nullptr),
|
||||
_size(0),
|
||||
_isNull(true)
|
||||
{
|
||||
@@ -325,48 +325,48 @@ inline void OutputParameter::setValues(Poco::Data::MetaColumn::ColumnDataType aF
|
||||
std::size_t theSize,
|
||||
bool anIsNull)
|
||||
{
|
||||
_fieldType = aFieldType;
|
||||
_internalFieldType = anInternalFieldType;
|
||||
_rowNumber = aRowNumber;
|
||||
_pData = aDataPtr;
|
||||
_size = theSize;
|
||||
_isNull = anIsNull;
|
||||
_fieldType = aFieldType;
|
||||
_internalFieldType = anInternalFieldType;
|
||||
_rowNumber = aRowNumber;
|
||||
_pData = aDataPtr;
|
||||
_size = theSize;
|
||||
_isNull = anIsNull;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::Data::MetaColumn::ColumnDataType OutputParameter::fieldType() const
|
||||
{
|
||||
return _fieldType;
|
||||
return _fieldType;
|
||||
}
|
||||
|
||||
|
||||
inline Oid OutputParameter::internalFieldType() const
|
||||
{
|
||||
return _internalFieldType;
|
||||
return _internalFieldType;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t OutputParameter::rowNumber() const
|
||||
{
|
||||
return _rowNumber;
|
||||
return _rowNumber;
|
||||
}
|
||||
|
||||
|
||||
inline const char* OutputParameter::pData() const
|
||||
{
|
||||
return _pData;
|
||||
return _pData;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t OutputParameter::size() const
|
||||
{
|
||||
return _size;
|
||||
return _size;
|
||||
}
|
||||
|
||||
|
||||
inline bool OutputParameter::isNull() const
|
||||
{
|
||||
return _isNull;
|
||||
return _isNull;
|
||||
}
|
||||
|
||||
|
||||
@@ -378,11 +378,11 @@ inline PQConnectionInfoOptionsFree::PQConnectionInfoOptionsFree(PQconninfoOption
|
||||
|
||||
inline PQConnectionInfoOptionsFree::~PQConnectionInfoOptionsFree()
|
||||
{
|
||||
if (_pConnectionInfoOption)
|
||||
{
|
||||
PQconninfoFree(_pConnectionInfoOption);
|
||||
_pConnectionInfoOption = 0;
|
||||
}
|
||||
if (_pConnectionInfoOption)
|
||||
{
|
||||
PQconninfoFree(_pConnectionInfoOption);
|
||||
_pConnectionInfoOption = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -394,11 +394,11 @@ inline PQResultClear::PQResultClear(PGresult* aPQResultPtr):
|
||||
|
||||
inline PQResultClear::~PQResultClear()
|
||||
{
|
||||
if (_pPQResult)
|
||||
{
|
||||
PQclear(_pPQResult);
|
||||
_pPQResult = 0;
|
||||
}
|
||||
if (_pPQResult)
|
||||
{
|
||||
PQclear(_pPQResult);
|
||||
_pPQResult = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -412,11 +412,11 @@ inline PGCancelFree::PGCancelFree(PGcancel* aStatementCancelPtr):
|
||||
|
||||
inline PGCancelFree::~PGCancelFree()
|
||||
{
|
||||
if (_pPGCancel)
|
||||
{
|
||||
PQfreeCancel(_pPGCancel);
|
||||
_pPGCancel = 0;
|
||||
}
|
||||
if (_pPGCancel)
|
||||
{
|
||||
PQfreeCancel(_pPGCancel);
|
||||
_pPGCancel = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
poco_assert(dir == PD_IN);
|
||||
realBind(pos, Poco::Data::MetaColumn::FDT_UNKNOWN, 0, 0);
|
||||
realBind(pos, Poco::Data::MetaColumn::FDT_UNKNOWN, nullptr, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ PostgreSQLException::PostgreSQLException(const std::string& aMessage):
|
||||
PostgreSQLException::PostgreSQLException(const std::string& aMessage,const char* pAnSqlState):
|
||||
Poco::Data::DataException(std::string("[PostgreSQL]: ") + aMessage)
|
||||
{
|
||||
// handle anSqlState
|
||||
if (pAnSqlState == nullptr) _sqlState[0] = '\0';
|
||||
// handle anSqlState
|
||||
if (pAnSqlState == nullptr) _sqlState[0] = '\0';
|
||||
else
|
||||
{
|
||||
strncpy(_sqlState,pAnSqlState,5);
|
||||
_sqlState[5] = '\0';
|
||||
_sqlState[5] = '\0';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ const std::string SessionHandle::POSTGRESQL_SERIALIZABLE = "SERIALIZABLE";
|
||||
|
||||
|
||||
SessionHandle::SessionHandle():
|
||||
_pConnection(0),
|
||||
_pConnection(nullptr),
|
||||
_inTransaction(false),
|
||||
_isAsynchronousCommit(false),
|
||||
_tranactionIsolationLevel(Session::TRANSACTION_READ_COMMITTED)
|
||||
@@ -86,7 +86,7 @@ void SessionHandle::connect(const std::string& aConnectionString)
|
||||
{
|
||||
// free bad connection
|
||||
PQfinish(_pConnection);
|
||||
_pConnection = 0;
|
||||
_pConnection = nullptr;
|
||||
}
|
||||
|
||||
_pConnection = PQconnectdb(aConnectionString.c_str());
|
||||
@@ -97,7 +97,7 @@ void SessionHandle::connect(const std::string& aConnectionString)
|
||||
if (_pConnection)
|
||||
{
|
||||
PQfinish(_pConnection);
|
||||
_pConnection = 0;
|
||||
_pConnection = nullptr;
|
||||
}
|
||||
throw ConnectionFailedException(msg);
|
||||
}
|
||||
@@ -152,7 +152,7 @@ void SessionHandle::disconnect()
|
||||
{
|
||||
PQfinish(_pConnection);
|
||||
|
||||
_pConnection = 0;
|
||||
_pConnection = nullptr;
|
||||
|
||||
_connectionString = std::string();
|
||||
_inTransaction= false;
|
||||
@@ -197,7 +197,7 @@ std::string SessionHandle::lastError() const
|
||||
std::string SessionHandle::lastErrorNoLock() const
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
@@ -328,7 +328,7 @@ void SessionHandle::cancel()
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
PQconninfoOption* ptrConnInfoOptions = 0;
|
||||
PQconninfoOption* ptrConnInfoOptions = nullptr;
|
||||
{
|
||||
Poco::FastMutex::ScopedLock mutexLocker(_sessionMutex);
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ StatementExecutor::StatementExecutor(SessionHandle& sessionHandle, bool binaryEx
|
||||
_sessionHandle(sessionHandle),
|
||||
_binaryExtraction(binaryExtraction),
|
||||
_state(STMT_INITED),
|
||||
_pResultHandle(0),
|
||||
_pResultHandle(nullptr),
|
||||
_countPlaceholdersInSQLStatement(0),
|
||||
_currentRow(0),
|
||||
_affectedRowCount(0)
|
||||
@@ -133,23 +133,23 @@ void StatementExecutor::prepare(const std::string& aSQLStatement)
|
||||
std::replace(statementName.begin(), statementName.end(), '-', 'p'); // PostgreSQL doesn't like dashes in prepared statement names
|
||||
const char* pStatementName = statementName.c_str();
|
||||
|
||||
PGresult* ptrPGResult = 0;
|
||||
PGresult* ptrPGResult = nullptr;
|
||||
|
||||
{
|
||||
Poco::FastMutex::ScopedLock mutexLocker(_sessionHandle.mutex());
|
||||
|
||||
// prepare the statement - temporary PGresult returned
|
||||
ptrPGResult = PQprepare(_sessionHandle, pStatementName, ptrCSQLStatement, (int)countPlaceholdersInSQLStatement, 0);
|
||||
ptrPGResult = PQprepare(_sessionHandle, pStatementName, ptrCSQLStatement, (int)countPlaceholdersInSQLStatement, nullptr);
|
||||
}
|
||||
|
||||
{
|
||||
// get the sqlState
|
||||
const char* pSQLState = PQresultErrorField(ptrPGResult, PG_DIAG_SQLSTATE);
|
||||
// get the sqlState
|
||||
const char* pSQLState = PQresultErrorField(ptrPGResult, PG_DIAG_SQLSTATE);
|
||||
|
||||
// setup to clear the result from PQprepare
|
||||
PQResultClear resultClearer(ptrPGResult);
|
||||
|
||||
//
|
||||
//
|
||||
if (!ptrPGResult || PQresultStatus(ptrPGResult) != PGRES_COMMAND_OK )
|
||||
{
|
||||
throw StatementException(std::string("postgresql_stmt_prepare error: ") + PQresultErrorMessage (ptrPGResult) + " " + aSQLStatement,pSQLState);
|
||||
@@ -164,8 +164,8 @@ void StatementExecutor::prepare(const std::string& aSQLStatement)
|
||||
}
|
||||
|
||||
{
|
||||
// get the sqlState
|
||||
const char* pSQLState = PQresultErrorField(ptrPGResult, PG_DIAG_SQLSTATE);
|
||||
// get the sqlState
|
||||
const char* pSQLState = PQresultErrorField(ptrPGResult, PG_DIAG_SQLSTATE);
|
||||
|
||||
PQResultClear resultClearer(ptrPGResult);
|
||||
|
||||
@@ -254,15 +254,15 @@ void StatementExecutor::execute()
|
||||
// clear out any result data. One way or another it is now obsolete.
|
||||
clearResults();
|
||||
|
||||
PGresult* ptrPGResult = 0;
|
||||
PGresult* ptrPGResult = nullptr;
|
||||
{
|
||||
Poco::FastMutex::ScopedLock mutexLocker(_sessionHandle.mutex());
|
||||
|
||||
ptrPGResult = PQexecPrepared(_sessionHandle,
|
||||
_preparedStatementName.c_str(), (int)_countPlaceholdersInSQLStatement,
|
||||
_inputParameterVector.size() != 0 ? &pParameterVector[ 0 ] : 0,
|
||||
_inputParameterVector.size() != 0 ? ¶meterLengthVector[ 0 ] : 0,
|
||||
_inputParameterVector.size() != 0 ? ¶meterFormatVector[ 0 ] : 0,
|
||||
_inputParameterVector.size() != 0 ? &pParameterVector[ 0 ] : nullptr,
|
||||
_inputParameterVector.size() != 0 ? ¶meterLengthVector[ 0 ] : nullptr,
|
||||
_inputParameterVector.size() != 0 ? ¶meterFormatVector[ 0 ] : nullptr,
|
||||
_binaryExtraction ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ void StatementExecutor::execute()
|
||||
const char* pHint = PQresultErrorField(ptrPGResult, PG_DIAG_MESSAGE_HINT);
|
||||
const char* pConstraint = PQresultErrorField(ptrPGResult, PG_DIAG_CONSTRAINT_NAME);
|
||||
|
||||
|
||||
|
||||
throw StatementException(std::string("postgresql_stmt_execute error: ")
|
||||
+ PQresultErrorMessage (ptrPGResult)
|
||||
+ " Severity: " + (pSeverity ? pSeverity : "N/A")
|
||||
@@ -308,7 +308,7 @@ void StatementExecutor::execute()
|
||||
{ // non Select DML statments also have an affected row count.
|
||||
// unfortunately PostgreSQL offers up this count as a char * - go figure!
|
||||
const char * pNonSelectAffectedRowCountString = PQcmdTuples(_pResultHandle);
|
||||
if (0 != pNonSelectAffectedRowCountString)
|
||||
if (nullptr != pNonSelectAffectedRowCountString)
|
||||
{
|
||||
if ( Poco::NumberParser::tryParse(pNonSelectAffectedRowCountString, affectedRowCount)
|
||||
&& affectedRowCount >= 0
|
||||
|
||||
@@ -41,8 +41,8 @@ using Poco::NamedTuple;
|
||||
using Poco::Environment;
|
||||
|
||||
|
||||
Poco::SharedPtr<Poco::Data::Session> PostgreSQLTest::_pSession = 0;
|
||||
Poco::SharedPtr<SQLExecutor> PostgreSQLTest::_pExecutor = 0;
|
||||
Poco::SharedPtr<Poco::Data::Session> PostgreSQLTest::_pSession = nullptr;
|
||||
Poco::SharedPtr<SQLExecutor> PostgreSQLTest::_pExecutor = nullptr;
|
||||
|
||||
|
||||
//
|
||||
@@ -1254,7 +1254,7 @@ CppUnit::Test* PostgreSQLTest::suite()
|
||||
catch (ConnectionFailedException& ex)
|
||||
{
|
||||
std::cout << ex.displayText() << std::endl;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::cout << "*** Connected to [" << "PostgreSQL" << "] test database." << std::endl;
|
||||
|
||||
@@ -174,13 +174,13 @@ void SQLExecutor::oidPostgreSQLTest(std::string host, std::string user, std::str
|
||||
connectionString.append("port=");
|
||||
connectionString.append(port);
|
||||
|
||||
PGconn * pConnection = 0;
|
||||
PGconn * pConnection = nullptr;
|
||||
|
||||
pConnection = PQconnectdb(connectionString.c_str());
|
||||
|
||||
assertTrue (PQstatus(pConnection) == CONNECTION_OK);
|
||||
|
||||
PGresult * pResult = 0;
|
||||
PGresult * pResult = nullptr;
|
||||
std::string sql = "DROP TABLE IF EXISTS Test";
|
||||
|
||||
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";
|
||||
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);
|
||||
PQclear(pResult);
|
||||
@@ -273,20 +273,20 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
|
||||
connectionString.append("port=");
|
||||
connectionString.append(port);
|
||||
|
||||
PGconn * pConnection = 0;
|
||||
PGconn * pConnection = nullptr;
|
||||
|
||||
pConnection = PQconnectdb(connectionString.c_str());
|
||||
|
||||
assertTrue (PQstatus(pConnection) == CONNECTION_OK);
|
||||
|
||||
PGresult * pResult = 0;
|
||||
PGresult * pResult = nullptr;
|
||||
std::string sql = "DROP TABLE IF EXISTS Test";
|
||||
|
||||
pResult = PQexec(pConnection, sql.c_str());
|
||||
|
||||
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);
|
||||
|
||||
PQclear(pResult);
|
||||
@@ -306,7 +306,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
|
||||
insertStatementName.c_str(),
|
||||
sql.c_str(),
|
||||
5,
|
||||
0
|
||||
nullptr
|
||||
);
|
||||
|
||||
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);
|
||||
float fifth = 1.5;
|
||||
|
||||
const char *paramValues[5] = { 0 };
|
||||
const char *paramValues[5] = { nullptr };
|
||||
int paramLengths[5] = { 0 };
|
||||
int paramFormats[5] = { 0 };
|
||||
|
||||
@@ -364,7 +364,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
|
||||
|
||||
assertTrue (PQntuples(pResult) == 1);
|
||||
|
||||
char* pSelectResult[5] = { 0 };
|
||||
char* pSelectResult[5] = { nullptr };
|
||||
int pResultLengths[5] = { 0 };
|
||||
|
||||
// column 0
|
||||
@@ -377,7 +377,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
|
||||
0,
|
||||
0
|
||||
);
|
||||
assertTrue (pSelectResult[ 0 ] != 0);
|
||||
assertTrue (pSelectResult[ 0 ] != nullptr);
|
||||
assertTrue (pResultLengths[ 0 ] != 0);
|
||||
|
||||
// column 1
|
||||
@@ -390,7 +390,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
|
||||
0,
|
||||
1
|
||||
);
|
||||
assertTrue (pSelectResult[ 1 ] != 0);
|
||||
assertTrue (pSelectResult[ 1 ] != nullptr);
|
||||
assertTrue (pResultLengths[ 1 ] != 0);
|
||||
|
||||
// column 2
|
||||
@@ -403,7 +403,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
|
||||
0,
|
||||
2
|
||||
);
|
||||
assertTrue (pSelectResult[ 2 ] != 0);
|
||||
assertTrue (pSelectResult[ 2 ] != nullptr);
|
||||
assertTrue (pResultLengths[ 2 ] != 0);
|
||||
|
||||
// column 3
|
||||
@@ -416,7 +416,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
|
||||
0,
|
||||
3
|
||||
);
|
||||
assertTrue (pSelectResult[ 3 ] != 0);
|
||||
assertTrue (pSelectResult[ 3 ] != nullptr);
|
||||
assertTrue (pResultLengths[ 3 ] != 0);
|
||||
|
||||
// column 4
|
||||
@@ -429,7 +429,7 @@ void SQLExecutor::barebonePostgreSQLTest(std::string host, std::string user, std
|
||||
0,
|
||||
4
|
||||
);
|
||||
assertTrue (pSelectResult[ 4 ] != 0);
|
||||
assertTrue (pSelectResult[ 4 ] != nullptr);
|
||||
assertTrue (pResultLengths[ 4 ] != 0);
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,20 +7,20 @@ int main(int argc, char** argv) {
|
||||
// Create parse and tokenize benchmarks for TPC-H queries.
|
||||
const auto tpch_queries = getTPCHQueries();
|
||||
for (const auto& query : tpch_queries) {
|
||||
std::string p_name = query.first + "-parse";
|
||||
benchmark::RegisterBenchmark(p_name.c_str(), &BM_ParseBenchmark, query.second);
|
||||
std::string t_name = query.first + "-tokenize";
|
||||
benchmark::RegisterBenchmark(t_name.c_str(), &BM_TokenizeBenchmark, query.second);
|
||||
std::string p_name = query.first + "-parse";
|
||||
benchmark::RegisterBenchmark(p_name.c_str(), &BM_ParseBenchmark, query.second);
|
||||
std::string t_name = query.first + "-tokenize";
|
||||
benchmark::RegisterBenchmark(t_name.c_str(), &BM_TokenizeBenchmark, query.second);
|
||||
}
|
||||
|
||||
// Create parse and tokenize benchmarks for all queries in sql_queries array.
|
||||
for (unsigned i = 0; i < sql_queries.size(); ++i) {
|
||||
const auto& query = sql_queries[i];
|
||||
std::string p_name = getQueryName(i) + "-parse";
|
||||
benchmark::RegisterBenchmark(p_name.c_str(), &BM_ParseBenchmark, query.second);
|
||||
const auto& query = sql_queries[i];
|
||||
std::string p_name = getQueryName(i) + "-parse";
|
||||
benchmark::RegisterBenchmark(p_name.c_str(), &BM_ParseBenchmark, query.second);
|
||||
|
||||
std::string t_name = getQueryName(i) + "-tokenize";
|
||||
benchmark::RegisterBenchmark(t_name.c_str(), &BM_TokenizeBenchmark, query.second);
|
||||
std::string t_name = getQueryName(i) + "-tokenize";
|
||||
benchmark::RegisterBenchmark(t_name.c_str(), &BM_TokenizeBenchmark, query.second);
|
||||
}
|
||||
|
||||
benchmark::Initialize(&argc, argv);
|
||||
|
||||
@@ -16,8 +16,8 @@ void BM_TokenizeBenchmark(benchmark::State& st, const std::string& query) {
|
||||
st.counters["num_chars"] = query.size();
|
||||
|
||||
while (st.KeepRunning()) {
|
||||
std::vector<int16_t> tokens(512);
|
||||
hsql::SQLParser::tokenize(query, &tokens);
|
||||
std::vector<int16_t> tokens(512);
|
||||
hsql::SQLParser::tokenize(query, &tokens);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,19 +26,19 @@ void BM_ParseBenchmark(benchmark::State& st, const std::string& query) {
|
||||
st.counters["num_chars"] = query.size();
|
||||
|
||||
while (st.KeepRunning()) {
|
||||
hsql::SQLParserResult result;
|
||||
hsql::SQLParser::parse(query, &result);
|
||||
if (!result.isValid()) {
|
||||
std::cout << query << std::endl;
|
||||
std::cout << result.errorMsg() << std::endl;
|
||||
st.SkipWithError("Parsing failed!");
|
||||
}
|
||||
hsql::SQLParserResult result;
|
||||
hsql::SQLParser::parse(query, &result);
|
||||
if (!result.isValid()) {
|
||||
std::cout << query << std::endl;
|
||||
std::cout << result.errorMsg() << std::endl;
|
||||
st.SkipWithError("Parsing failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string readFileContents(const std::string& file_path) {
|
||||
std::ifstream t(file_path.c_str());
|
||||
std::string text((std::istreambuf_iterator<char>(t)),
|
||||
std::istreambuf_iterator<char>());
|
||||
std::istreambuf_iterator<char>());
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ std::string readFileContents(const std::string& file_path);
|
||||
|
||||
#define PARSE_QUERY_BENCHMARK(name, query)\
|
||||
static void name(benchmark::State& st) {\
|
||||
BM_ParseBenchmark(st, query);\
|
||||
BM_ParseBenchmark(st, query);\
|
||||
}\
|
||||
BENCHMARK(name);
|
||||
|
||||
#define TOKENIZE_QUERY_BENCHMARK(name, query)\
|
||||
static void name(benchmark::State& st) {\
|
||||
BM_TokenizeBenchmark(st, query);\
|
||||
BM_TokenizeBenchmark(st, query);\
|
||||
}\
|
||||
BENCHMARK(name);
|
||||
|
||||
|
||||
@@ -24,14 +24,14 @@ static void BM_CharacterCount(benchmark::State& st) {
|
||||
st.counters["num_tokens"] = getNumTokens(query);
|
||||
st.counters["num_chars"] = query.size();
|
||||
while (st.KeepRunning()) {
|
||||
hsql::SQLParserResult result;
|
||||
hsql::SQLParser::parse(query, &result);
|
||||
hsql::SQLParserResult result;
|
||||
hsql::SQLParser::parse(query, &result);
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_CharacterCount)
|
||||
->RangeMultiplier(1 << 2)
|
||||
->Ranges({{1 << 5, 1 << 15},
|
||||
{5, 5}});
|
||||
{5, 5}});
|
||||
|
||||
// Benchmark the influence of increasing number of tokens, while
|
||||
// the number of characters remains unchanged.
|
||||
@@ -46,42 +46,42 @@ static void BM_ConditionalTokens(benchmark::State& st) {
|
||||
std::stringstream condStream;
|
||||
size_t missingTokens = numTokens - 4;
|
||||
if (missingTokens > 0) {
|
||||
condStream << " WHERE a";
|
||||
missingTokens -= 2;
|
||||
condStream << " WHERE a";
|
||||
missingTokens -= 2;
|
||||
|
||||
while (missingTokens > 0) {
|
||||
condStream << " AND a";
|
||||
missingTokens -= 2;
|
||||
}
|
||||
while (missingTokens > 0) {
|
||||
condStream << " AND a";
|
||||
missingTokens -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
query += condStream.str();
|
||||
|
||||
if (targetSize >= query.size()) {
|
||||
const size_t pad = targetSize - query.size();
|
||||
const std::string filler = std::string(pad, 'a');
|
||||
query.replace(7, 1, filler);
|
||||
const size_t pad = targetSize - query.size();
|
||||
const std::string filler = std::string(pad, 'a');
|
||||
query.replace(7, 1, filler);
|
||||
|
||||
} else {
|
||||
// Query can't be the same length as in the other benchmarks.
|
||||
// Running this will result in unusable data.
|
||||
fprintf(stderr, "Too many tokens. Query too long for benchmark char limit (%lu > %lu).\n",
|
||||
query.size(), targetSize);
|
||||
return;
|
||||
// Query can't be the same length as in the other benchmarks.
|
||||
// Running this will result in unusable data.
|
||||
fprintf(stderr, "Too many tokens. Query too long for benchmark char limit (%lu > %lu).\n",
|
||||
query.size(), targetSize);
|
||||
return;
|
||||
}
|
||||
|
||||
st.counters["num_tokens"] = getNumTokens(query);
|
||||
st.counters["num_chars"] = query.size();
|
||||
while (st.KeepRunning()) {
|
||||
hsql::SQLParserResult result;
|
||||
hsql::SQLParser::parse(query, &result);
|
||||
if (!result.isValid()) st.SkipWithError("Parsing failed!");
|
||||
hsql::SQLParserResult result;
|
||||
hsql::SQLParser::parse(query, &result);
|
||||
if (!result.isValid()) st.SkipWithError("Parsing failed!");
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ConditionalTokens)
|
||||
->RangeMultiplier(1 << 2)
|
||||
->Ranges({{1 << 14, 1 << 14},
|
||||
{1 << 2, 1 << 11}});
|
||||
{1 << 2, 1 << 11}});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace filesystem = std::filesystem;
|
||||
|
||||
std::string getQueryName(unsigned i) {
|
||||
if (sql_queries[i].first.empty()) {
|
||||
std::string name = "#" + std::to_string(i + 1);
|
||||
return name;
|
||||
std::string name = "#" + std::to_string(i + 1);
|
||||
return name;
|
||||
}
|
||||
return std::string("") + sql_queries[i].first;
|
||||
}
|
||||
@@ -22,22 +22,22 @@ std::vector<SQLQuery> getQueriesFromDirectory(const std::string& dir_path) {
|
||||
std::vector<std::string> files;
|
||||
|
||||
for (auto& entry : filesystem::directory_iterator(dir_path)) {
|
||||
if (filesystem::is_regular_file(entry)) {
|
||||
std::string path_str = filesystem::path(entry);
|
||||
if (filesystem::is_regular_file(entry)) {
|
||||
std::string path_str = filesystem::path(entry);
|
||||
|
||||
if (std::regex_search(path_str, query_file_regex)) {
|
||||
files.push_back(path_str);
|
||||
}
|
||||
}
|
||||
if (std::regex_search(path_str, query_file_regex)) {
|
||||
files.push_back(path_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(files.begin(), files.end());
|
||||
|
||||
std::vector<SQLQuery> queries;
|
||||
for (const std::string& file_path : files) {
|
||||
const filesystem::path p(file_path);
|
||||
const std::string query = readFileContents(file_path);
|
||||
queries.emplace_back(p.filename(), query);
|
||||
const filesystem::path p(file_path);
|
||||
const std::string query = readFileContents(file_path);
|
||||
queries.emplace_back(p.filename(), query);
|
||||
}
|
||||
return queries;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ bool SQLParser::parse(const std::string& sql, SQLParserResult* result) {
|
||||
YY_BUFFER_STATE state;
|
||||
|
||||
if (hsql_lex_init(&scanner)) {
|
||||
// Couldn't initialize the lexer.
|
||||
fprintf(stderr, "SQLParser: Error when initializing lexer!\n");
|
||||
return false;
|
||||
// Couldn't initialize the lexer.
|
||||
fprintf(stderr, "SQLParser: Error when initializing lexer!\n");
|
||||
return false;
|
||||
}
|
||||
const char* text = sql.c_str();
|
||||
state = hsql__scan_string(text, scanner);
|
||||
@@ -44,8 +44,8 @@ bool SQLParser::tokenize(const std::string& sql, std::vector<int16_t>* tokens) {
|
||||
// Initialize the scanner.
|
||||
yyscan_t scanner;
|
||||
if (hsql_lex_init(&scanner)) {
|
||||
fprintf(stderr, "SQLParser: Error when initializing lexer!\n");
|
||||
return false;
|
||||
fprintf(stderr, "SQLParser: Error when initializing lexer!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
YY_BUFFER_STATE state;
|
||||
@@ -58,12 +58,12 @@ bool SQLParser::tokenize(const std::string& sql, std::vector<int16_t>* tokens) {
|
||||
// Note: hsql_lex returns int, but we know that its range is within 16 bit.
|
||||
int16_t token = hsql_lex(&yylval, &yylloc, scanner);
|
||||
while (token != 0) {
|
||||
tokens->push_back(token);
|
||||
token = hsql_lex(&yylval, &yylloc, scanner);
|
||||
tokens->push_back(token);
|
||||
token = hsql_lex(&yylval, &yylloc, scanner);
|
||||
|
||||
if (token == SQL_IDENTIFIER || token == SQL_STRING) {
|
||||
free(yylval.sval);
|
||||
}
|
||||
if (token == SQL_IDENTIFIER || token == SQL_STRING) {
|
||||
free(yylval.sval);
|
||||
}
|
||||
}
|
||||
|
||||
hsql__delete_buffer(state, scanner);
|
||||
|
||||
@@ -82,8 +82,8 @@ std::vector<SQLStatement*> SQLParserResult::releaseStatements() {
|
||||
std::vector<SQLStatement*> copy;
|
||||
if (statements_)
|
||||
{
|
||||
copy = *statements_;
|
||||
statements_->clear();
|
||||
copy = *statements_;
|
||||
statements_->clear();
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
@@ -91,28 +91,28 @@ std::vector<SQLStatement*> SQLParserResult::releaseStatements() {
|
||||
void SQLParserResult::reset(bool mv) {
|
||||
if (statements_)
|
||||
{
|
||||
if (!mv)
|
||||
{
|
||||
for (SQLStatement* statement : *statements_) {
|
||||
delete statement;
|
||||
}
|
||||
delete statements_;
|
||||
}
|
||||
statements_ = nullptr;
|
||||
if (!mv)
|
||||
{
|
||||
for (SQLStatement* statement : *statements_) {
|
||||
delete statement;
|
||||
}
|
||||
delete statements_;
|
||||
}
|
||||
statements_ = nullptr;
|
||||
}
|
||||
|
||||
if (parameters_)
|
||||
{
|
||||
if (!mv) delete parameters_;
|
||||
parameters_ = nullptr;
|
||||
if (!mv) delete parameters_;
|
||||
parameters_ = nullptr;
|
||||
}
|
||||
|
||||
isValid_ = false;
|
||||
|
||||
if (errorMsg_)
|
||||
{
|
||||
if (!mv) free(errorMsg_);
|
||||
errorMsg_ = nullptr;
|
||||
if (!mv) free(errorMsg_);
|
||||
errorMsg_ = nullptr;
|
||||
}
|
||||
errorLine_ = -1;
|
||||
errorColumn_ = -1;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -66,14 +66,14 @@ extern int hsql_debug;
|
||||
yylloc->first_line = yylloc->last_line; \
|
||||
yylloc->first_column = yylloc->last_column; \
|
||||
for (int i = 0; yytext[i] != '\0'; i++) { \
|
||||
yylloc->total_column++; \
|
||||
yylloc->string_length++; \
|
||||
if (yytext[i] == '\n') { \
|
||||
yylloc->last_line++; \
|
||||
yylloc->last_column = 0; \
|
||||
} else { \
|
||||
yylloc->last_column++; \
|
||||
} \
|
||||
yylloc->total_column++; \
|
||||
yylloc->string_length++; \
|
||||
if (yytext[i] == '\n') { \
|
||||
yylloc->last_line++; \
|
||||
yylloc->last_column = 0; \
|
||||
} else { \
|
||||
yylloc->last_column++; \
|
||||
} \
|
||||
}
|
||||
|
||||
#line 80 "bison_parser.h"
|
||||
@@ -83,186 +83,186 @@ extern int hsql_debug;
|
||||
# define HSQL_TOKENTYPE
|
||||
enum hsql_tokentype
|
||||
{
|
||||
SQL_HSQL_EMPTY = -2,
|
||||
SQL_YYEOF = 0, /* "end of file" */
|
||||
SQL_HSQL_error = 256, /* error */
|
||||
SQL_HSQL_UNDEF = 257, /* "invalid token" */
|
||||
SQL_IDENTIFIER = 258, /* IDENTIFIER */
|
||||
SQL_STRING = 259, /* STRING */
|
||||
SQL_FLOATVAL = 260, /* FLOATVAL */
|
||||
SQL_INTVAL = 261, /* INTVAL */
|
||||
SQL_DEALLOCATE = 262, /* DEALLOCATE */
|
||||
SQL_PARAMETERS = 263, /* PARAMETERS */
|
||||
SQL_INTERSECT = 264, /* INTERSECT */
|
||||
SQL_TEMPORARY = 265, /* TEMPORARY */
|
||||
SQL_TIMESTAMP = 266, /* TIMESTAMP */
|
||||
SQL_DISTINCT = 267, /* DISTINCT */
|
||||
SQL_NVARCHAR = 268, /* NVARCHAR */
|
||||
SQL_RESTRICT = 269, /* RESTRICT */
|
||||
SQL_TRUNCATE = 270, /* TRUNCATE */
|
||||
SQL_ANALYZE = 271, /* ANALYZE */
|
||||
SQL_BETWEEN = 272, /* BETWEEN */
|
||||
SQL_CASCADE = 273, /* CASCADE */
|
||||
SQL_COLUMNS = 274, /* COLUMNS */
|
||||
SQL_CONTROL = 275, /* CONTROL */
|
||||
SQL_DEFAULT = 276, /* DEFAULT */
|
||||
SQL_EXECUTE = 277, /* EXECUTE */
|
||||
SQL_EXPLAIN = 278, /* EXPLAIN */
|
||||
SQL_INTEGER = 279, /* INTEGER */
|
||||
SQL_NATURAL = 280, /* NATURAL */
|
||||
SQL_PREPARE = 281, /* PREPARE */
|
||||
SQL_PRIMARY = 282, /* PRIMARY */
|
||||
SQL_SCHEMAS = 283, /* SCHEMAS */
|
||||
SQL_CHARACTER_VARYING = 284, /* CHARACTER_VARYING */
|
||||
SQL_REAL = 285, /* REAL */
|
||||
SQL_DECIMAL = 286, /* DECIMAL */
|
||||
SQL_SMALLINT = 287, /* SMALLINT */
|
||||
SQL_BIGINT = 288, /* BIGINT */
|
||||
SQL_SPATIAL = 289, /* SPATIAL */
|
||||
SQL_VARCHAR = 290, /* VARCHAR */
|
||||
SQL_VIRTUAL = 291, /* VIRTUAL */
|
||||
SQL_DESCRIBE = 292, /* DESCRIBE */
|
||||
SQL_BEFORE = 293, /* BEFORE */
|
||||
SQL_COLUMN = 294, /* COLUMN */
|
||||
SQL_CREATE = 295, /* CREATE */
|
||||
SQL_DELETE = 296, /* DELETE */
|
||||
SQL_DIRECT = 297, /* DIRECT */
|
||||
SQL_DOUBLE = 298, /* DOUBLE */
|
||||
SQL_ESCAPE = 299, /* ESCAPE */
|
||||
SQL_EXCEPT = 300, /* EXCEPT */
|
||||
SQL_EXISTS = 301, /* EXISTS */
|
||||
SQL_EXTRACT = 302, /* EXTRACT */
|
||||
SQL_CAST = 303, /* CAST */
|
||||
SQL_FORMAT = 304, /* FORMAT */
|
||||
SQL_GLOBAL = 305, /* GLOBAL */
|
||||
SQL_HAVING = 306, /* HAVING */
|
||||
SQL_IMPORT = 307, /* IMPORT */
|
||||
SQL_INSERT = 308, /* INSERT */
|
||||
SQL_ISNULL = 309, /* ISNULL */
|
||||
SQL_OFFSET = 310, /* OFFSET */
|
||||
SQL_RENAME = 311, /* RENAME */
|
||||
SQL_SCHEMA = 312, /* SCHEMA */
|
||||
SQL_SELECT = 313, /* SELECT */
|
||||
SQL_SORTED = 314, /* SORTED */
|
||||
SQL_TABLES = 315, /* TABLES */
|
||||
SQL_UNIQUE = 316, /* UNIQUE */
|
||||
SQL_UNLOAD = 317, /* UNLOAD */
|
||||
SQL_UPDATE = 318, /* UPDATE */
|
||||
SQL_VALUES = 319, /* VALUES */
|
||||
SQL_AFTER = 320, /* AFTER */
|
||||
SQL_ALTER = 321, /* ALTER */
|
||||
SQL_CROSS = 322, /* CROSS */
|
||||
SQL_DELTA = 323, /* DELTA */
|
||||
SQL_FLOAT = 324, /* FLOAT */
|
||||
SQL_GROUP = 325, /* GROUP */
|
||||
SQL_INDEX = 326, /* INDEX */
|
||||
SQL_INNER = 327, /* INNER */
|
||||
SQL_LIMIT = 328, /* LIMIT */
|
||||
SQL_LOCAL = 329, /* LOCAL */
|
||||
SQL_MERGE = 330, /* MERGE */
|
||||
SQL_MINUS = 331, /* MINUS */
|
||||
SQL_ORDER = 332, /* ORDER */
|
||||
SQL_OVER = 333, /* OVER */
|
||||
SQL_OUTER = 334, /* OUTER */
|
||||
SQL_RIGHT = 335, /* RIGHT */
|
||||
SQL_TABLE = 336, /* TABLE */
|
||||
SQL_UNION = 337, /* UNION */
|
||||
SQL_USING = 338, /* USING */
|
||||
SQL_WHERE = 339, /* WHERE */
|
||||
SQL_CALL = 340, /* CALL */
|
||||
SQL_CASE = 341, /* CASE */
|
||||
SQL_CHAR = 342, /* CHAR */
|
||||
SQL_COPY = 343, /* COPY */
|
||||
SQL_DATE = 344, /* DATE */
|
||||
SQL_DATETIME = 345, /* DATETIME */
|
||||
SQL_DESC = 346, /* DESC */
|
||||
SQL_DROP = 347, /* DROP */
|
||||
SQL_ELSE = 348, /* ELSE */
|
||||
SQL_FILE = 349, /* FILE */
|
||||
SQL_FROM = 350, /* FROM */
|
||||
SQL_FULL = 351, /* FULL */
|
||||
SQL_HASH = 352, /* HASH */
|
||||
SQL_HINT = 353, /* HINT */
|
||||
SQL_INTO = 354, /* INTO */
|
||||
SQL_JOIN = 355, /* JOIN */
|
||||
SQL_LEFT = 356, /* LEFT */
|
||||
SQL_LIKE = 357, /* LIKE */
|
||||
SQL_LOAD = 358, /* LOAD */
|
||||
SQL_LONG = 359, /* LONG */
|
||||
SQL_NULL = 360, /* NULL */
|
||||
SQL_PARTITION = 361, /* PARTITION */
|
||||
SQL_PLAN = 362, /* PLAN */
|
||||
SQL_SHOW = 363, /* SHOW */
|
||||
SQL_TEXT = 364, /* TEXT */
|
||||
SQL_THEN = 365, /* THEN */
|
||||
SQL_TIME = 366, /* TIME */
|
||||
SQL_VIEW = 367, /* VIEW */
|
||||
SQL_WHEN = 368, /* WHEN */
|
||||
SQL_WITH = 369, /* WITH */
|
||||
SQL_ADD = 370, /* ADD */
|
||||
SQL_ALL = 371, /* ALL */
|
||||
SQL_AND = 372, /* AND */
|
||||
SQL_ASC = 373, /* ASC */
|
||||
SQL_END = 374, /* END */
|
||||
SQL_FOR = 375, /* FOR */
|
||||
SQL_INT = 376, /* INT */
|
||||
SQL_KEY = 377, /* KEY */
|
||||
SQL_NOT = 378, /* NOT */
|
||||
SQL_OFF = 379, /* OFF */
|
||||
SQL_SET = 380, /* SET */
|
||||
SQL_TOP = 381, /* TOP */
|
||||
SQL_AS = 382, /* AS */
|
||||
SQL_BY = 383, /* BY */
|
||||
SQL_IF = 384, /* IF */
|
||||
SQL_IN = 385, /* IN */
|
||||
SQL_IS = 386, /* IS */
|
||||
SQL_OF = 387, /* OF */
|
||||
SQL_ON = 388, /* ON */
|
||||
SQL_OR = 389, /* OR */
|
||||
SQL_TO = 390, /* TO */
|
||||
SQL_NO = 391, /* NO */
|
||||
SQL_ARRAY = 392, /* ARRAY */
|
||||
SQL_CONCAT = 393, /* CONCAT */
|
||||
SQL_ILIKE = 394, /* ILIKE */
|
||||
SQL_SECOND = 395, /* SECOND */
|
||||
SQL_MINUTE = 396, /* MINUTE */
|
||||
SQL_HOUR = 397, /* HOUR */
|
||||
SQL_DAY = 398, /* DAY */
|
||||
SQL_MONTH = 399, /* MONTH */
|
||||
SQL_YEAR = 400, /* YEAR */
|
||||
SQL_SECONDS = 401, /* SECONDS */
|
||||
SQL_MINUTES = 402, /* MINUTES */
|
||||
SQL_HOURS = 403, /* HOURS */
|
||||
SQL_DAYS = 404, /* DAYS */
|
||||
SQL_MONTHS = 405, /* MONTHS */
|
||||
SQL_YEARS = 406, /* YEARS */
|
||||
SQL_INTERVAL = 407, /* INTERVAL */
|
||||
SQL_TRUE = 408, /* TRUE */
|
||||
SQL_FALSE = 409, /* FALSE */
|
||||
SQL_BOOLEAN = 410, /* BOOLEAN */
|
||||
SQL_TRANSACTION = 411, /* TRANSACTION */
|
||||
SQL_BEGIN = 412, /* BEGIN */
|
||||
SQL_COMMIT = 413, /* COMMIT */
|
||||
SQL_ROLLBACK = 414, /* ROLLBACK */
|
||||
SQL_NOWAIT = 415, /* NOWAIT */
|
||||
SQL_SKIP = 416, /* SKIP */
|
||||
SQL_LOCKED = 417, /* LOCKED */
|
||||
SQL_SHARE = 418, /* SHARE */
|
||||
SQL_RANGE = 419, /* RANGE */
|
||||
SQL_ROWS = 420, /* ROWS */
|
||||
SQL_GROUPS = 421, /* GROUPS */
|
||||
SQL_UNBOUNDED = 422, /* UNBOUNDED */
|
||||
SQL_FOLLOWING = 423, /* FOLLOWING */
|
||||
SQL_PRECEDING = 424, /* PRECEDING */
|
||||
SQL_CURRENT_ROW = 425, /* CURRENT_ROW */
|
||||
SQL_EQUALS = 426, /* EQUALS */
|
||||
SQL_NOTEQUALS = 427, /* NOTEQUALS */
|
||||
SQL_LESS = 428, /* LESS */
|
||||
SQL_GREATER = 429, /* GREATER */
|
||||
SQL_LESSEQ = 430, /* LESSEQ */
|
||||
SQL_GREATEREQ = 431, /* GREATEREQ */
|
||||
SQL_NOTNULL = 432, /* NOTNULL */
|
||||
SQL_UMINUS = 433 /* UMINUS */
|
||||
SQL_HSQL_EMPTY = -2,
|
||||
SQL_YYEOF = 0, /* "end of file" */
|
||||
SQL_HSQL_error = 256, /* error */
|
||||
SQL_HSQL_UNDEF = 257, /* "invalid token" */
|
||||
SQL_IDENTIFIER = 258, /* IDENTIFIER */
|
||||
SQL_STRING = 259, /* STRING */
|
||||
SQL_FLOATVAL = 260, /* FLOATVAL */
|
||||
SQL_INTVAL = 261, /* INTVAL */
|
||||
SQL_DEALLOCATE = 262, /* DEALLOCATE */
|
||||
SQL_PARAMETERS = 263, /* PARAMETERS */
|
||||
SQL_INTERSECT = 264, /* INTERSECT */
|
||||
SQL_TEMPORARY = 265, /* TEMPORARY */
|
||||
SQL_TIMESTAMP = 266, /* TIMESTAMP */
|
||||
SQL_DISTINCT = 267, /* DISTINCT */
|
||||
SQL_NVARCHAR = 268, /* NVARCHAR */
|
||||
SQL_RESTRICT = 269, /* RESTRICT */
|
||||
SQL_TRUNCATE = 270, /* TRUNCATE */
|
||||
SQL_ANALYZE = 271, /* ANALYZE */
|
||||
SQL_BETWEEN = 272, /* BETWEEN */
|
||||
SQL_CASCADE = 273, /* CASCADE */
|
||||
SQL_COLUMNS = 274, /* COLUMNS */
|
||||
SQL_CONTROL = 275, /* CONTROL */
|
||||
SQL_DEFAULT = 276, /* DEFAULT */
|
||||
SQL_EXECUTE = 277, /* EXECUTE */
|
||||
SQL_EXPLAIN = 278, /* EXPLAIN */
|
||||
SQL_INTEGER = 279, /* INTEGER */
|
||||
SQL_NATURAL = 280, /* NATURAL */
|
||||
SQL_PREPARE = 281, /* PREPARE */
|
||||
SQL_PRIMARY = 282, /* PRIMARY */
|
||||
SQL_SCHEMAS = 283, /* SCHEMAS */
|
||||
SQL_CHARACTER_VARYING = 284, /* CHARACTER_VARYING */
|
||||
SQL_REAL = 285, /* REAL */
|
||||
SQL_DECIMAL = 286, /* DECIMAL */
|
||||
SQL_SMALLINT = 287, /* SMALLINT */
|
||||
SQL_BIGINT = 288, /* BIGINT */
|
||||
SQL_SPATIAL = 289, /* SPATIAL */
|
||||
SQL_VARCHAR = 290, /* VARCHAR */
|
||||
SQL_VIRTUAL = 291, /* VIRTUAL */
|
||||
SQL_DESCRIBE = 292, /* DESCRIBE */
|
||||
SQL_BEFORE = 293, /* BEFORE */
|
||||
SQL_COLUMN = 294, /* COLUMN */
|
||||
SQL_CREATE = 295, /* CREATE */
|
||||
SQL_DELETE = 296, /* DELETE */
|
||||
SQL_DIRECT = 297, /* DIRECT */
|
||||
SQL_DOUBLE = 298, /* DOUBLE */
|
||||
SQL_ESCAPE = 299, /* ESCAPE */
|
||||
SQL_EXCEPT = 300, /* EXCEPT */
|
||||
SQL_EXISTS = 301, /* EXISTS */
|
||||
SQL_EXTRACT = 302, /* EXTRACT */
|
||||
SQL_CAST = 303, /* CAST */
|
||||
SQL_FORMAT = 304, /* FORMAT */
|
||||
SQL_GLOBAL = 305, /* GLOBAL */
|
||||
SQL_HAVING = 306, /* HAVING */
|
||||
SQL_IMPORT = 307, /* IMPORT */
|
||||
SQL_INSERT = 308, /* INSERT */
|
||||
SQL_ISNULL = 309, /* ISNULL */
|
||||
SQL_OFFSET = 310, /* OFFSET */
|
||||
SQL_RENAME = 311, /* RENAME */
|
||||
SQL_SCHEMA = 312, /* SCHEMA */
|
||||
SQL_SELECT = 313, /* SELECT */
|
||||
SQL_SORTED = 314, /* SORTED */
|
||||
SQL_TABLES = 315, /* TABLES */
|
||||
SQL_UNIQUE = 316, /* UNIQUE */
|
||||
SQL_UNLOAD = 317, /* UNLOAD */
|
||||
SQL_UPDATE = 318, /* UPDATE */
|
||||
SQL_VALUES = 319, /* VALUES */
|
||||
SQL_AFTER = 320, /* AFTER */
|
||||
SQL_ALTER = 321, /* ALTER */
|
||||
SQL_CROSS = 322, /* CROSS */
|
||||
SQL_DELTA = 323, /* DELTA */
|
||||
SQL_FLOAT = 324, /* FLOAT */
|
||||
SQL_GROUP = 325, /* GROUP */
|
||||
SQL_INDEX = 326, /* INDEX */
|
||||
SQL_INNER = 327, /* INNER */
|
||||
SQL_LIMIT = 328, /* LIMIT */
|
||||
SQL_LOCAL = 329, /* LOCAL */
|
||||
SQL_MERGE = 330, /* MERGE */
|
||||
SQL_MINUS = 331, /* MINUS */
|
||||
SQL_ORDER = 332, /* ORDER */
|
||||
SQL_OVER = 333, /* OVER */
|
||||
SQL_OUTER = 334, /* OUTER */
|
||||
SQL_RIGHT = 335, /* RIGHT */
|
||||
SQL_TABLE = 336, /* TABLE */
|
||||
SQL_UNION = 337, /* UNION */
|
||||
SQL_USING = 338, /* USING */
|
||||
SQL_WHERE = 339, /* WHERE */
|
||||
SQL_CALL = 340, /* CALL */
|
||||
SQL_CASE = 341, /* CASE */
|
||||
SQL_CHAR = 342, /* CHAR */
|
||||
SQL_COPY = 343, /* COPY */
|
||||
SQL_DATE = 344, /* DATE */
|
||||
SQL_DATETIME = 345, /* DATETIME */
|
||||
SQL_DESC = 346, /* DESC */
|
||||
SQL_DROP = 347, /* DROP */
|
||||
SQL_ELSE = 348, /* ELSE */
|
||||
SQL_FILE = 349, /* FILE */
|
||||
SQL_FROM = 350, /* FROM */
|
||||
SQL_FULL = 351, /* FULL */
|
||||
SQL_HASH = 352, /* HASH */
|
||||
SQL_HINT = 353, /* HINT */
|
||||
SQL_INTO = 354, /* INTO */
|
||||
SQL_JOIN = 355, /* JOIN */
|
||||
SQL_LEFT = 356, /* LEFT */
|
||||
SQL_LIKE = 357, /* LIKE */
|
||||
SQL_LOAD = 358, /* LOAD */
|
||||
SQL_LONG = 359, /* LONG */
|
||||
SQL_NULL = 360, /* NULL */
|
||||
SQL_PARTITION = 361, /* PARTITION */
|
||||
SQL_PLAN = 362, /* PLAN */
|
||||
SQL_SHOW = 363, /* SHOW */
|
||||
SQL_TEXT = 364, /* TEXT */
|
||||
SQL_THEN = 365, /* THEN */
|
||||
SQL_TIME = 366, /* TIME */
|
||||
SQL_VIEW = 367, /* VIEW */
|
||||
SQL_WHEN = 368, /* WHEN */
|
||||
SQL_WITH = 369, /* WITH */
|
||||
SQL_ADD = 370, /* ADD */
|
||||
SQL_ALL = 371, /* ALL */
|
||||
SQL_AND = 372, /* AND */
|
||||
SQL_ASC = 373, /* ASC */
|
||||
SQL_END = 374, /* END */
|
||||
SQL_FOR = 375, /* FOR */
|
||||
SQL_INT = 376, /* INT */
|
||||
SQL_KEY = 377, /* KEY */
|
||||
SQL_NOT = 378, /* NOT */
|
||||
SQL_OFF = 379, /* OFF */
|
||||
SQL_SET = 380, /* SET */
|
||||
SQL_TOP = 381, /* TOP */
|
||||
SQL_AS = 382, /* AS */
|
||||
SQL_BY = 383, /* BY */
|
||||
SQL_IF = 384, /* IF */
|
||||
SQL_IN = 385, /* IN */
|
||||
SQL_IS = 386, /* IS */
|
||||
SQL_OF = 387, /* OF */
|
||||
SQL_ON = 388, /* ON */
|
||||
SQL_OR = 389, /* OR */
|
||||
SQL_TO = 390, /* TO */
|
||||
SQL_NO = 391, /* NO */
|
||||
SQL_ARRAY = 392, /* ARRAY */
|
||||
SQL_CONCAT = 393, /* CONCAT */
|
||||
SQL_ILIKE = 394, /* ILIKE */
|
||||
SQL_SECOND = 395, /* SECOND */
|
||||
SQL_MINUTE = 396, /* MINUTE */
|
||||
SQL_HOUR = 397, /* HOUR */
|
||||
SQL_DAY = 398, /* DAY */
|
||||
SQL_MONTH = 399, /* MONTH */
|
||||
SQL_YEAR = 400, /* YEAR */
|
||||
SQL_SECONDS = 401, /* SECONDS */
|
||||
SQL_MINUTES = 402, /* MINUTES */
|
||||
SQL_HOURS = 403, /* HOURS */
|
||||
SQL_DAYS = 404, /* DAYS */
|
||||
SQL_MONTHS = 405, /* MONTHS */
|
||||
SQL_YEARS = 406, /* YEARS */
|
||||
SQL_INTERVAL = 407, /* INTERVAL */
|
||||
SQL_TRUE = 408, /* TRUE */
|
||||
SQL_FALSE = 409, /* FALSE */
|
||||
SQL_BOOLEAN = 410, /* BOOLEAN */
|
||||
SQL_TRANSACTION = 411, /* TRANSACTION */
|
||||
SQL_BEGIN = 412, /* BEGIN */
|
||||
SQL_COMMIT = 413, /* COMMIT */
|
||||
SQL_ROLLBACK = 414, /* ROLLBACK */
|
||||
SQL_NOWAIT = 415, /* NOWAIT */
|
||||
SQL_SKIP = 416, /* SKIP */
|
||||
SQL_LOCKED = 417, /* LOCKED */
|
||||
SQL_SHARE = 418, /* SHARE */
|
||||
SQL_RANGE = 419, /* RANGE */
|
||||
SQL_ROWS = 420, /* ROWS */
|
||||
SQL_GROUPS = 421, /* GROUPS */
|
||||
SQL_UNBOUNDED = 422, /* UNBOUNDED */
|
||||
SQL_FOLLOWING = 423, /* FOLLOWING */
|
||||
SQL_PRECEDING = 424, /* PRECEDING */
|
||||
SQL_CURRENT_ROW = 425, /* CURRENT_ROW */
|
||||
SQL_EQUALS = 426, /* EQUALS */
|
||||
SQL_NOTEQUALS = 427, /* NOTEQUALS */
|
||||
SQL_LESS = 428, /* LESS */
|
||||
SQL_GREATER = 429, /* GREATER */
|
||||
SQL_LESSEQ = 430, /* LESSEQ */
|
||||
SQL_GREATEREQ = 431, /* GREATEREQ */
|
||||
SQL_NOTNULL = 432, /* NOTNULL */
|
||||
SQL_UMINUS = 433 /* UMINUS */
|
||||
};
|
||||
typedef enum hsql_tokentype hsql_token_kind_t;
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user