pollita         Fri Mar 19 17:23:09 2004 EDT

  Modified files:              
    /php-src/ext/standard       dns.c 
  Log:
  Cleanup, minor refactor, and CS
  
http://cvs.php.net/diff.php/php-src/ext/standard/dns.c?r1=1.67&r2=1.68&ty=u
Index: php-src/ext/standard/dns.c
diff -u php-src/ext/standard/dns.c:1.67 php-src/ext/standard/dns.c:1.68
--- php-src/ext/standard/dns.c:1.67     Fri Mar 19 16:42:29 2004
+++ php-src/ext/standard/dns.c  Fri Mar 19 17:21:53 2004
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dns.c,v 1.67 2004/03/19 21:42:29 pollita Exp $ */
+/* $Id: dns.c,v 1.68 2004/03/19 22:21:53 pollita Exp $ */
 
 /* {{{ includes */
 #include "php.h"
@@ -352,7 +352,7 @@
                return cp;
        }
 
-       MAKE_STD_ZVAL(*subarray);
+       ALLOC_INIT_ZVAL(*subarray);
        array_init(*subarray);
 
        add_assoc_string(*subarray, "host", name, 1);
@@ -402,10 +402,8 @@
                        add_assoc_string(*subarray, "type", "TXT", 1);
                        n = cp[0];
                        tp = emalloc(n + 1);
-                       for(i=1; i<=n; i++) {
-                               tp[i-1] = cp[i];
-                       }
-                       tp[i-1] = '\0';
+                       memcpy(tp, cp + 1, n);
+                       tp[n] = '\0';
                        cp += dlen;
                        add_assoc_stringl(*subarray, "txt", tp, n, 0);
                        break;
@@ -517,11 +515,9 @@
    Get any Resource Record corresponding to a given Internet host name */
 PHP_FUNCTION(dns_get_record)
 {
-       zval *subarray[MAXRESOURCERECORDS];
        pval *addtl, *host, *authns, *fetch_type;
        int addtl_recs = 0;
        int type_to_fetch, type_param = PHP_DNS_ANY;
-       int current_subarray = 0;
        struct __res_state res;
        HEADER *hp;
        querybuf buf, answer, *ans;
@@ -670,10 +666,12 @@
                
                        /* YAY! Our real answers! */
                        while (an-- && cp && cp < end) {
-                               cp = php_parserr(cp, &answer, type_to_fetch, 
store_results, &subarray[current_subarray]);
-                               if (subarray[current_subarray] != NULL && 
store_results)
-                                       
zend_hash_next_index_insert(HASH_OF(return_value), (void 
*)&subarray[current_subarray], sizeof(zval *), NULL);
-                               current_subarray++;
+                               zval *retval;
+
+                               cp = php_parserr(cp, &answer, type_to_fetch, 
store_results, &retval);
+                               if (retval != NULL && store_results) {
+                                       add_next_index_zval(return_value, retval);
+                               }
                        }
                        res_nclose(&res);
                }
@@ -682,17 +680,21 @@
        if (addtl_recs) {
                /* List of Authoritative Name Servers */
                while (ns-- > 0 && cp && cp < end) {
-                       cp = php_parserr(cp, &answer, T_ANY, 1, 
&subarray[current_subarray]);
-                       if (subarray[current_subarray] != NULL)
-                               zend_hash_next_index_insert(HASH_OF(authns), (void 
*)&subarray[current_subarray], sizeof(zval *), NULL);
-                       current_subarray++;
+                       zval *retval;
+
+                       cp = php_parserr(cp, &answer, T_ANY, 1, &retval);
+                       if (retval != NULL) {
+                               add_next_index_zval(authns, retval);
+                       }
                }
                /* Additional records associated with authoritative name servers */
                while (ar-- > 0 && cp && cp < end) {
-                       cp = php_parserr(cp, &answer, T_ANY, 1, 
&subarray[current_subarray]);
-                       if (subarray[current_subarray] != NULL)
-                               zend_hash_next_index_insert(HASH_OF(addtl), (void 
*)&subarray[current_subarray], sizeof(zval *), NULL);
-                       current_subarray++;
+                       zval *retval;
+
+                       cp = php_parserr(cp, &answer, T_ANY, 1, &retval);
+                       if (retval != NULL) {
+                               add_next_index_zval(addtl, retval);
+                       }
                }
        }
 }

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

Reply via email to