summaryrefslogtreecommitdiff
path: root/main/SAPI.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/SAPI.c')
-rw-r--r--main/SAPI.c321
1 files changed, 161 insertions, 160 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index 284164e4c0..d3e855b771 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -1,8 +1,8 @@
-/*
+/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
+ | Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| 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 |
@@ -57,14 +57,22 @@ SAPI_API int sapi_globals_id;
sapi_globals_struct sapi_globals;
#endif
-static void sapi_globals_ctor(sapi_globals_struct *sapi_globals TSRMLS_DC)
+static void _type_dtor(zval *zv)
+{
+ free(Z_PTR_P(zv));
+}
+
+static void sapi_globals_ctor(sapi_globals_struct *sapi_globals)
{
+#ifdef ZTS
+ ZEND_TSRMLS_CACHE_UPDATE;
+#endif
memset(sapi_globals, 0, sizeof(*sapi_globals));
- zend_hash_init_ex(&sapi_globals->known_post_content_types, 5, NULL, NULL, 1, 0);
- php_setup_sapi_content_types(TSRMLS_C);
+ zend_hash_init_ex(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1, 0);
+ php_setup_sapi_content_types();
}
-static void sapi_globals_dtor(sapi_globals_struct *sapi_globals TSRMLS_DC)
+static void sapi_globals_dtor(sapi_globals_struct *sapi_globals)
{
zend_hash_destroy(&sapi_globals->known_post_content_types);
}
@@ -124,78 +132,69 @@ SAPI_API void sapi_free_header(sapi_header_struct *sapi_header)
PHP_FUNCTION(header_register_callback)
{
zval *callback_func;
- char *callback_name;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &callback_func) == FAILURE) {
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callback_func) == FAILURE) {
return;
}
-
- if (!zend_is_callable(callback_func, 0, &callback_name TSRMLS_CC)) {
- efree(callback_name);
+
+ if (!zend_is_callable(callback_func, 0, NULL)) {
RETURN_FALSE;
}
- efree(callback_name);
-
- if (SG(callback_func)) {
+ if (Z_TYPE(SG(callback_func)) != IS_UNDEF) {
zval_ptr_dtor(&SG(callback_func));
SG(fci_cache) = empty_fcall_info_cache;
}
- SG(callback_func) = callback_func;
-
- Z_ADDREF_P(SG(callback_func));
+ ZVAL_COPY(&SG(callback_func), callback_func);
RETURN_TRUE;
}
/* }}} */
-static void sapi_run_header_callback(TSRMLS_D)
+static void sapi_run_header_callback(void)
{
int error;
zend_fcall_info fci;
- char *callback_name = NULL;
char *callback_error = NULL;
- zval *retval_ptr = NULL;
-
- if (zend_fcall_info_init(SG(callback_func), 0, &fci, &SG(fci_cache), &callback_name, &callback_error TSRMLS_CC) == SUCCESS) {
- fci.retval_ptr_ptr = &retval_ptr;
-
- error = zend_call_function(&fci, &SG(fci_cache) TSRMLS_CC);
+ zval retval;
+
+ if (zend_fcall_info_init(&SG(callback_func), 0, &fci, &SG(fci_cache), NULL, &callback_error) == SUCCESS) {
+ fci.retval = &retval;
+
+ error = zend_call_function(&fci, &SG(fci_cache));
if (error == FAILURE) {
goto callback_failed;
- } else if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
+ } else {
+ zval_ptr_dtor(&retval);
}
} else {
callback_failed:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not call the sapi_header_callback");
- }
-
- if (callback_name) {
- efree(callback_name);
+ php_error_docref(NULL, E_WARNING, "Could not call the sapi_header_callback");
}
+
if (callback_error) {
efree(callback_error);
- }
+ }
}
-SAPI_API void sapi_handle_post(void *arg TSRMLS_DC)
+SAPI_API void sapi_handle_post(void *arg)
{
if (SG(request_info).post_entry && SG(request_info).content_type_dup) {
- SG(request_info).post_entry->post_handler(SG(request_info).content_type_dup, arg TSRMLS_CC);
+ SG(request_info).post_entry->post_handler(SG(request_info).content_type_dup, arg);
efree(SG(request_info).content_type_dup);
SG(request_info).content_type_dup = NULL;
}
}
-static void sapi_read_post_data(TSRMLS_D)
+static void sapi_read_post_data(void)
{
sapi_post_entry *post_entry;
- uint content_type_length = strlen(SG(request_info).content_type);
+ uint content_type_length = (uint)strlen(SG(request_info).content_type);
char *content_type = estrndup(SG(request_info).content_type, content_type_length);
char *p;
char oldchar=0;
- void (*post_reader_func)(TSRMLS_D) = NULL;
+ void (*post_reader_func)(void) = NULL;
/* dedicated implementation for increased performance:
@@ -218,8 +217,8 @@ static void sapi_read_post_data(TSRMLS_D)
}
/* now try to find an appropriate POST content handler */
- if (zend_hash_find(&SG(known_post_content_types), content_type,
- content_type_length+1, (void **) &post_entry) == SUCCESS) {
+ if ((post_entry = zend_hash_str_find_ptr(&SG(known_post_content_types), content_type,
+ content_type_length)) != NULL) {
/* found one, register it for use */
SG(request_info).post_entry = post_entry;
post_reader_func = post_entry->post_reader;
@@ -240,15 +239,15 @@ static void sapi_read_post_data(TSRMLS_D)
SG(request_info).content_type_dup = content_type;
if(post_reader_func) {
- post_reader_func(TSRMLS_C);
+ post_reader_func();
}
if(sapi_module.default_post_reader) {
- sapi_module.default_post_reader(TSRMLS_C);
+ sapi_module.default_post_reader();
}
}
-SAPI_API int sapi_read_post_block(char *buffer, size_t buflen TSRMLS_DC)
+SAPI_API int sapi_read_post_block(char *buffer, size_t buflen)
{
int read_bytes;
@@ -256,7 +255,7 @@ SAPI_API int sapi_read_post_block(char *buffer, size_t buflen TSRMLS_DC)
return -1;
}
- read_bytes = sapi_module.read_post(buffer, buflen TSRMLS_CC);
+ read_bytes = (int)sapi_module.read_post(buffer, buflen);
if (read_bytes > 0) {
/* gogo */
@@ -273,7 +272,7 @@ SAPI_API int sapi_read_post_block(char *buffer, size_t buflen TSRMLS_DC)
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
{
if ((SG(post_max_size) > 0) && (SG(request_info).content_length > SG(post_max_size))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes",
+ php_error_docref(NULL, E_WARNING, "POST Content-Length of %pd bytes exceeds the limit of %pd bytes",
SG(request_info).content_length, SG(post_max_size));
return;
}
@@ -287,14 +286,14 @@ SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
for (;;) {
char buffer[SAPI_POST_BLOCK_SIZE];
- read_bytes = sapi_read_post_block(buffer, SAPI_POST_BLOCK_SIZE TSRMLS_CC);
+ read_bytes = sapi_read_post_block(buffer, SAPI_POST_BLOCK_SIZE);
if (read_bytes > 0) {
php_stream_write(SG(request_info).request_body, buffer, read_bytes);
}
if ((SG(post_max_size) > 0) && (SG(read_post_bytes) > SG(post_max_size))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Actual POST length does not match Content-Length, and exceeds %ld bytes", SG(post_max_size));
+ php_error_docref(NULL, E_WARNING, "Actual POST length does not match Content-Length, and exceeds " ZEND_LONG_FMT " bytes", SG(post_max_size));
break;
}
@@ -308,21 +307,21 @@ SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
}
-static inline char *get_default_content_type(uint prefix_len, uint *len TSRMLS_DC)
+static inline char *get_default_content_type(uint prefix_len, uint *len)
{
char *mimetype, *charset, *content_type;
uint mimetype_len, charset_len;
if (SG(default_mimetype)) {
mimetype = SG(default_mimetype);
- mimetype_len = strlen(SG(default_mimetype));
+ mimetype_len = (uint)strlen(SG(default_mimetype));
} else {
mimetype = SAPI_DEFAULT_MIMETYPE;
mimetype_len = sizeof(SAPI_DEFAULT_MIMETYPE) - 1;
}
if (SG(default_charset)) {
charset = SG(default_charset);
- charset_len = strlen(SG(default_charset));
+ charset_len = (uint)strlen(SG(default_charset));
} else {
charset = SAPI_DEFAULT_CHARSET;
charset_len = sizeof(SAPI_DEFAULT_CHARSET) - 1;
@@ -348,19 +347,19 @@ static inline char *get_default_content_type(uint prefix_len, uint *len TSRMLS_D
}
-SAPI_API char *sapi_get_default_content_type(TSRMLS_D)
+SAPI_API char *sapi_get_default_content_type(void)
{
uint len;
- return get_default_content_type(0, &len TSRMLS_CC);
+ return get_default_content_type(0, &len);
}
-SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header TSRMLS_DC)
+SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header)
{
uint len;
- default_header->header = get_default_content_type(sizeof("Content-type: ")-1, &len TSRMLS_CC);
+ default_header->header = get_default_content_type(sizeof("Content-type: ")-1, &len);
default_header->header_len = len;
memcpy(default_header->header, "Content-type: ", sizeof("Content-type: ") - 1);
}
@@ -376,7 +375,7 @@ SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_h
* unchanged, 0 is returned.
*
*/
-SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len TSRMLS_DC)
+SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len)
{
char *charset, *newtype;
size_t newlen;
@@ -397,16 +396,16 @@ SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len TSRMLS_DC
return 0;
}
-SAPI_API void sapi_activate_headers_only(TSRMLS_D)
+SAPI_API void sapi_activate_headers_only(void)
{
if (SG(request_info).headers_read == 1)
return;
SG(request_info).headers_read = 1;
- zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct),
+ zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct),
(void (*)(void *)) sapi_free_header, 0);
SG(sapi_headers).send_default_content_type = 1;
- /* SG(sapi_headers).http_response_code = 200; */
+ /* SG(sapi_headers).http_response_code = 200; */
SG(sapi_headers).http_status_line = NULL;
SG(sapi_headers).mimetype = NULL;
SG(read_post_bytes) = 0;
@@ -418,7 +417,7 @@ SAPI_API void sapi_activate_headers_only(TSRMLS_D)
SG(global_request_time) = 0;
/*
- * It's possible to override this general case in the activate() callback,
+ * It's possible to override this general case in the activate() callback,
* if necessary.
*/
if (SG(request_info).request_method && !strcmp(SG(request_info).request_method, "HEAD")) {
@@ -427,13 +426,13 @@ SAPI_API void sapi_activate_headers_only(TSRMLS_D)
SG(request_info).headers_only = 0;
}
if (SG(server_context)) {
- SG(request_info).cookie_data = sapi_module.read_cookies(TSRMLS_C);
+ SG(request_info).cookie_data = sapi_module.read_cookies();
if (sapi_module.activate) {
- sapi_module.activate(TSRMLS_C);
+ sapi_module.activate();
}
}
if (sapi_module.input_filter_init ) {
- sapi_module.input_filter_init(TSRMLS_C);
+ sapi_module.input_filter_init();
}
}
@@ -441,7 +440,7 @@ SAPI_API void sapi_activate_headers_only(TSRMLS_D)
* Called from php_request_startup() for every request.
*/
-SAPI_API void sapi_activate(TSRMLS_D)
+SAPI_API void sapi_activate(void)
{
zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0);
SG(sapi_headers).send_default_content_type = 1;
@@ -453,7 +452,7 @@ SAPI_API void sapi_activate(TSRMLS_D)
SG(sapi_headers).mimetype = NULL;
SG(headers_sent) = 0;
SG(callback_run) = 0;
- SG(callback_func) = NULL;
+ ZVAL_UNDEF(&SG(callback_func));
SG(read_post_bytes) = 0;
SG(request_info).request_body = NULL;
SG(request_info).current_user = NULL;
@@ -479,33 +478,33 @@ SAPI_API void sapi_activate(TSRMLS_D)
&& !strcmp(SG(request_info).request_method, "POST")) {
/* HTTP POST may contain form data to be processed into variables
* depending on given content type */
- sapi_read_post_data(TSRMLS_C);
+ sapi_read_post_data();
} else {
SG(request_info).content_type_dup = NULL;
}
/* Cookies */
- SG(request_info).cookie_data = sapi_module.read_cookies(TSRMLS_C);
+ SG(request_info).cookie_data = sapi_module.read_cookies();
if (sapi_module.activate) {
- sapi_module.activate(TSRMLS_C);
+ sapi_module.activate();
}
}
if (sapi_module.input_filter_init) {
- sapi_module.input_filter_init(TSRMLS_C);
+ sapi_module.input_filter_init();
}
}
-static void sapi_send_headers_free(TSRMLS_D)
+static void sapi_send_headers_free(void)
{
if (SG(sapi_headers).http_status_line) {
efree(SG(sapi_headers).http_status_line);
SG(sapi_headers).http_status_line = NULL;
}
}
-
-SAPI_API void sapi_deactivate(TSRMLS_D)
+
+SAPI_API void sapi_deactivate(void)
{
zend_llist_destroy(&SG(sapi_headers).headers);
if (SG(request_info).request_body) {
@@ -517,7 +516,7 @@ SAPI_API void sapi_deactivate(TSRMLS_D)
int read_bytes;
do {
- read_bytes = sapi_read_post_block(dummy, SAPI_POST_BLOCK_SIZE TSRMLS_CC);
+ read_bytes = sapi_read_post_block(dummy, SAPI_POST_BLOCK_SIZE);
} while (SAPI_POST_BLOCK_SIZE == read_bytes);
}
}
@@ -537,28 +536,26 @@ SAPI_API void sapi_deactivate(TSRMLS_D)
efree(SG(request_info).current_user);
}
if (sapi_module.deactivate) {
- sapi_module.deactivate(TSRMLS_C);
+ sapi_module.deactivate();
}
if (SG(rfc1867_uploaded_files)) {
- destroy_uploaded_files_hash(TSRMLS_C);
+ destroy_uploaded_files_hash();
}
if (SG(sapi_headers).mimetype) {
efree(SG(sapi_headers).mimetype);
SG(sapi_headers).mimetype = NULL;
}
- sapi_send_headers_free(TSRMLS_C);
+ sapi_send_headers_free();
SG(sapi_started) = 0;
SG(headers_sent) = 0;
SG(callback_run) = 0;
- if (SG(callback_func)) {
- zval_ptr_dtor(&SG(callback_func));
- }
+ zval_ptr_dtor(&SG(callback_func));
SG(request_info).headers_read = 0;
SG(global_request_time) = 0;
}
-SAPI_API void sapi_initialize_empty_request(TSRMLS_D)
+SAPI_API void sapi_initialize_empty_request(void)
{
SG(server_context) = NULL;
SG(request_info).request_method = NULL;
@@ -578,12 +575,12 @@ static int sapi_extract_response_code(const char *header_line)
break;
}
}
-
+
return code;
}
-static void sapi_update_response_code(int ncode TSRMLS_DC)
+static void sapi_update_response_code(int ncode)
{
/* if the status code did not change, we do not want
to change the status line, and no need to change the code */
@@ -598,7 +595,7 @@ static void sapi_update_response_code(int ncode TSRMLS_DC)
SG(sapi_headers).http_response_code = ncode;
}
-/*
+/*
* since zend_llist_del_element only remove one matched item once,
* we should remove them by ourself
*/
@@ -630,16 +627,16 @@ static void sapi_remove_header(zend_llist *l, char *name, uint len) {
}
}
-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)
{
sapi_header_line ctr = {0};
int r;
-
+
ctr.line = header_line;
ctr.line_len = header_line_len;
r = sapi_header_op(replace ? SAPI_HEADER_REPLACE : SAPI_HEADER_ADD,
- &ctr TSRMLS_CC);
+ &ctr);
if (!duplicate)
efree(header_line);
@@ -647,10 +644,10 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo
return r;
}
-static void sapi_header_add_op(sapi_header_op_enum op, sapi_header_struct *sapi_header TSRMLS_DC)
+static void sapi_header_add_op(sapi_header_op_enum op, sapi_header_struct *sapi_header)
{
if (!sapi_module.header_handler ||
- (SAPI_HEADER_ADD & sapi_module.header_handler(sapi_header, op, &SG(sapi_headers) TSRMLS_CC))) {
+ (SAPI_HEADER_ADD & sapi_module.header_handler(sapi_header, op, &SG(sapi_headers)))) {
if (op == SAPI_HEADER_REPLACE) {
char *colon_offset = strchr(sapi_header->header, ':');
@@ -658,7 +655,7 @@ static void sapi_header_add_op(sapi_header_op_enum op, sapi_header_struct *sapi_
char sav = *colon_offset;
*colon_offset = 0;
- sapi_remove_header(&SG(sapi_headers).headers, sapi_header->header, strlen(sapi_header->header));
+ sapi_remove_header(&SG(sapi_headers).headers, sapi_header->header, (int)strlen(sapi_header->header));
*colon_offset = sav;
}
}
@@ -668,7 +665,7 @@ static void sapi_header_add_op(sapi_header_op_enum op, sapi_header_struct *sapi_
}
}
-SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
+SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
{
sapi_header_struct sapi_header;
char *colon_offset;
@@ -677,8 +674,8 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
int http_response_code;
if (SG(headers_sent) && !SG(request_info).no_headers) {
- const char *output_start_filename = php_output_get_start_filename(TSRMLS_C);
- int output_start_lineno = php_output_get_start_lineno(TSRMLS_C);
+ const char *output_start_filename = php_output_get_start_filename();
+ int output_start_lineno = php_output_get_start_lineno();
if (output_start_filename) {
sapi_module.sapi_error(E_WARNING, "Cannot modify header information - headers already sent by (output started at %s:%d)",
@@ -691,7 +688,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
switch (op) {
case SAPI_HEADER_SET_STATUS:
- sapi_update_response_code((int)(zend_intptr_t) arg TSRMLS_CC);
+ sapi_update_response_code((int)(zend_intptr_t) arg);
return SUCCESS;
case SAPI_HEADER_ADD:
@@ -710,7 +707,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
case SAPI_HEADER_DELETE_ALL:
if (sapi_module.header_handler) {
- sapi_module.header_handler(&sapi_header, op, &SG(sapi_headers) TSRMLS_CC);
+ sapi_module.header_handler(&sapi_header, op, &SG(sapi_headers));
}
zend_llist_clean(&SG(sapi_headers).headers);
return SUCCESS;
@@ -728,7 +725,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
} while(header_line_len && isspace(header_line[header_line_len-1]));
header_line[header_line_len]='\0';
}
-
+
if (op == SAPI_HEADER_DELETE) {
if (strchr(header_line, ':')) {
efree(header_line);
@@ -738,14 +735,14 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
if (sapi_module.header_handler) {
sapi_header.header = header_line;
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));
}
sapi_remove_header(&SG(sapi_headers).headers, header_line, header_line_len);
efree(header_line);
return SUCCESS;
} else {
/* new line/NUL character safety check */
- int i;
+ uint i;
for (i = 0; i < header_line_len; i++) {
/* RFC 2616 allows new lines if followed by SP or HT */
int illegal_break =
@@ -771,10 +768,10 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
sapi_header.header_len = header_line_len;
/* Check the header for a few cases that we have special support for in SAPI */
- if (header_line_len>=5
+ if (header_line_len>=5
&& !strncasecmp(header_line, "HTTP/", 5)) {
/* filter out the response code */
- sapi_update_response_code(sapi_extract_response_code(header_line) TSRMLS_CC);
+ sapi_update_response_code(sapi_extract_response_code(header_line));
/* sapi_update_response_code doesn't free the status line if the code didn't change */
if (SG(sapi_headers).http_status_line) {
efree(SG(sapi_headers).http_status_line);
@@ -795,11 +792,13 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
/* Disable possible output compression for images */
if (!strncmp(ptr, "image/", sizeof("image/")-1)) {
- zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
+ zend_string *key = zend_string_init("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
+ zend_alter_ini_entry_chars(key, "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
+ zend_string_release(key);
}
mimetype = estrdup(ptr);
- newlen = sapi_apply_default_charset(&mimetype, len TSRMLS_CC);
+ newlen = sapi_apply_default_charset(&mimetype, len);
if (!SG(sapi_headers).mimetype){
SG(sapi_headers).mimetype = estrdup(mimetype);
}
@@ -810,7 +809,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
PHP_STRLCPY(newheader, "Content-type: ", newlen, sizeof("Content-type: ")-1);
strlcat(newheader, mimetype, newlen);
sapi_header.header = newheader;
- sapi_header.header_len = newlen - 1;
+ sapi_header.header_len = (uint)(newlen - 1);
efree(header_line);
}
efree(mimetype);
@@ -821,26 +820,28 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
* do disable compression altogether. This contributes to making scripts
* portable between setups that have and don't have zlib compression
* enabled globally. See req #44164 */
- zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"),
+ zend_string *key = zend_string_init("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
+ zend_alter_ini_entry_chars(key,
"0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
+ zend_string_release(key);
} else if (!STRCASECMP(header_line, "Location")) {
if ((SG(sapi_headers).http_response_code < 300 ||
SG(sapi_headers).http_response_code > 399) &&
SG(sapi_headers).http_response_code != 201) {
/* Return a Found Redirect if one is not already specified */
if (http_response_code) { /* user specified redirect code */
- sapi_update_response_code(http_response_code TSRMLS_CC);
- } else if (SG(request_info).proto_num > 1000 &&
- SG(request_info).request_method &&
+ sapi_update_response_code(http_response_code);
+ } else if (SG(request_info).proto_num > 1000 &&
+ SG(request_info).request_method &&
strcmp(SG(request_info).request_method, "HEAD") &&
strcmp(SG(request_info).request_method, "GET")) {
- sapi_update_response_code(303 TSRMLS_CC);
+ sapi_update_response_code(303);
} else {
- sapi_update_response_code(302 TSRMLS_CC);
+ sapi_update_response_code(302);
}
}
} else if (!STRCASECMP(header_line, "WWW-Authenticate")) { /* HTTP Authentication */
- sapi_update_response_code(401 TSRMLS_CC); /* authentication-required */
+ sapi_update_response_code(401); /* authentication-required */
}
if (sapi_header.header==header_line) {
*colon_offset = ':';
@@ -848,14 +849,14 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
}
}
if (http_response_code) {
- sapi_update_response_code(http_response_code TSRMLS_CC);
+ sapi_update_response_code(http_response_code);
}
- sapi_header_add_op(op, &sapi_header TSRMLS_CC);
+ sapi_header_add_op(op, &sapi_header);
return SUCCESS;
}
-SAPI_API int sapi_send_headers(TSRMLS_D)
+SAPI_API int sapi_send_headers(void)
{
int retval;
int ret = FAILURE;
@@ -871,24 +872,24 @@ SAPI_API int sapi_send_headers(TSRMLS_D)
sapi_header_struct default_header;
uint len;
- SG(sapi_headers).mimetype = get_default_content_type(0, &len TSRMLS_CC);
+ SG(sapi_headers).mimetype = get_default_content_type(0, &len);
default_header.header_len = sizeof("Content-type: ") - 1 + len;
default_header.header = emalloc(default_header.header_len + 1);
memcpy(default_header.header, "Content-type: ", sizeof("Content-type: ") - 1);
memcpy(default_header.header + sizeof("Content-type: ") - 1, SG(sapi_headers).mimetype, len + 1);
- sapi_header_add_op(SAPI_HEADER_ADD, &default_header TSRMLS_CC);
+ sapi_header_add_op(SAPI_HEADER_ADD, &default_header);
SG(sapi_headers).send_default_content_type = 0;
}
- if (SG(callback_func) && !SG(callback_run)) {
+ if (Z_TYPE(SG(callback_func)) != IS_UNDEF && !SG(callback_run)) {
SG(callback_run) = 1;
- sapi_run_header_callback(TSRMLS_C);
+ sapi_run_header_callback();
}
SG(headers_sent) = 1;
if (sapi_module.send_headers) {
- retval = sapi_module.send_headers(&SG(sapi_headers) TSRMLS_CC);
+ retval = sapi_module.send_headers(&SG(sapi_headers));
} else {
retval = SAPI_HEADER_DO_SEND;
}
@@ -903,22 +904,22 @@ SAPI_API int sapi_send_headers(TSRMLS_D)
if (SG(sapi_headers).http_status_line) {
http_status_line.header = SG(sapi_headers).http_status_line;
- http_status_line.header_len = strlen(SG(sapi_headers).http_status_line);
+ http_status_line.header_len = (uint)strlen(SG(sapi_headers).http_status_line);
} else {
http_status_line.header = buf;
http_status_line.header_len = slprintf(buf, sizeof(buf), "HTTP/1.0 %d X", SG(sapi_headers).http_response_code);
}
- sapi_module.send_header(&http_status_line, SG(server_context) TSRMLS_CC);
+ sapi_module.send_header(&http_status_line, SG(server_context));
}
- zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) sapi_module.send_header, SG(server_context) TSRMLS_CC);
+ zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) sapi_module.send_header, SG(server_context));
if(SG(sapi_headers).send_default_content_type) {
sapi_header_struct default_header;
- sapi_get_default_content_type_header(&default_header TSRMLS_CC);
- sapi_module.send_header(&default_header, SG(server_context) TSRMLS_CC);
+ sapi_get_default_content_type_header(&default_header);
+ sapi_module.send_header(&default_header, SG(server_context));
sapi_free_header(&default_header);
}
- sapi_module.send_header(NULL, SG(server_context) TSRMLS_CC);
+ sapi_module.send_header(NULL, SG(server_context));
ret = SUCCESS;
break;
case SAPI_HEADER_SEND_FAILED:
@@ -927,18 +928,18 @@ SAPI_API int sapi_send_headers(TSRMLS_D)
break;
}
- sapi_send_headers_free(TSRMLS_C);
+ sapi_send_headers_free();
return ret;
}
-SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entries TSRMLS_DC)
+SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entries)
{
sapi_post_entry *p=post_entries;
while (p->content_type) {
- if (sapi_register_post_entry(p TSRMLS_CC) == FAILURE) {
+ if (sapi_register_post_entry(p) == FAILURE) {
return FAILURE;
}
p++;
@@ -947,29 +948,29 @@ SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entries TSRMLS_DC)
}
-SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry TSRMLS_DC)
+SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry)
{
- if (SG(sapi_started) && EG(in_execution)) {
+ if (SG(sapi_started) && EG(current_execute_data)) {
return FAILURE;
}
- return zend_hash_add(&SG(known_post_content_types),
- post_entry->content_type, post_entry->content_type_len+1,
- (void *) post_entry, sizeof(sapi_post_entry), NULL);
+ return zend_hash_str_add_mem(&SG(known_post_content_types),
+ post_entry->content_type, post_entry->content_type_len,
+ (void *) post_entry, sizeof(sapi_post_entry)) ? SUCCESS : FAILURE;
}
-SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry TSRMLS_DC)
+SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry)
{
- if (SG(sapi_started) && EG(in_execution)) {
+ if (SG(sapi_started) && EG(current_execute_data)) {
return;
}
- zend_hash_del(&SG(known_post_content_types), post_entry->content_type,
- post_entry->content_type_len+1);
+ zend_hash_str_del(&SG(known_post_content_types), post_entry->content_type,
+ post_entry->content_type_len);
}
-SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D) TSRMLS_DC)
+SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(void))
{
- if (SG(sapi_started) && EG(in_execution)) {
+ if (SG(sapi_started) && EG(current_execute_data)) {
return FAILURE;
}
sapi_module.default_post_reader = default_post_reader;
@@ -977,18 +978,18 @@ SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRML
}
-SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC) TSRMLS_DC)
+SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray))
{
- if (SG(sapi_started) && EG(in_execution)) {
+ if (SG(sapi_started) && EG(current_execute_data)) {
return FAILURE;
}
sapi_module.treat_data = treat_data;
return SUCCESS;
}
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC), unsigned int (*input_filter_init)(TSRMLS_D) TSRMLS_DC)
+SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
{
- if (SG(sapi_started) && EG(in_execution)) {
+ if (SG(sapi_started) && EG(current_execute_data)) {
return FAILURE;
}
sapi_module.input_filter = input_filter;
@@ -996,7 +997,7 @@ SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, ch
return SUCCESS;
}
-SAPI_API int sapi_flush(TSRMLS_D)
+SAPI_API int sapi_flush(void)
{
if (sapi_module.flush) {
sapi_module.flush(SG(server_context));
@@ -1006,10 +1007,10 @@ SAPI_API int sapi_flush(TSRMLS_D)
}
}
-SAPI_API struct stat *sapi_get_stat(TSRMLS_D)
+SAPI_API zend_stat_t *sapi_get_stat(void)
{
if (sapi_module.get_stat) {
- return sapi_module.get_stat(TSRMLS_C);
+ return sapi_module.get_stat();
} else {
if (!SG(request_info).path_translated || (VCWD_STAT(SG(request_info).path_translated, &SG(global_stat)) == -1)) {
return NULL;
@@ -1018,66 +1019,66 @@ SAPI_API struct stat *sapi_get_stat(TSRMLS_D)
}
}
-SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC)
+SAPI_API char *sapi_getenv(char *name, size_t name_len)
{
- if (sapi_module.getenv) {
- char *value, *tmp = sapi_module.getenv(name, name_len TSRMLS_CC);
+ if (sapi_module.getenv) {
+ char *value, *tmp = sapi_module.getenv(name, name_len);
if (tmp) {
value = estrdup(tmp);
} else {
return NULL;
}
if (sapi_module.input_filter) {
- sapi_module.input_filter(PARSE_STRING, name, &value, strlen(value), NULL TSRMLS_CC);
+ sapi_module.input_filter(PARSE_STRING, name, &value, strlen(value), NULL);
}
return value;
}
return NULL;
}
-SAPI_API int sapi_get_fd(int *fd TSRMLS_DC)
+SAPI_API int sapi_get_fd(int *fd)
{
if (sapi_module.get_fd) {
- return sapi_module.get_fd(fd TSRMLS_CC);
+ return sapi_module.get_fd(fd);
} else {
return FAILURE;
}
}
-SAPI_API int sapi_force_http_10(TSRMLS_D)
+SAPI_API int sapi_force_http_10(void)
{
if (sapi_module.force_http_10) {
- return sapi_module.force_http_10(TSRMLS_C);
+ return sapi_module.force_http_10();
} else {
return FAILURE;
}
}
-SAPI_API int sapi_get_target_uid(uid_t *obj TSRMLS_DC)
+SAPI_API int sapi_get_target_uid(uid_t *obj)
{
if (sapi_module.get_target_uid) {
- return sapi_module.get_target_uid(obj TSRMLS_CC);
+ return sapi_module.get_target_uid(obj);
} else {
return FAILURE;
}
}
-SAPI_API int sapi_get_target_gid(gid_t *obj TSRMLS_DC)
+SAPI_API int sapi_get_target_gid(gid_t *obj)
{
if (sapi_module.get_target_gid) {
- return sapi_module.get_target_gid(obj TSRMLS_CC);
+ return sapi_module.get_target_gid(obj);
} else {
return FAILURE;
}
}
-SAPI_API double sapi_get_request_time(TSRMLS_D)
+SAPI_API double sapi_get_request_time(void)
{
if(SG(global_request_time)) return SG(global_request_time);
if (sapi_module.get_request_time && SG(server_context)) {
- SG(global_request_time) = sapi_module.get_request_time(TSRMLS_C);
+ SG(global_request_time) = sapi_module.get_request_time();
} else {
struct timeval tp = {0};
if (!gettimeofday(&tp, NULL)) {
@@ -1089,9 +1090,9 @@ SAPI_API double sapi_get_request_time(TSRMLS_D)
return SG(global_request_time);
}
-SAPI_API void sapi_terminate_process(TSRMLS_D) {
+SAPI_API void sapi_terminate_process(void) {
if (sapi_module.terminate_process) {
- sapi_module.terminate_process(TSRMLS_C);
+ sapi_module.terminate_process();
}
}