diff options
author | Dale Stammen <dalestam@microsoft.com> | 2017-06-02 16:34:58 +0300 |
---|---|---|
committer | Anton Fedchin <anightik@gmail.com> | 2017-11-02 09:56:24 +0300 |
commit | fb49f7ac73c1a54c74fde639b9cbe19ea318e334 (patch) | |
tree | 7c77b83b887b85cc9003ba362648d99357e6e05f /lib | |
parent | 723824f79917348b62f25ed10f52089d12408553 (diff) |
[win10] uwp fixes libUPnP
Diffstat (limited to 'lib')
10 files changed, 70 insertions, 4 deletions
diff --git a/lib/libUPnP/CMakeLists.txt b/lib/libUPnP/CMakeLists.txt index a3aaa49e6f..81f526827e 100644 --- a/lib/libUPnP/CMakeLists.txt +++ b/lib/libUPnP/CMakeLists.txt @@ -70,7 +70,7 @@ set(SOURCES Platinum/Source/Core/PltAction.cpp Platinum/Source/Devices/MediaConnect/PltMediaConnect.cpp Neptune/Source/System/Posix/NptPosixEnvironment.cpp) -if(NOT CORE_SYSTEM_NAME STREQUAL windows) +if(NOT CORE_SYSTEM_NAME STREQUAL windows AND NOT CORE_SYSTEM_NAME STREQUAL windowsstore) list(APPEND SOURCES Neptune/Source/System/Posix/NptPosixSystem.cpp Neptune/Source/System/Posix/NptSelectableMessageQueue.cpp Neptune/Source/System/Posix/NptPosixQueue.cpp @@ -106,9 +106,13 @@ target_include_directories(upnp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} Platinum/Source/Extras Neptune/Source/Core Neptune/Source/System/Posix) -if(CORE_SYSTEM_NAME STREQUAL windows) +if(CORE_SYSTEM_NAME STREQUAL windows OR CORE_SYSTEM_NAME STREQUAL windowsstore) target_include_directories(upnp PRIVATE Neptune/Source/System/Win32) endif() set_target_properties(upnp PROPERTIES FOLDER lib) source_group_by_folder(upnp) set(core_DEPENDS upnp ${core_DEPENDS} CACHE STRING "" FORCE) + +if(CORE_SYSTEM_NAME STREQUAL windowsstore) + set_target_properties(upnp PROPERTIES STATIC_LIBRARY_FLAGS "/ignore:4264") +endif() diff --git a/lib/libUPnP/Neptune/Source/Core/NptConfig.h b/lib/libUPnP/Neptune/Source/Core/NptConfig.h index d51f67f94e..130d5cc33b 100644 --- a/lib/libUPnP/Neptune/Source/Core/NptConfig.h +++ b/lib/libUPnP/Neptune/Source/Core/NptConfig.h @@ -60,6 +60,11 @@ #define NPT_CONFIG_HAVE_GETENV #define NPT_CONFIG_HAVE_SETENV #define NPT_CONFIG_HAVE_UNSETENV +#if defined(TARGET_WINDOWS_STORE) +#undef NPT_CONFIG_HAVE_GETENV +#undef NPT_CONFIG_HAVE_SETENV +#undef NPT_CONFIG_HAVE_UNSETENV +#endif #define NPT_CONFIG_HAVE_READDIR_R #endif /* NPT_CONFIG_HAS_STD_C */ @@ -225,12 +230,20 @@ typedef long NPT_PointerLong; #define NPT_strncpy(d,s,c) strncpy_s(d,c+1,s,c) #define NPT_strcpy(d,s) strcpy_s(d,strlen(s)+1,s) #undef NPT_CONFIG_HAVE_GETENV +#ifdef TARGET_WINDOWS_STORE +#undef NPT_CONFIG_HAVE_GETENV +#undef NPT_CONFIG_HAVE_DUPENV_S +#undef NPT_CONFIG_HAVE_SETENV +#undef NPT_CONFIG_HAVE_UNSETENV +#undef NPT_CONFIG_HAVE_PUTENV_S +#else #define NPT_CONFIG_HAVE_DUPENV_S #define dupenv_s _dupenv_s #undef NPT_CONFIG_HAVE_SETENV #undef NPT_CONFIG_HAVE_UNSETENV #define NPT_CONFIG_HAVE_PUTENV_S #define putenv_s _putenv_s +#endif #else #undef NPT_CONFIG_HAVE_GMTIME_R #undef NPT_CONFIG_HAVE_LOCALTIME_R diff --git a/lib/libUPnP/Neptune/Source/Core/NptUtils.cpp b/lib/libUPnP/Neptune/Source/Core/NptUtils.cpp index a68a1afeaf..d98710dc12 100644 --- a/lib/libUPnP/Neptune/Source/Core/NptUtils.cpp +++ b/lib/libUPnP/Neptune/Source/Core/NptUtils.cpp @@ -44,6 +44,12 @@ #include <limits.h> #endif +#ifdef TARGET_WINDOWS_STORE +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include <windows.h> +#endif /*---------------------------------------------------------------------- | constants +---------------------------------------------------------------------*/ @@ -922,3 +928,27 @@ NPT_ParseMimeParameters(const char* encoded, return NPT_SUCCESS; } +#ifdef TARGET_WINDOWS_STORE +std::wstring win32ConvertUtf8ToW(const std::string &text) +{ + if (text.empty()) + { + return L""; + } + + int bufSize = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, text.c_str(), -1, NULL, 0); + if (bufSize == 0) + return L""; + wchar_t *converted = new wchar_t[bufSize]; + if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, text.c_str(), -1, converted, bufSize) != bufSize) + { + delete[] converted; + return L""; + } + + std::wstring Wret(converted); + delete[] converted; + + return Wret; +} +#endif diff --git a/lib/libUPnP/Neptune/Source/Core/NptUtils.h b/lib/libUPnP/Neptune/Source/Core/NptUtils.h index 3a06d497f4..89b2e29812 100644 --- a/lib/libUPnP/Neptune/Source/Core/NptUtils.h +++ b/lib/libUPnP/Neptune/Source/Core/NptUtils.h @@ -54,6 +54,9 @@ #include <stdarg.h> #endif +#if defined(TARGET_WINDOWS_STORE) +#include <string> +#endif /*---------------------------------------------------------------------- | macros +---------------------------------------------------------------------*/ @@ -225,4 +228,8 @@ extern void NPT_SetMemory(void* dest, int c, NPT_Size size); extern int NPT_MemoryEqual(const void* s1, const void* s2, unsigned long n); #endif +#if defined(TARGET_WINDOWS_STORE) +std::wstring win32ConvertUtf8ToW(const std::string &text); +#endif + #endif // _NPT_UTILS_H_ diff --git a/lib/libUPnP/Neptune/Source/System/Bsd/NptBsdSockets.cpp b/lib/libUPnP/Neptune/Source/System/Bsd/NptBsdSockets.cpp index ee86dbf4b0..a42dfbfb85 100644 --- a/lib/libUPnP/Neptune/Source/System/Bsd/NptBsdSockets.cpp +++ b/lib/libUPnP/Neptune/Source/System/Bsd/NptBsdSockets.cpp @@ -131,6 +131,7 @@ static NPT_WinsockSystem& WinsockInitializer = NPT_WinsockSystem::Initializer; #undef SetPort #endif +#ifndef TARGET_WINDOWS_STORE #define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEINPROGRESS #define ECONNREFUSED WSAECONNREFUSED @@ -142,6 +143,7 @@ static NPT_WinsockSystem& WinsockInitializer = NPT_WinsockSystem::Initializer; #define ENETDOWN WSAENETDOWN #define ENETUNREACH WSAENETUNREACH #define ENOTCONN WSAENOTCONN +#endif #if !defined(EAGAIN) #define EAGAIN WSAEWOULDBLOCK #define EINTR WSAEINTR diff --git a/lib/libUPnP/Neptune/Source/System/StdC/NptStdcEnvironment.cpp b/lib/libUPnP/Neptune/Source/System/StdC/NptStdcEnvironment.cpp index c9f9939d2b..f700b2212b 100644 --- a/lib/libUPnP/Neptune/Source/System/StdC/NptStdcEnvironment.cpp +++ b/lib/libUPnP/Neptune/Source/System/StdC/NptStdcEnvironment.cpp @@ -22,7 +22,7 @@ NPT_Result NPT_Environment::Get(const char* name, NPT_String& value) { - char* env; + char* env = nullptr; /* default value */ value.SetLength(0); diff --git a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32DynamicLibraries.cpp b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32DynamicLibraries.cpp index caaf6d1903..371aaf5ab9 100644 --- a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32DynamicLibraries.cpp +++ b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32DynamicLibraries.cpp @@ -97,7 +97,11 @@ NPT_DynamicLibrary::Load(const char* name, NPT_Flags flags, NPT_DynamicLibrary*& // load the lib NPT_LOG_FINE_2("loading library %s, flags=%x", name, flags); +#ifdef TARGET_WINDOWS_STORE + HMODULE handle = LoadPackagedLibrary(NPT_WIN32_A2W(name), NULL); +#else HMODULE handle = LoadLibraryW(NPT_WIN32_A2W(name)); +#endif if (handle == NULL) { NPT_LOG_FINE("library not found"); return NPT_FAILURE; diff --git a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.cpp b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.cpp index f415b851d5..d5ad0b953c 100644 --- a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.cpp +++ b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.cpp @@ -11,7 +11,7 @@ | includes +---------------------------------------------------------------------*/ #include "NptWin32MessageQueue.h" - +#ifndef TARGET_WINDOWS_STORE /*---------------------------------------------------------------------- | platform adaptation +---------------------------------------------------------------------*/ @@ -181,3 +181,4 @@ NPT_Win32WindowMessageQueue::HandleMessage(NPT_Message* message, return result; } +#endif // ! TARGET_WINDOWS_STORE diff --git a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.h b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.h index a5f846b016..1d84800586 100644 --- a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.h +++ b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.h @@ -10,6 +10,7 @@ #ifndef _NPT_WIN32_MESSAGE_QUEUE_ #define _NPT_WIN32_MESSAGE_QUEUE_ +#ifndef TARGET_WINDOWS_STORE /*---------------------------------------------------------------------- | includes +---------------------------------------------------------------------*/ @@ -45,5 +46,7 @@ private: HINSTANCE m_hInstance; }; +#endif // ! TARGET_WINDOWS_STORE + #endif // _NPT_WIN32_MESSAGE_QUEUE_ diff --git a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32SerialPort.cpp b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32SerialPort.cpp index 9428648bd7..4dfc23a603 100644 --- a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32SerialPort.cpp +++ b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32SerialPort.cpp @@ -17,6 +17,7 @@ #include "NptStrings.h" #include "NptLogging.h" +#ifndef TARGET_WINDOWS_STORE /*---------------------------------------------------------------------- | NPT_Win32HandletWrapper +---------------------------------------------------------------------*/ @@ -338,3 +339,4 @@ NPT_SerialPort::NPT_SerialPort(const char* name) { m_Delegate = new NPT_Win32SerialPort(name); } +#endif // ! TARGET_WINDOWS_STORE |