mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Remove Windows
This commit is contained in:
parent
ac14941b84
commit
3f99daf86d
@ -66,15 +66,6 @@ enum RSAPaddingMode
|
||||
// Crypto_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32)
|
||||
# if defined(POCO_DLL)
|
||||
# if defined(Crypto_EXPORTS)
|
||||
# define Crypto_API __declspec(dllexport)
|
||||
# else
|
||||
# define Crypto_API __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(Crypto_API)
|
||||
|
@ -22,18 +22,6 @@
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x0907000L
|
||||
#include <openssl/conf.h>
|
||||
#endif
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#define POCO_STR_HELPER(x) #x
|
||||
#define POCO_STR(x) POCO_STR_HELPER(x)
|
||||
#if defined POCO_INTERNAL_OPENSSL_MSVC_VER
|
||||
#define POCO_INTERNAL_OPENSSL_BUILD \
|
||||
" (POCO internal build, MSVC version " \
|
||||
POCO_STR(POCO_INTERNAL_OPENSSL_MSVC_VER) ")"
|
||||
#else
|
||||
#define POCO_INTERNAL_OPENSSL_BUILD ""
|
||||
#endif
|
||||
#pragma message (OPENSSL_VERSION_TEXT POCO_INTERNAL_OPENSSL_BUILD)
|
||||
#endif
|
||||
|
||||
|
||||
using Poco::RandomInputStream;
|
||||
@ -88,7 +76,6 @@ void OpenSSLInitializer::initialize()
|
||||
int nMutexes = CRYPTO_num_locks();
|
||||
_mutexes = new Poco::FastMutex[nMutexes];
|
||||
CRYPTO_set_locking_callback(&OpenSSLInitializer::lock);
|
||||
#ifndef POCO_OS_FAMILY_WINDOWS
|
||||
// Not needed on Windows (see SF #110: random unhandled exceptions when linking with ssl).
|
||||
// https://sourceforge.net/p/poco/bugs/110/
|
||||
//
|
||||
@ -97,7 +84,6 @@ void OpenSSLInitializer::initialize()
|
||||
// then a default implementation is used - on Windows and BeOS this uses the system's
|
||||
// default thread identifying APIs"
|
||||
CRYPTO_set_id_callback(&OpenSSLInitializer::id);
|
||||
#endif
|
||||
CRYPTO_set_dynlock_create_callback(&OpenSSLInitializer::dynlockCreate);
|
||||
CRYPTO_set_dynlock_lock_callback(&OpenSSLInitializer::dynlock);
|
||||
CRYPTO_set_dynlock_destroy_callback(&OpenSSLInitializer::dynlockDestroy);
|
||||
@ -112,9 +98,7 @@ void OpenSSLInitializer::uninitialize()
|
||||
EVP_cleanup();
|
||||
ERR_free_strings();
|
||||
CRYPTO_set_locking_callback(0);
|
||||
#ifndef POCO_OS_FAMILY_WINDOWS
|
||||
CRYPTO_set_id_callback(0);
|
||||
#endif
|
||||
delete [] _mutexes;
|
||||
|
||||
CONF_modules_free();
|
||||
|
@ -20,10 +20,6 @@
|
||||
#include "Poco/Format.h"
|
||||
#include <sstream>
|
||||
#include <openssl/pem.h>
|
||||
#ifdef _WIN32
|
||||
// fix for WIN32 header conflict
|
||||
#undef X509_NAME
|
||||
#endif
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
|
@ -31,9 +31,6 @@
|
||||
#include "Poco/Data/ODBC/TypeInfo.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/Exception.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqlext.h>
|
||||
|
||||
|
||||
|
@ -20,9 +20,6 @@
|
||||
|
||||
#include "Poco/Data/ODBC/EnvironmentHandle.h"
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqltypes.h>
|
||||
|
||||
|
||||
|
@ -22,9 +22,6 @@
|
||||
#include <vector>
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqlext.h>
|
||||
|
||||
|
||||
|
@ -19,9 +19,6 @@
|
||||
|
||||
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqltypes.h>
|
||||
|
||||
|
||||
|
@ -23,9 +23,6 @@
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#include "Poco/Format.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqlext.h>
|
||||
|
||||
|
||||
|
@ -34,9 +34,6 @@
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Nullable.h"
|
||||
#include "Poco/UTFString.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqltypes.h>
|
||||
|
||||
|
||||
|
@ -23,9 +23,6 @@
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/ODBC/ODBCException.h"
|
||||
#include "Poco/Data/ODBC/Utility.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqltypes.h>
|
||||
|
||||
|
||||
|
@ -21,9 +21,6 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
@ -34,13 +31,6 @@
|
||||
// ODBC_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
# if defined(ODBC_EXPORTS)
|
||||
# define ODBC_API __declspec(dllexport)
|
||||
# else
|
||||
# define ODBC_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(ODBC_API)
|
||||
|
@ -23,9 +23,6 @@
|
||||
#include "Poco/Data/ODBC/Handle.h"
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/Data/ODBC/ODBCException.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqlext.h>
|
||||
|
||||
|
||||
|
@ -29,9 +29,6 @@
|
||||
#include "Poco/Data/StatementImpl.h"
|
||||
#include "Poco/Format.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqltypes.h>
|
||||
|
||||
|
||||
|
@ -20,9 +20,6 @@
|
||||
|
||||
#include "Poco/Data/ODBC/Handle.h"
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqlext.h>
|
||||
|
||||
|
||||
|
@ -31,9 +31,6 @@
|
||||
#include "Poco/DynamicAny.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "Poco/UTFString.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqlext.h>
|
||||
|
||||
|
||||
|
@ -27,9 +27,6 @@
|
||||
#include "Poco/Data/ODBC/TypeInfo.h"
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqltypes.h>
|
||||
|
||||
|
||||
|
@ -23,9 +23,6 @@
|
||||
#include "Poco/Data/ODBC/ODBC.h"
|
||||
#include "Poco/DynamicAny.h"
|
||||
#include "Poco/NamedTuple.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <sqlext.h>
|
||||
|
||||
|
||||
|
@ -22,9 +22,6 @@
|
||||
#include "Poco/Buffer.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#ifndef SQL_NOUNICODEMAP
|
||||
# define SQL_NOUNICODEMAP
|
||||
#endif
|
||||
@ -33,10 +30,7 @@
|
||||
#include <sqlucode.h>
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
# define POCO_ODBC_UNICODE
|
||||
# define POCO_ODBC_UNICODE_WINDOWS
|
||||
#elif defined(POCO_OS_FAMILY_UNIX) && defined(UNICODE)
|
||||
#if defined(POCO_OS_FAMILY_UNIX) && defined(UNICODE)
|
||||
# define POCO_ODBC_UNICODE
|
||||
# ifdef POCO_UNIXODBC
|
||||
# define POCO_ODBC_UNICODE_UNIXODBC
|
||||
|
@ -500,18 +500,6 @@ void Binder::getColumnOrParameterSize(std::size_t pos, SQLINTEGER& size)
|
||||
{
|
||||
size = DEFAULT_PARAM_SIZE;
|
||||
//On Linux, PostgreSQL driver segfaults on SQLGetDescField, so this is disabled for now
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
SQLHDESC hIPD = 0;
|
||||
if (!Utility::isError(SQLGetStmtAttr(_rStmt, SQL_ATTR_IMP_PARAM_DESC, &hIPD, SQL_IS_POINTER, 0)))
|
||||
{
|
||||
SQLUINTEGER sz = 0;
|
||||
if (!Utility::isError(SQLGetDescField(hIPD, (SQLSMALLINT) pos + 1, SQL_DESC_LENGTH, &sz, SQL_IS_UINTEGER, 0)) &&
|
||||
sz > 0)
|
||||
{
|
||||
size = sz;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (colSize > 0 && paramSize > 0)
|
||||
|
@ -20,9 +20,6 @@
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
#pragma warning(disable:4312)// 'type cast' : conversion from 'std::size_t' to 'SQLPOINTER' of greater size
|
||||
#endif
|
||||
|
||||
|
||||
using Poco::DataFormatException;
|
||||
|
@ -31,13 +31,6 @@
|
||||
// Data_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
# if defined(Data_EXPORTS)
|
||||
# define Data_API __declspec(dllexport)
|
||||
# else
|
||||
# define Data_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(Data_API)
|
||||
|
@ -23,11 +23,7 @@
|
||||
#include "Poco/Manifest.h"
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define POCO_LIBRARY_API __declspec(dllexport)
|
||||
#else
|
||||
# define POCO_LIBRARY_API
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
|
@ -30,19 +30,11 @@ class Foundation_API Error
|
||||
/// for error reporting.
|
||||
{
|
||||
public:
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
static DWORD last();
|
||||
/// Utility function returning the last error.
|
||||
|
||||
static std::string getMessage(DWORD errorCode);
|
||||
/// Utility function translating numeric error code to string.
|
||||
#else
|
||||
static int last();
|
||||
/// Utility function returning the last error.
|
||||
|
||||
static std::string getMessage(int errorCode);
|
||||
/// Utility function translating numeric error code to string.
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -22,11 +22,7 @@
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/Event_WIN32.h"
|
||||
#else
|
||||
# include "Poco/Event_POSIX.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco
|
||||
|
@ -29,8 +29,6 @@
|
||||
# include "Poco/FPEnvironment_SUN.h"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
# include "Poco/FPEnvironment_C99.h"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/FPEnvironment_WIN32.h"
|
||||
#else
|
||||
# include "Poco/FPEnvironment_DUMMY.h"
|
||||
#endif
|
||||
|
@ -23,15 +23,7 @@
|
||||
#include "Poco/Timestamp.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
# if defined(_WIN32_WCE)
|
||||
# include "File_WINCE.h"
|
||||
# else
|
||||
# include "Poco/File_WIN32U.h"
|
||||
# endif
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/File_WIN32.h"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
# include "Poco/File_UNIX.h"
|
||||
#endif
|
||||
|
||||
|
@ -19,11 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/FileStream_WIN32.h"
|
||||
#else
|
||||
# include "Poco/FileStream_POSIX.h"
|
||||
#endif
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
|
@ -29,11 +29,6 @@
|
||||
//
|
||||
// Ensure that POCO_DLL is default unless POCO_STATIC is defined
|
||||
//
|
||||
#if defined(_WIN32) && defined(_DLL)
|
||||
# if !defined(POCO_DLL) && !defined(POCO_STATIC)
|
||||
# define POCO_DLL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
@ -71,9 +66,7 @@
|
||||
// Include platform-specific definitions
|
||||
//
|
||||
#include "Poco/Platform.h"
|
||||
#if defined(_WIN32)
|
||||
# include "Poco/Platform_WIN32.h"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
# include "Poco/Platform_POSIX.h"
|
||||
#endif
|
||||
|
||||
@ -86,15 +79,9 @@
|
||||
//
|
||||
// Cleanup inconsistencies
|
||||
//
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
# if defined(POCO_WIN32_UTF8) && defined(POCO_NO_WSTRING)
|
||||
# error POCO_WIN32_UTF8 and POCO_NO_WSTRING are mutually exclusive.
|
||||
# endif
|
||||
#else
|
||||
# ifdef POCO_WIN32_UTF8
|
||||
# undef POCO_WIN32_UTF8
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
|
@ -21,13 +21,7 @@
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
# include "Poco/LogFile_WIN32U.h"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/LogFile_WIN32.h"
|
||||
#else
|
||||
# include "Poco/LogFile_STD.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco
|
||||
|
@ -23,15 +23,7 @@
|
||||
#include "Poco/ScopedLock.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# if defined(_WIN32_WCE)
|
||||
# include "Poco/Mutex_WINCE.h"
|
||||
# else
|
||||
# include "Poco/Mutex_WIN32.h"
|
||||
# endif
|
||||
#else
|
||||
# include "Poco/Mutex_POSIX.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco
|
||||
|
@ -21,11 +21,7 @@
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
# include "Poco/NamedEvent_WIN32U.h"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/NamedEvent_WIN32.h"
|
||||
#elif POCO_OS == POCO_OS_ANDROID
|
||||
#if POCO_OS == POCO_OS_ANDROID
|
||||
# include "Poco/NamedEvent_Android.h"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
# include "Poco/NamedEvent_UNIX.h"
|
||||
|
@ -22,11 +22,7 @@
|
||||
#include "Poco/ScopedLock.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
# include "Poco/NamedMutex_WIN32U.h"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/NamedMutex_WIN32.h"
|
||||
#elif POCO_OS == POCO_OS_ANDROID
|
||||
#if POCO_OS == POCO_OS_ANDROID
|
||||
# include "Poco/NamedMutex_Android.h"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
# include "Poco/NamedMutex_UNIX.h"
|
||||
|
@ -470,8 +470,6 @@ inline char Path::separator()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_VMS)
|
||||
return '.';
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return '\\';
|
||||
#else
|
||||
return '/';
|
||||
#endif
|
||||
@ -482,8 +480,6 @@ inline char Path::pathSeparator()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_VMS)
|
||||
return ',';
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return ';';
|
||||
#else
|
||||
return ':';
|
||||
#endif
|
||||
|
@ -21,13 +21,7 @@
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# if defined(_WIN32_WCE)
|
||||
# include "PipeImpl_DUMMY.h"
|
||||
# else
|
||||
# include "Poco/PipeImpl_WIN32.h"
|
||||
# endif
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
# include "Poco/PipeImpl_POSIX.h"
|
||||
#else
|
||||
# include "Poco/PipeImpl_DUMMY.h"
|
||||
|
@ -143,10 +143,7 @@
|
||||
# define POCO_ARCH_LITTLE_ENDIAN 1
|
||||
#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(_M_MRX000)
|
||||
# define POCO_ARCH POCO_ARCH_MIPS
|
||||
# if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
// Is this OK? Supports windows only little endian??
|
||||
# define POCO_ARCH_LITTLE_ENDIAN 1
|
||||
# elif defined(__MIPSEB__) || defined(_MIPSEB) || defined(__MIPSEB)
|
||||
# if defined(__MIPSEB__) || defined(_MIPSEB) || defined(__MIPSEB)
|
||||
# define POCO_ARCH_BIG_ENDIAN 1
|
||||
# elif defined(__MIPSEL__) || defined(_MIPSEL) || defined(__MIPSEL)
|
||||
# define POCO_ARCH_LITTLE_ENDIAN 1
|
||||
@ -249,11 +246,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# define POCO_DEFAULT_NEWLINE_CHARS "\r\n"
|
||||
#else
|
||||
# define POCO_DEFAULT_NEWLINE_CHARS "\n"
|
||||
#endif
|
||||
|
||||
|
||||
#endif // Foundation_Platform_INCLUDED
|
||||
|
@ -21,15 +21,7 @@
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
# if defined(_WIN32_WCE)
|
||||
# include "Process_WINCE.h"
|
||||
# else
|
||||
# include "Poco/Process_WIN32U.h"
|
||||
# endif
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/Process_WIN32.h"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
# include "Poco/Process_UNIX.h"
|
||||
#endif
|
||||
|
||||
|
@ -22,13 +22,7 @@
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# if defined(_WIN32_WCE)
|
||||
# include "Poco/RWLock_WINCE.h"
|
||||
# else
|
||||
# include "Poco/RWLock_WIN32.h"
|
||||
# endif
|
||||
#elif POCO_OS == POCO_OS_ANDROID
|
||||
#if POCO_OS == POCO_OS_ANDROID
|
||||
# include "Poco/RWLock_Android.h"
|
||||
#else
|
||||
# include "Poco/RWLock_POSIX.h"
|
||||
|
@ -22,11 +22,7 @@
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/Semaphore_WIN32.h"
|
||||
#else
|
||||
# include "Poco/Semaphore_POSIX.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco
|
||||
|
@ -25,10 +25,6 @@
|
||||
# include "Poco/SharedLibrary_HPUX.h"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
# include "Poco/SharedLibrary_UNIX.h"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
# include "Poco/SharedLibrary_WIN32U.h"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/SharedLibrary_WIN32.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -23,15 +23,7 @@
|
||||
#include "Poco/Mutex.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# if defined(_WIN32_WCE)
|
||||
# include "Poco/Thread_WINCE.h"
|
||||
# else
|
||||
# include "Poco/Thread_WIN32.h"
|
||||
# endif
|
||||
#else
|
||||
# include "Poco/Thread_POSIX.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco
|
||||
|
@ -140,10 +140,6 @@ public:
|
||||
/// Since the timestamp has microsecond resolution,
|
||||
/// the returned value is always 1000000.
|
||||
|
||||
#if defined(_WIN32)
|
||||
static Timestamp fromFileTimeNP(UInt32 fileTimeLow, UInt32 fileTimeHigh);
|
||||
void toFileTimeNP(UInt32 & fileTimeLow, UInt32 & fileTimeHigh) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
TimeVal _ts;
|
||||
|
@ -35,13 +35,6 @@ typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
# if defined(_WIN64)
|
||||
# define POCO_PTR_IS_64_BIT 1
|
||||
typedef signed long long IntPtr;
|
||||
typedef unsigned long long UIntPtr;
|
||||
typedef signed long long Int64;
|
||||
typedef unsigned long long UInt64;
|
||||
# else
|
||||
typedef signed long IntPtr;
|
||||
typedef unsigned long UIntPtr;
|
||||
# if defined(__LP64__)
|
||||
@ -53,7 +46,6 @@ typedef unsigned long UInt64;
|
||||
typedef signed long long Int64;
|
||||
typedef unsigned long long UInt64;
|
||||
# endif
|
||||
# endif
|
||||
# define POCO_HAVE_INT64 1
|
||||
#endif
|
||||
|
||||
|
@ -225,12 +225,7 @@ typedef std::basic_string<UTF16Char, UTF16CharTraits> UTF16String;
|
||||
typedef UInt32 UTF32Char;
|
||||
typedef std::basic_string<UTF32Char, UTF32CharTraits> UTF32String;
|
||||
#else // POCO_NO_WSTRING
|
||||
# if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
typedef wchar_t UTF16Char;
|
||||
typedef std::wstring UTF16String;
|
||||
typedef UInt32 UTF32Char;
|
||||
typedef std::basic_string<UTF32Char, UTF32CharTraits> UTF32String;
|
||||
# elif defined(__SIZEOF_WCHAR_T__) //gcc
|
||||
# if defined(__SIZEOF_WCHAR_T__) //gcc
|
||||
# if (__SIZEOF_WCHAR_T__ == 2)
|
||||
typedef wchar_t UTF16Char;
|
||||
typedef std::wstring UTF16String;
|
||||
|
@ -38,11 +38,6 @@
|
||||
|
||||
|
||||
// Reduce bloat
|
||||
#if defined(_WIN32)
|
||||
# if !defined(WIN32_LEAN_AND_MEAN) && !defined(POCO_BLOATED_WIN32)
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// Microsoft Visual C++ includes copies of the Windows header files
|
||||
|
@ -21,8 +21,6 @@
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/UnWindows.h"
|
||||
#endif
|
||||
#include <algorithm>
|
||||
#undef min
|
||||
@ -91,18 +89,7 @@ void Clock::swap(Clock& timestamp)
|
||||
|
||||
void Clock::update()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
|
||||
LARGE_INTEGER perfCounter;
|
||||
LARGE_INTEGER perfFreq;
|
||||
if (QueryPerformanceCounter(&perfCounter) && QueryPerformanceFrequency(&perfFreq))
|
||||
{
|
||||
_clock = resolution()*(perfCounter.QuadPart/perfFreq.QuadPart);
|
||||
_clock += (perfCounter.QuadPart % perfFreq.QuadPart)*resolution()/perfFreq.QuadPart;
|
||||
}
|
||||
else throw Poco::SystemException("cannot get system clock");
|
||||
|
||||
#elif defined(__MACH__)
|
||||
#if defined(__MACH__)
|
||||
|
||||
clock_serv_t cs;
|
||||
mach_timespec_t ts;
|
||||
@ -131,17 +118,7 @@ void Clock::update()
|
||||
|
||||
Clock::ClockDiff Clock::accuracy()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
|
||||
LARGE_INTEGER perfFreq;
|
||||
if (QueryPerformanceFrequency(&perfFreq) && perfFreq.QuadPart > 0)
|
||||
{
|
||||
ClockVal acc = resolution()/perfFreq.QuadPart;
|
||||
return acc > 0 ? acc : 1;
|
||||
}
|
||||
else throw Poco::SystemException("cannot get system clock accuracy");
|
||||
|
||||
#elif defined(__MACH__)
|
||||
#if defined(__MACH__)
|
||||
|
||||
clock_serv_t cs;
|
||||
int nanosecs;
|
||||
@ -173,11 +150,7 @@ Clock::ClockDiff Clock::accuracy()
|
||||
|
||||
bool Clock::monotonic()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
|
||||
return true;
|
||||
|
||||
#elif defined(__MACH__)
|
||||
#if defined(__MACH__)
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -16,9 +16,7 @@
|
||||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/UnWindows.h"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
|
||||
#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
@ -38,22 +36,7 @@ namespace Poco {
|
||||
bool Debugger::isAvailable()
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
#if (_WIN32_WCE >= 0x600)
|
||||
BOOL isDebuggerPresent;
|
||||
if (CheckRemoteDebuggerPresent(GetCurrentProcess(), &isDebuggerPresent))
|
||||
{
|
||||
return isDebuggerPresent ? true : false;
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#else
|
||||
return IsDebuggerPresent() ? true : false;
|
||||
#endif
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
return std::getenv("POCO_ENABLE_DEBUGGER") ? true : false;
|
||||
#endif
|
||||
#else
|
||||
@ -68,20 +51,6 @@ void Debugger::message(const std::string& msg)
|
||||
std::fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
|
||||
std::fputs(msg.c_str(), stderr);
|
||||
std::fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
if (isAvailable())
|
||||
{
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
std::wstring umsg;
|
||||
UnicodeConverter::toUTF16(msg, umsg);
|
||||
umsg += '\n';
|
||||
OutputDebugStringW(umsg.c_str());
|
||||
#else
|
||||
OutputDebugStringA(msg.c_str());
|
||||
OutputDebugStringA("\n");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -99,12 +68,7 @@ void Debugger::message(const std::string& msg, const char* file, int line)
|
||||
void Debugger::enter()
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
if (isAvailable())
|
||||
{
|
||||
DebugBreak();
|
||||
}
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
if (isAvailable())
|
||||
{
|
||||
kill(getpid(), SIGINT);
|
||||
|
@ -15,11 +15,7 @@
|
||||
#include "Poco/DirectoryIterator.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
#include "DirectoryIterator_WIN32U.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "DirectoryIterator_WIN32.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "DirectoryIterator_UNIX.cpp"
|
||||
#endif
|
||||
|
||||
|
@ -20,12 +20,6 @@
|
||||
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "Environment_UNIX.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "Environment_WINCE.cpp"
|
||||
#else
|
||||
#include "Environment_WIN32.cpp"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -147,11 +141,7 @@ bool Environment::isUnix()
|
||||
|
||||
bool Environment::isWindows()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,34 +23,6 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
|
||||
|
||||
DWORD Error::last()
|
||||
{
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
|
||||
std::string Error::getMessage(DWORD errorCode)
|
||||
{
|
||||
std::string errMsg;
|
||||
DWORD dwFlg = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
LPWSTR lpMsgBuf = 0;
|
||||
if (FormatMessageW(dwFlg, 0, errorCode, 0, (LPWSTR) & lpMsgBuf, 0, NULL))
|
||||
UnicodeConverter::toUTF8(lpMsgBuf, errMsg);
|
||||
#else
|
||||
LPTSTR lpMsgBuf = 0;
|
||||
if (FormatMessageA(dwFlg, 0, errorCode, 0, (LPTSTR) & lpMsgBuf, 0, NULL))
|
||||
errMsg = lpMsgBuf;
|
||||
#endif
|
||||
LocalFree(lpMsgBuf);
|
||||
return errMsg;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
int Error::last()
|
||||
@ -111,7 +83,6 @@ namespace Poco {
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
@ -15,11 +15,7 @@
|
||||
#include "Poco/Event.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Event_WIN32.cpp"
|
||||
#else
|
||||
#include "Event_POSIX.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
@ -224,17 +224,9 @@ void EventLogChannel::setUpRegistry() const
|
||||
std::wstring path;
|
||||
#if defined(POCO_DLL)
|
||||
#if defined(_DEBUG)
|
||||
#if defined(_WIN64)
|
||||
path = findLibrary(L"PocoFoundation64d.dll");
|
||||
#else
|
||||
path = findLibrary(L"PocoFoundationd.dll");
|
||||
#endif
|
||||
#else
|
||||
#if defined(_WIN64)
|
||||
path = findLibrary(L"PocoFoundation64.dll");
|
||||
#else
|
||||
path = findLibrary(L"PocoFoundation.dll");
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -244,17 +236,9 @@ void EventLogChannel::setUpRegistry() const
|
||||
std::string path;
|
||||
#if defined(POCO_DLL)
|
||||
#if defined(_DEBUG)
|
||||
#if defined(_WIN64)
|
||||
path = findLibrary("PocoFoundation64d.dll");
|
||||
#else
|
||||
path = findLibrary("PocoFoundationd.dll");
|
||||
#endif
|
||||
#else
|
||||
#if defined(_WIN64)
|
||||
path = findLibrary("PocoFoundation64.dll");
|
||||
#else
|
||||
path = findLibrary("PocoFoundation.dll");
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "FPEnvironment_SUN.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "FPEnvironment_C99.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "FPEnvironment_WIN32.cpp"
|
||||
#else
|
||||
#include "FPEnvironment_DUMMY.cpp"
|
||||
#endif
|
||||
|
@ -17,15 +17,7 @@
|
||||
#include "Poco/DirectoryIterator.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "File_WINCE.cpp"
|
||||
#else
|
||||
#include "File_WIN32U.cpp"
|
||||
#endif
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "File_WIN32.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "File_UNIX.cpp"
|
||||
#endif
|
||||
#include "Poco/Thread.h"
|
||||
|
@ -14,11 +14,7 @@
|
||||
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/Exception.h"
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "FileStream_WIN32.cpp"
|
||||
#else
|
||||
#include "FileStream_POSIX.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
@ -15,13 +15,7 @@
|
||||
#include "Poco/LogFile.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
#include "LogFile_WIN32U.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "LogFile_WIN32.cpp"
|
||||
#else
|
||||
#include "LogFile_STD.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
@ -24,10 +24,6 @@
|
||||
#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_NO_SYSLOGCHANNEL)
|
||||
#include "Poco/SyslogChannel.h"
|
||||
#endif
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
|
||||
#include "Poco/EventLogChannel.h"
|
||||
#include "Poco/WindowsConsoleChannel.h"
|
||||
#endif
|
||||
#include "Poco/PatternFormatter.h"
|
||||
|
||||
|
||||
@ -84,13 +80,8 @@ LoggingFactory& LoggingFactory::defaultFactory()
|
||||
void LoggingFactory::registerBuiltins()
|
||||
{
|
||||
_channelFactory.registerClass("AsyncChannel", new Instantiator<AsyncChannel, Channel>);
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
|
||||
_channelFactory.registerClass("ConsoleChannel", new Instantiator<WindowsConsoleChannel, Channel>);
|
||||
_channelFactory.registerClass("ColorConsoleChannel", new Instantiator<WindowsColorConsoleChannel, Channel>);
|
||||
#else
|
||||
_channelFactory.registerClass("ConsoleChannel", new Instantiator<ConsoleChannel, Channel>);
|
||||
_channelFactory.registerClass("ColorConsoleChannel", new Instantiator<ColorConsoleChannel, Channel>);
|
||||
#endif
|
||||
#ifndef POCO_NO_FILECHANNEL
|
||||
_channelFactory.registerClass("FileChannel", new Instantiator<FileChannel, Channel>);
|
||||
#endif
|
||||
@ -105,9 +96,6 @@ void LoggingFactory::registerBuiltins()
|
||||
#ifndef POCO_NO_SYSLOGCHANNEL
|
||||
_channelFactory.registerClass("SyslogChannel", new Instantiator<SyslogChannel, Channel>);
|
||||
#endif
|
||||
#endif
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
|
||||
_channelFactory.registerClass("EventLogChannel", new Instantiator<EventLogChannel, Channel>);
|
||||
#endif
|
||||
|
||||
_formatterFactory.registerClass("PatternFormatter", new Instantiator<PatternFormatter, Formatter>);
|
||||
|
@ -15,15 +15,7 @@
|
||||
#include "Poco/Mutex.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "Mutex_WINCE.cpp"
|
||||
#else
|
||||
#include "Mutex_WIN32.cpp"
|
||||
#endif
|
||||
#else
|
||||
#include "Mutex_POSIX.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
@ -15,11 +15,7 @@
|
||||
#include "Poco/NamedEvent.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
#include "NamedEvent_WIN32U.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "NamedEvent_WIN32.cpp"
|
||||
#elif POCO_OS == POCO_OS_ANDROID
|
||||
#if POCO_OS == POCO_OS_ANDROID
|
||||
#include "NamedEvent_Android.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "NamedEvent_UNIX.cpp"
|
||||
|
@ -15,11 +15,7 @@
|
||||
#include "Poco/NamedMutex.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
#include "NamedMutex_WIN32U.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "NamedMutex_WIN32.cpp"
|
||||
#elif POCO_OS == POCO_OS_ANDROID
|
||||
#if POCO_OS == POCO_OS_ANDROID
|
||||
#include "NamedMutex_Android.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "NamedMutex_UNIX.cpp"
|
||||
|
@ -16,23 +16,11 @@
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/StringTokenizer.h"
|
||||
#if defined(_WIN32) && defined(POCO_WIN32_UTF8)
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
#include "Poco/Buffer.h"
|
||||
#endif
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "Path_UNIX.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "Path_WINCE.cpp"
|
||||
#else
|
||||
#include "Path_WIN32U.cpp"
|
||||
#endif
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Path_WIN32.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
@ -176,11 +164,7 @@ Path& Path::assign(const Path& path)
|
||||
|
||||
Path& Path::assign(const std::string& path)
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
parseWindows(path);
|
||||
#else
|
||||
parseUnix(path);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -219,11 +203,7 @@ Path& Path::assign(const char* path)
|
||||
|
||||
std::string Path::toString() const
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return buildWindows();
|
||||
#else
|
||||
return buildUnix();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1043,20 +1023,6 @@ std::string Path::buildVMS() const
|
||||
|
||||
std::string Path::transcode(const std::string& path)
|
||||
{
|
||||
#if defined(_WIN32) && defined(POCO_WIN32_UTF8)
|
||||
std::wstring uniPath;
|
||||
UnicodeConverter::toUTF16(path, uniPath);
|
||||
DWORD len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, uniPath.c_str(), static_cast<int>(uniPath.length()), NULL, 0, NULL, NULL);
|
||||
if (len > 0)
|
||||
{
|
||||
Buffer<char> buffer(len);
|
||||
DWORD rc = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, uniPath.c_str(), static_cast<int>(uniPath.length()), buffer.begin(), static_cast<int>(buffer.size()), NULL, NULL);
|
||||
if (rc)
|
||||
{
|
||||
return std::string(buffer.begin(), buffer.size());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return path;
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,7 @@
|
||||
#include "Poco/PipeImpl.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
/// #include "PipeImpl_DUMMY.cpp"
|
||||
#else
|
||||
#include "PipeImpl_WIN32.cpp"
|
||||
#endif
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "PipeImpl_POSIX.cpp"
|
||||
#else
|
||||
#include "PipeImpl_DUMMY.cpp"
|
||||
|
@ -47,15 +47,7 @@ namespace
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "Process_WINCE.cpp"
|
||||
#else
|
||||
#include "Process_WIN32U.cpp"
|
||||
#endif
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Process_WIN32.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "Process_UNIX.cpp"
|
||||
#endif
|
||||
|
||||
|
@ -15,13 +15,7 @@
|
||||
#include "Poco/RWLock.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "RWLock_WINCE.cpp"
|
||||
#else
|
||||
#include "RWLock_WIN32.cpp"
|
||||
#endif
|
||||
#elif POCO_OS == POCO_OS_ANDROID
|
||||
#if POCO_OS == POCO_OS_ANDROID
|
||||
#include "RWLock_Android.cpp"
|
||||
#else
|
||||
#include "RWLock_POSIX.cpp"
|
||||
|
@ -15,10 +15,7 @@
|
||||
#include "Poco/RandomStream.h"
|
||||
#include "Poco/Random.h"
|
||||
#include "Poco/SHA1Engine.h"
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/UnWindows.h"
|
||||
#include <wincrypt.h>
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -42,13 +39,6 @@ int RandomBuf::readFromDevice(char* buffer, std::streamsize length)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
HCRYPTPROV hProvider = 0;
|
||||
CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
CryptGenRandom(hProvider, (DWORD) length, (BYTE*) buffer);
|
||||
CryptReleaseContext(hProvider, 0);
|
||||
n = static_cast<int>(length);
|
||||
#else
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
int fd = open("/dev/urandom", O_RDONLY, 0);
|
||||
if (fd >= 0)
|
||||
@ -92,7 +82,6 @@ int RandomBuf::readFromDevice(char* buffer, std::streamsize length)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,7 @@
|
||||
#include "Poco/Semaphore.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Semaphore_WIN32.cpp"
|
||||
#else
|
||||
#include "Semaphore_POSIX.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
@ -20,10 +20,6 @@
|
||||
#include "SharedLibrary_HPUX.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "SharedLibrary_UNIX.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
#include "SharedLibrary_WIN32U.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "SharedLibrary_WIN32.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -16,8 +16,6 @@
|
||||
#include "Poco/Exception.h"
|
||||
#if defined(POCO_NO_SHAREDMEMORY)
|
||||
/// #include "SharedMemory_DUMMY.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "SharedMemory_WIN32.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "SharedMemory_POSIX.cpp"
|
||||
#else
|
||||
|
@ -20,15 +20,7 @@
|
||||
#include <sstream>
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "Thread_WINCE.cpp"
|
||||
#else
|
||||
#include "Thread_WIN32.cpp"
|
||||
#endif
|
||||
#else
|
||||
#include "Thread_POSIX.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
@ -24,11 +24,6 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/times.h>
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/UnWindows.h"
|
||||
#if defined(_WIN32_WCE)
|
||||
#include <cmath>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -210,26 +205,7 @@ Timestamp Timestamp::fromUtcTime(UtcTimeVal val)
|
||||
|
||||
void Timestamp::update()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
|
||||
FILETIME ft;
|
||||
#if defined(_WIN32_WCE) && defined(POCO_WINCE_TIMESTAMP_HACK)
|
||||
GetSystemTimeAsFileTimeWithMillisecondResolution(&ft);
|
||||
#else
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
#endif
|
||||
|
||||
ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
|
||||
epoch.LowPart = 0xD53E8000;
|
||||
epoch.HighPart = 0x019DB1DE;
|
||||
|
||||
ULARGE_INTEGER ts;
|
||||
ts.LowPart = ft.dwLowDateTime;
|
||||
ts.HighPart = ft.dwHighDateTime;
|
||||
ts.QuadPart -= epoch.QuadPart;
|
||||
_ts = ts.QuadPart/10;
|
||||
|
||||
#elif defined(POCO_HAVE_CLOCK_GETTIME)
|
||||
#if defined(POCO_HAVE_CLOCK_GETTIME)
|
||||
|
||||
struct timespec ts;
|
||||
if (clock_gettime(CLOCK_REALTIME, &ts))
|
||||
@ -271,39 +247,6 @@ Timestamp& Timestamp::operator -= (const Timespan& span)
|
||||
}
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
|
||||
Timestamp Timestamp::fromFileTimeNP(UInt32 fileTimeLow, UInt32 fileTimeHigh)
|
||||
{
|
||||
ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
|
||||
epoch.LowPart = 0xD53E8000;
|
||||
epoch.HighPart = 0x019DB1DE;
|
||||
|
||||
ULARGE_INTEGER ts;
|
||||
ts.LowPart = fileTimeLow;
|
||||
ts.HighPart = fileTimeHigh;
|
||||
ts.QuadPart -= epoch.QuadPart;
|
||||
|
||||
return Timestamp(ts.QuadPart/10);
|
||||
}
|
||||
|
||||
|
||||
void Timestamp::toFileTimeNP(UInt32& fileTimeLow, UInt32& fileTimeHigh) const
|
||||
{
|
||||
ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
|
||||
epoch.LowPart = 0xD53E8000;
|
||||
epoch.HighPart = 0x019DB1DE;
|
||||
|
||||
ULARGE_INTEGER ts;
|
||||
ts.QuadPart = _ts*10;
|
||||
ts.QuadPart += epoch.QuadPart;
|
||||
fileTimeLow = ts.LowPart;
|
||||
fileTimeHigh = ts.HighPart;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
@ -16,15 +16,7 @@
|
||||
#include <ctime>
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "Timezone_WINCE.cpp"
|
||||
#else
|
||||
#include "Timezone_WIN32.cpp"
|
||||
#endif
|
||||
#else
|
||||
#include "Timezone_UNIX.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
@ -31,9 +31,6 @@
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
# if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
|
||||
|
@ -51,19 +51,6 @@ imported have to be identified as such. When building PCRE, the appropriate
|
||||
export setting is defined in pcre_internal.h, which includes this file. So we
|
||||
don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
|
||||
|
||||
#if defined(_WIN32) && !defined(PCRE_STATIC)
|
||||
# ifndef PCRE_EXP_DECL
|
||||
# define PCRE_EXP_DECL extern __declspec(dllimport)
|
||||
# endif
|
||||
# ifdef __cplusplus
|
||||
# ifndef PCRECPP_EXP_DECL
|
||||
# define PCRECPP_EXP_DECL extern __declspec(dllimport)
|
||||
# endif
|
||||
# ifndef PCRECPP_EXP_DEFN
|
||||
# define PCRECPP_EXP_DEFN __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* By default, we use the standard "extern" declarations. */
|
||||
|
||||
|
@ -146,17 +146,6 @@ exported symbols. That's why, in the non-Windows case, we set PCRE_EXP_DEFN and
|
||||
PCRE_EXP_DATA_DEFN only if they are not already set. */
|
||||
|
||||
# ifndef PCRE_EXP_DECL
|
||||
# ifdef _WIN32
|
||||
# ifndef PCRE_STATIC
|
||||
# define PCRE_EXP_DECL extern __declspec(dllexport)
|
||||
# define PCRE_EXP_DEFN __declspec(dllexport)
|
||||
# define PCRE_EXP_DATA_DEFN __declspec(dllexport)
|
||||
# else
|
||||
# define PCRE_EXP_DECL extern
|
||||
# define PCRE_EXP_DEFN
|
||||
# define PCRE_EXP_DATA_DEFN
|
||||
# endif
|
||||
# else
|
||||
# ifdef __cplusplus
|
||||
# define PCRE_EXP_DECL extern "C"
|
||||
# else
|
||||
@ -168,7 +157,6 @@ PCRE_EXP_DATA_DEFN only if they are not already set. */
|
||||
# ifndef PCRE_EXP_DATA_DEFN
|
||||
# define PCRE_EXP_DATA_DEFN
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* When compiling with the MSVC compiler, it is sometimes necessary to include
|
||||
|
@ -59,12 +59,7 @@
|
||||
|| defined(__nios2__)
|
||||
# define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
|
||||
#elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
|
||||
# if defined(_WIN32)
|
||||
// Windows uses a 64bit wide floating point stack.
|
||||
# define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
|
||||
# else
|
||||
# undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
|
||||
# endif // _WIN32
|
||||
#else
|
||||
# error Target architecture was not detected as supported by Double-Conversion.
|
||||
#endif
|
||||
@ -75,23 +70,9 @@
|
||||
# define DOUBLE_CONVERSION_UNUSED
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef short int16_t; // NOLINT
|
||||
typedef unsigned short uint16_t; // NOLINT
|
||||
typedef int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
// intptr_t and friends are defined in crtdefs.h through stdio.h.
|
||||
|
||||
#else
|
||||
|
||||
# include <stdint.h>
|
||||
|
||||
#endif
|
||||
|
||||
// The following macro works on both 32 and 64-bit platforms.
|
||||
// Usage: instead of writing 0x1234567890123456
|
||||
|
@ -31,13 +31,6 @@
|
||||
// JSON_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
# if defined(JSON_EXPORTS)
|
||||
# define JSON_API __declspec(dllexport)
|
||||
# else
|
||||
# define JSON_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(JSON_API)
|
||||
|
@ -33,13 +33,6 @@
|
||||
//
|
||||
|
||||
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
# if defined(MongoDB_EXPORTS)
|
||||
# define MongoDB_API __declspec(dllexport)
|
||||
# else
|
||||
# define MongoDB_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(MongoDB_API)
|
||||
|
@ -109,10 +109,6 @@ namespace Net
|
||||
IPAddress(unsigned prefix, Family family);
|
||||
/// Creates an IPAddress mask with the given length of prefix.
|
||||
|
||||
#if defined(_WIN32)
|
||||
IPAddress(const SOCKET_ADDRESS & socket_address);
|
||||
/// Creates an IPAddress from Windows SOCKET_ADDRESS structure.
|
||||
#endif
|
||||
|
||||
IPAddress(const struct sockaddr & sockaddr);
|
||||
/// Same for struct sock_addr on POSIX.
|
||||
|
@ -31,13 +31,6 @@
|
||||
// Net_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
# if defined(Net_EXPORTS)
|
||||
# define Net_API __declspec(dllexport)
|
||||
# else
|
||||
# define Net_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(Net_API)
|
||||
@ -86,27 +79,6 @@ namespace Net
|
||||
// Automate network initialization (only relevant on Windows).
|
||||
//
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_NO_AUTOMATIC_LIB_INIT) && !defined(__GNUC__)
|
||||
|
||||
extern "C" const struct Net_API NetworkInitializer pocoNetworkInitializer;
|
||||
|
||||
# if defined(Net_EXPORTS)
|
||||
# if defined(_WIN64) || defined(_WIN32_WCE)
|
||||
# define POCO_NET_FORCE_SYMBOL(s) __pragma(comment(linker, "/export:" # s))
|
||||
# elif defined(_WIN32)
|
||||
# define POCO_NET_FORCE_SYMBOL(s) __pragma(comment(linker, "/export:_" # s))
|
||||
# endif
|
||||
# else // !Net_EXPORTS
|
||||
# if defined(_WIN64) || defined(_WIN32_WCE)
|
||||
# define POCO_NET_FORCE_SYMBOL(s) __pragma(comment(linker, "/include:" # s))
|
||||
# elif defined(_WIN32)
|
||||
# define POCO_NET_FORCE_SYMBOL(s) __pragma(comment(linker, "/include:_" # s))
|
||||
# endif
|
||||
# endif // Net_EXPORTS
|
||||
|
||||
POCO_NET_FORCE_SYMBOL(pocoNetworkInitializer)
|
||||
|
||||
#endif // POCO_OS_FAMILY_WINDOWS
|
||||
|
||||
|
||||
//
|
||||
|
@ -100,11 +100,7 @@ namespace Net
|
||||
};
|
||||
|
||||
static const unsigned NO_INDEX = ~0;
|
||||
# if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
static const char MAC_SEPARATOR = '-';
|
||||
# else
|
||||
static const char MAC_SEPARATOR = ':';
|
||||
# endif
|
||||
|
||||
NetworkInterface(unsigned index = NO_INDEX);
|
||||
/// Creates a NetworkInterface representing the
|
||||
|
@ -21,59 +21,7 @@
|
||||
#define POCO_ENOERR 0
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/UnWindows.h"
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
# define POCO_INVALID_SOCKET INVALID_SOCKET
|
||||
# define poco_socket_t SOCKET
|
||||
# define poco_socklen_t int
|
||||
# define poco_ioctl_request_t int
|
||||
# define poco_closesocket(s) closesocket(s)
|
||||
# define POCO_EINTR WSAEINTR
|
||||
# define POCO_EACCES WSAEACCES
|
||||
# define POCO_EFAULT WSAEFAULT
|
||||
# define POCO_EINVAL WSAEINVAL
|
||||
# define POCO_EMFILE WSAEMFILE
|
||||
# define POCO_EAGAIN WSAEWOULDBLOCK
|
||||
# define POCO_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
# define POCO_EINPROGRESS WSAEINPROGRESS
|
||||
# define POCO_EALREADY WSAEALREADY
|
||||
# define POCO_ENOTSOCK WSAENOTSOCK
|
||||
# define POCO_EDESTADDRREQ WSAEDESTADDRREQ
|
||||
# define POCO_EMSGSIZE WSAEMSGSIZE
|
||||
# define POCO_EPROTOTYPE WSAEPROTOTYPE
|
||||
# define POCO_ENOPROTOOPT WSAENOPROTOOPT
|
||||
# define POCO_EPROTONOSUPPORT WSAEPROTONOSUPPORT
|
||||
# define POCO_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
|
||||
# define POCO_ENOTSUP WSAEOPNOTSUPP
|
||||
# define POCO_EPFNOSUPPORT WSAEPFNOSUPPORT
|
||||
# define POCO_EAFNOSUPPORT WSAEAFNOSUPPORT
|
||||
# define POCO_EADDRINUSE WSAEADDRINUSE
|
||||
# define POCO_EADDRNOTAVAIL WSAEADDRNOTAVAIL
|
||||
# define POCO_ENETDOWN WSAENETDOWN
|
||||
# define POCO_ENETUNREACH WSAENETUNREACH
|
||||
# define POCO_ENETRESET WSAENETRESET
|
||||
# define POCO_ECONNABORTED WSAECONNABORTED
|
||||
# define POCO_ECONNRESET WSAECONNRESET
|
||||
# define POCO_ENOBUFS WSAENOBUFS
|
||||
# define POCO_EISCONN WSAEISCONN
|
||||
# define POCO_ENOTCONN WSAENOTCONN
|
||||
# define POCO_ESHUTDOWN WSAESHUTDOWN
|
||||
# define POCO_ETIMEDOUT WSAETIMEDOUT
|
||||
# define POCO_ECONNREFUSED WSAECONNREFUSED
|
||||
# define POCO_EHOSTDOWN WSAEHOSTDOWN
|
||||
# define POCO_EHOSTUNREACH WSAEHOSTUNREACH
|
||||
# define POCO_ESYSNOTREADY WSASYSNOTREADY
|
||||
# define POCO_ENOTINIT WSANOTINITIALISED
|
||||
# define POCO_HOST_NOT_FOUND WSAHOST_NOT_FOUND
|
||||
# define POCO_TRY_AGAIN WSATRY_AGAIN
|
||||
# define POCO_NO_RECOVERY WSANO_RECOVERY
|
||||
# define POCO_NO_DATA WSANO_DATA
|
||||
# ifndef ADDRESS_FAMILY
|
||||
# define ADDRESS_FAMILY USHORT
|
||||
# endif
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
# include <unistd.h>
|
||||
# include <errno.h>
|
||||
# include <sys/types.h>
|
||||
@ -274,11 +222,7 @@ extern "C" {
|
||||
|
||||
|
||||
#if !defined(s6_addr16)
|
||||
# if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# define s6_addr16 u.Word
|
||||
# else
|
||||
# define s6_addr16 __u6_addr.__u6_addr16
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -485,11 +485,7 @@ namespace Net
|
||||
|
||||
inline int SocketImpl::lastError()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return WSAGetLastError();
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -318,11 +318,7 @@ std::string DNS::decodeIDNLabel(const std::string& encodedIDN)
|
||||
|
||||
int DNS::lastError()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return GetLastError();
|
||||
#else
|
||||
return h_errno;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -357,11 +353,9 @@ void DNS::aierror(int code, const std::string& arg)
|
||||
throw DNSException("Temporary DNS error while resolving", arg);
|
||||
case EAI_FAIL:
|
||||
throw DNSException("Non recoverable DNS error while resolving", arg);
|
||||
#if !defined(_WIN32) // EAI_NODATA and EAI_NONAME have the same value
|
||||
#if defined(EAI_NODATA) // deprecated in favor of EAI_NONAME on FreeBSD
|
||||
case EAI_NODATA:
|
||||
throw NoAddressFoundException(arg);
|
||||
#endif
|
||||
#endif
|
||||
case EAI_NONAME:
|
||||
throw HostNotFoundException(arg);
|
||||
@ -369,10 +363,6 @@ void DNS::aierror(int code, const std::string& arg)
|
||||
case EAI_SYSTEM:
|
||||
error(lastError(), arg);
|
||||
break;
|
||||
#endif
|
||||
#if defined(_WIN32)
|
||||
case WSANO_DATA: // may happen on XP
|
||||
throw HostNotFoundException(arg);
|
||||
#endif
|
||||
default:
|
||||
throw DNSException("EAI", gai_strerror(code));
|
||||
|
@ -148,11 +148,7 @@ void HTTPServerConnection::onServerStopped(const bool& abortCurrent)
|
||||
// Note: On Windows, select() will not return if one of its socket is being
|
||||
// shut down. Therefore we have to call close(), which works better.
|
||||
// On other platforms, we do the more graceful thing.
|
||||
#if defined(_WIN32)
|
||||
socket().close();
|
||||
#else
|
||||
socket().shutdown();
|
||||
#endif
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -164,11 +160,7 @@ void HTTPServerConnection::onServerStopped(const bool& abortCurrent)
|
||||
|
||||
try
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
socket().close();
|
||||
#else
|
||||
socket().shutdown();
|
||||
#endif
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -182,21 +182,6 @@ IPAddress::IPAddress(unsigned prefix, Family family)
|
||||
}
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
IPAddress::IPAddress(const SOCKET_ADDRESS& socket_address)
|
||||
: _pImpl(0)
|
||||
{
|
||||
ADDRESS_FAMILY family = socket_address.lpSockaddr->sa_family;
|
||||
if (family == AF_INET)
|
||||
newIPv4(&reinterpret_cast<const struct sockaddr_in*>(socket_address.lpSockaddr)->sin_addr);
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (family == AF_INET6)
|
||||
newIPv6(&reinterpret_cast<const struct sockaddr_in6*>(socket_address.lpSockaddr)->sin6_addr,
|
||||
reinterpret_cast<const struct sockaddr_in6*>(socket_address.lpSockaddr)->sin6_scope_id);
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
IPAddress::IPAddress(const struct sockaddr& sockaddr)
|
||||
|
@ -256,14 +256,6 @@ bool IPv4AddressImpl::isGlobalMC() const
|
||||
IPv4AddressImpl IPv4AddressImpl::parse(const std::string& addr)
|
||||
{
|
||||
if (addr.empty()) return IPv4AddressImpl();
|
||||
#if defined(_WIN32)
|
||||
struct in_addr ia;
|
||||
ia.s_addr = inet_addr(addr.c_str());
|
||||
if (ia.s_addr == INADDR_NONE && addr != "255.255.255.255")
|
||||
return IPv4AddressImpl();
|
||||
else
|
||||
return IPv4AddressImpl(&ia);
|
||||
#else
|
||||
#if __GNUC__ < 3 || defined(POCO_VXWORKS)
|
||||
struct in_addr ia;
|
||||
ia.s_addr = inet_addr(const_cast<char*>(addr.c_str()));
|
||||
@ -278,7 +270,6 @@ IPv4AddressImpl IPv4AddressImpl::parse(const std::string& addr)
|
||||
else
|
||||
return IPv4AddressImpl();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -388,20 +379,6 @@ IPv6AddressImpl::IPv6AddressImpl(unsigned prefix):
|
||||
_scope(0)
|
||||
{
|
||||
unsigned i = 0;
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
for (; prefix >= 16; ++i, prefix -= 16)
|
||||
{
|
||||
_addr.s6_addr16[i] = 0xffff;
|
||||
}
|
||||
if (prefix > 0)
|
||||
{
|
||||
_addr.s6_addr16[i++] = ByteOrder::toNetwork(static_cast<Poco::UInt16>(~(0xffff >> prefix)));
|
||||
}
|
||||
while (i < 8)
|
||||
{
|
||||
_addr.s6_addr16[i++] = 0;
|
||||
}
|
||||
#else
|
||||
for (; prefix >= 32; ++i, prefix -= 32)
|
||||
{
|
||||
_addr.s6_addr32[i] = 0xffffffff;
|
||||
@ -414,7 +391,6 @@ IPv6AddressImpl::IPv6AddressImpl(unsigned prefix):
|
||||
{
|
||||
_addr.s6_addr32[i++] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -467,9 +443,6 @@ std::string IPv6AddressImpl::toString() const
|
||||
if (_scope > 0)
|
||||
{
|
||||
result.append("%");
|
||||
#if defined(_WIN32)
|
||||
NumberFormatter::append(result, _scope);
|
||||
#else
|
||||
char buffer[IFNAMSIZ];
|
||||
if (if_indextoname(_scope, buffer))
|
||||
{
|
||||
@ -479,7 +452,6 @@ std::string IPv6AddressImpl::toString() const
|
||||
{
|
||||
NumberFormatter::append(result, _scope);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return toLower(result);
|
||||
}
|
||||
@ -522,14 +494,6 @@ unsigned IPv6AddressImpl::prefixLength() const
|
||||
bitPos -= 32;
|
||||
}
|
||||
return 0;
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
for (int i = 7; i >= 0; --i)
|
||||
{
|
||||
unsigned short addr = ByteOrder::fromNetwork(_addr.s6_addr16[i]);
|
||||
if ((bits = maskBits(addr, 16))) return (bitPos - (16 - bits));
|
||||
bitPos -= 16;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
#warning prefixLength() not implemented
|
||||
throw NotImplementedException("prefixLength() not implemented");
|
||||
@ -645,20 +609,6 @@ bool IPv6AddressImpl::isGlobalMC() const
|
||||
IPv6AddressImpl IPv6AddressImpl::parse(const std::string& addr)
|
||||
{
|
||||
if (addr.empty()) return IPv6AddressImpl();
|
||||
#if defined(_WIN32)
|
||||
struct addrinfo* pAI;
|
||||
struct addrinfo hints;
|
||||
std::memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
int rc = getaddrinfo(addr.c_str(), NULL, &hints, &pAI);
|
||||
if (rc == 0)
|
||||
{
|
||||
IPv6AddressImpl result = IPv6AddressImpl(&reinterpret_cast<struct sockaddr_in6*>(pAI->ai_addr)->sin6_addr, static_cast<int>(reinterpret_cast<struct sockaddr_in6*>(pAI->ai_addr)->sin6_scope_id));
|
||||
freeaddrinfo(pAI);
|
||||
return result;
|
||||
}
|
||||
else return IPv6AddressImpl();
|
||||
#else
|
||||
struct in6_addr ia;
|
||||
std::string::size_type pos = addr.find('%');
|
||||
if (std::string::npos != pos)
|
||||
@ -681,7 +631,6 @@ IPv6AddressImpl IPv6AddressImpl::parse(const std::string& addr)
|
||||
else
|
||||
return IPv6AddressImpl();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -703,21 +652,10 @@ IPv6AddressImpl IPv6AddressImpl::operator & (const IPv6AddressImpl& addr) const
|
||||
throw Poco::InvalidArgumentException("Scope ID of passed IPv6 address does not match with the source one.");
|
||||
|
||||
IPv6AddressImpl result(*this);
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
result._addr.s6_addr16[0] &= addr._addr.s6_addr16[0];
|
||||
result._addr.s6_addr16[1] &= addr._addr.s6_addr16[1];
|
||||
result._addr.s6_addr16[2] &= addr._addr.s6_addr16[2];
|
||||
result._addr.s6_addr16[3] &= addr._addr.s6_addr16[3];
|
||||
result._addr.s6_addr16[4] &= addr._addr.s6_addr16[4];
|
||||
result._addr.s6_addr16[5] &= addr._addr.s6_addr16[5];
|
||||
result._addr.s6_addr16[6] &= addr._addr.s6_addr16[6];
|
||||
result._addr.s6_addr16[7] &= addr._addr.s6_addr16[7];
|
||||
#else
|
||||
result._addr.s6_addr32[0] &= addr._addr.s6_addr32[0];
|
||||
result._addr.s6_addr32[1] &= addr._addr.s6_addr32[1];
|
||||
result._addr.s6_addr32[2] &= addr._addr.s6_addr32[2];
|
||||
result._addr.s6_addr32[3] &= addr._addr.s6_addr32[3];
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -728,21 +666,10 @@ IPv6AddressImpl IPv6AddressImpl::operator | (const IPv6AddressImpl& addr) const
|
||||
throw Poco::InvalidArgumentException("Scope ID of passed IPv6 address does not match with the source one.");
|
||||
|
||||
IPv6AddressImpl result(*this);
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
result._addr.s6_addr16[0] |= addr._addr.s6_addr16[0];
|
||||
result._addr.s6_addr16[1] |= addr._addr.s6_addr16[1];
|
||||
result._addr.s6_addr16[2] |= addr._addr.s6_addr16[2];
|
||||
result._addr.s6_addr16[3] |= addr._addr.s6_addr16[3];
|
||||
result._addr.s6_addr16[4] |= addr._addr.s6_addr16[4];
|
||||
result._addr.s6_addr16[5] |= addr._addr.s6_addr16[5];
|
||||
result._addr.s6_addr16[6] |= addr._addr.s6_addr16[6];
|
||||
result._addr.s6_addr16[7] |= addr._addr.s6_addr16[7];
|
||||
#else
|
||||
result._addr.s6_addr32[0] |= addr._addr.s6_addr32[0];
|
||||
result._addr.s6_addr32[1] |= addr._addr.s6_addr32[1];
|
||||
result._addr.s6_addr32[2] |= addr._addr.s6_addr32[2];
|
||||
result._addr.s6_addr32[3] |= addr._addr.s6_addr32[3];
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -754,21 +681,10 @@ IPv6AddressImpl IPv6AddressImpl::operator ^ (const IPv6AddressImpl& addr) const
|
||||
|
||||
IPv6AddressImpl result(*this);
|
||||
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
result._addr.s6_addr16[0] ^= addr._addr.s6_addr16[0];
|
||||
result._addr.s6_addr16[1] ^= addr._addr.s6_addr16[1];
|
||||
result._addr.s6_addr16[2] ^= addr._addr.s6_addr16[2];
|
||||
result._addr.s6_addr16[3] ^= addr._addr.s6_addr16[3];
|
||||
result._addr.s6_addr16[4] ^= addr._addr.s6_addr16[4];
|
||||
result._addr.s6_addr16[5] ^= addr._addr.s6_addr16[5];
|
||||
result._addr.s6_addr16[6] ^= addr._addr.s6_addr16[6];
|
||||
result._addr.s6_addr16[7] ^= addr._addr.s6_addr16[7];
|
||||
#else
|
||||
result._addr.s6_addr32[0] ^= addr._addr.s6_addr32[0];
|
||||
result._addr.s6_addr32[1] ^= addr._addr.s6_addr32[1];
|
||||
result._addr.s6_addr32[2] ^= addr._addr.s6_addr32[2];
|
||||
result._addr.s6_addr32[3] ^= addr._addr.s6_addr32[3];
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -776,21 +692,10 @@ IPv6AddressImpl IPv6AddressImpl::operator ^ (const IPv6AddressImpl& addr) const
|
||||
IPv6AddressImpl IPv6AddressImpl::operator ~ () const
|
||||
{
|
||||
IPv6AddressImpl result(*this);
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
result._addr.s6_addr16[0] ^= 0xffff;
|
||||
result._addr.s6_addr16[1] ^= 0xffff;
|
||||
result._addr.s6_addr16[2] ^= 0xffff;
|
||||
result._addr.s6_addr16[3] ^= 0xffff;
|
||||
result._addr.s6_addr16[4] ^= 0xffff;
|
||||
result._addr.s6_addr16[5] ^= 0xffff;
|
||||
result._addr.s6_addr16[6] ^= 0xffff;
|
||||
result._addr.s6_addr16[7] ^= 0xffff;
|
||||
#else
|
||||
result._addr.s6_addr32[0] ^= 0xffffffff;
|
||||
result._addr.s6_addr32[1] ^= 0xffffffff;
|
||||
result._addr.s6_addr32[2] ^= 0xffffffff;
|
||||
result._addr.s6_addr32[3] ^= 0xffffffff;
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -25,52 +25,14 @@ namespace Net {
|
||||
|
||||
void Net_API initializeNetwork()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
WORD version = MAKEWORD(2, 2);
|
||||
WSADATA data;
|
||||
if (WSAStartup(version, &data) != 0)
|
||||
throw NetException("Failed to initialize network subsystem");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Net_API uninitializeNetwork()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_NO_AUTOMATIC_LIB_INIT)
|
||||
|
||||
struct NetworkInitializer
|
||||
/// Network initializer for windows statically
|
||||
/// linked library.
|
||||
{
|
||||
NetworkInitializer()
|
||||
/// Calls Poco::Net::initializeNetwork();
|
||||
{
|
||||
Poco::Net::initializeNetwork();
|
||||
}
|
||||
|
||||
~NetworkInitializer()
|
||||
/// Calls Poco::Net::uninitializeNetwork();
|
||||
{
|
||||
try
|
||||
{
|
||||
Poco::Net::uninitializeNetwork();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
poco_unexpected();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const NetworkInitializer pocoNetworkInitializer;
|
||||
|
||||
#endif
|
||||
|
@ -25,15 +25,6 @@
|
||||
#include "Poco/StringTokenizer.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/Format.h"
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(POCO_WIN32_UTF8)
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
#endif
|
||||
#include "Poco/Error.h"
|
||||
#include <wincrypt.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <ipifcons.h>
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
@ -123,12 +114,7 @@ public:
|
||||
bool running() const;
|
||||
bool up() const;
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
void setFlags(DWORD flags, DWORD iftype);
|
||||
void setRunning(bool running);
|
||||
#else
|
||||
void setFlags(short flags);
|
||||
#endif
|
||||
|
||||
void setUp(bool up);
|
||||
void setMTU(unsigned mtu);
|
||||
@ -443,40 +429,6 @@ inline bool NetworkInterfaceImpl::up() const
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
|
||||
|
||||
void NetworkInterfaceImpl::setFlags(DWORD flags, DWORD iftype)
|
||||
{
|
||||
_running = _up = false;
|
||||
switch (iftype) {
|
||||
case IF_TYPE_ETHERNET_CSMACD:
|
||||
case IF_TYPE_ISO88025_TOKENRING:
|
||||
case IF_TYPE_IEEE80211:
|
||||
_multicast = _broadcast = true;
|
||||
break;
|
||||
case IF_TYPE_SOFTWARE_LOOPBACK:
|
||||
_loopback = true;
|
||||
break;
|
||||
case IF_TYPE_PPP:
|
||||
case IF_TYPE_ATM:
|
||||
case IF_TYPE_TUNNEL:
|
||||
case IF_TYPE_IEEE1394:
|
||||
_pointToPoint = true;
|
||||
break;
|
||||
}
|
||||
if (!(flags & IP_ADAPTER_NO_MULTICAST))
|
||||
_multicast = true;
|
||||
}
|
||||
|
||||
|
||||
void NetworkInterfaceImpl::setRunning(bool running)
|
||||
{
|
||||
_running = running;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
void NetworkInterfaceImpl::setFlags(short flags)
|
||||
@ -492,7 +444,6 @@ void NetworkInterfaceImpl::setFlags(short flags)
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
inline void NetworkInterfaceImpl::setUp(bool up)
|
||||
@ -927,368 +878,7 @@ NetworkInterface::List NetworkInterface::list(bool ipOnly, bool upOnly)
|
||||
//
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
//
|
||||
// Windows
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Buffer.h"
|
||||
#include <iterator>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
IPAddress getBroadcastAddress(PIP_ADAPTER_PREFIX pPrefix, const IPAddress& addr, ULONG* pprefix = 0)
|
||||
/// This function relies on (1) subnet prefix being at the position
|
||||
/// immediately preceding and (2) broadcast address being at the position
|
||||
/// immediately succeeding the IPv4 unicast address.
|
||||
///
|
||||
/// Since there is no explicit guarantee on order, to ensure correctness,
|
||||
/// the above constraints are checked prior to returning the result.
|
||||
/// Additionally, on pre-Vista versions on Windows, the main structure does
|
||||
/// not contain prefix length; for those platforms, this function
|
||||
/// returns prefix through pprefix argument.
|
||||
{
|
||||
PIP_ADAPTER_PREFIX pPrev = 0;
|
||||
for (int i = 0; pPrefix; pPrefix = pPrefix->Next, ++i)
|
||||
{
|
||||
ADDRESS_FAMILY family = pPrefix->Address.lpSockaddr->sa_family;
|
||||
if ((family == AF_INET) && (addr == IPAddress(pPrefix->Address)))
|
||||
break;
|
||||
pPrev = pPrefix;
|
||||
}
|
||||
|
||||
if (pPrefix && pPrefix->Next && pPrev)
|
||||
{
|
||||
IPAddress ipPrefix(pPrev->PrefixLength, IPAddress::IPv4);
|
||||
IPAddress mask(pPrefix->Next->Address);
|
||||
if ((ipPrefix & mask) == (ipPrefix & addr))
|
||||
{
|
||||
if (pprefix) *pprefix = pPrefix->PrefixLength;
|
||||
return IPAddress(pPrefix->Next->Address);
|
||||
}
|
||||
}
|
||||
|
||||
return IPAddress(IPAddress::IPv4);
|
||||
}
|
||||
|
||||
|
||||
NetworkInterface::Type fromNative(DWORD type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case IF_TYPE_ETHERNET_CSMACD: return NetworkInterface::NI_TYPE_ETHERNET_CSMACD;
|
||||
case IF_TYPE_ISO88025_TOKENRING: return NetworkInterface::NI_TYPE_ISO88025_TOKENRING;
|
||||
case IF_TYPE_FRAMERELAY: return NetworkInterface::NI_TYPE_FRAMERELAY;
|
||||
case IF_TYPE_PPP: return NetworkInterface::NI_TYPE_PPP;
|
||||
case IF_TYPE_SOFTWARE_LOOPBACK: return NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK;
|
||||
case IF_TYPE_ATM: return NetworkInterface::NI_TYPE_ATM;
|
||||
case IF_TYPE_IEEE80211: return NetworkInterface::NI_TYPE_IEEE80211;
|
||||
case IF_TYPE_TUNNEL: return NetworkInterface::NI_TYPE_TUNNEL;
|
||||
case IF_TYPE_IEEE1394: return NetworkInterface::NI_TYPE_IEEE1394;
|
||||
default: return NetworkInterface::NI_TYPE_OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IPAddress subnetMaskForInterface(const std::string& name, bool isLoopback)
|
||||
{
|
||||
if (isLoopback)
|
||||
{
|
||||
return IPAddress::parse("255.0.0.0");
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(_WIN32_WCE)
|
||||
std::string subKey("SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters\\Interfaces\\");
|
||||
subKey += name;
|
||||
std::string netmask;
|
||||
HKEY hKey;
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
std::wstring usubKey;
|
||||
Poco::UnicodeConverter::toUTF16(subKey, usubKey);
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, usubKey.c_str(), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
||||
return IPAddress();
|
||||
wchar_t unetmask[16];
|
||||
DWORD size = sizeof(unetmask);
|
||||
if (RegQueryValueExW(hKey, L"DhcpSubnetMask", NULL, NULL, (LPBYTE)&unetmask, &size) != ERROR_SUCCESS)
|
||||
{
|
||||
if (RegQueryValueExW(hKey, L"SubnetMask", NULL, NULL, (LPBYTE)&unetmask, &size) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return IPAddress();
|
||||
}
|
||||
}
|
||||
Poco::UnicodeConverter::toUTF8(unetmask, netmask);
|
||||
#else
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, subKey.c_str(), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
||||
return IPAddress();
|
||||
char unetmask[16];
|
||||
DWORD size = sizeof(unetmask);
|
||||
if (RegQueryValueExA(hKey, "DhcpSubnetMask", NULL, NULL, (LPBYTE)&unetmask, &size) != ERROR_SUCCESS)
|
||||
{
|
||||
if (RegQueryValueExA(hKey, "SubnetMask", NULL, NULL, (LPBYTE)&unetmask, &size) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return IPAddress();
|
||||
}
|
||||
}
|
||||
netmask = unetmask;
|
||||
#endif
|
||||
RegCloseKey(hKey);
|
||||
return IPAddress::parse(netmask);
|
||||
#else
|
||||
return IPAddress();
|
||||
#endif // !defined(_WIN32_WCE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /// namespace
|
||||
|
||||
|
||||
NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
||||
{
|
||||
OSVERSIONINFO osvi;
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
GetVersionEx(&osvi);
|
||||
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
Map result;
|
||||
ULONG outBufLen = 16384;
|
||||
Poco::Buffer<UCHAR> memory(outBufLen);
|
||||
ULONG flags = (GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_INCLUDE_PREFIX);
|
||||
#ifdef GAA_FLAG_INCLUDE_ALL_INTERFACES
|
||||
flags |= GAA_FLAG_INCLUDE_ALL_INTERFACES;
|
||||
#endif
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
const unsigned family = AF_UNSPEC; //IPv4 and IPv6
|
||||
#else
|
||||
const unsigned family = AF_INET; //IPv4 only
|
||||
#endif
|
||||
DWORD dwRetVal = 0;
|
||||
ULONG iterations = 0;
|
||||
PIP_ADAPTER_ADDRESSES pAddress = 0;
|
||||
do
|
||||
{
|
||||
pAddress = reinterpret_cast<IP_ADAPTER_ADDRESSES*>(memory.begin()); // leave in the loop, begin may change after resize
|
||||
poco_assert (memory.capacity() >= outBufLen);
|
||||
if (ERROR_BUFFER_OVERFLOW == (dwRetVal = GetAdaptersAddresses(family, flags, 0, pAddress, &outBufLen)))
|
||||
memory.resize(outBufLen, false); // adjust size and try again
|
||||
else if (ERROR_NO_DATA == dwRetVal) // no network interfaces found
|
||||
return result;
|
||||
else if (NO_ERROR != dwRetVal) // error occurred
|
||||
throw SystemException(format("An error occurred while trying to obtain list of network interfaces: [%s]", Error::getMessage(dwRetVal)));
|
||||
else
|
||||
break;
|
||||
}
|
||||
while ((ERROR_BUFFER_OVERFLOW == dwRetVal) && (++iterations <= 2));
|
||||
|
||||
poco_assert (NO_ERROR == dwRetVal);
|
||||
for (; pAddress; pAddress = pAddress->Next)
|
||||
{
|
||||
IPAddress address;
|
||||
IPAddress subnetMask;
|
||||
IPAddress broadcastAddress;
|
||||
unsigned ifIndex = 0;
|
||||
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
#if defined(_WIN32_WCE)
|
||||
ifIndex = pAddress->Ipv6IfIndex;
|
||||
#elif (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100) // Win XP SP1
|
||||
#if defined (IP_ADAPTER_IPV6_ENABLED) // Vista
|
||||
if(osvi.dwMajorVersion>=6)//vista
|
||||
{
|
||||
if ((pAddress->Flags & IP_ADAPTER_IPV6_ENABLED) &&
|
||||
(osvi.dwMajorVersion >= 5) &&
|
||||
(osvi.dwMinorVersion >= 1) &&
|
||||
(osvi.dwBuildNumber >=1))
|
||||
{
|
||||
ifIndex = pAddress->Ipv6IfIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((osvi.dwMajorVersion >= 5) &&
|
||||
(osvi.dwMinorVersion >= 1) &&
|
||||
(osvi.dwBuildNumber >= 1))
|
||||
{
|
||||
ifIndex = pAddress->Ipv6IfIndex;
|
||||
}
|
||||
}
|
||||
#else // !defined(IP_ADAPTER_IPV6_ENABLED)
|
||||
if ((osvi.dwMajorVersion >= 5) &&
|
||||
(osvi.dwMinorVersion >= 1) &&
|
||||
(osvi.dwBuildNumber >= 1))
|
||||
{
|
||||
ifIndex = pAddress->Ipv6IfIndex;
|
||||
}
|
||||
#endif // defined(IP_ADAPTER_IPV6_ENABLED)
|
||||
#endif // (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100)
|
||||
#endif // POCO_HAVE_IPv6
|
||||
|
||||
#if defined (IP_ADAPTER_IPV4_ENABLED)
|
||||
if(osvi.dwMajorVersion>=6)
|
||||
{//vista
|
||||
if (pAddress->Flags & IP_ADAPTER_IPV4_ENABLED)
|
||||
{
|
||||
ifIndex = pAddress->IfIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ifIndex = pAddress->IfIndex;
|
||||
}
|
||||
#else // !IP_ADAPTER_IPV4_ENABLED
|
||||
ifIndex = pAddress->IfIndex;
|
||||
#endif
|
||||
if (ifIndex == 0) continue;
|
||||
|
||||
std::string name;
|
||||
std::string displayName;
|
||||
std::string adapterName(pAddress->AdapterName);
|
||||
#ifdef POCO_WIN32_UTF8
|
||||
Poco::UnicodeConverter::toUTF8(pAddress->FriendlyName, name);
|
||||
Poco::UnicodeConverter::toUTF8(pAddress->Description, displayName);
|
||||
#else
|
||||
char nameBuffer[1024];
|
||||
int rc = WideCharToMultiByte(CP_ACP, 0, pAddress->FriendlyName, -1, nameBuffer, sizeof(nameBuffer), NULL, NULL);
|
||||
if (rc) name = nameBuffer;
|
||||
char displayNameBuffer[1024];
|
||||
rc = WideCharToMultiByte(CP_ACP, 0, pAddress->Description, -1, displayNameBuffer, sizeof(displayNameBuffer), NULL, NULL);
|
||||
if (rc) displayName = displayNameBuffer;
|
||||
#endif
|
||||
|
||||
bool isUp = (pAddress->OperStatus == IfOperStatusUp);
|
||||
bool isIP = (0 != pAddress->FirstUnicastAddress);
|
||||
if (((ipOnly && isIP) || !ipOnly) && ((upOnly && isUp) || !upOnly))
|
||||
{
|
||||
NetworkInterface ni(name, displayName, adapterName, ifIndex);
|
||||
// Create interface even if it has an empty list of addresses; also, set
|
||||
// physical attributes which are protocol independent (name, media type,
|
||||
// MAC address, MTU, operational status, etc).
|
||||
Map::iterator ifIt = result.find(ifIndex);
|
||||
if (ifIt == result.end())
|
||||
ifIt = result.insert(Map::value_type(ifIndex, ni)).first;
|
||||
|
||||
ifIt->second.impl().setFlags(pAddress->Flags, pAddress->IfType);
|
||||
ifIt->second.impl().setMTU(pAddress->Mtu);
|
||||
ifIt->second.impl().setUp(pAddress->OperStatus == IfOperStatusUp);
|
||||
#if (_WIN32_WINNT >= 0x0600) // Vista and newer only
|
||||
if ((osvi.dwMajorVersion >= 6) &&
|
||||
(osvi.dwMinorVersion >= 0) &&
|
||||
(osvi.dwBuildNumber >= 0))
|
||||
{
|
||||
ifIt->second.impl().setRunning(pAddress->ReceiveLinkSpeed > 0 || pAddress->TransmitLinkSpeed > 0);
|
||||
}
|
||||
#endif
|
||||
ifIt->second.impl().setType(fromNative(pAddress->IfType));
|
||||
if (pAddress->PhysicalAddressLength)
|
||||
ifIt->second.impl().setMACAddress(pAddress->PhysicalAddress, pAddress->PhysicalAddressLength);
|
||||
|
||||
for (PIP_ADAPTER_UNICAST_ADDRESS pUniAddr = pAddress->FirstUnicastAddress;
|
||||
pUniAddr;
|
||||
pUniAddr = pUniAddr->Next)
|
||||
{
|
||||
address = IPAddress(pUniAddr->Address);
|
||||
ADDRESS_FAMILY family = pUniAddr->Address.lpSockaddr->sa_family;
|
||||
switch (family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
// Windows lists broadcast address on localhost
|
||||
bool hasBroadcast = (pAddress->IfType == IF_TYPE_ETHERNET_CSMACD) || (pAddress->IfType == IF_TYPE_SOFTWARE_LOOPBACK) || (pAddress->IfType == IF_TYPE_IEEE80211);
|
||||
if (hasBroadcast)
|
||||
{
|
||||
// On Windows, a valid broadcast address will be all 1's (== address | ~subnetMask); additionally, on pre-Vista versions of
|
||||
// OS, master address structure does not contain member for prefix length; we go an extra mile here in order to make sure
|
||||
// we reflect the actual values held by system and protect against misconfiguration (e.g. bad DHCP config entry)
|
||||
ULONG prefixLength = 0;
|
||||
#if defined(_WIN32_WCE)
|
||||
#if _WIN32_WCE >= 0x0800
|
||||
prefixLength = pUniAddr->OnLinkPrefixLength;
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address);
|
||||
#else
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
||||
#endif
|
||||
// if previous call did not do it, make last-ditch attempt for prefix and broadcast
|
||||
if (prefixLength == 0 && pAddress->FirstPrefix)
|
||||
prefixLength = pAddress->FirstPrefix->PrefixLength;
|
||||
poco_assert (prefixLength <= 32);
|
||||
if (broadcastAddress.isWildcard())
|
||||
{
|
||||
IPAddress mask(static_cast<unsigned>(prefixLength), IPAddress::IPv4);
|
||||
IPAddress host(mask & address);
|
||||
broadcastAddress = host | ~mask;
|
||||
}
|
||||
#elif (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100) // Win XP SP1
|
||||
#if (_WIN32_WINNT >= 0x0600) // Vista and newer
|
||||
if (osvi.dwMajorVersion >= 6)
|
||||
{
|
||||
prefixLength = pUniAddr->OnLinkPrefixLength;
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address);
|
||||
}
|
||||
else
|
||||
{
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
||||
}
|
||||
#else
|
||||
broadcastAddress = getBroadcastAddress(pAddress->FirstPrefix, address, &prefixLength);
|
||||
#endif
|
||||
poco_assert (prefixLength <= 32);
|
||||
if (broadcastAddress.isWildcard())
|
||||
{
|
||||
IPAddress mask(static_cast<unsigned>(prefixLength), IPAddress::IPv4);
|
||||
IPAddress host(mask & address);
|
||||
broadcastAddress = host | ~mask;
|
||||
}
|
||||
#endif // (_WIN32_WINNT >= 0x0501) && (NTDDI_VERSION >= 0x05010100)
|
||||
if (prefixLength)
|
||||
{
|
||||
subnetMask = IPAddress(static_cast<unsigned>(prefixLength), IPAddress::IPv4);
|
||||
}
|
||||
else // if all of the above fails, look up the subnet mask in the registry
|
||||
{
|
||||
address = IPAddress(&reinterpret_cast<struct sockaddr_in*>(pUniAddr->Address.lpSockaddr)->sin_addr, sizeof(in_addr));
|
||||
subnetMask = subnetMaskForInterface(name, address.isLoopback());
|
||||
if (!address.isLoopback())
|
||||
{
|
||||
broadcastAddress = address;
|
||||
broadcastAddress.mask(subnetMask, IPAddress::broadcast());
|
||||
}
|
||||
}
|
||||
ifIt->second.addAddress(address, subnetMask, broadcastAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
ifIt->second.addAddress(address);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
case AF_INET6:
|
||||
ifIt->second.addAddress(address);
|
||||
break;
|
||||
#endif
|
||||
} // switch family
|
||||
} // for addresses
|
||||
} // if ipOnly/upOnly
|
||||
} // for adapters
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
|
||||
#elif defined(POCO_OS_FAMILY_BSD) || (POCO_OS == POCO_OS_QNX) || (POCO_OS == POCO_OS_SOLARIS)
|
||||
#if defined(POCO_OS_FAMILY_BSD) || (POCO_OS == POCO_OS_QNX) || (POCO_OS == POCO_OS_SOLARIS)
|
||||
//
|
||||
// BSD variants, QNX(?) and Solaris
|
||||
//
|
||||
|
@ -21,11 +21,7 @@
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && _WIN32_WINNT >= 0x0600
|
||||
#ifndef POCO_HAVE_FD_POLL
|
||||
#define POCO_HAVE_FD_POLL 1
|
||||
#endif
|
||||
#elif defined(POCO_OS_FAMILY_BSD)
|
||||
#if defined(POCO_OS_FAMILY_BSD)
|
||||
#ifndef POCO_HAVE_FD_POLL
|
||||
#define POCO_HAVE_FD_POLL 1
|
||||
#endif
|
||||
@ -35,10 +31,8 @@
|
||||
#if defined(POCO_HAVE_FD_EPOLL)
|
||||
#include <sys/epoll.h>
|
||||
#elif defined(POCO_HAVE_FD_POLL)
|
||||
#ifndef _WIN32
|
||||
#include <poll.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -296,11 +290,7 @@ public:
|
||||
do
|
||||
{
|
||||
Poco::Timestamp start;
|
||||
#ifdef _WIN32
|
||||
rc = WSAPoll(&_pollfds[0], _pollfds.size(), static_cast<INT>(timeout.totalMilliseconds()));
|
||||
#else
|
||||
rc = ::poll(&_pollfds[0], _pollfds.size(), timeout.totalMilliseconds());
|
||||
#endif
|
||||
if (rc < 0 && SocketImpl::lastError() == POCO_EINTR)
|
||||
{
|
||||
Poco::Timestamp end;
|
||||
@ -330,10 +320,6 @@ public:
|
||||
result[its->second] |= PollSet::POLL_WRITE;
|
||||
if (it->revents & POLLERR)
|
||||
result[its->second] |= PollSet::POLL_ERROR;
|
||||
#ifdef _WIN32
|
||||
if (it->revents & POLLHUP)
|
||||
result[its->second] |= PollSet::POLL_READ;
|
||||
#endif
|
||||
}
|
||||
it->revents = 0;
|
||||
}
|
||||
|
@ -20,11 +20,7 @@
|
||||
#include <string.h> // FD_SET needs memset on some platforms, so we can't use <cstring>
|
||||
|
||||
|
||||
#if defined(_WIN32) && _WIN32_WINNT >= 0x0600
|
||||
#ifndef POCO_HAVE_FD_POLL
|
||||
#define POCO_HAVE_FD_POLL 1
|
||||
#endif
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#ifndef POCO_HAVE_FD_POLL
|
||||
#define POCO_HAVE_FD_POLL 1
|
||||
#endif
|
||||
@ -32,10 +28,8 @@
|
||||
|
||||
|
||||
#if defined(POCO_HAVE_FD_POLL)
|
||||
#ifndef _WIN32
|
||||
#include <poll.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(sun) || defined(__sun) || defined(__sun__)
|
||||
@ -44,9 +38,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef POCO_OS_FAMILY_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
using Poco::IOException;
|
||||
@ -64,13 +55,6 @@ bool checkIsBrokenTimeout()
|
||||
{
|
||||
#if defined(POCO_BROKEN_TIMEOUTS)
|
||||
return true;
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
// on Windows 7 and lower, socket timeouts have a minimum of 500ms, use poll for timeouts on this case
|
||||
// https://social.msdn.microsoft.com/Forums/en-US/76620f6d-22b1-4872-aaf0-833204f3f867/minimum-timeout-value-for-sorcvtimeo
|
||||
OSVERSIONINFO vi;
|
||||
vi.dwOSVersionInfoSize = sizeof(vi);
|
||||
if (GetVersionEx(&vi) == 0) return true; //throw SystemException("Cannot get OS version information");
|
||||
return vi.dwMajorVersion < 6 || (vi.dwMajorVersion == 6 && vi.dwMinorVersion < 2);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -445,11 +429,7 @@ bool SocketImpl::pollImpl(Poco::Timespan& remainingTime, int mode)
|
||||
do
|
||||
{
|
||||
Poco::Timestamp start;
|
||||
#ifdef _WIN32
|
||||
rc = WSAPoll(&pollBuf, 1, static_cast<INT>(remainingTime.totalMilliseconds()));
|
||||
#else
|
||||
rc = ::poll(&pollBuf, 1, remainingTime.totalMilliseconds());
|
||||
#endif
|
||||
/// Decrease timeout in case of retriable error.
|
||||
///
|
||||
/// But do this only if the timeout is positive,
|
||||
@ -550,12 +530,7 @@ int SocketImpl::getReceiveBufferSize()
|
||||
|
||||
void SocketImpl::setSendTimeout(const Poco::Timespan& timeout)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
int value = (int) timeout.totalMilliseconds();
|
||||
setOption(SOL_SOCKET, SO_SNDTIMEO, value);
|
||||
#else
|
||||
setOption(SOL_SOCKET, SO_SNDTIMEO, timeout);
|
||||
#endif
|
||||
_sndTimeout = timeout;
|
||||
}
|
||||
|
||||
@ -563,11 +538,7 @@ void SocketImpl::setSendTimeout(const Poco::Timespan& timeout)
|
||||
Poco::Timespan SocketImpl::getSendTimeout()
|
||||
{
|
||||
Timespan result;
|
||||
#if defined(_WIN32) && !defined(POCO_BROKEN_TIMEOUTS)
|
||||
int value;
|
||||
getOption(SOL_SOCKET, SO_SNDTIMEO, value);
|
||||
result = Timespan::TimeDiff(value)*1000;
|
||||
#elif !defined(POCO_BROKEN_TIMEOUTS)
|
||||
#if !defined(POCO_BROKEN_TIMEOUTS)
|
||||
getOption(SOL_SOCKET, SO_SNDTIMEO, result);
|
||||
#endif
|
||||
if (_isBrokenTimeout)
|
||||
@ -578,12 +549,7 @@ Poco::Timespan SocketImpl::getSendTimeout()
|
||||
|
||||
void SocketImpl::setReceiveTimeout(const Poco::Timespan& timeout)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
int value = (int) timeout.totalMilliseconds();
|
||||
setOption(SOL_SOCKET, SO_RCVTIMEO, value);
|
||||
#else
|
||||
setOption(SOL_SOCKET, SO_RCVTIMEO, timeout);
|
||||
#endif
|
||||
_recvTimeout = timeout;
|
||||
}
|
||||
|
||||
@ -591,11 +557,7 @@ void SocketImpl::setReceiveTimeout(const Poco::Timespan& timeout)
|
||||
Poco::Timespan SocketImpl::getReceiveTimeout()
|
||||
{
|
||||
Timespan result;
|
||||
#if defined(_WIN32) && !defined(POCO_BROKEN_TIMEOUTS)
|
||||
int value;
|
||||
getOption(SOL_SOCKET, SO_RCVTIMEO, value);
|
||||
result = Timespan::TimeDiff(value)*1000;
|
||||
#elif !defined(POCO_BROKEN_TIMEOUTS)
|
||||
#if !defined(POCO_BROKEN_TIMEOUTS)
|
||||
getOption(SOL_SOCKET, SO_RCVTIMEO, result);
|
||||
#endif
|
||||
if (_isBrokenTimeout)
|
||||
@ -905,22 +867,14 @@ void SocketImpl::initSocket(int af, int type, int proto)
|
||||
|
||||
void SocketImpl::ioctl(poco_ioctl_request_t request, int& arg)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
int rc = ioctlsocket(_sockfd, request, reinterpret_cast<u_long*>(&arg));
|
||||
#else
|
||||
int rc = ::ioctl(_sockfd, request, &arg);
|
||||
#endif
|
||||
if (rc != 0) error();
|
||||
}
|
||||
|
||||
|
||||
void SocketImpl::ioctl(poco_ioctl_request_t request, void* arg)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
int rc = ioctlsocket(_sockfd, request, reinterpret_cast<u_long*>(arg));
|
||||
#else
|
||||
int rc = ::ioctl(_sockfd, request, arg);
|
||||
#endif
|
||||
if (rc != 0) error();
|
||||
}
|
||||
|
||||
|
@ -31,13 +31,6 @@
|
||||
// Redis_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
# if defined(Redis_EXPORTS)
|
||||
# define Redis_API __declspec(dllexport)
|
||||
# else
|
||||
# define Redis_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(Redis_API)
|
||||
|
@ -482,23 +482,6 @@ namespace Util
|
||||
//
|
||||
// Macro to implement main()
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
# define POCO_APP_MAIN(App) \
|
||||
int wmain(int argc, wchar_t ** argv) \
|
||||
{ \
|
||||
Poco::AutoPtr<App> pApp = new App; \
|
||||
try \
|
||||
{ \
|
||||
pApp->init(argc, argv); \
|
||||
} \
|
||||
catch (Poco::Exception & exc) \
|
||||
{ \
|
||||
pApp->logger().log(exc); \
|
||||
return Poco::Util::Application::EXIT_CONFIG; \
|
||||
} \
|
||||
return pApp->run(); \
|
||||
}
|
||||
#else
|
||||
# define POCO_APP_MAIN(App) \
|
||||
int main(int argc, char ** argv) \
|
||||
{ \
|
||||
@ -514,7 +497,6 @@ namespace Util
|
||||
} \
|
||||
return pApp->run(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // Util_Application_INCLUDED
|
||||
|
@ -21,9 +21,6 @@
|
||||
#include "Poco/Event.h"
|
||||
#include "Poco/Util/Application.h"
|
||||
#include "Poco/Util/Util.h"
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# include "Poco/NamedEvent.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco
|
||||
@ -178,43 +175,6 @@ namespace Util
|
||||
# if POCO_OS == POCO_OS_ANDROID
|
||||
static Poco::Event _terminate;
|
||||
# endif
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
# if !defined(_WIN32_WCE)
|
||||
enum Action
|
||||
{
|
||||
SRV_RUN,
|
||||
SRV_REGISTER,
|
||||
SRV_UNREGISTER
|
||||
};
|
||||
static BOOL __stdcall ConsoleCtrlHandler(DWORD ctrlType);
|
||||
static void __stdcall ServiceControlHandler(DWORD control);
|
||||
# if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
static void __stdcall ServiceMain(DWORD argc, LPWSTR * argv);
|
||||
# else
|
||||
static void __stdcall ServiceMain(DWORD argc, LPTSTR * argv);
|
||||
# endif
|
||||
|
||||
bool hasConsole();
|
||||
bool isService();
|
||||
void beService();
|
||||
void registerService();
|
||||
void unregisterService();
|
||||
void handleRegisterService(const std::string & name, const std::string & value);
|
||||
void handleUnregisterService(const std::string & name, const std::string & value);
|
||||
void handleDisplayName(const std::string & name, const std::string & value);
|
||||
void handleDescription(const std::string & name, const std::string & value);
|
||||
void handleStartup(const std::string & name, const std::string & value);
|
||||
|
||||
Action _action;
|
||||
std::string _displayName;
|
||||
std::string _description;
|
||||
std::string _startup;
|
||||
|
||||
static Poco::Event _terminated;
|
||||
static SERVICE_STATUS _serviceStatus;
|
||||
static SERVICE_STATUS_HANDLE _serviceStatusHandle;
|
||||
# endif // _WIN32_WCE
|
||||
static Poco::NamedEvent _terminate;
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -226,22 +186,6 @@ namespace Util
|
||||
//
|
||||
// Macro to implement main()
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_WIN32_UTF8)
|
||||
# define POCO_SERVER_MAIN(App) \
|
||||
int wmain(int argc, wchar_t ** argv) \
|
||||
{ \
|
||||
try \
|
||||
{ \
|
||||
App app; \
|
||||
return app.run(argc, argv); \
|
||||
} \
|
||||
catch (Poco::Exception & exc) \
|
||||
{ \
|
||||
std::cerr << exc.displayText() << std::endl; \
|
||||
return Poco::Util::Application::EXIT_SOFTWARE; \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
# define POCO_SERVER_MAIN(App) \
|
||||
int main(int argc, char ** argv) \
|
||||
{ \
|
||||
@ -256,7 +200,6 @@ namespace Util
|
||||
return Poco::Util::Application::EXIT_SOFTWARE; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // Util_ServerApplication_INCLUDED
|
||||
|
@ -31,13 +31,6 @@
|
||||
// Util_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
# if defined(Util_EXPORTS)
|
||||
# define Util_API __declspec(dllexport)
|
||||
# else
|
||||
# define Util_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(Util_API)
|
||||
|
@ -35,9 +35,6 @@
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/ConsoleChannel.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/UnWindows.h"
|
||||
#endif
|
||||
#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
|
||||
#include "Poco/SignalHandler.h"
|
||||
#endif
|
||||
@ -436,25 +433,6 @@ void Application::getApplicationPath(Poco::Path& appPath) const
|
||||
appPath = Path(_workingDirAtLaunch, _command);
|
||||
appPath.makeAbsolute();
|
||||
}
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
wchar_t path[1024];
|
||||
int n = GetModuleFileNameW(0, path, sizeof(path)/sizeof(wchar_t));
|
||||
if (n > 0)
|
||||
{
|
||||
std::string p;
|
||||
Poco::UnicodeConverter::toUTF8(path, p);
|
||||
appPath = p;
|
||||
}
|
||||
else throw SystemException("Cannot get application file name.");
|
||||
#else
|
||||
char path[1024];
|
||||
int n = GetModuleFileNameA(0, path, sizeof(path));
|
||||
if (n > 0)
|
||||
appPath = path;
|
||||
else
|
||||
throw SystemException("Cannot get application file name.");
|
||||
#endif
|
||||
#else
|
||||
appPath = _command;
|
||||
#endif
|
||||
|
@ -31,13 +31,6 @@
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fstream>
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if !defined(_WIN32_WCE)
|
||||
#include "Poco/Util/WinService.h"
|
||||
#include "Poco/Util/WinRegistryKey.h"
|
||||
#endif
|
||||
#include "Poco/UnWindows.h"
|
||||
#include <cstring>
|
||||
#endif
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
@ -53,14 +46,6 @@ namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
Poco::NamedEvent ServerApplication::_terminate(Poco::ProcessImpl::terminationEventName(Poco::Process::id()));
|
||||
#if !defined(_WIN32_WCE)
|
||||
Poco::Event ServerApplication::_terminated;
|
||||
SERVICE_STATUS ServerApplication::_serviceStatus;
|
||||
SERVICE_STATUS_HANDLE ServerApplication::_serviceStatusHandle = 0;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(POCO_VXWORKS) || POCO_OS == POCO_OS_ANDROID
|
||||
Poco::Event ServerApplication::_terminate;
|
||||
#endif
|
||||
@ -68,12 +53,6 @@ Poco::Event ServerApplication::_terminate;
|
||||
|
||||
ServerApplication::ServerApplication()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if !defined(_WIN32_WCE)
|
||||
_action = SRV_RUN;
|
||||
std::memset(&_serviceStatus, 0, sizeof(_serviceStatus));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -97,9 +76,7 @@ int ServerApplication::run()
|
||||
|
||||
void ServerApplication::terminate()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
_terminate.set();
|
||||
#elif defined(POCO_VXWORKS) || POCO_OS == POCO_OS_ANDROID
|
||||
#if defined(POCO_VXWORKS) || POCO_OS == POCO_OS_ANDROID
|
||||
_terminate.set();
|
||||
#else
|
||||
Poco::Process::requestTermination(Process::id());
|
||||
@ -107,413 +84,7 @@ void ServerApplication::terminate()
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if !defined(_WIN32_WCE)
|
||||
|
||||
|
||||
//
|
||||
// Windows specific code
|
||||
//
|
||||
BOOL ServerApplication::ConsoleCtrlHandler(DWORD ctrlType)
|
||||
{
|
||||
switch (ctrlType)
|
||||
{
|
||||
case CTRL_C_EVENT:
|
||||
case CTRL_CLOSE_EVENT:
|
||||
case CTRL_BREAK_EVENT:
|
||||
terminate();
|
||||
return _terminated.tryWait(10000) ? TRUE : FALSE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ServerApplication::ServiceControlHandler(DWORD control)
|
||||
{
|
||||
switch (control)
|
||||
{
|
||||
case SERVICE_CONTROL_STOP:
|
||||
case SERVICE_CONTROL_SHUTDOWN:
|
||||
terminate();
|
||||
_serviceStatus.dwCurrentState = SERVICE_STOP_PENDING;
|
||||
break;
|
||||
case SERVICE_CONTROL_INTERROGATE:
|
||||
break;
|
||||
}
|
||||
SetServiceStatus(_serviceStatusHandle, &_serviceStatus);
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
void ServerApplication::ServiceMain(DWORD argc, LPWSTR* argv)
|
||||
#else
|
||||
void ServerApplication::ServiceMain(DWORD argc, LPTSTR* argv)
|
||||
#endif
|
||||
{
|
||||
ServerApplication& app = static_cast<ServerApplication&>(Application::instance());
|
||||
|
||||
app.config().setBool("application.runAsService", true);
|
||||
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
_serviceStatusHandle = RegisterServiceCtrlHandlerW(L"", ServiceControlHandler);
|
||||
#else
|
||||
_serviceStatusHandle = RegisterServiceCtrlHandlerA("", ServiceControlHandler);
|
||||
#endif
|
||||
if (!_serviceStatusHandle)
|
||||
throw SystemException("cannot register service control handler");
|
||||
|
||||
_serviceStatus.dwServiceType = SERVICE_WIN32;
|
||||
_serviceStatus.dwCurrentState = SERVICE_START_PENDING;
|
||||
_serviceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
|
||||
_serviceStatus.dwWin32ExitCode = 0;
|
||||
_serviceStatus.dwServiceSpecificExitCode = 0;
|
||||
_serviceStatus.dwCheckPoint = 0;
|
||||
_serviceStatus.dwWaitHint = 0;
|
||||
SetServiceStatus(_serviceStatusHandle, &_serviceStatus);
|
||||
|
||||
try
|
||||
{
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
std::vector<std::string> args;
|
||||
for (DWORD i = 0; i < argc; ++i)
|
||||
{
|
||||
std::string arg;
|
||||
Poco::UnicodeConverter::toUTF8(argv[i], arg);
|
||||
args.push_back(arg);
|
||||
}
|
||||
app.init(args);
|
||||
#else
|
||||
app.init(argc, argv);
|
||||
#endif
|
||||
_serviceStatus.dwCurrentState = SERVICE_RUNNING;
|
||||
SetServiceStatus(_serviceStatusHandle, &_serviceStatus);
|
||||
int rc = app.run();
|
||||
_serviceStatus.dwWin32ExitCode = rc ? ERROR_SERVICE_SPECIFIC_ERROR : 0;
|
||||
_serviceStatus.dwServiceSpecificExitCode = rc;
|
||||
}
|
||||
catch (Exception& exc)
|
||||
{
|
||||
app.logger().log(exc);
|
||||
_serviceStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
|
||||
_serviceStatus.dwServiceSpecificExitCode = EXIT_CONFIG;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
app.logger().error("fatal error - aborting");
|
||||
_serviceStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
|
||||
_serviceStatus.dwServiceSpecificExitCode = EXIT_SOFTWARE;
|
||||
}
|
||||
_serviceStatus.dwCurrentState = SERVICE_STOPPED;
|
||||
SetServiceStatus(_serviceStatusHandle, &_serviceStatus);
|
||||
}
|
||||
|
||||
|
||||
void ServerApplication::waitForTerminationRequest()
|
||||
{
|
||||
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
|
||||
_terminate.wait();
|
||||
_terminated.set();
|
||||
}
|
||||
|
||||
|
||||
int ServerApplication::run(int argc, char** argv)
|
||||
{
|
||||
if (!hasConsole() && isService())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int rc = EXIT_OK;
|
||||
try
|
||||
{
|
||||
init(argc, argv);
|
||||
switch (_action)
|
||||
{
|
||||
case SRV_REGISTER:
|
||||
registerService();
|
||||
rc = EXIT_OK;
|
||||
break;
|
||||
case SRV_UNREGISTER:
|
||||
unregisterService();
|
||||
rc = EXIT_OK;
|
||||
break;
|
||||
default:
|
||||
rc = run();
|
||||
}
|
||||
}
|
||||
catch (Exception& exc)
|
||||
{
|
||||
logger().log(exc);
|
||||
rc = EXIT_SOFTWARE;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ServerApplication::run(const std::vector<std::string>& args)
|
||||
{
|
||||
if (!hasConsole() && isService())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int rc = EXIT_OK;
|
||||
try
|
||||
{
|
||||
init(args);
|
||||
switch (_action)
|
||||
{
|
||||
case SRV_REGISTER:
|
||||
registerService();
|
||||
rc = EXIT_OK;
|
||||
break;
|
||||
case SRV_UNREGISTER:
|
||||
unregisterService();
|
||||
rc = EXIT_OK;
|
||||
break;
|
||||
default:
|
||||
rc = run();
|
||||
}
|
||||
}
|
||||
catch (Exception& exc)
|
||||
{
|
||||
logger().log(exc);
|
||||
rc = EXIT_SOFTWARE;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
int ServerApplication::run(int argc, wchar_t** argv)
|
||||
{
|
||||
if (!hasConsole() && isService())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int rc = EXIT_OK;
|
||||
try
|
||||
{
|
||||
init(argc, argv);
|
||||
switch (_action)
|
||||
{
|
||||
case SRV_REGISTER:
|
||||
registerService();
|
||||
rc = EXIT_OK;
|
||||
break;
|
||||
case SRV_UNREGISTER:
|
||||
unregisterService();
|
||||
rc = EXIT_OK;
|
||||
break;
|
||||
default:
|
||||
rc = run();
|
||||
}
|
||||
}
|
||||
catch (Exception& exc)
|
||||
{
|
||||
logger().log(exc);
|
||||
rc = EXIT_SOFTWARE;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool ServerApplication::isService()
|
||||
{
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
SERVICE_TABLE_ENTRYW svcDispatchTable[2];
|
||||
svcDispatchTable[0].lpServiceName = L"";
|
||||
svcDispatchTable[0].lpServiceProc = ServiceMain;
|
||||
svcDispatchTable[1].lpServiceName = 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 StartServiceCtrlDispatcherA(svcDispatchTable) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool ServerApplication::hasConsole()
|
||||
{
|
||||
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
return hStdOut != INVALID_HANDLE_VALUE && hStdOut != NULL;
|
||||
}
|
||||
|
||||
|
||||
void ServerApplication::registerService()
|
||||
{
|
||||
std::string name = config().getString("application.baseName");
|
||||
std::string path = config().getString("application.path");
|
||||
|
||||
WinService service(name);
|
||||
if (_displayName.empty())
|
||||
service.registerService(path);
|
||||
else
|
||||
service.registerService(path, _displayName);
|
||||
if (_startup == "auto")
|
||||
service.setStartup(WinService::SVC_AUTO_START);
|
||||
else if (_startup == "manual")
|
||||
service.setStartup(WinService::SVC_MANUAL_START);
|
||||
if (!_description.empty())
|
||||
service.setDescription(_description);
|
||||
logger().information("The application has been successfully registered as a service.");
|
||||
}
|
||||
|
||||
|
||||
void ServerApplication::unregisterService()
|
||||
{
|
||||
std::string name = config().getString("application.baseName");
|
||||
|
||||
WinService service(name);
|
||||
service.unregisterService();
|
||||
logger().information("The service has been successfully unregistered.");
|
||||
}
|
||||
|
||||
|
||||
void ServerApplication::defineOptions(OptionSet& options)
|
||||
{
|
||||
Application::defineOptions(options);
|
||||
|
||||
options.addOption(
|
||||
Option("registerService", "", "Register the application as a service.")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.callback(OptionCallback<ServerApplication>(this, &ServerApplication::handleRegisterService)));
|
||||
|
||||
options.addOption(
|
||||
Option("unregisterService", "", "Unregister the application as a service.")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.callback(OptionCallback<ServerApplication>(this, &ServerApplication::handleUnregisterService)));
|
||||
|
||||
options.addOption(
|
||||
Option("displayName", "", "Specify a display name for the service (only with /registerService).")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.argument("name")
|
||||
.callback(OptionCallback<ServerApplication>(this, &ServerApplication::handleDisplayName)));
|
||||
|
||||
options.addOption(
|
||||
Option("description", "", "Specify a description for the service (only with /registerService).")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.argument("text")
|
||||
.callback(OptionCallback<ServerApplication>(this, &ServerApplication::handleDescription)));
|
||||
|
||||
options.addOption(
|
||||
Option("startup", "", "Specify the startup mode for the service (only with /registerService).")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.argument("automatic|manual")
|
||||
.callback(OptionCallback<ServerApplication>(this, &ServerApplication::handleStartup)));
|
||||
}
|
||||
|
||||
|
||||
void ServerApplication::handleRegisterService(const std::string& name, const std::string& value)
|
||||
{
|
||||
_action = SRV_REGISTER;
|
||||
}
|
||||
|
||||
|
||||
void ServerApplication::handleUnregisterService(const std::string& name, const std::string& value)
|
||||
{
|
||||
_action = SRV_UNREGISTER;
|
||||
}
|
||||
|
||||
|
||||
void ServerApplication::handleDisplayName(const std::string& name, const std::string& value)
|
||||
{
|
||||
_displayName = value;
|
||||
}
|
||||
|
||||
|
||||
void ServerApplication::handleDescription(const std::string& name, const std::string& value)
|
||||
{
|
||||
_description = value;
|
||||
}
|
||||
|
||||
|
||||
void ServerApplication::handleStartup(const std::string& name, const std::string& value)
|
||||
{
|
||||
if (Poco::icompare(value, 4, std::string("auto")) == 0)
|
||||
_startup = "auto";
|
||||
else if (Poco::icompare(value, std::string("manual")) == 0)
|
||||
_startup = "manual";
|
||||
else
|
||||
throw InvalidArgumentException("argument to startup option must be 'auto[matic]' or 'manual'");
|
||||
}
|
||||
|
||||
|
||||
#else // _WIN32_WCE
|
||||
void ServerApplication::waitForTerminationRequest()
|
||||
{
|
||||
_terminate.wait();
|
||||
}
|
||||
|
||||
|
||||
int ServerApplication::run(int argc, char** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
init(argc, argv);
|
||||
}
|
||||
catch (Exception& exc)
|
||||
{
|
||||
logger().log(exc);
|
||||
return EXIT_CONFIG;
|
||||
}
|
||||
return run();
|
||||
}
|
||||
|
||||
|
||||
int ServerApplication::run(const std::vector<std::string>& args)
|
||||
{
|
||||
try
|
||||
{
|
||||
init(args);
|
||||
}
|
||||
catch (Exception& exc)
|
||||
{
|
||||
logger().log(exc);
|
||||
return EXIT_CONFIG;
|
||||
}
|
||||
return run();
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
|
||||
int ServerApplication::run(int argc, wchar_t** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
init(argc, argv);
|
||||
}
|
||||
catch (Exception& exc)
|
||||
{
|
||||
logger().log(exc);
|
||||
return EXIT_CONFIG;
|
||||
}
|
||||
return run();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _WIN32_WCE
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
|
||||
|
||||
//
|
||||
|
@ -31,13 +31,6 @@
|
||||
// XML_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
# if defined(XML_EXPORTS)
|
||||
# define XML_API __declspec(dllexport)
|
||||
# else
|
||||
# define XML_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(XML_API)
|
||||
|
@ -151,11 +151,7 @@ void XMLWriter::setNewLine(const std::string& newLineCharacters)
|
||||
{
|
||||
if (newLineCharacters.empty())
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
_newLine = NEWLINE_CRLF;
|
||||
#else
|
||||
_newLine = NEWLINE_LF;
|
||||
#endif
|
||||
}
|
||||
else _newLine = newLineCharacters;
|
||||
}
|
||||
|
@ -107,16 +107,6 @@
|
||||
|
||||
#include <limits.h> // ULONG_MAX
|
||||
|
||||
#if defined(_WIN32) && !defined(__USE_MINGW_ANSI_STDIO)
|
||||
# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u"
|
||||
# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u"
|
||||
# else
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
|
||||
# endif
|
||||
#else
|
||||
# define EXPAT_FMT_ULL(midpart) "%" midpart "llu"
|
||||
# if !defined(ULONG_MAX)
|
||||
# error Compiler did not define ULONG_MAX for us
|
||||
@ -127,7 +117,6 @@
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef UNUSED_P
|
||||
# define UNUSED_P(p) (void)p
|
||||
|
@ -61,12 +61,6 @@
|
||||
# define _GNU_SOURCE 1 /* syscall prototype */
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/* force stdlib to define rand_s() */
|
||||
# if ! defined(_CRT_RAND_S)
|
||||
# define _CRT_RAND_S
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
@ -83,8 +77,6 @@
|
||||
#if defined(EXPAT_POCO)
|
||||
# include "Poco/RandomStream.h"
|
||||
# include "Poco/BinaryReader.h"
|
||||
#elif defined(_WIN32)
|
||||
# define getpid GetCurrentProcessId
|
||||
#else
|
||||
# include <sys/time.h> /* gettimeofday() */
|
||||
# include <sys/types.h> /* getpid() */
|
||||
@ -122,9 +114,6 @@
|
||||
# include <bsd/stdlib.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && ! defined(LOAD_LIBRARY_SEARCH_SYSTEM32)
|
||||
# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
|
||||
#endif
|
||||
|
||||
#if ! defined(HAVE_GETRANDOM) && ! defined(HAVE_SYSCALL_GETRANDOM) \
|
||||
&& ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) \
|
||||
@ -833,52 +822,11 @@ writeRandomBytes_arc4random(void *target, size_t count) {
|
||||
|
||||
#endif /* defined(HAVE_ARC4RANDOM) && ! defined(HAVE_ARC4RANDOM_BUF) */
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Provide declaration of rand_s() for MinGW-32 (not 64, which has it),
|
||||
as it didn't declare it in its header prior to version 5.3.0 of its
|
||||
runtime package (mingwrt, containing stdlib.h). The upstream fix
|
||||
was introduced at https://osdn.net/projects/mingw/ticket/39658 . */
|
||||
# if defined(__MINGW32__) && defined(__MINGW32_VERSION) \
|
||||
&& __MINGW32_VERSION < 5003000L && ! defined(__MINGW64_VERSION_MAJOR)
|
||||
__declspec(dllimport) int rand_s(unsigned int *);
|
||||
# endif
|
||||
|
||||
/* Obtain entropy on Windows using the rand_s() function which
|
||||
* generates cryptographically secure random numbers. Internally it
|
||||
* uses RtlGenRandom API which is present in Windows XP and later.
|
||||
*/
|
||||
static int
|
||||
writeRandomBytes_rand_s(void *target, size_t count) {
|
||||
size_t bytesWrittenTotal = 0;
|
||||
|
||||
while (bytesWrittenTotal < count) {
|
||||
unsigned int random32 = 0;
|
||||
size_t i = 0;
|
||||
|
||||
if (rand_s(&random32))
|
||||
return 0; /* failure */
|
||||
|
||||
for (; (i < sizeof(random32)) && (bytesWrittenTotal < count);
|
||||
i++, bytesWrittenTotal++) {
|
||||
const uint8_t random8 = (uint8_t)(random32 >> (i * 8));
|
||||
((uint8_t *)target)[bytesWrittenTotal] = random8;
|
||||
}
|
||||
}
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#if ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM)
|
||||
|
||||
static unsigned long
|
||||
gather_time_entropy(void) {
|
||||
# ifdef _WIN32
|
||||
FILETIME ft;
|
||||
GetSystemTimeAsFileTime(&ft); /* never fails */
|
||||
return ft.dwHighDateTime ^ ft.dwLowDateTime;
|
||||
# else
|
||||
struct timeval tv;
|
||||
int gettimeofday_res;
|
||||
|
||||
@ -892,7 +840,6 @@ gather_time_entropy(void) {
|
||||
|
||||
/* Microseconds time is <20 bits entropy */
|
||||
return tv.tv_usec;
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif /* ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) */
|
||||
@ -927,11 +874,7 @@ generate_hash_secret_salt(XML_Parser parser) {
|
||||
return ENTROPY_DEBUG("arc4random", entropy);
|
||||
#else
|
||||
/* Try high quality providers first .. */
|
||||
# ifdef _WIN32
|
||||
if (writeRandomBytes_rand_s((void *)&entropy, sizeof(entropy))) {
|
||||
return ENTROPY_DEBUG("rand_s", entropy);
|
||||
}
|
||||
# elif defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM)
|
||||
# if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM)
|
||||
if (writeRandomBytes_getrandom_nonblock((void *)&entropy, sizeof(entropy))) {
|
||||
return ENTROPY_DEBUG("getrandom", entropy);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user