Huw Davies : iphlpapi: Add a configure check for struct __res_state.

Alexandre Julliard julliard at winehq.org
Tue Sep 17 15:25:53 CDT 2013


Module: wine
Branch: master
Commit: c7dd313d750096687f8531c27e39c7de71f0092c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c7dd313d750096687f8531c27e39c7de71f0092c

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Sep 17 13:09:15 2013 +0100

iphlpapi: Add a configure check for struct __res_state.

---

 configure                     |   14 ++++++++++++
 configure.ac                  |    6 +++++
 dlls/iphlpapi/iphlpapi_main.c |   47 +++++++++++++++++++++++++++--------------
 include/config.h.in           |    3 ++
 4 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/configure b/configure
index 28e275d..a01bee0 100755
--- a/configure
+++ b/configure
@@ -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
diff --git a/configure.ac b/configure.ac
index f42fc15..b69c379 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index 789c339..6ce2c94 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -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)
diff --git a/include/config.h.in b/include/config.h.in
index 2ab1081..505dd28 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -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
 




More information about the wine-cvs mailing list