From d19e2042c3eff3e6bd3e19e4bf4f42d84d3ffe6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 17 Dec 2012 10:20:25 -0500 Subject: [PATCH] libfreerdp-utils: remove deprecrated unicode utils in favor of WinPR --- channels/cliprdr/client/cliprdr_format.c | 3 +- channels/cliprdr/client/cliprdr_main.c | 1 - channels/drive/client/drive_file.c | 3 +- channels/drive/client/drive_main.c | 15 ++++---- channels/parallel/client/parallel_main.c | 1 - channels/printer/client/printer_main.c | 5 +-- channels/rail/client/rail_orders.c | 3 +- channels/rdpdr/client/rdpdr_main.c | 3 +- channels/serial/client/serial_main.c | 1 - channels/serial/client/serial_tty.c | 3 +- client/Windows/wf_cliprdr.c | 3 +- client/X11/xf_cliprdr.c | 3 +- include/freerdp/utils/unicode.h | 31 --------------- libfreerdp/core/gateway/tsg.c | 6 +-- libfreerdp/core/gcc.c | 5 +-- libfreerdp/core/info.c | 36 +++++++++--------- libfreerdp/core/nego.c | 5 +-- libfreerdp/core/timezone.c | 6 +-- libfreerdp/rail/icon.c | 3 +- libfreerdp/rail/window.c | 3 +- libfreerdp/utils/CMakeLists.txt | 3 +- libfreerdp/utils/unicode.c | 48 ------------------------ 22 files changed, 44 insertions(+), 146 deletions(-) delete mode 100644 include/freerdp/utils/unicode.h delete mode 100644 libfreerdp/utils/unicode.c diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c index cc56db4ce..7f368537e 100644 --- a/channels/cliprdr/client/cliprdr_format.c +++ b/channels/cliprdr/client/cliprdr_format.c @@ -27,11 +27,10 @@ #include #include +#include #include #include -#include -#include #include #include diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index 44cf58382..ddcc64099 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -30,7 +30,6 @@ #include #include -#include #include #include diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index 753a1ec1a..c12c3a285 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -42,7 +42,6 @@ #include #include -#include #include #include @@ -603,7 +602,7 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT DEBUG_SVC(" pattern %s matched %s", file->pattern, ent_path); free(ent_path); - length = freerdp_AsciiToUnicodeAlloc(ent->d_name, &ent_path, 0) * 2; + length = ConvertToUnicode(CP_UTF8, 0, ent->d_name, -1, &ent_path, 0) * 2; ret = TRUE; diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index be69fe460..73b7bd169 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -35,17 +35,16 @@ #include #include -#include -#include -#include -#include -#include - #include #include #include #include +#include +#include +#include +#include + #include "drive_file.h" typedef struct _DRIVE_DEVICE DRIVE_DEVICE; @@ -404,7 +403,7 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* { case FileFsVolumeInformation: /* http://msdn.microsoft.com/en-us/library/cc232108.aspx */ - length = freerdp_AsciiToUnicodeAlloc(volumeLabel, &outStr, 0) * 2; + length = ConvertToUnicode(CP_UTF8, 0, volumeLabel, -1, &outStr, 0) * 2; stream_write_UINT32(output, 17 + length); /* Length */ stream_check_size(output, 17 + length); stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* VolumeCreationTime */ @@ -428,7 +427,7 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* case FileFsAttributeInformation: /* http://msdn.microsoft.com/en-us/library/cc232101.aspx */ - length = freerdp_AsciiToUnicodeAlloc(diskType, &outStr, 0) * 2; + length = ConvertToUnicode(CP_UTF8, 0, diskType, -1, &outStr, 0) * 2; stream_write_UINT32(output, 12 + length); /* Length */ stream_check_size(output, 12 + length); stream_write_UINT32(output, diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index d40674f70..3f1e06ccc 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -54,7 +54,6 @@ #include #include #include -#include #include #include diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index c00df2aa8..830402b17 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -266,8 +265,8 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri if (printer->is_default) Flags |= RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER; - DriverNameLen = freerdp_AsciiToUnicodeAlloc(printer->driver, &DriverName, 0) * 2; - PrintNameLen = freerdp_AsciiToUnicodeAlloc(printer->name, &PrintName, 0) * 2; + DriverNameLen = ConvertToUnicode(CP_UTF8, 0, printer->driver, -1, &DriverName, 0) * 2; + PrintNameLen = ConvertToUnicode(CP_UTF8, 0, printer->name, -1, &PrintName, 0) * 2; printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen); diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index c9c529ebe..700c24d2d 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -28,7 +28,6 @@ #include #include -#include #include "rail_orders.h" @@ -83,7 +82,7 @@ void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_ if (string == NULL || strlen(string) < 1) return; - length = freerdp_AsciiToUnicodeAlloc(string, &buffer, 0) * 2; + length = ConvertToUnicode(CP_UTF8, 0, string, -1, &buffer, 0) * 2; unicode_string->string = (BYTE*) buffer; unicode_string->length = (UINT16) length; diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 9e4e493f8..e9ebcd90a 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -99,7 +98,7 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr) if (!rdpdr->computerName[0]) gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1); - computerNameLenW = freerdp_AsciiToUnicodeAlloc(rdpdr->computerName, &computerNameW, 0) * 2; + computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1, &computerNameW, 0) * 2; data_out = stream_new(16 + computerNameLenW + 2); diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index 5ad87e07b..c882cb7a1 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -48,7 +48,6 @@ #include #include #include -#include #include typedef struct _SERIAL_DEVICE SERIAL_DEVICE; diff --git a/channels/serial/client/serial_tty.c b/channels/serial/client/serial_tty.c index 21da19caf..ac9fd90d1 100644 --- a/channels/serial/client/serial_tty.c +++ b/channels/serial/client/serial_tty.c @@ -27,13 +27,12 @@ #include #include +#include #include -#include #include #include #include -#include #include #ifndef _WIN32 diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index 6ad53b8e9..6b1213de1 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -21,9 +21,10 @@ #include "config.h" #endif +#include + #include #include -#include #include #include "wf_cliprdr.h" diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index e0f0e0447..071d8ed11 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -29,7 +29,6 @@ #include #include -#include #include #include "xf_cliprdr.h" @@ -538,7 +537,7 @@ static BYTE* xf_cliprdr_process_requested_unicodetext(BYTE* data, int* size) int out_size; inbuf = (char*) lf2crlf(data, size); - out_size = freerdp_AsciiToUnicodeAlloc(inbuf, &outbuf, 0); + out_size = ConvertToUnicode(CP_UTF8, 0, inbuf, -1, &outbuf, 0); free(inbuf); *size = (int) ((out_size + 1) * 2); diff --git a/include/freerdp/utils/unicode.h b/include/freerdp/utils/unicode.h deleted file mode 100644 index 6310eafbd..000000000 --- a/include/freerdp/utils/unicode.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Unicode Utils - * - * Copyright 2011 Marc-Andre Moreau - * - * 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 FREERDP_UTILS_UNICODE_H -#define FREERDP_UTILS_UNICODE_H - -#include -#include - -#include -#include - -FREERDP_API int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length); - -#endif /* FREERDP_UTILS_UNICODE_H */ diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index 2fae9e3bf..8e4e900c6 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -26,8 +26,6 @@ #include #include -#include - #include #include #include @@ -1070,8 +1068,8 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port) rdpSettings* settings = rpc->settings; tsg->Port = port; - freerdp_AsciiToUnicodeAlloc(hostname, &tsg->Hostname, 0); - freerdp_AsciiToUnicodeAlloc(settings->ComputerName, &tsg->MachineName, 0); + ConvertToUnicode(CP_UTF8, 0, hostname, -1, &tsg->Hostname, 0); + ConvertToUnicode(CP_UTF8, 0, settings->ComputerName, -1, &tsg->MachineName, 0); if (!rpc_connect(rpc)) { diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index 93a13be7b..68b650e3f 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -22,7 +22,6 @@ #endif #include -#include #include "gcc.h" #include "certificate.h" @@ -669,8 +668,8 @@ void gcc_write_client_core_data(STREAM* s, rdpSettings* settings) version = settings->RdpVersion >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4; - clientNameLength = freerdp_AsciiToUnicodeAlloc(settings->ClientHostname, &clientName, 0); - clientDigProductIdLength = freerdp_AsciiToUnicodeAlloc(settings->ClientProductId, &clientDigProductId, 0); + clientNameLength = ConvertToUnicode(CP_UTF8, 0, settings->ClientHostname, -1, &clientName, 0); + clientDigProductIdLength = ConvertToUnicode(CP_UTF8, 0, settings->ClientProductId, -1, &clientDigProductId, 0); stream_write_UINT32(s, version); /* Version */ stream_write_UINT16(s, settings->DesktopWidth); /* DesktopWidth */ diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index f73bc6739..c27d9d43c 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -23,8 +23,6 @@ #include -#include - #include "timezone.h" #include "info.h" @@ -174,9 +172,9 @@ void rdp_write_extended_info_packet(STREAM* s, rdpSettings* settings) clientAddressFamily = settings->IPv6Enabled ? ADDRESS_FAMILY_INET6 : ADDRESS_FAMILY_INET; - cbClientAddress = freerdp_AsciiToUnicodeAlloc(settings->ClientAddress, &clientAddress, 0) * 2; + cbClientAddress = ConvertToUnicode(CP_UTF8, 0, settings->ClientAddress, -1, &clientAddress, 0) * 2; - cbClientDir = freerdp_AsciiToUnicodeAlloc(settings->ClientDir, &clientDir, 0) * 2; + cbClientDir = ConvertToUnicode(CP_UTF8, 0, settings->ClientDir, -1, &clientDir, 0) * 2; cbAutoReconnectLen = (int) settings->ClientAutoReconnectCookie->cbLen; @@ -307,16 +305,16 @@ BOOL rdp_read_info_packet(STREAM* s, rdpSettings* settings) void rdp_write_info_packet(STREAM* s, rdpSettings* settings) { UINT32 flags; - WCHAR* domain; - int cbDomain; - WCHAR* userName; - int cbUserName; - WCHAR* password; - int cbPassword; - WCHAR* alternateShell; - int cbAlternateShell; - WCHAR* workingDir; - int cbWorkingDir; + WCHAR* domain = NULL; + int cbDomain = 0; + WCHAR* userName = NULL; + int cbUserName = 0; + WCHAR* password = NULL; + int cbPassword = 0; + WCHAR* alternateShell = NULL; + int cbAlternateShell = 0; + WCHAR* workingDir = NULL; + int cbWorkingDir = 0; BOOL usedPasswordCookie = FALSE; flags = INFO_MOUSE | @@ -347,7 +345,7 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings) if (settings->Domain) { - cbDomain = freerdp_AsciiToUnicodeAlloc(settings->Domain, &domain, 0) * 2; + cbDomain = ConvertToUnicode(CP_UTF8, 0, settings->Domain, -1, &domain, 0) * 2; } else { @@ -355,7 +353,7 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings) cbDomain = 0; } - cbUserName = freerdp_AsciiToUnicodeAlloc(settings->Username, &userName, 0) * 2; + cbUserName = ConvertToUnicode(CP_UTF8, 0, settings->Username, -1, &userName, 0) * 2; if (settings->RedirectionPassword && settings->RedirectionPasswordLength > 0) { @@ -365,12 +363,12 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings) } else { - cbPassword = freerdp_AsciiToUnicodeAlloc(settings->Password, &password, 0) * 2; + cbPassword = ConvertToUnicode(CP_UTF8, 0, settings->Password, -1, &password, 0) * 2; } - cbAlternateShell = freerdp_AsciiToUnicodeAlloc(settings->AlternateShell, &alternateShell, 0) * 2; + cbAlternateShell = ConvertToUnicode(CP_UTF8, 0, settings->AlternateShell, -1, &alternateShell, 0) * 2; - cbWorkingDir = freerdp_AsciiToUnicodeAlloc(settings->ShellWorkingDirectory, &workingDir, 0) * 2; + cbWorkingDir = ConvertToUnicode(CP_UTF8, 0, settings->ShellWorkingDirectory, -1, &workingDir, 0) * 2; stream_write_UINT32(s, 0); /* CodePage */ stream_write_UINT32(s, flags); /* flags */ diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 7d609fda4..0d0e43182 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -26,9 +26,6 @@ #include -#include -#include - #include "tpkt.h" #include "nego.h" @@ -274,7 +271,7 @@ BOOL nego_send_preconnection_pdu(rdpNego* nego) if (nego->preconnection_blob) { - cchPCB = (UINT16) freerdp_AsciiToUnicodeAlloc(nego->preconnection_blob, &wszPCB, 0); + cchPCB = (UINT16) ConvertToUnicode(CP_UTF8, 0, nego->preconnection_blob, -1, &wszPCB, 0); cchPCB += 1; /* zero-termination */ cbSize += cchPCB * 2; } diff --git a/libfreerdp/core/timezone.c b/libfreerdp/core/timezone.c index 03d9df6ef..596b5da7d 100644 --- a/libfreerdp/core/timezone.c +++ b/libfreerdp/core/timezone.c @@ -23,8 +23,6 @@ #include -#include - #include "timezone.h" /** @@ -130,8 +128,8 @@ void rdp_write_client_time_zone(STREAM* s, rdpSettings* settings) clientTimeZone = settings->ClientTimeZone; freerdp_time_zone_detect(clientTimeZone); - standardNameLength = freerdp_AsciiToUnicodeAlloc(clientTimeZone->standardName, &standardName, 0) * 2; - daylightNameLength = freerdp_AsciiToUnicodeAlloc(clientTimeZone->daylightName, &daylightName, 0) * 2; + standardNameLength = ConvertToUnicode(CP_UTF8, 0, clientTimeZone->standardName, -1, &standardName, 0) * 2; + daylightNameLength = ConvertToUnicode(CP_UTF8, 0, clientTimeZone->daylightName, -1, &daylightName, 0) * 2; if (standardNameLength > 62) standardNameLength = 62; diff --git a/libfreerdp/rail/icon.c b/libfreerdp/rail/icon.c index 3fc029dcc..15ca11412 100644 --- a/libfreerdp/rail/icon.c +++ b/libfreerdp/rail/icon.c @@ -22,10 +22,9 @@ #endif #include +#include #include -#include -#include #include diff --git a/libfreerdp/rail/window.c b/libfreerdp/rail/window.c index bb552c7b3..7819beafb 100644 --- a/libfreerdp/rail/window.c +++ b/libfreerdp/rail/window.c @@ -22,11 +22,10 @@ #endif #include +#include #include #include -#include -#include #include "librail.h" diff --git a/libfreerdp/utils/CMakeLists.txt b/libfreerdp/utils/CMakeLists.txt index 8c367e241..ba14e9e42 100644 --- a/libfreerdp/utils/CMakeLists.txt +++ b/libfreerdp/utils/CMakeLists.txt @@ -36,8 +36,7 @@ set(${MODULE_PREFIX}_SRCS tcp.c thread.c time.c - uds.c - unicode.c) + uds.c) if(NOT WIN32) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} msusb.c) diff --git a/libfreerdp/utils/unicode.c b/libfreerdp/utils/unicode.c deleted file mode 100644 index ecae1a989..000000000 --- a/libfreerdp/utils/unicode.c +++ /dev/null @@ -1,48 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Unicode Utils - * - * Copyright 2011 Marc-Andre Moreau - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include - -#include - -#include - -int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length) -{ - int status; - - *wstr = NULL; - - if (!str) - return 0; - - if (length < 1) - length = -1; - - status = ConvertToUnicode(CP_UTF8, 0, str, length, wstr, 0); - - return status; -}