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