iphlpapi: Add a configure check for struct __res_state.

This commit is contained in:
Huw Davies 2013-09-17 13:09:15 +01:00 committed by Alexandre Julliard
parent 4f1c0e9355
commit c7dd313d75
4 changed files with 54 additions and 16 deletions

14
configure vendored
View File

@ -14792,6 +14792,20 @@ _ACEOF
fi
ac_fn_c_check_type "$LINENO" "struct __res_state" "ac_cv_type_struct___res_state" "#ifdef HAVE_RESOLV_H
#include <resolv.h>
#endif
"
if test "x$ac_cv_type_struct___res_state" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT___RES_STATE 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct __res_state" "_u._ext.nscount6" "ac_cv_member_struct___res_state__u__ext_nscount6" "#ifdef HAVE_RESOLV_H
#include <resolv.h>
#endif

View File

@ -2344,6 +2344,12 @@ AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id],,,
#include <netinet/in.h>
#endif])
dnl Check for struct __res_state
AC_CHECK_TYPES([struct __res_state],,,
[#ifdef HAVE_RESOLV_H
#include <resolv.h>
#endif])
dnl Check for _u._ext.nscount6
AC_CHECK_MEMBERS([struct __res_state._u._ext.nscount6],,,
[#ifdef HAVE_RESOLV_H

View File

@ -63,14 +63,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
#define INADDR_NONE ~0UL
#endif
/* call res_init() just once because of a bug in Mac OS X 10.4 */
/* Call once per thread on systems that have per-thread _res. */
static void initialise_resolver(void)
{
if ((_res.options & RES_INIT) == 0)
res_init();
}
/******************************************************************
* AddIPAddress (IPHLPAPI.@)
*
@ -933,6 +925,15 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
return ERROR_SUCCESS;
}
#ifdef HAVE_STRUCT___RES_STATE
/* call res_init() just once because of a bug in Mac OS X 10.4 */
/* Call once per thread on systems that have per-thread _res. */
static void initialise_resolver(void)
{
if ((_res.options & RES_INIT) == 0)
res_init();
}
static int get_dns_servers( SOCKADDR_STORAGE *servers, int num, BOOL ip4_only )
{
int i, ip6_count = 0;
@ -977,6 +978,13 @@ static int get_dns_servers( SOCKADDR_STORAGE *servers, int num, BOOL ip4_only )
}
return addr - servers;
}
#else
static int get_dns_servers( SOCKADDR_STORAGE *servers, int num, BOOL ip4_only )
{
FIXME("Unimplemented on this system\n");
return 0;
}
#endif
static ULONG get_dns_server_addresses(PIP_ADAPTER_DNS_SERVER_ADDRESS address, ULONG *len)
{
@ -1015,6 +1023,7 @@ static ULONG get_dns_server_addresses(PIP_ADAPTER_DNS_SERVER_ADDRESS address, UL
return ERROR_SUCCESS;
}
#ifdef HAVE_STRUCT___RES_STATE
static BOOL is_ip_address_string(const char *str)
{
struct in_addr in;
@ -1023,22 +1032,28 @@ static BOOL is_ip_address_string(const char *str)
ret = inet_aton(str, &in);
return ret != 0;
}
#endif
static ULONG get_dns_suffix(WCHAR *suffix, ULONG *len)
{
ULONG size, i;
ULONG size;
const char *found_suffix = "";
/* Always return a NULL-terminated string, even if it's empty. */
initialise_resolver();
for (i = 0; !*found_suffix && i < MAXDNSRCH + 1 && _res.dnsrch[i]; i++)
#ifdef HAVE_STRUCT___RES_STATE
{
/* This uses a heuristic to select a DNS suffix:
* the first, non-IP address string is selected.
*/
if (!is_ip_address_string(_res.dnsrch[i]))
found_suffix = _res.dnsrch[i];
ULONG i;
initialise_resolver();
for (i = 0; !*found_suffix && i < MAXDNSRCH + 1 && _res.dnsrch[i]; i++)
{
/* This uses a heuristic to select a DNS suffix:
* the first, non-IP address string is selected.
*/
if (!is_ip_address_string(_res.dnsrch[i]))
found_suffix = _res.dnsrch[i];
}
}
#endif
size = MultiByteToWideChar( CP_UNIXCP, 0, found_suffix, -1, NULL, 0 ) * sizeof(WCHAR);
if (!suffix || *len < size)

View File

@ -912,6 +912,9 @@
/* Define to 1 if the system has the type `struct xinpgen'. */
#undef HAVE_STRUCT_XINPGEN
/* Define to 1 if the system has the type `struct __res_state'. */
#undef HAVE_STRUCT___RES_STATE
/* Define to 1 if `_u._ext.nscount6' is a member of `struct __res_state'. */
#undef HAVE_STRUCT___RES_STATE__U__EXT_NSCOUNT6