ports/78710: [PATCH] Add unicode support patch to rdesktop port

Alex Miller asm at asm.kiev.ua
Fri Mar 11 22:20:04 UTC 2005


>Number:         78710
>Category:       ports
>Synopsis:       [PATCH] Add unicode support patch to rdesktop port
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 11 22:20:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Alex Miller
>Release:        FreeBSD 5.3-RELEASE i386
>Organization:
Home Sweet Home, Inc.
>Environment:
System: FreeBSD 5.3-RELEASE i386

>Description:
	Add unicode support patch to rdesktop port 
	from http://www.itadvisor.ru/sites/ita/Shared%20Files/rdesktop-unicode.patch
>How-To-Repeat:
	apply
>Fix:


diff -ruN rdesktop.orig/Makefile rdesktop/Makefile
--- rdesktop.orig/Makefile	Fri Mar 11 14:28:11 2005
+++ rdesktop/Makefile	Sat Mar 12 00:03:17 2005
@@ -2,12 +2,12 @@
 # Date created:               13 December 2000
 # Whom:                       mwest at uct.ac.za
 #
-# $FreeBSD: ports/net/rdesktop/Makefile,v 1.30 2005/03/11 12:28:11 lofi Exp $
+# $FreeBSD$
 #
 
 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_GMAKE=	yes
 USE_REINPLACE=	yes
 USE_OPENSSL=	yes
+USE_ICONV=	yes
 HAS_CONFIGURE=	yes
-CONFIGURE_ARGS=	--prefix=${PREFIX}
+CFLAGS+=	-I${LOCALBASE}/include
+LDFLAGS+=	-L${LOCALBASE}/lib -liconv
+CONFIGURE_ARGS= --with-libiconv-prefix=${LOCALBASE} \
+		--prefix=${PREFIX}
 DOCS=		doc/AUTHORS doc/TODO doc/*.txt
 MAN1=		rdesktop.1
 
diff -ruN rdesktop.orig/files/patch-rdesktop.unicode rdesktop/files/patch-rdesktop.unicode
--- rdesktop.orig/files/patch-rdesktop.unicode	Thu Jan  1 03:00:00 1970
+++ rdesktop/files/patch-rdesktop.unicode	Fri Mar 11 23:29:19 2005
@@ -0,0 +1,211 @@
+diff -uNr constants.h.orig constants.h
+--- 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
+--- 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
+--- 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
+--- 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;
+ }
+ 
+ 
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list