1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-01 03:11:09 -08:00
emacs/src/w32reg.c
Eli Zaretskii d4352f813a Include file cleanup for w32 files in src directory
* src/w32xfns.c: Don't include keyboard.h, window.h, charset.h,
fontset.h, blockinput.h.
* src/w32uniscribe.c: Don't include dispextern.h, character.h,
charset.h, fontset.h.
* src/w32term.c: Don't include systty.h, systime.h, charset.h,
character.h, ccl.h, dispextern.h, disptab.h, intervals.h,
process.h, atimer.h, keymap.h, w32heap.h.  Include bitmap/gray.xbm
in an ifdef-ed away block.
Include fcntl.h for CYGWIN.
(set_frame_param): Remove unused function.
* src/w32select.c: Don't include charset.h and composite.h.
(setup_config, Fw32_get_clipboard_data): Avoid compiler warnings
due to pointer signedness mismatches.
* src/w32reg.c (w32_get_string_resource): Avoid compiler warnings
due to pointer signedness mismatches.
* src/w32proc.c: Include unistd.h.  Don't include systime.h,
process.h, dispextern.h.
(sys_spawnve, Fw32_short_file_name, Fw32_long_file_name)
(Fw32_application_type): Avoid compiler warnings due to pointer
signedness mismatches.
* src/w32menu.c: Don't include keymap.h, termhooks.h, window.h,
character.h, charset.h, dispextern.h.
(simple_dialog_show, add_menu_item): Avoid compiler warnings due
to pointer signedness mismatches.
* src/w32inevt.c: Don't include dispextern.h, window.h,
termhooks.h, w32heap.h.
* src/w32font.c: Don't include dispextern.h, character.h,
charset.h, fontset.h, font.h.
(intern_font_name, add_font_entity_to_list)
(registry_to_w32_charset, w32_to_x_charset, fill_in_logfont)
(list_all_matching_fonts): Avoid compiler warnings due to pointer
signedness mismatches.
* src/w32fns.c: Don't include character.h, intervals.h,
dispextern.h, epaths.h, charset.h, ccl.h, fontset.h, systime.h,
termhooks.h, w32heap.h, bitmap/gray.xbm, font.h, w32font.h.
(w32_color_map_lookup, add_system_logical_colors_to_map)
(x_decode_color, x_set_name, FPRINTF_WM_CHARS, Fxw_color_defined_p)
(Fxw_color_values, x_display_info_for_name, Fset_message_beep)
(x_create_tip_frame, Fx_file_dialog, Fsystem_move_file_to_trash)
(w32_parse_hot_key, Ffile_system_info, w32_kbd_patch_key): Avoid
compiler warnings, mainly due to pointer signedness mismatches.
(unwind_create_frame_1): Remove unused function.
* src/w32console.c: Don't include character.h, disptab.h, frame.h,
window.h, termhooks.h, dispextern.h.
(w32con_write_glyphs, w32con_write_glyphs_with_face): Fix pointer
signedness mismatch.
* src/w32.c: Include c-strcase.h and systty.h.  Don't include
w32heap.h.
2015-10-22 19:52:18 +03:00

161 lines
4.4 KiB
C

/* Emulate the X Resource Manager through the registry.
Copyright (C) 1990, 1993-1994, 2001-2015 Free Software Foundation,
Inc.
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Kevin Gallo */
#include <config.h>
#include "lisp.h"
#include "w32term.h" /* for XrmDatabase, xrdb */
#include "blockinput.h"
#include <stdio.h>
#define REG_ROOT "SOFTWARE\\GNU\\Emacs"
/* Default system colors from the Display Control Panel settings. */
#define SYSTEM_DEFAULT_RESOURCES \
"emacs.foreground:SystemWindowText\0" \
"emacs.background:SystemWindow\0" \
"emacs.tooltip.attributeForeground:SystemInfoText\0" \
"emacs.tooltip.attributeBackground:SystemInfoWindow\0" \
"emacs.tool-bar.attributeForeground:SystemButtonText\0" \
"emacs.tool-bar.attributeBackground:SystemButtonFace\0" \
"emacs.menu.attributeForeground:SystemMenuText\0" \
"emacs.menu.attributeBackground:SystemMenu\0" \
"emacs.scroll-bar.attributeForeground:SystemScrollbar\0"
/* Other possibilities for default faces:
region: Could use SystemHilight, but interferes with our ability to
see most syntax highlighting through the region face.
modeline: Could use System(In)ActiveTitle, gradient versions (not
supported on 95 and NT), but modeline is more like a status bar
really (which don't appear to be configurable in Windows).
highlight: Could use SystemHotTrackingColor, but it is not supported
on Windows 95 or NT, and other apps only seem to use it for menus
anyway.
*/
static char *
w32_get_rdb_resource (char *rdb, const char *resource)
{
char *value = rdb;
int len = strlen (resource);
while (*value)
{
/* Comparison is case-insensitive because registry searches are too. */
if ((strnicmp (value, resource, len) == 0) && (value[len] == ':'))
return xstrdup (&value[len + 1]);
value = strchr (value, '\0') + 1;
}
return NULL;
}
static char *
w32_get_string_resource (const char *name, const char *class, DWORD dwexptype)
{
LPBYTE lpvalue = NULL;
HKEY hrootkey = NULL;
DWORD dwType;
DWORD cbData;
BOOL ok = FALSE;
HKEY hive = HKEY_CURRENT_USER;
trykey:
block_input ();
/* Check both the current user and the local machine to see if we have
any resources */
if (RegOpenKeyEx (hive, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS)
{
const char *keyname;
if (RegQueryValueEx (hrootkey, name, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS
&& dwType == dwexptype)
{
keyname = name;
}
else if (RegQueryValueEx (hrootkey, class, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS
&& dwType == dwexptype)
{
keyname = class;
}
else
{
keyname = NULL;
}
ok = (keyname
&& (lpvalue = xmalloc (cbData)) != NULL
&& RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS);
RegCloseKey (hrootkey);
}
unblock_input ();
if (!ok)
{
if (lpvalue)
{
xfree (lpvalue);
lpvalue = NULL;
}
if (hive == HKEY_CURRENT_USER)
{
hive = HKEY_LOCAL_MACHINE;
goto trykey;
}
/* Check if there are Windows specific defaults defined. */
return w32_get_rdb_resource (SYSTEM_DEFAULT_RESOURCES, name);
}
return (char *)lpvalue;
}
/* Retrieve the string resource specified by NAME with CLASS from
database RDB. */
char *
x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
{
if (rdb)
{
char *resource;
if ((resource = w32_get_rdb_resource (rdb, name)))
return resource;
if ((resource = w32_get_rdb_resource (rdb, class)))
return resource;
}
if (inhibit_x_resources)
/* --quick was passed, so this is a no-op. */
return NULL;
return w32_get_string_resource (name, class, REG_SZ);
}