libfreerdp-utils: get rid of UNICONV unicode conversion context

This commit is contained in:
Marc-André Moreau 2012-09-23 18:41:07 -04:00
parent 1059337d90
commit 44f18159c4
40 changed files with 111 additions and 186 deletions

View File

@ -143,7 +143,7 @@ void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint3
}
else
{
format_name->name = freerdp_uniconv_in(cliprdr->uniconv, s->p, 32);
format_name->name = freerdp_uniconv_in(s->p, 32);
format_name->length = strlen(format_name->name);
}
@ -187,7 +187,7 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint32
break;
}
format_name->name = freerdp_uniconv_in(cliprdr->uniconv, stream_get_tail(s), name_len);
format_name->name = freerdp_uniconv_in(stream_get_tail(s), name_len);
format_name->length = strlen(format_name->name);
stream_seek(s, name_len + 2);
}

View File

@ -82,8 +82,6 @@ void cliprdr_packet_send(cliprdrPlugin* cliprdr, STREAM* s)
static void cliprdr_process_connect(rdpSvcPlugin* plugin)
{
DEBUG_CLIPRDR("connecting");
((cliprdrPlugin*) plugin)->uniconv = freerdp_uniconv_new();
}
void cliprdr_print_general_capability_flags(uint32 flags)
@ -267,11 +265,6 @@ static void cliprdr_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event)
static void cliprdr_process_terminate(rdpSvcPlugin* plugin)
{
cliprdrPlugin* cliprdr_plugin = (cliprdrPlugin*) plugin;
if (cliprdr_plugin->uniconv != NULL)
freerdp_uniconv_free(cliprdr_plugin->uniconv);
xfree(plugin);
}

View File

@ -35,7 +35,6 @@ typedef struct _CLIPRDR_FORMAT_NAME CLIPRDR_FORMAT_NAME;
struct cliprdr_plugin
{
rdpSvcPlugin plugin;
UNICONV* uniconv;
boolean received_caps;
boolean use_long_format_names;
boolean stream_fileclip_enabled;

View File

@ -29,7 +29,6 @@
struct rdp_rail_order
{
UNICONV* uniconv;
RDP_PLUGIN_DATA* plugin_data;
void* plugin;
RAIL_HANDSHAKE_ORDER handshake;

View File

@ -24,6 +24,7 @@
#include <freerdp/utils/rail.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/unicode.h>
#include "rail_orders.h"
@ -78,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(rail_order->uniconv, string, &length);
buffer = freerdp_uniconv_out(string, &length);
unicode_string->string = (uint8*) buffer;
unicode_string->length = (uint16) length;
@ -631,7 +632,7 @@ rdpRailOrder* rail_order_new()
if (rail_order != NULL)
{
rail_order->uniconv = freerdp_uniconv_new();
}
return rail_order;
@ -641,7 +642,7 @@ void rail_order_free(rdpRailOrder* rail_order)
{
if (rail_order != NULL)
{
freerdp_uniconv_free(rail_order->uniconv);
xfree(rail_order);
}
}

View File

@ -36,8 +36,10 @@
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/unicode.h>
#include <freerdp/utils/svc_plugin.h>
#ifdef HAVE_UNISTD_H
@ -425,7 +427,6 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui
uint64 size;
char* fullpath;
struct STAT st;
UNICONV* uniconv;
struct timeval tv[2];
uint64 LastWriteTime;
uint32 FileAttributes;
@ -485,9 +486,8 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui
stream_seek_uint8(input); /* ReplaceIfExists */
stream_seek_uint8(input); /* RootDirectory */
stream_read_uint32(input, FileNameLength);
uniconv = freerdp_uniconv_new();
s = freerdp_uniconv_in(uniconv, stream_get_tail(input), FileNameLength);
freerdp_uniconv_free(uniconv);
s = freerdp_uniconv_in(stream_get_tail(input), FileNameLength);
fullpath = disk_file_combine_fullpath(file->basepath, s);
xfree(s);
@ -520,7 +520,6 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
struct dirent* ent;
char* ent_path;
struct STAT st;
UNICONV* uniconv;
size_t len;
boolean ret;
@ -549,6 +548,7 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
do
{
ent = readdir(file->dir);
if (ent == NULL)
continue;
@ -572,6 +572,7 @@ 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);
if (STAT(ent_path, &st) != 0)
{
DEBUG_WARN("stat %s failed. errno = %d", ent_path, errno);
@ -580,9 +581,7 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui
DEBUG_SVC(" pattern %s matched %s", file->pattern, ent_path);
xfree(ent_path);
uniconv = freerdp_uniconv_new();
ent_path = freerdp_uniconv_out(uniconv, ent->d_name, &len);
freerdp_uniconv_free(uniconv);
ent_path = freerdp_uniconv_out(ent->d_name, &len);
ret = true;
switch (FsInformationClass)

View File

@ -123,7 +123,6 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp)
uint32 CreateDisposition;
uint32 CreateOptions;
uint32 PathLength;
UNICONV* uniconv;
char* path;
uint32 FileId;
uint8 Information;
@ -134,9 +133,7 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp)
stream_read_uint32(irp->input, CreateOptions);
stream_read_uint32(irp->input, PathLength);
uniconv = freerdp_uniconv_new();
path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength);
freerdp_uniconv_free(uniconv);
path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength);
FileId = irp->devman->id_sequence++;
@ -388,7 +385,6 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
STREAM* output = irp->output;
struct STATVFS svfst;
struct STAT st;
UNICONV* uniconv;
char* volumeLabel = {"FREERDP"}; /* TODO: Add sub routine to correctly pick up Volume Label name for each O/S supported */
char* diskType = {"FAT32"};
char* outStr;
@ -403,9 +399,7 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
{
case FileFsVolumeInformation:
/* http://msdn.microsoft.com/en-us/library/cc232108.aspx */
uniconv = freerdp_uniconv_new();
outStr = freerdp_uniconv_out(uniconv, volumeLabel, &len);
freerdp_uniconv_free(uniconv);
outStr = freerdp_uniconv_out(volumeLabel, &len);
stream_write_uint32(output, 17 + len); /* Length */
stream_check_size(output, 17 + len);
stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* VolumeCreationTime */
@ -429,9 +423,7 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
case FileFsAttributeInformation:
/* http://msdn.microsoft.com/en-us/library/cc232101.aspx */
uniconv = freerdp_uniconv_new();
outStr = freerdp_uniconv_out(uniconv, diskType, &len);
freerdp_uniconv_free(uniconv);
outStr = freerdp_uniconv_out(diskType, &len);
stream_write_uint32(output, 12 + len); /* Length */
stream_check_size(output, 12 + len);
@ -480,7 +472,6 @@ static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp)
uint32 FsInformationClass;
uint8 InitialQuery;
uint32 PathLength;
UNICONV* uniconv;
char* path;
stream_read_uint32(irp->input, FsInformationClass);
@ -488,9 +479,7 @@ static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp)
stream_read_uint32(irp->input, PathLength);
stream_seek(irp->input, 23); /* Padding */
uniconv = freerdp_uniconv_new();
path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength);
freerdp_uniconv_free(uniconv);
path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength);
file = disk_get_file_by_id(disk, irp->FileId);

View File

@ -50,6 +50,7 @@
#include <freerdp/utils/thread.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/unicode.h>
#include <freerdp/utils/svc_plugin.h>
#include "rdpdr_constants.h"
@ -70,18 +71,15 @@ typedef struct _PARALLEL_DEVICE PARALLEL_DEVICE;
static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp)
{
uint32 PathLength;
char* path;
UNICONV* uniconv;
uint32 PathLength;
stream_seek(irp->input, 28);
/* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */
/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */
stream_read_uint32(irp->input, PathLength);
uniconv = freerdp_uniconv_new();
path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength);
freerdp_uniconv_free(uniconv);
path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength);
parallel->id = irp->devman->id_sequence++;
parallel->file = open(parallel->path, O_RDWR);

View File

@ -230,9 +230,7 @@ static void printer_free(DEVICE* device)
void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* printer)
{
PRINTER_DEVICE* printer_dev;
char* port;
UNICONV* uniconv;
uint32 Flags;
size_t DriverNameLen;
char* DriverName;
@ -240,6 +238,7 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
char* PrintName;
uint32 CachedFieldsLen;
uint8* CachedPrinterConfigData;
PRINTER_DEVICE* printer_dev;
port = xmalloc(10);
snprintf(port, 10, "PRN%d", printer->id);
@ -262,10 +261,8 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
if (printer->is_default)
Flags |= RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER;
uniconv = freerdp_uniconv_new();
DriverName = freerdp_uniconv_out(uniconv, printer->driver, &DriverNameLen);
PrintName = freerdp_uniconv_out(uniconv, printer->name, &PrintNameLen);
freerdp_uniconv_free(uniconv);
DriverName = freerdp_uniconv_out(printer->driver, &DriverNameLen);
PrintName = freerdp_uniconv_out(printer->name, &PrintNameLen);
printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen);

View File

@ -96,15 +96,12 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
{
char* s;
STREAM* data_out;
UNICONV* uniconv;
size_t computerNameLenW;
uniconv = freerdp_uniconv_new();
if (!rdpdr->computerName[0])
gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1);
s = freerdp_uniconv_out(uniconv, rdpdr->computerName, &computerNameLenW);
s = freerdp_uniconv_out(rdpdr->computerName, &computerNameLenW);
data_out = stream_new(16 + computerNameLenW + 2);
stream_write_uint16(data_out, RDPDR_CTYP_CORE);
@ -117,7 +114,6 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
stream_write_uint16(data_out, 0); /* null terminator */
xfree(s);
freerdp_uniconv_free(uniconv);
svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out);
}

View File

@ -79,23 +79,21 @@ static boolean serial_check_fds(SERIAL_DEVICE* serial);
static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
{
char* path;
SERIAL_TTY* tty;
uint32 PathLength;
uint32 FileId;
char* path;
UNICONV* uniconv;
stream_seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */
/* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */
stream_read_uint32(irp->input, PathLength);
uniconv = freerdp_uniconv_new();
path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength);
freerdp_uniconv_free(uniconv);
path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength);
FileId = irp->devman->id_sequence++;
tty = serial_tty_new(serial->path, FileId);
if (tty == NULL)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -122,6 +120,7 @@ static void serial_process_irp_close(SERIAL_DEVICE* serial, IRP* irp)
SERIAL_TTY* tty;
tty = serial->tty;
if (tty == NULL)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -153,6 +152,7 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
DEBUG_SVC("length %u offset %llu", Length, Offset);
tty = serial->tty;
if (tty == NULL)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -179,11 +179,13 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
}
stream_write_uint32(irp->output, Length);
if (Length > 0)
{
stream_check_size(irp->output, Length);
stream_write(irp->output, buffer, Length);
}
xfree(buffer);
irp->Complete(irp);
@ -202,6 +204,7 @@ static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp)
DEBUG_SVC("length %u offset %llu", Length, Offset);
tty = serial->tty;
if (tty == NULL)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -243,6 +246,7 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp)
stream_seek(irp->input, 20); /* Padding */
tty = serial->tty;
if (tty == NULL)
{
irp->IoStatus = STATUS_UNSUCCESSFUL;

View File

@ -530,13 +530,10 @@ static uint8* xf_cliprdr_process_requested_unicodetext(uint8* data, int* size)
uint8* inbuf;
uint8* outbuf;
size_t out_size;
UNICONV* uniconv;
inbuf = lf2crlf(data, size);
uniconv = freerdp_uniconv_new();
outbuf = (uint8*) freerdp_uniconv_out(uniconv, (char*) inbuf, &out_size);
freerdp_uniconv_free(uniconv);
outbuf = (uint8*) freerdp_uniconv_out((char*) inbuf, &out_size);
xfree(inbuf);
@ -578,9 +575,9 @@ static uint8* xf_cliprdr_process_requested_html(uint8* data, int* size)
uint8* in;
uint8* outbuf;
char num[11];
UNICONV* uniconv;
inbuf = NULL;
if (*size > 2)
{
if ((uint8) data[0] == 0xFE && (uint8) data[1] == 0xFF)
@ -590,11 +587,10 @@ static uint8* xf_cliprdr_process_requested_html(uint8* data, int* size)
if ((uint8) data[0] == 0xFF && (uint8) data[1] == 0xFE)
{
uniconv = freerdp_uniconv_new();
inbuf = (uint8*) freerdp_uniconv_in(uniconv, data + 2, *size - 2);
freerdp_uniconv_free(uniconv);
inbuf = (uint8*) freerdp_uniconv_in(data + 2, *size - 2);
}
}
if (inbuf == NULL)
{
inbuf = xzalloc(*size + 1);
@ -884,11 +880,7 @@ static void xf_cliprdr_process_text(clipboardContext* cb, uint8* data, int size)
static void xf_cliprdr_process_unicodetext(clipboardContext* cb, uint8* data, int size)
{
UNICONV* uniconv;
uniconv = freerdp_uniconv_new();
cb->data = (uint8*) freerdp_uniconv_in(uniconv, data, size);
freerdp_uniconv_free(uniconv);
cb->data = (uint8*) freerdp_uniconv_in(data, size);
cb->data_length = strlen((char*) cb->data);
crlf2lf(cb->data, &cb->data_length);
}

View File

@ -45,7 +45,6 @@ typedef void (*railDesktopNonMonitored) (rdpRail* rail, rdpWindow* window);
struct rdp_rail
{
void* extra;
UNICONV* uniconv;
CLRCONV* clrconv;
rdpIconCache* cache;
rdpWindowList* list;

View File

@ -22,7 +22,6 @@
#include <freerdp/types.h>
#include <freerdp/utils/blob.h>
#include <freerdp/utils/unicode.h>
/* Performance Flags */
#define PERF_FLAG_NONE 0x00000000
@ -317,7 +316,7 @@ struct rdp_settings
ALIGN64 char* home_path; /* 112 */
ALIGN64 uint32 share_id; /* 113 */
ALIGN64 uint32 pdu_source; /* 114 */
ALIGN64 UNICONV* uniconv; /* 115 */
ALIGN64 void* unused115; /* 115 */
ALIGN64 boolean server_mode; /* 116 */
ALIGN64 char* config_path; /* 117 */
ALIGN64 char* current_path; /* 118 */

View File

@ -23,7 +23,6 @@
#include <freerdp/api.h>
#include <freerdp/types.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/unicode.h>
struct rdp_string
{
@ -33,7 +32,7 @@ struct rdp_string
};
typedef struct rdp_string rdpString;
FREERDP_API void freerdp_string_read_length32(STREAM* s, rdpString* string, UNICONV* uniconv);
FREERDP_API void freerdp_string_read_length32(STREAM* s, rdpString* string);
FREERDP_API void freerdp_string_free(rdpString* string);
#endif /* __STRING_UTILS_H */

View File

@ -24,31 +24,8 @@
#include <string.h>
#include <freerdp/api.h>
#define DEFAULT_CODEPAGE "UTF-8"
#define WINDOWS_CODEPAGE "UTF-16LE"
#ifdef HAVE_ICONV
#include <iconv.h>
#endif
#ifndef ICONV_CONST
#define ICONV_CONST ""
#endif
struct _UNICONV
{
int iconv;
#ifdef HAVE_ICONV
iconv_t* in_iconv_h;
iconv_t* out_iconv_h;
#endif
};
typedef struct _UNICONV UNICONV;
FREERDP_API UNICONV* freerdp_uniconv_new();
FREERDP_API void freerdp_uniconv_free(UNICONV *uniconv);
FREERDP_API char* freerdp_uniconv_in(UNICONV *uniconv, unsigned char* pin, size_t in_len);
FREERDP_API char* freerdp_uniconv_out(UNICONV *uniconv, const char *str, size_t *pout_len);
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>

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <stdio.h>
#include <freerdp/freerdp.h>
#include <freerdp/constants.h>
#include <freerdp/utils/stream.h>

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <stdio.h>
#include <freerdp/update.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/stream.h>

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <stdio.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/memory.h>

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <stdio.h>
#include <freerdp/update.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/stream.h>

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <stdio.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/memory.h>

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <stdio.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/memory.h>

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <stdio.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/memory.h>

View File

@ -22,9 +22,12 @@
#include "config.h"
#endif
#include <freerdp/codec/mppc_dec.h>
#include <stdio.h>
#include <freerdp/utils/memory.h>
#include <freerdp/codec/mppc_dec.h>
static uint8 HuffLenLEC[] = {
0x6, 0x6, 0x6, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x9, 0x8, 0x9, 0x9, 0x9, 0x9, 0x8, 0x8, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0x8, 0x9, 0x9, 0xa, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0xa, 0x9, 0xa, 0xa, 0xa, 0x9, 0x9, 0xa, 0x9, 0xa, 0x9, 0xa, 0x9, 0x9, 0x9, 0xa, 0xa, 0x9, 0xa, 0x9, 0x9, 0x8, 0x9, 0x9, 0x9, 0x9, 0xa, 0xa, 0xa, 0x9, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x8, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0x7, 0x9, 0x9, 0xa, 0x9, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xd, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xb, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0x8, 0x9, 0x9, 0xa, 0x9, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0x9, 0x9, 0x8, 0x7, 0xd, 0xd, 0x7, 0x7, 0xa, 0x7, 0x7, 0x6, 0x6, 0x6, 0x6, 0x5, 0x6, 0x6, 0x6, 0x5, 0x6, 0x5, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x8, 0x5, 0x6, 0x7, 0x7 };

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <stdio.h>
#include "errinfo.h"
int connectErrorCode;

View File

@ -22,6 +22,7 @@
#endif
#include <freerdp/utils/print.h>
#include <freerdp/utils/unicode.h>
#include "gcc.h"
#include "certificate.h"
@ -490,7 +491,7 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block
stream_read_uint32(s, settings->client_build); /* clientBuild */
/* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 32);
str = freerdp_uniconv_in(stream_get_tail(s), 32);
stream_seek(s, 32);
snprintf(settings->client_hostname, 31, "%s", str);
settings->client_hostname[31] = 0;
@ -545,7 +546,7 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block
if (blockLength < 64)
break;
str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 64);
str = freerdp_uniconv_in(stream_get_tail(s), 64);
stream_seek(s, 64);
snprintf(settings->client_product_id, 32, "%s", str);
xfree(str);
@ -642,8 +643,8 @@ void gcc_write_client_core_data(STREAM* s, rdpSettings* settings)
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->uniconv, settings->client_hostname, &clientNameLength);
clientDigProductId = freerdp_uniconv_out(settings->uniconv, settings->client_product_id, &clientDigProductIdLength);
clientName = freerdp_uniconv_out(settings->client_hostname, &clientNameLength);
clientDigProductId = freerdp_uniconv_out(settings->client_product_id, &clientDigProductIdLength);
stream_write_uint32(s, version); /* version */
stream_write_uint16(s, settings->width); /* desktopWidth */

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <freerdp/utils/unicode.h>
#include "timezone.h"
#include "info.h"
@ -119,7 +121,7 @@ boolean rdp_read_extended_info_packet(STREAM* s, rdpSettings* settings)
settings->ipv6 = (clientAddressFamily == ADDRESS_FAMILY_INET6 ? true : false);
if (stream_get_left(s) < cbClientAddress)
return false;
settings->ip_address = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbClientAddress);
settings->ip_address = freerdp_uniconv_in(stream_get_tail(s), cbClientAddress);
stream_seek(s, cbClientAddress);
stream_read_uint16(s, cbClientDir); /* cbClientDir */
@ -127,7 +129,7 @@ boolean rdp_read_extended_info_packet(STREAM* s, rdpSettings* settings)
return false;
if (settings->client_dir)
xfree(settings->client_dir);
settings->client_dir = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbClientDir);
settings->client_dir = freerdp_uniconv_in(stream_get_tail(s), cbClientDir);
stream_seek(s, cbClientDir);
if (!rdp_read_client_time_zone(s, settings))
@ -166,10 +168,10 @@ void rdp_write_extended_info_packet(STREAM* s, rdpSettings* settings)
clientAddressFamily = settings->ipv6 ? ADDRESS_FAMILY_INET6 : ADDRESS_FAMILY_INET;
clientAddress = (uint8*) freerdp_uniconv_out(settings->uniconv, settings->ip_address, &length);
clientAddress = (uint8*) freerdp_uniconv_out(settings->ip_address, &length);
cbClientAddress = length;
clientDir = (uint8*) freerdp_uniconv_out(settings->uniconv, settings->client_dir, &length);
clientDir = (uint8*) freerdp_uniconv_out(settings->client_dir, &length);
cbClientDir = length;
cbAutoReconnectLen = settings->client_auto_reconnect_cookie->cbLen;
@ -239,7 +241,7 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings)
return false;
if (cbDomain > 0)
{
settings->domain = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbDomain);
settings->domain = freerdp_uniconv_in(stream_get_tail(s), cbDomain);
stream_seek(s, cbDomain);
}
stream_seek(s, 2);
@ -248,7 +250,7 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings)
return false;
if (cbUserName > 0)
{
settings->username = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbUserName);
settings->username = freerdp_uniconv_in(stream_get_tail(s), cbUserName);
stream_seek(s, cbUserName);
}
stream_seek(s, 2);
@ -257,7 +259,7 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings)
return false;
if (cbPassword > 0)
{
settings->password = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbPassword);
settings->password = freerdp_uniconv_in(stream_get_tail(s), cbPassword);
stream_seek(s, cbPassword);
}
stream_seek(s, 2);
@ -266,7 +268,7 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings)
return false;
if (cbAlternateShell > 0)
{
settings->shell = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbAlternateShell);
settings->shell = freerdp_uniconv_in(stream_get_tail(s), cbAlternateShell);
stream_seek(s, cbAlternateShell);
}
stream_seek(s, 2);
@ -275,7 +277,7 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings)
return false;
if (cbWorkingDir > 0)
{
settings->directory = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbWorkingDir);
settings->directory = freerdp_uniconv_in(stream_get_tail(s), cbWorkingDir);
stream_seek(s, cbWorkingDir);
}
stream_seek(s, 2);
@ -335,10 +337,10 @@ 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->uniconv, settings->domain, &length);
domain = (uint8*) freerdp_uniconv_out(settings->domain, &length);
cbDomain = length;
userName = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->username, &length);
userName = (uint8*) freerdp_uniconv_out(settings->username, &length);
cbUserName = length;
if (settings->password_cookie && settings->password_cookie->length > 0)
@ -349,14 +351,14 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings)
}
else
{
password = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->password, &length);
password = (uint8*) freerdp_uniconv_out(settings->password, &length);
cbPassword = length;
}
alternateShell = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->shell, &length);
alternateShell = (uint8*) freerdp_uniconv_out(settings->shell, &length);
cbAlternateShell = length;
workingDir = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->directory, &length);
workingDir = (uint8*) freerdp_uniconv_out(settings->directory, &length);
cbWorkingDir = length;
stream_write_uint32(s, 0); /* CodePage */

View File

@ -26,6 +26,7 @@
#include <freerdp/constants.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/unicode.h>
#include "tpkt.h"
@ -234,7 +235,6 @@ boolean nego_send_preconnection_pdu(rdpNego* nego)
{
STREAM* s;
uint32 cbSize;
UNICONV* uniconv;
uint16 cchPCB_times2 = 0;
char* wszPCB = NULL;
@ -252,10 +252,8 @@ boolean nego_send_preconnection_pdu(rdpNego* nego)
if (nego->preconnection_blob)
{
size_t size;
uniconv = freerdp_uniconv_new();
wszPCB = freerdp_uniconv_out(uniconv, nego->preconnection_blob, &size);
wszPCB = freerdp_uniconv_out(nego->preconnection_blob, &size);
cchPCB_times2 = (uint16) size;
freerdp_uniconv_free(uniconv);
cchPCB_times2 += 2; /* zero-termination */
cbSize += cchPCB_times2;
}

View File

@ -78,7 +78,7 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s)
if (redirection->flags & LB_TARGET_NET_ADDRESS)
{
freerdp_string_read_length32(s, &redirection->targetNetAddress, rdp->settings->uniconv);
freerdp_string_read_length32(s, &redirection->targetNetAddress);
DEBUG_REDIR("targetNetAddress: %s", redirection->targetNetAddress.ascii);
}
@ -96,13 +96,13 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s)
if (redirection->flags & LB_USERNAME)
{
freerdp_string_read_length32(s, &redirection->username, rdp->settings->uniconv);
freerdp_string_read_length32(s, &redirection->username);
DEBUG_REDIR("username: %s", redirection->username.ascii);
}
if (redirection->flags & LB_DOMAIN)
{
freerdp_string_read_length32(s, &redirection->domain, rdp->settings->uniconv);
freerdp_string_read_length32(s, &redirection->domain);
DEBUG_REDIR("domain: %s", redirection->domain.ascii);
}
@ -121,19 +121,19 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s)
if (redirection->flags & LB_TARGET_FQDN)
{
freerdp_string_read_length32(s, &redirection->targetFQDN, rdp->settings->uniconv);
freerdp_string_read_length32(s, &redirection->targetFQDN);
DEBUG_REDIR("targetFQDN: %s", redirection->targetFQDN.ascii);
}
if (redirection->flags & LB_TARGET_NETBIOS_NAME)
{
freerdp_string_read_length32(s, &redirection->targetNetBiosName, rdp->settings->uniconv);
freerdp_string_read_length32(s, &redirection->targetNetBiosName);
DEBUG_REDIR("targetNetBiosName: %s", redirection->targetNetBiosName.ascii);
}
if (redirection->flags & LB_CLIENT_TSV_URL)
{
freerdp_string_read_length32(s, &redirection->tsvUrl, rdp->settings->uniconv);
freerdp_string_read_length32(s, &redirection->tsvUrl);
DEBUG_REDIR("tsvUrl: %s", redirection->tsvUrl.ascii);
}
@ -152,7 +152,7 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s)
for (i = 0; i < (int) count; i++)
{
freerdp_string_read_length32(s, &redirection->targetNetAddresses[i], rdp->settings->uniconv);
freerdp_string_read_length32(s, &redirection->targetNetAddresses[i]);
DEBUG_REDIR("targetNetAddresses: %s", (&redirection->targetNetAddresses[i])->ascii);
}
}

View File

@ -156,7 +156,7 @@ rdpNtlm* ntlm_new()
if (ntlm != NULL)
{
ntlm->uniconv = freerdp_uniconv_new();
}
return ntlm;
@ -166,7 +166,7 @@ void ntlm_free(rdpNtlm* ntlm)
{
if (ntlm != NULL)
{
freerdp_uniconv_free(ntlm->uniconv);
}
}

View File

@ -530,7 +530,6 @@ typedef struct {
struct rdp_ntlm
{
UNICONV* uniconv;
CtxtHandle context;
ULONG cbMaxToken;
ULONG fContextReq;
@ -647,7 +646,6 @@ struct rdp_rpc
rdpNtlmHttp* ntlm_http_in;
rdpNtlmHttp* ntlm_http_out;
UNICONV* uniconv;
rdpSettings* settings;
rdpTransport* transport;

View File

@ -272,7 +272,6 @@ rdpSettings* settings_new(void* instance)
settings->frame_acknowledge = 2;
settings->uniconv = freerdp_uniconv_new();
gethostname(settings->client_hostname, 31);
settings->client_hostname[31] = 0;
settings->mouse_motion = true;
@ -296,7 +295,6 @@ void settings_free(rdpSettings* settings)
{
if (settings != NULL)
{
freerdp_uniconv_free(settings->uniconv);
xfree(settings->hostname);
xfree(settings->username);
xfree(settings->password);

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <freerdp/utils/unicode.h>
#include "timezone.h"
/**
@ -85,7 +87,7 @@ boolean rdp_read_client_time_zone(STREAM* s, rdpSettings* settings)
stream_read_uint32(s, clientTimeZone->bias); /* Bias */
/* standardName (64 bytes) */
str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 64);
str = freerdp_uniconv_in(stream_get_tail(s), 64);
stream_seek(s, 64);
strncpy(clientTimeZone->standardName, str, sizeof(clientTimeZone->standardName));
xfree(str);
@ -94,7 +96,7 @@ boolean rdp_read_client_time_zone(STREAM* s, rdpSettings* settings)
stream_read_uint32(s, clientTimeZone->standardBias); /* StandardBias */
/* daylightName (64 bytes) */
str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 64);
str = freerdp_uniconv_in(stream_get_tail(s), 64);
stream_seek(s, 64);
strncpy(clientTimeZone->daylightName, str, sizeof(clientTimeZone->daylightName));
xfree(str);
@ -127,10 +129,10 @@ void rdp_write_client_time_zone(STREAM* s, rdpSettings* settings)
clientTimeZone = settings->client_time_zone;
freerdp_time_zone_detect(clientTimeZone);
standardName = (uint8*) freerdp_uniconv_out(settings->uniconv, clientTimeZone->standardName, &length);
standardName = (uint8*) freerdp_uniconv_out(clientTimeZone->standardName, &length);
standardNameLength = length;
daylightName = (uint8*) freerdp_uniconv_out(settings->uniconv, clientTimeZone->daylightName, &length);
daylightName = (uint8*) freerdp_uniconv_out(clientTimeZone->daylightName, &length);
daylightNameLength = length;
if (standardNameLength > 62)

View File

@ -459,7 +459,6 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port)
uint32 length;
STREAM* s_p4;
int status = -1;
UNICONV* tsg_uniconv;
rdpRpc* rpc = tsg->rpc;
uint8* dest_addr_unic;
uint32 dest_addr_unic_len;
@ -572,9 +571,7 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port)
}
status = -1;
tsg_uniconv = freerdp_uniconv_new();
dest_addr_unic = (uint8*) freerdp_uniconv_out(tsg_uniconv, hostname, (size_t*) &dest_addr_unic_len);
freerdp_uniconv_free(tsg_uniconv);
dest_addr_unic = (uint8*) freerdp_uniconv_out(hostname, (size_t*) &dest_addr_unic_len);
memcpy(tsg_packet4 + 4, tsg->TunnelContext, 16);
memcpy(tsg_packet4 + 38, &port, 2);

View File

@ -148,7 +148,6 @@ rdpRail* rail_new(rdpSettings* settings)
rail->settings = settings;
rail->cache = icon_cache_new(rail);
rail->list = window_list_new(rail);
rail->uniconv = freerdp_uniconv_new();
rail->clrconv = (CLRCONV*) xzalloc(sizeof(CLRCONV));
}
@ -161,7 +160,6 @@ void rail_free(rdpRail* rail)
{
icon_cache_free(rail->cache);
window_list_free(rail->list);
freerdp_uniconv_free(rail->uniconv);
xfree(rail->clrconv);
xfree(rail);
}

View File

@ -285,7 +285,7 @@ void rail_CreateWindow(rdpRail* rail, rdpWindow* window)
{
if (window->titleInfo.length > 0)
{
window->title = freerdp_uniconv_in(rail->uniconv, window->titleInfo.string, window->titleInfo.length);
window->title = freerdp_uniconv_in(window->titleInfo.string, window->titleInfo.length);
}
else
{
@ -327,7 +327,7 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
if (window->title != NULL)
xfree(window->title);
window->title = freerdp_uniconv_in(rail->uniconv, window->titleInfo.string, window->titleInfo.length);
window->title = freerdp_uniconv_in(window->titleInfo.string, window->titleInfo.length);
IFCALL(rail->rail_SetWindowText, rail, window);
}

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <stdio.h>
#include <freerdp/utils/profiler.h>
PROFILER* profiler_create(char* name)

View File

@ -22,15 +22,16 @@
#endif
#include <freerdp/utils/memory.h>
#include <freerdp/utils/unicode.h>
#include <freerdp/utils/string.h>
void freerdp_string_read_length32(STREAM* s, rdpString* string, UNICONV* uniconv)
void freerdp_string_read_length32(STREAM* s, rdpString* string)
{
stream_read_uint32(s, string->length);
string->unicode = (char*) xmalloc(string->length);
stream_read(s, string->unicode, string->length);
string->ascii = freerdp_uniconv_in(uniconv, (uint8*) string->unicode, string->length);
string->ascii = freerdp_uniconv_in((uint8*) string->unicode, string->length);
}
void freerdp_string_free(rdpString* string)

View File

@ -21,6 +21,7 @@
#include "config.h"
#endif
#include <stdio.h>
#include <winpr/windows.h>
#include <freerdp/utils/time.h>

View File

@ -31,40 +31,7 @@
#include <winpr/crt.h>
UNICONV* freerdp_uniconv_new()
{
UNICONV *uniconv = xnew(UNICONV);
#ifdef HAVE_ICONV
uniconv->iconv = 1;
uniconv->in_iconv_h = iconv_open(DEFAULT_CODEPAGE, WINDOWS_CODEPAGE);
if (errno == EINVAL)
{
printf("Error opening iconv converter to %s from %s\n", DEFAULT_CODEPAGE, WINDOWS_CODEPAGE);
}
uniconv->out_iconv_h = iconv_open(WINDOWS_CODEPAGE, DEFAULT_CODEPAGE);
if (errno == EINVAL)
{
printf("Error opening iconv converter to %s from %s\n", WINDOWS_CODEPAGE, DEFAULT_CODEPAGE);
}
#endif
return uniconv;
}
void freerdp_uniconv_free(UNICONV *uniconv)
{
if (uniconv != NULL)
{
#ifdef HAVE_ICONV
iconv_close(uniconv->in_iconv_h);
iconv_close(uniconv->out_iconv_h);
#endif
xfree(uniconv);
}
}
char* freerdp_uniconv_out(UNICONV* uniconv, const char *str, size_t* pout_len)
char* freerdp_uniconv_out(const char *str, size_t* pout_len)
{
WCHAR* wstr;
int length;
@ -97,7 +64,7 @@ int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length)
return length;
}
char* freerdp_uniconv_in(UNICONV* uniconv, unsigned char* pin, size_t in_len)
char* freerdp_uniconv_in(unsigned char* pin, size_t in_len)
{
CHAR* str;
int length;