From b2f6cc52960915985cbb4e60ccac035135ed8ede Mon Sep 17 00:00:00 2001 From: Florent Thoumie Date: Wed, 20 Apr 2005 08:12:44 +0000 Subject: - Add unicode support (this is already in rdesktop CVS tree, so this will be removed when rdesktop will release 1.4.1). PR: ports/78710 Submitted by: Alex Miller Obtained from: rdesktop project --- net/rdesktop/files/patch-constants.h | 13 ++++ net/rdesktop/files/patch-licence.c | 12 ++++ net/rdesktop/files/patch-rdesktop.c | 67 ++++++++++++++++++++ net/rdesktop/files/patch-rdp.c | 118 +++++++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 net/rdesktop/files/patch-constants.h create mode 100644 net/rdesktop/files/patch-licence.c create mode 100644 net/rdesktop/files/patch-rdesktop.c create mode 100644 net/rdesktop/files/patch-rdp.c (limited to 'net/rdesktop/files') diff --git a/net/rdesktop/files/patch-constants.h b/net/rdesktop/files/patch-constants.h new file mode 100644 index 000000000000..bbe80c66a104 --- /dev/null +++ b/net/rdesktop/files/patch-constants.h @@ -0,0 +1,13 @@ +--- constants.h.orig 2004-11-03 16:56:44.000000000 +0300 ++++ constants.h 2004-12-15 11:47:49.583973715 +0300 +@@ -21,6 +21,9 @@ + /* TCP port for Remote Desktop Protocol */ + #define TCP_PORT_RDP 3389 + ++#define DEFAULT_CODEPAGE "UTF-8" ++#define WINDOWS_CODEPAGE "UTF-16" ++ + /* ISO PDU codes */ + enum ISO_PDU_CODE + { +diff -uNr licence.c.orig licence.c diff --git a/net/rdesktop/files/patch-licence.c b/net/rdesktop/files/patch-licence.c new file mode 100644 index 000000000000..4071ab9b8495 --- /dev/null +++ b/net/rdesktop/files/patch-licence.c @@ -0,0 +1,12 @@ +--- licence.c.orig 2004-07-31 17:07:41.000000000 +0400 ++++ licence.c 2004-12-15 10:19:42.000000000 +0300 +@@ -21,7 +21,7 @@ + #include "rdesktop.h" + #include + +-extern char g_username[16]; ++extern char g_username[64]; + extern char g_hostname[16]; + + static uint8 g_licence_key[16]; +diff -uNr rdesktop.c.orig rdesktop.c diff --git a/net/rdesktop/files/patch-rdesktop.c b/net/rdesktop/files/patch-rdesktop.c new file mode 100644 index 000000000000..509be4c1107a --- /dev/null +++ b/net/rdesktop/files/patch-rdesktop.c @@ -0,0 +1,67 @@ +--- rdesktop.c.orig 2004-11-18 14:18:49.000000000 +0300 ++++ rdesktop.c 2004-12-15 12:19:11.263991136 +0300 +@@ -28,6 +28,8 @@ + #include /* times */ + #include /* toupper */ + #include ++#include ++#include + #include "rdesktop.h" + + #ifdef EGD_SOCKET +@@ -39,6 +41,7 @@ + + char g_title[64] = ""; + char g_username[64]; ++char g_codepage[16] = ""; + char g_hostname[16]; + char keymapname[16]; + int g_keylayout = 0x409; /* Defaults to US keyboard layout */ +@@ -112,6 +115,7 @@ + fprintf(stderr, " -g: desktop geometry (WxH)\n"); + fprintf(stderr, " -f: full-screen mode\n"); + fprintf(stderr, " -b: force bitmap updates\n"); ++ fprintf(stderr, " -L: local codepage\n"); + fprintf(stderr, " -B: use BackingStore of X-server (if available)\n"); + fprintf(stderr, " -e: disable encryption (French TS)\n"); + fprintf(stderr, " -E: disable encryption from client to server\n"); +@@ -366,7 +370,7 @@ + #endif + + while ((c = getopt(argc, argv, +- VNCOPT "u:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1) ++ VNCOPT "u:L:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1) + { + switch (c) + { +@@ -389,6 +393,10 @@ + username_option = 1; + break; + ++ case 'L': ++ STRNCPY(g_codepage, optarg, sizeof(g_codepage)); ++ break; ++ + case 'd': + STRNCPY(domain, optarg, sizeof(domain)); + break; +@@ -675,6 +683,18 @@ + STRNCPY(g_username, pw->pw_name, sizeof(g_username)); + } + ++ if (g_codepage[0] == 0) ++ { ++ if (setlocale(LC_CTYPE, "")) ++ { ++ STRNCPY(g_codepage, nl_langinfo(CODESET), sizeof(g_codepage)); ++ } ++ else ++ { ++ STRNCPY(g_codepage, DEFAULT_CODEPAGE, sizeof(g_codepage)); ++ } ++ } ++ + if (g_hostname[0] == 0) + { + if (gethostname(fullhostname, sizeof(fullhostname)) == -1) +diff -uNr rdp.c.orig rdp.c diff --git a/net/rdesktop/files/patch-rdp.c b/net/rdesktop/files/patch-rdp.c new file mode 100644 index 000000000000..6c0c690fd024 --- /dev/null +++ b/net/rdesktop/files/patch-rdp.c @@ -0,0 +1,118 @@ +--- rdp.c.orig 2004-10-07 17:00:28.000000000 +0400 ++++ rdp.c 2004-12-15 12:12:23.022107839 +0300 +@@ -19,10 +19,14 @@ + */ + + #include ++#include ++#include ++#include + #include "rdesktop.h" + + extern uint16 g_mcs_userid; +-extern char g_username[16]; ++extern char g_username[64]; ++extern char g_codepage[16]; + extern BOOL g_bitmap_compression; + extern BOOL g_orders; + extern BOOL g_encryption; +@@ -140,17 +144,51 @@ + void + rdp_out_unistr(STREAM s, char *string, int len) + { +- int i = 0, j = 0; ++ static iconv_t iconv_h = (iconv_t)-1; ++ size_t ibl = strlen(string), obl = len + 2; ++ char *pin = string, *pout; ++#ifdef WORDS_BIGENDIAN ++ char ss[4096]; // FIXME: global MAX_BUF_SIZE macro need ++ ++ pout = ss; ++#else ++ pout = s->p; ++#endif + +- len += 2; ++ memset(pout, 0, len + 4); + +- while (i < len) ++ if (iconv_h == (iconv_t)-1) + { +- s->p[i++] = string[j++]; +- s->p[i++] = 0; ++ size_t i = 1, o = 4; ++ if ((iconv_h = iconv_open(WINDOWS_CODEPAGE, g_codepage)) == (iconv_t)-1) ++ { ++ printf("rdp_out_unistr: iconv_open[%s -> %s] fail %d\n", ++ g_codepage, WINDOWS_CODEPAGE, (int)iconv_h); ++ return; ++ } ++ if (iconv(iconv_h, &pin, &i, &pout, &o) == (size_t)-1) ++ { ++ iconv_close(iconv_h); ++ iconv_h = (iconv_t)-1; ++ printf("rdp_out_unistr: iconv(1) fail, errno %d\n", errno); ++ return; ++ } ++ pin = string; pout = s->p; + } + +- s->p += len; ++ if (iconv(iconv_h, &pin, &ibl, &pout, &obl) == (size_t)-1) ++ { ++ iconv_close(iconv_h); ++ iconv_h = (iconv_t)-1; ++ printf("rdp_out_unistr: iconv(2) fail, errno %d\n", errno); ++ return; ++ } ++ ++#ifdef WORDS_BIGENDIAN ++ swab(ss, s->p, len + 4); ++#endif ++ ++ s->p += len + 2; + } + + /* Input a string in Unicode +@@ -160,15 +198,36 @@ + int + rdp_in_unistr(STREAM s, char *string, int uni_len) + { +- int i = 0; ++ static iconv_t iconv_h = (iconv_t)-1; ++ size_t ibl = uni_len, obl = uni_len; ++ char *pin, *pout = string; ++#ifdef WORDS_BIGENDIAN ++ char ss[4096]; // FIXME: global MAX_BUF_SIZE macro need ++ ++ swab(s->p, ss, uni_len); ++ pin = ss; ++#else ++ pin = s->p; ++#endif + +- while (i < uni_len / 2) ++ if (iconv_h == (iconv_t)-1) + { +- in_uint8a(s, &string[i++], 1); +- in_uint8s(s, 1); ++ if ((iconv_h = iconv_open(g_codepage, WINDOWS_CODEPAGE)) == (iconv_t)-1) ++ { ++ printf("rdp_in_unistr: iconv_open[%s -> %s] fail %d\n", ++ WINDOWS_CODEPAGE, g_codepage, (int)iconv_h); ++ return 0; ++ } + } + +- return i - 1; ++ if (iconv(iconv_h, &pin, &ibl, &pout, &obl) == (size_t)-1) ++ { ++ iconv_close(iconv_h); ++ iconv_h = (iconv_t)-1; ++ printf("rdp_in_unistr: iconv fail, errno %d\n", errno); ++ return 0; ++ } ++ return pout - string; + } + + -- cgit v1.2.3