dropped unused functions;
authorMichael Wallner <mike@php.net>
Wed, 7 Jan 2009 12:05:55 +0000 (12:05 +0000)
committerMichael Wallner <mike@php.net>
Wed, 7 Jan 2009 12:05:55 +0000 (12:05 +0000)
fix incompatibility with c-ares >= v1.5

git-svn-id: http://svn.php.net/repository/pecl/ares/trunk@272947 c90b9560-bf6c-de11-be94-00142212c4b1

ares.c
config.m4

diff --git a/ares.c b/ares.c
index 23930c345fdc88f7614c0bde96bff2a413379a37..07e5a443d11e888cc2daeeaf52eadc4e24eec2b2 100644 (file)
--- a/ares.c
+++ b/ares.c
@@ -618,6 +618,35 @@ static void php_ares_nameinfo_callback_func(void *aq, int status, char *node, ch
        }
 }
 #endif
+
+#if PHP_ARES_NEW_CALLBACK_API
+#      define php_ares_callback_func php_ares_callback_func_new
+static void php_ares_callback_func_new(void *aq, int status, int timeouts, unsigned char *abuf, int alen)
+{
+       php_ares_callback_func_old(aq, status, abuf, alen);
+}
+
+#      define php_ares_host_callback_func php_ares_host_callback_func_new
+static void php_ares_host_callback_func_new(void *aq, int status, int timeouts, struct hostent *hostent)
+{
+       php_ares_host_callback_func_old(aq, status, hostent);
+}
+
+#      ifdef HAVE_ARES_GETNAMEINFO
+#              define php_ares_nameinfo_callback_func php_ares_nameinfo_callback_func_new
+static void php_ares_nameinfo_callback_func_new(void *aq, int status, int timeouts, char *node, char *service)
+{
+       php_ares_nameinfo_callback_func_old(aq, status, node, service);
+}
+#      endif
+
+#else
+#      define php_ares_callback_func php_ares_callback_func_new
+#      define php_ares_host_callback_func php_ares_host_callback_func_new
+#      ifdef HAVE_ARES_GETNAMEINFO
+#              define php_ares_nameinfo_callback_func php_ares_nameinfo_callback_func_new
+#      endif
+#endif
 /* }}} */
 
 local struct timeval *php_ares_timeout(php_ares *ares, long max_timeout, struct timeval *tv_buf) /* {{{ */
@@ -1330,117 +1359,6 @@ static PHP_FUNCTION(ares_fds)
 }
 /* }}} */
 
-
-/* {{{ proto array ares_parse_a_reply(string reply)
-       Parse an A reply */
-static PHP_FUNCTION(ares_parse_a_reply)
-{
-       char *buf;
-       int len, err;
-       struct hostent *hostent;
-       
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &len)) {
-               RETURN_FALSE;
-       }
-       
-       if (ARES_SUCCESS != (err = ares_parse_a_reply((const unsigned char *) buf, len, &hostent))) {
-               RETURN_ARES_ERROR(err);
-       }
-       
-       object_init(return_value);
-       php_ares_hostent_to_struct(hostent, HASH_OF(return_value));
-       ares_free_hostent(hostent);
-}
-/* }}} */
-
-#ifdef HAVE_ARES_PARSE_AAAA_REPLY
-/* {{{ proto array ares_parse_aaaa_reply(string reply)
-       Parse an AAAA reply */
-static PHP_FUNCTION(ares_parse_aaaa_reply)
-{
-       char *buf;
-       int len, err;
-       struct hostent *hostent;
-       
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &len)) {
-               RETURN_FALSE;
-       }
-       
-       if (ARES_SUCCESS != (err = ares_parse_aaaa_reply((const unsigned char *) buf, len, &hostent))) {
-               RETURN_ARES_ERROR(err);
-       }
-       
-       object_init(return_value);
-       php_ares_hostent_to_struct(hostent, HASH_OF(return_value));
-       ares_free_hostent(hostent);
-}
-/* }}} */
-#endif
-
-/* {{{ proto array ares_parse_ptr_reply(string reply)
-       Parse a PTR reply */
-static PHP_FUNCTION(ares_parse_ptr_reply)
-{
-       char *buf;
-       int len, err;
-       struct hostent *hostent;
-       
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &len)) {
-               RETURN_FALSE;
-       }
-       
-       if (ARES_SUCCESS != (err = ares_parse_ptr_reply((const unsigned char *) buf, len, NULL, 0, 0, &hostent))) {
-               RETURN_ARES_ERROR(err);
-       }
-       
-       object_init(return_value);
-       php_ares_hostent_to_struct(hostent, HASH_OF(return_value));
-       ares_free_hostent(hostent);
-}
-/* }}} */
-
-/* {{{ proto string ares_expand_name(string name)
-       Expand a DNS encoded name into a human readable dotted string */
-static PHP_FUNCTION(ares_expand_name)
-{
-       char *name_str, *exp_str;
-       int name_len,err;
-       PHP_ARES_EXPAND_LEN_TYPE exp_len;
-       
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len)) {
-               RETURN_FALSE;
-       }
-       
-       if (ARES_SUCCESS != (err = ares_expand_name((const unsigned char *) name_str, (const unsigned char *) name_str, name_len, &exp_str, &exp_len))) {
-               RETURN_ARES_ERROR(err);
-       }
-       RETVAL_STRINGL(exp_str, exp_len, 1);
-       ares_free_string(exp_str);
-}
-/* }}} */
-
-#ifdef HAVE_ARES_EXPAND_STRING
-/* {{{ proto string ares_expand_string(string buf)
-       Expand a DNS encoded string into a human readable */
-static PHP_FUNCTION(ares_expand_string)
-{
-       char *buf_str, *exp_str;
-       int buf_len, err;
-       PHP_ARES_EXPAND_LEN_TYPE exp_len;
-       
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf_str, &buf_len)) {
-               RETURN_FALSE;
-       }
-       
-       if (ARES_SUCCESS != (err = ares_expand_string((const unsigned char *) buf_str, (const unsigned char *) buf_str, buf_len, (unsigned char **) &exp_str, &exp_len))) {
-               RETURN_ARES_ERROR(err);
-       }
-       RETVAL_STRINGL(exp_str, exp_len, 1);
-       ares_free_string(exp_str);
-}
-/* }}} */
-#endif
-
 static ZEND_RSRC_DTOR_FUNC(php_ares_le_dtor)
 {
        php_ares *ares = (php_ares *) rsrc->ptr;
@@ -1808,15 +1726,6 @@ zend_function_entry ares_functions[] = {
        PHP_FE(ares_select, ai_ares_select)
        PHP_FE(ares_fds, ai_ares_fds)
        PHP_FE(ares_timeout, NULL)
-       PHP_FE(ares_parse_a_reply, NULL)
-#ifdef HAVE_ARES_PARSE_AAAA_REPLY
-       PHP_FE(ares_parse_aaaa_reply, NULL)
-#endif
-       PHP_FE(ares_parse_ptr_reply, NULL)
-       PHP_FE(ares_expand_name, NULL)
-#ifdef HAVE_ARES_EXPAND_STRING
-       PHP_FE(ares_expand_string, NULL)
-#endif
        {NULL, NULL, NULL}
 };
 /* }}} */
index 46d96a37256a4240fed96d5bbe74f785ee49c1fb..1b96e73f4b561bedae8cfb5b19c92e7fbc9ccdfb 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -18,6 +18,7 @@ if test "$PHP_ARES" != "no"; then
                AC_MSG_ERROR(could not find ares.h)
        fi
        
+       PHP_ADD_LIBRARY(rt, ARES_SHARED_LIBADD)
        PHP_ARES_LIB=
        PHP_CHECK_LIBRARY(cares, ares_init, [
                        PHP_ARES_LIB=cares
@@ -56,14 +57,6 @@ if test "$PHP_ARES" != "no"; then
                [AC_DEFINE([HAVE_ARES_GETNAMEINFO], [1], [ ])], [ ], 
                [-L$PHP_ARES_DIR/$PHP_LIBDIR]
        )
-       PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_expand_string, 
-               [AC_DEFINE([HAVE_ARES_EXPAND_STRING], [1], [ ])], [ ], 
-               [-L$PHP_ARES_DIR/$PHP_LIBDIR]
-       )
-       PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_parse_aaaa_reply, 
-               [AC_DEFINE([HAVE_ARES_PARSE_AAAA_REPLY], [1], [ ])], [ ], 
-               [-L$PHP_ARES_DIR/$PHP_LIBDIR]
-       )
        PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_getsock, 
                [AC_DEFINE([HAVE_ARES_GETSOCK], [1], [ ])], [ ], 
                [-L$PHP_ARES_DIR/$PHP_LIBDIR]
@@ -73,6 +66,31 @@ if test "$PHP_ARES" != "no"; then
                [-L$PHP_ARES_DIR/$PHP_LIBDIR]
        )
        
+       
+       dnl check new c-ares API
+       
+       save_LIBS=$LIBS
+       save_CFLAGS=$CFLAGS
+       LIBS="-L $PHP_ARES_DIR/$PHP_LIBDIR -l $PHP_ARES_LIB"
+       CFLAGS="-I$PHP_ARES_DIR/include -pedantic-errors"
+       
+       AC_MSG_CHECKING(for new c-ares callback API)
+       AC_TRY_COMPILE(
+               [#include <ares.h>
+               ], [
+                       ares_search(0, 0, 0, 0, (void (*)(void *, int, int, unsigned char *, int)) 0, 0);
+               ], [
+                       AC_MSG_RESULT(yes)
+                       AC_DEFINE([PHP_ARES_NEW_CALLBACK_API], [1], [ ])
+               ], [
+                       AC_MSG_RESULT(no)
+                       AC_DEFINE([PHP_ARES_NEW_CALLBACK_API], [0], [ ])
+               ]
+       )
+       
+       LIBS=$save_LIBS
+       CFLAGS=$save_CFLAGS
+       
        AC_CHECK_HEADERS([netdb.h unistd.h arpa/inet.h arpa/nameser.h])
        
        PHP_ADD_INCLUDE($PHP_ARES_DIR/include)