diff --git a/channels/cliprdr/client/CMakeLists.txt b/channels/cliprdr/client/CMakeLists.txt index bd465b4eb..8a617b880 100644 --- a/channels/cliprdr/client/CMakeLists.txt +++ b/channels/cliprdr/client/CMakeLists.txt @@ -36,9 +36,9 @@ add_library(${MODULE_NAME} STATIC ${${MODULE_PREFIX}_SRCS}) set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") if(MONOLITHIC_BUILD) - target_link_libraries(${MODULE_NAME} freerdp) + target_link_libraries(${MODULE_NAME} freerdp winpr) else() - target_link_libraries(${MODULE_NAME} freerdp-utils) + target_link_libraries(${MODULE_NAME} freerdp-utils winpr-crt) endif() install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH}) diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c index 119e41798..59f02a728 100644 --- a/channels/cliprdr/client/cliprdr_format.c +++ b/channels/cliprdr/client/cliprdr_format.c @@ -25,6 +25,9 @@ #include #include #include + +#include + #include #include #include @@ -138,7 +141,7 @@ void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint3 if (ascii) { - format_name->name = xstrdup((char*) s->p); + format_name->name = _strdup((char*) s->p); format_name->length = strlen(format_name->name); } else diff --git a/channels/disk/client/disk_main.c b/channels/disk/client/disk_main.c index 9a216487a..73b906525 100644 --- a/channels/disk/client/disk_main.c +++ b/channels/disk/client/disk_main.c @@ -718,7 +718,7 @@ const int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) if( path[0] == '%' ) { _snprintf(buf, sizeof(buf), "%s\\", getenv("USERPROFILE")); - disk_register_disk_path(pEntryPoints, name, xstrdup(buf)); + disk_register_disk_path(pEntryPoints, name, _strdup(buf)); } else if( path[0] == '*' ) { @@ -738,7 +738,7 @@ const int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) buf[len + 1] = dev[0]; buf[len + 2] = 0; buf[len + 3] = 0; - disk_register_disk_path(pEntryPoints, xstrdup(buf), xstrdup(dev)); + disk_register_disk_path(pEntryPoints, _strdup(buf), _strdup(dev)); } } } diff --git a/channels/drdynvc/client/dvcman.c b/channels/drdynvc/client/dvcman.c index f87aa935c..53418ae93 100644 --- a/channels/drdynvc/client/dvcman.c +++ b/channels/drdynvc/client/dvcman.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -108,7 +109,7 @@ static int dvcman_create_listener(IWTSVirtualChannelManager* pChannelMgr, listener = xnew(DVCMAN_LISTENER); listener->iface.GetConfiguration = dvcman_get_configuration; listener->dvcman = dvcman; - listener->channel_name = xstrdup(pszChannelName); + listener->channel_name = _strdup(pszChannelName); listener->flags = ulFlags; listener->listener_callback = pListenerCallback; diff --git a/channels/printer/client/printer_cups.c b/channels/printer/client/printer_cups.c index 296ed78db..30bf5cf3f 100644 --- a/channels/printer/client/printer_cups.c +++ b/channels/printer/client/printer_cups.c @@ -29,6 +29,8 @@ #include #include +#include + #include #include #include @@ -152,7 +154,7 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, uint32 id) #ifndef _CUPS_API_1_4 - cups_printjob->printjob_object = xstrdup(tmpnam(NULL)); + cups_printjob->printjob_object = _strdup(tmpnam(NULL)); #else { @@ -218,7 +220,7 @@ static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver, c cups_printer = xnew(rdpCupsPrinter); cups_printer->printer.id = cups_driver->id_sequence++; - cups_printer->printer.name = xstrdup(name); + cups_printer->printer.name = _strdup(name); /* This is a generic PostScript printer driver developed by MS, so it should be good in most cases */ cups_printer->printer.driver = "MS Publisher Imagesetter"; cups_printer->printer.is_default = is_default; diff --git a/channels/printer/client/printer_win.c b/channels/printer/client/printer_win.c index a7db9c94c..f61ee3294 100644 --- a/channels/printer/client/printer_win.c +++ b/channels/printer/client/printer_win.c @@ -17,18 +17,22 @@ * limitations under the License. */ -#include -#include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include #include #include #include -#include +#include -#include "config.h" #include #include -#include "rdpdr_types.h" #include "printer_main.h" #include "printer_win.h" @@ -179,7 +183,7 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, cons win_printer = xnew(rdpWinPrinter); win_printer->printer.id = win_driver->id_sequence++; - win_printer->printer.name = xstrdup(name); + win_printer->printer.name = _strdup(name); win_printer->printer.is_default = is_default; win_printer->printer.CreatePrintJob = printer_win_create_printjob; diff --git a/channels/rdpsnd/client/alsa/CMakeLists.txt b/channels/rdpsnd/client/alsa/CMakeLists.txt index 1d50df6bc..1f9db48b2 100644 --- a/channels/rdpsnd/client/alsa/CMakeLists.txt +++ b/channels/rdpsnd/client/alsa/CMakeLists.txt @@ -18,8 +18,7 @@ # limitations under the License. set(RDPSND_ALSA_SRCS - rdpsnd_alsa.c -) + rdpsnd_alsa.c) include_directories(..) include_directories(${ALSA_INCLUDE_DIRS}) @@ -28,9 +27,9 @@ add_library(rdpsnd_alsa ${RDPSND_ALSA_SRCS}) set_target_properties(rdpsnd_alsa PROPERTIES PREFIX "") if(MONOLITHIC_BUILD) - target_link_libraries(rdpsnd_alsa freerdp) + target_link_libraries(rdpsnd_alsa freerdp winpr) else() - target_link_libraries(rdpsnd_alsa freerdp-utils) + target_link_libraries(rdpsnd_alsa freerdp-utils winpr-crt) endif() target_link_libraries(rdpsnd_alsa ${ALSA_LIBRARIES}) diff --git a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c index 26326bbba..5864aeb0b 100644 --- a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c +++ b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include @@ -434,12 +436,12 @@ int FreeRDPRdpsndDeviceEntry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints) if (data && strcmp((char*) data->data[0], "alsa") == 0) { - alsa->device_name = xstrdup((char*) data->data[1]); + alsa->device_name = _strdup((char*) data->data[1]); } if (alsa->device_name == NULL) { - alsa->device_name = xstrdup("default"); + alsa->device_name = _strdup("default"); } alsa->out_handle = 0; diff --git a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c index 702f2d49c..7a167da46 100644 --- a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c +++ b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c @@ -25,7 +25,10 @@ #include #include +#include + #include + #include #include #include @@ -541,7 +544,7 @@ int FreeRDPRdpsndDeviceEntry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints) if (data && strcmp((char*)data->data[0], "pulse") == 0) { if(data->data[1] && strlen((char*)data->data[1]) > 0) - pulse->device_name = xstrdup((char*)data->data[1]); + pulse->device_name = _strdup((char*)data->data[1]); else pulse->device_name = NULL; } diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index c794704eb..067e5f450 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -59,6 +59,7 @@ #include #include +#include #include #include "xf_gdi.h" @@ -310,7 +311,7 @@ void xf_create_window(xfInfo* xfi) if (xfi->instance->settings->window_title != NULL) { - win_title = xstrdup(xfi->instance->settings->window_title); + win_title = _strdup(xfi->instance->settings->window_title); } else if (xfi->instance->settings->port == 3389) { diff --git a/include/freerdp/utils/memory.h b/include/freerdp/utils/memory.h index b5ef007c6..d1e18f51f 100644 --- a/include/freerdp/utils/memory.h +++ b/include/freerdp/utils/memory.h @@ -23,11 +23,11 @@ #include #include #include + #include FREERDP_API void* xzalloc(size_t size); -FREERDP_API char* xstrdup(const char* str); FREERDP_API char* xstrtoup(const char* str); FREERDP_API wchar_t* xwcsdup(const wchar_t* wstr); diff --git a/libfreerdp/core/CMakeLists.txt b/libfreerdp/core/CMakeLists.txt index 81086c11b..d1187517d 100644 --- a/libfreerdp/core/CMakeLists.txt +++ b/libfreerdp/core/CMakeLists.txt @@ -104,12 +104,10 @@ if(MONOLITHIC_BUILD) set(${MODULE_PREFIX}_LIBS winpr) else() set(${MODULE_PREFIX}_LIBS + winpr-registry winpr-utils - winpr-sspi) - - if(NOT WIN32) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-registry) - endif() + winpr-sspi + winpr-crt) endif() if(WIN32) diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 1a11b4d00..860ba958d 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -27,6 +27,8 @@ #include "connection.h" #include "transport.h" +#include + #include /** @@ -165,30 +167,30 @@ boolean rdp_client_redirect(rdpRdp* rdp) if (redirection->flags & LB_TARGET_NET_ADDRESS) { free(settings->hostname); - settings->hostname = xstrdup(redirection->targetNetAddress.ascii); + settings->hostname = _strdup(redirection->targetNetAddress.ascii); } else if (redirection->flags & LB_TARGET_FQDN) { free(settings->hostname); - settings->hostname = xstrdup(redirection->targetFQDN.ascii); + settings->hostname = _strdup(redirection->targetFQDN.ascii); } else if (redirection->flags & LB_TARGET_NETBIOS_NAME) { free(settings->hostname); - settings->hostname = xstrdup(redirection->targetNetBiosName.ascii); + settings->hostname = _strdup(redirection->targetNetBiosName.ascii); } } if (redirection->flags & LB_USERNAME) { free(settings->username); - settings->username = xstrdup(redirection->username.ascii); + settings->username = _strdup(redirection->username.ascii); } if (redirection->flags & LB_DOMAIN) { free(settings->domain); - settings->domain = xstrdup(redirection->domain.ascii); + settings->domain = _strdup(redirection->domain.ascii); } if (redirection->flags & LB_PASSWORD) diff --git a/libfreerdp/core/http.c b/libfreerdp/core/http.c index 2b5a2840d..ae9fd0fed 100644 --- a/libfreerdp/core/http.c +++ b/libfreerdp/core/http.c @@ -44,7 +44,7 @@ void http_context_set_method(HttpContext* http_context, char* method) if (http_context->Method) free(http_context->Method); - http_context->Method = xstrdup(method); + http_context->Method = _strdup(method); } void http_context_set_uri(HttpContext* http_context, char* uri) @@ -52,7 +52,7 @@ void http_context_set_uri(HttpContext* http_context, char* uri) if (http_context->URI) free(http_context->URI); - http_context->URI = xstrdup(uri); + http_context->URI = _strdup(uri); } void http_context_set_user_agent(HttpContext* http_context, char* user_agent) @@ -60,7 +60,7 @@ void http_context_set_user_agent(HttpContext* http_context, char* user_agent) if (http_context->UserAgent) free(http_context->UserAgent); - http_context->UserAgent = xstrdup(user_agent); + http_context->UserAgent = _strdup(user_agent); } void http_context_set_host(HttpContext* http_context, char* host) @@ -68,7 +68,7 @@ void http_context_set_host(HttpContext* http_context, char* host) if (http_context->Host) free(http_context->Host); - http_context->Host = xstrdup(host); + http_context->Host = _strdup(host); } void http_context_set_accept(HttpContext* http_context, char* accept) @@ -76,7 +76,7 @@ void http_context_set_accept(HttpContext* http_context, char* accept) if (http_context->Accept) free(http_context->Accept); - http_context->Accept = xstrdup(accept); + http_context->Accept = _strdup(accept); } void http_context_set_cache_control(HttpContext* http_context, char* cache_control) @@ -84,7 +84,7 @@ void http_context_set_cache_control(HttpContext* http_context, char* cache_contr if (http_context->CacheControl) free(http_context->CacheControl); - http_context->CacheControl = xstrdup(cache_control); + http_context->CacheControl = _strdup(cache_control); } void http_context_set_connection(HttpContext* http_context, char* connection) @@ -92,7 +92,7 @@ void http_context_set_connection(HttpContext* http_context, char* connection) if (http_context->Connection) free(http_context->Connection); - http_context->Connection = xstrdup(connection); + http_context->Connection = _strdup(connection); } void http_context_set_pragma(HttpContext* http_context, char* pragma) @@ -100,7 +100,7 @@ void http_context_set_pragma(HttpContext* http_context, char* pragma) if (http_context->Pragma) free(http_context->Pragma); - http_context->Pragma = xstrdup(pragma); + http_context->Pragma = _strdup(pragma); } void http_context_free(HttpContext* http_context) @@ -122,7 +122,7 @@ void http_request_set_method(HttpRequest* http_request, char* method) if (http_request->Method) free(http_request->Method); - http_request->Method = xstrdup(method); + http_request->Method = _strdup(method); } void http_request_set_uri(HttpRequest* http_request, char* uri) @@ -130,7 +130,7 @@ void http_request_set_uri(HttpRequest* http_request, char* uri) if (http_request->URI) free(http_request->URI); - http_request->URI = xstrdup(uri); + http_request->URI = _strdup(uri); } void http_request_set_auth_scheme(HttpRequest* http_request, char* auth_scheme) @@ -138,7 +138,7 @@ void http_request_set_auth_scheme(HttpRequest* http_request, char* auth_scheme) if (http_request->AuthScheme) free(http_request->AuthScheme); - http_request->AuthScheme = xstrdup(auth_scheme); + http_request->AuthScheme = _strdup(auth_scheme); } void http_request_set_auth_param(HttpRequest* http_request, char* auth_param) @@ -146,7 +146,7 @@ void http_request_set_auth_param(HttpRequest* http_request, char* auth_param) if (http_request->AuthParam) free(http_request->AuthParam); - http_request->AuthParam = xstrdup(auth_param); + http_request->AuthParam = _strdup(auth_param); } #ifndef _WIN32 @@ -310,7 +310,7 @@ void http_response_parse_header_status_line(HttpResponse* http_response, char* s *separator = '\0'; http_response->StatusCode = atoi(status_code); - http_response->ReasonPhrase = xstrdup(reason_phrase); + http_response->ReasonPhrase = _strdup(reason_phrase); *separator = ' '; } @@ -324,15 +324,15 @@ void http_response_parse_header_field(HttpResponse* http_response, char* name, c { char* separator; - http_response->Authorization = xstrdup(value); + http_response->Authorization = _strdup(value); separator = strchr(value, ' '); if (separator != NULL) { *separator = '\0'; - http_response->AuthScheme = xstrdup(value); - http_response->AuthParam = xstrdup(separator + 1); + http_response->AuthScheme = _strdup(value); + http_response->AuthParam = _strdup(separator + 1); *separator = ' '; } } @@ -355,8 +355,8 @@ void http_response_parse_header_field(HttpResponse* http_response, char* name, c /* WWW-Authenticate: NTLM base64token */ *separator = '\0'; - http_response->AuthScheme = xstrdup(value); - http_response->AuthParam = xstrdup(separator + 1); + http_response->AuthScheme = _strdup(value); + http_response->AuthParam = _strdup(separator + 1); *separator = ' '; return; @@ -473,7 +473,7 @@ HttpResponse* http_response_recv(rdpTls* tls) while (line != NULL) { - http_response->lines[count] = xstrdup(line); + http_response->lines[count] = _strdup(line); line = strtok(NULL, "\r\n"); count++; } @@ -482,7 +482,7 @@ HttpResponse* http_response_recv(rdpTls* tls) if (http_response->ContentLength > 0) { - http_response->Content = xstrdup(content); + http_response->Content = _strdup(content); } break; diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index 8b16c7c61..11ef5d3e4 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -30,11 +30,12 @@ #include #endif +#include +#include + #include #include -#include - static const char client_dll[] = "C:\\Windows\\System32\\mstscax.dll"; void settings_client_load_hkey_local_machine(rdpSettings* settings) @@ -258,7 +259,7 @@ rdpSettings* settings_new(void* instance) settings->draw_nine_grid_cache_size = 2560; settings->draw_nine_grid_cache_entries = 256; - settings->client_dir = xstrdup(client_dll); + settings->client_dir = _strdup(client_dll); settings->num_icon_caches = 3; settings->num_icon_cache_entries = 12; diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index b409e1fbd..8c8d8a1db 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -29,6 +29,8 @@ #include #include +#include + #ifndef _WIN32 #include #include @@ -79,7 +81,7 @@ void tcp_get_ip_address(rdpTcp * tcp) tcp->ip_address[sizeof(tcp->ip_address) - 1] = 0; tcp->settings->ipv6 = 0; - tcp->settings->ip_address = xstrdup(tcp->ip_address); + tcp->settings->ip_address = _strdup(tcp->ip_address); } void tcp_get_mac_address(rdpTcp * tcp) diff --git a/libfreerdp/crypto/CMakeLists.txt b/libfreerdp/crypto/CMakeLists.txt index e8a920624..4cd1b0e8d 100644 --- a/libfreerdp/crypto/CMakeLists.txt +++ b/libfreerdp/crypto/CMakeLists.txt @@ -59,8 +59,10 @@ else() endif() if(MONOLITHIC_BUILD) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/libfreerdp/crypto/certificate.c b/libfreerdp/crypto/certificate.c index f60d6f0f7..ecb47e696 100644 --- a/libfreerdp/crypto/certificate.c +++ b/libfreerdp/crypto/certificate.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include @@ -217,8 +219,8 @@ rdpCertificateData* certificate_data_new(char* hostname, char* fingerprint) if (certdata != NULL) { - certdata->hostname = xstrdup(hostname); - certdata->fingerprint = xstrdup(fingerprint); + certdata->hostname = _strdup(hostname); + certdata->fingerprint = _strdup(fingerprint); } return certdata; diff --git a/libfreerdp/locale/CMakeLists.txt b/libfreerdp/locale/CMakeLists.txt index bae6b46da..a96812706 100644 --- a/libfreerdp/locale/CMakeLists.txt +++ b/libfreerdp/locale/CMakeLists.txt @@ -81,8 +81,10 @@ endif() set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") if(MONOLITHIC_BUILD) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/libfreerdp/locale/keyboard_layout.c b/libfreerdp/locale/keyboard_layout.c index 20bda4950..422d113f9 100644 --- a/libfreerdp/locale/keyboard_layout.c +++ b/libfreerdp/locale/keyboard_layout.c @@ -25,6 +25,8 @@ #include #include +#include + #include "liblocale.h" #include @@ -492,7 +494,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types) for (i = 0; i < length; i++, num++) { layouts[num].code = RDP_KEYBOARD_LAYOUT_TABLE[i].code; - layouts[num].name = xstrdup(RDP_KEYBOARD_LAYOUT_TABLE[i].name); + layouts[num].name = _strdup(RDP_KEYBOARD_LAYOUT_TABLE[i].name); } } if ((types & RDP_KEYBOARD_LAYOUT_TYPE_VARIANT) != 0) @@ -503,7 +505,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types) for (i = 0; i < length; i++, num++) { layouts[num].code = RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code; - layouts[num].name = xstrdup(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name); + layouts[num].name = _strdup(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name); } } if ((types & RDP_KEYBOARD_LAYOUT_TYPE_IME) != 0) @@ -514,7 +516,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types) for (i = 0; i < length; i++, num++) { layouts[num].code = RDP_KEYBOARD_IME_TABLE[i].code; - layouts[num].name = xstrdup(RDP_KEYBOARD_IME_TABLE[i].name); + layouts[num].name = _strdup(RDP_KEYBOARD_IME_TABLE[i].name); } } diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index 3996ccd30..d974de55e 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -25,7 +25,10 @@ #include #include +#include + #include "liblocale.h" + #include #include #include @@ -103,8 +106,8 @@ uint32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var if (keyboardLayoutId > 0) { - *xkb_layout = xstrdup(layout); - *xkb_variant = xstrdup(variant); + *xkb_layout = _strdup(layout); + *xkb_variant = _strdup(variant); return keyboardLayoutId; } @@ -149,8 +152,8 @@ uint32 freerdp_detect_keyboard_layout_from_xkb(char** xkb_layout, char** xkb_var if (keyboardLayoutId > 0) { - *xkb_layout = xstrdup(layout); - *xkb_variant = xstrdup(variant); + *xkb_layout = _strdup(layout); + *xkb_variant = _strdup(variant); return keyboardLayoutId; } diff --git a/libfreerdp/locale/timezone.c b/libfreerdp/locale/timezone.c index 2d98eecbd..278f473c6 100644 --- a/libfreerdp/locale/timezone.c +++ b/libfreerdp/locale/timezone.c @@ -26,6 +26,8 @@ #include #include +#include + #include "liblocale.h" #include @@ -1502,7 +1504,7 @@ char* freerdp_get_unix_timezone_identifier() if (tz_env != NULL) { - tzid = xstrdup(tz_env); + tzid = _strdup(tz_env); return tzid; } @@ -1576,7 +1578,7 @@ boolean freerdp_match_unix_timezone_identifier_with_list(const char* tzid, const char* p; char* list_copy; - list_copy = xstrdup(list); + list_copy = _strdup(list); p = strtok(list_copy, " "); diff --git a/libfreerdp/utils/CMakeLists.txt b/libfreerdp/utils/CMakeLists.txt index ae639bbb3..34e11f72e 100644 --- a/libfreerdp/utils/CMakeLists.txt +++ b/libfreerdp/utils/CMakeLists.txt @@ -76,12 +76,7 @@ if(MONOLITHIC_BUILD) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - if(NOT WIN32) - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt) - endif() - - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-synch) - + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt winpr-synch) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() diff --git a/libfreerdp/utils/args.c b/libfreerdp/utils/args.c index 651490b56..90ba448ad 100644 --- a/libfreerdp/utils/args.c +++ b/libfreerdp/utils/args.c @@ -26,6 +26,8 @@ #include #include +#include + #ifdef _WIN32 #include #define isatty _isatty @@ -51,7 +53,7 @@ void freerdp_parse_hostname(rdpSettings* settings, char* hostname) && (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':')))) { /* Either "[...]" or "[...]:..." with at most one : after the brackets */ - settings->hostname = xstrdup(hostname + 1); + settings->hostname = _strdup(hostname + 1); if ((p = strchr((char*)settings->hostname, ']'))) { @@ -64,7 +66,7 @@ void freerdp_parse_hostname(rdpSettings* settings, char* hostname) else { /* Port number is cut off and used if exactly one : in the string */ - settings->hostname = xstrdup(hostname); + settings->hostname = _strdup(hostname); if ((p = strchr((char*)settings->hostname, ':')) && !strchr(p + 1, ':')) { @@ -185,7 +187,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing username\n"); return FREERDP_ARGS_PARSE_FAILURE; } - settings->username = xstrdup(argv[index]); + settings->username = _strdup(argv[index]); } else if (strcmp("-p", argv[index]) == 0) { @@ -195,7 +197,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing password\n"); return FREERDP_ARGS_PARSE_FAILURE; } - settings->password = xstrdup(argv[index]); + settings->password = _strdup(argv[index]); settings->autologon = 1; /* @@ -213,7 +215,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing domain\n"); return FREERDP_ARGS_PARSE_FAILURE; } - settings->domain = xstrdup(argv[index]); + settings->domain = _strdup(argv[index]); } else if (strcmp("-s", argv[index]) == 0) { @@ -223,7 +225,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing shell\n"); return FREERDP_ARGS_PARSE_FAILURE; } - settings->shell = xstrdup(argv[index]); + settings->shell = _strdup(argv[index]); } else if (strcmp("-c", argv[index]) == 0) { @@ -233,7 +235,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing directory\n"); return FREERDP_ARGS_PARSE_FAILURE; } - settings->directory = xstrdup(argv[index]); + settings->directory = _strdup(argv[index]); } else if (strcmp("-g", argv[index]) == 0) { @@ -289,7 +291,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, return FREERDP_ARGS_PARSE_FAILURE; } - settings->window_title = xstrdup(argv[index]); + settings->window_title = _strdup(argv[index]); } else if (strcmp("-t", argv[index]) == 0) { @@ -384,7 +386,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, return FREERDP_ARGS_PARSE_FAILURE; } - settings->certificate_name = xstrdup(argv[index]); + settings->certificate_name = _strdup(argv[index]); } else if (strcmp("--no-fastpath", argv[index]) == 0) { @@ -520,7 +522,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing file name\n"); return FREERDP_ARGS_PARSE_FAILURE; } - settings->dump_rfx_file = xstrdup(argv[index]); + settings->dump_rfx_file = _strdup(argv[index]); settings->dump_rfx = true; settings->rfx_codec_only = true; } @@ -532,7 +534,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing file name\n"); return FREERDP_ARGS_PARSE_FAILURE; } - settings->play_rfx_file = xstrdup(argv[index]); + settings->play_rfx_file = _strdup(argv[index]); settings->play_rfx = true; } else if (strcmp("--fonts", argv[index]) == 0) @@ -679,21 +681,21 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing TSG username\n"); return -1; } - settings->tsg_username = xstrdup(argv[index]); + settings->tsg_username = _strdup(argv[index]); index++; if (index == argc) { printf("missing TSG password\n"); return -1; } - settings->tsg_password = xstrdup(argv[index]); + settings->tsg_password = _strdup(argv[index]); index++; if (index == argc) { printf("missing TSG server\n"); return -1; } - settings->tsg_hostname = xstrdup(argv[index]); + settings->tsg_hostname = _strdup(argv[index]); } else if (strcmp("--plugin", argv[index]) == 0) { @@ -809,7 +811,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, return -1; } settings->send_preconnection_pdu = true; - settings->preconnection_blob = xstrdup(argv[index]); + settings->preconnection_blob = _strdup(argv[index]); } else if (strcmp("--version", argv[index]) == 0) { @@ -874,7 +876,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, input[0] = '\0'; printf("username: "); if (scanf("%511s", input) > 0) { - settings->username = xstrdup(input); + settings->username = _strdup(input); } } /* password */ @@ -899,7 +901,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, /* Try to catch the cases where the string is NULL-ish right at the get go */ if (input[0] != '\0' && !(input[0] == '.' && input[1] == '\0')) { - settings->domain = xstrdup(input); + settings->domain = _strdup(input); } } } diff --git a/libfreerdp/utils/file.c b/libfreerdp/utils/file.c index 076201005..3be331a33 100644 --- a/libfreerdp/utils/file.c +++ b/libfreerdp/utils/file.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -87,7 +89,7 @@ char* freerdp_get_home_path(rdpSettings* settings) if (settings->home_path == NULL) settings->home_path = getenv(HOME_ENV_VARIABLE); if (settings->home_path == NULL) - settings->home_path = xstrdup("/"); + settings->home_path = _strdup("/"); return settings->home_path; } @@ -155,7 +157,7 @@ char* freerdp_append_shared_library_suffix(char* file_path) } else { - path = xstrdup(file_path); + path = _strdup(file_path); } } else @@ -179,7 +181,7 @@ char* freerdp_get_parent_path(char* base_path, int depth) return NULL; if (depth <= 0) - return xstrdup(base_path); + return _strdup(base_path); base_length = strlen(base_path); diff --git a/libfreerdp/utils/load_plugin.c b/libfreerdp/utils/load_plugin.c index 607f32144..5bc5e617e 100644 --- a/libfreerdp/utils/load_plugin.c +++ b/libfreerdp/utils/load_plugin.c @@ -24,7 +24,10 @@ #include #include #include + +#include #include + #include #include #include @@ -129,7 +132,7 @@ void* freerdp_load_plugin(const char* name, const char* entry_name) else { /* explicit path given, use it instead of default path */ - path = xstrdup(suffixed_name); + path = _strdup(suffixed_name); } entry = freerdp_load_library_symbol(path, entry_name); diff --git a/libfreerdp/utils/memory.c b/libfreerdp/utils/memory.c index 3cc2a69e1..d3b65a1ac 100644 --- a/libfreerdp/utils/memory.c +++ b/libfreerdp/utils/memory.c @@ -25,6 +25,8 @@ #include #include +#include + #include /** @@ -54,37 +56,6 @@ void* xzalloc(size_t size) return mem; } -/** - * Duplicate a string in memory. - * This function is used to secure the strdup function. - * It will allocate a new memory buffer and copy the string content in it. - * If allocation fails, it will log an error. - * - * @param str - pointer to the character string to copy. If str is NULL, nothing is done. - * - * @return a pointer to a newly allocated character string containing the same bytes as str. - * NULL if an allocation error occurred, or if the str parameter was NULL. - */ - -char* xstrdup(const char* str) -{ - char* mem; - - if (str == NULL) - return NULL; - -#ifdef _WIN32 - mem = _strdup(str); -#else - mem = strdup(str); -#endif - - if (mem == NULL) - perror("strdup"); - - return mem; -} - /** * Duplicate a wide string in memory. * This function is used to secure a call to wcsdup. @@ -136,15 +107,19 @@ char* xstrtoup(const char* str) char* out; char* p; int c; - out = xstrdup(str); - if(out != NULL) + + out = _strdup(str); + + if (out != NULL) { p = out; - while(*p != '\0') + + while (*p != '\0') { c = toupper((unsigned char)*p); - *p++ = (char)c; + *p++ = (char) c; } } + return out; } diff --git a/server/Sample/CMakeLists.txt b/server/Sample/CMakeLists.txt index 783c621ba..35dc0a348 100644 --- a/server/Sample/CMakeLists.txt +++ b/server/Sample/CMakeLists.txt @@ -30,10 +30,12 @@ add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) if(MONOLITHIC_BUILD) target_link_libraries(${MODULE_NAME} + winpr freerdp freerdp-channels-server) else() target_link_libraries(${MODULE_NAME} + winpr-crt freerdp-core freerdp-utils freerdp-codec diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index ae9332b5a..4c2d3de61 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -30,6 +30,8 @@ #include #include +#include + #include #include #include @@ -650,8 +652,8 @@ static void* test_peer_mainloop(void* arg) test_peer_init(client); /* Initialize the real server settings here */ - client->settings->cert_file = xstrdup("server.crt"); - client->settings->privatekey_file = xstrdup("server.key"); + client->settings->cert_file = _strdup("server.crt"); + client->settings->privatekey_file = _strdup("server.key"); client->settings->nla_security = false; client->settings->rfx_codec = true; client->settings->suppress_output = true;