winpr: fix build on Linux
This commit is contained in:
parent
4d2bc6ba46
commit
913d532e0d
@ -302,6 +302,12 @@ extern "C" {
|
||||
WINPR_API BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern);
|
||||
WINPR_API LPSTR FilePatternFindNextWildcardA(LPCSTR lpPattern, DWORD* pFlags);
|
||||
|
||||
WINPR_API int UnixChangeFileMode(const char* filename, int flags);
|
||||
|
||||
WINPR_API char* GetNamedPipeNameWithoutPrefixA(LPCSTR lpName);
|
||||
WINPR_API char* GetNamedPipeUnixDomainSocketBaseFilePathA();
|
||||
WINPR_API char* GetNamedPipeUnixDomainSocketFilePathA(LPCSTR lpName);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -88,8 +88,8 @@ typedef DWORD HCALL;
|
||||
typedef int INT, *LPINT;
|
||||
typedef signed char INT8;
|
||||
typedef signed short INT16;
|
||||
typedef signed int INT32;
|
||||
#ifndef XMD_H
|
||||
typedef signed int INT32;
|
||||
typedef signed __int64 INT64;
|
||||
#endif
|
||||
typedef const WCHAR* LMCSTR;
|
||||
|
@ -31,7 +31,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SO
|
||||
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
|
||||
MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL
|
||||
MODULE winpr
|
||||
MODULES winpr-crt winpr-handle)
|
||||
MODULES winpr-crt winpr-handle winpr-path)
|
||||
|
||||
if(MONOLITHIC_BUILD)
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/path.h>
|
||||
#include <winpr/handle.h>
|
||||
|
||||
#include <winpr/file.h>
|
||||
@ -553,3 +554,72 @@ BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttrib
|
||||
|
||||
#endif
|
||||
|
||||
/* Extended API */
|
||||
|
||||
#define NAMED_PIPE_PREFIX_PATH "\\\\.\\pipe\\"
|
||||
|
||||
char* GetNamedPipeNameWithoutPrefixA(LPCSTR lpName)
|
||||
{
|
||||
char* lpFileName;
|
||||
|
||||
if (!lpName)
|
||||
return NULL;
|
||||
|
||||
if (strncmp(lpName, NAMED_PIPE_PREFIX_PATH, sizeof(NAMED_PIPE_PREFIX_PATH) - 1) != 0)
|
||||
return NULL;
|
||||
|
||||
lpFileName = _strdup(&lpName[strlen(NAMED_PIPE_PREFIX_PATH)]);
|
||||
|
||||
return lpFileName;
|
||||
}
|
||||
|
||||
char* GetNamedPipeUnixDomainSocketBaseFilePathA()
|
||||
{
|
||||
char* lpTempPath;
|
||||
char* lpPipePath;
|
||||
|
||||
lpTempPath = GetKnownPath(KNOWN_PATH_TEMP);
|
||||
lpPipePath = GetCombinedPath(lpTempPath, ".pipe");
|
||||
|
||||
free(lpTempPath);
|
||||
|
||||
return lpPipePath;
|
||||
}
|
||||
|
||||
char* GetNamedPipeUnixDomainSocketFilePathA(LPCSTR lpName)
|
||||
{
|
||||
char* lpPipePath;
|
||||
char* lpFileName;
|
||||
char* lpFilePath;
|
||||
|
||||
lpPipePath = GetNamedPipeUnixDomainSocketBaseFilePathA();
|
||||
|
||||
lpFileName = GetNamedPipeNameWithoutPrefixA(lpName);
|
||||
lpFilePath = GetCombinedPath(lpPipePath, (char*) lpFileName);
|
||||
|
||||
free(lpPipePath);
|
||||
free(lpFileName);
|
||||
|
||||
return lpFilePath;
|
||||
}
|
||||
|
||||
int UnixChangeFileMode(const char* filename, int flags)
|
||||
{
|
||||
mode_t fl = 0;
|
||||
|
||||
fl |= (flags & 0x4000) ? S_ISUID : 0;
|
||||
fl |= (flags & 0x2000) ? S_ISGID : 0;
|
||||
fl |= (flags & 0x1000) ? S_ISVTX : 0;
|
||||
fl |= (flags & 0x0400) ? S_IRUSR : 0;
|
||||
fl |= (flags & 0x0200) ? S_IWUSR : 0;
|
||||
fl |= (flags & 0x0100) ? S_IXUSR : 0;
|
||||
fl |= (flags & 0x0040) ? S_IRGRP : 0;
|
||||
fl |= (flags & 0x0020) ? S_IWGRP : 0;
|
||||
fl |= (flags & 0x0010) ? S_IXGRP : 0;
|
||||
fl |= (flags & 0x0004) ? S_IROTH : 0;
|
||||
fl |= (flags & 0x0002) ? S_IWOTH : 0;
|
||||
fl |= (flags & 0x0001) ? S_IXOTH : 0;
|
||||
|
||||
return chmod(filename, fl);
|
||||
}
|
||||
|
||||
|
@ -83,73 +83,6 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP
|
||||
* Named pipe
|
||||
*/
|
||||
|
||||
#define NAMED_PIPE_PREFIX_PATH "\\\\.\\pipe\\"
|
||||
|
||||
char* GetNamedPipeNameWithoutPrefixA(LPCSTR lpName)
|
||||
{
|
||||
char* lpFileName;
|
||||
|
||||
if (!lpName)
|
||||
return NULL;
|
||||
|
||||
if (strncmp(lpName, NAMED_PIPE_PREFIX_PATH, sizeof(NAMED_PIPE_PREFIX_PATH) - 1) != 0)
|
||||
return NULL;
|
||||
|
||||
lpFileName = _strdup(&lpName[strlen(NAMED_PIPE_PREFIX_PATH)]);
|
||||
|
||||
return lpFileName;
|
||||
}
|
||||
|
||||
char* GetNamedPipeUnixDomainSocketBaseFilePathA()
|
||||
{
|
||||
char* lpTempPath;
|
||||
char* lpPipePath;
|
||||
|
||||
lpTempPath = GetKnownPath(KNOWN_PATH_TEMP);
|
||||
lpPipePath = GetCombinedPath(lpTempPath, ".pipe");
|
||||
|
||||
free(lpTempPath);
|
||||
|
||||
return lpPipePath;
|
||||
}
|
||||
|
||||
char* GetNamedPipeUnixDomainSocketFilePathA(LPCSTR lpName)
|
||||
{
|
||||
char* lpPipePath;
|
||||
char* lpFileName;
|
||||
char* lpFilePath;
|
||||
|
||||
lpPipePath = GetNamedPipeUnixDomainSocketBaseFilePathA();
|
||||
|
||||
lpFileName = GetNamedPipeNameWithoutPrefixA(lpName);
|
||||
lpFilePath = GetCombinedPath(lpPipePath, (char*) lpFileName);
|
||||
|
||||
free(lpPipePath);
|
||||
free(lpFileName);
|
||||
|
||||
return lpFilePath;
|
||||
}
|
||||
|
||||
int UnixChangeMode(const char* filename, int flags)
|
||||
{
|
||||
mode_t fl = 0;
|
||||
|
||||
fl |= (flags & 0x4000) ? S_ISUID : 0;
|
||||
fl |= (flags & 0x2000) ? S_ISGID : 0;
|
||||
fl |= (flags & 0x1000) ? S_ISVTX : 0;
|
||||
fl |= (flags & 0x0400) ? S_IRUSR : 0;
|
||||
fl |= (flags & 0x0200) ? S_IWUSR : 0;
|
||||
fl |= (flags & 0x0100) ? S_IXUSR : 0;
|
||||
fl |= (flags & 0x0040) ? S_IRGRP : 0;
|
||||
fl |= (flags & 0x0020) ? S_IWGRP : 0;
|
||||
fl |= (flags & 0x0010) ? S_IXGRP : 0;
|
||||
fl |= (flags & 0x0004) ? S_IROTH : 0;
|
||||
fl |= (flags & 0x0002) ? S_IWOTH : 0;
|
||||
fl |= (flags & 0x0001) ? S_IXOTH : 0;
|
||||
|
||||
return chmod(filename, fl);
|
||||
}
|
||||
|
||||
HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances,
|
||||
DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||
{
|
||||
@ -209,7 +142,7 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD
|
||||
|
||||
if (status == 0)
|
||||
{
|
||||
UnixChangeMode(pNamedPipe->lpFilePath, 0xFFFF);
|
||||
UnixChangeFileMode(pNamedPipe->lpFilePath, 0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user