}
else
{
- format_name->length = freerdp_UnicodeToAsciiAlloc((WCHAR*) s->p, &format_name->name, 32 / 2);
+ format_name->length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) s->p, 32 / 2, &format_name->name, 0, NULL, NULL);
}
stream_seek(s, 32);
break;
}
- format_name->length = freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &format_name->name, name_len / 2);
+ format_name->length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), name_len / 2, &format_name->name, 0, NULL, NULL);
+
stream_seek(s, name_len + 2);
}
}
BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UINT32 Length, STREAM* input)
{
char* s;
-
mode_t m;
UINT64 size;
+ int status;
char* fullpath;
struct STAT st;
struct timeval tv[2];
stream_seek_BYTE(input); /* RootDirectory */
stream_read_UINT32(input, FileNameLength);
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(input), &s, FileNameLength / 2);
+ status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(input),
+ FileNameLength / 2, &s, 0, NULL, NULL);
+
+ if (status < 1)
+ s = (char*) calloc(1, 1);
fullpath = drive_file_combine_fullpath(file->basepath, s);
free(s);
static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp)
{
char* path;
+ int status;
UINT32 FileId;
DRIVE_FILE* file;
BYTE Information;
stream_read_UINT32(irp->input, CreateOptions);
stream_read_UINT32(irp->input, PathLength);
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2);
+ status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input),
+ PathLength / 2, &path, 0, NULL, NULL);
+
+ if (status < 1)
+ path = (char*) calloc(1, 1);
FileId = irp->devman->id_sequence++;
static void drive_process_irp_query_directory(DRIVE_DEVICE* disk, IRP* irp)
{
char* path;
+ int status;
DRIVE_FILE* file;
BYTE InitialQuery;
UINT32 PathLength;
stream_read_UINT32(irp->input, PathLength);
stream_seek(irp->input, 23); /* Padding */
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2);
+ status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input),
+ PathLength / 2, &path, 0, NULL, NULL);
+
+ if (status < 1)
+ path = (char*) calloc(1, 1);
file = drive_get_file_by_id(disk, irp->FileId);
static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp)
{
char* path;
+ int status;
UINT32 PathLength;
stream_seek(irp->input, 28);
/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */
stream_read_UINT32(irp->input, PathLength);
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2);
+ status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input),
+ PathLength / 2, &path, 0, NULL, NULL);
+
+ if (status < 1)
+ path = (char*) calloc(1, 1);
parallel->id = irp->devman->id_sequence++;
parallel->file = open(parallel->path, O_RDWR);
#include "serial_tty.h"
#include "serial_constants.h"
+#include <winpr/crt.h>
+
#include <freerdp/freerdp.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/thread.h>
static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
{
char* path;
+ int status;
SERIAL_TTY* tty;
UINT32 PathLength;
UINT32 FileId;
/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */
stream_read_UINT32(irp->input, PathLength);
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2);
+ status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input),
+ PathLength / 2, &path, 0, NULL, NULL);
+
+ if (status < 1)
+ path = (char*) calloc(1, 1);
FileId = irp->devman->id_sequence++;
if ((BYTE) data[0] == 0xFF && (BYTE) data[1] == 0xFE)
{
- freerdp_UnicodeToAsciiAlloc((WCHAR*) (data + 2), &inbuf, (*size - 2) / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) (data + 2),
+ (*size - 2) / 2, &inbuf, 0, NULL, NULL);
}
}
static void xf_cliprdr_process_unicodetext(clipboardContext* cb, BYTE* data, int size)
{
- cb->data_length = freerdp_UnicodeToAsciiAlloc((WCHAR*) data, (CHAR**) &(cb->data), size / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) data, size / 2, (CHAR**) &(cb->data), 0, NULL, NULL);
crlf2lf(cb->data, &cb->data_length);
}
#include <freerdp/types.h>
FREERDP_API int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length);
-FREERDP_API int freerdp_UnicodeToAsciiAlloc(const WCHAR* wstr, CHAR** str, int length);
#endif /* FREERDP_UTILS_UNICODE_H */
stream_read_UINT32(s, settings->ClientBuild); /* ClientBuild */
/* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &str, 32 / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 32 / 2, &str, 0, NULL, NULL);
stream_seek(s, 32);
sprintf_s(settings->ClientHostname, 31, "%s", str);
settings->ClientHostname[31] = 0;
if (blockLength < 64)
break;
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &str, 64 / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 64 / 2, &str, 0, NULL, NULL);
stream_seek(s, 64);
sprintf_s(settings->ClientProductId, 32, "%s", str);
free(str);
#include "config.h"
#endif
+#include <winpr/crt.h>
+
#include <freerdp/utils/unicode.h>
#include "timezone.h"
if (stream_get_left(s) < cbClientAddress)
return FALSE;
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->ClientAddress, cbClientAddress / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbClientAddress / 2, &settings->ClientAddress, 0, NULL, NULL);
stream_seek(s, cbClientAddress);
stream_read_UINT16(s, cbClientDir); /* cbClientDir */
if (settings->ClientDir)
free(settings->ClientDir);
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->ClientDir, cbClientDir / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbClientDir / 2, &settings->ClientDir, 0, NULL, NULL);
stream_seek(s, cbClientDir);
if (!rdp_read_client_time_zone(s, settings))
if (cbDomain > 0)
{
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->Domain, cbDomain / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbDomain / 2, &settings->Domain, 0, NULL, NULL);
stream_seek(s, cbDomain);
}
stream_seek(s, 2);
if (cbUserName > 0)
{
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->Username, cbUserName / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbUserName / 2, &settings->Username, 0, NULL, NULL);
stream_seek(s, cbUserName);
}
stream_seek(s, 2);
if (cbPassword > 0)
{
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->Password, cbPassword / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbPassword / 2, &settings->Password, 0, NULL, NULL);
stream_seek(s, cbPassword);
}
stream_seek(s, 2);
if (cbAlternateShell > 0)
{
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->AlternateShell, cbAlternateShell / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbAlternateShell / 2, &settings->AlternateShell, 0, NULL, NULL);
stream_seek(s, cbAlternateShell);
}
stream_seek(s, 2);
if (cbWorkingDir > 0)
{
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->ShellWorkingDirectory, cbWorkingDir / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbWorkingDir / 2, &settings->ShellWorkingDirectory, 0, NULL, NULL);
stream_seek(s, cbWorkingDir);
}
stream_seek(s, 2);
#include "config.h"
#endif
+#include <winpr/crt.h>
+
#include <freerdp/utils/unicode.h>
#include "timezone.h"
stream_read_UINT32(s, clientTimeZone->bias); /* Bias */
/* standardName (64 bytes) */
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &str, 64 / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 64 / 2, &str, 0, NULL, NULL);
stream_seek(s, 64);
strncpy(clientTimeZone->standardName, str, sizeof(clientTimeZone->standardName));
free(str);
stream_read_UINT32(s, clientTimeZone->standardBias); /* StandardBias */
/* daylightName (64 bytes) */
- freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &str, 64 / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 64 / 2, &str, 0, NULL, NULL);
stream_seek(s, 64);
strncpy(clientTimeZone->daylightName, str, sizeof(clientTimeZone->daylightName));
free(str);
{
if (window->titleInfo.length > 0)
{
- freerdp_UnicodeToAsciiAlloc((WCHAR*) window->titleInfo.string, &window->title, window->titleInfo.length / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) window->titleInfo.string, window->titleInfo.length / 2,
+ &window->title, 0, NULL, NULL);
}
else
{
if (window->title != NULL)
free(window->title);
- freerdp_UnicodeToAsciiAlloc((WCHAR*) window->titleInfo.string, &window->title, window->titleInfo.length / 2);
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) window->titleInfo.string, window->titleInfo.length / 2,
+ &window->title, 0, NULL, NULL);
IFCALL(rail->rail_SetWindowText, rail, window);
}
#include <stdlib.h>
#include <string.h>
-#include <freerdp/utils/unicode.h>
+#include <winpr/crt.h>
#include <freerdp/utils/string.h>
stream_read_UINT32(s, string->length);
string->unicode = (char*) malloc(string->length);
stream_read(s, string->unicode, string->length);
- freerdp_UnicodeToAsciiAlloc((WCHAR*) string->unicode, &string->ascii, string->length / 2);
+
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) string->unicode, string->length / 2, &string->ascii, 0, NULL, NULL);
}
void freerdp_string_free(rdpString* string)
return status;
}
-
-int freerdp_UnicodeToAsciiAlloc(const WCHAR* wstr, CHAR** str, int length)
-{
- int status;
-
- if (length < 1)
- {
- *str = malloc(1);
- (*str)[0] = '\0';
- return 0;
- }
-
- status = ConvertFromUnicode(CP_UTF8, 0, wstr, -1, str, 0, NULL, NULL);
-
- return status;
-}