windows.c: use ANSI for subsurface_unset_conf()

We may not write config variables with UTF-8 characters so the wchar_t
conversation in subsurface_unset_conf() is not needed.

This patch also attempts to improve subsurface_get_conf_bool()
and subsurface_get_conf_int() or better consitentcy with the other OS
files. For both functions return -1 if config key is not found.
Previouosly there was a check for that in  function get_from_registry().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Lubomir I. Ivanov 2013-03-01 11:32:52 +02:00 committed by Dirk Hohndel
parent b2ba7917ab
commit c3b3ab9af7

View file

@ -22,12 +22,7 @@ void subsurface_open_conf(void)
void subsurface_unset_conf(char *name) void subsurface_unset_conf(char *name)
{ {
wchar_t *wname; RegDeleteKey(hkey, (LPCTSTR)name);
wname = (wchar_t *)g_utf8_to_utf16(name, -1, NULL, NULL, NULL);
if (!wname)
return;
RegDeleteKey(hkey, (LPCTSTR)wname);
} }
void subsurface_set_conf(char *name, const char *value) void subsurface_set_conf(char *name, const char *value)
@ -108,8 +103,10 @@ const void *subsurface_get_conf(char *name)
int subsurface_get_conf_int(char *name) int subsurface_get_conf_int(char *name)
{ {
DWORD value = -1, len = 4; DWORD value = -1, len = 4;
RegQueryValueEx(hkey, (LPCTSTR)TEXT(name), NULL, NULL, LONG ret = RegQueryValueEx(hkey, (LPCTSTR)TEXT(name), NULL, NULL,
(LPBYTE)&value, (LPDWORD)&len); (LPBYTE)&value, (LPDWORD)&len);
if (ret != ERROR_SUCCESS)
return -1;
return value; return value;
} }
@ -117,7 +114,7 @@ int subsurface_get_conf_bool(char *name)
{ {
int ret = subsurface_get_conf_int(name); int ret = subsurface_get_conf_int(name);
if (ret == -1) if (ret == -1)
return 0; return ret;
return ret != 0; return ret != 0;
} }