CVS: rdesktop proto.h,1.76,1.77 xkeymap.c,1.75,1.76
Peter Åstrand <[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-serv1934
Modified Files:
proto.h xkeymap.c
Log Message:
Keymaps are now searched in ~/.rdesktop/keymaps as well.
Index: proto.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/proto.h,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -d -r1.76 -r1.77
*** proto.h 2 Aug 2005 15:07:26 -0000 1.76
--- proto.h 3 Aug 2005 08:25:32 -0000 1.77
***************
*** 167,170 ****
--- 167,171 ----
void xclip_init(void);
/* xkeymap.c */
+ FILE *xkeymap_open(const char *filename);
void xkeymap_init(void);
BOOL handle_special_keys(uint32 keysym, unsigned int state, uint32 ev_time, BOOL pressed);
Index: xkeymap.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xkeymap.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -d -r1.75 -r1.76
*** xkeymap.c 3 Aug 2005 07:08:48 -0000 1.75
--- xkeymap.c 3 Aug 2005 08:25:32 -0000 1.76
***************
*** 156,159 ****
--- 156,219 ----
}
+ /* Joins two path components. The result should be freed with
+ xfree(). */
+ static char *
+ pathjoin(const char *a, const char *b)
+ {
+ char *result;
+ result = xmalloc(PATH_MAX * 2 + 1);
+
+ if (b[0] == '/')
+ {
+ strncpy(result, b, PATH_MAX);
+ }
+ else
+ {
+ strncpy(result, a, PATH_MAX);
+ strcat(result, "/");
+ strncat(result, b, PATH_MAX);
+ }
+ return result;
+ }
+
+ /* Try to open a keymap with fopen() */
+ FILE *
+ xkeymap_open(const char *filename)
+ {
+ char *path1, *path2;
+ char *home;
+ FILE *fp;
+
+ /* Try KEYMAP_PATH */
+ path1 = pathjoin(KEYMAP_PATH, filename);
+ fp = fopen(path1, "r");
+ xfree(path1);
+ if (fp)
+ return fp;
+
+ /* Try ~/.rdesktop/keymaps */
+ home = getenv("HOME");
+ if (home)
+ {
+ path1 = pathjoin(home, ".rdesktop/keymaps");
+ path2 = pathjoin(path1, filename);
+ xfree(path1);
+ fp = fopen(path2, "r");
+ xfree(path2);
+ if (fp)
+ return fp;
+ }
+
+ /* Try current directory, in case we are running from the source
+ tree */
+ path1 = pathjoin("keymaps", filename);
+ fp = fopen(path1, "r");
+ xfree(path1);
+ if (fp)
+ return fp;
+
+ return NULL;
+ }
+
static BOOL
xkeymap_read(char *mapname)
***************
*** 161,165 ****
FILE *fp;
char line[KEYMAP_MAX_LINE_LENGTH];
- char path[PATH_MAX], inplace_path[PATH_MAX];
unsigned int line_num = 0;
unsigned int line_length = 0;
--- 221,224 ----
***************
*** 169,189 ****
uint16 modifiers;
!
! strcpy(path, KEYMAP_PATH);
! strncat(path, mapname, sizeof(path) - sizeof(KEYMAP_PATH));
!
! fp = fopen(path, "r");
if (fp == NULL)
{
! /* in case we are running from the source tree */
! strcpy(inplace_path, "keymaps/");
! 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;
! }
}
--- 228,236 ----
uint16 modifiers;
! fp = xkeymap_open(mapname);
if (fp == NULL)
{
! error("Failed to open keymap %s\n", mapname);
! return False;
}
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click