1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-01 05:45:45 +00:00

- 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 <asm@asm.kiev.ua>
Obtained from:	rdesktop project
This commit is contained in:
Florent Thoumie 2005-04-20 08:12:44 +00:00
parent bf007f80d9
commit b2f6cc5296
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=133730
5 changed files with 217 additions and 3 deletions

View File

@ -7,7 +7,7 @@
PORTNAME= rdesktop
PORTVERSION= 1.4.0
PORTREVISION?= 0
PORTREVISION= 1
CATEGORIES= net comms
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= ${PORTNAME}
@ -19,8 +19,12 @@ USE_XLIB= yes
USE_GMAKE= yes
USE_REINPLACE= yes
USE_OPENSSL= yes
HAS_CONFIGURE= yes
CONFIGURE_ARGS= --prefix=${PREFIX} --with-x=${X11BASE}
GNU_CONFIGURE= yes
USE_ICONV= yes
CFLAGS+= -I${LOCALBASE}/include
LDFLAGS+= -L${LOCALBASE}/lib -liconv
CONFIGURE_ARGS= --with-libiconv-prefix=${LOCALBASE} \
--with-x=${X11BASE}
DOCS= doc/AUTHORS doc/TODO doc/*.txt
MAN1= rdesktop.1

View File

@ -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

View File

@ -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 <openssl/rc4.h>
-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

View File

@ -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 <sys/times.h> /* times */
#include <ctype.h> /* toupper */
#include <errno.h>
+#include <locale.h>
+#include <langinfo.h>
#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

View File

@ -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 <time.h>
+#include <errno.h>
+#include <iconv.h>
+#include <unistd.h>
#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;
}