--- sourceforge.net/trunk/rdesktop/rdesktop.c 2005/08/03 08:36:08 958 +++ sourceforge.net/trunk/rdesktop/rdesktop.c 2005/08/04 12:50:15 974 @@ -27,13 +27,14 @@ #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 @@ -50,8 +51,11 @@ char g_title[64] = ""; char g_username[64]; char g_hostname[16]; -char keymapname[PATH_MAX]; +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 @@ -370,13 +374,21 @@ 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 = xstrdup(locale); + } + +#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; @@ -740,6 +752,21 @@ STRNCPY(g_hostname, fullhostname, sizeof(g_hostname)); } + if (keymapname[0] == 0) + { + 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; @@ -907,6 +934,19 @@ exit(1); } return mem; +} + +/* strdup */ +char * +xstrdup(const char *s) +{ + char *mem = strdup(s); + if (mem == NULL) + { + perror("strdup"); + exit(1); + } + return mem; } /* realloc; exit if out of memory */