libfreerdp-utils: get rid of freerdp_uniconv_out
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Sun, 23 Sep 2012 23:49:13 +0000 (19:49 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Sun, 23 Sep 2012 23:49:13 +0000 (19:49 -0400)
13 files changed:
channels/rail/client/rail_orders.c
channels/rdpdr/client/disk/disk_file.c
channels/rdpdr/client/disk/disk_main.c
channels/rdpdr/client/printer/printer_main.c
channels/rdpdr/client/rdpdr_main.c
client/X11/xf_cliprdr.c
include/freerdp/utils/unicode.h
libfreerdp/core/gcc.c
libfreerdp/core/info.c
libfreerdp/core/nego.c
libfreerdp/core/timezone.c
libfreerdp/core/tsg.c
libfreerdp/utils/unicode.c

index f756b5a..ee9bf01 100644 (file)
@@ -67,8 +67,8 @@ static const char* const RAIL_ORDER_TYPE_STRINGS[] =
 
 void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_UNICODE_STRING* unicode_string)
 {
-       char* buffer;
-       size_t length = 0;
+       WCHAR* buffer;
+       int length = 0;
 
        if (unicode_string->string != NULL)
                xfree(unicode_string->string);
@@ -79,7 +79,7 @@ void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_
        if (string == NULL || strlen(string) < 1)
                return;
 
-       buffer = freerdp_uniconv_out(string, &length);
+       length = freerdp_AsciiToUnicodeAlloc(string, &buffer, 0) * 2;
 
        unicode_string->string = (uint8*) buffer;
        unicode_string->length = (uint16) length;
index 6582785..aabb6b6 100644 (file)
@@ -517,11 +517,11 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui
 boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, uint8 InitialQuery,
        const char* path, STREAM* output)
 {
-       struct dirent* ent;
-       char* ent_path;
-       struct STAT st;
-       size_t len;
+       int length;
        boolean ret;
+       WCHAR* ent_path;
+       struct STAT st;
+       struct dirent* ent;
 
        DEBUG_SVC("path %s FsInformationClass %d InitialQuery %d", path, FsInformationClass, InitialQuery);
 
@@ -570,26 +570,27 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
        }
 
        memset(&st, 0, sizeof(struct STAT));
-       ent_path = xmalloc(strlen(file->fullpath) + strlen(ent->d_name) + 2);
-       sprintf(ent_path, "%s/%s", file->fullpath, ent->d_name);
+       ent_path = (WCHAR*) malloc(strlen(file->fullpath) + strlen(ent->d_name) + 2);
+       sprintf((char*) ent_path, "%s/%s", file->fullpath, ent->d_name);
 
-       if (STAT(ent_path, &st) != 0)
+       if (STAT((char*) ent_path, &st) != 0)
        {
-               DEBUG_WARN("stat %s failed. errno = %d", ent_path, errno);
+               DEBUG_WARN("stat %s failed. errno = %d", (char*) ent_path, errno);
        }
 
        DEBUG_SVC("  pattern %s matched %s", file->pattern, ent_path);
        xfree(ent_path);
 
-       ent_path = freerdp_uniconv_out(ent->d_name, &len);
+       length = freerdp_AsciiToUnicodeAlloc(ent->d_name, &ent_path, 0) * 2;
 
        ret = true;
+
        switch (FsInformationClass)
        {
                case FileDirectoryInformation:
                        /* http://msdn.microsoft.com/en-us/library/cc232097.aspx */
-                       stream_write_uint32(output, 64 + len); /* Length */
-                       stream_check_size(output, 64 + len);
+                       stream_write_uint32(output, 64 + length); /* Length */
+                       stream_check_size(output, 64 + length);
                        stream_write_uint32(output, 0); /* NextEntryOffset */
                        stream_write_uint32(output, 0); /* FileIndex */
                        stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */
@@ -599,14 +600,14 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
                        stream_write_uint64(output, st.st_size); /* EndOfFile */
                        stream_write_uint64(output, st.st_size); /* AllocationSize */
                        stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
-                       stream_write_uint32(output, len); /* FileNameLength */
-                       stream_write(output, ent_path, len);
+                       stream_write_uint32(output, length); /* FileNameLength */
+                       stream_write(output, ent_path, length);
                        break;
 
                case FileFullDirectoryInformation:
                        /* http://msdn.microsoft.com/en-us/library/cc232068.aspx */
-                       stream_write_uint32(output, 68 + len); /* Length */
-                       stream_check_size(output, 68 + len);
+                       stream_write_uint32(output, 68 + length); /* Length */
+                       stream_check_size(output, 68 + length);
                        stream_write_uint32(output, 0); /* NextEntryOffset */
                        stream_write_uint32(output, 0); /* FileIndex */
                        stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */
@@ -616,15 +617,15 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
                        stream_write_uint64(output, st.st_size); /* EndOfFile */
                        stream_write_uint64(output, st.st_size); /* AllocationSize */
                        stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
-                       stream_write_uint32(output, len); /* FileNameLength */
+                       stream_write_uint32(output, length); /* FileNameLength */
                        stream_write_uint32(output, 0); /* EaSize */
-                       stream_write(output, ent_path, len);
+                       stream_write(output, ent_path, length);
                        break;
 
                case FileBothDirectoryInformation:
                        /* http://msdn.microsoft.com/en-us/library/cc232095.aspx */
-                       stream_write_uint32(output, 93 + len); /* Length */
-                       stream_check_size(output, 93 + len);
+                       stream_write_uint32(output, 93 + length); /* Length */
+                       stream_check_size(output, 93 + length);
                        stream_write_uint32(output, 0); /* NextEntryOffset */
                        stream_write_uint32(output, 0); /* FileIndex */
                        stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */
@@ -634,22 +635,22 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
                        stream_write_uint64(output, st.st_size); /* EndOfFile */
                        stream_write_uint64(output, st.st_size); /* AllocationSize */
                        stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
-                       stream_write_uint32(output, len); /* FileNameLength */
+                       stream_write_uint32(output, length); /* FileNameLength */
                        stream_write_uint32(output, 0); /* EaSize */
                        stream_write_uint8(output, 0); /* ShortNameLength */
                        /* Reserved(1), MUST NOT be added! */
                        stream_write_zero(output, 24); /* ShortName */
-                       stream_write(output, ent_path, len);
+                       stream_write(output, ent_path, length);
                        break;
 
                case FileNamesInformation:
                        /* http://msdn.microsoft.com/en-us/library/cc232077.aspx */
-                       stream_write_uint32(output, 12 + len); /* Length */
-                       stream_check_size(output, 12 + len);
+                       stream_write_uint32(output, 12 + length); /* Length */
+                       stream_check_size(output, 12 + length);
                        stream_write_uint32(output, 0); /* NextEntryOffset */
                        stream_write_uint32(output, 0); /* FileIndex */
-                       stream_write_uint32(output, len); /* FileNameLength */
-                       stream_write(output, ent_path, len);
+                       stream_write_uint32(output, length); /* FileNameLength */
+                       stream_write(output, ent_path, length);
                        break;
 
                default:
index f90e3c0..24137d8 100644 (file)
@@ -385,10 +385,10 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
        STREAM* output = irp->output;
        struct STATVFS svfst;
        struct STAT st;
-       char* volumeLabel = {"FREERDP"};  /* TODO: Add sub routine to correctly pick up Volume Label name for each O/S supported */
+       char* volumeLabel = {"FREERDP"};
        char* diskType = {"FAT32"};
-       char* outStr;
-       size_t len;
+       WCHAR* outStr;
+       int length;
 
        stream_read_uint32(irp->input, FsInformationClass);
 
@@ -399,15 +399,15 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
        {
                case FileFsVolumeInformation:
                        /* http://msdn.microsoft.com/en-us/library/cc232108.aspx */
-                       outStr = freerdp_uniconv_out(volumeLabel, &len);
-                       stream_write_uint32(output, 17 + len); /* Length */
-                       stream_check_size(output, 17 + len);
+                       length = freerdp_AsciiToUnicodeAlloc(volumeLabel, &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 */
                        stream_write_uint32(output, svfst.f_fsid); /* VolumeSerialNumber */
-                       stream_write_uint32(output, len); /* VolumeLabelLength */
+                       stream_write_uint32(output, length); /* VolumeLabelLength */
                        stream_write_uint8(output, 0); /* SupportsObjects */
                        /* Reserved(1), MUST NOT be added! */
-                       stream_write(output, outStr, len); /* VolumeLabel (Unicode) */
+                       stream_write(output, outStr, length); /* VolumeLabel (Unicode) */
                        xfree(outStr);
                        break;
 
@@ -423,17 +423,16 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
 
                case FileFsAttributeInformation:
                        /* http://msdn.microsoft.com/en-us/library/cc232101.aspx */
-                       outStr = freerdp_uniconv_out(diskType, &len);
-
-                       stream_write_uint32(output, 12 + len); /* Length */
-                       stream_check_size(output, 12 + len);
+                       length = freerdp_AsciiToUnicodeAlloc(diskType, &outStr, 0) * 2;
+                       stream_write_uint32(output, 12 + length); /* Length */
+                       stream_check_size(output, 12 + length);
                        stream_write_uint32(output,
                                FILE_CASE_SENSITIVE_SEARCH |
                                FILE_CASE_PRESERVED_NAMES |
                                FILE_UNICODE_ON_DISK); /* FileSystemAttributes */
                        stream_write_uint32(output, svfst.f_namemax/*510*/); /* MaximumComponentNameLength */
-                       stream_write_uint32(output, len); /* FileSystemNameLength */
-                       stream_write(output, outStr, len); /* FileSystemName (Unicode) */
+                       stream_write_uint32(output, length); /* FileSystemNameLength */
+                       stream_write(output, outStr, length); /* FileSystemName (Unicode) */
                        xfree(outStr);
                        break;
 
@@ -652,7 +651,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
 {
        char* name;
        char* path;
-       int i, len;
+       int i, length;
        DISK_DEVICE* disk;
 
        name = (char*) pEntryPoints->plugin_data->data[1];
@@ -667,10 +666,10 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
                disk->device.IRPRequest = disk_irp_request;
                disk->device.Free = disk_free;
 
-               len = strlen(name);
-               disk->device.data = stream_new(len + 1);
+               length = strlen(name);
+               disk->device.data = stream_new(length + 1);
 
-               for (i = 0; i <= len; i++)
+               for (i = 0; i <= length; i++)
                        stream_write_uint8(disk->device.data, name[i] < 0 ? '_' : name[i]);
 
                disk->path = path;
index 25b5e35..a4db937 100644 (file)
@@ -232,10 +232,10 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
 {
        char* port;
        uint32 Flags;
-       size_t DriverNameLen;
-       char* DriverName;
-       size_t PrintNameLen;
-       char* PrintName;
+       int DriverNameLen;
+       WCHAR* DriverName;
+       int PrintNameLen;
+       WCHAR* PrintName;
        uint32 CachedFieldsLen;
        uint8* CachedPrinterConfigData;
        PRINTER_DEVICE* printer_dev;
@@ -258,11 +258,12 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
        DEBUG_SVC("Printer %s registered", printer->name);
 
        Flags = 0;
+
        if (printer->is_default)
                Flags |= RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER;
 
-       DriverName = freerdp_uniconv_out(printer->driver, &DriverNameLen);
-       PrintName = freerdp_uniconv_out(printer->name, &PrintNameLen);
+       DriverNameLen = freerdp_AsciiToUnicodeAlloc(printer->driver, &DriverName, 0) * 2;
+       PrintNameLen = freerdp_AsciiToUnicodeAlloc(printer->name, &PrintName, 0) * 2;
 
        printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen);
 
@@ -276,6 +277,7 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
        stream_write_uint16(printer_dev->device.data, 0);
        stream_write(printer_dev->device.data, PrintName, PrintNameLen);
        stream_write_uint16(printer_dev->device.data, 0);
+
        if (CachedFieldsLen > 0)
        {
                stream_write(printer_dev->device.data, CachedPrinterConfigData, CachedFieldsLen);
index 390d254..bb5939b 100644 (file)
@@ -94,14 +94,15 @@ static void rdpdr_send_client_announce_reply(rdpdrPlugin* rdpdr)
 
 static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
 {
-       char* s;
        STREAM* data_out;
+       WCHAR* computerNameW;
        size_t computerNameLenW;
 
        if (!rdpdr->computerName[0])
                gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1);
 
-       s = freerdp_uniconv_out(rdpdr->computerName, &computerNameLenW);
+       computerNameLenW = freerdp_AsciiToUnicodeAlloc(rdpdr->computerName, &computerNameW, 0) * 2;
+
        data_out = stream_new(16 + computerNameLenW + 2);
 
        stream_write_uint16(data_out, RDPDR_CTYP_CORE);
@@ -110,10 +111,10 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
        stream_write_uint32(data_out, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */
        stream_write_uint32(data_out, 0); /* codePage, must be set to zero */
        stream_write_uint32(data_out, computerNameLenW + 2); /* computerNameLen, including null terminator */
-       stream_write(data_out, s, computerNameLenW);
+       stream_write(data_out, computerNameW, computerNameLenW);
        stream_write_uint16(data_out, 0); /* null terminator */
 
-       xfree(s);
+       xfree(computerNameW);
 
        svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out);
 }
index 55bc429..6ada96f 100644 (file)
@@ -527,19 +527,17 @@ static uint8* xf_cliprdr_process_requested_raw(uint8* data, int* size)
 
 static uint8* xf_cliprdr_process_requested_unicodetext(uint8* data, int* size)
 {
-       uint8* inbuf;
-       uint8* outbuf;
-       size_t out_size;
-
-       inbuf = lf2crlf(data, size);
-
-       outbuf = (uint8*) freerdp_uniconv_out((char*) inbuf, &out_size);
+       char* inbuf;
+       WCHAR* outbuf;
+       int out_size;
 
+       inbuf = (char*) lf2crlf(data, size);
+       out_size = freerdp_AsciiToUnicodeAlloc(inbuf, &outbuf, 0);
        xfree(inbuf);
 
-       *size = (int) out_size + 2;
+       *size = (int) ((out_size + 1) * 2);
 
-       return outbuf;
+       return (uint8*) outbuf;
 }
 
 static uint8* xf_cliprdr_process_requested_text(uint8* data, int* size)
index c43dadb..732f584 100644 (file)
@@ -25,7 +25,6 @@
 #include <freerdp/api.h>
 
 FREERDP_API char* freerdp_uniconv_in(unsigned char* pin, size_t in_len);
-FREERDP_API char* freerdp_uniconv_out(const char *str, size_t *pout_len);
 
 #include <freerdp/types.h>
 
index 3c6d732..bfa0c25 100644 (file)
@@ -612,7 +612,7 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block
        }
 
        /*
-        * If we are in server mode, accepth client's color depth only if
+        * If we are in server mode, accept client's color depth only if
         * it is smaller than ours. This is what Windows server does.
         */
        if (color_depth < settings->color_depth || !settings->server_mode)
@@ -631,20 +631,21 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block
 void gcc_write_client_core_data(STREAM* s, rdpSettings* settings)
 {
        uint32 version;
-       char* clientName;
-       size_t clientNameLength;
+       WCHAR* clientName;
+       int clientNameLength;
        uint8 connectionType;
        uint16 highColorDepth;
        uint16 supportedColorDepths;
        uint16 earlyCapabilityFlags;
-       char* clientDigProductId;
-       size_t clientDigProductIdLength;
+       WCHAR* clientDigProductId;
+       int clientDigProductIdLength;
 
        gcc_write_user_data_header(s, CS_CORE, 216);
 
        version = settings->rdp_version >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4;
-       clientName = freerdp_uniconv_out(settings->client_hostname, &clientNameLength);
-       clientDigProductId = freerdp_uniconv_out(settings->client_product_id, &clientDigProductIdLength);
+
+       clientNameLength = freerdp_AsciiToUnicodeAlloc(settings->client_hostname, &clientName, 0);
+       clientDigProductIdLength = freerdp_AsciiToUnicodeAlloc(settings->client_product_id, &clientDigProductId, 0);
 
        stream_write_uint32(s, version); /* version */
        stream_write_uint16(s, settings->width); /* desktopWidth */
@@ -655,14 +656,15 @@ void gcc_write_client_core_data(STREAM* s, rdpSettings* settings)
        stream_write_uint32(s, settings->client_build); /* clientBuild */
 
        /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
-       if (clientNameLength > 30)
+
+       if (clientNameLength > 15)
        {
-               clientNameLength = 30;
+               clientNameLength = 15;
                clientName[clientNameLength] = 0;
-               clientName[clientNameLength + 1] = 0;
        }
-       stream_write(s, clientName, clientNameLength + 2);
-       stream_write_zero(s, 32 - clientNameLength - 2);
+
+       stream_write(s, clientName, ((clientNameLength + 1) * 2));
+       stream_write_zero(s, 32 - ((clientNameLength + 1) * 2));
        xfree(clientName);
 
        stream_write_uint32(s, settings->kbd_type); /* keyboardType */
index 8f5ac3a..e059839 100644 (file)
@@ -158,23 +158,20 @@ boolean rdp_read_extended_info_packet(STREAM* s, rdpSettings* settings)
 
 void rdp_write_extended_info_packet(STREAM* s, rdpSettings* settings)
 {
-       size_t length;
-       uint16 clientAddressFamily;
-       uint8* clientAddress;
-       uint16 cbClientAddress;
-       uint8* clientDir;
-       uint16 cbClientDir;
-       uint16 cbAutoReconnectLen;
+       int clientAddressFamily;
+       WCHAR* clientAddress;
+       int cbClientAddress;
+       WCHAR* clientDir;
+       int cbClientDir;
+       int cbAutoReconnectLen;
 
        clientAddressFamily = settings->ipv6 ? ADDRESS_FAMILY_INET6 : ADDRESS_FAMILY_INET;
 
-       clientAddress = (uint8*) freerdp_uniconv_out(settings->ip_address, &length);
-       cbClientAddress = length;
+       cbClientAddress = freerdp_AsciiToUnicodeAlloc(settings->ip_address, &clientAddress, 0) * 2;
 
-       clientDir = (uint8*) freerdp_uniconv_out(settings->client_dir, &length);
-       cbClientDir = length;
+       cbClientDir = freerdp_AsciiToUnicodeAlloc(settings->client_dir, &clientDir, 0) * 2;
 
-       cbAutoReconnectLen = settings->client_auto_reconnect_cookie->cbLen;
+       cbAutoReconnectLen = (int) settings->client_auto_reconnect_cookie->cbLen;
 
        stream_write_uint16(s, clientAddressFamily); /* clientAddressFamily */
 
@@ -297,18 +294,17 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings)
 
 void rdp_write_info_packet(STREAM* s, rdpSettings* settings)
 {
-       size_t length;
        uint32 flags;
-       uint8* domain;
-       uint16 cbDomain;
-       uint8* userName;
-       uint16 cbUserName;
-       uint8* password;
-       uint16 cbPassword;
-       uint8* alternateShell;
-       uint16 cbAlternateShell;
-       uint8* workingDir;
-       uint16 cbWorkingDir;
+       WCHAR* domain;
+       int cbDomain;
+       WCHAR* userName;
+       int cbUserName;
+       WCHAR* password;
+       int cbPassword;
+       WCHAR* alternateShell;
+       int cbAlternateShell;
+       WCHAR* workingDir;
+       int cbWorkingDir;
        boolean usedPasswordCookie = false;
 
        flags = INFO_MOUSE |
@@ -337,29 +333,32 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings)
        if (settings->compression)
                flags |= INFO_COMPRESSION | INFO_PACKET_COMPR_TYPE_RDP6;
 
-       domain = (uint8*) freerdp_uniconv_out(settings->domain, &length);
-       cbDomain = length;
+       if (settings->domain)
+       {
+               cbDomain = freerdp_AsciiToUnicodeAlloc(settings->domain, &domain, 0) * 2;
+       }
+       else
+       {
+               domain = NULL;
+               cbDomain = 0;
+       }
 
-       userName = (uint8*) freerdp_uniconv_out(settings->username, &length);
-       cbUserName = length;
+       cbUserName = freerdp_AsciiToUnicodeAlloc(settings->username, &userName, 0) * 2;
 
        if (settings->password_cookie && settings->password_cookie->length > 0)
        {
                usedPasswordCookie = true;
-               password = (uint8*)settings->password_cookie->data;
+               password = (WCHAR*) settings->password_cookie->data;
                cbPassword = settings->password_cookie->length - 2;     /* Strip double zero termination */
        }
        else
        {
-               password = (uint8*) freerdp_uniconv_out(settings->password, &length);
-               cbPassword = length;
+               cbPassword = freerdp_AsciiToUnicodeAlloc(settings->password, &password, 0) * 2;
        }
 
-       alternateShell = (uint8*) freerdp_uniconv_out(settings->shell, &length);
-       cbAlternateShell = length;
+       cbAlternateShell = freerdp_AsciiToUnicodeAlloc(settings->shell, &alternateShell, 0) * 2;
 
-       workingDir = (uint8*) freerdp_uniconv_out(settings->directory, &length);
-       cbWorkingDir = length;
+       cbWorkingDir = freerdp_AsciiToUnicodeAlloc(settings->directory, &workingDir, 0) * 2;
 
        stream_write_uint32(s, 0); /* CodePage */
        stream_write_uint32(s, flags); /* flags */
index 502d7e7..0f32013 100644 (file)
@@ -235,8 +235,8 @@ boolean nego_send_preconnection_pdu(rdpNego* nego)
 {
        STREAM* s;
        uint32 cbSize;
-       uint16 cchPCB_times2 = 0;
-       char* wszPCB = NULL;
+       uint16 cchPCB = 0;
+       WCHAR* wszPCB = NULL;
 
        if (!nego->send_preconnection_pdu)
                return true;
@@ -251,11 +251,9 @@ boolean nego_send_preconnection_pdu(rdpNego* nego)
 
        if (nego->preconnection_blob)
        {
-               size_t size;
-               wszPCB = freerdp_uniconv_out(nego->preconnection_blob, &size);
-               cchPCB_times2 = (uint16) size;
-               cchPCB_times2 += 2; /* zero-termination */
-               cbSize += cchPCB_times2;
+               cchPCB = (uint16) freerdp_AsciiToUnicodeAlloc(nego->preconnection_blob, &wszPCB, 0);
+               cchPCB += 1; /* zero-termination */
+               cbSize += cchPCB * 2;
        }
 
        s = transport_send_stream_init(nego->transport, cbSize);
@@ -263,11 +261,11 @@ boolean nego_send_preconnection_pdu(rdpNego* nego)
        stream_write_uint32(s, 0); /* Flags */
        stream_write_uint32(s, PRECONNECTION_PDU_V2); /* Version */
        stream_write_uint32(s, nego->preconnection_id); /* Id */
-       stream_write_uint16(s, cchPCB_times2 / 2); /* cchPCB */
+       stream_write_uint16(s, cchPCB); /* cchPCB */
 
        if (wszPCB)
        {
-               stream_write(s, wszPCB, cchPCB_times2); /* wszPCB */
+               stream_write(s, wszPCB, cchPCB * 2); /* wszPCB */
                xfree(wszPCB);
        }
 
index 3bccf9c..0361ab6 100644 (file)
@@ -119,21 +119,17 @@ void rdp_write_client_time_zone(STREAM* s, rdpSettings* settings)
        uint32 bias;
        sint32 sbias;
        uint32 bias2c;
-       size_t length;
-       uint8* standardName;
-       uint8* daylightName;
-       size_t standardNameLength;
-       size_t daylightNameLength;
+       WCHAR* standardName;
+       WCHAR* daylightName;
+       int standardNameLength;
+       int daylightNameLength;
        TIME_ZONE_INFO* clientTimeZone;
 
        clientTimeZone = settings->client_time_zone;
        freerdp_time_zone_detect(clientTimeZone);
 
-       standardName = (uint8*) freerdp_uniconv_out(clientTimeZone->standardName, &length);
-       standardNameLength = length;
-
-       daylightName = (uint8*) freerdp_uniconv_out(clientTimeZone->daylightName, &length);
-       daylightNameLength = length;
+       standardNameLength = freerdp_AsciiToUnicodeAlloc(clientTimeZone->standardName, &standardName, 0) * 2;
+       daylightNameLength = freerdp_AsciiToUnicodeAlloc(clientTimeZone->daylightName, &daylightName, 0) * 2;
 
        if (standardNameLength > 62)
                standardNameLength = 62;
@@ -161,6 +157,7 @@ void rdp_write_client_time_zone(STREAM* s, rdpSettings* settings)
        stream_write_zero(s, 64 - standardNameLength);
 
        rdp_write_system_time(s, &clientTimeZone->standardDate); /* StandardDate */
+
        DEBUG_TIMEZONE("bias=%d stdName='%s' dlName='%s'",
                bias, clientTimeZone->standardName, clientTimeZone->daylightName);
 
index 5a4f425..f643f24 100644 (file)
@@ -460,8 +460,8 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port)
        STREAM* s_p4;
        int status = -1;
        rdpRpc* rpc = tsg->rpc;
-       uint8* dest_addr_unic;
-       uint32 dest_addr_unic_len;
+       WCHAR* dest_addr_unic;
+       int dest_addr_unic_len;
 
        if (!rpc_connect(rpc))
        {
@@ -571,7 +571,7 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port)
        }
        status = -1;
 
-       dest_addr_unic = (uint8*) freerdp_uniconv_out(hostname, (size_t*) &dest_addr_unic_len);
+       dest_addr_unic_len = freerdp_AsciiToUnicodeAlloc(hostname, &dest_addr_unic, 0) * 2;
 
        memcpy(tsg_packet4 + 4, tsg->TunnelContext, 16);
        memcpy(tsg_packet4 + 38, &port, 2);
index 3ea8d16..123784f 100644 (file)
 
 #include <winpr/crt.h>
 
-char* freerdp_uniconv_out(const char *str, size_t* pout_len)
-{
-       WCHAR* wstr;
-       int length;
-
-       length = freerdp_AsciiToUnicodeAlloc(str, &wstr, 0);
-       *pout_len = (size_t) length;
-
-       return (char*) wstr;
-}
-
 int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length)
 {
        if (!str)
@@ -59,8 +48,6 @@ int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length)
        MultiByteToWideChar(CP_UTF8, 0, str, length, (LPWSTR) (*wstr), length * sizeof(WCHAR));
        (*wstr)[length] = 0;
 
-       length *= 2;
-
        return length;
 }