commit
1040492757
@ -58,6 +58,14 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_X86_")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFREERDP_EXPORTS")
|
||||
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
|
||||
check_include_files(sys/param.h HAVE_SYS_PARAM_H)
|
||||
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
|
||||
@ -106,7 +114,11 @@ endif()
|
||||
# Sub-directories
|
||||
add_subdirectory(include)
|
||||
add_subdirectory(libfreerdp-utils)
|
||||
add_subdirectory(libfreerdp-kbd)
|
||||
|
||||
if(NOT WIN32)
|
||||
add_subdirectory(libfreerdp-kbd)
|
||||
endif()
|
||||
|
||||
add_subdirectory(libfreerdp-gdi)
|
||||
add_subdirectory(libfreerdp-rail)
|
||||
add_subdirectory(libfreerdp-cache)
|
||||
|
@ -21,14 +21,16 @@
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
# Build DirectFB Client
|
||||
find_package(X11)
|
||||
if(X11_FOUND)
|
||||
add_subdirectory(X11)
|
||||
endif()
|
||||
if(NOT WIN32)
|
||||
# Build X11 Client
|
||||
find_package(X11)
|
||||
if(X11_FOUND)
|
||||
add_subdirectory(X11)
|
||||
endif()
|
||||
|
||||
# Build DirectFB Client
|
||||
find_package(DirectFB)
|
||||
if(DIRECTFB_FOUND)
|
||||
add_subdirectory(DirectFB)
|
||||
# Build DirectFB Client
|
||||
find_package(DirectFB)
|
||||
if(DIRECTFB_FOUND)
|
||||
add_subdirectory(DirectFB)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -17,12 +17,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <freerdp/gdi/gdi.h>
|
||||
#include <freerdp/utils/args.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <freerdp/types.h>
|
||||
#include <freerdp/utils/print.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
#include <freerdp/utils/hexdump.h>
|
||||
#include <freerdp/rfx/rfx.h>
|
||||
|
29
include/freerdp/utils/print.h
Normal file
29
include/freerdp/utils/print.h
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Print Utils
|
||||
*
|
||||
* Copyright 2011 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.
|
||||
*/
|
||||
|
||||
#ifndef __PRINT_UTILS_H
|
||||
#define __PRINT_UTILS_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
|
||||
#endif /* __PRINT_UTILS_H */
|
@ -55,15 +55,15 @@ void profiler_print_footer();
|
||||
#define PROFILER_PRINT(prof) profiler_print(prof)
|
||||
#define PROFILER_PRINT_FOOTER profiler_print_footer()
|
||||
#else
|
||||
#define IF_PROFILER(then)
|
||||
#define PROFILER_DEFINE(prof)
|
||||
#define PROFILER_CREATE(prof,name)
|
||||
#define PROFILER_FREE(prof)
|
||||
#define PROFILER_ENTER(prof)
|
||||
#define PROFILER_EXIT(prof)
|
||||
#define PROFILER_PRINT_HEADER
|
||||
#define PROFILER_PRINT(prof)
|
||||
#define PROFILER_PRINT_FOOTER
|
||||
#define IF_PROFILER(then) do { } while (0)
|
||||
#define PROFILER_DEFINE(prof) void* prof
|
||||
#define PROFILER_CREATE(prof,name) do { } while (0)
|
||||
#define PROFILER_FREE(prof) do { } while (0)
|
||||
#define PROFILER_ENTER(prof) do { } while (0)
|
||||
#define PROFILER_EXIT(prof) do { } while (0)
|
||||
#define PROFILER_PRINT_HEADER do { } while (0)
|
||||
#define PROFILER_PRINT(prof) do { } while (0)
|
||||
#define PROFILER_PRINT_FOOTER do { } while (0)
|
||||
#endif
|
||||
|
||||
#endif /* __UTILS_PROFILER_H */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Configuration Registry
|
||||
* Registry Utils
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
@ -17,8 +17,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __REGISTRY_H
|
||||
#define __REGISTRY_H
|
||||
#ifndef __REGISTRY_UTILS_H
|
||||
#define __REGISTRY_UTILS_H
|
||||
|
||||
typedef struct rdp_registry rdpRegistry;
|
||||
|
||||
@ -68,4 +68,4 @@ void registry_init(rdpRegistry* registry);
|
||||
rdpRegistry* registry_new(rdpSettings* settings);
|
||||
void registry_free(rdpRegistry* registry);
|
||||
|
||||
#endif /* __REGISTRY_H */
|
||||
#endif /* __REGISTRY_UTILS_H */
|
27
include/freerdp/utils/sleep.h
Normal file
27
include/freerdp/utils/sleep.h
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Sleep Utils
|
||||
*
|
||||
* Copyright 2011 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.
|
||||
*/
|
||||
|
||||
#ifndef __SLEEP_UTILS_H
|
||||
#define __SLEEP_UTILS_H
|
||||
|
||||
#include <freerdp/types.h>
|
||||
|
||||
void freerdp_usleep(uint32 useconds);
|
||||
|
||||
#endif /* __SLEEP_UTILS_H */
|
@ -28,5 +28,6 @@ add_library(freerdp-cache SHARED ${FREERDP_CACHE_SRCS})
|
||||
|
||||
set_target_properties(freerdp-cache PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION})
|
||||
|
||||
install(TARGETS freerdp-cache DESTINATION lib)
|
||||
target_link_libraries(freerdp-cache freerdp-utils)
|
||||
|
||||
install(TARGETS freerdp-cache DESTINATION lib)
|
||||
|
@ -112,7 +112,7 @@ void bitmap_v2_free(rdpBitmapV2* bitmap_v2)
|
||||
{
|
||||
for (i = 0; i < bitmap_v2->maxCells; i++)
|
||||
{
|
||||
for (j = 0; j < bitmap_v2->cells[i].number; j++)
|
||||
for (j = 0; j < (int) bitmap_v2->cells[i].number; j++)
|
||||
{
|
||||
if (bitmap_v2->cells[i].entries[j].entry != NULL)
|
||||
xfree(bitmap_v2->cells[i].entries[j].entry);
|
||||
|
@ -48,8 +48,6 @@ set(LIBFREERDP_CORE_SRCS
|
||||
license.h
|
||||
errinfo.c
|
||||
errinfo.h
|
||||
registry.c
|
||||
registry.h
|
||||
security.c
|
||||
security.h
|
||||
settings.c
|
||||
@ -90,7 +88,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)
|
||||
|
||||
|
@ -409,7 +409,7 @@ void RLEDECOMPRESS(uint8* pbSrcBuffer, uint32 cbSrcBuffer, uint8* pbDestBuffer,
|
||||
/* Watch out for the end of the first scanline. */
|
||||
if (fFirstLine)
|
||||
{
|
||||
if (pbDest - pbDestBuffer >= rowDelta)
|
||||
if ((uint32)(pbDest - pbDestBuffer) >= rowDelta)
|
||||
{
|
||||
fFirstLine = False;
|
||||
fInsertFgPel = False;
|
||||
|
@ -198,6 +198,7 @@ void rdp_write_bitmap_capability_set(STREAM* s, rdpSettings* settings)
|
||||
{
|
||||
uint8* header;
|
||||
uint8 drawingFlags;
|
||||
uint16 desktopResizeFlag;
|
||||
uint16 preferredBitsPerPixel;
|
||||
|
||||
header = rdp_capability_set_start(s);
|
||||
@ -209,6 +210,8 @@ void rdp_write_bitmap_capability_set(STREAM* s, rdpSettings* settings)
|
||||
else
|
||||
preferredBitsPerPixel = 8;
|
||||
|
||||
desktopResizeFlag = settings->desktop_resize;
|
||||
|
||||
stream_write_uint16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */
|
||||
stream_write_uint16(s, 1); /* receive1BitPerPixel (2 bytes) */
|
||||
stream_write_uint16(s, 1); /* receive4BitsPerPixel (2 bytes) */
|
||||
@ -216,7 +219,7 @@ void rdp_write_bitmap_capability_set(STREAM* s, rdpSettings* settings)
|
||||
stream_write_uint16(s, settings->width); /* desktopWidth (2 bytes) */
|
||||
stream_write_uint16(s, settings->height); /* desktopHeight (2 bytes) */
|
||||
stream_write_uint16(s, 0); /* pad2Octets (2 bytes) */
|
||||
stream_write_uint16(s, settings->desktop_resize); /* desktopResizeFlag (2 bytes) */
|
||||
stream_write_uint16(s, desktopResizeFlag); /* desktopResizeFlag (2 bytes) */
|
||||
stream_write_uint16(s, 1); /* bitmapCompressionFlag (2 bytes) */
|
||||
stream_write_uint8(s, 0); /* highColorFlags (1 byte) */
|
||||
stream_write_uint8(s, drawingFlags); /* drawingFlags (1 byte) */
|
||||
|
@ -113,7 +113,7 @@
|
||||
* @param cert X.509 certificate
|
||||
*/
|
||||
|
||||
void certificate_read_x509_certificate(CERT_BLOB* cert, CERT_INFO* info)
|
||||
void certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info)
|
||||
{
|
||||
STREAM* s;
|
||||
int length;
|
||||
@ -194,14 +194,14 @@ void certificate_read_x509_certificate(CERT_BLOB* cert, CERT_INFO* info)
|
||||
* @return new X.509 certificate chain
|
||||
*/
|
||||
|
||||
X509_CERT_CHAIN* certificate_new_x509_certificate_chain(uint32 count)
|
||||
rdpX509CertChain* certificate_new_x509_certificate_chain(uint32 count)
|
||||
{
|
||||
X509_CERT_CHAIN* x509_cert_chain;
|
||||
rdpX509CertChain* x509_cert_chain;
|
||||
|
||||
x509_cert_chain = (X509_CERT_CHAIN*) xmalloc(sizeof(X509_CERT_CHAIN));
|
||||
x509_cert_chain = (rdpX509CertChain*) xmalloc(sizeof(rdpX509CertChain));
|
||||
|
||||
x509_cert_chain->count = count;
|
||||
x509_cert_chain->array = (CERT_BLOB*) xzalloc(sizeof(CERT_BLOB) * count);
|
||||
x509_cert_chain->array = (rdpCertBlob*) xzalloc(sizeof(rdpCertBlob) * count);
|
||||
|
||||
return x509_cert_chain;
|
||||
}
|
||||
@ -211,14 +211,14 @@ X509_CERT_CHAIN* certificate_new_x509_certificate_chain(uint32 count)
|
||||
* @param x509_cert_chain X.509 certificate chain to be freed
|
||||
*/
|
||||
|
||||
void certificate_free_x509_certificate_chain(X509_CERT_CHAIN* x509_cert_chain)
|
||||
void certificate_free_x509_certificate_chain(rdpX509CertChain* x509_cert_chain)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (x509_cert_chain == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < x509_cert_chain->count; i++)
|
||||
for (i = 0; i < (int) x509_cert_chain->count; i++)
|
||||
{
|
||||
if (x509_cert_chain->array[i].data != NULL)
|
||||
xfree(x509_cert_chain->array[i].data);
|
||||
@ -256,7 +256,7 @@ void certificate_read_server_x509_certificate_chain(rdpCertificate* certificate,
|
||||
|
||||
certificate->x509_cert_chain = certificate_new_x509_certificate_chain(numCertBlobs);
|
||||
|
||||
for (i = 0; i < numCertBlobs; i++)
|
||||
for (i = 0; i < (int) numCertBlobs; i++)
|
||||
{
|
||||
stream_read_uint32(s, certLength);
|
||||
|
||||
@ -268,7 +268,7 @@ void certificate_read_server_x509_certificate_chain(rdpCertificate* certificate,
|
||||
|
||||
if (numCertBlobs - i == 2)
|
||||
{
|
||||
CERT_INFO cert_info;
|
||||
rdpCertInfo cert_info;
|
||||
DEBUG_CERTIFICATE("License Server Certificate");
|
||||
certificate_read_x509_certificate(&certificate->x509_cert_chain->array[i], &cert_info);
|
||||
DEBUG_LICENSE("modulus length:%d", cert_info.modulus.length);
|
||||
|
@ -37,35 +37,38 @@ typedef struct rdp_certificate rdpCertificate;
|
||||
#define CERT_PERMANENTLY_ISSUED 0x00000000
|
||||
#define CERT_TEMPORARILY_ISSUED 0x80000000
|
||||
|
||||
typedef struct
|
||||
struct rdp_CertBlob
|
||||
{
|
||||
uint32 length;
|
||||
uint8* data;
|
||||
} CERT_BLOB;
|
||||
};
|
||||
typedef struct rdp_CertBlob rdpCertBlob;
|
||||
|
||||
typedef struct
|
||||
struct rdp_X509CertChain
|
||||
{
|
||||
uint32 count;
|
||||
CERT_BLOB* array;
|
||||
} X509_CERT_CHAIN;
|
||||
rdpCertBlob* array;
|
||||
};
|
||||
typedef struct rdp_X509CertChain rdpX509CertChain;
|
||||
|
||||
typedef struct
|
||||
struct rdp_CertInfo
|
||||
{
|
||||
rdpBlob modulus;
|
||||
uint8 exponent[4];
|
||||
} CERT_INFO;
|
||||
};
|
||||
typedef struct rdp_CertInfo rdpCertInfo;
|
||||
|
||||
struct rdp_certificate
|
||||
{
|
||||
struct rdp_rdp* rdp;
|
||||
CERT_INFO cert_info;
|
||||
X509_CERT_CHAIN* x509_cert_chain;
|
||||
rdpCertInfo cert_info;
|
||||
rdpX509CertChain* x509_cert_chain;
|
||||
};
|
||||
|
||||
void certificate_read_x509_certificate(CERT_BLOB* cert, CERT_INFO* info);
|
||||
void certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info);
|
||||
|
||||
X509_CERT_CHAIN* certificate_new_x509_certificate_chain(uint32 count);
|
||||
void certificate_free_x509_certificate_chain(X509_CERT_CHAIN* x509_cert_chain);
|
||||
rdpX509CertChain* certificate_new_x509_certificate_chain(uint32 count);
|
||||
void certificate_free_x509_certificate_chain(rdpX509CertChain* x509_cert_chain);
|
||||
|
||||
void certificate_read_server_proprietary_certificate(rdpCertificate* certificate, STREAM* s);
|
||||
void certificate_read_server_x509_certificate_chain(rdpCertificate* certificate, STREAM* s);
|
||||
|
@ -20,6 +20,10 @@
|
||||
#ifndef __CRYPTO_H
|
||||
#define __CRYPTO_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "tcp.h"
|
||||
#endif
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/rc4.h>
|
||||
|
@ -148,7 +148,7 @@ STREAM* license_send_stream_init(rdpLicense* license)
|
||||
void license_send(rdpLicense* license, STREAM* s, uint8 type)
|
||||
{
|
||||
int length;
|
||||
uint16 flags;
|
||||
uint8 flags;
|
||||
uint16 wMsgSize;
|
||||
uint16 sec_flags;
|
||||
|
||||
@ -515,7 +515,7 @@ void license_free_binary_blob(LICENSE_BLOB* blob)
|
||||
|
||||
void license_read_scope_list(STREAM* s, SCOPE_LIST* scopeList)
|
||||
{
|
||||
int i;
|
||||
uint32 i;
|
||||
uint32 scopeCount;
|
||||
|
||||
stream_read_uint32(s, scopeCount); /* ScopeCount (4 bytes) */
|
||||
@ -556,7 +556,7 @@ SCOPE_LIST* license_new_scope_list()
|
||||
|
||||
void license_free_scope_list(SCOPE_LIST* scopeList)
|
||||
{
|
||||
int i;
|
||||
uint32 i;
|
||||
|
||||
for (i = 0; i < scopeList->count; i++)
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ void rdp_send_pdu(rdpRdp* rdp, STREAM* s, uint16 type, uint16 channel_id)
|
||||
transport_write(rdp->transport, s);
|
||||
}
|
||||
|
||||
void rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint16 type, uint16 channel_id)
|
||||
void rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint8 type, uint16 channel_id)
|
||||
{
|
||||
int length;
|
||||
|
||||
@ -523,7 +523,6 @@ rdpRdp* rdp_new(freerdp* instance)
|
||||
{
|
||||
rdp->licensed = False;
|
||||
rdp->settings = settings_new();
|
||||
rdp->registry = registry_new(rdp->settings);
|
||||
rdp->transport = transport_new(rdp->settings);
|
||||
rdp->license = license_new(rdp);
|
||||
rdp->input = input_new(rdp);
|
||||
|
@ -32,7 +32,6 @@ typedef struct rdp_rdp rdpRdp;
|
||||
#include "license.h"
|
||||
#include "errinfo.h"
|
||||
#include "security.h"
|
||||
#include "registry.h"
|
||||
#include "transport.h"
|
||||
#include "connection.h"
|
||||
#include "capabilities.h"
|
||||
@ -123,7 +122,6 @@ struct rdp_rdp
|
||||
struct rdp_fastpath* fastpath;
|
||||
struct rdp_license* license;
|
||||
struct rdp_settings* settings;
|
||||
struct rdp_registry* registry;
|
||||
struct rdp_transport* transport;
|
||||
struct rdp_vchan* vchan;
|
||||
};
|
||||
@ -144,7 +142,7 @@ STREAM* rdp_pdu_init(rdpRdp* rdp);
|
||||
void rdp_send_pdu(rdpRdp* rdp, STREAM* s, uint16 type, uint16 channel_id);
|
||||
|
||||
STREAM* rdp_data_pdu_init(rdpRdp* rdp);
|
||||
void rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint16 type, uint16 channel_id);
|
||||
void rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint8 type, uint16 channel_id);
|
||||
|
||||
void rdp_send(rdpRdp* rdp, STREAM* s, uint16 channel_id);
|
||||
void rdp_recv(rdpRdp* rdp);
|
||||
|
@ -23,13 +23,19 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#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 close(_fd) closesocket(_fd)
|
||||
#endif
|
||||
|
||||
#include <freerdp/utils/print.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
|
||||
@ -191,6 +197,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);
|
||||
|
||||
@ -201,15 +208,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,12 @@
|
||||
#ifndef __TCP_H
|
||||
#define __TCP_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <Windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include <freerdp/types.h>
|
||||
#include <freerdp/settings.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
@ -29,7 +35,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 +49,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);
|
||||
|
@ -20,11 +20,11 @@
|
||||
#ifndef __TLS_H
|
||||
#define __TLS_H
|
||||
|
||||
#include "crypto.h"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#include "crypto.h"
|
||||
|
||||
#include <freerdp/types.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
|
||||
|
@ -21,16 +21,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/utils/stream.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
#include <freerdp/utils/hexdump.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
@ -135,7 +136,7 @@ int transport_read(rdpTransport* transport, STREAM* s)
|
||||
|
||||
if (status == 0 && transport->blocking)
|
||||
{
|
||||
nanosleep(&transport->ts, NULL);
|
||||
freerdp_usleep(transport->usleep_interval);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -198,7 +199,7 @@ int transport_write(rdpTransport* transport, STREAM* s)
|
||||
if (status == 0)
|
||||
{
|
||||
/* blocking while sending */
|
||||
nanosleep(&transport->ts, NULL);
|
||||
freerdp_usleep(transport->usleep_interval);
|
||||
|
||||
/* when sending is blocked in nonblocking mode, the receiving buffer should be checked */
|
||||
if (!transport->blocking)
|
||||
@ -302,8 +303,7 @@ rdpTransport* transport_new(rdpSettings* settings)
|
||||
transport->settings = settings;
|
||||
|
||||
/* a small 0.1ms delay when transport is blocking. */
|
||||
transport->ts.tv_sec = 0;
|
||||
transport->ts.tv_nsec = 100000;
|
||||
transport->usleep_interval = 100;
|
||||
|
||||
/* receive buffer for non-blocking read. */
|
||||
transport->recv_buffer = stream_new(BUFFER_SIZE);
|
||||
|
@ -59,7 +59,7 @@ struct rdp_transport
|
||||
struct rdp_tls* tls;
|
||||
struct rdp_settings* settings;
|
||||
struct rdp_credssp* credssp;
|
||||
struct timespec ts;
|
||||
uint32 usleep_interval;
|
||||
void* recv_extra;
|
||||
STREAM* recv_buffer;
|
||||
TransportRecv recv_callback;
|
||||
|
@ -134,7 +134,7 @@ void update_read_palette(rdpUpdate* update, STREAM* s, PALETTE_UPDATE* palette_u
|
||||
palette_update->number = 256;
|
||||
|
||||
/* paletteEntries */
|
||||
for (i = 0; i < palette_update->number; i++)
|
||||
for (i = 0; i < (int) palette_update->number; i++)
|
||||
{
|
||||
stream_read_uint8(s, byte);
|
||||
color = byte;
|
||||
|
@ -55,7 +55,7 @@ boolean vchan_send(rdpVchan* vchan, uint16 channel_id, uint8* data, int size)
|
||||
{
|
||||
s = rdp_send_stream_init(vchan->instance->rdp);
|
||||
|
||||
if (size > vchan->instance->settings->vc_chunk_size)
|
||||
if (size > (int) vchan->instance->settings->vc_chunk_size)
|
||||
{
|
||||
chunk_size = vchan->instance->settings->vc_chunk_size;
|
||||
}
|
||||
|
@ -505,10 +505,10 @@ void gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt)
|
||||
if (brush->style & CACHED_BRUSH)
|
||||
{
|
||||
brush->data = brush_get(gdi->cache->brush, brush->index, &brush->bpp);
|
||||
brush->style = BS_PATTERN;
|
||||
brush->style = GDI_BS_PATTERN;
|
||||
}
|
||||
|
||||
if (brush->style == BS_SOLID)
|
||||
if (brush->style == GDI_BS_SOLID)
|
||||
{
|
||||
uint32 color;
|
||||
originalBrush = gdi->drawing->hdc->brush;
|
||||
@ -522,7 +522,7 @@ void gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt)
|
||||
gdi_DeleteObject((HGDIOBJECT) gdi->drawing->hdc->brush);
|
||||
gdi->drawing->hdc->brush = originalBrush;
|
||||
}
|
||||
else if (brush->style == BS_PATTERN)
|
||||
else if (brush->style == GDI_BS_PATTERN)
|
||||
{
|
||||
HGDI_BITMAP hBmp;
|
||||
|
||||
|
@ -26,4 +26,6 @@ add_library(freerdp-rail SHARED ${FREERDP_RAIL_SRCS})
|
||||
|
||||
set_target_properties(freerdp-rail PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION})
|
||||
|
||||
target_link_libraries(freerdp-rail freerdp-utils)
|
||||
|
||||
install(TARGETS freerdp-rail DESTINATION lib)
|
||||
|
@ -32,7 +32,9 @@ set(FREERDP_UTILS_SRCS
|
||||
mutex.c
|
||||
profiler.c
|
||||
rail.c
|
||||
registry.c
|
||||
semaphore.c
|
||||
sleep.c
|
||||
stopwatch.c
|
||||
stream.c
|
||||
svc_plugin.c
|
||||
@ -48,4 +50,8 @@ set_target_properties(freerdp-utils PROPERTIES VERSION ${FREERDP_VERSION_FULL} S
|
||||
|
||||
target_link_libraries(freerdp-utils ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(freerdp-utils ws2_32)
|
||||
endif()
|
||||
|
||||
install(TARGETS freerdp-utils DESTINATION lib)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <freerdp/settings.h>
|
||||
#include <freerdp/utils/print.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
#include <freerdp/utils/args.h>
|
||||
|
||||
@ -126,10 +127,10 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
|
||||
printf("missing width\n");
|
||||
return 0;
|
||||
}
|
||||
settings->width = strtol(argv[index], &p, 10);
|
||||
settings->width = (uint16) strtol(argv[index], &p, 10);
|
||||
if (*p == 'x')
|
||||
{
|
||||
settings->height = strtol(p + 1, &p, 10);
|
||||
settings->height = (uint16) strtol(p + 1, &p, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -294,13 +294,13 @@ uint8* dsp_encode_ima_adpcm(ADPCM* adpcm,
|
||||
{
|
||||
*dst++ = adpcm->last_sample[0] & 0xff;
|
||||
*dst++ = (adpcm->last_sample[0] >> 8) & 0xff;
|
||||
*dst++ = adpcm->last_step[0];
|
||||
*dst++ = (uint8) adpcm->last_step[0];
|
||||
*dst++ = 0;
|
||||
if (channels > 1)
|
||||
{
|
||||
*dst++ = adpcm->last_sample[1] & 0xff;
|
||||
*dst++ = (adpcm->last_sample[1] >> 8) & 0xff;
|
||||
*dst++ = adpcm->last_step[1];
|
||||
*dst++ = (uint8) adpcm->last_step[1];
|
||||
*dst++ = 0;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <freerdp/utils/print.h>
|
||||
#include <freerdp/utils/load_plugin.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Configuration Registry
|
||||
* Registry Utils
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
@ -17,7 +17,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "registry.h"
|
||||
#include <freerdp/utils/registry.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
static char registry_dir[] = "freerdp";
|
||||
static char registry_file[] = "config.txt";
|
||||
@ -142,7 +146,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);
|
||||
}
|
||||
|
49
libfreerdp-utils/sleep.c
Normal file
49
libfreerdp-utils/sleep.c
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Sleep Utils
|
||||
*
|
||||
* Copyright 2011 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.
|
||||
*/
|
||||
|
||||
#include <freerdp/utils/sleep.h>
|
||||
|
||||
#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
|
||||
}
|
@ -153,7 +153,7 @@ static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, uint3
|
||||
}
|
||||
|
||||
data_in = plugin->priv->data_in;
|
||||
stream_check_size(data_in, dataLength);
|
||||
stream_check_size(data_in, (int) dataLength);
|
||||
stream_write(data_in, pData, dataLength);
|
||||
|
||||
if (dataFlags & CHANNEL_FLAG_LAST)
|
||||
@ -283,8 +283,9 @@ static void svc_plugin_process_connected(rdpSvcPlugin* plugin, void* pData, uint
|
||||
{
|
||||
uint32 error;
|
||||
|
||||
error = plugin->channel_entry_points.pVirtualChannelOpen(plugin->priv->init_handle, &plugin->priv->open_handle,
|
||||
plugin->channel_def.name, svc_plugin_open_event);
|
||||
error = plugin->channel_entry_points.pVirtualChannelOpen(plugin->priv->init_handle,
|
||||
&plugin->priv->open_handle, plugin->channel_def.name, svc_plugin_open_event);
|
||||
|
||||
if (error != CHANNEL_RC_OK)
|
||||
{
|
||||
printf("svc_plugin_process_connected: open failed\n");
|
||||
|
@ -21,13 +21,15 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
#include <freerdp/utils/thread.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#include <freerdp/utils/sleep.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
#include <freerdp/utils/thread.h>
|
||||
|
||||
freerdp_thread* freerdp_thread_new(void)
|
||||
{
|
||||
freerdp_thread* thread;
|
||||
@ -61,17 +63,14 @@ void freerdp_thread_start(freerdp_thread* thread, void* func, void* arg)
|
||||
|
||||
void freerdp_thread_stop(freerdp_thread* thread)
|
||||
{
|
||||
struct timespec ts;
|
||||
int i;
|
||||
int i = 0;
|
||||
|
||||
wait_obj_set(thread->signals[0]);
|
||||
i = 0;
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 10000000;
|
||||
|
||||
while (thread->status > 0 && i < 1000)
|
||||
{
|
||||
i++;
|
||||
nanosleep(&ts, NULL);
|
||||
freerdp_usleep(100);
|
||||
}
|
||||
|
||||
for (i = 0; i < thread->num_signals; i++)
|
||||
|
@ -27,7 +27,7 @@
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
@ -133,7 +133,7 @@ void
|
||||
wait_obj_clear(struct wait_obj* obj)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
ResetEvent(chan_man->chan_event);
|
||||
ResetEvent(obj->event);
|
||||
#else
|
||||
int len;
|
||||
|
||||
@ -149,13 +149,15 @@ wait_obj_clear(struct wait_obj* obj)
|
||||
int
|
||||
wait_obj_select(struct wait_obj** listobj, int numobj, int timeout)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
int max;
|
||||
int rv;
|
||||
int index;
|
||||
int sock;
|
||||
struct timeval time;
|
||||
struct timeval * ptime;
|
||||
int index;
|
||||
#endif
|
||||
fd_set fds;
|
||||
int status;
|
||||
struct timeval time;
|
||||
struct timeval* ptime;
|
||||
|
||||
ptime = 0;
|
||||
if (timeout >= 0)
|
||||
@ -164,6 +166,8 @@ wait_obj_select(struct wait_obj** listobj, int numobj, int timeout)
|
||||
time.tv_usec = (timeout * 1000) % 1000000;
|
||||
ptime = &time;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
max = 0;
|
||||
FD_ZERO(&fds);
|
||||
if (listobj)
|
||||
@ -172,14 +176,17 @@ wait_obj_select(struct wait_obj** listobj, int numobj, int timeout)
|
||||
{
|
||||
sock = listobj[index]->pipe_fd[0];
|
||||
FD_SET(sock, &fds);
|
||||
|
||||
if (sock > max)
|
||||
{
|
||||
max = sock;
|
||||
}
|
||||
}
|
||||
}
|
||||
rv = select(max + 1, &fds, 0, 0, ptime);
|
||||
return rv;
|
||||
status = select(max + 1, &fds, 0, 0, ptime);
|
||||
#else
|
||||
status = select(0, &fds, 0, 0, ptime);
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void wait_obj_get_fds(struct wait_obj* obj, void** fds, int* count)
|
||||
|
Loading…
Reference in New Issue
Block a user