mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-15 22:50:36 +02:00
latest changes from main repository
This commit is contained in:
parent
5caf218376
commit
4d80e24d44
@ -635,6 +635,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\include\Poco\MetaProgramming.h">
|
RelativePath=".\include\Poco\MetaProgramming.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\NamedTuple.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\Poco\NestedDiagnosticContext.h">
|
RelativePath=".\include\Poco\NestedDiagnosticContext.h">
|
||||||
</File>
|
</File>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ClassLibrary.h
|
// ClassLibrary.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/ClassLibrary.h#3 $
|
// $Id: //poco/Main/Foundation/include/Poco/ClassLibrary.h#4 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: SharedLibrary
|
// Package: SharedLibrary
|
||||||
@ -63,6 +63,16 @@ extern "C"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// additional support for named manifests
|
||||||
|
//
|
||||||
|
#define POCO_DECLARE_NAMED_MANIFEST(name) \
|
||||||
|
extern "C" \
|
||||||
|
{ \
|
||||||
|
void POCO_LIBRARY_API POCO_JOIN(pocoBuildManifest, name)(Poco::ManifestBase* pManifest); \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Macros to automatically implement pocoBuildManifest
|
// Macros to automatically implement pocoBuildManifest
|
||||||
//
|
//
|
||||||
@ -74,8 +84,8 @@ extern "C"
|
|||||||
// ...
|
// ...
|
||||||
// POCO_END_MANIFEST
|
// POCO_END_MANIFEST
|
||||||
//
|
//
|
||||||
#define POCO_BEGIN_MANIFEST(base) \
|
#define POCO_BEGIN_MANIFEST_IMPL(fnName, base) \
|
||||||
bool pocoBuildManifest(Poco::ManifestBase* pManifest_) \
|
bool fnName(Poco::ManifestBase* pManifest_) \
|
||||||
{ \
|
{ \
|
||||||
typedef base _Base; \
|
typedef base _Base; \
|
||||||
typedef Poco::Manifest<_Base> _Manifest; \
|
typedef Poco::Manifest<_Base> _Manifest; \
|
||||||
@ -86,6 +96,14 @@ extern "C"
|
|||||||
Poco::Manifest<_Base>* pManifest = static_cast<_Manifest*>(pManifest_);
|
Poco::Manifest<_Base>* pManifest = static_cast<_Manifest*>(pManifest_);
|
||||||
|
|
||||||
|
|
||||||
|
#define POCO_BEGIN_MANIFEST(base) \
|
||||||
|
POCO_BEGIN_MANIFEST_IMPL(pocoBuildManifest, base)
|
||||||
|
|
||||||
|
|
||||||
|
#define POCO_BEGIN_NAMED_MANIFEST(name, base) \
|
||||||
|
POCO_BEGIN_MANIFEST_IMPL(POCO_JOIN(pocoBuildManifest, name), base)
|
||||||
|
|
||||||
|
|
||||||
#define POCO_END_MANIFEST \
|
#define POCO_END_MANIFEST \
|
||||||
return true; \
|
return true; \
|
||||||
} \
|
} \
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ClassLoader.h
|
// ClassLoader.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/ClassLoader.h#2 $
|
// $Id: //poco/Main/Foundation/include/Poco/ClassLoader.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: SharedLibrary
|
// Package: SharedLibrary
|
||||||
@ -62,6 +62,15 @@ class ClassLoader
|
|||||||
/// The Manifest for a shared library can be easily built
|
/// The Manifest for a shared library can be easily built
|
||||||
/// with the help of the macros in the header file
|
/// with the help of the macros in the header file
|
||||||
/// "Foundation/ClassLibrary.h".
|
/// "Foundation/ClassLibrary.h".
|
||||||
|
///
|
||||||
|
/// Starting with POCO release 1.3, a class library can
|
||||||
|
/// export multiple manifests. In addition to the default
|
||||||
|
/// (unnamed) manifest, multiple named manifests can
|
||||||
|
/// be exported, each having a different base class.
|
||||||
|
///
|
||||||
|
/// There is one important restriction: one instance of
|
||||||
|
/// ClassLoader can only load one manifest from a class
|
||||||
|
/// library.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef AbstractMetaObject<Base> Meta;
|
typedef AbstractMetaObject<Base> Meta;
|
||||||
@ -152,9 +161,9 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadLibrary(const std::string& path)
|
void loadLibrary(const std::string& path, const std::string& manifest)
|
||||||
/// Loads a library from the given path. Does nothing
|
/// Loads a library from the given path, using the given manifest.
|
||||||
/// if the library is already loaded.
|
/// Does nothing if the library is already loaded.
|
||||||
/// Throws a LibraryLoadException if the library
|
/// Throws a LibraryLoadException if the library
|
||||||
/// cannot be loaded or does not have a Manifest.
|
/// cannot be loaded or does not have a Manifest.
|
||||||
/// If the library exports a function named "pocoInitializeLibrary",
|
/// If the library exports a function named "pocoInitializeLibrary",
|
||||||
@ -174,20 +183,22 @@ public:
|
|||||||
li.refCount = 1;
|
li.refCount = 1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
std::string pocoBuildManifestSymbol("pocoBuildManifest");
|
||||||
|
pocoBuildManifestSymbol.append(manifest);
|
||||||
if (li.pLibrary->hasSymbol("pocoInitializeLibrary"))
|
if (li.pLibrary->hasSymbol("pocoInitializeLibrary"))
|
||||||
{
|
{
|
||||||
InitializeLibraryFunc initializeLibrary = (InitializeLibraryFunc) li.pLibrary->getSymbol("pocoInitializeLibrary");
|
InitializeLibraryFunc initializeLibrary = (InitializeLibraryFunc) li.pLibrary->getSymbol("pocoInitializeLibrary");
|
||||||
initializeLibrary();
|
initializeLibrary();
|
||||||
}
|
}
|
||||||
if (li.pLibrary->hasSymbol("pocoBuildManifest"))
|
if (li.pLibrary->hasSymbol(pocoBuildManifestSymbol))
|
||||||
{
|
{
|
||||||
BuildManifestFunc buildManifest = (BuildManifestFunc) li.pLibrary->getSymbol("pocoBuildManifest");
|
BuildManifestFunc buildManifest = (BuildManifestFunc) li.pLibrary->getSymbol(pocoBuildManifestSymbol);
|
||||||
if (buildManifest(const_cast<Manif*>(li.pManifest)))
|
if (buildManifest(const_cast<Manif*>(li.pManifest)))
|
||||||
_map[path] = li;
|
_map[path] = li;
|
||||||
else
|
else
|
||||||
throw LibraryLoadException(std::string("Manifest class mismatch in ") + path);
|
throw LibraryLoadException(std::string("Manifest class mismatch in ") + path, manifest);
|
||||||
}
|
}
|
||||||
else throw LibraryLoadException(std::string("No manifest in ") + path);
|
else throw LibraryLoadException(std::string("No manifest in ") + path, manifest);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -202,6 +213,22 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadLibrary(const std::string& path)
|
||||||
|
/// Loads a library from the given path. Does nothing
|
||||||
|
/// if the library is already loaded.
|
||||||
|
/// Throws a LibraryLoadException if the library
|
||||||
|
/// cannot be loaded or does not have a Manifest.
|
||||||
|
/// If the library exports a function named "pocoInitializeLibrary",
|
||||||
|
/// this function is executed.
|
||||||
|
/// If called multiple times for the same library,
|
||||||
|
/// the number of calls to unloadLibrary() must be the same
|
||||||
|
/// for the library to become unloaded.
|
||||||
|
///
|
||||||
|
/// Equivalent to loadLibrary(path, "").
|
||||||
|
{
|
||||||
|
loadLibrary(path, "");
|
||||||
|
}
|
||||||
|
|
||||||
void unloadLibrary(const std::string& path)
|
void unloadLibrary(const std::string& path)
|
||||||
/// Unloads the given library.
|
/// Unloads the given library.
|
||||||
/// Be extremely cautious when unloading shared libraries.
|
/// Be extremely cautious when unloading shared libraries.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// DynamicAny.h
|
// DynamicAny.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAny.h#6 $
|
// $Id: //poco/Main/Foundation/include/Poco/DynamicAny.h#8 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
@ -175,17 +175,34 @@ public:
|
|||||||
bool operator == (const T& other)
|
bool operator == (const T& other)
|
||||||
/// Equality operator
|
/// Equality operator
|
||||||
{
|
{
|
||||||
T result;
|
T value;
|
||||||
_pHolder->convert(result);
|
_pHolder->convert(value);
|
||||||
return result == other;
|
return value == other;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (const char* other)
|
bool operator == (const char* other)
|
||||||
/// Equality operator
|
/// Equality operator
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string value;
|
||||||
_pHolder->convert(result);
|
_pHolder->convert(value);
|
||||||
return result == other;
|
return value == other;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool operator != (const T& other)
|
||||||
|
/// Inequality operator
|
||||||
|
{
|
||||||
|
T value;
|
||||||
|
_pHolder->convert(value);
|
||||||
|
return value != other;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator != (const char* other)
|
||||||
|
/// Inequality operator
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
_pHolder->convert(value);
|
||||||
|
return value != other;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::type_info& type() const;
|
const std::type_info& type() const;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// DynamicAnyHolder.h
|
// DynamicAnyHolder.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAnyHolder.h#6 $
|
// $Id: //poco/Main/Foundation/include/Poco/DynamicAnyHolder.h#7 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Foundation.h
|
// Foundation.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/Foundation.h#7 $
|
// $Id: //poco/Main/Foundation/include/Poco/Foundation.h#8 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
@ -102,8 +102,8 @@
|
|||||||
// is that macro expansion of macro arguments does not
|
// is that macro expansion of macro arguments does not
|
||||||
// occur in POCO_DO_JOIN2 but does in POCO_DO_JOIN.
|
// occur in POCO_DO_JOIN2 but does in POCO_DO_JOIN.
|
||||||
//
|
//
|
||||||
#define POCO_JOIN(X, Y) POCO_DO_JOIN( X, Y )
|
#define POCO_JOIN(X, Y) POCO_DO_JOIN(X, Y)
|
||||||
#define POCO_DO_JOIN(X, Y) POCO_DO_JOIN2(X,Y)
|
#define POCO_DO_JOIN(X, Y) POCO_DO_JOIN2(X, Y)
|
||||||
#define POCO_DO_JOIN2(X, Y) X##Y
|
#define POCO_DO_JOIN2(X, Y) X##Y
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// NamedTuple.h
|
// NamedTuple.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/NamedTuple.h#6 $
|
// $Id: //poco/Main/Foundation/include/Poco/NamedTuple.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
@ -9,7 +9,7 @@
|
|||||||
//
|
//
|
||||||
// Definition of the NamedTuple class.
|
// Definition of the NamedTuple class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person or organization
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Platform_WIN32.h
|
// Platform_WIN32.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/Platform_WIN32.h#3 $
|
// $Id: //poco/Main/Foundation/include/Poco/Platform_WIN32.h#4 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
@ -69,9 +69,6 @@
|
|||||||
#if defined(UNICODE) && !defined(POCO_WIN32_UTF8)
|
#if defined(UNICODE) && !defined(POCO_WIN32_UTF8)
|
||||||
#define POCO_WIN32_UTF8
|
#define POCO_WIN32_UTF8
|
||||||
#endif
|
#endif
|
||||||
#if defined(POCO_WIN32_UTF8) && !defined(UNICODE)
|
|
||||||
#define UNICODE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// Turn off some annoying warnings
|
// Turn off some annoying warnings
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// RegularExpression.h
|
// RegularExpression.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/RegularExpression.h#4 $
|
// $Id: //poco/Main/Foundation/include/Poco/RegularExpression.h#5 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: RegExp
|
// Package: RegExp
|
||||||
@ -77,9 +77,9 @@ public:
|
|||||||
/// some can be passed only to matching functions, and some can be used
|
/// some can be passed only to matching functions, and some can be used
|
||||||
/// everywhere.
|
/// everywhere.
|
||||||
///
|
///
|
||||||
/// * Options marked [ctor] can be passed to the constructor.
|
/// * Options marked [ctor] can be passed to the constructor.
|
||||||
/// * Options marked [match] can be passed to match, extract, split and subst.
|
/// * Options marked [match] can be passed to match, extract, split and subst.
|
||||||
/// * Options marked [subst] can be passed to subst.
|
/// * Options marked [subst] can be passed to subst.
|
||||||
///
|
///
|
||||||
/// See the PCRE documentation for more information.
|
/// See the PCRE documentation for more information.
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Environment_WIN32U.cpp
|
// Environment_WIN32U.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/src/Environment_WIN32U.cpp#6 $
|
// $Id: //poco/Main/Foundation/src/Environment_WIN32U.cpp#7 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
@ -105,9 +105,9 @@ std::string EnvironmentImpl::osNameImpl()
|
|||||||
|
|
||||||
std::string EnvironmentImpl::osVersionImpl()
|
std::string EnvironmentImpl::osVersionImpl()
|
||||||
{
|
{
|
||||||
OSVERSIONINFO vi;
|
OSVERSIONINFOW vi;
|
||||||
vi.dwOSVersionInfoSize = sizeof(vi);
|
vi.dwOSVersionInfoSize = sizeof(vi);
|
||||||
if (GetVersionEx(&vi) == 0) throw SystemException("Cannot get OS version information");
|
if (GetVersionExW(&vi) == 0) throw SystemException("Cannot get OS version information");
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << vi.dwMajorVersion << "." << vi.dwMinorVersion << " (Build " << (vi.dwBuildNumber & 0xFFFF);
|
str << vi.dwMajorVersion << "." << vi.dwMinorVersion << " (Build " << (vi.dwBuildNumber & 0xFFFF);
|
||||||
std::string version;
|
std::string version;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// pocomsg.mc[.h]
|
// pocomsg.mc[.h]
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/src/pocomsg.h#20 $
|
// $Id: //poco/Main/Foundation/src/pocomsg.mc#7 $
|
||||||
//
|
//
|
||||||
// The Poco message source/header file.
|
// The Poco message source/header file.
|
||||||
//
|
//
|
||||||
|
@ -289,6 +289,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\src\MemoryPoolTest.cpp">
|
RelativePath=".\src\MemoryPoolTest.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\NamedTuplesTest.cpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\NDCTest.cpp">
|
RelativePath=".\src\NDCTest.cpp">
|
||||||
</File>
|
</File>
|
||||||
@ -353,6 +356,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\src\MemoryPoolTest.h">
|
RelativePath=".\src\MemoryPoolTest.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\NamedTuplesTest.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\NDCTest.h">
|
RelativePath=".\src\NDCTest.h">
|
||||||
</File>
|
</File>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// CoreTestSuite.cpp
|
// CoreTestSuite.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/CoreTestSuite.cpp#20 $
|
// $Id: //poco/Main/Foundation/testsuite/src/CoreTestSuite.cpp#21 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// DynamicAnyTest.cpp
|
// DynamicAnyTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.cpp#6 $
|
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.cpp#7 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// NamedTuplesTest.cpp
|
// NamedTuplesTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/NamedTuplesTest.cpp#4 $
|
// $Id: //poco/Main/Foundation/testsuite/src/NamedTuplesTest.cpp#1 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// NamedTuplesTest.h
|
// NamedTuplesTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/NamedTuplesTest.h#4 $
|
// $Id: //poco/Main/Foundation/testsuite/src/NamedTuplesTest.h#1 $
|
||||||
//
|
//
|
||||||
// Definition of the NamedTuplesTest class.
|
// Definition of the NamedTuplesTest class.
|
||||||
//
|
//
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPSClientSession.h
|
// HTTPSClientSession.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/HTTPSClientSession.h#6 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/HTTPSClientSession.h#7 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: HTTPSClient
|
// Package: HTTPSClient
|
||||||
@ -92,28 +92,7 @@ public:
|
|||||||
~HTTPSClientSession();
|
~HTTPSClientSession();
|
||||||
/// Destroys the HTTPSClientSession and closes
|
/// Destroys the HTTPSClientSession and closes
|
||||||
/// the underlying socket.
|
/// the underlying socket.
|
||||||
|
|
||||||
std::ostream& sendRequest(HTTPRequest& request);
|
|
||||||
/// Sends the header for the given HTTPS request to
|
|
||||||
/// the server.
|
|
||||||
///
|
|
||||||
/// The HTTPSClientSession will set the request's
|
|
||||||
/// Host and Keep-Alive headers accordingly.
|
|
||||||
///
|
|
||||||
/// The returned output stream can be used to write
|
|
||||||
/// the request body. The stream is valid until
|
|
||||||
/// receiveResponse() is called or the session
|
|
||||||
/// is destroyed.
|
|
||||||
|
|
||||||
std::istream& receiveResponse(HTTPResponse& response);
|
|
||||||
/// Receives the header for the response to the previous
|
|
||||||
/// HTTPS request.
|
|
||||||
///
|
|
||||||
/// The returned input stream can be used to read
|
|
||||||
/// the response body. The stream is valid until
|
|
||||||
/// sendRequest() is called or the session is
|
|
||||||
/// destroyed.
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void connect(const SocketAddress& address);
|
void connect(const SocketAddress& address);
|
||||||
// Connects the socket to the server.
|
// Connects the socket to the server.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPSClientSession.cpp
|
// HTTPSClientSession.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/HTTPSClientSession.cpp#11 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/src/HTTPSClientSession.cpp#12 $
|
||||||
//
|
//
|
||||||
// Library: NetSSL_OpenSSL
|
// Library: NetSSL_OpenSSL
|
||||||
// Package: HTTPSClient
|
// Package: HTTPSClient
|
||||||
@ -82,74 +82,6 @@ HTTPSClientSession::~HTTPSClientSession()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream& HTTPSClientSession::sendRequest(HTTPRequest& request)
|
|
||||||
{
|
|
||||||
deleteResponseStream();
|
|
||||||
|
|
||||||
bool keepAlive = getKeepAlive();
|
|
||||||
if (connected() && !keepAlive)
|
|
||||||
close();
|
|
||||||
if (!connected())
|
|
||||||
reconnect();
|
|
||||||
if (!keepAlive)
|
|
||||||
request.setKeepAlive(false);
|
|
||||||
request.setHost(getHost(), getPort());
|
|
||||||
|
|
||||||
{
|
|
||||||
HTTPHeaderOutputStream hos(*this);
|
|
||||||
setReconnect(keepAlive);
|
|
||||||
request.write(hos);
|
|
||||||
setReconnect(false);
|
|
||||||
setExpectResponseBody(request.getMethod() != HTTPRequest::HTTP_HEAD);
|
|
||||||
}
|
|
||||||
if (request.getChunkedTransferEncoding())
|
|
||||||
setRequestStream(new HTTPChunkedOutputStream(*this));
|
|
||||||
else if (request.getContentLength() != HTTPMessage::UNKNOWN_CONTENT_LENGTH)
|
|
||||||
setRequestStream(new HTTPFixedLengthOutputStream(*this, request.getContentLength()));
|
|
||||||
else if (request.getMethod() == HTTPRequest::HTTP_GET || request.getMethod() == HTTPRequest::HTTP_HEAD)
|
|
||||||
setRequestStream(new HTTPFixedLengthOutputStream(*this, 0));
|
|
||||||
else
|
|
||||||
setRequestStream(new HTTPOutputStream(*this));
|
|
||||||
|
|
||||||
return *getRequestStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::istream& HTTPSClientSession::receiveResponse(HTTPResponse& response)
|
|
||||||
{
|
|
||||||
deleteRequestStream();
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
response.clear();
|
|
||||||
HTTPHeaderInputStream his(*this);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
response.read(his);
|
|
||||||
}
|
|
||||||
catch (MessageException&)
|
|
||||||
{
|
|
||||||
if (networkException())
|
|
||||||
networkException()->rethrow();
|
|
||||||
else
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (response.getStatus() == HTTPResponse::HTTP_CONTINUE);
|
|
||||||
|
|
||||||
if (!getExpectResponseBody())
|
|
||||||
setResponseStream(new HTTPFixedLengthInputStream(*this, 0));
|
|
||||||
else if (response.getChunkedTransferEncoding())
|
|
||||||
setResponseStream(new HTTPChunkedInputStream(*this));
|
|
||||||
else if (response.getContentLength() != HTTPMessage::UNKNOWN_CONTENT_LENGTH)
|
|
||||||
setResponseStream(new HTTPFixedLengthInputStream(*this, response.getContentLength()));
|
|
||||||
else
|
|
||||||
setResponseStream(new HTTPInputStream(*this));
|
|
||||||
|
|
||||||
return *getResponseStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string HTTPSClientSession::getHostInfo() const
|
std::string HTTPSClientSession::getHostInfo() const
|
||||||
{
|
{
|
||||||
std::string result("https://");
|
std::string result("https://");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPSClientSessionTest.cpp
|
// HTTPSClientSessionTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.cpp#7 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.cpp#8 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@ -35,7 +35,13 @@
|
|||||||
#include "CppUnit/TestSuite.h"
|
#include "CppUnit/TestSuite.h"
|
||||||
#include "Poco/Net/HTTPSClientSession.h"
|
#include "Poco/Net/HTTPSClientSession.h"
|
||||||
#include "Poco/Net/HTTPRequest.h"
|
#include "Poco/Net/HTTPRequest.h"
|
||||||
|
#include "Poco/Net/HTTPRequestHandler.h"
|
||||||
|
#include "Poco/Net/HTTPRequestHandlerFactory.h"
|
||||||
#include "Poco/Net/HTTPResponse.h"
|
#include "Poco/Net/HTTPResponse.h"
|
||||||
|
#include "Poco/Net/HTTPServer.h"
|
||||||
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
#include "Poco/Net/HTTPServerRequest.h"
|
||||||
|
#include "Poco/Net/HTTPServerParams.h"
|
||||||
#include "Poco/StreamCopier.h"
|
#include "Poco/StreamCopier.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include "HTTPSTestServer.h"
|
#include "HTTPSTestServer.h"
|
||||||
@ -44,13 +50,45 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
using Poco::Net::HTTPSClientSession;
|
using namespace Poco::Net;
|
||||||
using Poco::Net::HTTPRequest;
|
|
||||||
using Poco::Net::HTTPResponse;
|
|
||||||
using Poco::Net::HTTPMessage;
|
|
||||||
using Poco::StreamCopier;
|
using Poco::StreamCopier;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TestRequestHandler: public HTTPRequestHandler
|
||||||
|
/// Return a HTML document with the current date and time.
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TestRequestHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
|
||||||
|
{
|
||||||
|
response.setChunkedTransferEncoding(true);
|
||||||
|
response.setContentType(request.getContentType());
|
||||||
|
std::ostream& ostr = response.send();
|
||||||
|
Poco::StreamCopier::copyStream(request.stream(), ostr);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TestRequestHandlerFactory: public HTTPRequestHandlerFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TestRequestHandlerFactory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request)
|
||||||
|
{
|
||||||
|
return new TestRequestHandler();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
HTTPSClientSessionTest::HTTPSClientSessionTest(const std::string& name): CppUnit::TestCase(name)
|
HTTPSClientSessionTest::HTTPSClientSessionTest(const std::string& name): CppUnit::TestCase(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -179,6 +217,39 @@ void HTTPSClientSessionTest::testPostLargeChunked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HTTPSClientSessionTest::testPostLargeChunkedKeepAlive()
|
||||||
|
{
|
||||||
|
SecureServerSocket svs(32322);
|
||||||
|
HTTPServer srv(new TestRequestHandlerFactory(), svs, new HTTPServerParams());
|
||||||
|
srv.start();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HTTPSClientSession s("localhost", srv.port());
|
||||||
|
s.setKeepAlive(true);
|
||||||
|
for (int i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
HTTPRequest request(HTTPRequest::HTTP_POST, "/keepAlive", HTTPMessage::HTTP_1_1);
|
||||||
|
std::string body(16000, 'x');
|
||||||
|
request.setChunkedTransferEncoding(true);
|
||||||
|
s.sendRequest(request) << body;
|
||||||
|
HTTPResponse response;
|
||||||
|
std::istream& rs = s.receiveResponse(response);
|
||||||
|
assert (response.getChunkedTransferEncoding());
|
||||||
|
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
|
||||||
|
std::ostringstream ostr;
|
||||||
|
StreamCopier::copyStream(rs, ostr);
|
||||||
|
assert (ostr.str() == body);
|
||||||
|
}
|
||||||
|
srv.stop();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
srv.stop();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void HTTPSClientSessionTest::testPostSmallClose()
|
void HTTPSClientSessionTest::testPostSmallClose()
|
||||||
{
|
{
|
||||||
HTTPSTestServer srv;
|
HTTPSTestServer srv;
|
||||||
@ -297,6 +368,7 @@ CppUnit::Test* HTTPSClientSessionTest::suite()
|
|||||||
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeIdentity);
|
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeIdentity);
|
||||||
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostSmallChunked);
|
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostSmallChunked);
|
||||||
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeChunked);
|
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeChunked);
|
||||||
|
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeChunkedKeepAlive);
|
||||||
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostSmallClose);
|
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostSmallClose);
|
||||||
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeClose);
|
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testPostLargeClose);
|
||||||
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testKeepAlive);
|
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testKeepAlive);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPSClientSessionTest.h
|
// HTTPSClientSessionTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.h#7 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.h#8 $
|
||||||
//
|
//
|
||||||
// Definition of the HTTPSClientSessionTest class.
|
// Definition of the HTTPSClientSessionTest class.
|
||||||
//
|
//
|
||||||
@ -53,6 +53,7 @@ public:
|
|||||||
void testPostLargeIdentity();
|
void testPostLargeIdentity();
|
||||||
void testPostSmallChunked();
|
void testPostSmallChunked();
|
||||||
void testPostLargeChunked();
|
void testPostLargeChunked();
|
||||||
|
void testPostLargeChunkedKeepAlive();
|
||||||
void testPostSmallClose();
|
void testPostSmallClose();
|
||||||
void testPostLargeClose();
|
void testPostLargeClose();
|
||||||
void testKeepAlive();
|
void testKeepAlive();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPSTestServer.cpp
|
// HTTPSTestServer.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSTestServer.cpp#8 $
|
// $Id: //poco/Main/NetSSL_OpenSSL/testsuite/src/HTTPSTestServer.cpp#9 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@ -173,7 +173,10 @@ std::string HTTPSTestServer::handleRequest() const
|
|||||||
{
|
{
|
||||||
response.append("Transfer-Encoding: chunked\r\n");
|
response.append("Transfer-Encoding: chunked\r\n");
|
||||||
}
|
}
|
||||||
response.append("Connection: Close\r\n");
|
if (_lastRequest.substr(0,15) == "POST /keepAlive")
|
||||||
|
response.append("Connection: keep-alive\r\n");
|
||||||
|
else
|
||||||
|
response.append("Connection: Close\r\n");
|
||||||
response.append("\r\n");
|
response.append("\r\n");
|
||||||
response.append(body);
|
response.append(body);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ServerApplication.h
|
// ServerApplication.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Util/include/Poco/Util/ServerApplication.h#4 $
|
// $Id: //poco/Main/Util/include/Poco/Util/ServerApplication.h#5 $
|
||||||
//
|
//
|
||||||
// Library: Util
|
// Library: Util
|
||||||
// Package: Application
|
// Package: Application
|
||||||
@ -170,7 +170,11 @@ private:
|
|||||||
};
|
};
|
||||||
static BOOL __stdcall ConsoleCtrlHandler(DWORD ctrlType);
|
static BOOL __stdcall ConsoleCtrlHandler(DWORD ctrlType);
|
||||||
static void __stdcall ServiceControlHandler(DWORD control);
|
static void __stdcall ServiceControlHandler(DWORD control);
|
||||||
|
#if defined(POCO_WIN32_UTF8)
|
||||||
|
static void __stdcall ServiceMain(DWORD argc, LPWSTR* argv);
|
||||||
|
#else
|
||||||
static void __stdcall ServiceMain(DWORD argc, LPTSTR* argv);
|
static void __stdcall ServiceMain(DWORD argc, LPTSTR* argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool hasConsole();
|
bool hasConsole();
|
||||||
bool isService();
|
bool isService();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// WinService.h
|
// WinService.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Util/include/Poco/Util/WinService.h#2 $
|
// $Id: //poco/Main/Util/include/Poco/Util/WinService.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Util
|
// Library: Util
|
||||||
// Package: Windows
|
// Package: Windows
|
||||||
@ -44,6 +44,13 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(POCO_WIN32_UTF8)
|
||||||
|
#define POCO_LPQUERY_SERVICE_CONFIG LPQUERY_SERVICE_CONFIGW
|
||||||
|
#else
|
||||||
|
#define POCO_LPQUERY_SERVICE_CONFIG LPQUERY_SERVICE_CONFIGA
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Util {
|
namespace Util {
|
||||||
|
|
||||||
@ -128,8 +135,8 @@ private:
|
|||||||
void open() const;
|
void open() const;
|
||||||
bool tryOpen() const;
|
bool tryOpen() const;
|
||||||
void close() const;
|
void close() const;
|
||||||
LPQUERY_SERVICE_CONFIG config() const;
|
POCO_LPQUERY_SERVICE_CONFIG config() const;
|
||||||
|
|
||||||
WinService();
|
WinService();
|
||||||
WinService(const WinService&);
|
WinService(const WinService&);
|
||||||
WinService& operator = (const WinService&);
|
WinService& operator = (const WinService&);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ServerApplication.cpp
|
// ServerApplication.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Util/src/ServerApplication.cpp#19 $
|
// $Id: //poco/Main/Util/src/ServerApplication.cpp#20 $
|
||||||
//
|
//
|
||||||
// Library: Util
|
// Library: Util
|
||||||
// Package: Application
|
// Package: Application
|
||||||
@ -146,7 +146,11 @@ void ServerApplication::ServiceControlHandler(DWORD control)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(POCO_WIN32_UTF8)
|
||||||
|
void ServerApplication::ServiceMain(DWORD argc, LPWSTR* argv)
|
||||||
|
#else
|
||||||
void ServerApplication::ServiceMain(DWORD argc, LPTSTR* argv)
|
void ServerApplication::ServiceMain(DWORD argc, LPTSTR* argv)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ServerApplication& app = static_cast<ServerApplication&>(Application::instance());
|
ServerApplication& app = static_cast<ServerApplication&>(Application::instance());
|
||||||
|
|
||||||
@ -302,17 +306,21 @@ int ServerApplication::run(int argc, wchar_t** argv)
|
|||||||
|
|
||||||
bool ServerApplication::isService()
|
bool ServerApplication::isService()
|
||||||
{
|
{
|
||||||
SERVICE_TABLE_ENTRY svcDispatchTable[2];
|
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
|
SERVICE_TABLE_ENTRYW svcDispatchTable[2];
|
||||||
svcDispatchTable[0].lpServiceName = L"";
|
svcDispatchTable[0].lpServiceName = L"";
|
||||||
#else
|
|
||||||
svcDispatchTable[0].lpServiceName = "";
|
|
||||||
#endif
|
|
||||||
svcDispatchTable[0].lpServiceProc = ServiceMain;
|
svcDispatchTable[0].lpServiceProc = ServiceMain;
|
||||||
svcDispatchTable[1].lpServiceName = NULL;
|
svcDispatchTable[1].lpServiceName = NULL;
|
||||||
svcDispatchTable[1].lpServiceProc = NULL;
|
svcDispatchTable[1].lpServiceProc = NULL;
|
||||||
|
return StartServiceCtrlDispatcherW(svcDispatchTable) != 0;
|
||||||
|
#else
|
||||||
|
SERVICE_TABLE_ENTRY svcDispatchTable[2];
|
||||||
|
svcDispatchTable[0].lpServiceName = "";
|
||||||
|
svcDispatchTable[0].lpServiceProc = ServiceMain;
|
||||||
|
svcDispatchTable[1].lpServiceName = NULL;
|
||||||
|
svcDispatchTable[1].lpServiceProc = NULL;
|
||||||
return StartServiceCtrlDispatcher(svcDispatchTable) != 0;
|
return StartServiceCtrlDispatcher(svcDispatchTable) != 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// WinRegistryKey.cpp
|
// WinRegistryKey.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Util/src/WinRegistryKey.cpp#11 $
|
// $Id: //poco/Main/Util/src/WinRegistryKey.cpp#12 $
|
||||||
//
|
//
|
||||||
// Library: Util
|
// Library: Util
|
||||||
// Package: Windows
|
// Package: Windows
|
||||||
@ -159,7 +159,7 @@ std::string WinRegistryKey::getStringExpand(const std::string& name)
|
|||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
std::wstring uname;
|
std::wstring uname;
|
||||||
Poco::UnicodeConverter::toUTF16(name, uname);
|
Poco::UnicodeConverter::toUTF16(name, uname);
|
||||||
if (RegQueryValueEx(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ)
|
if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ)
|
||||||
throw NotFoundException(key(name));
|
throw NotFoundException(key(name));
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
@ -168,7 +168,7 @@ std::string WinRegistryKey::getStringExpand(const std::string& name)
|
|||||||
RegQueryValueExW(_hKey, uname.c_str(), NULL, NULL, (BYTE*) buffer, &size);
|
RegQueryValueExW(_hKey, uname.c_str(), NULL, NULL, (BYTE*) buffer, &size);
|
||||||
buffer[len] = 0;
|
buffer[len] = 0;
|
||||||
wchar_t temp;
|
wchar_t temp;
|
||||||
DWORD expSize = ExpandEnvironmentStrings(buffer, &temp, 1);
|
DWORD expSize = ExpandEnvironmentStringsW(buffer, &temp, 1);
|
||||||
wchar_t* expBuffer = new wchar_t[expSize];
|
wchar_t* expBuffer = new wchar_t[expSize];
|
||||||
ExpandEnvironmentStringsW(buffer, expBuffer, expSize);
|
ExpandEnvironmentStringsW(buffer, expBuffer, expSize);
|
||||||
std::string result;
|
std::string result;
|
||||||
@ -320,7 +320,7 @@ void WinRegistryKey::open()
|
|||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
std::wstring usubKey;
|
std::wstring usubKey;
|
||||||
Poco::UnicodeConverter::toUTF16(_subKey, usubKey);
|
Poco::UnicodeConverter::toUTF16(_subKey, usubKey);
|
||||||
if (RegCreateKeyEx(_hRootKey, usubKey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &_hKey, NULL) != ERROR_SUCCESS)
|
if (RegCreateKeyExW(_hRootKey, usubKey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &_hKey, NULL) != ERROR_SUCCESS)
|
||||||
throw SystemException("Cannot open registry key: ", key());
|
throw SystemException("Cannot open registry key: ", key());
|
||||||
#else
|
#else
|
||||||
if (RegCreateKeyEx(_hRootKey, _subKey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &_hKey, NULL) != ERROR_SUCCESS)
|
if (RegCreateKeyEx(_hRootKey, _subKey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &_hKey, NULL) != ERROR_SUCCESS)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// WinService.cpp
|
// WinService.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Util/src/WinService.cpp#9 $
|
// $Id: //poco/Main/Util/src/WinService.cpp#10 $
|
||||||
//
|
//
|
||||||
// Library: Util
|
// Library: Util
|
||||||
// Package: Windows
|
// Package: Windows
|
||||||
@ -79,7 +79,7 @@ const std::string& WinService::name() const
|
|||||||
|
|
||||||
std::string WinService::displayName() const
|
std::string WinService::displayName() const
|
||||||
{
|
{
|
||||||
LPQUERY_SERVICE_CONFIG pSvcConfig = config();
|
POCO_LPQUERY_SERVICE_CONFIG pSvcConfig = config();
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
std::wstring udispName(pSvcConfig->lpDisplayName);
|
std::wstring udispName(pSvcConfig->lpDisplayName);
|
||||||
std::string dispName;
|
std::string dispName;
|
||||||
@ -94,7 +94,7 @@ std::string WinService::displayName() const
|
|||||||
|
|
||||||
std::string WinService::path() const
|
std::string WinService::path() const
|
||||||
{
|
{
|
||||||
LPQUERY_SERVICE_CONFIG pSvcConfig = config();
|
POCO_LPQUERY_SERVICE_CONFIG pSvcConfig = config();
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
std::wstring upath(pSvcConfig->lpBinaryPathName);
|
std::wstring upath(pSvcConfig->lpBinaryPathName);
|
||||||
std::string path;
|
std::string path;
|
||||||
@ -117,7 +117,7 @@ void WinService::registerService(const std::string& path, const std::string& dis
|
|||||||
Poco::UnicodeConverter::toUTF16(displayName, udisplayName);
|
Poco::UnicodeConverter::toUTF16(displayName, udisplayName);
|
||||||
std::wstring upath;
|
std::wstring upath;
|
||||||
Poco::UnicodeConverter::toUTF16(path, upath);
|
Poco::UnicodeConverter::toUTF16(path, upath);
|
||||||
_svcHandle = CreateService(
|
_svcHandle = CreateServiceW(
|
||||||
_scmHandle,
|
_scmHandle,
|
||||||
uname.c_str(),
|
uname.c_str(),
|
||||||
udisplayName.c_str(),
|
udisplayName.c_str(),
|
||||||
@ -232,7 +232,7 @@ void WinService::setStartup(WinService::Startup startup)
|
|||||||
|
|
||||||
WinService::Startup WinService::getStartup() const
|
WinService::Startup WinService::getStartup() const
|
||||||
{
|
{
|
||||||
LPQUERY_SERVICE_CONFIG pSvcConfig = config();
|
POCO_LPQUERY_SERVICE_CONFIG pSvcConfig = config();
|
||||||
Startup result;
|
Startup result;
|
||||||
switch (pSvcConfig->dwStartType)
|
switch (pSvcConfig->dwStartType)
|
||||||
{
|
{
|
||||||
@ -268,7 +268,7 @@ bool WinService::tryOpen() const
|
|||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
std::wstring uname;
|
std::wstring uname;
|
||||||
Poco::UnicodeConverter::toUTF16(_name, uname);
|
Poco::UnicodeConverter::toUTF16(_name, uname);
|
||||||
_svcHandle = OpenService(_scmHandle, uname.c_str(), SERVICE_ALL_ACCESS);
|
_svcHandle = OpenServiceW(_scmHandle, uname.c_str(), SERVICE_ALL_ACCESS);
|
||||||
#else
|
#else
|
||||||
_svcHandle = OpenService(_scmHandle, _name.c_str(), SERVICE_ALL_ACCESS);
|
_svcHandle = OpenService(_scmHandle, _name.c_str(), SERVICE_ALL_ACCESS);
|
||||||
#endif
|
#endif
|
||||||
@ -285,22 +285,26 @@ void WinService::close() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LPQUERY_SERVICE_CONFIG WinService::config() const
|
POCO_LPQUERY_SERVICE_CONFIG WinService::config() const
|
||||||
{
|
{
|
||||||
open();
|
open();
|
||||||
int size = 4096;
|
int size = 4096;
|
||||||
DWORD bytesNeeded;
|
DWORD bytesNeeded;
|
||||||
LPQUERY_SERVICE_CONFIG pSvcConfig = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, size);
|
POCO_LPQUERY_SERVICE_CONFIG pSvcConfig = (POCO_LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, size);
|
||||||
if (!pSvcConfig) throw OutOfMemoryException("cannot allocate service config buffer");
|
if (!pSvcConfig) throw OutOfMemoryException("cannot allocate service config buffer");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if defined(POCO_WIN32_UTF8)
|
||||||
|
while (!QueryServiceConfigW(_svcHandle, pSvcConfig, size, &bytesNeeded))
|
||||||
|
#else
|
||||||
while (!QueryServiceConfig(_svcHandle, pSvcConfig, size, &bytesNeeded))
|
while (!QueryServiceConfig(_svcHandle, pSvcConfig, size, &bytesNeeded))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
LocalFree(pSvcConfig);
|
LocalFree(pSvcConfig);
|
||||||
size = bytesNeeded;
|
size = bytesNeeded;
|
||||||
pSvcConfig = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, size);
|
pSvcConfig = (POCO_LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, size);
|
||||||
}
|
}
|
||||||
else throw SystemException("cannot query service configuration", _name);
|
else throw SystemException("cannot query service configuration", _name);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ElementsByTagNameList.h
|
// ElementsByTagNameList.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/XML/include/Poco/DOM/ElementsByTagNameList.h#2 $
|
// $Id: //poco/Main/XML/include/Poco/DOM/ElementsByTagNameList.h#4 $
|
||||||
//
|
//
|
||||||
// Library: XML
|
// Library: XML
|
||||||
// Package: DOM
|
// Package: DOM
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ElementsByTagNameList.cpp
|
// ElementsByTagNameList.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/XML/src/ElementsByTagNameList.cpp#10 $
|
// $Id: //poco/Main/XML/src/ElementsByTagNameList.cpp#11 $
|
||||||
//
|
//
|
||||||
// Library: XML
|
// Library: XML
|
||||||
// Package: DOM
|
// Package: DOM
|
||||||
@ -37,6 +37,7 @@
|
|||||||
#include "Poco/DOM/ElementsByTagNameList.h"
|
#include "Poco/DOM/ElementsByTagNameList.h"
|
||||||
#include "Poco/DOM/Node.h"
|
#include "Poco/DOM/Node.h"
|
||||||
#include "Poco/DOM/Document.h"
|
#include "Poco/DOM/Document.h"
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user