22char* strndup(
const char* __string,
size_t __n) {
23 size_t strsize =
strnlen(__string, __n);
24 char* newstr = (
char*)malloc(strsize + 1);
28 strncpy(newstr, __string, strsize);
55#if defined(_MSC_VER) || defined(DOXYGEN_RUN)
62#ifdef UPnPsdk_WITH_TRACE
63 std::cout <<
"TRACE[UPnPsdk/src/global.cpp:" << __LINE__ <<
"] " <<
this
64 <<
" Construct CWSAStartup\n";
67 int rc = ::WSAStartup(MAKEWORD(2, 2), &wsaData);
69 std::string err_str =
"UPnPsdk [" + std::string(__FUNCTION__) +
70 "] FATAL MSG1003: Failed to initialize "
71 "Windows Sockets, WSAStartup() returns (" +
72 std::to_string(rc) +
") \"" +
73 std::system_category().message(rc) +
"\"\n";
80 if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) {
84 "UPnPsdk [" + std::string(__FUNCTION__) +
85 "] FATAL MSG1131: Windows Sockets DLL must "
86 "support version 2.2 but it has " +
87 std::to_string(HIBYTE(wsaData.wVersion)) +
"." +
88 std::to_string(LOBYTE(wsaData.wVersion)) +
"\n";
105#ifdef UPnPsdk_WITH_TRACE
107 std::cout <<
"TRACE[UPnPsdk/src/global.cpp:" << __LINE__ <<
"] " <<
this
108 <<
" Destruct CWSAStartup"
126UPnPsdk_API
bool g_dbug{
false};
Initialize and cleanup Microsoft Windows Sockets.
Global used constants, variables, functions and macros.
static size_t strnlen(const char *s, size_t n)
strnlen() is a GNU extension and here provided for portability.
const CWSAStartup init_winsock
This object initialize and cleanup the Microsoft Windows Socket subsystem.
Reengineered Object Oriented UPnP+ program code.
UPnPsdk_EXTERN bool g_dbug
Switch to enable verbose (debug) output.
Specifications to be portable with sockets between different platforms.