30 |
|
|
31 |
#define REG_ROOT "SOFTWARE\\GNU\\Emacs" |
#define REG_ROOT "SOFTWARE\\GNU\\Emacs" |
32 |
|
|
33 |
LPBYTE |
static char * |
34 |
|
w32_get_rdb_resource (rdb, resource) |
35 |
|
char *rdb; |
36 |
|
char *resource; |
37 |
|
{ |
38 |
|
char *value = rdb; |
39 |
|
int len = strlen (resource); |
40 |
|
|
41 |
|
while (*value) |
42 |
|
{ |
43 |
|
/* Comparison is case-insensitive because registry searches are too. */ |
44 |
|
if ((strnicmp (value, resource, len) == 0) && (value[len] == ':')) |
45 |
|
return xstrdup (&value[len + 1]); |
46 |
|
|
47 |
|
value = strchr (value, '\0') + 1; |
48 |
|
} |
49 |
|
|
50 |
|
return NULL; |
51 |
|
} |
52 |
|
|
53 |
|
LPBYTE |
54 |
w32_get_string_resource (name, class, dwexptype) |
w32_get_string_resource (name, class, dwexptype) |
55 |
char *name, *class; |
char *name, *class; |
56 |
DWORD dwexptype; |
DWORD dwexptype; |
61 |
DWORD cbData; |
DWORD cbData; |
62 |
BOOL ok = FALSE; |
BOOL ok = FALSE; |
63 |
HKEY hive = HKEY_CURRENT_USER; |
HKEY hive = HKEY_CURRENT_USER; |
64 |
|
|
65 |
trykey: |
trykey: |
66 |
|
|
67 |
BLOCK_INPUT; |
BLOCK_INPUT; |
68 |
|
|
69 |
/* Check both the current user and the local machine to see if we have |
/* Check both the current user and the local machine to see if we have |
70 |
any resources */ |
any resources */ |
71 |
|
|
72 |
if (RegOpenKeyEx (hive, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) |
if (RegOpenKeyEx (hive, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) |
73 |
{ |
{ |
74 |
char *keyname; |
char *keyname; |
75 |
|
|
76 |
if (RegQueryValueEx (hrootkey, name, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS |
if (RegQueryValueEx (hrootkey, name, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS |
77 |
&& dwType == dwexptype) |
&& dwType == dwexptype) |
78 |
{ |
{ |
79 |
keyname = name; |
keyname = name; |
80 |
} |
} |
81 |
else if (RegQueryValueEx (hrootkey, class, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS |
else if (RegQueryValueEx (hrootkey, class, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS |
82 |
&& dwType == dwexptype) |
&& dwType == dwexptype) |
83 |
{ |
{ |
87 |
{ |
{ |
88 |
keyname = NULL; |
keyname = NULL; |
89 |
} |
} |
90 |
|
|
91 |
ok = (keyname |
ok = (keyname |
92 |
&& (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL |
&& (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL |
93 |
&& RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS); |
&& RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS); |
94 |
|
|
95 |
RegCloseKey (hrootkey); |
RegCloseKey (hrootkey); |
96 |
} |
} |
97 |
|
|
98 |
UNBLOCK_INPUT; |
UNBLOCK_INPUT; |
99 |
|
|
100 |
if (!ok) |
if (!ok) |
101 |
{ |
{ |
102 |
if (lpvalue) |
if (lpvalue) |
103 |
{ |
{ |
110 |
goto trykey; |
goto trykey; |
111 |
} |
} |
112 |
return (NULL); |
return (NULL); |
113 |
} |
} |
114 |
return (lpvalue); |
return (lpvalue); |
115 |
} |
} |
116 |
|
|
119 |
|
|
120 |
char * |
char * |
121 |
x_get_string_resource (rdb, name, class) |
x_get_string_resource (rdb, name, class) |
122 |
int rdb; |
XrmDatabase rdb; |
123 |
char *name, *class; |
char *name, *class; |
124 |
{ |
{ |
125 |
|
if (rdb) |
126 |
|
{ |
127 |
|
char *resource; |
128 |
|
|
129 |
|
if (resource = w32_get_rdb_resource (rdb, name)) |
130 |
|
return resource; |
131 |
|
if (resource = w32_get_rdb_resource (rdb, class)) |
132 |
|
return resource; |
133 |
|
} |
134 |
|
|
135 |
return (w32_get_string_resource (name, class, REG_SZ)); |
return (w32_get_string_resource (name, class, REG_SZ)); |
136 |
} |
} |