From d6d63147b6a5f425b1601b0576483937fe9f99d1 Mon Sep 17 00:00:00 2001
From: Yang Tse <yangsita@gmail.com>
Date: Thu, 18 Jun 2009 12:36:10 +0000
Subject: [PATCH] add CloseSocket camel case function check

---
 ares/configure.ac          |  1 +
 ares/m4/cares-functions.m4 | 92 +++++++++++++++++++++++++++++++++++++-
 configure.ac               |  1 +
 m4/curl-functions.m4       | 92 +++++++++++++++++++++++++++++++++++++-
 4 files changed, 184 insertions(+), 2 deletions(-)

diff --git a/ares/configure.ac b/ares/configure.ac
index d4bd4d284f..eda89eb093 100644
--- a/ares/configure.ac
+++ b/ares/configure.ac
@@ -536,6 +536,7 @@ CURL_CHECK_FUNC_SEND
 CURL_CHECK_MSG_NOSIGNAL
 
 CARES_CHECK_FUNC_CLOSESOCKET
+CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
 CARES_CHECK_FUNC_FCNTL
 CARES_CHECK_FUNC_FREEADDRINFO
 CARES_CHECK_FUNC_GETADDRINFO
diff --git a/ares/m4/cares-functions.m4 b/ares/m4/cares-functions.m4
index 40545d940d..1da3f5a534 100644
--- a/ares/m4/cares-functions.m4
+++ b/ares/m4/cares-functions.m4
@@ -16,7 +16,7 @@
 #***************************************************************************
 
 # File version for 'aclocal' use. Keep it a single number.
-# serial 30
+# serial 31
 
 
 dnl CARES_INCLUDES_ARPA_INET
@@ -434,6 +434,96 @@ AC_DEFUN([CARES_CHECK_FUNC_CLOSESOCKET], [
 ])
 
 
+dnl CARES_CHECK_FUNC_CLOSESOCKET_CAMEL
+dnl -------------------------------------------------
+dnl Verify if CloseSocket is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable cares_disallow_closesocket_camel,
+dnl then HAVE_CLOSESOCKET_CAMEL will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_CLOSESOCKET_CAMEL], [
+  AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
+  #
+  tst_links_closesocket_camel="unknown"
+  tst_proto_closesocket_camel="unknown"
+  tst_compi_closesocket_camel="unknown"
+  tst_allow_closesocket_camel="unknown"
+  #
+  AC_MSG_CHECKING([if CloseSocket can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([[
+      $cares_includes_sys_socket
+    ]],[[
+      if(0 != CloseSocket(0))
+        return 1;
+    ]])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_closesocket_camel="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_closesocket_camel="no"
+  ])
+  #
+  if test "$tst_links_closesocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if CloseSocket is prototyped])
+    AC_EGREP_CPP([CloseSocket],[
+      $cares_includes_sys_socket
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_closesocket_camel="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_closesocket_camel="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_closesocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if CloseSocket is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_sys_socket
+      ]],[[
+        if(0 != CloseSocket(0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_closesocket_camel="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_closesocket_camel="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_closesocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if CloseSocket usage allowed])
+    if test "x$cares_disallow_closesocket_camel" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_closesocket_camel="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_closesocket_camel="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if CloseSocket might be used])
+  if test "$tst_links_closesocket_camel" = "yes" &&
+     test "$tst_proto_closesocket_camel" = "yes" &&
+     test "$tst_compi_closesocket_camel" = "yes" &&
+     test "$tst_allow_closesocket_camel" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET_CAMEL, 1,
+      [Define to 1 if you have the CloseSocket camel case function.])
+    ac_cv_func_closesocket_camel="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_closesocket_camel="no"
+  fi
+])
+
+
 dnl CARES_CHECK_FUNC_FCNTL
 dnl -------------------------------------------------
 dnl Verify if fcntl is available, prototyped, and
diff --git a/configure.ac b/configure.ac
index 3dfd087ac4..c141e7bd63 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2001,6 +2001,7 @@ CURL_CHECK_MSG_NOSIGNAL
 
 CURL_CHECK_FUNC_ALARM
 CURL_CHECK_FUNC_CLOSESOCKET
+CURL_CHECK_FUNC_CLOSESOCKET_CAMEL
 CURL_CHECK_FUNC_FCNTL
 CURL_CHECK_FUNC_FDOPEN
 CURL_CHECK_FUNC_FREEADDRINFO
diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4
index 891493a0ac..df750478ce 100644
--- a/m4/curl-functions.m4
+++ b/m4/curl-functions.m4
@@ -22,7 +22,7 @@
 #***************************************************************************
 
 # File version for 'aclocal' use. Keep it a single number.
-# serial 49
+# serial 50
 
 
 dnl CURL_INCLUDES_ARPA_INET
@@ -692,6 +692,96 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET], [
 ])
 
 
+dnl CURL_CHECK_FUNC_CLOSESOCKET_CAMEL
+dnl -------------------------------------------------
+dnl Verify if CloseSocket is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable curl_disallow_closesocket_camel,
+dnl then HAVE_CLOSESOCKET_CAMEL will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET_CAMEL], [
+  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
+  #
+  tst_links_closesocket_camel="unknown"
+  tst_proto_closesocket_camel="unknown"
+  tst_compi_closesocket_camel="unknown"
+  tst_allow_closesocket_camel="unknown"
+  #
+  AC_MSG_CHECKING([if CloseSocket can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([[
+      $curl_includes_sys_socket
+    ]],[[
+      if(0 != CloseSocket(0))
+        return 1;
+    ]])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_closesocket_camel="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_closesocket_camel="no"
+  ])
+  #
+  if test "$tst_links_closesocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if CloseSocket is prototyped])
+    AC_EGREP_CPP([CloseSocket],[
+      $curl_includes_sys_socket
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_closesocket_camel="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_closesocket_camel="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_closesocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if CloseSocket is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_sys_socket
+      ]],[[
+        if(0 != CloseSocket(0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_closesocket_camel="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_closesocket_camel="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_closesocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if CloseSocket usage allowed])
+    if test "x$curl_disallow_closesocket_camel" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_closesocket_camel="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_closesocket_camel="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if CloseSocket might be used])
+  if test "$tst_links_closesocket_camel" = "yes" &&
+     test "$tst_proto_closesocket_camel" = "yes" &&
+     test "$tst_compi_closesocket_camel" = "yes" &&
+     test "$tst_allow_closesocket_camel" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET_CAMEL, 1,
+      [Define to 1 if you have the CloseSocket camel case function.])
+    ac_cv_func_closesocket_camel="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_closesocket_camel="no"
+  fi
+])
+
+
 dnl CURL_CHECK_FUNC_FCNTL
 dnl -------------------------------------------------
 dnl Verify if fcntl is available, prototyped, and
-- 
GitLab