libfreerdp-utils: get rid of xstrdup in favor of WinPR _strdup
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Tue, 9 Oct 2012 03:42:01 +0000 (23:42 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Tue, 9 Oct 2012 03:42:01 +0000 (23:42 -0400)
29 files changed:
channels/cliprdr/client/CMakeLists.txt
channels/cliprdr/client/cliprdr_format.c
channels/disk/client/disk_main.c
channels/drdynvc/client/dvcman.c
channels/printer/client/printer_cups.c
channels/printer/client/printer_win.c
channels/rdpsnd/client/alsa/CMakeLists.txt
channels/rdpsnd/client/alsa/rdpsnd_alsa.c
channels/rdpsnd/client/pulse/rdpsnd_pulse.c
client/X11/xfreerdp.c
include/freerdp/utils/memory.h
libfreerdp/core/CMakeLists.txt
libfreerdp/core/connection.c
libfreerdp/core/http.c
libfreerdp/core/settings.c
libfreerdp/core/tcp.c
libfreerdp/crypto/CMakeLists.txt
libfreerdp/crypto/certificate.c
libfreerdp/locale/CMakeLists.txt
libfreerdp/locale/keyboard_layout.c
libfreerdp/locale/keyboard_x11.c
libfreerdp/locale/timezone.c
libfreerdp/utils/CMakeLists.txt
libfreerdp/utils/args.c
libfreerdp/utils/file.c
libfreerdp/utils/load_plugin.c
libfreerdp/utils/memory.c
server/Sample/CMakeLists.txt
server/Sample/sfreerdp.c

index bd465b4..8a617b8 100644 (file)
@@ -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})
index 119e417..59f02a7 100644 (file)
@@ -25,6 +25,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#include <winpr/crt.h>
+
 #include <freerdp/types.h>
 #include <freerdp/constants.h>
 #include <freerdp/utils/hexdump.h>
@@ -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
index 9a21648..73b9065 100644 (file)
@@ -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));
                        }
                }
        }
index f87aa93..53418ae 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <winpr/crt.h>
 #include <winpr/synch.h>
 
 #include <freerdp/utils/memory.h>
@@ -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;
 
index 296ed78..30bf5cf 100644 (file)
@@ -29,6 +29,8 @@
 #include <time.h>
 #include <cups/cups.h>
 
+#include <winpr/crt.h>
+
 #include <freerdp/utils/memory.h>
 #include <freerdp/utils/svc_plugin.h>
 #include <freerdp/channels/rdpdr.h>
@@ -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;
index a7db9c9..f61ee32 100644 (file)
  * limitations under the License.
  */
 
-#include <windows.h>
-#include <winspool.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <winpr/crt.h>
+#include <winpr/windows.h>
+
+#include <time.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
+#include <winspool.h>
 
-#include "config.h"
 #include <freerdp/utils/memory.h>
 #include <freerdp/utils/svc_plugin.h>
 
-#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;
index 1d50df6..1f9db48 100644 (file)
@@ -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})
index 26326bb..5864aeb 100644 (file)
@@ -26,6 +26,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <winpr/crt.h>
+
 #include <alsa/asoundlib.h>
 
 #include <freerdp/types.h>
@@ -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;
index 702f2d4..7a167da 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+#include <winpr/crt.h>
+
 #include <pulse/pulseaudio.h>
+
 #include <freerdp/types.h>
 #include <freerdp/utils/memory.h>
 #include <freerdp/utils/dsp.h>
@@ -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;
        }
index c794704..067e5f4 100644 (file)
@@ -59,6 +59,7 @@
 #include <freerdp/client/channels.h>
 #include <freerdp/rail.h>
 
+#include <winpr/crt.h>
 #include <winpr/synch.h>
 
 #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)
        {
index b5ef007..d1e18f5 100644 (file)
 #include <stddef.h>
 #include <ctype.h>
 #include <wchar.h>
+
 #include <freerdp/api.h>
 
 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);
 
index 81086c1..d118751 100644 (file)
@@ -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)
index 1a11b4d..860ba95 100644 (file)
@@ -27,6 +27,8 @@
 #include "connection.h"
 #include "transport.h"
 
+#include <winpr/crt.h>
+
 #include <freerdp/errorcodes.h>
 
 /**
@@ -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)
index 2b5a284..ae9fd0f 100644 (file)
@@ -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;
index 8b16c7c..11ef5d3 100644 (file)
 #include <unistd.h>
 #endif
 
+#include <winpr/crt.h>
+#include <winpr/registry.h>
+
 #include <freerdp/settings.h>
 #include <freerdp/utils/file.h>
 
-#include <winpr/registry.h>
-
 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;
index b409e1f..8c8d8a1 100644 (file)
@@ -29,6 +29,8 @@
 #include <errno.h>
 #include <fcntl.h>
 
+#include <winpr/crt.h>
+
 #ifndef _WIN32
 #include <netdb.h>
 #include <unistd.h>
@@ -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)
index e8a9206..4cd1b0e 100644 (file)
@@ -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})
index f60d6f0..ecb47e6 100644 (file)
@@ -26,6 +26,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <winpr/crt.h>
+
 #include <openssl/pem.h>
 #include <openssl/rsa.h>
 
@@ -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;
index bae6b46..a968127 100644 (file)
@@ -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})
index 20bda49..422d113 100644 (file)
@@ -25,6 +25,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <winpr/crt.h>
+
 #include "liblocale.h"
 
 #include <freerdp/types.h>
@@ -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);
                }
        }
 
index 3996ccd..d974de5 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+#include <winpr/crt.h>
+
 #include "liblocale.h"
+
 #include <freerdp/utils/memory.h>
 #include <freerdp/locale/locale.h>
 #include <freerdp/locale/keyboard.h>
@@ -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;
        }
 
index 2d98eec..278f473 100644 (file)
@@ -26,6 +26,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <winpr/crt.h>
+
 #include "liblocale.h"
 
 #include <freerdp/utils/time.h>
@@ -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, " ");
 
index ae639bb..34e11f7 100644 (file)
@@ -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()
index 651490b..90ba448 100644 (file)
@@ -26,6 +26,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <winpr/crt.h>
+
 #ifdef _WIN32
 #include <io.h>
 #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);
                                }
                        }
                }
index 0762010..3be331a 100644 (file)
@@ -26,6 +26,8 @@
 #include <string.h>
 #include <sys/stat.h>
 
+#include <winpr/crt.h>
+
 #include <freerdp/types.h>
 #include <freerdp/settings.h>
 #include <freerdp/utils/memory.h>
@@ -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);
 
index 607f321..5bc5e61 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#include <winpr/crt.h>
 #include <winpr/windows.h>
+
 #include <freerdp/utils/file.h>
 #include <freerdp/utils/print.h>
 #include <freerdp/utils/memory.h>
@@ -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);
index 3cc2a69..d3b65a1 100644 (file)
@@ -25,6 +25,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <winpr/crt.h>
+
 #include <freerdp/utils/memory.h>
 
 /**
@@ -55,37 +57,6 @@ void* xzalloc(size_t size)
 }
 
 /**
- * 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.
  * It verifies the return value, and logs a message if an allocation error occurred.
@@ -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;
 }
index 783c621..35dc0a3 100644 (file)
@@ -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
index ae9332b..4c2d3de 100644 (file)
@@ -30,6 +30,8 @@
 #include <signal.h>
 #include <sys/time.h>
 
+#include <winpr/crt.h>
+
 #include <freerdp/constants.h>
 #include <freerdp/utils/sleep.h>
 #include <freerdp/utils/memory.h>
@@ -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;