mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
libfreerdp-core: fixed multiple windows porting issues
This commit is contained in:
@@ -60,7 +60,8 @@ endif()
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_X86_")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_X86_ -D_CRT_SECURE_NO_WARNINGS")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN")
|
||||
endif()
|
||||
|
||||
# Include files
|
||||
|
||||
@@ -90,7 +90,12 @@ set(LIBFREERDP_CORE_SRCS
|
||||
|
||||
add_library(freerdp-core SHARED ${LIBFREERDP_CORE_SRCS})
|
||||
|
||||
target_link_libraries(freerdp-core ${ZLIB_LIBRARIES})
|
||||
if(WIN32)
|
||||
target_link_libraries(freerdp-core ws2_32)
|
||||
else()
|
||||
target_link_libraries(freerdp-core ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
|
||||
target_link_libraries(freerdp-core ${OPENSSL_LIBRARIES})
|
||||
target_link_libraries(freerdp-core freerdp-utils)
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "registry.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
static char registry_dir[] = "freerdp";
|
||||
static char registry_file[] = "config.txt";
|
||||
|
||||
@@ -142,7 +144,11 @@ void registry_init(rdpRegistry* registry)
|
||||
|
||||
if (stat(registry->path, &stat_info) != 0)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
mkdir(registry->path, S_IRUSR | S_IWUSR | S_IXUSR);
|
||||
#else
|
||||
CreateDirectory(registry->path, 0);
|
||||
#endif
|
||||
printf("creating directory %s\n", registry->path);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,12 @@
|
||||
#ifndef _WIN32
|
||||
#include <netdb.h>
|
||||
#include <net/if.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#define socklen_t int
|
||||
#define close(_fd) closesocket(_fd)
|
||||
#endif
|
||||
|
||||
#include <freerdp/utils/print.h>
|
||||
@@ -195,6 +198,7 @@ boolean tcp_disconnect(rdpTcp * tcp)
|
||||
|
||||
boolean tcp_set_blocking_mode(rdpTcp* tcp, boolean blocking)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
int flags;
|
||||
flags = fcntl(tcp->sockfd, F_GETFL);
|
||||
|
||||
@@ -205,15 +209,15 @@ boolean tcp_set_blocking_mode(rdpTcp* tcp, boolean blocking)
|
||||
}
|
||||
|
||||
if (blocking == True)
|
||||
{
|
||||
/* blocking */
|
||||
fcntl(tcp->sockfd, F_SETFL, flags & ~(O_NONBLOCK));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* non-blocking */
|
||||
fcntl(tcp->sockfd, F_SETFL, flags | O_NONBLOCK);
|
||||
}
|
||||
#else
|
||||
u_long arg = blocking;
|
||||
ioctlsocket(tcp->sockfd, FIONBIO, &arg);
|
||||
tcp->wsa_event = WSACreateEvent();
|
||||
WSAEventSelect(tcp->sockfd, tcp->wsa_event, FD_READ);
|
||||
#endif
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
#ifndef __TCP_H
|
||||
#define __TCP_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <freerdp/types.h>
|
||||
#include <freerdp/settings.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
@@ -29,7 +34,6 @@
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct rdp_tcp rdpTcp;
|
||||
typedef boolean (*TcpConnect) (rdpTcp* tcp, const char* hostname, uint16 port);
|
||||
typedef boolean (*TcpDisconnect) (rdpTcp* tcp);
|
||||
@@ -44,6 +48,9 @@ struct rdp_tcp
|
||||
TcpConnect connect;
|
||||
TcpDisconnect disconnect;
|
||||
TcpSetBlockingMode set_blocking_mode;
|
||||
#ifdef _WIN32
|
||||
WSAEVENT wsa_event;
|
||||
#endif
|
||||
};
|
||||
|
||||
boolean tcp_connect(rdpTcp* tcp, const char* hostname, uint16 port);
|
||||
|
||||
@@ -19,12 +19,31 @@
|
||||
|
||||
#include <freerdp/utils/sleep.h>
|
||||
|
||||
#define _XOPEN_SOURCE 500
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#define _XOPEN_SOURCE 500
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
void freerdp_usleep(uint32 useconds)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
usleep(useconds);
|
||||
#else
|
||||
uint64 t1;
|
||||
uint64 t2;
|
||||
uint64 freq;
|
||||
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &t1);
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &freq);
|
||||
|
||||
do
|
||||
{
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &t2);
|
||||
}
|
||||
while((t2 - t1) < useconds);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
#include <freerdp/utils/thread.h>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
|
||||
Reference in New Issue
Block a user