cvs: php4(PHP_4) /main SAPI.c SAPI.h

From: Date: Sat, 19 Apr 2003 17:47:30 +0000
Subject: cvs: php4(PHP_4) /main SAPI.c SAPI.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-20395@lists.php.net to get a copy of this message
sas Sat Apr 19 13:47:30 2003 EDT Modified files: (Branch: PHP_4) /php4/main SAPI.c SAPI.h Log: Merge changes from PHP_4_3 Index: php4/main/SAPI.c diff -u php4/main/SAPI.c:1.155.2.4.2.3 php4/main/SAPI.c:1.155.2.4.2.4 --- php4/main/SAPI.c:1.155.2.4.2.3 Sun Feb 9 16:30:15 2003 +++ php4/main/SAPI.c Sat Apr 19 13:47:30 2003 @@ -18,21 +18,21 @@ +----------------------------------------------------------------------+ */ -/* $Id: SAPI.c,v 1.155.2.4.2.3 2003/02/09 21:30:15 sas Exp $ */ +/* $Id: SAPI.c,v 1.155.2.4.2.4 2003/04/19 17:47:30 sas Exp $ */ #include <ctype.h> #include <sys/stat.h> #include "php.h" #include "SAPI.h" +#include "php_ini.h" #include "ext/standard/php_string.h" #include "ext/standard/pageinfo.h" #if (HAVE_PCRE || HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE) #include "ext/pcre/php_pcre.h" #endif -#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB) +#if HAVE_ZLIB #include "ext/zlib/php_zlib.h" -ZEND_EXTERN_MODULE_GLOBALS(zlib) #endif #ifdef ZTS #include "TSRM.h" @@ -556,9 +556,9 @@ while (*ptr == ' ' && *ptr != '\0') { ptr++; } -#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB) +#if HAVE_ZLIB if(!strncmp(ptr, "image/", sizeof("image/")-1)) { - ZLIBG(output_compression) = 0; + zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); } #endif mimetype = estrdup(ptr); @@ -626,7 +626,7 @@ /* If there is no realm string at all, append one */ if(!strstr(lower_temp,"realm")) { efree(result); - conv_len = sprintf(conv_temp," realm=\"%ld\"",myuid); + conv_len = sprintf(conv_temp, " realm=\"%ld\"",myuid); result = emalloc(ptr_len+conv_len+1); result_len = ptr_len+conv_len; memcpy(result, ptr, ptr_len); @@ -649,7 +649,7 @@ #else { myuid = php_getuid(); - result = emalloc(32); + result = emalloc(sizeof("WWW-Authenticate: ")+20); newlen = sprintf(result, "WWW-Authenticate: %ld", myuid); newheader = estrndup(result,newlen); efree(header_line); @@ -704,27 +704,32 @@ return SUCCESS; } -#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB) +#if HAVE_ZLIB /* Add output compression headers at this late stage in order to make it possible to switch it off inside the script. */ - if (ZLIBG(output_compression)) { - switch (ZLIBG(ob_gzip_coding)) { - case CODING_GZIP: - if (sapi_add_header("Content-Encoding: gzip", sizeof("Content-Encoding: gzip") - 1, 1)==FAILURE) { - return FAILURE; - } - if (sapi_add_header("Vary: Accept-Encoding", sizeof("Vary: Accept-Encoding") - 1, 1)==FAILURE) { - return FAILURE; - } - break; - case CODING_DEFLATE: - if (sapi_add_header("Content-Encoding: deflate", sizeof("Content-Encoding: deflate") - 1, 1)==FAILURE) { - return FAILURE; - } - if (sapi_add_header("Vary: Accept-Encoding", sizeof("Vary: Accept-Encoding") - 1, 1)==FAILURE) { - return FAILURE; - } - break; + + if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) { + zval nm_zlib_get_coding_type; + zval *uf_result = NULL; + + ZVAL_STRINGL(&nm_zlib_get_coding_type, "zlib_get_coding_type", sizeof("zlib_get_coding_type") - 1, 0); + + if (call_user_function_ex(CG(function_table), NULL, &nm_zlib_get_coding_type, &uf_result, 0, NULL, 1, NULL TSRMLS_CC) != FAILURE && uf_result != NULL && Z_TYPE_P(uf_result) == IS_STRING) { + char buf[128]; + int len; + + assert(Z_STRVAL_P(uf_result) != NULL); + + len = snprintf(buf, sizeof(buf), "Content-Encoding: %s", Z_STRVAL_P(uf_result)); + if (len <= 0 || sapi_add_header(buf, len, 1) == FAILURE) { + return FAILURE; + } + if (sapi_add_header("Vary: Accept-Encoding", sizeof("Vary: Accept-Encoding") - 1, 1) == FAILURE) { + return FAILURE; + } + } + if (uf_result != NULL) { + zval_ptr_dtor(&uf_result); } } #endif Index: php4/main/SAPI.h diff -u php4/main/SAPI.h:1.87.2.4.2.2 php4/main/SAPI.h:1.87.2.4.2.3 --- php4/main/SAPI.h:1.87.2.4.2.2 Tue Jan 21 06:12:06 2003 +++ php4/main/SAPI.h Sat Apr 19 13:47:30 2003 @@ -237,6 +237,9 @@ int (*get_target_uid)(uid_t * TSRMLS_DC); int (*get_target_gid)(gid_t * TSRMLS_DC); + + void (*ini_defaults)(HashTable *configuration_hash); + int phpinfo_as_text; };

« previous php.cvs (#20395) next »