Diff for /embedaddon/php/ext/standard/dns.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:48:02 version 1.1.1.2, 2012/05/29 12:34:43
Line 413  PHP_FUNCTION(dns_check_record) Line 413  PHP_FUNCTION(dns_check_record)
 #if HAVE_FULL_DNS_FUNCS  #if HAVE_FULL_DNS_FUNCS
   
 /* {{{ php_parserr */  /* {{{ php_parserr */
static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, zval **subarray)static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, int raw, zval **subarray)
 {  {
         u_short type, class, dlen;          u_short type, class, dlen;
         u_long ttl;          u_long ttl;
Line 449  static u_char *php_parserr(u_char *cp, querybuf *answe Line 449  static u_char *php_parserr(u_char *cp, querybuf *answe
         array_init(*subarray);          array_init(*subarray);
   
         add_assoc_string(*subarray, "host", name, 1);          add_assoc_string(*subarray, "host", name, 1);
           add_assoc_string(*subarray, "class", "IN", 1);
           add_assoc_long(*subarray, "ttl", ttl);
   
           if (raw) {
                   add_assoc_long(*subarray, "type", type);
                   add_assoc_stringl(*subarray, "data", (char*) cp, (uint) dlen, 1);
                   cp += dlen;
                   return cp;
           }
   
         switch (type) {          switch (type) {
                 case DNS_T_A:                  case DNS_T_A:
                         add_assoc_string(*subarray, "type", "A", 1);                          add_assoc_string(*subarray, "type", "A", 1);
Line 689  static u_char *php_parserr(u_char *cp, querybuf *answe Line 699  static u_char *php_parserr(u_char *cp, querybuf *answe
                         add_assoc_string(*subarray, "replacement", name, 1);                          add_assoc_string(*subarray, "replacement", name, 1);
                         break;                          break;
                 default:                  default:
                           zval_ptr_dtor(subarray);
                           *subarray = NULL;
                         cp += dlen;                          cp += dlen;
                           break;
         }          }
   
         add_assoc_string(*subarray, "class", "IN", 1);  
         add_assoc_long(*subarray, "ttl", ttl);  
   
         return cp;          return cp;
 }  }
 /* }}} */  /* }}} */
Line 721  PHP_FUNCTION(dns_get_record) Line 731  PHP_FUNCTION(dns_get_record)
         u_char *cp = NULL, *end = NULL;          u_char *cp = NULL, *end = NULL;
         int n, qd, an, ns = 0, ar = 0;          int n, qd, an, ns = 0, ar = 0;
         int type, first_query = 1, store_results = 1;          int type, first_query = 1, store_results = 1;
           zend_bool raw = 0;
   
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lzz", &hostname, &hostname_len, &type_param, &authns, &addtl) == FAILURE) {        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz!z!b",
                         &hostname, &hostname_len, &type_param, &authns, &addtl, &raw) == FAILURE) {
                 return;                  return;
         }          }
   
Line 735  PHP_FUNCTION(dns_get_record) Line 747  PHP_FUNCTION(dns_get_record)
                 array_init(addtl);                  array_init(addtl);
         }          }
   
        if (type_param & ~PHP_DNS_ALL && type_param != PHP_DNS_ANY) {        if (!raw) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%ld' not supported", type_param);                if ((type_param & ~PHP_DNS_ALL) && (type_param != PHP_DNS_ANY)) {
                RETURN_FALSE;                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%ld' not supported", type_param);
                         RETURN_FALSE;
                 }
         } else {
                 if ((type_param < 1) || (type_param > 0xFFFF)) {
                         php_error_docref(NULL TSRMLS_CC, E_WARNING,
                                 "Numeric DNS record type must be between 1 and 65535, '%ld' given", type_param);
                         RETURN_FALSE;
                 }
         }          }
   
         /* Initialize the return array */          /* Initialize the return array */
Line 748  PHP_FUNCTION(dns_get_record) Line 768  PHP_FUNCTION(dns_get_record)
          *   store_results is used to skip storing the results retrieved in step           *   store_results is used to skip storing the results retrieved in step
          *   NUMTYPES+1 when results were already fetched.           *   NUMTYPES+1 when results were already fetched.
          * - In case of PHP_DNS_ANY we use the directly fetch DNS_T_ANY. (step NUMTYPES+1 )           * - In case of PHP_DNS_ANY we use the directly fetch DNS_T_ANY. (step NUMTYPES+1 )
            * - In case of raw mode, we query only the requestd type instead of looping type by type
            *   before going with the additional info stuff.
          */           */
        for (type = (type_param == PHP_DNS_ANY ? (PHP_DNS_NUM_TYPES + 1) : 0);
         if (raw) {
                 type = -1;
         } else if (type_param == PHP_DNS_ANY) {
                 type = PHP_DNS_NUM_TYPES + 1;
         } else {
                 type = 0;
         }
 
         for ( ;
                 type < (addtl ? (PHP_DNS_NUM_TYPES + 2) : PHP_DNS_NUM_TYPES) || first_query;                  type < (addtl ? (PHP_DNS_NUM_TYPES + 2) : PHP_DNS_NUM_TYPES) || first_query;
                 type++                  type++
         ) {          ) {
                 first_query = 0;                  first_query = 0;
                 switch (type) {                  switch (type) {
                           case -1: /* raw */
                                   type_to_fetch = type_param;
                                   /* skip over the rest and go directly to additional records */
                                   type = PHP_DNS_NUM_TYPES - 1;
                                   break;
                         case 0:                          case 0:
                                 type_to_fetch = type_param&PHP_DNS_A     ? DNS_T_A     : 0;                                  type_to_fetch = type_param&PHP_DNS_A     ? DNS_T_A     : 0;
                                 break;                                  break;
Line 848  PHP_FUNCTION(dns_get_record) Line 884  PHP_FUNCTION(dns_get_record)
                         while (an-- && cp && cp < end) {                          while (an-- && cp && cp < end) {
                                 zval *retval;                                  zval *retval;
   
                                cp = php_parserr(cp, &answer, type_to_fetch, store_results, &retval);                                cp = php_parserr(cp, &answer, type_to_fetch, store_results, raw, &retval);
                                 if (retval != NULL && store_results) {                                  if (retval != NULL && store_results) {
                                         add_next_index_zval(return_value, retval);                                          add_next_index_zval(return_value, retval);
                                 }                                  }
Line 861  PHP_FUNCTION(dns_get_record) Line 897  PHP_FUNCTION(dns_get_record)
                                 while (ns-- > 0 && cp && cp < end) {                                  while (ns-- > 0 && cp && cp < end) {
                                         zval *retval = NULL;                                          zval *retval = NULL;
   
                                        cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, &retval);                                        cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, raw, &retval);
                                         if (retval != NULL) {                                          if (retval != NULL) {
                                                 add_next_index_zval(authns, retval);                                                  add_next_index_zval(authns, retval);
                                         }                                          }
Line 873  PHP_FUNCTION(dns_get_record) Line 909  PHP_FUNCTION(dns_get_record)
                                 while (ar-- > 0 && cp && cp < end) {                                  while (ar-- > 0 && cp && cp < end) {
                                         zval *retval = NULL;                                          zval *retval = NULL;
   
                                        cp = php_parserr(cp, &answer, DNS_T_ANY, 1, &retval);                                        cp = php_parserr(cp, &answer, DNS_T_ANY, 1, raw, &retval);
                                         if (retval != NULL) {                                          if (retval != NULL) {
                                                 add_next_index_zval(addtl, retval);                                                  add_next_index_zval(addtl, retval);
                                         }                                          }

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>