From: Sascha Schumann Date: Sun, 5 Aug 2001 15:29:47 +0000 (+0000) Subject: more tsrm cleanup X-Git-Tag: PRE_ENGINE2_SPLIT~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8aef1930565d36807647e52b5e5b7c4e3f4a57b1;p=php more tsrm cleanup --- diff --git a/ext/sablot/sablot.c b/ext/sablot/sablot.c index f3b3f8520d..6547f9050e 100644 --- a/ext/sablot/sablot.c +++ b/ext/sablot/sablot.c @@ -282,7 +282,7 @@ PHP_FUNCTION(xslt_output_begintransform) * Start output buffering, NULL signifies that no "user-space" output function * will be used. The 0 disables chunking */ - php_start_ob_buffer(NULL, 0); + php_start_ob_buffer(NULL, 0 TSRMLS_CC); } /* }}} */ @@ -345,7 +345,7 @@ PHP_FUNCTION(xslt_output_endtransform) * current output buffer (so we don't send data twice) */ if (tRes) - php_end_ob_buffer(0, 0); + php_end_ob_buffer(0, 0 TSRMLS_CC); PUTS(tRes); @@ -360,7 +360,7 @@ PHP_FUNCTION(xslt_output_endtransform) if (tRes) SablotFree(tRes); else - php_end_ob_buffer(1, 0); + php_end_ob_buffer(1, 0 TSRMLS_CC); } /* }}} */ diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 70ad99076d..8c3ce17208 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -146,7 +146,7 @@ typedef struct ps_serializer_struct { #ifdef TRANS_SID void session_adapt_uris(const char *, size_t, char **, size_t * TSRMLS_DC); void session_adapt_url(const char *, size_t, char **, size_t * TSRMLS_DC); -void session_adapt_flush(int (*)(const char *, uint)); +void session_adapt_flush(int (*)(const char *, uint) TSRMLS_DC); #else #define session_adapt_uris(a,b,c,d) do { } while(0) #define session_adapt_url(a,b,c,d) do { } while(0) diff --git a/ext/session/session.c b/ext/session/session.c index e41897793a..7e753261b6 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -658,8 +658,8 @@ static int php_session_cache_limiter(TSRMLS_D) php_session_cache_limiter_t *lim; if (SG(headers_sent)) { - char *output_start_filename = php_get_output_start_filename(); - int output_start_lineno = php_get_output_start_lineno(); + char *output_start_filename = php_get_output_start_filename(TSRMLS_C); + int output_start_lineno = php_get_output_start_lineno(TSRMLS_C); if (output_start_filename) { php_error(E_WARNING, "Cannot send session cache limiter - headers already sent (output started at %s:%d)", @@ -692,8 +692,8 @@ static void php_session_send_cookie(TSRMLS_D) char *date_fmt = NULL; if (SG(headers_sent)) { - char *output_start_filename = php_get_output_start_filename(); - int output_start_lineno = php_get_output_start_lineno(); + char *output_start_filename = php_get_output_start_filename(TSRMLS_C); + int output_start_lineno = php_get_output_start_lineno(TSRMLS_C); if (output_start_filename) { php_error(E_WARNING, "Cannot send session cookie - headers already sent by (output started at %s:%d)", @@ -1280,13 +1280,13 @@ void session_adapt_url(const char *url, size_t urllen, char **new, size_t *newle *new = url_adapt_single_url(url, urllen, PS(session_name), PS(id), newlen); } -void session_adapt_flush(int (*write)(const char *, uint)) +void session_adapt_flush(int (*write)(const char *, uint TSRMLS_DC) TSRMLS_DC) { char *str; size_t len; str = url_adapt_flush(&len); - if (str) write(str, len); + if (str) write(str, len TSRMLS_CC); } #endif diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index 22432c4a1b..8fd808024e 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -65,7 +65,7 @@ PHP_FUNCTION(gzencode); PHP_FUNCTION(ob_gzhandler); FILE *zlib_fopen_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path TSRMLS_DC); -int php_enable_output_compression(int buffer_size); +int php_enable_output_compression(int buffer_size TSRMLS_DC); #ifdef ZTS diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 45dee37364..a0137878d5 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -187,10 +187,10 @@ PHP_RINIT_FUNCTION(zlib) case 0: break; case 1: - php_enable_output_compression(4096); + php_enable_output_compression(4096 TSRMLS_CC); break; default: - php_enable_output_compression(ZLIBG(output_compression)); + php_enable_output_compression(ZLIBG(output_compression) TSRMLS_CC); } return SUCCESS; } @@ -1025,10 +1025,9 @@ static int php_do_deflate(uint str_length, Bytef **p_buffer, uint *p_buffer_len, /* {{{ php_deflate_string */ -int php_deflate_string(const char *str, uint str_length, char **newstr, uint *new_length, int coding, zend_bool do_start, zend_bool do_end) +int php_deflate_string(const char *str, uint str_length, char **newstr, uint *new_length, int coding, zend_bool do_start, zend_bool do_end TSRMLS_DC) { int err; - TSRMLS_FETCH(); ZLIBG(compression_coding) = coding; @@ -1127,7 +1126,7 @@ PHP_FUNCTION(gzencode) ZEND_WRONG_PARAM_COUNT(); break; } - if (php_deflate_string(Z_STRVAL_PP(zv_string), Z_STRLEN_PP(zv_string), &Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), coding, 1, 1)==SUCCESS) { + if (php_deflate_string(Z_STRVAL_PP(zv_string), Z_STRLEN_PP(zv_string), &Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), coding, 1, 1 TSRMLS_CC)==SUCCESS) { Z_TYPE_P(return_value) = IS_STRING; } else { RETURN_FALSE; @@ -1173,7 +1172,7 @@ PHP_FUNCTION(ob_gzhandler) do_end = ((Z_LVAL_PP(zv_mode) & PHP_OUTPUT_HANDLER_END) ? 1 : 0); Z_STRVAL_P(return_value) = NULL; Z_STRLEN_P(return_value) = 0; - if (php_deflate_string(Z_STRVAL_PP(zv_string), Z_STRLEN_PP(zv_string), &Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), coding, do_start, do_end)==SUCCESS) { + if (php_deflate_string(Z_STRVAL_PP(zv_string), Z_STRLEN_PP(zv_string), &Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), coding, do_start, do_end TSRMLS_CC)==SUCCESS) { Z_TYPE_P(return_value) = IS_STRING; if (do_start) { switch (coding) { @@ -1223,14 +1222,13 @@ PHP_FUNCTION(ob_gzhandler) /* {{{ php_gzip_output_handler */ -static void php_gzip_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode) +static void php_gzip_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC) { zend_bool do_start, do_end; - TSRMLS_FETCH(); do_start = (mode & PHP_OUTPUT_HANDLER_START ? 1 : 0); do_end = (mode & PHP_OUTPUT_HANDLER_END ? 1 : 0); - if (php_deflate_string(output, output_len, handled_output, handled_output_len, ZLIBG(ob_gzip_coding), do_start, do_end)!=SUCCESS) { + if (php_deflate_string(output, output_len, handled_output, handled_output_len, ZLIBG(ob_gzip_coding), do_start, do_end TSRMLS_CC)!=SUCCESS) { zend_error(E_ERROR, "Compression failed"); } } @@ -1238,10 +1236,9 @@ static void php_gzip_output_handler(char *output, uint output_len, char **handle /* {{{ php_enable_output_compression */ -int php_enable_output_compression(int buffer_size) +int php_enable_output_compression(int buffer_size TSRMLS_DC) { zval **a_encoding, **data; - TSRMLS_FETCH(); if (zend_hash_find(&EG(symbol_table), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), (void **) &data)==FAILURE || Z_TYPE_PP(data)!=IS_ARRAY @@ -1263,8 +1260,8 @@ int php_enable_output_compression(int buffer_size) return FAILURE; } - php_start_ob_buffer(NULL, buffer_size); - php_ob_set_internal_handler(php_gzip_output_handler, buffer_size*1.5); + php_start_ob_buffer(NULL, buffer_size TSRMLS_CC); + php_ob_set_internal_handler(php_gzip_output_handler, buffer_size*1.5 TSRMLS_CC); return SUCCESS; } /* }}} */ diff --git a/main/SAPI.c b/main/SAPI.c index b38fd1edb5..ac082fb6d3 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -373,8 +373,8 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo char *colon_offset; if (SG(headers_sent) && !SG(request_info).no_headers) { - char *output_start_filename = php_get_output_start_filename(); - int output_start_lineno = php_get_output_start_lineno(); + char *output_start_filename = php_get_output_start_filename(TSRMLS_C); + int output_start_lineno = php_get_output_start_lineno(TSRMLS_C); if (output_start_filename) { sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already sent by (output started at %s:%d)", diff --git a/main/SAPI.h b/main/SAPI.h index def26a08f3..d1e8a3de19 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -160,7 +160,7 @@ struct _sapi_module_struct { int (*activate)(TSRMLS_D); int (*deactivate)(TSRMLS_D); - int (*ub_write)(const char *str, unsigned int str_length); + int (*ub_write)(const char *str, unsigned int str_length TSRMLS_DC); void (*flush)(void *server_context); struct stat *(*get_stat)(TSRMLS_D); char *(*getenv)(char *name, size_t name_len TSRMLS_DC); diff --git a/main/main.c b/main/main.c index ae64e8c911..c55ada3a33 100644 --- a/main/main.c +++ b/main/main.c @@ -622,7 +622,7 @@ int php_request_startup(TSRMLS_D) zend_try { PG(during_request_startup) = 1; - php_output_activate(); + php_output_activate(TSRMLS_C); /* initialize global variables */ PG(modules_activated) = 0; @@ -645,11 +645,11 @@ int php_request_startup(TSRMLS_D) Z_STRLEN_P(output_handler) = strlen(PG(output_handler)); /* this can be optimized */ Z_STRVAL_P(output_handler) = estrndup(PG(output_handler), Z_STRLEN_P(output_handler)); Z_TYPE_P(output_handler) = IS_STRING; - php_start_ob_buffer(output_handler, 0); + php_start_ob_buffer(output_handler, 0 TSRMLS_CC); } else if (PG(output_buffering)) { - php_start_ob_buffer(NULL, 0); + php_start_ob_buffer(NULL, 0 TSRMLS_CC); } else if (PG(implicit_flush)) { - php_start_implicit_flush(); + php_start_implicit_flush(TSRMLS_C); } /* We turn this off in php_execute_script() */ @@ -683,7 +683,7 @@ void php_request_shutdown(void *dummy) TSRMLS_FETCH(); zend_try { - php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1)); + php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1) TSRMLS_CC); } zend_end_try(); zend_try { @@ -800,7 +800,7 @@ int php_module_startup(sapi_module_struct *sf) sapi_module = *sf; php_output_startup(); - php_output_activate(); + php_output_activate(TSRMLS_C); zuf.error_function = php_error_cb; zuf.printf_function = php_printf; @@ -883,7 +883,7 @@ int php_module_startup(sapi_module_struct *sf) REGISTER_MAIN_STRINGL_CONSTANT("PHP_SYSCONFDIR", PHP_SYSCONFDIR, sizeof(PHP_SYSCONFDIR)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_LOCALSTATEDIR", PHP_LOCALSTATEDIR, sizeof(PHP_LOCALSTATEDIR)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_PATH", PHP_CONFIG_FILE_PATH, sizeof(PHP_CONFIG_FILE_PATH)-1, CONST_PERSISTENT | CONST_CS); - php_output_register_constants(); + php_output_register_constants(TSRMLS_C); if (php_startup_ticks(TSRMLS_C) == FAILURE) { php_printf("Unable to start PHP ticks\n"); @@ -1249,7 +1249,7 @@ PHPAPI void php_handle_aborted_connection(void) TSRMLS_FETCH(); PG(connection_status) = PHP_CONNECTION_ABORTED; - php_output_set_status(0); + php_output_set_status(0 TSRMLS_CC); if (!PG(ignore_user_abort)) { zend_bailout(); diff --git a/main/output.c b/main/output.c index 8d1c9d0369..7d4e1fa2cb 100644 --- a/main/output.c +++ b/main/output.c @@ -26,12 +26,12 @@ #include "SAPI.h" /* output functions */ -static int php_ub_body_write(const char *str, uint str_length); -static int php_ub_body_write_no_header(const char *str, uint str_length); -static int php_b_body_write(const char *str, uint str_length); +static int php_ub_body_write(const char *str, uint str_length TSRMLS_DC); +static int php_ub_body_write_no_header(const char *str, uint str_length TSRMLS_DC); +static int php_b_body_write(const char *str, uint str_length TSRMLS_DC); -static void php_ob_init(uint initial_size, uint block_size, zval *output_handler, uint chunk_size); -static void php_ob_append(const char *text, uint text_length); +static void php_ob_init(uint initial_size, uint block_size, zval *output_handler, uint chunk_size TSRMLS_DC); +static void php_ob_append(const char *text, uint text_length TSRMLS_DC); #if 0 static void php_ob_prepend(const char *text, uint text_length); #endif @@ -43,7 +43,7 @@ int output_globals_id; php_output_globals output_globals; #endif -static int php_default_output_func(const char *str, uint str_len) +static int php_default_output_func(const char *str, uint str_len TSRMLS_DC) { fwrite(str, 1, str_len, stderr); return str_len; @@ -71,10 +71,8 @@ PHPAPI void php_output_startup(void) } -PHPAPI void php_output_activate(void) +PHPAPI void php_output_activate(TSRMLS_D) { - TSRMLS_FETCH(); - OG(php_body_write) = php_ub_body_write; OG(php_header_write) = sapi_module.ub_write; OG(ob_nesting_level) = 0; @@ -83,18 +81,14 @@ PHPAPI void php_output_activate(void) } -PHPAPI void php_output_set_status(zend_bool status) +PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC) { - TSRMLS_FETCH(); - OG(disable_output) = !status; } -void php_output_register_constants() +void php_output_register_constants(TSRMLS_D) { - TSRMLS_FETCH(); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_START", PHP_OUTPUT_HANDLER_START, CONST_CS | CONST_PERSISTENT); REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_CONT", PHP_OUTPUT_HANDLER_CONT, CONST_CS | CONST_PERSISTENT); REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_END", PHP_OUTPUT_HANDLER_END, CONST_CS | CONST_PERSISTENT); @@ -104,7 +98,7 @@ void php_output_register_constants() PHPAPI int php_body_write(const char *str, uint str_length) { TSRMLS_FETCH(); - return OG(php_body_write)(str, str_length); + return OG(php_body_write)(str, str_length TSRMLS_CC); } PHPAPI int php_header_write(const char *str, uint str_length) @@ -113,23 +107,21 @@ PHPAPI int php_header_write(const char *str, uint str_length) if (OG(disable_output)) { return 0; } else { - return OG(php_header_write)(str, str_length); + return OG(php_header_write)(str, str_length TSRMLS_CC); } } /* {{{ php_start_ob_buffer * Start output buffering */ -PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size) +PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size TSRMLS_DC) { - TSRMLS_FETCH(); - if (OG(ob_lock)) { return FAILURE; } if (chunk_size) { - php_ob_init((chunk_size*3/2), chunk_size/2, output_handler, chunk_size); + php_ob_init((chunk_size*3/2), chunk_size/2, output_handler, chunk_size TSRMLS_CC); } else { - php_ob_init(40*1024, 10*1024, output_handler, chunk_size); + php_ob_init(40*1024, 10*1024, output_handler, chunk_size TSRMLS_CC); } OG(php_body_write) = php_b_body_write; return SUCCESS; @@ -138,7 +130,7 @@ PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size) /* {{{ php_end_ob_buffer * End output buffering (one level) */ -PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) +PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS_DC) { char *final_buffer=NULL; int final_buffer_length=0; @@ -146,7 +138,6 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) char *to_be_destroyed_buffer; char *to_be_destroyed_handled_output[2] = { 0, 0 }; int status; - TSRMLS_FETCH(); if (OG(ob_nesting_level)==0) { return; @@ -165,12 +156,11 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) if (OG(active_ob_buffer).internal_output_handler) { final_buffer = OG(active_ob_buffer).internal_output_handler_buffer; final_buffer_length = OG(active_ob_buffer).internal_output_handler_buffer_size; - OG(active_ob_buffer).internal_output_handler(OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, &final_buffer, &final_buffer_length, status); + OG(active_ob_buffer).internal_output_handler(OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, &final_buffer, &final_buffer_length, status TSRMLS_CC); } else if (OG(active_ob_buffer).output_handler) { zval **params[2]; zval *orig_buffer; zval *z_status; - TSRMLS_FETCH(); ALLOC_INIT_ZVAL(orig_buffer); ZVAL_STRINGL(orig_buffer, OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, 0); @@ -235,7 +225,7 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) } if (send_buffer) { - OG(php_body_write)(final_buffer, final_buffer_length); + OG(php_body_write)(final_buffer, final_buffer_length TSRMLS_CC); } if (alternate_buffer) { @@ -260,47 +250,39 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) /* {{{ php_end_ob_buffers * End output buffering (all buffers) */ -PHPAPI void php_end_ob_buffers(zend_bool send_buffer) +PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC) { - TSRMLS_FETCH(); - while (OG(ob_nesting_level)!=0) { - php_end_ob_buffer(send_buffer, 0); + php_end_ob_buffer(send_buffer, 0 TSRMLS_CC); } if (!OG(disable_output) && send_buffer && BG(use_trans_sid)) { - session_adapt_flush(OG(php_header_write)); + session_adapt_flush(OG(php_header_write) TSRMLS_CC); } } /* }}} */ /* {{{ php_start_implicit_flush */ -PHPAPI void php_start_implicit_flush() +PHPAPI void php_start_implicit_flush(TSRMLS_D) { - TSRMLS_FETCH(); - - php_end_ob_buffer(1, 0); /* Switch out of output buffering if we're in it */ + php_end_ob_buffer(1, 0 TSRMLS_CC); /* Switch out of output buffering if we're in it */ OG(implicit_flush)=1; } /* }}} */ /* {{{ php_end_implicit_flush */ -PHPAPI void php_end_implicit_flush() +PHPAPI void php_end_implicit_flush(TSRMLS_D) { - TSRMLS_FETCH(); - OG(implicit_flush)=0; } /* }}} */ /* {{{ php_ob_set_internal_handler */ -PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t internal_output_handler, uint buffer_size) +PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t internal_output_handler, uint buffer_size TSRMLS_DC) { - TSRMLS_FETCH(); - if (OG(ob_nesting_level)==0) { return; } @@ -317,10 +299,8 @@ PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t internal_outpu /* {{{ php_ob_allocate */ -static inline void php_ob_allocate(void) +static inline void php_ob_allocate(TSRMLS_D) { - TSRMLS_FETCH(); - if (OG(active_ob_buffer).size0) { if (OG(ob_nesting_level)==1) { /* initialize stack */ zend_stack_init(&OG(ob_buffers)); @@ -357,16 +335,15 @@ static void php_ob_init(uint initial_size, uint block_size, zval *output_handler /* {{{ php_ob_append */ -static void php_ob_append(const char *text, uint text_length) +static void php_ob_append(const char *text, uint text_length TSRMLS_DC) { char *target; int original_ob_text_length; - TSRMLS_FETCH(); original_ob_text_length=OG(active_ob_buffer).text_length; OG(active_ob_buffer).text_length = OG(active_ob_buffer).text_length + text_length; - php_ob_allocate(); + php_ob_allocate(TSRMLS_C); target = OG(active_ob_buffer).buffer+original_ob_text_length; memcpy(target, text, text_length); target[text_length]=0; @@ -378,7 +355,7 @@ static void php_ob_append(const char *text, uint text_length) if (output_handler) { output_handler->refcount++; } - php_end_ob_buffer(1, 1); + php_end_ob_buffer(1, 1 TSRMLS_CC); return; } } @@ -391,7 +368,7 @@ static void php_ob_prepend(const char *text, uint text_length) TSRMLS_FETCH(); OG(active_ob_buffer).text_length += text_length; - php_ob_allocate(); + php_ob_allocate(TSRMLS_C); /* php_ob_allocate() may change OG(ob_buffer), so we can't initialize p&start earlier */ p = OG(ob_buffer)+OG(ob_text_length); @@ -408,10 +385,8 @@ static void php_ob_prepend(const char *text, uint text_length) /* {{{ php_ob_get_buffer * Return the current output buffer */ -int php_ob_get_buffer(pval *p) +int php_ob_get_buffer(pval *p TSRMLS_DC) { - TSRMLS_FETCH(); - if (OG(ob_nesting_level)==0) { return FAILURE; } @@ -422,10 +397,8 @@ int php_ob_get_buffer(pval *p) /* {{{ php_ob_get_length * Return the size of the current output buffer */ -int php_ob_get_length(pval *p) +int php_ob_get_length(pval *p TSRMLS_DC) { - TSRMLS_FETCH(); - if (OG(ob_nesting_level) == 0) { return FAILURE; } @@ -440,20 +413,19 @@ int php_ob_get_length(pval *p) /* buffered output function */ -static int php_b_body_write(const char *str, uint str_length) +static int php_b_body_write(const char *str, uint str_length TSRMLS_DC) { - php_ob_append(str, str_length); + php_ob_append(str, str_length TSRMLS_CC); return str_length; } /* {{{ php_ub_body_write_no_header */ -static int php_ub_body_write_no_header(const char *str, uint str_length) +static int php_ub_body_write_no_header(const char *str, uint str_length TSRMLS_DC) { char *newstr = NULL; size_t new_length=0; int result; - TSRMLS_FETCH(); if (OG(disable_output)) { return 0; @@ -467,7 +439,7 @@ static int php_ub_body_write_no_header(const char *str, uint str_length) str_length = new_length; } - result = OG(php_header_write)(str, str_length); + result = OG(php_header_write)(str, str_length TSRMLS_CC); if (OG(implicit_flush)) { sapi_flush(TSRMLS_C); @@ -479,10 +451,9 @@ static int php_ub_body_write_no_header(const char *str, uint str_length) /* {{{ php_ub_body_write */ -static int php_ub_body_write(const char *str, uint str_length) +static int php_ub_body_write(const char *str, uint str_length TSRMLS_DC) { int result = 0; - TSRMLS_FETCH(); if (SG(request_info).headers_only) { php_header(); @@ -498,7 +469,7 @@ static int php_ub_body_write(const char *str, uint str_length) } OG(php_body_write) = php_ub_body_write_no_header; - result = php_ub_body_write_no_header(str, str_length); + result = php_ub_body_write_no_header(str, str_length TSRMLS_CC); } return result; @@ -548,9 +519,7 @@ PHP_FUNCTION(ob_start) ZEND_WRONG_PARAM_COUNT(); break; } - if (php_start_ob_buffer(output_handler, chunk_size)==FAILURE) { - TSRMLS_FETCH(); - + if (php_start_ob_buffer(output_handler, chunk_size TSRMLS_CC)==FAILURE) { if (SG(headers_sent) && !SG(request_info).headers_only) { OG(php_body_write) = php_ub_body_write_no_header; } else { @@ -568,7 +537,7 @@ PHP_FUNCTION(ob_start) Flush (send) the output buffer, and turn off output buffering */ PHP_FUNCTION(ob_end_flush) { - php_end_ob_buffer(1, 0); + php_end_ob_buffer(1, 0 TSRMLS_CC); } /* }}} */ @@ -576,7 +545,7 @@ PHP_FUNCTION(ob_end_flush) Clean (erase) the output buffer, and turn off output buffering */ PHP_FUNCTION(ob_end_clean) { - php_end_ob_buffer(0, 0); + php_end_ob_buffer(0, 0 TSRMLS_CC); } /* }}} */ @@ -584,7 +553,7 @@ PHP_FUNCTION(ob_end_clean) Return the contents of the output buffer */ PHP_FUNCTION(ob_get_contents) { - if (php_ob_get_buffer(return_value)==FAILURE) { + if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) { RETURN_FALSE; } } @@ -594,7 +563,7 @@ PHP_FUNCTION(ob_get_contents) Return the length of the output buffer */ PHP_FUNCTION(ob_get_length) { - if (php_ob_get_length(return_value)==FAILURE) { + if (php_ob_get_length(return_value TSRMLS_CC)==FAILURE) { RETURN_FALSE; } } @@ -623,25 +592,21 @@ PHP_FUNCTION(ob_implicit_flush) break; } if (flag) { - php_start_implicit_flush(); + php_start_implicit_flush(TSRMLS_C); } else { - php_end_implicit_flush(); + php_end_implicit_flush(TSRMLS_C); } } /* }}} */ -PHPAPI char *php_get_output_start_filename() +PHPAPI char *php_get_output_start_filename(TSRMLS_D) { - TSRMLS_FETCH(); - return OG(output_start_filename); } -PHPAPI int php_get_output_start_lineno() +PHPAPI int php_get_output_start_lineno(TSRMLS_D) { - TSRMLS_FETCH(); - return OG(output_start_lineno); } diff --git a/main/php_output.h b/main/php_output.h index 38211a5222..1521a7319a 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -23,24 +23,24 @@ #include "php.h" -typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode); +typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC); PHPAPI void php_output_startup(void); -PHPAPI void php_output_activate(void); -PHPAPI void php_output_set_status(zend_bool status); -void php_output_register_constants(void); +PHPAPI void php_output_activate(TSRMLS_D); +PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC); +void php_output_register_constants(TSRMLS_D); PHPAPI int php_body_write(const char *str, uint str_length); PHPAPI int php_header_write(const char *str, uint str_length); -PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size); -PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush); -PHPAPI void php_end_ob_buffers(zend_bool send_buffer); -PHPAPI int php_ob_get_buffer(pval *p); -PHPAPI int php_ob_get_length(pval *p); -PHPAPI void php_start_implicit_flush(void); -PHPAPI void php_end_implicit_flush(void); -PHPAPI char *php_get_output_start_filename(void); -PHPAPI int php_get_output_start_lineno(void); -PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t internal_output_handler, uint buffer_size); +PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size TSRMLS_DC); +PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS_DC); +PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC); +PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC); +PHPAPI int php_ob_get_length(zval *p TSRMLS_DC); +PHPAPI void php_start_implicit_flush(TSRMLS_D); +PHPAPI void php_end_implicit_flush(TSRMLS_D); +PHPAPI char *php_get_output_start_filename(TSRMLS_D); +PHPAPI int php_get_output_start_lineno(TSRMLS_D); +PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t internal_output_handler, uint buffer_size TSRMLS_DC); PHP_FUNCTION(ob_start); PHP_FUNCTION(ob_end_flush); @@ -63,8 +63,8 @@ typedef struct _php_ob_buffer { } php_ob_buffer; typedef struct _php_output_globals { - int (*php_body_write)(const char *str, uint str_length); /* string output */ - int (*php_header_write)(const char *str, uint str_length); /* unbuffer string output */ + int (*php_body_write)(const char *str, uint str_length TSRMLS_DC); /* string output */ + int (*php_header_write)(const char *str, uint str_length TSRMLS_DC); /* unbuffer string output */ php_ob_buffer active_ob_buffer; unsigned char implicit_flush; char *output_start_filename; diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c index 7e3271be64..3d2f0164f0 100644 --- a/sapi/aolserver/aolserver.c +++ b/sapi/aolserver/aolserver.c @@ -86,11 +86,10 @@ static void php_ns_config(php_ns_context *ctx, char global); */ static int -php_ns_sapi_ub_write(const char *str, uint str_length) +php_ns_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) { int n; uint sent = 0; - TSRMLS_FETCH(); while (str_length > 0) { n = Ns_ConnWrite(NSG(conn), (void *) str, str_length); diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c index 4265f4aa6a..1321c5cb1b 100644 --- a/sapi/apache/mod_php4.c +++ b/sapi/apache/mod_php4.c @@ -124,10 +124,9 @@ void php_save_umask(void) /* {{{ sapi_apache_ub_write */ -static int sapi_apache_ub_write(const char *str, uint str_length) +static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC) { int ret=0; - TSRMLS_FETCH(); if (SG(server_context)) { ret = rwrite(str, str_length, (request_rec *) SG(server_context)); @@ -311,7 +310,7 @@ static void php_apache_request_shutdown(void *dummy) { TSRMLS_FETCH(); - php_output_set_status(0); + php_output_set_status(0 TSRMLS_CC); SG(server_context) = NULL; /* The server context (request) is invalid by the time run_cleanups() is called */ if (AP(in_request)) { AP(in_request) = 0; diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c index 6b141c52b4..0f14f90421 100644 --- a/sapi/apache/php_apache.c +++ b/sapi/apache/php_apache.c @@ -302,7 +302,6 @@ PHP_FUNCTION(virtual) { pval **filename; request_rec *rr = NULL; - TSRMLS_FETCH(); if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) { WRONG_PARAM_COUNT; @@ -321,7 +320,7 @@ PHP_FUNCTION(virtual) RETURN_FALSE; } - php_end_ob_buffers(1); + php_end_ob_buffers(1 TSRMLS_CC); php_header(); if (run_sub_req(rr)) { diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index 15fab6a1cc..cca75156bf 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -44,13 +44,12 @@ #include "php_apache.h" static int -php_apache_sapi_ub_write(const char *str, uint str_length) +php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) { apr_bucket *b; apr_bucket_brigade *bb; php_struct *ctx; uint now; - TSRMLS_FETCH(); ctx = SG(server_context); diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c index caae71b2dd..962b9acc92 100644 --- a/sapi/caudium/caudium.c +++ b/sapi/caudium/caudium.c @@ -204,10 +204,9 @@ INLINE static int lookup_integer_header(char *headername, int default_value) */ INLINE static int -php_caudium_low_ub_write(const char *str, uint str_length) { +php_caudium_low_ub_write(const char *str, uint str_length TSRMLS_DC) { int sent_bytes = 0; struct pike_string *to_write = NULL; - TSRMLS_FETCH(); GET_THIS(); if(!MY_FD_OBJ->prog) { PG(connection_status) = PHP_CONNECTION_ABORTED; @@ -235,9 +234,8 @@ php_caudium_low_ub_write(const char *str, uint str_length) { */ static int -php_caudium_sapi_ub_write(const char *str, uint str_length) +php_caudium_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) { - TSRMLS_FETCH(); GET_THIS(); int sent_bytes = 0, fd = MY_FD; if(fd) @@ -266,7 +264,7 @@ php_caudium_sapi_ub_write(const char *str, uint str_length) } THIS->written += sent_bytes; } else { - THREAD_SAFE_RUN(sent_bytes = php_caudium_low_ub_write(str, str_length), + THREAD_SAFE_RUN(sent_bytes = php_caudium_low_ub_write(str, str_length TSRMLS_CC), "write"); } return sent_bytes; diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 52b9e6ccdd..5e09d5a694 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -108,7 +108,7 @@ static inline size_t sapi_cgibin_single_write(const char *str, uint str_length) #endif } -static int sapi_cgibin_ub_write(const char *str, uint str_length) +static int sapi_cgibin_ub_write(const char *str, uint str_length TSRMLS_DC) { const char *ptr = str; uint remaining = str_length; @@ -493,10 +493,10 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine case '?': no_headers = 1; php_output_startup(); - php_output_activate(); + php_output_activate(TSRMLS_C); SG(headers_sent) = 1; php_cgi_usage(argv[0]); - php_end_ob_buffers(1); + php_end_ob_buffers(1 TSRMLS_CC); exit(1); break; } @@ -554,10 +554,10 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine case '?': no_headers = 1; php_output_startup(); - php_output_activate(); + php_output_activate(TSRMLS_C); SG(headers_sent) = 1; php_cgi_usage(argv[0]); - php_end_ob_buffers(1); + php_end_ob_buffers(1 TSRMLS_CC); exit(1); break; @@ -581,7 +581,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine case 'm': /* list compiled in modules */ php_output_startup(); - php_output_activate(); + php_output_activate(TSRMLS_C); SG(headers_sent) = 1; php_printf("Running PHP %s\n%s\n", PHP_VERSION , get_zend_version()); php_printf("[PHP Modules]\n"); @@ -590,7 +590,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine /* zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) _print_module_info, NULL TSRMLS_CC); */ php_printf("Not Implemented\n"); php_printf("\n"); - php_end_ob_buffers(1); + php_end_ob_buffers(1 TSRMLS_CC); exit(1); break; @@ -619,7 +619,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine SG(request_info).no_headers = 1; } php_printf("%s\n", PHP_VERSION); - php_end_ob_buffers(1); + php_end_ob_buffers(1 TSRMLS_CC); exit(1); break; diff --git a/sapi/fastcgi/fastcgi.c b/sapi/fastcgi/fastcgi.c index 0984dabe84..e0a3fe7384 100644 --- a/sapi/fastcgi/fastcgi.c +++ b/sapi/fastcgi/fastcgi.c @@ -91,7 +91,7 @@ static int parent = 1; static pid_t pgroup; -static int sapi_fastcgi_ub_write(const char *str, uint str_length) +static int sapi_fastcgi_ub_write(const char *str, uint str_length TSRMLS_DC) { uint sent = FCGX_PutStr( str, str_length, out ); return sent; diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c index da0c303ebc..b272bd4ff8 100644 --- a/sapi/isapi/php4isapi.c +++ b/sapi/isapi/php4isapi.c @@ -199,11 +199,10 @@ static zend_module_entry php_isapi_module = { }; -static int sapi_isapi_ub_write(const char *str, uint str_length) +static int sapi_isapi_ub_write(const char *str, uint str_length TSRMLS_DC) { DWORD num_bytes = str_length; LPEXTENSION_CONTROL_BLOCK ecb; - TSRMLS_FETCH(); ecb = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); if (ecb->WriteClient(ecb->ConnID, (char *) str, &num_bytes, HSE_IO_SYNC ) == FALSE) { diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c index e7633f07b6..9465db5076 100644 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@ -135,12 +135,11 @@ static nsapi_equiv nsapi_client[] = { static size_t nsapi_client_size = sizeof(nsapi_client)/sizeof(nsapi_client[0]); static int -sapi_nsapi_ub_write(const char *str, unsigned int str_length) +sapi_nsapi_ub_write(const char *str, unsigned int str_length TSRMLS_DC) { int retval; nsapi_request_context *rc; - TSRMLS_FETCH(); rc = (nsapi_request_context *)SG(server_context); retval = net_write(rc->sn->csd, (char *)str, str_length); if (retval == IO_ERROR /*-1*/ || retval == IO_EOF /*0*/) diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c index c3aec39e93..ff5cc6677c 100644 --- a/sapi/phttpd/phttpd.c +++ b/sapi/phttpd/phttpd.c @@ -57,10 +57,9 @@ php_phttpd_startup(sapi_module_struct *sapi_module) } static int -php_phttpd_sapi_ub_write(const char *str, uint str_length) +php_phttpd_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) { int sent_bytes; - TSRMLS_FETCH(); sent_bytes = fd_write(PHG(cip)->fd, str, str_length); diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c index cba147a7c2..1e94b161a2 100644 --- a/sapi/pi3web/pi3web_sapi.c +++ b/sapi/pi3web/pi3web_sapi.c @@ -133,11 +133,10 @@ static zend_module_entry php_pi3web_module = { }; -static int zend_pi3web_ub_write(const char *str, uint str_length) +static int zend_pi3web_ub_write(const char *str, uint str_length TSRMLS_DC) { DWORD num_bytes = str_length; LPCONTROL_BLOCK cb; - TSRMLS_FETCH(); cb = (LPCONTROL_BLOCK) SG(server_context); diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c index 9dd8708e86..81f67c43d0 100644 --- a/sapi/roxen/roxen.c +++ b/sapi/roxen/roxen.c @@ -211,13 +211,12 @@ INLINE static int lookup_integer_header(char *headername, int default_value) */ static int -php_roxen_low_ub_write(const char *str, uint str_length) { +php_roxen_low_ub_write(const char *str, uint str_length TSRMLS_DC) { int sent_bytes = 0; struct pike_string *to_write = NULL; #ifdef ROXEN_USE_ZTS GET_THIS(); #endif - TSRMLS_FETCH(); if(!MY_FD_OBJ->prog) { PG(connection_status) = PHP_CONNECTION_ABORTED; @@ -243,12 +242,11 @@ php_roxen_low_ub_write(const char *str, uint str_length) { */ static int -php_roxen_sapi_ub_write(const char *str, uint str_length) +php_roxen_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) { #ifdef ROXEN_USE_ZTS GET_THIS(); #endif - TSRMLS_FETCH(); int sent_bytes = 0, fd = MY_FD; if(fd) @@ -276,7 +274,7 @@ php_roxen_sapi_ub_write(const char *str, uint str_length) } } } else { - THREAD_SAFE_RUN(sent_bytes = php_roxen_low_ub_write(str, str_length), + THREAD_SAFE_RUN(sent_bytes = php_roxen_low_ub_write(str, str_length TSRMLS_CC), "write"); } return sent_bytes; diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c index edfce72b81..aaf4589b3f 100644 --- a/sapi/servlet/servlet.c +++ b/sapi/servlet/servlet.c @@ -114,9 +114,8 @@ void ThrowServletException (JNIEnv *jenv, char *msg) { * sapi callbacks */ -static int sapi_servlet_ub_write(const char *str, uint str_length) +static int sapi_servlet_ub_write(const char *str, uint str_length TSRMLS_DC) { - TSRMLS_FETCH(); if (!SG(server_context)) { fprintf(stderr, str); return 0; diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index 969836ceec..d14325db94 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -43,11 +43,10 @@ static php_thttpd_globals thttpd_globals; #define TG(v) (thttpd_globals.v) #endif -static int sapi_thttpd_ub_write(const char *str, uint str_length) +static int sapi_thttpd_ub_write(const char *str, uint str_length TSRMLS_DC) { int n; uint sent = 0; - TSRMLS_FETCH(); while (str_length > 0) { n = send(TG(hc)->conn_fd, str, str_length, 0); diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c index 70199750fd..4d44b40728 100644 --- a/sapi/tux/php_tux.c +++ b/sapi/tux/php_tux.c @@ -49,11 +49,10 @@ static php_tux_globals tux_globals; #define TG(v) (tux_globals.v) -static int sapi_tux_ub_write(const char *str, uint str_length) +static int sapi_tux_ub_write(const char *str, uint str_length TSRMLS_DC) { int n; uint sent = 0; - TSRMLS_FETCH(); /* combine headers and body */ if (TG(number_vec)) {