From 7838e22477a727a98115d74f5374cbcc190ccf0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 3 Sep 2012 17:08:46 -0400 Subject: [PATCH] libfreerdp-core: improvements for C# bindings --- include/freerdp/settings.h | 45 +++++++++++++++++----------------- include/freerdp/utils/tcp.h | 3 +++ libfreerdp/core/capabilities.c | 2 +- libfreerdp/core/freerdp.c | 13 ++++++---- libfreerdp/core/transport.c | 1 + libfreerdp/utils/args.c | 1 + libfreerdp/utils/tcp.c | 19 ++++++++++++++ server/Windows/wfreerdp.c | 1 - 8 files changed, 56 insertions(+), 29 deletions(-) diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index ab37336ef..400a5c612 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -251,7 +251,7 @@ struct rdp_monitor struct rdp_settings { ALIGN64 void* instance; /* 0 */ - ALIGN64 uint64 paddingA[16 - 1]; /* 1 */ + uint64 paddingA[16 - 1]; /* 1 */ /* Core Protocol Parameters */ ALIGN64 uint32 width; /* 16 */ @@ -270,7 +270,7 @@ struct rdp_settings ALIGN64 boolean authentication; /* 29 */ ALIGN64 uint32 negotiationFlags; /* 30 */ ALIGN64 boolean security_layer_negotiation; /* 31 */ - ALIGN64 uint64 paddingB[48 - 32]; /* 32 */ + uint64 paddingB[48 - 32]; /* 32 */ /* Connection Settings */ ALIGN64 uint32 port; /* 48 */ @@ -299,7 +299,7 @@ struct rdp_settings ALIGN64 boolean send_preconnection_pdu; /* 71 */ ALIGN64 uint32 preconnection_id; /* 72 */ ALIGN64 char* preconnection_blob; /* 73 */ - ALIGN64 uint64 paddingC[80 - 74]; /* 74 */ + uint64 paddingC[80 - 74]; /* 74 */ /* User Interface Parameters */ ALIGN64 boolean sw_gdi; /* 80 */ @@ -311,7 +311,7 @@ struct rdp_settings ALIGN64 boolean mouse_motion; /* 86 */ ALIGN64 char* window_title; /* 87 */ ALIGN64 uint64 parent_window_xid; /* 88 */ - ALIGN64 uint64 paddingD[112 - 89]; /* 89 */ + uint64 paddingD[112 - 89]; /* 89 */ /* Internal Parameters */ ALIGN64 char* home_path; /* 112 */ @@ -323,7 +323,7 @@ struct rdp_settings ALIGN64 char* current_path; /* 118 */ ALIGN64 char* development_path; /* 119 */ ALIGN64 boolean development_mode; /* 120 */ - ALIGN64 uint64 paddingE[144 - 121]; /* 121 */ + uint64 paddingE[144 - 121]; /* 121 */ /* Security */ ALIGN64 boolean encryption; /* 144 */ @@ -332,7 +332,7 @@ struct rdp_settings ALIGN64 boolean rdp_security; /* 147 */ ALIGN64 uint32 ntlm_version; /* 148 */ ALIGN64 boolean salted_checksum; /* 149 */ - ALIGN64 uint64 paddingF[160 - 150]; /* 150 */ + uint64 paddingF[160 - 150]; /* 150 */ /* Session */ ALIGN64 boolean console_audio; /* 160 */ @@ -340,23 +340,23 @@ struct rdp_settings ALIGN64 uint32 redirected_session_id; /* 162 */ ALIGN64 boolean audio_playback; /* 163 */ ALIGN64 boolean audio_capture; /* 164 */ - ALIGN64 uint64 paddingG[176 - 165]; /* 165 */ + uint64 paddingG[176 - 165]; /* 165 */ /* Output Control */ ALIGN64 boolean refresh_rect; /* 176 */ ALIGN64 boolean suppress_output; /* 177 */ ALIGN64 boolean desktop_resize; /* 178 */ - ALIGN64 uint64 paddingH[192 - 179]; /* 179 */ + uint64 paddingH[192 - 179]; /* 179 */ /* Reconnection */ ALIGN64 boolean auto_reconnection; /* 192 */ ALIGN64 ARC_CS_PRIVATE_PACKET* client_auto_reconnect_cookie; /* 193 */ ALIGN64 ARC_SC_PRIVATE_PACKET* server_auto_reconnect_cookie; /* 194 */ - ALIGN64 uint64 paddingI[208 - 195]; /* 195 */ + uint64 paddingI[208 - 195]; /* 195 */ /* Time Zone */ ALIGN64 TIME_ZONE_INFO* client_time_zone; /* 208 */ - ALIGN64 uint64 paddingJ[216 - 209]; /* 209 */ + uint64 paddingJ[216 - 209]; /* 209 */ /* Capabilities */ ALIGN64 uint32 os_major_type; /* 216 */ @@ -376,7 +376,7 @@ struct rdp_settings ALIGN64 boolean disable_theming; /* 230 */ ALIGN64 uint32 connection_type; /* 231 */ ALIGN64 uint32 multifrag_max_request_size; /* 232 */ - ALIGN64 uint64 paddingK[248 - 233]; /* 233 */ + uint64 paddingK[248 - 233]; /* 233 */ /* Certificate */ ALIGN64 char* cert_file; /* 248 */ @@ -390,7 +390,7 @@ struct rdp_settings ALIGN64 char* rdp_key_file; /* 256 */ ALIGN64 rdpKey* server_key; /* 257 */ ALIGN64 char* certificate_name; /* 258 */ - ALIGN64 uint64 paddingL[280 - 259]; /* 259 */ + uint64 paddingL[280 - 259]; /* 259 */ /* Codecs */ ALIGN64 boolean rfx_codec; /* 280 */ @@ -403,27 +403,28 @@ struct rdp_settings ALIGN64 uint32 jpeg_codec_id; /* 287 */ ALIGN64 uint32 jpeg_quality; /* 288 */ ALIGN64 uint32 v3_codec_id; /* 289 */ - ALIGN64 uint64 paddingM[296 - 290]; /* 290 */ + ALIGN64 boolean rfx_codec_only; /* 290 */ + uint64 paddingM[296 - 291]; /* 291 */ /* Recording */ ALIGN64 boolean dump_rfx; /* 296 */ ALIGN64 boolean play_rfx; /* 297 */ ALIGN64 char* dump_rfx_file; /* 298 */ ALIGN64 char* play_rfx_file; /* 299 */ - ALIGN64 uint64 paddingN[312 - 300]; /* 300 */ + uint64 paddingN[312 - 300]; /* 300 */ /* RemoteApp */ ALIGN64 boolean remote_app; /* 312 */ ALIGN64 uint32 num_icon_caches; /* 313 */ ALIGN64 uint32 num_icon_cache_entries; /* 314 */ ALIGN64 boolean rail_langbar_supported; /* 315 */ - ALIGN64 uint64 paddingO[320 - 316]; /* 316 */ + uint64 paddingO[320 - 316]; /* 316 */ /* Pointer */ ALIGN64 boolean large_pointer; /* 320 */ ALIGN64 boolean color_pointer; /* 321 */ ALIGN64 uint32 pointer_cache_size; /* 322 */ - ALIGN64 uint64 paddingP[328 - 323]; /* 323 */ + uint64 paddingP[328 - 323]; /* 323 */ /* Bitmap Cache */ ALIGN64 boolean bitmap_cache; /* 328 */ @@ -431,35 +432,35 @@ struct rdp_settings ALIGN64 boolean persistent_bitmap_cache; /* 330 */ ALIGN64 uint32 bitmapCacheV2NumCells; /* 331 */ ALIGN64 BITMAP_CACHE_V2_CELL_INFO* bitmapCacheV2CellInfo; /* 332 */ - ALIGN64 uint64 paddingQ[344 - 333]; /* 333 */ + uint64 paddingQ[344 - 333]; /* 333 */ /* Offscreen Bitmap Cache */ ALIGN64 boolean offscreen_bitmap_cache; /* 344 */ ALIGN64 uint32 offscreen_bitmap_cache_size; /* 345 */ ALIGN64 uint32 offscreen_bitmap_cache_entries; /* 346 */ - ALIGN64 uint64 paddingR[352 - 347]; /* 347 */ + uint64 paddingR[352 - 347]; /* 347 */ /* Glyph Cache */ ALIGN64 boolean glyph_cache; /* 352 */ ALIGN64 uint32 glyphSupportLevel; /* 353 */ ALIGN64 GLYPH_CACHE_DEFINITION* glyphCache; /* 354 */ ALIGN64 GLYPH_CACHE_DEFINITION* fragCache; /* 355 */ - ALIGN64 uint64 paddingS[360 - 356]; /* 356 */ + uint64 paddingS[360 - 356]; /* 356 */ /* Draw Nine Grid */ ALIGN64 boolean draw_nine_grid; /* 360 */ ALIGN64 uint32 draw_nine_grid_cache_size; /* 361 */ ALIGN64 uint32 draw_nine_grid_cache_entries; /* 362 */ - ALIGN64 uint64 paddingT[368 - 363]; /* 363 */ + uint64 paddingT[368 - 363]; /* 363 */ /* Draw GDI+ */ ALIGN64 boolean draw_gdi_plus; /* 368 */ ALIGN64 boolean draw_gdi_plus_cache; /* 369 */ - ALIGN64 uint64 paddingU[376 - 370]; /* 370 */ + uint64 paddingU[376 - 370]; /* 370 */ /* Desktop Composition */ ALIGN64 boolean desktop_composition; /* 376 */ - ALIGN64 uint64 paddingV[384 - 377]; /* 377 */ + uint64 paddingV[384 - 377]; /* 377 */ /* Channels */ ALIGN64 int num_channels; diff --git a/include/freerdp/utils/tcp.h b/include/freerdp/utils/tcp.h index cad44dad7..5626c12eb 100644 --- a/include/freerdp/utils/tcp.h +++ b/include/freerdp/utils/tcp.h @@ -30,4 +30,7 @@ FREERDP_API int freerdp_tcp_disconnect(int sockfd); FREERDP_API int freerdp_tcp_set_no_delay(int sockfd, boolean no_delay); +FREERDP_API int freerdp_wsa_startup(); +FREERDP_API int freerdp_wsa_cleanup(); + #endif /* FREERDP_TCP_UTILS_H */ diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index 7c5ed657c..cb326a71c 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -1473,7 +1473,7 @@ void rdp_write_rfx_client_capability_container(STREAM* s, rdpSettings* settings) uint32 captureFlags; uint8 codecMode; - captureFlags = settings->dump_rfx ? 0 : CARDP_CAPS_CAPTURE_NON_CAC; + captureFlags = settings->rfx_codec_only ? CARDP_CAPS_CAPTURE_NON_CAC : 0; codecMode = settings->rfx_codec_mode; stream_write_uint16(s, 49); /* codecPropertiesLength */ diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 3d3ec3cc9..592c7ac5b 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -50,12 +50,14 @@ boolean freerdp_connect(freerdp* instance) { rdpRdp* rdp; + rdpSettings* settings; boolean status = false; /* We always set the return code to 0 before we start the connect sequence*/ connectErrorCode = 0; rdp = instance->context->rdp; + settings = instance->settings; IFCALLRET(instance->PreConnect, status, instance); @@ -67,7 +69,8 @@ boolean freerdp_connect(freerdp* instance) if (status != true) { - if(!connectErrorCode){ + if(!connectErrorCode) + { connectErrorCode = PREECONNECTERROR; } fprintf(stderr, "%s:%d: freerdp_pre_connect failed\n", __FILE__, __LINE__); @@ -75,8 +78,9 @@ boolean freerdp_connect(freerdp* instance) } status = rdp_client_connect(rdp); - // --authonly tests the connection without a UI - if (instance->settings->authentication_only) { + /* --authonly tests the connection without a UI */ + if (instance->settings->authentication_only) + { fprintf(stderr, "%s:%d: Authentication only, exit status %d\n", __FILE__, __LINE__, !status); return status; } @@ -191,7 +195,6 @@ boolean freerdp_disconnect(freerdp* instance) boolean freerdp_shall_disconnect(freerdp* instance) { - return instance->context->rdp->disconnect; } @@ -278,7 +281,7 @@ freerdp* freerdp_new() { freerdp* instance; - instance = xzalloc(sizeof(freerdp)); + instance = (freerdp*) xzalloc(sizeof(freerdp)); if (instance != NULL) { diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 4b2051e31..dee12e69f 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/libfreerdp/utils/args.c b/libfreerdp/utils/args.c index 481b45eaf..434119136 100644 --- a/libfreerdp/utils/args.c +++ b/libfreerdp/utils/args.c @@ -512,6 +512,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, } settings->dump_rfx_file = xstrdup(argv[index]); settings->dump_rfx = true; + settings->rfx_codec_only = true; } else if (strcmp("--play-rfx", argv[index]) == 0) { diff --git a/libfreerdp/utils/tcp.c b/libfreerdp/utils/tcp.c index b81cb7019..5bddb45d6 100644 --- a/libfreerdp/utils/tcp.c +++ b/libfreerdp/utils/tcp.c @@ -195,3 +195,22 @@ int freerdp_tcp_set_no_delay(int sockfd, boolean no_delay) return 0; } + +int freerdp_wsa_startup() +{ +#ifdef _WIN32 + WSADATA wsaData; + return WSAStartup(0x101, &wsaData); +#else + return 0; +#endif +} + +int freerdp_wsa_cleanup() +{ +#ifdef _WIN32 + return WSACleanup(); +#else + return 0; +#endif +} diff --git a/server/Windows/wfreerdp.c b/server/Windows/wfreerdp.c index 063542834..e28ee36d2 100644 --- a/server/Windows/wfreerdp.c +++ b/server/Windows/wfreerdp.c @@ -46,7 +46,6 @@ int g_thread_count = 0; static DWORD WINAPI wf_peer_socket_listener(LPVOID lpParam) { - wfInfo* wfi; int i, fds; int rcount; int max_fds;