winpr: fix compilation on Linux
This commit is contained in:
parent
1622a2f271
commit
fbd2f360e9
@ -24,7 +24,7 @@ set(${MODULE_PREFIX}_SRCS
|
||||
rdpsnd_main.c
|
||||
rdpsnd_main.h)
|
||||
|
||||
add_library(${MODULE_NAME} ${RDPSND_SRCS})
|
||||
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
|
||||
|
||||
if(WITH_MONOLITHIC_BUILD)
|
||||
@ -46,3 +46,4 @@ endif()
|
||||
if(WITH_MACAUDIO)
|
||||
add_subdirectory(MacAudio)
|
||||
endif()
|
||||
|
||||
|
@ -29,3 +29,4 @@ else()
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${MODULE_NAME}/Server")
|
||||
|
||||
|
@ -50,6 +50,11 @@ WINPR_API size_t _aligned_msize(void* memblock, size_t alignment, size_t offset)
|
||||
|
||||
WINPR_API void _aligned_free(void* memblock);
|
||||
|
||||
/* Buffer Manipulation */
|
||||
|
||||
WINPR_API errno_t memmove_s(void* dest, size_t numberOfElements, const void* src, size_t count);
|
||||
WINPR_API errno_t wmemmove_s(WCHAR* dest, size_t numberOfElements, const WCHAR* src, size_t count);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_CRT_H */
|
||||
|
@ -71,6 +71,9 @@ typedef short SHORT;
|
||||
#define CALLBACK
|
||||
|
||||
typedef void* HANDLE, *LPHANDLE;
|
||||
typedef HANDLE HINSTANCE;
|
||||
typedef HANDLE HMODULE;
|
||||
|
||||
typedef DWORD HCALL;
|
||||
typedef int INT, *LPINT;
|
||||
typedef signed char INT8;
|
||||
|
@ -20,6 +20,7 @@ set(MODULE_PREFIX "WINPR_CRT")
|
||||
|
||||
set(${MODULE_PREFIX}_SRCS
|
||||
alignment.c
|
||||
buffer.c
|
||||
memory.c
|
||||
string.c)
|
||||
|
||||
|
52
winpr/libwinpr/crt/buffer.c
Normal file
52
winpr/libwinpr/crt/buffer.c
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* WinPR: Windows Portable Runtime
|
||||
* Buffer Manipulation
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
|
||||
/* Buffer Manipulation: http://msdn.microsoft.com/en-us/library/b3893xdy/ */
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include <string.h>
|
||||
|
||||
errno_t memmove_s(void* dest, size_t numberOfElements, const void* src, size_t count)
|
||||
{
|
||||
if (count > numberOfElements)
|
||||
return -1;
|
||||
|
||||
memmove(dest, src, count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
errno_t wmemmove_s(WCHAR* dest, size_t numberOfElements, const WCHAR* src, size_t count)
|
||||
{
|
||||
if (count * 2 > numberOfElements)
|
||||
return -1;
|
||||
|
||||
memmove(dest, src, count * 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@ -36,7 +36,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SO
|
||||
if(WITH_MONOLITHIC_BUILD)
|
||||
|
||||
else()
|
||||
target_link_libraries(${MODULE_NAME} winpr-crt)
|
||||
target_link_libraries(${MODULE_NAME} winpr-crt winpr-handle winpr-synch)
|
||||
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/handle.h>
|
||||
|
||||
#include <winpr/interlocked.h>
|
||||
|
||||
/**
|
||||
@ -248,7 +251,7 @@ LONG InterlockedCompareExchange(LONG volatile *Destination, LONG Exchange, LONG
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#if (_WIN32_WINNT < 0x0502)
|
||||
#if (_WIN32 && (_WIN32_WINNT < 0x0502))
|
||||
|
||||
static volatile HANDLE mutex = NULL;
|
||||
|
||||
@ -262,7 +265,7 @@ int static_mutex_lock(volatile HANDLE* static_mutex)
|
||||
CloseHandle(handle);
|
||||
}
|
||||
|
||||
return WaitForSingleObject(*static_mutex, INFINITE) == WAIT_FAILED;
|
||||
return (WaitForSingleObject(*static_mutex, INFINITE) == WAIT_FAILED);
|
||||
}
|
||||
|
||||
/* Not available in XP */
|
||||
|
4
winpr/libwinpr/io/test/.gitignore
vendored
4
winpr/libwinpr/io/test/.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
TestIO
|
||||
TestIO.c
|
||||
TestIo
|
||||
TestIo.c
|
||||
|
||||
|
@ -34,8 +34,13 @@ endif()
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
|
||||
|
||||
if(WITH_MONOLITHIC_BUILD)
|
||||
|
||||
set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
|
||||
else()
|
||||
if(NOT WIN32)
|
||||
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} dl)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
|
@ -19,4 +19,6 @@ set(MODULE_NAME "TestLibraryA")
|
||||
|
||||
add_library(${MODULE_NAME} TestLibraryA.c)
|
||||
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test/Extra")
|
||||
|
@ -2,7 +2,9 @@
|
||||
#include <stdio.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/file.h>
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/windows.h>
|
||||
#include <winpr/library.h>
|
||||
|
||||
int TestLibraryAddDllDirectory(int argc, char* argv[])
|
||||
{
|
||||
|
@ -19,4 +19,6 @@ set(MODULE_NAME "TestLibraryB")
|
||||
|
||||
add_library(${MODULE_NAME} TestLibraryB.c)
|
||||
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test/Extra")
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <winpr/file.h>
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/windows.h>
|
||||
#include <winpr/library.h>
|
||||
|
||||
int TestLibraryFreeLibrary(int argc, char* argv[])
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/file.h>
|
||||
#include <winpr/path.h>
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/windows.h>
|
||||
#include <winpr/library.h>
|
||||
|
||||
int TestLibraryGetProcAddress(int argc, char* argv[])
|
||||
{
|
||||
@ -22,10 +22,9 @@ int TestLibraryGetProcAddress(int argc, char* argv[])
|
||||
MultiByteToWideChar(CP_UTF8, 0, str, length, (LPWSTR) BasePath, length * sizeof(WCHAR));
|
||||
BasePath[length] = 0;
|
||||
#else
|
||||
BasePath = _strdup(path);
|
||||
BasePath = _strdup(str);
|
||||
#endif
|
||||
|
||||
|
||||
_tprintf(_T("Base Path: %s\n"), BasePath);
|
||||
|
||||
PathAllocCombine(BasePath, _T("TestLibraryA\\TestLibraryA.dll"), 0, &LibraryPath);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <winpr/file.h>
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/windows.h>
|
||||
#include <winpr/library.h>
|
||||
|
||||
int TestLibraryLoadLibrary(int argc, char* argv[])
|
||||
{
|
||||
|
@ -2,7 +2,9 @@
|
||||
#include <stdio.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/file.h>
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/windows.h>
|
||||
#include <winpr/library.h>
|
||||
|
||||
int TestLibraryRemoveDllDirectory(int argc, char* argv[])
|
||||
{
|
||||
|
@ -2,7 +2,9 @@
|
||||
#include <stdio.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/file.h>
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/windows.h>
|
||||
#include <winpr/library.h>
|
||||
|
||||
int TestLibrarySetDefaultDllDirectories(int argc, char* argv[])
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SO
|
||||
if(WITH_MONOLITHIC_BUILD)
|
||||
|
||||
else()
|
||||
target_link_libraries(${MODULE_NAME} winpr-heap)
|
||||
target_link_libraries(${MODULE_NAME} winpr-crt winpr-heap)
|
||||
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
|
@ -181,6 +181,7 @@ HRESULT PathCchAddExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt)
|
||||
|
||||
HRESULT PathCchAddExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LPTCH pDot;
|
||||
BOOL bExtDot;
|
||||
LPTCH pBackslash;
|
||||
@ -215,7 +216,7 @@ HRESULT PathCchAddExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt)
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
@ -268,6 +269,7 @@ HRESULT PathCchAppendA(PSTR pszPath, size_t cchPath, PCSTR pszMore)
|
||||
|
||||
HRESULT PathCchAppendW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
BOOL pathBackslash;
|
||||
BOOL moreBackslash;
|
||||
size_t pszMoreLength;
|
||||
@ -309,6 +311,7 @@ HRESULT PathCchAppendW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore)
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
@ -435,6 +438,7 @@ HRESULT PathAllocCombineA(PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags,
|
||||
|
||||
HRESULT PathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags, PWSTR* ppszPathOut)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
PWSTR pszPathOut;
|
||||
BOOL backslashIn;
|
||||
BOOL backslashMore;
|
||||
@ -489,6 +493,7 @@ HRESULT PathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlag
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@ -583,7 +588,33 @@ HRESULT PathCchStripToRootW(PWSTR pszPath, size_t cchPath)
|
||||
|
||||
HRESULT PathCchStripPrefixA(PSTR pszPath, size_t cchPath)
|
||||
{
|
||||
return 0;
|
||||
BOOL hasPrefix;
|
||||
BOOL deviceNamespace;
|
||||
|
||||
if (!pszPath)
|
||||
return S_FALSE;
|
||||
|
||||
if (cchPath < 4)
|
||||
return S_FALSE;
|
||||
|
||||
hasPrefix = ((pszPath[0] == '\\') && (pszPath[1] == '\\') &&
|
||||
(pszPath[2] == '?') && (pszPath[3] == '\\')) ? TRUE : FALSE;
|
||||
|
||||
if (hasPrefix)
|
||||
{
|
||||
if (cchPath < 7)
|
||||
return S_FALSE;
|
||||
|
||||
deviceNamespace = ((pszPath[5] == ':') && (pszPath[6] == '\\')) ? TRUE : FALSE;
|
||||
|
||||
if (deviceNamespace)
|
||||
{
|
||||
memmove_s(pszPath, cchPath, &pszPath[4], cchPath - 4);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT PathCchStripPrefixW(PWSTR pszPath, size_t cchPath)
|
||||
|
@ -19,7 +19,7 @@ int TestPathIsUNCEx(int argc, char* argv[])
|
||||
|
||||
_tcscpy(Path, testPathUNC);
|
||||
|
||||
status = PathIsUNCEx(Path, &Server);
|
||||
status = PathIsUNCEx(Path, (LPTSTR*) &Server);
|
||||
|
||||
if (!status)
|
||||
{
|
||||
|
@ -46,9 +46,7 @@ endif()
|
||||
if(WITH_MONOLITHIC_BUILD)
|
||||
set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
|
||||
else()
|
||||
if(NOT WIN32)
|
||||
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-handle)
|
||||
endif()
|
||||
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-handle)
|
||||
|
||||
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
Loading…
Reference in New Issue
Block a user