Mercurial > emacs
annotate src/w32reg.c @ 50766:fc9cb527333d
(utf-translate-cjk-mode): Update the
second extra slot of the translation table
utf-translation-table-for-encode.
(mule-utf-8): Set the property translation-table-for-encode.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 01 May 2003 04:39:07 +0000 |
parents | fcf617f53ab1 |
children | b79b842995c2 |
rev | line source |
---|---|
13434 | 1 /* Emulate the X Resource Manager through the registry. |
2 Copyright (C) 1990, 1993, 1994 Free Software Foundation. | |
3 | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
4 This file is part of GNU Emacs. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
5 |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
13434 | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
10 | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
13434 | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
13434 | 20 |
21 /* Written by Kevin Gallo */ | |
22 | |
23 #include <config.h> | |
24 #include "lisp.h" | |
25 #include "w32term.h" | |
26 #include "blockinput.h" | |
27 | |
28 #include <stdio.h> | |
29 #include <string.h> | |
30 | |
15149
685510b93c83
(REG_ROOT): Remove trailing backslash.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14353
diff
changeset
|
31 #define REG_ROOT "SOFTWARE\\GNU\\Emacs" |
13434 | 32 |
50040
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
33 static char * |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
34 w32_get_rdb_resource (rdb, resource) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
35 char *rdb; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
36 char *resource; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
37 { |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
38 char *value = rdb; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
39 int len = strlen (resource); |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
40 |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
41 while (*value) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
42 { |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
43 /* Comparison is case-insensitive because registry searches are too. */ |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
44 if ((strnicmp (value, resource, len) == 0) && (value[len] == ':')) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
45 return xstrdup (&value[len + 1]); |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
46 |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
47 value = strchr (value, '\0') + 1; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
48 } |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
49 |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
50 return NULL; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
51 } |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
52 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
53 LPBYTE |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15149
diff
changeset
|
54 w32_get_string_resource (name, class, dwexptype) |
13434 | 55 char *name, *class; |
56 DWORD dwexptype; | |
57 { | |
58 LPBYTE lpvalue = NULL; | |
59 HKEY hrootkey = NULL; | |
60 DWORD dwType; | |
61 DWORD cbData; | |
62 BOOL ok = FALSE; | |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
63 HKEY hive = HKEY_CURRENT_USER; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
64 |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
65 trykey: |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
66 |
13434 | 67 BLOCK_INPUT; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
68 |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
69 /* Check both the current user and the local machine to see if we have |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
70 any resources */ |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
71 |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
72 if (RegOpenKeyEx (hive, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) |
13434 | 73 { |
74 char *keyname; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
75 |
13434 | 76 if (RegQueryValueEx (hrootkey, name, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS |
77 && dwType == dwexptype) | |
78 { | |
79 keyname = name; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
80 } |
13434 | 81 else if (RegQueryValueEx (hrootkey, class, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS |
82 && dwType == dwexptype) | |
83 { | |
84 keyname = class; | |
85 } | |
86 else | |
87 { | |
88 keyname = NULL; | |
89 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
90 |
13434 | 91 ok = (keyname |
92 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL | |
93 && RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
94 |
13434 | 95 RegCloseKey (hrootkey); |
96 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
97 |
13434 | 98 UNBLOCK_INPUT; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
99 |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
100 if (!ok) |
13434 | 101 { |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
102 if (lpvalue) |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
103 { |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
104 xfree (lpvalue); |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
105 lpvalue = NULL; |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
106 } |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
107 if (hive == HKEY_CURRENT_USER) |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
108 { |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
109 hive = HKEY_LOCAL_MACHINE; |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
110 goto trykey; |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
111 } |
13434 | 112 return (NULL); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
113 } |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
114 return (lpvalue); |
13434 | 115 } |
116 | |
117 /* Retrieve the string resource specified by NAME with CLASS from | |
118 database RDB. */ | |
119 | |
120 char * | |
121 x_get_string_resource (rdb, name, class) | |
50364
fcf617f53ab1
(x_get_string_resource): Use XrmDatabase.
Kim F. Storm <storm@cua.dk>
parents:
50040
diff
changeset
|
122 XrmDatabase rdb; |
13434 | 123 char *name, *class; |
124 { | |
50040
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
125 if (rdb) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
126 { |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
127 char *resource; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
128 |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
129 if (resource = w32_get_rdb_resource (rdb, name)) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
130 return resource; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
131 if (resource = w32_get_rdb_resource (rdb, class)) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
132 return resource; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
133 } |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
134 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15149
diff
changeset
|
135 return (w32_get_string_resource (name, class, REG_SZ)); |
13434 | 136 } |