#define local inline
#ifndef ZEND_ENGINE_2
-# define zend_is_callable(a,b,c) 1
+# define IS_CALLABLE(a,b,c) 1
# ifndef ZTS
# undef TSRMLS_SET_CTX
# define TSRMLS_SET_CTX
# define TSRMLS_FETCH_FROM_CTX
# endif
#endif
+#if (PHP_MAJOR_VERSION > 5) || ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION >= 3))
+# define ADDREF(z) Z_ADDREF_P(z)
+# define IS_CALLABLE(a,b,c) zend_is_callable((a), (b), (c) TSRMLS_CC)
+#else
+# define ADDREF(z) ZVAL_ADDREF(z)
+# define IS_CALLABLE(a,b,c) zend_is_callable((a), (b), (c))
+#endif
#define PHP_ARES_LE_NAME "AsyncResolver"
#define PHP_ARES_QUERY_LE_NAME "AsyncResolverQuery"
query->error = -1;
if (callback) {
- ZVAL_ADDREF(callback);
+ ADDREF(callback);
query->callback = callback;
}
/* }}} */
/* {{{ callbacks */
-static void php_ares_callback_func(void *aq, int status, unsigned char *abuf, int alen)
+static void php_ares_callback_func_old(void *aq, int status, unsigned char *abuf, int alen)
{
php_ares_query *q = (php_ares_query *) aq;
zval *params[3], *retval;
}
}
-static void php_ares_host_callback_func(void *aq, int status, struct hostent *hostent)
+static void php_ares_host_callback_func_old(void *aq, int status, struct hostent *hostent)
{
php_ares_query *q = (php_ares_query *) aq;
zval *params[3], *retval;
}
#ifdef HAVE_ARES_GETNAMEINFO
-static void php_ares_nameinfo_callback_func(void *aq, int status, char *node, char *service)
+static void php_ares_nameinfo_callback_func_old(void *aq, int status, char *node, char *service)
{
php_ares_query *q = (php_ares_query *) aq;
zval *params[4], *retval;
}
}
#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_old
+# define php_ares_host_callback_func php_ares_host_callback_func_old
+# ifdef HAVE_ARES_GETNAMEINFO
+# define php_ares_nameinfo_callback_func php_ares_nameinfo_callback_func_old
+# endif
+#endif
/* }}} */
local struct timeval *php_ares_timeout(php_ares *ares, long max_timeout, struct timeval *tv_buf) /* {{{ */
}
ZEND_FETCH_RESOURCE(ares, php_ares *, &rsrc, -1, PHP_ARES_LE_NAME, le_ares);
- if (cb && !zend_is_callable(cb, 0, NULL)) {
+ if (cb && !IS_CALLABLE(cb, 0, NULL)) {
RETURN_ARES_CB_ERROR("second");
}
}
ZEND_FETCH_RESOURCE(ares, php_ares *, &rsrc, -1, PHP_ARES_LE_NAME, le_ares);
- if (cb && !zend_is_callable(cb, 0, NULL)) {
+ if (cb && !IS_CALLABLE(cb, 0, NULL)) {
RETURN_ARES_CB_ERROR("second");
}
}
ZEND_FETCH_RESOURCE(ares, php_ares *, &rsrc, -1, PHP_ARES_LE_NAME, le_ares);
- if (cb && !zend_is_callable(cb, 0, NULL)) {
+ if (cb && !IS_CALLABLE(cb, 0, NULL)) {
RETURN_ARES_CB_ERROR("second");
}
}
ZEND_FETCH_RESOURCE(ares, php_ares *, &rsrc, -1, PHP_ARES_LE_NAME, le_ares);
- if (cb && !zend_is_callable(cb, 0, NULL)) {
+ if (cb && !IS_CALLABLE(cb, 0, NULL)) {
RETURN_ARES_CB_ERROR("second");
}
}
ZEND_FETCH_RESOURCE(ares, php_ares *, &rsrc, -1, PHP_ARES_LE_NAME, le_ares);
- if (cb && !zend_is_callable(cb, 0, NULL)) {
+ if (cb && !IS_CALLABLE(cb, 0, NULL)) {
PHP_ARES_CB_ERROR("second");
RETURN_FALSE;
}
}
ZEND_FETCH_RESOURCE(ares, php_ares *, &rsrc, -1, PHP_ARES_LE_NAME, le_ares);
- if (cb && !zend_is_callable(cb, 0, NULL)) {
+ if (cb && !IS_CALLABLE(cb, 0, NULL)) {
PHP_ARES_CB_ERROR("second");
RETURN_FALSE;
}
}
/* }}} */
-
-/* {{{ 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;
{
php_info_print_table_start();
php_info_print_table_header(2, "AsyncResolver support", "enabled");
+ php_info_print_table_row(2, "Version", PHP_ARES_VERSION);
php_info_print_table_end();
php_info_print_table_start();
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}
};
/* }}} */
NULL,
NULL,
PHP_MINFO(ares),
- NO_VERSION_YET,
+ PHP_ARES_VERSION,
STANDARD_MODULE_PROPERTIES
};
/* }}} */