dns_get_record for OSX
| From: | Scott MacVicar | Date: | Wed, 07 Jan 2009 03:30:42 +0000 |
| Subject: | dns_get_record for OSX | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-42521@lists.php.net to get a copy of this message | ||
I went to look at the bug Pierre mention earlier and noticed that
dns_get_record isn't implemented on OS X, this looks to be down to the
fact that it has a bind 8 BC layer that we use by default for some
reason. I tried to make it use the bind 9 interface but it wasn't a
simple task as some other things were missing.
End result here is a patch that allows bind 8 to work and therefore OS
X, the main difference is that there is a shared _res structure rather
than a per request one.
I'll apply this tomorrow if no one has any objections.
Scott
? tests/general_functions/escapeshellcmd-win32.phpt Index: config.m4 =================================================================== RCS file: /repository/php-src/ext/standard/config.m4,v retrieving revision 1.80.2.3.2.3.2.7 diff -u -r1.80.2.3.2.3.2.7 config.m4 --- config.m4 2 Dec 2008 16:27:15 -0000 1.80.2.3.2.3.2.7 +++ config.m4 7 Jan 2009 03:25:48 -0000 @@ -254,6 +254,14 @@ PHP_CHECK_FUNC(dn_expand, resolv, bind, socket) dnl +dnl These are old deprecated functions, a single define of HAVE_DEPRECATED_DNS_FUNCS +dnl will be set in ext/standard/dns.h +dnl + +PHP_CHECK_FUNC(res_mkquery, resolv, bind, socket) +PHP_CHECK_FUNC(res_send, resolv, bind, socket) + +dnl dnl Check if atof() accepts NAN dnl AC_CACHE_CHECK(whether atof() accepts NAN, ac_cv_atof_accept_nan,[ Index: dns.c =================================================================== RCS file: /repository/php-src/ext/standard/dns.c,v retrieving revision 1.70.2.7.2.5.2.14 diff -u -r1.70.2.7.2.5.2.14 dns.c --- dns.c 6 Jan 2009 23:37:28 -0000 1.70.2.7.2.5.2.14 +++ dns.c 7 Jan 2009 03:25:49 -0000 @@ -357,7 +357,7 @@ * __libc_res_nsend() in resolv/res_send.c * */ -#ifdef __GLIBC__ +#if defined(__GLIBC__) && !defined(HAVE_DEPRECATED_DNS_FUNCS) #define php_dns_free_res(__res__) _php_dns_free_res(__res__) static void _php_dns_free_res(struct __res_state res) { /* {{{ */ int ns; @@ -663,7 +663,9 @@ zval *authns = NULL, *addtl = NULL; int addtl_recs = 0; int type_to_fetch; +#if !defined(HAVE_DEPRECATED_DNS_FUNCS) struct __res_state res; +#endif HEADER *hp; querybuf buf, answer; u_char *cp = NULL, *end = NULL; @@ -748,11 +750,14 @@ break; } if (type_to_fetch) { +#if defined(HAVE_DEPRECATED_DNS_FUNCS) + res_init(); +#else memset(&res, 0, sizeof(res)); res_ninit(&res); res.retrans = 5; res.options &= ~RES_DEFNAMES; - +#endif n = res_nmkquery(&res, QUERY, hostname, C_IN, type_to_fetch, NULL, 0, NULL, buf.qb2, sizeof buf); if (n<0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "res_nmkquery() failed"); Index: dns.h =================================================================== RCS file: /repository/php-src/ext/standard/dns.h,v retrieving revision 1.19.2.1.2.1.2.4 diff -u -r1.19.2.1.2.1.2.4 dns.h --- dns.h 6 Jan 2009 20:48:20 -0000 1.19.2.1.2.1.2.4 +++ dns.h 7 Jan 2009 03:25:49 -0000 @@ -23,7 +23,18 @@ #ifndef DNS_H #define DNS_H -#if HAVE_RES_NMKQUERY && HAVE_RES_NSEND && HAVE_DN_EXPAND && HAVE_DN_SKIPNAME +#if HAVE_RES_MKQUERY && !defined(HAVE_RES_NMKQUERY) && HAVE_RES_SEND && !defined(HAVE_RES_NSEND) +#define HAVE_DEPRECATED_DNS_FUNCS 1 +#endif + +#if HAVE_DEPRECATED_DNS_FUNCS +#define res_nmkquery(res, op, dname, class, type, data, datalen, newrr, buf, buflen) \ + res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) +#define res_nsend(res, msg, msglen, answer, anslen) res_send(msg, msglen, answer, anslen); +#define res_nclose(res) /* noop*/ +#endif + +#if ((HAVE_RES_NMKQUERY && HAVE_RES_NSEND) || HAVE_DEPRECATED_DNS_FUNCS) && HAVE_DN_EXPAND && HAVE_DN_SKIPNAME #define HAVE_DNS_FUNCS 1 #endif
? tests/general_functions/escapeshellcmd-win32.phpt Index: config.m4 =================================================================== RCS file: /repository/php-src/ext/standard/config.m4,v retrieving revision 1.80.2.3.2.3.2.7 diff -u -r1.80.2.3.2.3.2.7 config.m4 --- config.m4 2 Dec 2008 16:27:15 -0000 1.80.2.3.2.3.2.7 +++ config.m4 7 Jan 2009 03:25:48 -0000 @@ -254,6 +254,14 @@ PHP_CHECK_FUNC(dn_expand, resolv, bind, socket) dnl +dnl These are old deprecated functions, a single define of HAVE_DEPRECATED_DNS_FUNCS +dnl will be set in ext/standard/dns.h +dnl + +PHP_CHECK_FUNC(res_mkquery, resolv, bind, socket) +PHP_CHECK_FUNC(res_send, resolv, bind, socket) + +dnl dnl Check if atof() accepts NAN dnl AC_CACHE_CHECK(whether atof() accepts NAN, ac_cv_atof_accept_nan,[ Index: dns.c =================================================================== RCS file: /repository/php-src/ext/standard/dns.c,v retrieving revision 1.70.2.7.2.5.2.14 diff -u -r1.70.2.7.2.5.2.14 dns.c --- dns.c 6 Jan 2009 23:37:28 -0000 1.70.2.7.2.5.2.14 +++ dns.c 7 Jan 2009 03:25:49 -0000 @@ -357,7 +357,7 @@ * __libc_res_nsend() in resolv/res_send.c * */ -#ifdef __GLIBC__ +#if defined(__GLIBC__) && !defined(HAVE_DEPRECATED_DNS_FUNCS) #define php_dns_free_res(__res__) _php_dns_free_res(__res__) static void _php_dns_free_res(struct __res_state res) { /* {{{ */ int ns; @@ -663,7 +663,9 @@ zval *authns = NULL, *addtl = NULL; int addtl_recs = 0; int type_to_fetch; +#if !defined(HAVE_DEPRECATED_DNS_FUNCS) struct __res_state res; +#endif HEADER *hp; querybuf buf, answer; u_char *cp = NULL, *end = NULL; @@ -748,11 +750,14 @@ break; } if (type_to_fetch) { +#if defined(HAVE_DEPRECATED_DNS_FUNCS) + res_init(); +#else memset(&res, 0, sizeof(res)); res_ninit(&res); res.retrans = 5; res.options &= ~RES_DEFNAMES; - +#endif n = res_nmkquery(&res, QUERY, hostname, C_IN, type_to_fetch, NULL, 0, NULL, buf.qb2, sizeof buf); if (n<0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "res_nmkquery() failed"); Index: dns.h =================================================================== RCS file: /repository/php-src/ext/standard/dns.h,v retrieving revision 1.19.2.1.2.1.2.4 diff -u -r1.19.2.1.2.1.2.4 dns.h --- dns.h 6 Jan 2009 20:48:20 -0000 1.19.2.1.2.1.2.4 +++ dns.h 7 Jan 2009 03:25:49 -0000 @@ -23,7 +23,18 @@ #ifndef DNS_H #define DNS_H -#if HAVE_RES_NMKQUERY && HAVE_RES_NSEND && HAVE_DN_EXPAND && HAVE_DN_SKIPNAME +#if HAVE_RES_MKQUERY && !defined(HAVE_RES_NMKQUERY) && HAVE_RES_SEND && !defined(HAVE_RES_NSEND) +#define HAVE_DEPRECATED_DNS_FUNCS 1 +#endif + +#if HAVE_DEPRECATED_DNS_FUNCS +#define res_nmkquery(res, op, dname, class, type, data, datalen, newrr, buf, buflen) \ + res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) +#define res_nsend(res, msg, msglen, answer, anslen) res_send(msg, msglen, answer, anslen); +#define res_nclose(res) /* noop*/ +#endif + +#if ((HAVE_RES_NMKQUERY && HAVE_RES_NSEND) || HAVE_DEPRECATED_DNS_FUNCS) && HAVE_DN_EXPAND && HAVE_DN_SKIPNAME #define HAVE_DNS_FUNCS 1 #endif