diff options
author | Zeev Suraski <zeev@php.net> | 2001-07-28 11:36:37 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2001-07-28 11:36:37 +0000 |
commit | d87cc976e1156b839fc6d4aa6b473a126802b8e3 (patch) | |
tree | 8acb068dd7458e1c8df3a7d8ecb87d065990fdb1 /sapi | |
parent | b4f3b9d3ce9f55cf040fb5aa8f201c64646cab43 (diff) | |
download | php-git-d87cc976e1156b839fc6d4aa6b473a126802b8e3.tar.gz |
Redesigned thread safety mechanism - nua nua
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/aolserver/aolserver.c | 57 | ||||
-rw-r--r-- | sapi/apache/mod_php4.c | 66 | ||||
-rw-r--r-- | sapi/apache/mod_php4.h | 6 | ||||
-rw-r--r-- | sapi/apache/php_apache.c | 24 | ||||
-rw-r--r-- | sapi/apache/sapi_apache.c | 8 | ||||
-rw-r--r-- | sapi/apache2filter/php_functions.c | 4 | ||||
-rw-r--r-- | sapi/apache2filter/sapi_apache2.c | 46 | ||||
-rw-r--r-- | sapi/caudium/caudium.c | 89 | ||||
-rw-r--r-- | sapi/cgi/cgi_main.c | 35 | ||||
-rw-r--r-- | sapi/fastcgi/fastcgi.c | 34 | ||||
-rw-r--r-- | sapi/isapi/php4isapi.c | 87 | ||||
-rw-r--r-- | sapi/nsapi/nsapi.c | 38 | ||||
-rw-r--r-- | sapi/phttpd/phttpd.c | 51 | ||||
-rw-r--r-- | sapi/pi3web/pi3web_sapi.c | 35 | ||||
-rw-r--r-- | sapi/roxen/roxen.c | 37 | ||||
-rw-r--r-- | sapi/servlet/servlet.c | 19 | ||||
-rw-r--r-- | sapi/thttpd/thttpd.c | 105 | ||||
-rw-r--r-- | sapi/tux/php_tux.c | 77 |
18 files changed, 386 insertions, 432 deletions
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c index 55b74b0233..6f620a3a9e 100644 --- a/sapi/aolserver/aolserver.c +++ b/sapi/aolserver/aolserver.c @@ -54,12 +54,7 @@ int Ns_ModuleVersion = 1; -#define NSLS_D ns_globals_struct *ns_context -#define NSLS_DC , NSLS_D -#define NSLS_C ns_context -#define NSLS_CC , NSLS_C -#define NSG(v) (ns_context->v) -#define NSLS_FETCH() ns_globals_struct *ns_context = ts_resource(ns_globals_id) +#define NSG(v) TSRMG(ns_globals_id, ns_globals_struct *, v) /* php_ns_context is per-server (thus only once at all) */ @@ -95,7 +90,7 @@ php_ns_sapi_ub_write(const char *str, uint str_length) { int n; uint sent = 0; - NSLS_FETCH(); + TSRMLS_FETCH(); while (str_length > 0) { n = Ns_ConnWrite(NSG(conn), (void *) str, str_length); @@ -117,11 +112,11 @@ php_ns_sapi_ub_write(const char *str, uint str_length) */ static int -php_ns_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC) +php_ns_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers) { char *header_name, *header_content; char *p; - NSLS_FETCH(); + TSRMLS_FETCH(); header_name = sapi_header->header; header_content = p = strchr(header_name, ':'); @@ -152,9 +147,9 @@ php_ns_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct */ static int -php_ns_sapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +php_ns_sapi_send_headers(sapi_headers_struct *sapi_headers) { - NSLS_FETCH(); + TSRMLS_FETCH(); if(SG(sapi_headers).send_default_content_type) { Ns_ConnSetRequiredHeaders(NSG(conn), "text/html", 0); @@ -171,11 +166,11 @@ php_ns_sapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) */ static int -php_ns_sapi_read_post(char *buf, uint count_bytes SLS_DC) +php_ns_sapi_read_post(char *buf, uint count_bytes) { uint max_read; uint total_read = 0; - NSLS_FETCH(); + TSRMLS_FETCH(); max_read = MIN(NSG(data_avail), count_bytes); @@ -196,11 +191,11 @@ php_ns_sapi_read_post(char *buf, uint count_bytes SLS_DC) */ static char * -php_ns_sapi_read_cookies(SLS_D) +php_ns_sapi_read_cookies() { int i; char *http_cookie = NULL; - NSLS_FETCH(); + TSRMLS_FETCH(); i = Ns_SetIFind(NSG(conn->headers), "cookie"); if(i != -1) { @@ -215,7 +210,7 @@ static void php_info_aolserver(ZEND_MODULE_INFO_FUNC_ARGS) char buf[512]; int uptime = Ns_InfoUptime(); int i; - NSLS_FETCH(); + TSRMLS_FETCH(); php_info_print_table_start(); php_info_print_table_row(2, "SAPI module version", "$Id$"); @@ -272,7 +267,7 @@ static zend_module_entry php_aolserver_module = { PHP_FUNCTION(getallheaders) { int i; - NSLS_FETCH(); + TSRMLS_FETCH(); if (array_init(return_value) == FAILURE) { RETURN_FALSE; @@ -305,18 +300,18 @@ php_ns_startup(sapi_module_struct *sapi_module) */ #define ADD_STRINGX(name,buf) \ - php_register_variable(name, buf, track_vars_array TSRMLS_CC PLS_CC) + php_register_variable(name, buf, track_vars_array TSRMLS_CC) #define ADD_STRING(name) \ ADD_STRINGX(name, buf) static void -php_ns_sapi_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +php_ns_sapi_register_variables(zval *track_vars_array TSRMLS_DC) { int i; char buf[NS_BUF_SIZE + 1]; char *tmp; - NSLS_FETCH(); + TSRMLS_FETCH(); for(i = 0; i < Ns_SetSize(NSG(conn->headers)); i++) { char *key = Ns_SetKey(NSG(conn->headers), i); @@ -414,12 +409,11 @@ static sapi_module_struct aolserver_sapi_module = { */ static int -php_ns_module_main(NSLS_D SLS_DC) +php_ns_module_main(TSRMLS_D) { zend_file_handle file_handle; - CLS_FETCH(); TSRMLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); file_handle.type = ZEND_HANDLE_FILENAME; file_handle.filename = SG(request_info).path_translated; @@ -427,11 +421,11 @@ php_ns_module_main(NSLS_D SLS_DC) file_handle.opened_path = NULL; php_ns_config(global_context, 0); - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC) == FAILURE) { + if (php_request_startup(TSRMLS_C) == FAILURE) { return NS_ERROR; } - php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + php_execute_script(&file_handle TSRMLS_CC); php_request_shutdown(NULL); return NS_OK; @@ -443,7 +437,7 @@ php_ns_module_main(NSLS_D SLS_DC) */ static void -php_ns_request_ctor(NSLS_D SLS_DC) +php_ns_request_ctor(TSRMLS_D) { char *server; Ns_DString ds; @@ -490,7 +484,7 @@ php_ns_request_ctor(NSLS_D SLS_DC) */ static void -php_ns_request_dtor(NSLS_D SLS_DC) +php_ns_request_dtor(TSRMLS_D) { free(SG(request_info).path_translated); if (SG(request_info).query_string) @@ -507,18 +501,17 @@ static int php_ns_request_handler(void *context, Ns_Conn *conn) { int status = NS_OK; - SLS_FETCH(); - NSLS_FETCH(); + TSRMLS_FETCH(); NSG(conn) = conn; SG(server_context) = global_context; - php_ns_request_ctor(NSLS_C SLS_CC); + php_ns_request_ctor(TSRMLS_C); - status = php_ns_module_main(NSLS_C SLS_CC); + status = php_ns_module_main(TSRMLS_C); - php_ns_request_dtor(NSLS_C SLS_CC); + php_ns_request_dtor(TSRMLS_C); return status; } diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c index 0a17b61721..a38cc94735 100644 --- a/sapi/apache/mod_php4.c +++ b/sapi/apache/mod_php4.c @@ -64,13 +64,13 @@ /* {{{ Prototypes */ -int apache_php_module_main(request_rec *r, int display_source_mode CLS_DC TSRMLS_DC PLS_DC SLS_DC); +int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC); void php_save_umask(void); void php_restore_umask(void); -int sapi_apache_read_post(char *buffer, uint count_bytes SLS_DC); -char *sapi_apache_read_cookies(SLS_D); -int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC); -int sapi_apache_send_headers(sapi_headers_struct *sapi_headers SLS_DC); +int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC); +char *sapi_apache_read_cookies(TSRMLS_D); +int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC); +int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC); static int send_php(request_rec *r, int display_source_mode, char *filename); static int send_parsed_php(request_rec * r); static int send_parsed_php_source(request_rec * r); @@ -127,7 +127,7 @@ void php_save_umask(void) static int sapi_apache_ub_write(const char *str, uint str_length) { int ret=0; - SLS_FETCH(); + TSRMLS_FETCH(); if (SG(server_context)) { ret = rwrite(str, str_length, (request_rec *) SG(server_context)); @@ -155,7 +155,7 @@ static void sapi_apache_flush(void *server_context) /* {{{ sapi_apache_read_post */ -int sapi_apache_read_post(char *buffer, uint count_bytes SLS_DC) +int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC) { uint total_read_bytes=0, read_bytes; request_rec *r = (request_rec *) SG(server_context); @@ -178,7 +178,7 @@ int sapi_apache_read_post(char *buffer, uint count_bytes SLS_DC) /* {{{ sapi_apache_read_cookies */ -char *sapi_apache_read_cookies(SLS_D) +char *sapi_apache_read_cookies(TSRMLS_D) { return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, "HTTP_COOKIE"); } @@ -186,7 +186,7 @@ char *sapi_apache_read_cookies(SLS_D) /* {{{ sapi_apache_header_handler */ -int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC) +int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) { char *header_name, *header_content, *p; request_rec *r = (request_rec *) SG(server_context); @@ -221,7 +221,7 @@ int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_str /* {{{ sapi_apache_send_headers */ -int sapi_apache_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { if(SG(server_context) == NULL) { /* server_context is not here anymore */ return SAPI_HEADER_SEND_FAILED; @@ -235,7 +235,7 @@ int sapi_apache_send_headers(sapi_headers_struct *sapi_headers SLS_DC) /* {{{ sapi_apache_register_server_variables */ -static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_DC) { register int i; array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env); @@ -251,7 +251,7 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_ } else { val = empty_string; } - php_register_variable(elts[i].key, val, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable(elts[i].key, val, track_vars_array TSRMLS_CC); } /* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */ @@ -266,10 +266,10 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_ if (symbol_table && !zend_hash_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")) && zend_hash_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &path_translated)==SUCCESS) { - php_register_variable("PATH_TRANSLATED", Z_STRVAL_PP(path_translated), track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("PATH_TRANSLATED", Z_STRVAL_PP(path_translated), track_vars_array TSRMLS_CC); } - php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array TSRMLS_CC); } /* }}} */ @@ -290,7 +290,7 @@ static int php_apache_startup(sapi_module_struct *sapi_module) */ static void php_apache_log_message(char *message) { - SLS_FETCH(); + TSRMLS_FETCH(); if (SG(server_context)) { #if MODULE_MAGIC_NUMBER >= 19970831 @@ -309,8 +309,8 @@ static void php_apache_log_message(char *message) */ static void php_apache_request_shutdown(void *dummy) { - SLS_FETCH(); - APLS_FETCH(); + TSRMLS_FETCH(); + TSRMLS_FETCH(); php_output_set_status(0); SG(server_context) = NULL; /* The server context (request) is invalid by the time run_cleanups() is called */ @@ -323,10 +323,10 @@ static void php_apache_request_shutdown(void *dummy) /* {{{ php_apache_sapi_activate */ -static int php_apache_sapi_activate(SLS_D) +static int php_apache_sapi_activate(TSRMLS_D) { request_rec *r = (request_rec *) SG(server_context); - APLS_FETCH(); + TSRMLS_FETCH(); /* * For the Apache module version, this bit of code registers a cleanup @@ -351,7 +351,7 @@ static int php_apache_sapi_activate(SLS_D) /* {{{ php_apache_get_stat */ -static struct stat *php_apache_get_stat(SLS_D) +static struct stat *php_apache_get_stat(TSRMLS_D) { return &((request_rec *) SG(server_context))->finfo; } @@ -359,7 +359,7 @@ static struct stat *php_apache_get_stat(SLS_D) /* {{{ php_apache_getenv */ -static char *php_apache_getenv(char *name, size_t name_len SLS_DC) +static char *php_apache_getenv(char *name, size_t name_len TSRMLS_DC) { return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, name); } @@ -418,7 +418,7 @@ void php_restore_umask(void) /* {{{ init_request_info */ -static void init_request_info(SLS_D) +static void init_request_info(TSRMLS_D) { request_rec *r = ((request_rec *) SG(server_context)); char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH"); @@ -468,7 +468,7 @@ static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry) /* {{{ php_apache_get_default_mimetype */ -static char *php_apache_get_default_mimetype(request_rec *r SLS_DC) +static char *php_apache_get_default_mimetype(request_rec *r TSRMLS_DC) { char *mimetype; @@ -476,7 +476,7 @@ static char *php_apache_get_default_mimetype(request_rec *r SLS_DC) /* Assume output will be of the default MIME type. Individual scripts may change this later. */ char *tmpmimetype; - tmpmimetype = sapi_get_default_content_type(SLS_C); + tmpmimetype = sapi_get_default_content_type(TSRMLS_C); mimetype = pstrdup(r->pool, tmpmimetype); efree(tmpmimetype); } else { @@ -492,11 +492,9 @@ static int send_php(request_rec *r, int display_source_mode, char *filename) { int retval; HashTable *per_dir_conf; - SLS_FETCH(); TSRMLS_FETCH(); - CLS_FETCH(); - PLS_FETCH(); - APLS_FETCH(); + TSRMLS_FETCH(); + TSRMLS_FETCH(); if (AP(in_request)) { zend_file_handle fh; @@ -505,7 +503,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename) fh.opened_path = NULL; fh.free_filename = 0; fh.type = ZEND_HANDLE_FILENAME; - zend_execute_scripts(ZEND_INCLUDE CLS_CC TSRMLS_CC, 1, &fh); + zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, 1, &fh); return OK; } @@ -530,7 +528,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename) * directive, then decline to handle this request */ if (!AP(engine)) { - r->content_type = php_apache_get_default_mimetype(r SLS_CC); + r->content_type = php_apache_get_default_mimetype(r TSRMLS_CC); r->allowed |= (1 << METHODS) - 1; zend_try { zend_ini_deactivate(TSRMLS_C); @@ -567,7 +565,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename) } /* Assume output will be of the default MIME type. Individual scripts may change this later in the request. */ - r->content_type = php_apache_get_default_mimetype(r SLS_CC); + r->content_type = php_apache_get_default_mimetype(r TSRMLS_CC); /* Init timeout */ hard_timeout("send", r); @@ -578,8 +576,8 @@ static int send_php(request_rec *r, int display_source_mode, char *filename) add_common_vars(r); add_cgi_vars(r); - init_request_info(SLS_C); - apache_php_module_main(r, display_source_mode CLS_CC TSRMLS_CC PLS_CC SLS_CC); + init_request_info(TSRMLS_C); + apache_php_module_main(r, display_source_mode TSRMLS_CC); /* Done, restore umask, turn off timeout, close file and return */ php_restore_umask(); @@ -843,7 +841,7 @@ void php_init_handler(server_rec *s, pool *p) } #if MODULE_MAGIC_NUMBER >= 19980527 { - PLS_FETCH(); + TSRMLS_FETCH(); if (PG(expose_php)) { ap_add_version_component("PHP/" PHP_VERSION); } diff --git a/sapi/apache/mod_php4.h b/sapi/apache/mod_php4.h index c70d09a5a8..92229e8cf3 100644 --- a/sapi/apache/mod_php4.h +++ b/sapi/apache/mod_php4.h @@ -38,14 +38,10 @@ extern zend_module_entry apache_module_entry; #ifdef ZTS extern int php_apache_info_id; -#define APLS_D php_apache_info_struct *apache_globals -#define AP(v) (apache_globals->v) -#define APLS_FETCH() APLS_D = ts_resource(php_apache_info_id) +#define AP(v) TSRMG(alloc_globals_id, php_apache_info_struct *, v) #else extern php_apache_info_struct php_apache_info; -#define APLS_D #define AP(v) (php_apache_info.v) -#define APLS_FETCH() #endif diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c index fd0270414a..cfc63ae639 100644 --- a/sapi/apache/php_apache.c +++ b/sapi/apache/php_apache.c @@ -90,7 +90,7 @@ PHP_INI_END() -static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRMLS_DC) +static void php_apache_globals_ctor(php_apache_info_struct *apache_globals_p TSRMLS_DC) { apache_globals->in_request = 0; } @@ -124,8 +124,8 @@ zend_module_entry apache_module_entry = { PHP_FUNCTION(apache_child_terminate) { #ifndef MULTITHREAD - APLS_FETCH(); - SLS_FETCH(); + ATSRMLS_FETCH(); + TSRMLS_FETCH(); if (AP(terminate_child)) { ap_child_terminate( ((request_rec *)SG(server_context)) ); @@ -145,7 +145,7 @@ PHP_FUNCTION(apache_note) pval **arg_name,**arg_val; char *note_val; int arg_count = ARG_COUNT(ht); - SLS_FETCH(); + TSRMLS_FETCH(); if (arg_count<1 || arg_count>2 || zend_get_parameters_ex(arg_count,&arg_name,&arg_val) ==FAILURE ) { @@ -185,7 +185,7 @@ PHP_MINFO_FUNCTION(apache) extern char *user_name; extern gid_t group_id; extern int max_requests_per_child; - SLS_FETCH(); + TSRMLS_FETCH(); serv = ((request_rec *) SG(server_context))->server; @@ -245,7 +245,7 @@ PHP_MINFO_FUNCTION(apache) array_header *arr; table_entry *elts; request_rec *r; - SLS_FETCH(); + TSRMLS_FETCH(); r = ((request_rec *) SG(server_context)); arr = table_elts(r->subprocess_env); @@ -265,7 +265,7 @@ PHP_MINFO_FUNCTION(apache) table_entry *env; int i; request_rec *r; - SLS_FETCH(); + TSRMLS_FETCH(); r = ((request_rec *) SG(server_context)); SECTION("HTTP Headers Information"); @@ -306,7 +306,7 @@ PHP_FUNCTION(virtual) { pval **filename; request_rec *rr = NULL; - SLS_FETCH(); + TSRMLS_FETCH(); if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1,&filename) == FAILURE) { WRONG_PARAM_COUNT; @@ -346,8 +346,8 @@ PHP_FUNCTION(getallheaders) array_header *env_arr; table_entry *tenv; int i; - SLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); + TSRMLS_FETCH(); if (array_init(return_value) == FAILURE) { RETURN_FALSE; @@ -373,7 +373,7 @@ PHP_FUNCTION(apache_lookup_uri) { pval **filename; request_rec *rr=NULL; - SLS_FETCH(); + TSRMLS_FETCH(); if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1,&filename) == FAILURE) { WRONG_PARAM_COUNT; @@ -448,7 +448,7 @@ PHP_FUNCTION(apache_exec_uri) { pval **filename; request_rec *rr=NULL; - SLS_FETCH(); + TSRMLS_FETCH(); if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1,&filename) == FAILURE) { WRONG_PARAM_COUNT; diff --git a/sapi/apache/sapi_apache.c b/sapi/apache/sapi_apache.c index 1ad8807f9d..e34f6701f9 100644 --- a/sapi/apache/sapi_apache.c +++ b/sapi/apache/sapi_apache.c @@ -60,12 +60,12 @@ /* {{{ apache_php_module_main */ -int apache_php_module_main(request_rec *r, int display_source_mode CLS_DC TSRMLS_DC PLS_DC SLS_DC) +int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC TSRMLS_DC) { zend_file_handle file_handle; - APLS_FETCH(); + TSRMLS_FETCH(); - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC) == FAILURE) { + if (php_request_startup(TSRMLS_C) == FAILURE) { return FAILURE; } /* sending a file handle to another dll is not working @@ -88,7 +88,7 @@ int apache_php_module_main(request_rec *r, int display_source_mode CLS_DC TSRMLS file_handle.opened_path = NULL; file_handle.free_filename = 0; - (void) php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + (void) php_execute_script(&file_handle TSRMLS_CC); } AP(in_request) = 0; diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c index 2679c38488..7d1aa1bd08 100644 --- a/sapi/apache2filter/php_functions.c +++ b/sapi/apache2filter/php_functions.c @@ -38,7 +38,7 @@ static request_rec *php_apache_lookup_uri(INTERNAL_FUNCTION_PARAMETERS) { zval **p1; php_struct *ctx; - SLS_FETCH(); + TSRMLS_FETCH(); if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &p1) == FAILURE) return NULL; @@ -110,7 +110,7 @@ PHP_FUNCTION(get_all_headers) php_struct *ctx; apr_array_header_t *arr; char *key, *val; - SLS_FETCH(); + TSRMLS_FETCH(); if (array_init(return_value) == FAILURE) { RETURN_FALSE; diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index 03a2ed90b9..8d47b8a29f 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -50,7 +50,7 @@ php_apache_sapi_ub_write(const char *str, uint str_length) apr_bucket_brigade *bb; php_struct *ctx; uint now; - SLS_FETCH(); + TSRMLS_FETCH(); ctx = SG(server_context); @@ -72,7 +72,7 @@ php_apache_sapi_ub_write(const char *str, uint str_length) } static int -php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC) +php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) { php_struct *ctx = SG(server_context); char *val; @@ -100,7 +100,7 @@ php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_str } static int -php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { php_struct *ctx = SG(server_context); @@ -110,7 +110,7 @@ php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) } static int -php_apache_sapi_read_post(char *buf, uint count_bytes SLS_DC) +php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) { int n; int to_read; @@ -131,7 +131,7 @@ php_apache_sapi_read_post(char *buf, uint count_bytes SLS_DC) } static char * -php_apache_sapi_read_cookies(SLS_D) +php_apache_sapi_read_cookies(TSRMLS_D) { php_struct *ctx = SG(server_context); const char *http_cookie; @@ -143,7 +143,7 @@ php_apache_sapi_read_cookies(SLS_D) } static void -php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC TSRMLS_DC TSRMLS_DC) { php_struct *ctx = SG(server_context); apr_array_header_t *arr = apr_table_elts(ctx->f->r->subprocess_env); @@ -151,10 +151,10 @@ php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_D APR_ARRAY_FOREACH_OPEN(arr, key, val) if (!val) val = empty_string; - php_register_variable(key, val, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable(key, val, track_vars_array TSRMLS_CC); APR_ARRAY_FOREACH_CLOSE() - php_register_variable("PHP_SELF", ctx->f->r->uri, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("PHP_SELF", ctx->f->r->uri, track_vars_array TSRMLS_CC); } static void @@ -180,7 +180,7 @@ php_apache_sapi_flush(void *server_context) static void php_apache_sapi_log_message(char *msg) { php_struct *ctx; - SLS_FETCH(); + TSRMLS_FETCH(); ctx = SG(server_context); @@ -239,7 +239,7 @@ static int php_input_filter(ap_filter_t *f, apr_bucket_brigade *bb, const char *str; apr_ssize_t n; apr_status_t rv; - SLS_FETCH(); + TSRMLS_FETCH(); ctx = SG(server_context); @@ -261,13 +261,12 @@ static int php_input_filter(ap_filter_t *f, apr_bucket_brigade *bb, return APR_SUCCESS; } -static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx SLS_DC) +static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx TSRMLS_DC) { char *content_type; const char *auth; - CLS_FETCH(); TSRMLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); PG(during_request_startup) = 0; SG(sapi_headers).http_response_code = 200; @@ -278,7 +277,7 @@ static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx SLS_DC) SG(request_info).request_method = f->r->method; SG(request_info).request_uri = safe_strdup(f->r->uri); f->r->no_local_copy = 1; - content_type = sapi_get_default_content_type(SLS_C); + content_type = sapi_get_default_content_type(TSRMLS_C); f->r->content_type = apr_pstrdup(f->r->pool, content_type); SG(request_info).post_data = ctx->post_data; SG(request_info).post_data_length = ctx->post_len; @@ -289,12 +288,12 @@ static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx SLS_DC) apr_table_unset(f->r->headers_out, "ETag"); apr_table_unset(f->r->headers_in, "Connection"); auth = apr_table_get(f->r->headers_in, "Authorization"); - php_handle_auth_data(auth SLS_CC); + php_handle_auth_data(auth TSRMLS_CC); - php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC); + php_request_startup(TSRMLS_C); } -static void php_apache_request_dtor(ap_filter_t *f SLS_DC) +static void php_apache_request_dtor(ap_filter_t *f TSRMLS_DC) { php_request_shutdown(NULL); @@ -309,7 +308,7 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) php_struct *ctx; apr_bucket *b; void *conf = ap_get_module_config(f->r->per_dir_config, &php4_module); - SLS_FETCH(); + TSRMLS_FETCH(); ctx = SG(server_context); INIT_CTX; @@ -327,7 +326,7 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) ctx->state++; - php_apache_request_ctor(f, ctx SLS_CC); + php_apache_request_ctor(f, ctx TSRMLS_CC); } /* moves all buckets from bb to ctx->bb */ @@ -339,9 +338,8 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) if (ctx->state == 1 && APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(ctx->bb))) { zend_file_handle zfd; apr_bucket *eos; - CLS_FETCH(); TSRMLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); /* We want to execute only one script per request. * A bug in Apache or other filters could cause us @@ -351,7 +349,7 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) ctx->state = 2; /* Handle phpinfo/phpcredits/built-in images */ - if (!php_handle_special_queries(SLS_C PLS_CC)) { + if (!php_handle_special_queries(TSRMLS_C)) { b = APR_BRIGADE_FIRST(ctx->bb); @@ -365,7 +363,7 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) zfd.free_filename = 0; zfd.opened_path = NULL; - php_execute_script(&zfd CLS_CC TSRMLS_CC PLS_CC); + php_execute_script(&zfd TSRMLS_CC); } else { #define NO_DATA "The PHP Filter did not receive suitable input data" @@ -375,7 +373,7 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) } } - php_apache_request_dtor(f SLS_CC); + php_apache_request_dtor(f TSRMLS_CC); SG(server_context) = 0; /* Pass EOS bucket to next filter to signal end of request */ diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c index 4c1cc60f38..356a6ee978 100644 --- a/sapi/caudium/caudium.c +++ b/sapi/caudium/caudium.c @@ -92,13 +92,13 @@ typedef struct struct pike_string *filename; int my_fd; int written; - SLS_D; + TSRMLS_D; } php_caudium_request; void pike_module_init(void); void pike_module_exit(void); -static void free_struct(SLS_D); +static void free_struct(TSRMLS_D); void f_php_caudium_request_handler(INT32 args); /* Defines to get to the data supplied when the script is started. */ @@ -207,7 +207,7 @@ INLINE static int php_caudium_low_ub_write(const char *str, uint str_length) { int sent_bytes = 0; struct pike_string *to_write = NULL; - PLS_FETCH(); + TSRMLS_FETCH(); GET_THIS(); if(!MY_FD_OBJ->prog) { PG(connection_status) = PHP_CONNECTION_ABORTED; @@ -237,7 +237,7 @@ php_caudium_low_ub_write(const char *str, uint str_length) { static int php_caudium_sapi_ub_write(const char *str, uint str_length) { - PLS_FETCH(); + TSRMLS_FETCH(); GET_THIS(); int sent_bytes = 0, fd = MY_FD; if(fd) @@ -332,7 +332,7 @@ php_caudium_set_header(char *header_name, char *value, char *p) */ static int php_caudium_sapi_header_handler(sapi_header_struct *sapi_header, - sapi_headers_struct *sapi_headers SLS_DC) + sapi_headers_struct *sapi_headers TSRMLS_DC) { char *header_name, *header_content, *p; header_name = sapi_header->header; @@ -354,9 +354,9 @@ php_caudium_sapi_header_handler(sapi_header_struct *sapi_header, */ INLINE static int -php_caudium_low_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +php_caudium_low_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { - PLS_FETCH(); + TSRMLS_FETCH(); struct pike_string *ind; struct svalue *s_headermap; GET_THIS(); @@ -381,10 +381,10 @@ php_caudium_low_send_headers(sapi_headers_struct *sapi_headers SLS_DC) } static int -php_caudium_sapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +php_caudium_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { int res = 0; - THREAD_SAFE_RUN(res = php_caudium_low_send_headers(sapi_headers SLS_CC), "send headers"); + THREAD_SAFE_RUN(res = php_caudium_low_send_headers(sapi_headers TSRMLS_CC), "send headers"); return res; } @@ -397,7 +397,7 @@ INLINE static int php_caudium_low_read_post(char *buf, uint count_bytes) { uint total_read = 0; GET_THIS(); - PLS_FETCH(); + TSRMLS_FETCH(); if(!MY_FD_OBJ->prog) { @@ -418,7 +418,7 @@ INLINE static int php_caudium_low_read_post(char *buf, uint count_bytes) } static int -php_caudium_sapi_read_post(char *buf, uint count_bytes SLS_DC) +php_caudium_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) { uint total_read = 0; THREAD_SAFE_RUN(total_read = php_caudium_low_read_post(buf, count_bytes), "read post"); @@ -431,7 +431,7 @@ php_caudium_sapi_read_post(char *buf, uint count_bytes SLS_DC) */ static char * -php_caudium_sapi_read_cookies(SLS_D) +php_caudium_sapi_read_cookies(TSRMLS_D) { char *cookies; cookies = lookup_string_header("HTTP_COOKIE", NULL); @@ -474,55 +474,55 @@ static zend_module_entry php_caudium_module = { }; -INLINE static void low_sapi_caudium_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +INLINE static void low_sapi_caudium_register_variables(zval *track_vars_array TSRMLS_DC TSRMLS_DC TSRMLS_DC) { char *tmp; php_register_variable("PHP_SELF", SG(request_info).request_uri, - track_vars_array TSRMLS_CC PLS_CC); + track_vars_array TSRMLS_CC); php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", - track_vars_array TSRMLS_CC PLS_CC); + track_vars_array TSRMLS_CC); php_register_variable("REQUEST_METHOD", (char *) SG(request_info).request_method, - track_vars_array TSRMLS_CC PLS_CC); + track_vars_array TSRMLS_CC); php_register_variable("REQUEST_URI", SG(request_info).request_uri, - track_vars_array TSRMLS_CC PLS_CC); + track_vars_array TSRMLS_CC); php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, - track_vars_array TSRMLS_CC PLS_CC); + track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("SERVER_NAME", NULL)) != NULL) - php_register_variable("SERVER_NAME", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("SERVER_NAME", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("SERVER_PORT", NULL)) != NULL) - php_register_variable("SERVER_PORT", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("SERVER_PORT", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("SERVER_PROTOCOL", NULL)) != NULL) - php_register_variable("SERVER_PROTOCOL", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("SERVER_PROTOCOL", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("SCRIPT_NAME", NULL)) != NULL) - php_register_variable("SCRIPT_NAME", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("SCRIPT_NAME", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("SCRIPT_FILENAME", NULL)) != NULL) - php_register_variable("SCRIPT_FILENAME", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("SCRIPT_FILENAME", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("REMOTE_ADDR", NULL)) != NULL) - php_register_variable("REMOTE_ADDR", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("REMOTE_ADDR", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("REMOTE_PORT", NULL)) != NULL) - php_register_variable("REMOTE_PORT", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("REMOTE_PORT", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("DOCUMENT_ROOT", NULL)) != NULL) - php_register_variable("DOCUMENT_ROOT", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("DOCUMENT_ROOT", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("HTTP_CONNECTION", NULL)) != NULL) - php_register_variable("HTTP_CONNECTION", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("HTTP_CONNECTION", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("HTTP_USER_AGENT", NULL)) != NULL) - php_register_variable("HTTP_USER_AGENT", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("HTTP_USER_AGENT", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("DOCUMENT_ROOT", NULL)) != NULL) - php_register_variable("DOCUMENT_ROOT", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("DOCUMENT_ROOT", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("QUERY_STRING", "")) != NULL) - php_register_variable("QUERY_STRING", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("QUERY_STRING", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("REMOTE_USER", NULL)) != NULL) - php_register_variable("REMOTE_USER", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("REMOTE_USER", tmp, track_vars_array TSRMLS_CC); if( (tmp = lookup_string_header("REMOTE_PASSWORD", NULL)) != NULL) - php_register_variable("REMOTE_PASSWORD", tmp, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("REMOTE_PASSWORD", tmp, track_vars_array TSRMLS_CC); } -static void sapi_caudium_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +static void sapi_caudium_register_variables(zval *track_vars_array TSRMLS_DC TSRMLS_DC TSRMLS_DC) { - THREAD_SAFE_RUN(low_sapi_caudium_register_variables(track_vars_array TSRMLS_CC SLS_CC PLS_CC), "register_variables"); + THREAD_SAFE_RUN(low_sapi_caudium_register_variables(track_vars_array TSRMLS_CC TSRMLS_CC TSRMLS_CC), "register_variables"); } /* this structure is static (as in "it does not change") */ @@ -556,7 +556,7 @@ static sapi_module_struct caudium_sapi_module = { * with a number of variables. HTTP_* variables are created for * the HTTP header data, so that a script can access these. */ -static void php_caudium_hash_environment(CLS_D TSRMLS_DC PLS_DC SLS_DC) +static void php_caudium_hash_environment(TSRMLS_D) { int i; char buf[512]; @@ -612,9 +612,8 @@ static void php_caudium_module_main(php_caudium_request *ureq) struct thread_state *state; extern struct program *thread_id_prog; #endif - SLS_FETCH(); - CLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); + TSRMLS_FETCH(); TSRMLS_FETCH(); GET_THIS(); THIS->filename = ureq->filename; @@ -673,7 +672,7 @@ static void php_caudium_module_main(php_caudium_request *ureq) } /* Let PHP4 handle the deconding of the AUTH */ - php_handle_auth_data(lookup_string_header("HTTP_AUTHORIZATION", NULL), SLS_C); + php_handle_auth_data(lookup_string_header("HTTP_AUTHORIZATION", NULL), TSRMLS_C); /* Swap out this thread and release the interpreter lock to allow * Pike threads to run. We wait since the above would otherwise require * a lot of unlock/lock. @@ -700,24 +699,24 @@ static void php_caudium_module_main(php_caudium_request *ureq) file_handle.free_filename = 0; THIS->written = 0; - res = php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC); + res = php_request_startup(TSRMLS_C); if(res == FAILURE) { THREAD_SAFE_RUN({ apply_svalue(&THIS->done_cb, 0); pop_stack(); - free_struct(SLS_C); + free_struct(TSRMLS_C); }, "Negative run response"); } else { - THREAD_SAFE_RUN(php_caudium_hash_environment(CLS_C TSRMLS_CC PLS_CC SLS_CC), + THREAD_SAFE_RUN(php_caudium_hash_environment(TSRMLS_C), "environment hashing"); - php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + php_execute_script(&file_handle TSRMLS_CC); php_request_shutdown(NULL); THREAD_SAFE_RUN({ push_int(THIS->written); apply_svalue(&THIS->done_cb, 1); pop_stack(); - free_struct(SLS_C); + free_struct(TSRMLS_C); }, "positive run response"); } @@ -795,7 +794,7 @@ void f_php_caudium_request_handler(INT32 args) pop_n_elems(args); } -static void free_struct(SLS_D) +static void free_struct(TSRMLS_D) { GET_THIS(); if(THIS->request_data) free_mapping(THIS->request_data); diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 26378b7639..e58c7be8ae 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -144,7 +144,7 @@ static void sapi_cgi_send_header(sapi_header_struct *sapi_header, void *server_c } -static int sapi_cgi_read_post(char *buffer, uint count_bytes SLS_DC) +static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) { uint read_bytes=0, tmp_read_bytes; @@ -160,21 +160,21 @@ static int sapi_cgi_read_post(char *buffer, uint count_bytes SLS_DC) } -static char *sapi_cgi_read_cookies(SLS_D) +static char *sapi_cgi_read_cookies(TSRMLS_D) { return getenv("HTTP_COOKIE"); } -static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC) { /* In CGI mode, we consider the environment to be a part of the server * variables */ - php_import_environment_variables(track_vars_array TSRMLS_CC PLS_CC); + php_import_environment_variables(track_vars_array TSRMLS_CC); /* Build the special-case PHP_SELF variable for the CGI version */ - php_register_variable("PHP_SELF", (SG(request_info).request_uri ? SG(request_info).request_uri:""), track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("PHP_SELF", (SG(request_info).request_uri ? SG(request_info).request_uri:""), track_vars_array TSRMLS_CC); } @@ -186,7 +186,7 @@ static void sapi_cgi_log_message(char *message) } } -static int sapi_cgi_deactivate(SLS_D) +static int sapi_cgi_deactivate(TSRMLS_D) { fflush(stdout); if(SG(request_info).argv0) { @@ -266,7 +266,7 @@ static void php_cgi_usage(char *argv0) /* {{{ init_request_info */ -static void init_request_info(SLS_D) +static void init_request_info(TSRMLS_D) { char *content_length = getenv("CONTENT_LENGTH"); char *content_type = getenv("CONTENT_TYPE"); @@ -324,7 +324,7 @@ static void init_request_info(SLS_D) /* The CGI RFC allows servers to pass on unvalidated Authorization data */ auth = getenv("HTTP_AUTHORIZATION"); - php_handle_auth_data(auth SLS_CC); + php_handle_auth_data(auth TSRMLS_CC); } /* }}} */ @@ -348,7 +348,6 @@ static void php_register_command_line_global_vars(char **arg) { char *var, *val; TSRMLS_FETCH(); - PLS_FETCH(); var = *arg; val = strchr(var, '='); @@ -356,7 +355,7 @@ static void php_register_command_line_global_vars(char **arg) printf("No value specified for variable '%s'\n", var); } else { *val++ = '\0'; - php_register_variable(var, val, NULL TSRMLS_CC PLS_CC); + php_register_variable(var, val, NULL TSRMLS_CC); } efree(*arg); } @@ -506,7 +505,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine ap_php_optarg = orig_optarg; } - init_request_info(SLS_C); + init_request_info(TSRMLS_C); SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */ CG(extended_info) = 0; @@ -563,7 +562,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine break; case 'i': /* php info & quit */ - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC)==FAILURE) { + if (php_request_startup(TSRMLS_C)==FAILURE) { php_module_shutdown(); return FAILURE; } @@ -610,7 +609,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine case 'v': /* show php version & quit */ no_headers = 1; - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC)==FAILURE) { + if (php_request_startup(TSRMLS_C)==FAILURE) { php_module_shutdown(); return FAILURE; } @@ -667,7 +666,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine SG(request_info).path_translated = script_file; } - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC)==FAILURE) { + if (php_request_startup(TSRMLS_C)==FAILURE) { php_module_shutdown(); return FAILURE; } @@ -734,11 +733,11 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine switch (behavior) { case PHP_MODE_STANDARD: - exit_status = php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + exit_status = php_execute_script(&file_handle TSRMLS_CC); break; case PHP_MODE_LINT: PG(during_request_startup) = 0; - exit_status = php_lint_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + exit_status = php_lint_script(&file_handle TSRMLS_CC); if (exit_status==SUCCESS) { zend_printf("No syntax errors detected in %s\n", file_handle.filename); } else { @@ -749,7 +748,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine { zend_syntax_highlighter_ini syntax_highlighter_ini; - if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) { + if (open_file_for_scanning(&file_handle TSRMLS_CC)==SUCCESS) { php_get_highlight_struct(&syntax_highlighter_ini); zend_highlight(&syntax_highlighter_ini); fclose(file_handle.handle.fp); @@ -760,7 +759,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine #if 0 /* Zeev might want to do something with this one day */ case PHP_MODE_INDENT: - open_file_for_scanning(&file_handle CLS_CC); + open_file_for_scanning(&file_handle TSRMLS_CC); zend_indent(); fclose(file_handle.handle.fp); return SUCCESS; diff --git a/sapi/fastcgi/fastcgi.c b/sapi/fastcgi/fastcgi.c index 344c343c88..c6f1e5bb84 100644 --- a/sapi/fastcgi/fastcgi.c +++ b/sapi/fastcgi/fastcgi.c @@ -59,13 +59,6 @@ #include <signal.h> #endif -#define TLS_D -#define TLS_DC -#define TLS_C -#define TLS_CC -#define TLS_FETCH() - - FCGX_Stream *in, *out, *err; FCGX_ParamArray envp; char *path_info = NULL; @@ -124,12 +117,12 @@ static void sapi_fastcgi_send_header(sapi_header_struct *sapi_header, void *serv FCGX_PutStr( "\r\n", 2, out ); } -static int sapi_fastcgi_read_post(char *buffer, uint count_bytes SLS_DC) +static int sapi_fastcgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) { size_t read_bytes = 0, tmp; int c; char *pos = buffer; - TLS_FETCH(); + TSRMLS_FETCH(); while( count_bytes ) { c = FCGX_GetStr( pos, count_bytes, in ); @@ -141,13 +134,13 @@ static int sapi_fastcgi_read_post(char *buffer, uint count_bytes SLS_DC) return read_bytes; } -static char *sapi_fastcgi_read_cookies(SLS_D) +static char *sapi_fastcgi_read_cookies(TSRMLS_D) { return getenv( "HTTP_COOKIE" ); } -static void sapi_fastcgi_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +static void sapi_fastcgi_register_variables(zval *track_vars_array TSRMLS_DC TSRMLS_DC TSRMLS_DC) { char *self = getenv("REQUEST_URI"); char *ptr = strchr( self, '?' ); @@ -162,7 +155,7 @@ static void sapi_fastcgi_register_variables(zval *track_vars_array TSRMLS_DC SLS /* strip query string off this */ if ( ptr ) *ptr = 0; - php_register_variable( "PHP_SELF", getenv("REQUEST_URI"), track_vars_array TSRMLS_CC PLS_CC); + php_register_variable( "PHP_SELF", getenv("REQUEST_URI"), track_vars_array TSRMLS_CC); if ( ptr ) *ptr = '?'; } @@ -199,26 +192,25 @@ static sapi_module_struct fastcgi_sapi_module = { STANDARD_SAPI_MODULE_PROPERTIES }; -static void fastcgi_module_main(TLS_D SLS_DC) +static void fastcgi_module_main(TSRMLS_D TSRMLS_DC) { zend_file_handle file_handle; - CLS_FETCH(); TSRMLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); file_handle.type = ZEND_HANDLE_FILENAME; file_handle.filename = SG(request_info).path_translated; file_handle.free_filename = 0; file_handle.opened_path = NULL; - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC) == SUCCESS) { - php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + if (php_request_startup(TSRMLS_C) == SUCCESS) { + php_execute_script(&file_handle TSRMLS_CC); php_request_shutdown(NULL); } } -static void init_request_info( SLS_D ) +static void init_request_info( TSRMLS_D ) { char *content_length = getenv("CONTENT_LENGTH"); char *content_type = getenv( "CONTENT_TYPE" ); @@ -275,7 +267,7 @@ static void init_request_info( SLS_D ) #ifdef DEBUG_FASTCGI fprintf( stderr, "Authorization: %s\n", auth ); #endif - php_handle_auth_data(auth SLS_CC); + php_handle_auth_data(auth TSRMLS_CC); } @@ -480,13 +472,13 @@ int main(int argc, char *argv[]) cgi_env, (cgi_env_size+1)*sizeof(char *) ); environ = merge_env; - init_request_info( TLS_C SLS_CC ); + init_request_info(TSRMLS_C); SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */ CG(extended_info) = 0; SG(request_info).argv0 = argv0; zend_llist_init(&global_vars, sizeof(char *), NULL, 0); - fastcgi_module_main( TLS_C SLS_CC ); + fastcgi_module_main(TSRMLS_C); if( path_info ) { free( path_info ); path_info = NULL; diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c index 6074fcb216..8526665233 100644 --- a/sapi/isapi/php4isapi.c +++ b/sapi/isapi/php4isapi.c @@ -156,7 +156,7 @@ static void php_info_isapi(ZEND_MODULE_INFO_FUNC_ARGS) }; char ***server_variable_names; LPEXTENSION_CONTROL_BLOCK lpECB; - SLS_FETCH(); + TSRMLS_FETCH(); lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); @@ -204,7 +204,7 @@ static int sapi_isapi_ub_write(const char *str, uint str_length) { DWORD num_bytes = str_length; LPEXTENSION_CONTROL_BLOCK ecb; - SLS_FETCH(); + TSRMLS_FETCH(); ecb = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); if (ecb->WriteClient(ecb->ConnID, (char *) str, &num_bytes, HSE_IO_SYNC ) == FALSE) { @@ -214,7 +214,7 @@ static int sapi_isapi_ub_write(const char *str, uint str_length) } -static int sapi_isapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC) +static int sapi_isapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) { return SAPI_HEADER_ADD; } @@ -238,7 +238,7 @@ static void concat_header(sapi_header_struct *sapi_header, char **combined_heade } -static int sapi_isapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +static int sapi_isapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { uint total_length = 2; /* account for the trailing \r\n */ char *combined_headers, *combined_headers_ptr; @@ -246,11 +246,11 @@ static int sapi_isapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) HSE_SEND_HEADER_EX_INFO header_info; char status_buf[MAX_STATUS_LENGTH]; sapi_header_struct default_content_type; - PLS_FETCH(); + TSRMLS_FETCH(); /* Obtain headers length */ if (SG(sapi_headers).send_default_content_type) { - sapi_get_default_content_type_header(&default_content_type SLS_CC); + sapi_get_default_content_type_header(&default_content_type TSRMLS_CC); accumulate_header_length(&default_content_type, (void *) &total_length); } zend_llist_apply_with_argument(&SG(sapi_headers).headers, (void (*)(void *, void *)) accumulate_header_length, (void *) &total_length); @@ -307,7 +307,7 @@ static int php_isapi_startup(sapi_module_struct *sapi_module) -static int sapi_isapi_read_post(char *buffer, uint count_bytes SLS_DC) +static int sapi_isapi_read_post(char *buffer, uint count_bytes TSRMLS_DC) { LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); DWORD read_from_buf=0; @@ -337,7 +337,7 @@ static int sapi_isapi_read_post(char *buffer, uint count_bytes SLS_DC) } -static char *sapi_isapi_read_cookies(SLS_D) +static char *sapi_isapi_read_cookies(TSRMLS_D) { LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); char variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; @@ -361,7 +361,7 @@ static char *sapi_isapi_read_cookies(SLS_D) #ifdef WITH_ZEUS -static void sapi_isapi_register_zeus_ssl_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array TSRMLS_DC PLS_DC) +static void sapi_isapi_register_zeus_ssl_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array TSRMLS_DC) { char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; @@ -379,7 +379,7 @@ static void sapi_isapi_register_zeus_ssl_variables(LPEXTENSION_CONTROL_BLOCK lpE if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_ST", static_variable_buf, &variable_len ) && static_variable_buf[0] ) { strcat( static_cons_buf, static_variable_buf ); } - php_register_variable( "SSL_CLIENT_DN", static_cons_buf, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( "SSL_CLIENT_DN", static_cons_buf, track_vars_array TSRMLS_CC ); strcpy( static_cons_buf, "/C=" ); variable_len = ISAPI_SERVER_VAR_BUF_SIZE; @@ -391,10 +391,10 @@ static void sapi_isapi_register_zeus_ssl_variables(LPEXTENSION_CONTROL_BLOCK lpE if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_I_ST", static_variable_buf, &variable_len ) && static_variable_buf[0] ) { strcat( static_cons_buf, static_variable_buf ); } - php_register_variable( "SSL_CLIENT_I_DN", static_cons_buf, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( "SSL_CLIENT_I_DN", static_cons_buf, track_vars_array TSRMLS_CC ); } -static void sapi_isapi_register_zeus_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array TSRMLS_DC PLS_DC) +static void sapi_isapi_register_zeus_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array TSRMLS_DC) { char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; @@ -413,11 +413,11 @@ static void sapi_isapi_register_zeus_variables(LPEXTENSION_CONTROL_BLOCK lpECB, if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_INFO", static_variable_buf, &variable_len) && static_variable_buf[0] ) { /* PHP_SELF is just PATH_INFO */ - php_register_variable( "PHP_SELF", static_variable_buf, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( "PHP_SELF", static_variable_buf, track_vars_array TSRMLS_CC ); /* Chop off filename to get just the 'real' PATH_INFO' */ pathinfo_len = variable_len - scriptname_len; - php_register_variable( "PATH_INFO", static_variable_buf + scriptname_len - 1, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( "PATH_INFO", static_variable_buf + scriptname_len - 1, track_vars_array TSRMLS_CC ); /* append query string to give url... extra byte for '?' */ if ( strlen(lpECB->lpszQueryString) + variable_len + 1 < ISAPI_SERVER_VAR_BUF_SIZE ) { /* append query string only if it is present... */ @@ -425,8 +425,8 @@ static void sapi_isapi_register_zeus_variables(LPEXTENSION_CONTROL_BLOCK lpECB, static_variable_buf[ variable_len - 1 ] = '?'; strcpy( static_variable_buf + variable_len, lpECB->lpszQueryString ); } - php_register_variable( "URL", static_variable_buf, track_vars_array TSRMLS_CC PLS_CC ); - php_register_variable( "REQUEST_URI", static_variable_buf, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( "URL", static_variable_buf, track_vars_array TSRMLS_CC ); + php_register_variable( "REQUEST_URI", static_variable_buf, track_vars_array TSRMLS_CC ); } } @@ -434,38 +434,38 @@ static void sapi_isapi_register_zeus_variables(LPEXTENSION_CONTROL_BLOCK lpECB, variable_len = ISAPI_SERVER_VAR_BUF_SIZE; if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_TRANSLATED", static_variable_buf, &variable_len) && static_variable_buf[0] ) { static_variable_buf[ variable_len - pathinfo_len - 1 ] = '\0'; - php_register_variable( "PATH_TRANSLATED", static_variable_buf, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( "PATH_TRANSLATED", static_variable_buf, track_vars_array TSRMLS_CC ); } /* Bring in the AUTHENTICATION stuff as needed */ variable_len = ISAPI_SERVER_VAR_BUF_SIZE; if ( lpECB->GetServerVariable(lpECB->ConnID, "AUTH_USER", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - php_register_variable( "PHP_AUTH_USER", static_variable_buf, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( "PHP_AUTH_USER", static_variable_buf, track_vars_array TSRMLS_CC ); } variable_len = ISAPI_SERVER_VAR_BUF_SIZE; if ( lpECB->GetServerVariable(lpECB->ConnID, "AUTH_PASSWORD", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - php_register_variable( "PHP_AUTH_PW", static_variable_buf, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( "PHP_AUTH_PW", static_variable_buf, track_vars_array TSRMLS_CC ); } variable_len = ISAPI_SERVER_VAR_BUF_SIZE; if ( lpECB->GetServerVariable(lpECB->ConnID, "AUTH_TYPE", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - php_register_variable( "PHP_AUTH_TYPE", static_variable_buf, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( "PHP_AUTH_TYPE", static_variable_buf, track_vars_array TSRMLS_CC ); } /* And now, for the SSL variables (if applicable) */ variable_len = ISAPI_SERVER_VAR_BUF_SIZE; if ( lpECB->GetServerVariable(lpECB->ConnID, "CERT_COOKIE", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - sapi_isapi_register_zeus_ssl_variables( lpECB, track_vars_array TSRMLS_CC PLS_CC ); + sapi_isapi_register_zeus_ssl_variables( lpECB, track_vars_array TSRMLS_CC ); } /* Copy some of the variables we need to meet Apache specs */ variable_len = ISAPI_SERVER_VAR_BUF_SIZE; if ( lpECB->GetServerVariable(lpECB->ConnID, "SERVER_SOFTWARE", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - php_register_variable( "SERVER_SIGNATURE", static_variable_buf, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( "SERVER_SIGNATURE", static_variable_buf, track_vars_array TSRMLS_CC ); } } #endif -static void sapi_isapi_register_server_variables2(char **server_variables, LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array, char **recorded_values TSRMLS_DC PLS_DC) +static void sapi_isapi_register_server_variables2(char **server_variables, LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array, char **recorded_values TSRMLS_DC) { char **p=server_variables; DWORD variable_len; @@ -476,7 +476,7 @@ static void sapi_isapi_register_server_variables2(char **server_variables, LPEXT variable_len = ISAPI_SERVER_VAR_BUF_SIZE; if (lpECB->GetServerVariable(lpECB->ConnID, *p, static_variable_buf, &variable_len) && static_variable_buf[0]) { - php_register_variable(*p, static_variable_buf, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable(*p, static_variable_buf, track_vars_array TSRMLS_CC); if (recorded_values) { recorded_values[p-server_variables] = estrndup(static_variable_buf, variable_len); } @@ -484,7 +484,7 @@ static void sapi_isapi_register_server_variables2(char **server_variables, LPEXT variable_buf = (char *) emalloc(variable_len); if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) && variable_buf[0]) { - php_register_variable(*p, variable_buf, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable(*p, variable_buf, track_vars_array TSRMLS_CC); } if (recorded_values) { recorded_values[p-server_variables] = variable_buf; @@ -497,7 +497,7 @@ static void sapi_isapi_register_server_variables2(char **server_variables, LPEXT } -static void sapi_isapi_register_server_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +static void sapi_isapi_register_server_variables(zval *track_vars_array TSRMLS_DC TSRMLS_DC TSRMLS_DC) { DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; char *variable; @@ -509,18 +509,18 @@ static void sapi_isapi_register_server_variables(zval *track_vars_array TSRMLS_D /* Register the special ISAPI variables */ memset(isapi_special_server_variables, 0, sizeof(isapi_special_server_variables)); - sapi_isapi_register_server_variables2(isapi_special_server_variable_names, lpECB, track_vars_array, isapi_special_server_variables TSRMLS_CC PLS_CC); + sapi_isapi_register_server_variables2(isapi_special_server_variable_names, lpECB, track_vars_array, isapi_special_server_variables TSRMLS_CC); if (SG(request_info).cookie_data) { - php_register_variable("HTTP_COOKIE", SG(request_info).cookie_data, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("HTTP_COOKIE", SG(request_info).cookie_data, track_vars_array TSRMLS_CC); } /* Register the standard ISAPI variables */ - sapi_isapi_register_server_variables2(isapi_server_variable_names, lpECB, track_vars_array, NULL TSRMLS_CC PLS_CC); + sapi_isapi_register_server_variables2(isapi_server_variable_names, lpECB, track_vars_array, NULL TSRMLS_CC); if (isapi_special_server_variables[SPECIAL_VAR_HTTPS] && atoi(isapi_special_server_variables[SPECIAL_VAR_HTTPS])) { /* Register SSL ISAPI variables */ - sapi_isapi_register_server_variables2(isapi_secure_server_variable_names, lpECB, track_vars_array, NULL TSRMLS_CC PLS_CC); + sapi_isapi_register_server_variables2(isapi_secure_server_variable_names, lpECB, track_vars_array, NULL TSRMLS_CC); } if (isapi_special_server_variables[SPECIAL_VAR_HTTPS]) { @@ -529,12 +529,12 @@ static void sapi_isapi_register_server_variables(zval *track_vars_array TSRMLS_D #ifdef WITH_ZEUS - sapi_isapi_register_zeus_variables(lpECB, track_vars_array TSRMLS_CC PLS_CC); + sapi_isapi_register_zeus_variables(lpECB, track_vars_array TSRMLS_CC); #endif /* PHP_SELF support */ if (isapi_special_server_variables[SPECIAL_VAR_PHP_SELF]) { - php_register_variable("PHP_SELF", isapi_special_server_variables[SPECIAL_VAR_PHP_SELF], track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("PHP_SELF", isapi_special_server_variables[SPECIAL_VAR_PHP_SELF], track_vars_array TSRMLS_CC); efree(isapi_special_server_variables[SPECIAL_VAR_PHP_SELF]); } @@ -551,7 +551,7 @@ static void sapi_isapi_register_server_variables(zval *track_vars_array TSRMLS_D value++; } *colon = 0; - php_register_variable(variable, value, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable(variable, value, track_vars_array TSRMLS_CC); *colon = ':'; } variable = php_strtok_r(NULL, "\r\n", &strtok_buf); @@ -570,7 +570,7 @@ static void sapi_isapi_register_server_variables(zval *track_vars_array TSRMLS_D if (humi.lpszPath[path_len-2] == '\\') { humi.lpszPath[path_len-2] = 0; } - php_register_variable("DOCUMENT_ROOT", humi.lpszPath, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("DOCUMENT_ROOT", humi.lpszPath, track_vars_array TSRMLS_CC); } } #endif @@ -623,7 +623,7 @@ BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pFilterVersion) DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificationType, LPVOID pvNotification) { - SLS_FETCH(); + TSRMLS_FETCH(); switch (notificationType) { case SF_NOTIFY_PREPROC_HEADERS: @@ -663,7 +663,7 @@ static void init_request_info(sapi_globals_struct *sapi_globals, LPEXTENSION_CON } -static void php_isapi_report_exception(char *message, int message_len SLS_DC) +static void php_isapi_report_exception(char *message, int message_len TSRMLS_DC) { if (!SG(headers_sent)) { HSE_SEND_HEADER_EX_INFO header_info; @@ -718,10 +718,9 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB) { zend_file_handle file_handle; zend_bool stack_overflown=0; - SLS_FETCH(); - CLS_FETCH(); TSRMLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); + TSRMLS_FETCH(); #ifdef PHP_ENABLE_SEH LPEXCEPTION_POINTERS e; #endif @@ -757,8 +756,8 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB) file_handle.type = ZEND_HANDLE_FILENAME; file_handle.opened_path = NULL; - php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC); - php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + php_request_startup(TSRMLS_C); + php_execute_script(&file_handle TSRMLS_CC); if (SG(request_info).cookie_data) { efree(SG(request_info).cookie_data); } @@ -794,14 +793,14 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB) CG(unclean_shutdown)=1; _snprintf(buf,sizeof(buf)-1,"PHP has encountered a Stack overflow"); - php_isapi_report_exception(buf, strlen(buf) SLS_CC); + php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); } else if (_exception_code()==EXCEPTION_ACCESS_VIOLATION) { _snprintf(buf,sizeof(buf)-1,"PHP has encountered an Access Violation at %p",e->ExceptionRecord->ExceptionAddress); - php_isapi_report_exception(buf, strlen(buf) SLS_CC); + php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); my_endthread(); } else { _snprintf(buf,sizeof(buf)-1,"PHP has encountered an Unhandled Exception Code %d at %p",e->ExceptionRecord->ExceptionCode , e->ExceptionRecord->ExceptionAddress); - php_isapi_report_exception(buf, strlen(buf) SLS_CC); + php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); my_endthread(); } #endif diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c index 32710d2e1e..0ed677a96d 100644 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@ -140,7 +140,7 @@ sapi_nsapi_ub_write(const char *str, unsigned int str_length) int retval; nsapi_request_context *rc; - SLS_FETCH(); + 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*/) @@ -278,7 +278,7 @@ sapi_nsapi_read_cookies(SLS_D) } static void -sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_DC SLS_DC TSRMLS_DC) { nsapi_request_context *rc = (nsapi_request_context *)SG(server_context); size_t i; @@ -288,55 +288,55 @@ sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS for (i = 0; i < nsapi_reqpb_size; i++) { value = pblock_findval(nsapi_reqpb[i].nsapi_eq, rc->rq->reqpb); if (value) { - php_register_variable( (char *)nsapi_reqpb[i].env_var, value, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( (char *)nsapi_reqpb[i].env_var, value, track_vars_array TSRMLS_CC ); } } for (i = 0; i < nsapi_headers_size; i++) { value = pblock_findval(nsapi_headers[i].nsapi_eq, rc->rq->headers); if (value) { - php_register_variable( (char *)nsapi_headers[i].env_var, value, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( (char *)nsapi_headers[i].env_var, value, track_vars_array TSRMLS_CC ); } } for (i = 0; i < nsapi_vars_size; i++) { value = pblock_findval(nsapi_vars[i].nsapi_eq, rc->rq->vars); if (value) { - php_register_variable( (char *)nsapi_vars[i].env_var, value, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( (char *)nsapi_vars[i].env_var, value, track_vars_array TSRMLS_CC ); } } for (i = 0; i < nsapi_client_size; i++) { value = pblock_findval(nsapi_client[i].nsapi_eq, rc->sn->client); if (value) { - php_register_variable( (char *)nsapi_client[i].env_var, value, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable( (char *)nsapi_client[i].env_var, value, track_vars_array TSRMLS_CC ); } } value = session_dns(rc->sn); if (value) { - php_register_variable("REMOTE_HOST", value, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable("REMOTE_HOST", value, track_vars_array TSRMLS_CC ); } sprintf(buf, "%d", conf_getglobals()->Vport); - php_register_variable("SERVER_PORT", buf, track_vars_array TSRMLS_CC PLS_CC ); - php_register_variable("SERVER_NAME", util_hostname(), track_vars_array TSRMLS_CC PLS_CC ); - php_register_variable("SERVER_URL", http_uri2url("", ""), track_vars_array TSRMLS_CC PLS_CC ); - php_register_variable("HTTPS", (security_active ? "ON" : "OFF"), track_vars_array TSRMLS_CC PLS_CC ); -/* php_register_variable("SERVER_SOFTWARE", MAGNUS_VERSION_STRING, track_vars_array TSRMLS_CC PLS_CC ); */ + php_register_variable("SERVER_PORT", buf, track_vars_array TSRMLS_CC ); + php_register_variable("SERVER_NAME", util_hostname(), track_vars_array TSRMLS_CC ); + php_register_variable("SERVER_URL", http_uri2url("", ""), track_vars_array TSRMLS_CC ); + php_register_variable("HTTPS", (security_active ? "ON" : "OFF"), track_vars_array TSRMLS_CC ); +/* php_register_variable("SERVER_SOFTWARE", MAGNUS_VERSION_STRING, track_vars_array TSRMLS_CC ); */ /* * Special PHP_SELF variable. */ value = pblock_findval("uri", rc->rq->reqpb); if ( value != NULL ) { - php_register_variable("PHP_SELF", value, track_vars_array TSRMLS_CC PLS_CC ); + php_register_variable("PHP_SELF", value, track_vars_array TSRMLS_CC ); } } static void nsapi_log_message(char *message) { - SLS_FETCH(); + TSRMLS_FETCH(); nsapi_request_context *rc = (nsapi_request_context *)SG(server_context); log_error(LOG_INFORM, "PHP_log_message", rc->sn, rc->rq, "%s", message); @@ -447,12 +447,10 @@ nsapi_module_main(NSLS_D SLS_DC) { int result; zend_file_handle file_handle; - - CLS_FETCH(); TSRMLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC) == FAILURE) { + if (php_request_startup(TSRMLS_C) == FAILURE) { return FAILURE; } @@ -466,7 +464,7 @@ nsapi_module_main(NSLS_D SLS_DC) "Parsing [%s]", SG(request_info).path_translated); #endif - php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + php_execute_script(&file_handle TSRMLS_CC); php_request_shutdown(NULL); #if defined(NSAPI_DEBUG) @@ -506,7 +504,7 @@ php4_execute(pblock *pb, Session *sn, Request *rq) int retval; nsapi_request_context *request_context; - SLS_FETCH(); + TSRMLS_FETCH(); request_context = (nsapi_request_context *)MALLOC(sizeof(nsapi_request_context)); request_context->pb = pb; diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c index 7ea34fc795..a7fbebcde1 100644 --- a/sapi/phttpd/phttpd.c +++ b/sapi/phttpd/phttpd.c @@ -38,12 +38,7 @@ typedef struct { static int ph_globals_id; -#define PHLS_D phttpd_globals_struct *ph_context -#define PHLS_DC , PHLS_D -#define PHLS_C ph_context -#define PHLS_CC , PHLS_C -#define PHG(v) (ph_context->v) -#define PHLS_FETCH() phttpd_globals_struct *ph_context = ts_resource(ph_globals_id) +#define PHG(v) TSRMG(ph_globals_id, phttpd_globals_struct *, v) static int php_phttpd_startup(sapi_module_struct *sapi_module) @@ -65,7 +60,7 @@ static int php_phttpd_sapi_ub_write(const char *str, uint str_length) { int sent_bytes; - PHLS_FETCH(); + TSRMLS_FETCH(); sent_bytes = fd_write(PHG(cip)->fd,str,str_length); @@ -77,11 +72,11 @@ php_phttpd_sapi_ub_write(const char *str, uint str_length) } static int -php_phttpd_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC) +php_phttpd_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) { char *header_name, *header_content; char *p; - PHLS_FETCH(); + TSRMLS_FETCH(); http_sendheaders(PHG(cip)->fd,PHG(cip), SG(sapi_headers).http_response_code, NULL); @@ -105,9 +100,9 @@ php_phttpd_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_str } static int -php_phttpd_sapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +php_phttpd_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { - PHLS_FETCH(); + TSRMLS_FETCH(); if (SG(sapi_headers).send_default_content_type) { fd_printf(PHG(cip)->fd,"Content-Type: text/html\n"); @@ -119,13 +114,13 @@ php_phttpd_sapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) } static char * -php_phttpd_sapi_read_cookies(SLS_D) +php_phttpd_sapi_read_cookies(TSRMLS_D) { /* int i; char *http_cookie = NULL; - NSLS_FETCH(); + NTSRMLS_FETCH(); i = Ns_SetIFind(NSG(conn->headers), "cookie"); if(i != -1) { @@ -140,12 +135,12 @@ php_phttpd_sapi_read_cookies(SLS_D) } static int -php_phttpd_sapi_read_post(char *buf, uint count_bytes SLS_DC) +php_phttpd_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) { /* uint max_read; uint total_read = 0; - NSLS_FETCH(); + NTSRMLS_FETCH(); max_read = MIN(NSG(data_avail), count_bytes); @@ -197,7 +192,7 @@ static sapi_module_struct phttpd_sapi_module = { }; static void -php_phttpd_request_ctor(PHLS_D SLS_DC) +php_phttpd_request_ctor(TSRMLS_D TSRMLS_DC) { memset(&SG(request_info),0,sizeof(sapi_globals_struct)); /* pfusch! */ @@ -248,23 +243,21 @@ php_phttpd_request_ctor(PHLS_D SLS_DC) } static void -php_phttpd_request_dtor(PHLS_D SLS_DC) +php_phttpd_request_dtor(TSRMLS_D TSRMLS_DC) { free(SG(request_info).path_translated); } -int php_doit(PHLS_D SLS_DC) +int php_doit(TSRMLS_D TSRMLS_DC) { struct stat sb; zend_file_handle file_handle; struct httpinfo *hip = PHG(cip)->hip; - - CLS_FETCH(); TSRMLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC) == FAILURE) { + if (php_request_startup(TSRMLS_C) == FAILURE) { return -1; } @@ -273,9 +266,9 @@ int php_doit(PHLS_D SLS_DC) file_handle.free_filename = 0; /* - php_phttpd_hash_environment(PHLS_C CLS_CC TSRMLS_CC PLS_CC SLS_CC); + php_phttpd_hash_environment(TSRMLS_C); */ - php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + php_execute_script(&file_handle TSRMLS_CC); php_request_shutdown(NULL); return SG(sapi_headers).http_response_code; @@ -301,17 +294,17 @@ int pm_request(struct connectioninfo *cip) { struct httpinfo *hip = cip->hip; int status; - PHLS_FETCH(); - SLS_FETCH(); + TSRMLS_FETCH(); + TSRMLS_FETCH(); if (strcasecmp(hip->method, "GET") == 0 || strcasecmp(hip->method, "HEAD") == 0 || strcasecmp(hip->method, "POST") == 0) { PHG(cip) = cip; - php_phttpd_request_ctor(PHLS_C SLS_CC); - status = php_doit(PHLS_C SLS_CC); - php_phttpd_request_dtor(PHLS_C SLS_CC); + php_phttpd_request_ctor(TSRMLS_C); + status = php_doit(TSRMLS_C); + php_phttpd_request_dtor(TSRMLS_C); return status; } else { diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c index 30eb7ba36e..120cf91c72 100644 --- a/sapi/pi3web/pi3web_sapi.c +++ b/sapi/pi3web/pi3web_sapi.c @@ -71,7 +71,7 @@ static void php_info_pi3web(ZEND_MODULE_INFO_FUNC_ARGS) char variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE]; DWORD variable_len; LPCONTROL_BLOCK lpCB; - SLS_FETCH(); + TSRMLS_FETCH(); lpCB = (LPCONTROL_BLOCK) SG(server_context); @@ -137,7 +137,7 @@ static int zend_pi3web_ub_write(const char *str, uint str_length) { DWORD num_bytes = str_length; LPCONTROL_BLOCK cb; - SLS_FETCH(); + TSRMLS_FETCH(); cb = (LPCONTROL_BLOCK) SG(server_context); @@ -150,7 +150,7 @@ static int zend_pi3web_ub_write(const char *str, uint str_length) } -static int sapi_pi3web_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC) +static int sapi_pi3web_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) { return SAPI_HEADER_ADD; } @@ -174,19 +174,19 @@ static void concat_header(sapi_header_struct *sapi_header, char **combined_heade } -static int sapi_pi3web_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +static int sapi_pi3web_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { uint total_length = 2; /* account for the trailing \r\n */ char *combined_headers, *combined_headers_ptr; LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context); sapi_header_struct default_content_type; - PLS_FETCH(); + TSRMLS_FETCH(); if ( !IWasLoaded ) return SAPI_HEADER_SENT_SUCCESSFULLY; if (SG(sapi_headers).send_default_content_type) { - sapi_get_default_content_type_header(&default_content_type SLS_CC); + sapi_get_default_content_type_header(&default_content_type TSRMLS_CC); accumulate_header_length(&default_content_type, (void *) &total_length); } zend_llist_apply_with_argument(&SG(sapi_headers).headers, (void (*)(void *, void *)) accumulate_header_length, (void *) &total_length); @@ -225,7 +225,7 @@ static int php_pi3web_startup(sapi_module_struct *sapi_module) } -static int sapi_pi3web_read_post(char *buffer, uint count_bytes SLS_DC) +static int sapi_pi3web_read_post(char *buffer, uint count_bytes TSRMLS_DC) { LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context); DWORD read_from_buf=0; @@ -256,7 +256,7 @@ static int sapi_pi3web_read_post(char *buffer, uint count_bytes SLS_DC) } -static char *sapi_pi3web_read_cookies(SLS_D) +static char *sapi_pi3web_read_cookies(TSRMLS_D) { LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context); char variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE]; @@ -320,7 +320,7 @@ static void init_request_info(sapi_globals_struct *sapi_globals, LPCONTROL_BLOCK SG(sapi_headers).http_response_code = 200; } -static void hash_pi3web_variables(TSRMLS_D SLS_DC) +static void hash_pi3web_variables(TSRMLS_D TSRMLS_DC) { char static_variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE]; char *variable_buf; @@ -377,10 +377,9 @@ DWORD PHP4_wrapper(LPCONTROL_BLOCK lpCB) zend_file_handle file_handle; char *header_line; int iRet = PIAPI_COMPLETED; - SLS_FETCH(); - CLS_FETCH(); TSRMLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); + TSRMLS_FETCH(); zend_try { file_handle.filename = lpCB->lpszFileName; @@ -390,18 +389,18 @@ DWORD PHP4_wrapper(LPCONTROL_BLOCK lpCB) CG(extended_info) = 0; init_request_info(sapi_globals, lpCB); - php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC); + php_request_startup(TSRMLS_C); - hash_pi3web_variables(TSRMLS_C SLS_CC); + hash_pi3web_variables(TSRMLS_C); switch ( lpCB->dwBehavior ) { case PHP_MODE_STANDARD: - iRet = ( php_execute_script( &file_handle CLS_CC TSRMLS_CC PLS_CC ) == SUCCESS ) ? + iRet = ( php_execute_script( &file_handle TSRMLS_CC ) == SUCCESS ) ? PIAPI_COMPLETED : PIAPI_ERROR; break; case PHP_MODE_HIGHLIGHT: { zend_syntax_highlighter_ini syntax_highlighter_ini; - if ( open_file_for_scanning( &file_handle CLS_CC ) == SUCCESS ) + if ( open_file_for_scanning( &file_handle TSRMLS_CC ) == SUCCESS ) { php_get_highlight_struct( &syntax_highlighter_ini ); zend_highlight( &syntax_highlighter_ini ); @@ -415,7 +414,7 @@ DWORD PHP4_wrapper(LPCONTROL_BLOCK lpCB) case PHP_MODE_INDENT: header_line = (char *)estrdup("Content-Type: text/plain"); sapi_add_header_ex(header_line, strlen(header_line), 1, 1); - if ( open_file_for_scanning( &file_handle CLS_CC ) == SUCCESS ) + if ( open_file_for_scanning( &file_handle TSRMLS_CC ) == SUCCESS ) { zend_indent(); } @@ -426,7 +425,7 @@ DWORD PHP4_wrapper(LPCONTROL_BLOCK lpCB) efree(header_line); break; case PHP_MODE_LINT: - iRet = (php_lint_script(&file_handle CLS_CC TSRMLS_CC PLS_CC) == SUCCESS) ? + iRet = (php_lint_script(&file_handle TSRMLS_CC) == SUCCESS) ? PIAPI_COMPLETED : PIAPI_ERROR; break; default: diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c index 407cba1989..bad3621e7d 100644 --- a/sapi/roxen/roxen.c +++ b/sapi/roxen/roxen.c @@ -215,7 +215,7 @@ php_roxen_low_ub_write(const char *str, uint str_length) { int sent_bytes = 0; struct pike_string *to_write = NULL; #ifdef ZTS - PLS_FETCH(); + TSRMLS_FETCH(); #endif #ifdef ROXEN_USE_ZTS GET_THIS(); @@ -247,7 +247,7 @@ static int php_roxen_sapi_ub_write(const char *str, uint str_length) { #ifdef ZTS - PLS_FETCH(); + TSRMLS_FETCH(); #endif #ifdef ROXEN_USE_ZTS GET_THIS(); @@ -328,7 +328,7 @@ static void php_roxen_set_header(char *header_name, char *value, char *p) */ static int php_roxen_sapi_header_handler(sapi_header_struct *sapi_header, - sapi_headers_struct *sapi_headers SLS_DC) + sapi_headers_struct *sapi_headers TSRMLS_DC) { char *header_name, *header_content, *p; header_name = sapi_header->header; @@ -350,10 +350,10 @@ php_roxen_sapi_header_handler(sapi_header_struct *sapi_header, */ static int -php_roxen_low_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +php_roxen_low_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { #ifdef ZTS - PLS_FETCH(); + TSRMLS_FETCH(); #endif struct pike_string *ind; struct svalue *s_headermap; @@ -381,10 +381,10 @@ php_roxen_low_send_headers(sapi_headers_struct *sapi_headers SLS_DC) } static int -php_roxen_sapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +php_roxen_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { int res = 0; - THREAD_SAFE_RUN(res = php_roxen_low_send_headers(sapi_headers SLS_CC), "send headers"); + THREAD_SAFE_RUN(res = php_roxen_low_send_headers(sapi_headers TSRMLS_CC), "send headers"); return res; } @@ -400,7 +400,7 @@ INLINE static int php_roxen_low_read_post(char *buf, uint count_bytes) GET_THIS(); #endif #ifdef ZTS - PLS_FETCH(); + TSRMLS_FETCH(); #endif if(!MY_FD_OBJ->prog) @@ -422,7 +422,7 @@ INLINE static int php_roxen_low_read_post(char *buf, uint count_bytes) } static int -php_roxen_sapi_read_post(char *buf, uint count_bytes SLS_DC) +php_roxen_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) { uint total_read = 0; THREAD_SAFE_RUN(total_read = php_roxen_low_read_post(buf, count_bytes), "read post"); @@ -435,7 +435,7 @@ php_roxen_sapi_read_post(char *buf, uint count_bytes SLS_DC) */ static char * -php_roxen_sapi_read_cookies(SLS_D) +php_roxen_sapi_read_cookies(TSRMLS_D) { char *cookies; cookies = lookup_string_header("HTTP_COOKIE", NULL); @@ -528,7 +528,7 @@ static sapi_module_struct roxen_sapi_module = { &pval, sizeof(zval *), NULL) static void -php_roxen_hash_environment(CLS_D TSRMLS_DC PLS_DC SLS_DC) +php_roxen_hash_environment(TSRMLS_D) { int i; char buf[512]; @@ -578,14 +578,13 @@ php_roxen_hash_environment(CLS_D TSRMLS_DC PLS_DC SLS_DC) * "executes" the script */ -static int php_roxen_module_main(SLS_D) +static int php_roxen_module_main(TSRMLS_D) { int res, len; char *dir; zend_file_handle file_handle; #ifdef ZTS - CLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); TSRMLS_FETCH(); #ifdef ROXEN_USE_ZTS GET_THIS(); @@ -598,14 +597,14 @@ static int php_roxen_module_main(SLS_D) file_handle.opened_path = NULL; THREADS_ALLOW(); - res = php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC); + res = php_request_startup(TSRMLS_C); THREADS_DISALLOW(); if(res == FAILURE) { return 0; } - php_roxen_hash_environment(CLS_C TSRMLS_CC PLS_CC SLS_CC); + php_roxen_hash_environment(TSRMLS_C); THREADS_ALLOW(); - php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + php_execute_script(&file_handle TSRMLS_CC); php_request_shutdown(NULL); THREADS_DISALLOW(); return 1; @@ -623,7 +622,7 @@ void f_php_roxen_request_handler(INT32 args) struct svalue *done_callback, *raw_fd; struct pike_string *script, *ind; int status = 1; - SLS_FETCH(); + TSRMLS_FETCH(); #ifdef ROXEN_USE_ZTS GET_THIS(); #endif @@ -675,7 +674,7 @@ void f_php_roxen_request_handler(INT32 args) } else THIS->my_fd = 0; - status = php_roxen_module_main(SLS_C); + status = php_roxen_module_main(TSRMLS_C); current_thread = -1; apply_svalue(done_callback, 0); diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c index 14f2a42a8a..fccdf017d0 100644 --- a/sapi/servlet/servlet.c +++ b/sapi/servlet/servlet.c @@ -116,7 +116,7 @@ void ThrowServletException (JNIEnv *jenv, char *msg) { static int sapi_servlet_ub_write(const char *str, uint str_length) { - SLS_FETCH(); + TSRMLS_FETCH(); if (!SG(server_context)) { fprintf(stderr, str); return 0; @@ -144,7 +144,7 @@ static int sapi_servlet_ub_write(const char *str, uint str_length) static void sapi_servlet_send_header(sapi_header_struct *sapi_header, void *server_context) { - SLS_FETCH(); + TSRMLS_FETCH(); if (!sapi_header) return; if (!SG(server_context)) return; @@ -162,7 +162,7 @@ static void sapi_servlet_send_header(sapi_header_struct *sapi_header, void *serv } -static int sapi_servlet_read_post(char *buffer, uint count_bytes SLS_DC) +static int sapi_servlet_read_post(char *buffer, uint count_bytes TSRMLS_DC) { if (count_bytes == 0) { return 0; @@ -190,7 +190,7 @@ static int sapi_servlet_read_post(char *buffer, uint count_bytes SLS_DC) } -static char *sapi_servlet_read_cookies(SLS_D) +static char *sapi_servlet_read_cookies(TSRMLS_D) { JNIEnv *jenv = ((servlet_request*)SG(server_context))->jenv; jobject servlet = ((servlet_request*)SG(server_context))->servlet; @@ -318,9 +318,8 @@ JNIEXPORT void JNICALL Java_net_php_servlet_send #ifndef VIRTUAL_DIR char cwd[MAXPATHLEN]; #endif - SLS_FETCH(); - PLS_FETCH(); - CLS_FETCH(); + TSRMLS_FETCH(); + TSRMLS_FETCH(); TSRMLS_FETCH(); zend_try { @@ -342,7 +341,7 @@ JNIEXPORT void JNICALL Java_net_php_servlet_send SG(sapi_headers).http_response_code = 200; SG(request_info).content_length = contentLength; SG(request_info).auth_password = NULL; - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC)==FAILURE) { + if (php_request_startup(TSRMLS_C)==FAILURE) { ThrowServletException(jenv,"request startup failure"); return; } @@ -379,13 +378,13 @@ JNIEXPORT void JNICALL Java_net_php_servlet_send if (display_source_mode) { zend_syntax_highlighter_ini syntax_highlighter_ini; - if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) { + if (open_file_for_scanning(&file_handle TSRMLS_CC)==SUCCESS) { php_get_highlight_struct(&syntax_highlighter_ini); sapi_send_headers(); zend_highlight(&syntax_highlighter_ini); } } else { - php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + php_execute_script(&file_handle TSRMLS_CC); php_header(); /* Make sure headers have been sent */ } diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index 19dcd983d2..f12e50a79a 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -37,27 +37,27 @@ typedef struct { #ifdef ZTS static int thttpd_globals_id; -#define TLS_D php_thttpd_globals *thttpd_context -#define TLS_DC , TLS_D -#define TLS_C thttpd_context -#define TLS_CC , thttpd_context +#define TSRMLS_D php_thttpd_globals *thttpd_context +#define TSRMLS_DC , TSRMLS_D +#define TSRMLS_C thttpd_context +#define TSRMLS_CC , thttpd_context #define TG(v) (thttpd_context->v) -#define TLS_FETCH() TLS_D = ts_resource(thttpd_globals_id) +#define TSRMLS_FETCH() TSRMLS_D = ts_resource(thttpd_globals_id) #else static php_thttpd_globals thttpd_globals; -#define TLS_D -#define TLS_DC -#define TLS_C -#define TLS_CC +#define TSRMLS_D +#define TSRMLS_DC +#define TSRMLS_C +#define TSRMLS_CC #define TG(v) (thttpd_globals.v) -#define TLS_FETCH() +#define TSRMLS_FETCH() #endif static int sapi_thttpd_ub_write(const char *str, uint str_length) { int n; uint sent = 0; - TLS_FETCH(); + TSRMLS_FETCH(); while (str_length > 0) { n = send(TG(hc)->conn_fd, str, str_length, 0); @@ -80,7 +80,7 @@ static int sapi_thttpd_ub_write(const char *str, uint str_length) #define COMBINE_HEADERS 30 -static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { char buf[1024]; struct iovec vec[COMBINE_HEADERS]; @@ -88,7 +88,7 @@ static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers SLS_DC) zend_llist_position pos; sapi_header_struct *h; size_t len; - TLS_FETCH(); + TSRMLS_FETCH(); if (!SG(sapi_headers).http_status_line) { snprintf(buf, 1023, "HTTP/1.0 %d Something\r\n", SG(sapi_headers).http_response_code); @@ -133,11 +133,11 @@ static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers SLS_DC) return SAPI_HEADER_SENT_SUCCESSFULLY; } -static int sapi_thttpd_read_post(char *buffer, uint count_bytes SLS_DC) +static int sapi_thttpd_read_post(char *buffer, uint count_bytes TSRMLS_DC) { size_t read_bytes = 0, tmp; int c; - TLS_FETCH(); + TSRMLS_FETCH(); /* to understand this, read cgi_interpose_input() in libhttpd.c */ c = TG(hc)->read_idx - TG(hc)->checked_idx; @@ -162,29 +162,29 @@ static int sapi_thttpd_read_post(char *buffer, uint count_bytes SLS_DC) return read_bytes; } -static char *sapi_thttpd_read_cookies(SLS_D) +static char *sapi_thttpd_read_cookies(TSRMLS_D) { - TLS_FETCH(); + TSRMLS_FETCH(); return TG(hc)->cookie; } #define BUF_SIZE 512 #define ADD_STRING(name) \ - php_register_variable(name, buf, track_vars_array TSRMLS_CC PLS_CC) + php_register_variable(name, buf, track_vars_array TSRMLS_CC) -static void sapi_thttpd_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +static void sapi_thttpd_register_variables(zval *track_vars_array TSRMLS_DC TSRMLS_DC TSRMLS_DC) { char buf[BUF_SIZE + 1]; char *p; - TLS_FETCH(); + TSRMLS_FETCH(); - php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("SERVER_SOFTWARE", SERVER_SOFTWARE, track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("REQUEST_METHOD", (char *) SG(request_info).request_method, track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array TSRMLS_CC); + php_register_variable("SERVER_SOFTWARE", SERVER_SOFTWARE, track_vars_array TSRMLS_CC); + php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array TSRMLS_CC); + php_register_variable("REQUEST_METHOD", (char *) SG(request_info).request_method, track_vars_array TSRMLS_CC); + php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array TSRMLS_CC); + php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, track_vars_array TSRMLS_CC); p = inet_ntoa(TG(hc)->client_addr.sa_in.sin_addr); /* string representation of IPs are never larger than 512 bytes */ @@ -205,7 +205,7 @@ static void sapi_thttpd_register_variables(zval *track_vars_array TSRMLS_DC SLS_ #define CONDADD(name, field) \ if (TG(hc)->field[0]) { \ - php_register_variable(#name, TG(hc)->field, track_vars_array TSRMLS_CC PLS_CC); \ + php_register_variable(#name, TG(hc)->field, track_vars_array TSRMLS_CC); \ } CONDADD(HTTP_REFERER, referer); @@ -223,7 +223,7 @@ static void sapi_thttpd_register_variables(zval *track_vars_array TSRMLS_DC SLS_ } if (TG(hc)->authorization[0]) - php_register_variable("AUTH_TYPE", "Basic", track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("AUTH_TYPE", "Basic", track_vars_array TSRMLS_CC); } static sapi_module_struct thttpd_sapi_module = { @@ -258,27 +258,26 @@ static sapi_module_struct thttpd_sapi_module = { STANDARD_SAPI_MODULE_PROPERTIES }; -static void thttpd_module_main(TLS_D SLS_DC) +static void thttpd_module_main(TSRMLS_D TSRMLS_DC) { zend_file_handle file_handle; - CLS_FETCH(); TSRMLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH(); file_handle.type = ZEND_HANDLE_FILENAME; file_handle.filename = SG(request_info).path_translated; file_handle.free_filename = 0; file_handle.opened_path = NULL; - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC) == FAILURE) { + if (php_request_startup(TSRMLS_C) == FAILURE) { return; } - php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + php_execute_script(&file_handle TSRMLS_CC); php_request_shutdown(NULL); } -static void thttpd_request_ctor(TLS_D SLS_DC) +static void thttpd_request_ctor(TSRMLS_D TSRMLS_DC) { int offset; smart_str s = {0}; @@ -300,7 +299,7 @@ static void thttpd_request_ctor(TLS_D SLS_DC) SG(request_info).content_type = TG(hc)->contenttype; SG(request_info).content_length = TG(hc)->contentlength; - php_handle_auth_data(TG(hc)->authorization SLS_CC); + php_handle_auth_data(TG(hc)->authorization TSRMLS_CC); TG(post_off) = TG(hc)->read_idx - TG(hc)->checked_idx; @@ -313,7 +312,7 @@ static void thttpd_request_ctor(TLS_D SLS_DC) } } -static void thttpd_request_dtor(TLS_D SLS_DC) +static void thttpd_request_dtor(TSRMLS_D TSRMLS_DC) { if (SG(request_info).query_string) free(SG(request_info).query_string); @@ -440,14 +439,14 @@ static void queue_request(httpd_conn *hc) tsrm_mutex_unlock(qr_lock); } -static off_t thttpd_real_php_request(httpd_conn *hc TLS_DC SLS_DC); +static off_t thttpd_real_php_request(httpd_conn *hc TSRMLS_DC TSRMLS_DC); static void *worker_thread(void *dummy) { int do_work = 50; httpd_conn *hc; - SLS_FETCH(); - TLS_FETCH(); + TSRMLS_FETCH(); + TSRMLS_FETCH(); while (do_work) { hc = dequeue_request(); @@ -461,7 +460,7 @@ static void *worker_thread(void *dummy) thread_atomic_dec(nr_free_threads); - thttpd_real_php_request(hc TLS_CC SLS_CC); + thttpd_real_php_request(hc TSRMLS_CC TSRMLS_CC); shutdown(hc->conn_fd, 0); destroy_conn(hc); free(hc); @@ -500,16 +499,16 @@ static void remove_dead_conn(int fd) #endif -static off_t thttpd_real_php_request(httpd_conn *hc TLS_DC SLS_DC) +static off_t thttpd_real_php_request(httpd_conn *hc TSRMLS_DC TSRMLS_DC) { TG(hc) = hc; hc->bytes_sent = 0; - thttpd_request_ctor(TLS_C SLS_CC); + thttpd_request_ctor(TSRMLS_C); - thttpd_module_main(TLS_C SLS_CC); + thttpd_module_main(TSRMLS_C); - thttpd_request_dtor(TLS_C SLS_CC); + thttpd_request_dtor(TSRMLS_C); return 0; } @@ -519,33 +518,33 @@ off_t thttpd_php_request(httpd_conn *hc) #ifdef ZTS queue_request(hc); #else - SLS_FETCH(); - TLS_FETCH(); - return thttpd_real_php_request(hc TLS_CC SLS_CC); + TSRMLS_FETCH(); + TSRMLS_FETCH(); + return thttpd_real_php_request(hc TSRMLS_CC TSRMLS_CC); #endif } void thttpd_register_on_close(void (*arg)(int)) { - TLS_FETCH(); + TSRMLS_FETCH(); TG(on_close) = arg; } void thttpd_closed_conn(int fd) { - TLS_FETCH(); + TSRMLS_FETCH(); if (TG(on_close)) TG(on_close)(fd); } int thttpd_get_fd(void) { - TLS_FETCH(); + TSRMLS_FETCH(); return TG(hc)->conn_fd; } void thttpd_set_dont_close(void) { - TLS_FETCH(); + TSRMLS_FETCH(); TG(hc)->file_address = (char *) 1; } @@ -561,14 +560,14 @@ void thttpd_php_init(void) sapi_startup(&thttpd_sapi_module); thttpd_sapi_module.startup(&thttpd_sapi_module); { - SLS_FETCH(); + TSRMLS_FETCH(); SG(server_context) = (void *) 1; } } void thttpd_php_shutdown(void) { - SLS_FETCH(); + TSRMLS_FETCH(); if (SG(server_context) != NULL) { thttpd_sapi_module.shutdown(&thttpd_sapi_module); diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c index 7dbc6f748c..215e4d5cbe 100644 --- a/sapi/tux/php_tux.c +++ b/sapi/tux/php_tux.c @@ -47,18 +47,13 @@ typedef struct { static php_tux_globals tux_globals; -#define TLS_D -#define TLS_DC -#define TLS_C -#define TLS_CC #define TG(v) (tux_globals.v) -#define TLS_FETCH() static int sapi_tux_ub_write(const char *str, uint str_length) { int n; uint sent = 0; - TLS_FETCH(); + TSRMLS_FETCH(); /* combine headers and body */ if (TG(number_vec)) { @@ -94,7 +89,7 @@ static int sapi_tux_ub_write(const char *str, uint str_length) return sent; } -static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers SLS_DC) +static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers) { char buf[1024]; struct iovec *vec; @@ -105,7 +100,7 @@ static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers SLS_DC) size_t len; char *status_line; int locate_cl; - TLS_FETCH(); + TSRMLS_FETCH(); max_headers = 30; snprintf(buf, 1023, "HTTP/1.1 %d NA\r\n", SG(sapi_headers).http_response_code); @@ -153,11 +148,11 @@ static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers SLS_DC) return SAPI_HEADER_SENT_SUCCESSFULLY; } -static int sapi_tux_read_post(char *buffer, uint count_bytes SLS_DC) +static int sapi_tux_read_post(char *buffer, uint count_bytes) { #if 0 int amount = 0; - TLS_FETCH(); + TSRMLS_FETCH(); TG(req)->objectlen = count_bytes; TG(req)->object_addr = buffer; @@ -172,34 +167,34 @@ static int sapi_tux_read_post(char *buffer, uint count_bytes SLS_DC) #endif } -static char *sapi_tux_read_cookies(SLS_D) +static char *sapi_tux_read_cookies(void) { - TLS_FETCH(); + TSRMLS_FETCH(); return TG(req)->cookies; } #define BUF_SIZE 512 #define ADD_STRING(name) \ - php_register_variable(name, buf, track_vars_array TSRMLS_CC PLS_CC) + php_register_variable(name, buf, track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()CC) -static void sapi_tux_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC PLS_DC) +static void sapi_tux_register_variables(zval *track_vars_array TSRMLS_DC) { char buf[BUF_SIZE + 1]; char *p; - TLS_FETCH(); + TSRMLS_FETCH(); sprintf(buf, "Server: %s", TUXAPI_version); sapi_add_header_ex(buf, strlen(buf), 1, 0); - php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("SERVER_SOFTWARE", TUXAPI_version, track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("REQUEST_METHOD", (char *) SG(request_info).request_method, track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("DOCUMENT_ROOT", TUXAPI_docroot, track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("SERVER_NAME", TUXAPI_servername, track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array TSRMLS_CC PLS_CC); - php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, track_vars_array TSRMLS_CC PLS_CC); + php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()CC); + php_register_variable("SERVER_SOFTWARE", TUXAPI_version, track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()CC); + php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()CC); + php_register_variable("REQUEST_METHOD", (char *) SG(request_info).request_method, track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()CC); + php_register_variable("DOCUMENT_ROOT", TUXAPI_docroot, track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()CC); + php_register_variable("SERVER_NAME", TUXAPI_servername, track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()CC); + php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()CC); + php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()CC); p = inet_ntoa(TG(req)->client_host); /* string representation of IPs are never larger than 512 bytes */ @@ -222,7 +217,7 @@ static void sapi_tux_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC #define CONDADD(name, field) \ if (TG(req)->field[0]) { \ - php_register_variable(#name, TG(req)->field, track_vars_array TSRMLS_CC PLS_C); \ + php_register_variable(#name, TG(req)->field, track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()C); \ } CONDADD(HTTP_REFERER, referer); @@ -242,7 +237,7 @@ static void sapi_tux_register_variables(zval *track_vars_array TSRMLS_DC SLS_DC #if 0 if (TG(hc)->authorization[0]) - php_register_variable("AUTH_TYPE", "Basic", track_vars_array TSRMLS_CC PLS_C); + php_register_variable("AUTH_TYPE", "Basic", track_vars_array TSRMLS_FETCH()CC TSRMLS_FETCH()C); #endif } @@ -278,27 +273,26 @@ static sapi_module_struct tux_sapi_module = { STANDARD_SAPI_MODULE_PROPERTIES }; -static void tux_module_main(TLS_D SLS_DC) +static void tux_module_main(TSRMLS_D) { zend_file_handle file_handle; - CLS_FETCH(); - TSRMLS_FETCH(); - PLS_FETCH(); + TSRMLS_FETCH()FETCH(); + TSRMLS_FETCH()FETCH(); file_handle.type = ZEND_HANDLE_FILENAME; file_handle.filename = SG(request_info).path_translated; file_handle.free_filename = 0; file_handle.opened_path = NULL; - if (php_request_startup(CLS_C TSRMLS_CC PLS_CC SLS_CC) == FAILURE) { + if (php_request_startup(TSRMLS_C) == FAILURE) { return; } - php_execute_script(&file_handle CLS_CC TSRMLS_CC PLS_CC); + php_execute_script(&file_handle TSRMLS_FETCH()CC TSRMLS_FETCH()CC); php_request_shutdown(NULL); } -static void tux_request_ctor(TLS_D SLS_DC) +static void tux_request_ctor(TSRMLS_D) { char buf[1024]; int offset; @@ -329,11 +323,11 @@ static void tux_request_ctor(TLS_D SLS_DC) SG(request_info).content_length = 0; // TG(req)->contentlength; #if 0 - php_handle_auth_data(TG(hc)->authorization SLS_CC); + php_handle_auth_data(TG(hc)->authorization TSRMLS_CC); #endif } -static void tux_request_dtor(TLS_D SLS_DC) +static void tux_request_dtor(TSRMLS_D) { if (TG(header_vec)) free(TG(header_vec)); @@ -367,8 +361,7 @@ static void *separate_thread(void *bla) int TUXAPI_handle_events(user_req_t *req) { - SLS_FETCH(); - TLS_FETCH(); + TSRMLS_FETCH(); if (req->event == PHP_TUX_BACKGROUND_CONN) { tux_closed_conn(req->sock); @@ -378,11 +371,11 @@ int TUXAPI_handle_events(user_req_t *req) TG(req) = req; TG(tux_action) = TUX_ACTION_FINISH_CLOSE_REQ; - tux_request_ctor(TLS_C SLS_CC); + tux_request_ctor(TSRMLS_C); - tux_module_main(TLS_C SLS_CC); + tux_module_main(TSRMLS_C); - tux_request_dtor(TLS_C SLS_CC); + tux_request_dtor(TSRMLS_C); return tux(TG(tux_action), req); } @@ -394,21 +387,21 @@ void tux_register_on_close(void (*arg)(int)) void tux_closed_conn(int fd) { - TLS_FETCH(); + TSRMLS_FETCH(); if (TG(on_close)) TG(on_close)(fd); } int tux_get_fd(void) { - TLS_FETCH(); + TSRMLS_FETCH(); return TG(req)->sock; } void tux_set_dont_close(void) { - TLS_FETCH(); + TSRMLS_FETCH(); TG(req)->event = PHP_TUX_BACKGROUND_CONN; tux(TUX_ACTION_POSTPONE_REQ, TG(req)); |