13434
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1 /* Emulate the X Resource Manager through the registry.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
2 Copyright (C) 1990, 1993, 1994 Free Software Foundation.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
3
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
4 This program is free software; you can redistribute it and/or modify
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 2, or (at your option)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
7 any later version.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
8
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
12 GNU General Public License for more details.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
13
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
15 along with this program; see the file COPYING. If not, write to
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
17
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
18 /* Written by Kevin Gallo */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
19
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
20 #include <config.h>
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
21 #include "lisp.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
22 #include "w32term.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
23 #include "blockinput.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
24
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
25 #include <stdio.h>
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
26 #include <string.h>
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
27
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
28 #define REG_ROOT "SOFTWARE\\GNU\\Emacs\\"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
29
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
30 LPBYTE
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
31 win32_get_string_resource (name, class, dwexptype)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
32 char *name, *class;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
33 DWORD dwexptype;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
34 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
35 LPBYTE lpvalue = NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
36 HKEY hrootkey = NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
37 DWORD dwType;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
38 DWORD cbData;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
39 BOOL ok = FALSE;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
40
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
41 BLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
42
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
43 /* Check both the current user and the local machine to see if we have any resources */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
44
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
45 if (RegOpenKeyEx (HKEY_CURRENT_USER, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
46 || RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
47 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
48 char *keyname;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
49
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
50 if (RegQueryValueEx (hrootkey, name, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
51 && dwType == dwexptype)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
52 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
53 keyname = name;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
54 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
55 else if (RegQueryValueEx (hrootkey, class, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
56 && dwType == dwexptype)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
57 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
58 keyname = class;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
59 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
60 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
61 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
62 keyname = NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
63 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
64
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
65 ok = (keyname
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
66 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
67 && RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
68
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
69 RegCloseKey (hrootkey);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
70 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
71
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
72 UNBLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
73
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
74 if (!ok)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
75 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
76 if (lpvalue) xfree (lpvalue);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
77 return (NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
78 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
79 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
80 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
81 return (lpvalue);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
82 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
83 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
84
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
85 /* Retrieve the string resource specified by NAME with CLASS from
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
86 database RDB. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
87
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
88 char *
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
89 x_get_string_resource (rdb, name, class)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
90 int rdb;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
91 char *name, *class;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
92 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
93 return (win32_get_string_resource (name, class, REG_SZ));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
94 }
|