--- sourceforge.net/trunk/rdesktop/rdesktop.c 2005/03/13 17:40:51 861 +++ sourceforge.net/trunk/rdesktop/rdesktop.c 2005/08/04 12:44:10 973 @@ -27,19 +27,21 @@ #include /* gettimeofday */ #include /* times */ #include /* toupper */ +#include /* PATH_MAX */ #include #include "rdesktop.h" -#ifdef HAVE_ICONV #ifdef HAVE_LOCALE_H #include #endif +#ifdef HAVE_ICONV #ifdef HAVE_LANGINFO_H #include #endif #endif #ifdef EGD_SOCKET +#include #include /* socket connect */ #include /* sockaddr_un */ #endif @@ -49,8 +51,11 @@ char g_title[64] = ""; char g_username[64]; char g_hostname[16]; -char keymapname[16]; +char keymapname[PATH_MAX] = ""; int g_keylayout = 0x409; /* Defaults to US keyboard layout */ +int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */ +int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */ +int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */ int g_width = 800; /* width is special: If 0, the geometry will be fetched from @@ -60,6 +65,10 @@ int g_height = 600; int g_xpos = 0; int g_ypos = 0; +int g_pos = 0; /* 0 position unspecified, + 1 specified, + 2 xpos neg, + 4 ypos neg */ extern int g_tcp_port_rdp; int g_server_bpp = 8; int g_win_button_size = 0; /* If zero, disable single app mode */ @@ -166,7 +175,7 @@ fprintf(stderr, " -5: use RDP version 5 (default)\n"); } -void +static void print_disconnect_reason(uint16 reason) { char *text; @@ -365,13 +374,26 @@ uint32 flags, ext_disc_reason = 0; char *p; int c; - + char *locale = NULL; int username_option = 0; +#ifdef HAVE_LOCALE_H + /* Set locale according to environment */ + locale = setlocale(LC_ALL, ""); + if (locale) + { + locale = strdup(locale); + if (locale == NULL) + { + perror("strdup"); + exit(1); + } + } + +#endif flags = RDP_LOGON_NORMAL; prompt_password = False; domain[0] = password[0] = shell[0] = directory[0] = 0; - strcpy(keymapname, "en-us"); g_embed_wnd = 0; g_num_devices = 0; @@ -481,10 +503,16 @@ } if (*p == '+' || *p == '-') + { + g_pos |= (*p == '-') ? 2 : 1; g_xpos = strtol(p, &p, 10); + } if (*p == '+' || *p == '-') + { + g_pos |= (*p == '-') ? 4 : 1; g_ypos = strtol(p, NULL, 10); + } break; @@ -548,7 +576,7 @@ break; case 'X': - g_embed_wnd = strtol(optarg, NULL, 10); + g_embed_wnd = strtol(optarg, NULL, 0); break; case 'a': @@ -563,7 +591,7 @@ case 'z': DEBUG(("rdp compression enabled\n")); - flags |= RDP_COMPRESSION; + flags |= (RDP_LOGON_COMPRESSION | RDP_LOGON_COMPRESSION2); break; case 'x': @@ -729,11 +757,20 @@ STRNCPY(g_hostname, fullhostname, sizeof(g_hostname)); } - if ((flags & RDP_COMPRESSION) && (g_server_bpp > 8)) + if (keymapname[0] == 0) { - warning("rdp compression not supported for bpp > 8, compression disabled\n"); - flags ^= RDP_COMPRESSION; + if (locale && xkeymap_from_locale(locale)) + { + fprintf(stderr, "Autoselected keyboard map %s\n", keymapname); + } + else + { + STRNCPY(keymapname, "en-us", sizeof(keymapname)); + } } + if (locale) + xfree(locale); + if (prompt_password && read_password(password, sizeof(password))) flags |= RDP_LOGON_AUTO;