Mercurial > emacs
annotate src/w32reg.c @ 88256:db2e6586ecf5
(rmail-msgbeg, rmail-msgend): Fix and make obsolete.
(rmail-process-new-messages): Use mail-decode-encoded-word-string
on the subject. Requires mail-parse from Gnus.
(rmail-highlight-headers): Doc.
author | Alex Schroeder <alex@gnu.org> |
---|---|
date | Sat, 21 Jan 2006 15:00:38 +0000 |
parents | d7ddb3e565de |
children |
rev | line source |
---|---|
13434 | 1 /* Emulate the X Resource Manager through the registry. |
88155 | 2 Copyright (C) 1990, 1993, 1994, 2002, 2003, 2004, |
3 2005 Free Software Foundation, Inc. | |
13434 | 4 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
5 This file is part of GNU Emacs. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
6 |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
7 GNU Emacs is free software; you can redistribute it and/or modify |
13434 | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 2, or (at your option) | |
10 any later version. | |
11 | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
12 GNU Emacs is distributed in the hope that it will be useful, |
13434 | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 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
|
18 along with GNU Emacs; see the file COPYING. If not, write to |
88155 | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02110-1301, USA. */ | |
13434 | 21 |
22 /* Written by Kevin Gallo */ | |
23 | |
24 #include <config.h> | |
25 #include "lisp.h" | |
26 #include "w32term.h" | |
27 #include "blockinput.h" | |
28 | |
29 #include <stdio.h> | |
30 #include <string.h> | |
31 | |
15149
685510b93c83
(REG_ROOT): Remove trailing backslash.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14353
diff
changeset
|
32 #define REG_ROOT "SOFTWARE\\GNU\\Emacs" |
13434 | 33 |
88155 | 34 /* Default system colors from the Display Control Panel settings. */ |
35 #define SYSTEM_DEFAULT_RESOURCES \ | |
36 "emacs.foreground:SystemWindowText\0" \ | |
37 "emacs.background:SystemWindow\0" \ | |
38 "emacs.tooltip.attributeForeground:SystemInfoText\0" \ | |
39 "emacs.tooltip.attributeBackground:SystemInfoWindow\0" \ | |
40 "emacs.tool-bar.attributeForeground:SystemButtonText\0" \ | |
41 "emacs.tool-bar.attributeBackground:SystemButtonFace\0" \ | |
42 "emacs.menu.attributeForeground:SystemMenuText\0" \ | |
43 "emacs.menu.attributeBackground:SystemMenu\0" \ | |
44 "emacs.scroll-bar.attributeForeground:SystemScrollbar" | |
45 | |
46 /* Other possibilities for default faces: | |
47 | |
48 region: Could use SystemHilight, but interferes with our ability to | |
49 see most syntax highlighting through the region face. | |
50 | |
51 modeline: Could use System(In)ActiveTitle, gradient versions (not | |
52 supported on 95 and NT), but modeline is more like a status bar | |
53 really (which don't appear to be configurable in Windows). | |
54 | |
55 highlight: Could use SystemHotTrackingColor, but it is not supported | |
56 on Windows 95 or NT, and other apps only seem to use it for menus | |
57 anyway. | |
58 | |
59 */ | |
60 | |
61 static char * | |
62 w32_get_rdb_resource (rdb, resource) | |
63 char *rdb; | |
64 char *resource; | |
65 { | |
66 char *value = rdb; | |
67 int len = strlen (resource); | |
68 | |
69 while (*value) | |
70 { | |
71 /* Comparison is case-insensitive because registry searches are too. */ | |
72 if ((strnicmp (value, resource, len) == 0) && (value[len] == ':')) | |
73 return xstrdup (&value[len + 1]); | |
74 | |
75 value = strchr (value, '\0') + 1; | |
76 } | |
77 | |
78 return NULL; | |
79 } | |
80 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
81 LPBYTE |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15149
diff
changeset
|
82 w32_get_string_resource (name, class, dwexptype) |
13434 | 83 char *name, *class; |
84 DWORD dwexptype; | |
85 { | |
86 LPBYTE lpvalue = NULL; | |
87 HKEY hrootkey = NULL; | |
88 DWORD dwType; | |
89 DWORD cbData; | |
90 BOOL ok = FALSE; | |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
91 HKEY hive = HKEY_CURRENT_USER; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
92 |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
93 trykey: |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
94 |
13434 | 95 BLOCK_INPUT; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
96 |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
97 /* 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
|
98 any resources */ |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
99 |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
100 if (RegOpenKeyEx (hive, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) |
13434 | 101 { |
102 char *keyname; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
103 |
13434 | 104 if (RegQueryValueEx (hrootkey, name, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS |
105 && dwType == dwexptype) | |
106 { | |
107 keyname = name; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
108 } |
13434 | 109 else if (RegQueryValueEx (hrootkey, class, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS |
110 && dwType == dwexptype) | |
111 { | |
112 keyname = class; | |
113 } | |
114 else | |
115 { | |
116 keyname = NULL; | |
117 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
118 |
13434 | 119 ok = (keyname |
120 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL | |
121 && RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
122 |
13434 | 123 RegCloseKey (hrootkey); |
124 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
125 |
13434 | 126 UNBLOCK_INPUT; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
127 |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
128 if (!ok) |
13434 | 129 { |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
130 if (lpvalue) |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
131 { |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
132 xfree (lpvalue); |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
133 lpvalue = NULL; |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
134 } |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
135 if (hive == HKEY_CURRENT_USER) |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
136 { |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
137 hive = HKEY_LOCAL_MACHINE; |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
138 goto trykey; |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
139 } |
88155 | 140 |
141 /* Check if there are Windows specific defaults defined. */ | |
142 return w32_get_rdb_resource (SYSTEM_DEFAULT_RESOURCES, name); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
143 } |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
144 return (lpvalue); |
13434 | 145 } |
146 | |
147 /* Retrieve the string resource specified by NAME with CLASS from | |
148 database RDB. */ | |
149 | |
150 char * | |
151 x_get_string_resource (rdb, name, class) | |
88155 | 152 XrmDatabase rdb; |
13434 | 153 char *name, *class; |
154 { | |
88155 | 155 if (rdb) |
156 { | |
157 char *resource; | |
158 | |
159 if (resource = w32_get_rdb_resource (rdb, name)) | |
160 return resource; | |
161 if (resource = w32_get_rdb_resource (rdb, class)) | |
162 return resource; | |
163 } | |
164 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15149
diff
changeset
|
165 return (w32_get_string_resource (name, class, REG_SZ)); |
13434 | 166 } |
88155 | 167 |
168 /* arch-tag: 755fce25-42d7-4acb-874f-2fb42336823d | |
169 (do not change this comment) */ |