/[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 951 by astrand, Tue Aug 2 18:07:56 2005 UTC revision 960 by astrand, Wed Aug 3 08:41:02 2005 UTC
# Line 54  static uint16 saved_remote_modifier_stat Line 54  static uint16 saved_remote_modifier_stat
54    
55  static void update_modifier_state(uint8 scancode, BOOL pressed);  static void update_modifier_state(uint8 scancode, BOOL pressed);
56    
57  /* Free key_translation structure, included linked list */  /* Free key_translation structure, including linked list */
58  void  static void
59  free_key_translation(key_translation * ptr)  free_key_translation(key_translation * ptr)
60  {  {
61          key_translation *next;          key_translation *next;
# Line 155  add_sequence(char *rest, char *mapname) Line 155  add_sequence(char *rest, char *mapname)
155          DEBUG_KBD(("\n"));          DEBUG_KBD(("\n"));
156  }  }
157    
158    /* Joins two path components. The result should be freed with
159       xfree(). */
160    static char *
161    pathjoin(const char *a, const char *b)
162    {
163            char *result;
164            result = xmalloc(PATH_MAX * 2 + 1);
165    
166            if (b[0] == '/')
167            {
168                    strncpy(result, b, PATH_MAX);
169            }
170            else
171            {
172                    strncpy(result, a, PATH_MAX);
173                    strcat(result, "/");
174                    strncat(result, b, PATH_MAX);
175            }
176            return result;
177    }
178    
179    /* Try to open a keymap with fopen() */
180    FILE *
181    xkeymap_open(const char *filename)
182    {
183            char *path1, *path2;
184            char *home;
185            FILE *fp;
186    
187            /* Try ~/.rdesktop/keymaps */
188            home = getenv("HOME");
189            if (home)
190            {
191                    path1 = pathjoin(home, ".rdesktop/keymaps");
192                    path2 = pathjoin(path1, filename);
193                    xfree(path1);
194                    fp = fopen(path2, "r");
195                    xfree(path2);
196                    if (fp)
197                            return fp;
198            }
199    
200            /* Try KEYMAP_PATH */
201            path1 = pathjoin(KEYMAP_PATH, filename);
202            fp = fopen(path1, "r");
203            xfree(path1);
204            if (fp)
205                    return fp;
206    
207            /* Try current directory, in case we are running from the source
208               tree */
209            path1 = pathjoin("keymaps", filename);
210            fp = fopen(path1, "r");
211            xfree(path1);
212            if (fp)
213                    return fp;
214    
215            return NULL;
216    }
217    
218  static BOOL  static BOOL
219  xkeymap_read(char *mapname)  xkeymap_read(char *mapname)
220  {  {
221          FILE *fp;          FILE *fp;
222          char line[KEYMAP_MAX_LINE_LENGTH];          char line[KEYMAP_MAX_LINE_LENGTH];
         char path[PATH_MAX], inplace_path[PATH_MAX];  
223          unsigned int line_num = 0;          unsigned int line_num = 0;
224          unsigned int line_length = 0;          unsigned int line_length = 0;
225          char *keyname, *p;          char *keyname, *p;
# Line 168  xkeymap_read(char *mapname) Line 227  xkeymap_read(char *mapname)
227          uint8 scancode;          uint8 scancode;
228          uint16 modifiers;          uint16 modifiers;
229    
230            fp = xkeymap_open(mapname);
         strcpy(path, KEYMAP_PATH);  
         strncat(path, mapname, sizeof(path) - sizeof(KEYMAP_PATH));  
   
         fp = fopen(path, "r");  
231          if (fp == NULL)          if (fp == NULL)
232          {          {
233                  /* in case we are running from the source tree */                  error("Failed to open keymap %s\n", mapname);
234                  strcpy(inplace_path, "keymaps/");                  return False;
                 strncat(inplace_path, mapname, sizeof(inplace_path) - sizeof("keymaps/"));  
   
                 fp = fopen(inplace_path, "r");  
                 if (fp == NULL)  
                 {  
                         error("Failed to open keymap %s\n", path);  
                         return False;  
                 }  
235          }          }
236    
237          /* FIXME: More tolerant on white space */          /* FIXME: More tolerant on white space */
# Line 379  reset_winkey(uint32 ev_time) Line 426  reset_winkey(uint32 ev_time)
426          }          }
427  }  }
428    
429  /* Handles, for example, multi-scancode keypresses (which is not  /* Handle special key combinations */
    possible via keymap-files) */  
430  BOOL  BOOL
431  handle_special_keys(uint32 keysym, unsigned int state, uint32 ev_time, BOOL pressed)  handle_special_keys(uint32 keysym, unsigned int state, uint32 ev_time, BOOL pressed)
432  {  {

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

  ViewVC Help
Powered by ViewVC 1.1.26