/[rdesktop]/sourceforge.net/trunk/rdesktop/xkeymap.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/xkeymap.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 960 by astrand, Wed Aug 3 08:41:02 2005 UTC revision 962 by astrand, Wed Aug 3 09:56:17 2005 UTC
# Line 30  Line 30 
30  #include <ctype.h>  #include <ctype.h>
31  #include <limits.h>  #include <limits.h>
32  #include <time.h>  #include <time.h>
33    #include <string.h>
34  #include "rdesktop.h"  #include "rdesktop.h"
35  #include "scancodes.h"  #include "scancodes.h"
36    
# Line 155  add_sequence(char *rest, char *mapname) Line 156  add_sequence(char *rest, char *mapname)
156          DEBUG_KBD(("\n"));          DEBUG_KBD(("\n"));
157  }  }
158    
159    void
160    xkeymap_from_locale(const char *locale)
161    {
162            char *str, *ptr;
163            FILE *fp;
164    
165            /* Create a working copy */
166            str = strdup(locale);
167            if (str == NULL)
168            {
169                    perror("strdup");
170                    exit(1);
171            }
172    
173            /* Truncate at dot and at */
174            ptr = strrchr(str, '.');
175            if (ptr)
176                    *ptr = '\0';
177            ptr = strrchr(str, '@');
178            if (ptr)
179                    *ptr = '\0';
180    
181            /* Replace _ with - */
182            ptr = strrchr(str, '_');
183            if (ptr)
184                    *ptr = '-';
185    
186            /* Convert to lowercase */
187            ptr = str;
188            while (*ptr)
189            {
190                    *ptr = tolower((int) *ptr);
191                    ptr++;
192            }
193    
194            /* Try to open this keymap (da-dk) */
195            fp = xkeymap_open(str);
196            if (fp == NULL)
197            {
198                    /* Truncate at dash */
199                    ptr = strrchr(str, '-');
200                    if (ptr)
201                            *ptr = '\0';
202    
203                    /* Try the short name (da) */
204                    fp = xkeymap_open(str);
205            }
206    
207            if (fp)
208            {
209                    fclose(fp);
210                    STRNCPY(keymapname, str, sizeof(keymapname));
211                    fprintf(stderr, "Autoselected keyboard map %s.\n", keymapname);
212            }
213    }
214    
215    
216  /* Joins two path components. The result should be freed with  /* Joins two path components. The result should be freed with
217     xfree(). */     xfree(). */
218  static char *  static char *
# Line 358  void Line 416  void
416  xkeymap_init(void)  xkeymap_init(void)
417  {  {
418          unsigned int max_keycode;          unsigned int max_keycode;
         char *mapname_ptr;  
   
         /* Make keymapname lowercase */  
         mapname_ptr = keymapname;  
         while (*mapname_ptr)  
         {  
                 *mapname_ptr = tolower((int) *mapname_ptr);  
                 mapname_ptr++;  
         }  
419    
420          if (strcmp(keymapname, "none"))          if (strcmp(keymapname, "none"))
421          {          {

Legend:
Removed from v.960  
changed lines
  Added in v.962

  ViewVC Help
Powered by ViewVC 1.1.26