Improve win32 behavior of dns-sample.c codex

This commit is contained in:
Gisle Vanem 2011-11-09 00:17:56 -05:00 committed by Nick Mathewson
parent 674bc6a29e
commit a3f320e83d

View File

@ -165,6 +165,13 @@ main(int c, char **v) {
++idx; ++idx;
} }
#ifdef WIN32
{
WSADATA WSAData;
WSAStartup(0x101, &WSAData);
}
#endif
event_base = event_base_new(); event_base = event_base_new();
evdns_base = evdns_base_new(event_base, 0); evdns_base = evdns_base_new(event_base, 0);
evdns_set_log_fn(logfn); evdns_set_log_fn(logfn);
@ -188,12 +195,17 @@ main(int c, char **v) {
evdns_add_server_port_with_base(event_base, sock, 0, evdns_server_callback, NULL); evdns_add_server_port_with_base(event_base, sock, 0, evdns_server_callback, NULL);
} }
if (idx < c) { if (idx < c) {
int res;
#ifdef WIN32 #ifdef WIN32
evdns_base_config_windows_nameservers(evdns_base); res = evdns_base_config_windows_nameservers(evdns_base);
#else #else
evdns_base_resolv_conf_parse(evdns_base, DNS_OPTION_NAMESERVERS, res = evdns_base_resolv_conf_parse(evdns_base, DNS_OPTION_NAMESERVERS,
"/etc/resolv.conf"); "/etc/resolv.conf");
#endif #endif
if (res < 0) {
fprintf(stderr, "Couldn't configure nameservers");
return 1;
}
} }
printf("EVUTIL_AI_CANONNAME in example = %d\n", EVUTIL_AI_CANONNAME); printf("EVUTIL_AI_CANONNAME in example = %d\n", EVUTIL_AI_CANONNAME);