Diff for /embedaddon/php/main/SAPI.c between versions 1.1.1.2 and 1.1.1.4

version 1.1.1.2, 2012/05/29 12:34:35 version 1.1.1.4, 2014/06/15 20:04:01
Line 2 Line 2
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | PHP Version 5                                                        |     | PHP Version 5                                                        |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
   | Copyright (c) 1997-2012 The PHP Group                                |   | Copyright (c) 1997-2014 The PHP Group                                |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |     | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |     | that is bundled with this package in the file LICENSE, and is        |
Line 137  PHP_FUNCTION(header_register_callback) Line 137  PHP_FUNCTION(header_register_callback)
                 efree(callback_name);                  efree(callback_name);
                 RETURN_FALSE;                  RETURN_FALSE;
         }          }
   
         efree(callback_name);          efree(callback_name);
   
         if (SG(callback_func)) {          if (SG(callback_func)) {
Line 144  PHP_FUNCTION(header_register_callback) Line 145  PHP_FUNCTION(header_register_callback)
                 SG(fci_cache) = empty_fcall_info_cache;                  SG(fci_cache) = empty_fcall_info_cache;
         }          }
   
         Z_ADDREF_P(callback_func);  
   
         SG(callback_func) = callback_func;          SG(callback_func) = callback_func;
        
         Z_ADDREF_P(SG(callback_func));
 
         RETURN_TRUE;          RETURN_TRUE;
 }  }
 /* }}} */  /* }}} */
Line 156  static void sapi_run_header_callback(TSRMLS_D) Line 157  static void sapi_run_header_callback(TSRMLS_D)
 {  {
         int   error;          int   error;
         zend_fcall_info fci;          zend_fcall_info fci;
           char *callback_name = NULL;
           char *callback_error = NULL;
         zval *retval_ptr = NULL;          zval *retval_ptr = NULL;
        
        fci.size = sizeof(fci);        if (zend_fcall_info_init(SG(callback_func), 0, &fci, &SG(fci_cache), &callback_name, &callback_error TSRMLS_CC) == SUCCESS) {
        fci.function_table = EG(function_table);                fci.retval_ptr_ptr = &retval_ptr;
        fci.object_ptr = NULL;                
        fci.function_name = SG(callback_func);                error = zend_call_function(&fci, &SG(fci_cache) TSRMLS_CC);
        fci.retval_ptr_ptr = &retval_ptr;                if (error == FAILURE) {
        fci.param_count = 0;                        goto callback_failed;
        fci.params = NULL;                } else if (retval_ptr) {
        fci.no_separation = 0;                        zval_ptr_dtor(&retval_ptr);
        fci.symbol_table = NULL;                }
        } else {
        error = zend_call_function(&fci, &SG(fci_cache) TSRMLS_CC);callback_failed:
        if (error == FAILURE) { 
                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not call the sapi_header_callback");                  php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not call the sapi_header_callback");
         } else if (retval_ptr) {  
                 zval_ptr_dtor(&retval_ptr);  
         }          }
           
           if (callback_name) {
                   efree(callback_name);
           }
           if (callback_error) {
                   efree(callback_error);
           }       
 }  }
   
 SAPI_API void sapi_handle_post(void *arg TSRMLS_DC)  SAPI_API void sapi_handle_post(void *arg TSRMLS_DC)
Line 587  static void sapi_update_response_code(int ncode TSRMLS Line 594  static void sapi_update_response_code(int ncode TSRMLS
         SG(sapi_headers).http_response_code = ncode;          SG(sapi_headers).http_response_code = ncode;
 }  }
   
static int sapi_find_matching_header(void *element1, void *element2)/* 
{ * since zend_llist_del_element only remove one matched item once,
        int len = strlen((char*)element2); * we should remove them by ourself
        return strncasecmp(((sapi_header_struct*)element1)->header, (char*)element2, len) == 0 && ((sapi_header_struct*)element1)->header[len] == ':'; */
 static void sapi_remove_header(zend_llist *l, char *name, uint len) {
         sapi_header_struct *header;
         zend_llist_element *next;
         zend_llist_element *current=l->head;
 
         while (current) {
                 header = (sapi_header_struct *)(current->data);
                 next = current->next;
                 if (header->header_len > len && header->header[len] == ':'
                                 && !strncasecmp(header->header, name, len)) {
                         if (current->prev) {
                                 current->prev->next = next;
                         } else {
                                 l->head = next;
                         }
                         if (next) {
                                 next->prev = current->prev;
                         } else {
                                 l->tail = current->prev;
                         }
                         sapi_free_header(header);
                         efree(current);
                         --l->count;
                 }
                 current = next;
         }
 }  }
   
 SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC)  SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC)
Line 621  static void sapi_header_add_op(sapi_header_op_enum op, Line 654  static void sapi_header_add_op(sapi_header_op_enum op,
                                 char sav = *colon_offset;                                  char sav = *colon_offset;
   
                                 *colon_offset = 0;                                  *colon_offset = 0;
                                zend_llist_del_element(&SG(sapi_headers).headers, sapi_header->header, (int(*)(void*, void*))sapi_find_matching_header);                        sapi_remove_header(&SG(sapi_headers).headers, sapi_header->header, strlen(sapi_header->header));
                                 *colon_offset = sav;                                  *colon_offset = sav;
                         }                          }
                 }                  }
Line 684  SAPI_API int sapi_header_op(sapi_header_op_enum op, vo Line 717  SAPI_API int sapi_header_op(sapi_header_op_enum op, vo
   
         header_line = estrndup(header_line, header_line_len);          header_line = estrndup(header_line, header_line_len);
   
        /* cut of trailing spaces, linefeeds and carriage-returns */        /* cut off trailing spaces, linefeeds and carriage-returns */
         if (header_line_len && isspace(header_line[header_line_len-1])) {          if (header_line_len && isspace(header_line[header_line_len-1])) {
                 do {                  do {
                         header_line_len--;                          header_line_len--;
Line 703  SAPI_API int sapi_header_op(sapi_header_op_enum op, vo Line 736  SAPI_API int sapi_header_op(sapi_header_op_enum op, vo
                         sapi_header.header_len = header_line_len;                          sapi_header.header_len = header_line_len;
                         sapi_module.header_handler(&sapi_header, op, &SG(sapi_headers) TSRMLS_CC);                          sapi_module.header_handler(&sapi_header, op, &SG(sapi_headers) TSRMLS_CC);
                 }                  }
                zend_llist_del_element(&SG(sapi_headers).headers, header_line, (int(*)(void*, void*))sapi_find_matching_header);                sapi_remove_header(&SG(sapi_headers).headers, header_line, header_line_len);
                 efree(header_line);                  efree(header_line);
                 return SUCCESS;                  return SUCCESS;
         } else {          } else {
Line 990  SAPI_API char *sapi_getenv(char *name, size_t name_len Line 1023  SAPI_API char *sapi_getenv(char *name, size_t name_len
                 } else {                  } else {
                         return NULL;                          return NULL;
                 }                  }
                sapi_module.input_filter(PARSE_ENV, name, &value, strlen(value), NULL TSRMLS_CC);                if (sapi_module.input_filter) {
                         sapi_module.input_filter(PARSE_STRING, name, &value, strlen(value), NULL TSRMLS_CC);
                 }
                 return value;                  return value;
         }          }
         return NULL;          return NULL;

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


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