mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Use generic win32 interfaces, not ASCII-only ones, where possible.
This commit is contained in:
parent
4ff247b293
commit
899b0a39ab
24
evdns.c
24
evdns.c
@ -3498,12 +3498,12 @@ load_nameservers_with_getnetworkparams(struct evdns_base *base)
|
||||
GetNetworkParams_fn_t fn;
|
||||
|
||||
ASSERT_LOCKED(base);
|
||||
if (!(handle = LoadLibraryA("iphlpapi.dll"))) {
|
||||
if (!(handle = LoadLibrary(TEXT("iphlpapi.dll")))) {
|
||||
log(EVDNS_LOG_WARN, "Could not open iphlpapi.dll");
|
||||
status = -1;
|
||||
goto done;
|
||||
}
|
||||
if (!(fn = (GetNetworkParams_fn_t) GetProcAddress(handle, "GetNetworkParams"))) {
|
||||
if (!(fn = (GetNetworkParams_fn_t) GetProcAddress(handle, TEXT("GetNetworkParams")))) {
|
||||
log(EVDNS_LOG_WARN, "Could not get address of function.");
|
||||
status = -1;
|
||||
goto done;
|
||||
@ -3564,20 +3564,20 @@ load_nameservers_with_getnetworkparams(struct evdns_base *base)
|
||||
}
|
||||
|
||||
static int
|
||||
config_nameserver_from_reg_key(struct evdns_base *base, HKEY key, const char *subkey)
|
||||
config_nameserver_from_reg_key(struct evdns_base *base, HKEY key, const TCHAR *subkey)
|
||||
{
|
||||
char *buf;
|
||||
DWORD bufsz = 0, type = 0;
|
||||
int status = 0;
|
||||
|
||||
ASSERT_LOCKED(base);
|
||||
if (RegQueryValueExA(key, subkey, 0, &type, NULL, &bufsz)
|
||||
if (RegQueryValueEx(key, subkey, 0, &type, NULL, &bufsz)
|
||||
!= ERROR_MORE_DATA)
|
||||
return -1;
|
||||
if (!(buf = mm_malloc(bufsz)))
|
||||
return -1;
|
||||
|
||||
if (RegQueryValueExA(key, subkey, 0, &type, (LPBYTE)buf, &bufsz)
|
||||
if (RegQueryValueEx(key, subkey, 0, &type, (LPBYTE)buf, &bufsz)
|
||||
== ERROR_SUCCESS && bufsz > 1) {
|
||||
status = evdns_nameserver_ip_add_line(base,buf);
|
||||
}
|
||||
@ -3586,9 +3586,9 @@ config_nameserver_from_reg_key(struct evdns_base *base, HKEY key, const char *su
|
||||
return status;
|
||||
}
|
||||
|
||||
#define SERVICES_KEY "System\\CurrentControlSet\\Services\\"
|
||||
#define WIN_NS_9X_KEY SERVICES_KEY "VxD\\MSTCP"
|
||||
#define WIN_NS_NT_KEY SERVICES_KEY "Tcpip\\Parameters"
|
||||
#define SERVICES_KEY TEXT("System\\CurrentControlSet\\Services\\")
|
||||
#define WIN_NS_9X_KEY SERVICES_KEY TEXT("VxD\\MSTCP")
|
||||
#define WIN_NS_NT_KEY SERVICES_KEY TEXT("Tcpip\\Parameters")
|
||||
|
||||
static int
|
||||
load_nameservers_from_registry(struct evdns_base *base)
|
||||
@ -3596,7 +3596,7 @@ load_nameservers_from_registry(struct evdns_base *base)
|
||||
int found = 0;
|
||||
int r;
|
||||
#define TRY(k, name) \
|
||||
if (!found && config_nameserver_from_reg_key(base,k,name) == 0) { \
|
||||
if (!found && config_nameserver_from_reg_key(base,k,TEXT(name)) == 0) { \
|
||||
log(EVDNS_LOG_DEBUG,"Found nameservers in %s/%s",#k,name); \
|
||||
found = 1; \
|
||||
} else if (!found) { \
|
||||
@ -3609,12 +3609,12 @@ load_nameservers_from_registry(struct evdns_base *base)
|
||||
if (((int)GetVersion()) > 0) { /* NT */
|
||||
HKEY nt_key = 0, interfaces_key = 0;
|
||||
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,
|
||||
KEY_READ, &nt_key) != ERROR_SUCCESS) {
|
||||
log(EVDNS_LOG_DEBUG,"Couldn't open nt key, %d",(int)GetLastError());
|
||||
return -1;
|
||||
}
|
||||
r = RegOpenKeyExA(nt_key, "Interfaces", 0,
|
||||
r = RegOpenKeyEx(nt_key, TEXT("Interfaces"), 0,
|
||||
KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
|
||||
&interfaces_key);
|
||||
if (r != ERROR_SUCCESS) {
|
||||
@ -3629,7 +3629,7 @@ load_nameservers_from_registry(struct evdns_base *base)
|
||||
RegCloseKey(nt_key);
|
||||
} else {
|
||||
HKEY win_key = 0;
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_9X_KEY, 0,
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_9X_KEY, 0,
|
||||
KEY_READ, &win_key) != ERROR_SUCCESS) {
|
||||
log(EVDNS_LOG_DEBUG, "Couldn't open registry key, %d", (int)GetLastError());
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user