jani            Mon Nov  5 13:42:33 2007 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/standard       dns.c 
  Log:
  MFH: Sync
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dns.c?r1=1.70.2.7.2.5&r2=1.70.2.7.2.5.2.1&diff_format=u
Index: php-src/ext/standard/dns.c
diff -u php-src/ext/standard/dns.c:1.70.2.7.2.5 
php-src/ext/standard/dns.c:1.70.2.7.2.5.2.1
--- php-src/ext/standard/dns.c:1.70.2.7.2.5     Tue Jun 26 11:04:55 2007
+++ php-src/ext/standard/dns.c  Mon Nov  5 13:42:33 2007
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dns.c,v 1.70.2.7.2.5 2007/06/26 11:04:55 tony2001 Exp $ */
+/* $Id: dns.c,v 1.70.2.7.2.5.2.1 2007/11/05 13:42:33 jani Exp $ */
 
 /* {{{ includes */
 #include "php.h"
@@ -33,7 +33,7 @@
 #define WINNT 1
 #endif
 /* located in www.php.net/extra/bindlib.zip */
-#if HAVE_ARPA_INET_H 
+#if HAVE_ARPA_INET_H
 #include "arpa/inet.h"
 #endif
 #include "netdb.h"
@@ -123,18 +123,17 @@
    Get the Internet host name corresponding to a given IP address */
 PHP_FUNCTION(gethostbyaddr)
 {
-       zval **arg;
-       char *addr;     
-       
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) 
{
-               ZEND_WRONG_PARAM_COUNT();
+       char *addr;
+       int addr_len;
+       char *hostname;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addr, 
&addr_len) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(arg);
-       
-       addr = php_gethostbyaddr(Z_STRVAL_PP(arg));
+       hostname = php_gethostbyaddr(addr);
 
-       if (addr == NULL) {
+       if (hostname == NULL) {
 #if HAVE_IPV6 && HAVE_INET_PTON
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Address is not a 
valid IPv4 or IPv6 address");
 #else
@@ -142,7 +141,7 @@
 #endif
                RETVAL_FALSE;
        } else {
-               RETVAL_STRING(addr, 0);
+               RETVAL_STRING(hostname, 0);
        }
 }
 /* }}} */
@@ -186,15 +185,17 @@
    Get the IP address corresponding to a given Internet host name */
 PHP_FUNCTION(gethostbyname)
 {
-       zval **arg;
-       
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) 
{
-               ZEND_WRONG_PARAM_COUNT();
+       char *hostname;
+       int hostname_len;
+       char *addr;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, 
&hostname_len) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(arg);
+       addr = php_gethostbyname(hostname);
 
-       RETVAL_STRING(php_gethostbyname(Z_STRVAL_PP(arg)), 0);
+       RETVAL_STRING(addr, 0);
 }
 /* }}} */
 
@@ -202,17 +203,17 @@
    Return a list of IP addresses that a given hostname resolves to. */
 PHP_FUNCTION(gethostbynamel)
 {
-       zval **arg;
+       char *hostname;
+       int hostname_len;
        struct hostent *hp;
        struct in_addr in;
        int i;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) 
{
-               ZEND_WRONG_PARAM_COUNT();
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, 
&hostname_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(arg);
 
-       hp = gethostbyname(Z_STRVAL_PP(arg));
+       hp = gethostbyname(hostname);
        if (hp == NULL || hp->h_addr_list == NULL) {
                RETURN_FALSE;
        }
@@ -250,62 +251,43 @@
    Check DNS records corresponding to a given Internet host name or IP address 
*/
 PHP_FUNCTION(dns_check_record)
 {
-       zval **arg1, **arg2;
-       int type, i;
 #ifndef MAXPACKET
 #define MAXPACKET  8192 /* max packet size used internally by BIND */
 #endif
        u_char ans[MAXPACKET];
-       
-       switch (ZEND_NUM_ARGS()) {
-               case 1:
-                       if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
-                               WRONG_PARAM_COUNT;
-                       }
-                       type = T_MX;
-                       convert_to_string_ex(arg1);
-                       
-                       if (Z_STRLEN_PP(arg1) == 0) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Host cannot be empty");
-                               RETURN_FALSE;
-                       }
-                       break;
+       char *hostname, *rectype = NULL;
+       int hostname_len, rectype_len = 0;
+       int type = T_MX, i;
 
-               case 2:
-                       if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) 
{
-                               WRONG_PARAM_COUNT;
-                       }
-                       convert_to_string_ex(arg1);
-                       convert_to_string_ex(arg2);
-
-                       if (Z_STRLEN_PP(arg1) == 0 || Z_STRLEN_PP(arg2) == 0) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Host and type cannot be empty");
-                               RETURN_FALSE;
-                       }
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &hostname, 
&hostname_len, &rectype, &rectype_len) == FAILURE) {
+               return;
+       }
 
-                       if (!strcasecmp("A", Z_STRVAL_PP(arg2))) type = T_A;
-                       else if (!strcasecmp("NS",    Z_STRVAL_PP(arg2))) type 
= DNS_T_NS;
-                       else if (!strcasecmp("MX",    Z_STRVAL_PP(arg2))) type 
= DNS_T_MX;
-                       else if (!strcasecmp("PTR",   Z_STRVAL_PP(arg2))) type 
= DNS_T_PTR;
-                       else if (!strcasecmp("ANY",   Z_STRVAL_PP(arg2))) type 
= DNS_T_ANY;
-                       else if (!strcasecmp("SOA",   Z_STRVAL_PP(arg2))) type 
= DNS_T_SOA;
-                       else if (!strcasecmp("TXT",   Z_STRVAL_PP(arg2))) type 
= DNS_T_TXT;
-                       else if (!strcasecmp("CNAME", Z_STRVAL_PP(arg2))) type 
= DNS_T_CNAME;
-                       else if (!strcasecmp("AAAA",  Z_STRVAL_PP(arg2))) type 
= DNS_T_AAAA;
-                       else if (!strcasecmp("SRV",   Z_STRVAL_PP(arg2))) type 
= DNS_T_SRV;
-                       else if (!strcasecmp("NAPTR", Z_STRVAL_PP(arg2))) type 
= DNS_T_NAPTR;
-                       else if (!strcasecmp("A6", Z_STRVAL_PP(arg2)))    type 
= DNS_T_A6;
-                       else {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Type '%s' not supported", Z_STRVAL_PP(arg2));
-                               RETURN_FALSE;
-                       }
-                       break;
+       if (hostname_len == 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host cannot be 
empty");
+               RETURN_FALSE;
+       }
 
-               default:
-                       WRONG_PARAM_COUNT;
+       if (rectype) {
+                    if (!strcasecmp("A",     rectype)) type = T_A;
+               else if (!strcasecmp("NS",    rectype)) type = DNS_T_NS;
+               else if (!strcasecmp("MX",    rectype)) type = DNS_T_MX;
+               else if (!strcasecmp("PTR",   rectype)) type = DNS_T_PTR;
+               else if (!strcasecmp("ANY",   rectype)) type = DNS_T_ANY;
+               else if (!strcasecmp("SOA",   rectype)) type = DNS_T_SOA;
+               else if (!strcasecmp("TXT",   rectype)) type = DNS_T_TXT;
+               else if (!strcasecmp("CNAME", rectype)) type = DNS_T_CNAME;
+               else if (!strcasecmp("AAAA",  rectype)) type = DNS_T_AAAA;
+               else if (!strcasecmp("SRV",   rectype)) type = DNS_T_SRV;
+               else if (!strcasecmp("NAPTR", rectype)) type = DNS_T_NAPTR;
+               else if (!strcasecmp("A6",    rectype)) type = DNS_T_A6;
+               else {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%s' 
not supported", rectype);
+                       RETURN_FALSE;
+               }
        }
 
-       i = res_search(Z_STRVAL_PP(arg1), C_IN, type, ans, sizeof(ans));
+       i = res_search(hostname, C_IN, type, ans, sizeof(ans));
 
        if (i < 0) {
                RETURN_FALSE;
@@ -329,7 +311,7 @@
 #define PHP_DNS_TXT    0x00008000
 #define PHP_DNS_A6     0x01000000
 #define PHP_DNS_SRV    0x02000000
-#define PHP_DNS_NAPTR  0x04000000    
+#define PHP_DNS_NAPTR  0x04000000
 #define PHP_DNS_AAAA   0x08000000
 #define PHP_DNS_ANY    0x10000000
 #define PHP_DNS_ALL    
(PHP_DNS_A|PHP_DNS_NS|PHP_DNS_CNAME|PHP_DNS_SOA|PHP_DNS_PTR|PHP_DNS_HINFO|PHP_DNS_MX|PHP_DNS_TXT|PHP_DNS_A6|PHP_DNS_SRV|PHP_DNS_NAPTR|PHP_DNS_AAAA)
@@ -372,10 +354,10 @@
        u_char qb2[65536];
 } querybuf;
 
-/* just a hack to free resources allocated by glibc in __res_nsend() 
- * See also: 
- *   res_thread_freeres() in glibc/resolv/res_init.c 
- *   __libc_res_nsend()   in resolv/res_send.c 
+/* just a hack to free resources allocated by glibc in __res_nsend()
+ * See also:
+ *   res_thread_freeres() in glibc/resolv/res_init.c
+ *   __libc_res_nsend()   in resolv/res_send.c
  * */
 
 #ifdef __GLIBC__
@@ -411,7 +393,7 @@
                return NULL;
        }
        cp += n;
-       
+
        GETSHORT(type, cp);
        GETSHORT(class, cp);
        GETLONG(ttl, cp);
@@ -443,16 +425,19 @@
                        add_assoc_long(*subarray, "pri", n);
                        /* no break; */
                case DNS_T_CNAME:
-                       if (type == DNS_T_CNAME)
+                       if (type == DNS_T_CNAME) {
                                add_assoc_string(*subarray, "type", "CNAME", 1);
+                       }
                        /* no break; */
                case DNS_T_NS:
-                       if (type == DNS_T_NS)
+                       if (type == DNS_T_NS) {
                                add_assoc_string(*subarray, "type", "NS", 1);
+                       }
                        /* no break; */
                case DNS_T_PTR:
-                       if (type == DNS_T_PTR)
+                       if (type == DNS_T_PTR) {
                                add_assoc_string(*subarray, "type", "PTR", 1);
+                       }
                        n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, 
(sizeof name) - 2);
                        if (n < 0) {
                                return NULL;
@@ -465,11 +450,11 @@
                        add_assoc_string(*subarray, "type", "HINFO", 1);
                        n = *cp & 0xFF;
                        cp++;
-                       add_assoc_stringl(*subarray, "cpu", cp, n, 1);
+                       add_assoc_stringl(*subarray, "cpu", (char*)cp, n, 1);
                        cp += n;
                        n = *cp & 0xFF;
                        cp++;
-                       add_assoc_stringl(*subarray, "os", cp, n, 1);
+                       add_assoc_stringl(*subarray, "os", (char*)cp, n, 1);
                        cp += n;
                        break;
                case DNS_T_TXT:
@@ -479,7 +464,7 @@
                        memcpy(tp, cp + 1, n);
                        tp[n] = '\0';
                        cp += dlen;
-                       add_assoc_stringl(*subarray, "txt", tp, n, 0);
+                       add_assoc_stringl(*subarray, "txt", (char*)tp, n, 0);
                        break;
                case DNS_T_SOA:
                        add_assoc_string(*subarray, "type", "SOA", 1);
@@ -507,7 +492,7 @@
                        add_assoc_long(*subarray, "minimum-ttl", n);
                        break;
                case DNS_T_AAAA:
-                       tp = name;
+                       tp = (u_char*)name;
                        for(i=0; i < 8; i++) {
                                GETSHORT(s, cp);
                                if (s != 0) {
@@ -516,7 +501,7 @@
                                                tp[0] = ':';
                                                tp++;
                                        }
-                                       tp += sprintf(tp,"%x",s);
+                                       tp += sprintf((char*)tp,"%x",s);
                                } else {
                                        if (!have_v6_break) {
                                                have_v6_break = 1;
@@ -538,14 +523,14 @@
                        tp[0] = '\0';
                        add_assoc_string(*subarray, "type", "AAAA", 1);
                        add_assoc_string(*subarray, "ipv6", name, 1);
-                       break; 
+                       break;
                case DNS_T_A6:
                        p = cp;
                        add_assoc_string(*subarray, "type", "A6", 1);
                        n = ((int)cp[0]) & 0xFF;
                        cp++;
                        add_assoc_long(*subarray, "masklen", n);
-                       tp = name;
+                       tp = (u_char*)name;
                        if (n > 15) {
                                have_v6_break = 1;
                                in_v6_break = 1;
@@ -560,7 +545,7 @@
                                                tp[0] = ':';
                                                tp++;
                                        }
-                                       sprintf(tp, "%x", cp[0] & 0xFF);
+                                       sprintf((char*)tp, "%x", cp[0] & 0xFF);
                                } else {
                                        if (!have_v6_break) {
                                                have_v6_break = 1;
@@ -576,7 +561,7 @@
                                }
                                cp++;
                        }
-                       for(i = (n+8)/16; i < 8; i++) {
+                       for (i = (n + 8) / 16; i < 8; i++) {
                                GETSHORT(s, cp);
                                if (s != 0) {
                                        if (tp > (u_char *)name) {
@@ -584,7 +569,7 @@
                                                tp[0] = ':';
                                                tp++;
                                        }
-                                       tp += sprintf(tp,"%x",s);
+                                       tp += sprintf((char*)tp,"%x",s);
                                } else {
                                        if (!have_v6_break) {
                                                have_v6_break = 1;
@@ -636,13 +621,13 @@
                        GETSHORT(n, cp);
                        add_assoc_long(*subarray, "pref", n);
                        n = (cp[0] & 0xFF);
-                       add_assoc_stringl(*subarray, "flags", ++cp, n, 1);
+                       add_assoc_stringl(*subarray, "flags", (char*)++cp, n, 
1);
                        cp += n;
                        n = (cp[0] & 0xFF);
-                       add_assoc_stringl(*subarray, "services", ++cp, n, 1);
+                       add_assoc_stringl(*subarray, "services", (char*)++cp, 
n, 1);
                        cp += n;
                        n = (cp[0] & 0xFF);
-                       add_assoc_stringl(*subarray, "regex", ++cp, n, 1);
+                       add_assoc_stringl(*subarray, "regex", (char*)++cp, n, 
1);
                        cp += n;
                        n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, 
(sizeof name) - 2);
                        if (n < 0) {
@@ -666,9 +651,12 @@
    Get any Resource Record corresponding to a given Internet host name */
 PHP_FUNCTION(dns_get_record)
 {
-       zval *addtl, *host, *authns, *fetch_type;
+       char *hostname;
+       int hostname_len;
+       long type_param = PHP_DNS_ANY;
+       zval *authns, *addtl;
        int addtl_recs = 0;
-       int type_to_fetch, type_param = PHP_DNS_ANY;
+       int type_to_fetch;
        struct __res_state res;
        HEADER *hp;
        querybuf buf, answer;
@@ -676,39 +664,21 @@
        int n, qd, an, ns = 0, ar = 0;
        int type, first_query = 1, store_results = 1;
 
-       switch (ZEND_NUM_ARGS()) {
-               case 1:
-                       if (zend_get_parameters(ht, 1, &host) == FAILURE) {
-                               WRONG_PARAM_COUNT;
-                       }
-                       break;
-               case 2:
-                       if (zend_get_parameters(ht, 2, &host, &fetch_type) == 
FAILURE) {
-                               WRONG_PARAM_COUNT;
-                       }
-                       convert_to_long(fetch_type);
-                       type_param = Z_LVAL_P(fetch_type);
-                       break;
-               case 4:
-                       if (zend_get_parameters(ht, 4, &host, &fetch_type, 
&authns, &addtl) == FAILURE) {
-                               WRONG_PARAM_COUNT;
-                       }
-                       convert_to_long(fetch_type);
-                       type_param = Z_LVAL_P(fetch_type);
-                       zval_dtor(authns);
-                       addtl_recs = 1;         /* We want the additional 
Records */
-                       array_init(authns);
-                       zval_dtor(addtl);
-                       array_init(addtl);
-                       break;
-               default:
-                       WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz!z!", 
&hostname, &hostname_len, &type_param, &authns, &addtl) == FAILURE) {
+               return;
        }
-       
-       convert_to_string(host);
 
-       if (type_param&~PHP_DNS_ALL && type_param!=PHP_DNS_ANY) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%d' not 
supported", type_param);
+       if (authns) {
+               zval_dtor(authns);
+               array_init(authns);
+       }
+       if (addtl) {
+               zval_dtor(addtl);
+               array_init(addtl);
+       }
+
+       if (type_param & ~PHP_DNS_ALL && type_param != PHP_DNS_ANY) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%ld' not 
supported", type_param);
                RETURN_FALSE;
        }
 
@@ -721,32 +691,34 @@
         *   NUMTYPES+1 when results were already fetched.
         * - In case of PHP_DNS_ANY we use the directly fetch DNS_T_ANY. (step 
NUMTYPES+1 )
         */
-       for(type = (type_param==PHP_DNS_ANY ? (PHP_DNS_NUM_TYPES + 1) : 0); 
type < (addtl_recs ? (PHP_DNS_NUM_TYPES + 2) : PHP_DNS_NUM_TYPES) || 
first_query; type++)
-       {
+       for (type = (type_param == PHP_DNS_ANY ? (PHP_DNS_NUM_TYPES + 1) : 0);
+               type < (addtl_recs ? (PHP_DNS_NUM_TYPES + 2) : 
PHP_DNS_NUM_TYPES) || first_query;
+               type++
+       ) {
                first_query = 0;
                switch (type) {
-                       case 0: 
+                       case 0:
                                type_to_fetch = type_param&PHP_DNS_A     ? 
DNS_T_A     : 0;
                                break;
-                       case 1: 
+                       case 1:
                                type_to_fetch = type_param&PHP_DNS_NS    ? 
DNS_T_NS    : 0;
                                break;
-                       case 2: 
+                       case 2:
                                type_to_fetch = type_param&PHP_DNS_CNAME ? 
DNS_T_CNAME : 0;
                                break;
-                       case 3: 
+                       case 3:
                                type_to_fetch = type_param&PHP_DNS_SOA   ? 
DNS_T_SOA   : 0;
                                break;
-                       case 4: 
+                       case 4:
                                type_to_fetch = type_param&PHP_DNS_PTR   ? 
DNS_T_PTR   : 0;
                                break;
-                       case 5: 
+                       case 5:
                                type_to_fetch = type_param&PHP_DNS_HINFO ? 
DNS_T_HINFO : 0;
                                break;
-                       case 6: 
+                       case 6:
                                type_to_fetch = type_param&PHP_DNS_MX    ? 
DNS_T_MX    : 0;
                                break;
-                       case 7: 
+                       case 7:
                                type_to_fetch = type_param&PHP_DNS_TXT   ? 
DNS_T_TXT   : 0;
                                break;
                        case 8:
@@ -774,8 +746,8 @@
                        res_ninit(&res);
                        res.retrans = 5;
                        res.options &= ~RES_DEFNAMES;
-               
-                       n = res_nmkquery(&res, QUERY, Z_STRVAL_P(host), C_IN, 
type_to_fetch, NULL, 0, NULL, buf.qb2, sizeof buf);
+
+                       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");
                                zval_dtor(return_value);
@@ -791,7 +763,7 @@
                                php_dns_free_res(res);
                                RETURN_FALSE;
                        }
-               
+
                        cp = answer.qb2 + HFIXEDSZ;
                        end = answer.qb2 + n;
                        hp = (HEADER *)&answer;
@@ -799,7 +771,7 @@
                        an = ntohs(hp->ancount);
                        ns = ntohs(hp->nscount);
                        ar = ntohs(hp->arcount);
-       
+
                        /* Skip QD entries, they're only used by dn_expand 
later on */
                        while (qd-- > 0) {
                                n = dn_skipname(cp, end);
@@ -812,7 +784,7 @@
                                }
                                cp += n + QFIXEDSZ;
                        }
-               
+
                        /* YAY! Our real answers! */
                        while (an-- && cp && cp < end) {
                                zval *retval;
@@ -827,19 +799,24 @@
                }
        }
 
-       if (addtl_recs) {
-               /* List of Authoritative Name Servers */
+       if (authns || addtl) {
+               /* List of Authoritative Name Servers
+                * Process when only requesting addtl so that we can skip 
through the section
+                */
                while (ns-- > 0 && cp && cp < end) {
-                       zval *retval;
+                       zval *retval = NULL;
 
-                       cp = php_parserr(cp, &answer, DNS_T_ANY, 1, &retval);
+                       cp = php_parserr(cp, &answer, DNS_T_ANY, authns != 
NULL, &retval);
                        if (retval != NULL) {
                                add_next_index_zval(authns, retval);
                        }
                }
+       }
+
+       if (addtl) {
                /* Additional records associated with authoritative name 
servers */
                while (ar-- > 0 && cp && cp < end) {
-                       zval *retval;
+                       zval *retval = NULL;
 
                        cp = php_parserr(cp, &answer, DNS_T_ANY, 1, &retval);
                        if (retval != NULL) {
@@ -856,7 +833,9 @@
    Get MX records corresponding to a given Internet host name */
 PHP_FUNCTION(dns_get_mx)
 {
-       zval *host, *mx_list, *weight_list;
+       char *hostname;
+       int hostname_len;
+       zval *mx_list, *weight_list = NULL;
        int need_weight = 0;
        int count, qdc;
        u_short type, weight;
@@ -866,32 +845,19 @@
        u_char *cp, *end;
        int i;
 
-       switch (ZEND_NUM_ARGS()) {
-               case 2:
-                       if (zend_get_parameters(ht, 2, &host, &mx_list) == 
FAILURE) {
-                               WRONG_PARAM_COUNT;
-                       }
-                       break;
-
-               case 3:
-                       if (zend_get_parameters(ht, 3, &host, &mx_list, 
&weight_list) == FAILURE) {
-                               WRONG_PARAM_COUNT;
-                       }
-                       need_weight = 1;
-                       zval_dtor(weight_list); /* start with clean array */
-                       array_init(weight_list);
-                       break;
-
-               default:
-                       WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|z", &hostname, 
&hostname_len, &mx_list, &weight_list) == FAILURE) {
+               return;
        }
 
-       convert_to_string(host);
-       zval_dtor(mx_list); /* start with clean array */
+       zval_dtor(mx_list);
        array_init(mx_list);
 
-       /* Go! */
-       i = res_search(Z_STRVAL_P(host), C_IN, DNS_T_MX, (u_char *)&ans, 
sizeof(ans));
+       if (weight_list) {
+               zval_dtor(weight_list);
+               array_init(weight_list);
+       }
+
+       i = res_search(hostname, C_IN, DNS_T_MX, (u_char *)&ans, sizeof(ans));
        if (i < 0) {
                RETURN_FALSE;
        }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to