CVS: rdesktop constants.h,1.40,1.41 licence.c,1.34,1.35 rdesktop.c,1.120,1.121 rdp.c,1.76,1.77
Michael Gernoth <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/rdesktop In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23543 Modified Files: constants.h licence.c rdesktop.c rdp.c Log Message: unicode support from Andy Igoshin <[email protected]> Currently disabled, need HAVE_ICONV and HAVE_ICONV_H defined to be used. This should be done with a new configure test. Index: constants.h =================================================================== RCS file: /cvsroot/rdesktop/rdesktop/constants.h,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** constants.h 8 Mar 2005 00:43:10 -0000 1.40 --- constants.h 13 Mar 2005 13:18:48 -0000 1.41 *************** *** 22,25 **** --- 22,28 ---- #define TCP_PORT_RDP 3389 + #define DEFAULT_CODEPAGE "UTF-8" + #define WINDOWS_CODEPAGE "UTF-16" + /* ISO PDU codes */ enum ISO_PDU_CODE Index: licence.c =================================================================== RCS file: /cvsroot/rdesktop/rdesktop/licence.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** licence.c 6 Mar 2005 21:11:04 -0000 1.34 --- licence.c 13 Mar 2005 13:18:48 -0000 1.35 *************** *** 22,26 **** #include <openssl/rc4.h> ! extern char g_username[16]; extern char g_hostname[16]; --- 22,26 ---- #include <openssl/rc4.h> ! extern char g_username[64]; extern char g_hostname[16]; Index: rdesktop.c =================================================================== RCS file: /cvsroot/rdesktop/rdesktop/rdesktop.c,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** rdesktop.c 13 Mar 2005 03:29:18 -0000 1.120 --- rdesktop.c 13 Mar 2005 13:18:48 -0000 1.121 *************** *** 31,34 **** --- 31,39 ---- #include "rdesktop.h" + #ifdef HAVE_ICONV + #include <locale.h> + #include <langinfo.h> + #endif + #ifdef EGD_SOCKET #include <sys/socket.h> /* socket connect */ *************** *** 80,83 **** --- 85,92 ---- #endif + #ifdef HAVE_ICONV + char g_codepage[16] = ""; + #endif + extern RDPDR_DEVICE g_rdpdr_device[]; extern uint32 g_num_devices; *************** *** 114,117 **** --- 123,129 ---- fprintf(stderr, " -f: full-screen mode\n"); fprintf(stderr, " -b: force bitmap updates\n"); + #ifdef HAVE_ICONV + fprintf(stderr, " -L: local codepage\n"); + #endif fprintf(stderr, " -B: use BackingStore of X-server (if available)\n"); fprintf(stderr, " -e: disable encryption (French TS)\n"); *************** *** 368,372 **** while ((c = getopt(argc, argv, ! VNCOPT "u:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1) { switch (c) --- 380,384 ---- while ((c = getopt(argc, argv, ! VNCOPT "u:L:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1) { switch (c) *************** *** 391,394 **** --- 403,414 ---- break; + case 'L': + #ifdef HAVE_ICONV + STRNCPY(g_codepage, optarg, sizeof(g_codepage)); + #else + error("iconv support not available\n"); + #endif + break; + case 'd': STRNCPY(domain, optarg, sizeof(domain)); *************** *** 677,680 **** --- 697,714 ---- } + #ifdef HAVE_ICONV + 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)); + } + } + #endif + if (g_hostname[0] == 0) { Index: rdp.c =================================================================== RCS file: /cvsroot/rdesktop/rdesktop/rdp.c,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** rdp.c 13 Mar 2005 03:29:19 -0000 1.76 --- rdp.c 13 Mar 2005 13:18:48 -0000 1.77 *************** *** 20,27 **** #include <time.h> #include "rdesktop.h" extern uint16 g_mcs_userid; ! extern char g_username[16]; extern BOOL g_bitmap_compression; extern BOOL g_orders; --- 20,34 ---- #include <time.h> + #include <errno.h> + #include <unistd.h> #include "rdesktop.h" + #ifdef HAVE_ICONV_H + #include <iconv.h> + #endif + extern uint16 g_mcs_userid; ! extern char g_username[64]; ! extern char g_codepage[16]; extern BOOL g_bitmap_compression; extern BOOL g_orders; *************** *** 142,145 **** --- 149,200 ---- rdp_out_unistr(STREAM s, char *string, int len) { + #ifdef HAVE_ICONV + size_t ibl = strlen(string), obl = len + 2; + static iconv_t iconv_h = (iconv_t)-1; + char *pin = string, *pout; + #ifdef B_ENDIAN + char ss[4096]; // FIXME: global MAX_BUF_SIZE macro need + + pout = ss; + #else + pout = s->p; + #endif + + memset(pout, 0, len + 4); + + if (iconv_h == (iconv_t)-1) + { + 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, (const char**)&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; + } + + if (iconv(iconv_h, (const char**)&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 B_ENDIAN + swab(ss, s->p, len + 4); + #endif + + s->p += len + 2; + + #else /*HAVE_ICONV undef*/ int i = 0, j = 0; *************** *** 151,156 **** s->p[i++] = 0; } ! s->p += len; } --- 206,212 ---- s->p[i++] = 0; } ! s->p += len; + #endif } *************** *** 162,165 **** --- 218,253 ---- rdp_in_unistr(STREAM s, char *string, int uni_len) { + #ifdef HAVE_ICONV + size_t ibl = uni_len, obl = uni_len; + char *pin, *pout = string; + static iconv_t iconv_h = (iconv_t)-1; + #ifdef B_ENDIAN + char ss[4096]; // FIXME: global MAX_BUF_SIZE macro need + + swab(s->p, ss, uni_len); + pin = ss; + #else + pin = s->p; + #endif + + if (iconv_h == (iconv_t)-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; + } + } + + if (iconv(iconv_h, (const char**)&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; + #else /* HAVE_ICONV undef */ int i = 0; *************** *** 171,174 **** --- 259,263 ---- return i - 1; + #endif } ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click