summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>1999-05-02 18:07:41 +0000
committerAndi Gutmans <andi@php.net>1999-05-02 18:07:41 +0000
commit5dbe9246609e59439ca0340aed5b2eaac1bed7d8 (patch)
tree9b2f8401987eb02e9165c975c954c6f3647ee6d6
parent7e0ee50ed484aae4ebc0601392157c9a79407919 (diff)
downloadphp-git-5dbe9246609e59439ca0340aed5b2eaac1bed7d8.tar.gz
- Make ISAPI hook in as an extension too.
- Some work on moving stuff to SAPI.
-rw-r--r--cgi_main.c24
-rw-r--r--ext/hyperwave/hw.c4
-rw-r--r--ext/standard/post.c3
-rw-r--r--main.h3
-rw-r--r--main/SAPI.c6
-rw-r--r--main/SAPI.h21
-rw-r--r--main/main.c28
-rw-r--r--mod_php3.c6
-rw-r--r--output.c2
-rw-r--r--request_info.c5
-rw-r--r--request_info.h1
11 files changed, 68 insertions, 35 deletions
diff --git a/cgi_main.c b/cgi_main.c
index 190d930ff9..db3ecaac57 100644
--- a/cgi_main.c
+++ b/cgi_main.c
@@ -76,8 +76,13 @@ static int zend_cgibin_ub_write(const char *str, uint str_length)
}
-static sapi_functions_struct sapi_functions = {
- zend_cgibin_ub_write
+static sapi_module_struct sapi_module = {
+ "PHP Language", /* name */
+
+ php_module_startup, /* startup */
+ php_module_shutdown_wrapper, /* shutdown */
+
+ zend_cgibin_ub_write, /* unbuffered write */
};
@@ -127,6 +132,7 @@ int main(int argc, char *argv[])
zend_compiler_globals *compiler_globals;
zend_executor_globals *executor_globals;
php_core_globals *core_globals;
+ sapi_globals_struct *sapi_globals;
#endif
@@ -135,7 +141,10 @@ int main(int argc, char *argv[])
return -1;
}
#endif
-
+
+ tsrm_startup(1,1,0);
+ sapi_startup(&sapi_module);
+
#if WIN32|WINNT
_fmode = _O_BINARY; /*sets default for file streams to binary */
setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
@@ -178,13 +187,14 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
#endif /* FORCE_CGI_REDIRECT */
}
- if (php_module_startup(&sapi_functions)==FAILURE) {
+ if (php_module_startup(&sapi_module)==FAILURE) {
return FAILURE;
}
#ifdef ZTS
compiler_globals = ts_resource(compiler_globals_id);
executor_globals = ts_resource(executor_globals_id);
core_globals = ts_resource(core_globals_id);
+ sapi_globals = ts_resource(sapi_globals_id);
#endif
CG(extended_info) = 0;
@@ -280,8 +290,10 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
php3_TreatHeaders();
+ SG(request_info).query_string = getenv("QUERY_STRING");
+
if (!cgi) {
- if (!request_info.query_string) {
+ if (!SG(request_info).query_string) {
for (i = optind, len = 0; i < argc; i++)
len += strlen(argv[i]) + 1;
@@ -292,7 +304,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
if (i < (argc - 1))
strcat(s, "+");
}
- request_info.query_string = s;
+ SG(request_info).query_string = s;
}
if (!request_info.filename && argc > optind)
request_info.filename = argv[optind];
diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c
index 8ac6dbd070..8a813dde86 100644
--- a/ext/hyperwave/hw.c
+++ b/ext/hyperwave/hw.c
@@ -1533,7 +1533,7 @@ void php3_hw_getcgi(INTERNAL_FUNCTION_PARAMETERS) {
sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
request_info.request_method,
request_info.path_info,
- request_info.query_string);
+ SG(request_info).query_string);
#endif
/* !!!! memory for object and attributes is allocated with malloc !!!! */
if (0 != (ptr->lasterror = send_getcgi(ptr->socket, id, cgi_env_str, &attributes, &object, &count)))
@@ -1785,7 +1785,7 @@ void php3_hw_pipecgi(INTERNAL_FUNCTION_PARAMETERS) {
sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
request_info.request_method,
request_info.path_info,
- request_info.query_string);
+ SG(request_info).query_string);
#endif
/* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
if (0 != (ptr->lasterror = send_pipecgi(ptr->socket,
diff --git a/ext/standard/post.c b/ext/standard/post.c
index 166c6799e7..009f37f08a 100644
--- a/ext/standard/post.c
+++ b/ext/standard/post.c
@@ -317,6 +317,7 @@ void php3_treat_data(int arg, char *str)
pval *array_ptr;
ELS_FETCH();
PLS_FETCH();
+ SLS_FETCH();
switch (arg) {
case PARSE_POST:
@@ -350,7 +351,7 @@ void php3_treat_data(int arg, char *str)
if (arg == PARSE_POST) {
res = php3_getpost(array_ptr PLS_CC);
} else if (arg == PARSE_GET) { /* Get data */
- var = request_info.query_string;
+ var = SG(request_info).query_string;
if (var && *var) {
res = (char *) estrdup(var);
}
diff --git a/main.h b/main.h
index d450ac5986..df3455c9c9 100644
--- a/main.h
+++ b/main.h
@@ -42,9 +42,10 @@
PHPAPI int php_request_startup(CLS_D ELS_DC PLS_DC);
PHPAPI void php_request_shutdown(void *dummy);
PHPAPI void php_request_shutdown_for_exec(void *dummy);
-PHPAPI int php_module_startup(sapi_functions_struct *sf);
+PHPAPI int php_module_startup(sapi_module_struct *sf);
PHPAPI void php_module_shutdown();
PHPAPI void php_module_shutdown_for_exec(void);
+PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals);
PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_DC);
diff --git a/main/SAPI.c b/main/SAPI.c
index 827bd2553f..bdb58baed4 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -11,11 +11,11 @@ sapi_globals_struct sapi_globals;
#endif
/* A true global (no need for thread safety) */
-sapi_functions_struct sapi_functions;
+sapi_module_struct sapi_module;
-void sapi_startup(sapi_functions_struct *sf)
+SAPI_API void sapi_startup(sapi_module_struct *sf)
{
- sapi_functions = *sf;
+ sapi_module = *sf;
#ifdef ZTS
sapi_globals_id = ts_allocate_id(sizeof(sapi_globals_struct), NULL, NULL);
#endif
diff --git a/main/SAPI.h b/main/SAPI.h
index bd62eaed76..feddbc3bbc 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -13,19 +13,32 @@
#endif
-typedef struct {
+typedef struct _sapi_module_struct {
+ char *name;
+
+ int (*startup)(struct _sapi_module_struct *sapi_module);
+ int (*shutdown)(struct _sapi_module_struct *sapi_module);
+
int (*ub_write)(const char *str, unsigned int str_length);
-} sapi_functions_struct;
+} sapi_module_struct;
+
-extern sapi_functions_struct sapi_functions; /* true global */
+extern sapi_module_struct sapi_module; /* true global */
+
+
+typedef struct {
+ char *path_translated;
+ char *query_string;
+} sapi_request_info;
typedef struct {
void *server_context;
+ sapi_request_info request_info;
} sapi_globals_struct;
-void sapi_startup(sapi_functions_struct *sf);
+SAPI_API void sapi_startup(sapi_module_struct *sf);
#ifdef ZTS
# define SLS_D sapi_globals_struct *sapi_globals
diff --git a/main/main.c b/main/main.c
index a4da4b9851..7bef2e8af1 100644
--- a/main/main.c
+++ b/main/main.c
@@ -755,7 +755,7 @@ static core_globals_ctor(php_core_globals *core_globals)
#endif
-int php_module_startup(sapi_functions_struct *sf)
+int php_module_startup(sapi_module_struct *sf)
{
zend_utility_functions zuf;
zend_utility_values zuv;
@@ -775,7 +775,7 @@ int php_module_startup(sapi_functions_struct *sf)
return SUCCESS;
}
- sapi_functions = *sf;
+ sapi_module = *sf;
zend_output_startup();
@@ -796,7 +796,6 @@ int php_module_startup(sapi_functions_struct *sf)
#endif
PG(header_is_being_sent) = 0;
- sapi_startup(sf);
#if HAVE_SETLOCALE
setlocale(LC_CTYPE, "");
@@ -840,6 +839,14 @@ void php_module_shutdown_for_exec(void)
/* used to close fd's in the range 3.255 here, but it's problematic */
}
+
+int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals)
+{
+ php_module_shutdown();
+ return SUCCESS;
+}
+
+
void php_module_shutdown()
{
int module_number=0; /* for UNREGISTER_INI_ENTRIES() */
@@ -875,12 +882,12 @@ void php_module_shutdown()
/* in 3.1 some of this should move into sapi */
-int _php3_hash_environment(PLS_D)
+int _php3_hash_environment(PLS_D ELS_DC)
{
char **env, *p, *t;
unsigned char _gpc_flags[3] = {0,0,0};
pval *tmp;
- ELS_FETCH();
+ SLS_FETCH();
p = PG(gpc_order);
while(*p) {
@@ -1050,7 +1057,7 @@ int _php3_hash_environment(PLS_D)
/* need argc/argv support as well */
- _php3_build_argv(request_info.query_string ELS_CC);
+ _php3_build_argv(SG(request_info).query_string ELS_CC);
return SUCCESS;
}
@@ -1113,16 +1120,17 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
{
zend_file_handle *prepend_file_p, *append_file_p;
zend_file_handle prepend_file, append_file;
+ SLS_FETCH();
- if (request_info.query_string && request_info.query_string[0]=='=') {
- if (!strcmp(request_info.query_string+1, "PHPE9568F34-D428-11d2-A769-00AA001ACF42")) {
+ if (SG(request_info).query_string && SG(request_info).query_string[0]=='=') {
+ if (!strcmp(SG(request_info).query_string+1, "PHPE9568F34-D428-11d2-A769-00AA001ACF42")) {
char *header_line = estrndup("Content-type: image/gif", sizeof("Content-type: image/gif")-1);
php4i_add_header_information(header_line);
PHPWRITE(php4_logo, sizeof(php4_logo));
efree(header_line);
return;
- } else if (!strcmp(request_info.query_string+1, "PHPE9568F35-D428-11d2-A769-00AA001ACF42")) {
+ } else if (!strcmp(SG(request_info).query_string+1, "PHPE9568F35-D428-11d2-A769-00AA001ACF42")) {
char *header_line = estrndup("Content-type: image/gif", sizeof("Content-type: image/gif")-1);
php4i_add_header_information(header_line);
@@ -1136,7 +1144,7 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
PG(unclean_shutdown) = 1;
return;
}
- _php3_hash_environment(PLS_C);
+ _php3_hash_environment(PLS_C ELS_CC);
#if WIN32||WINNT
UpdateIniFromRegistry(primary_file->filename);
diff --git a/mod_php3.c b/mod_php3.c
index 07641c7d37..7adfa2c8a2 100644
--- a/mod_php3.c
+++ b/mod_php3.c
@@ -88,7 +88,7 @@ int saved_umask;
php_apache_info_struct php_apache_info; /* active config */
int apache_php3_module_main(request_rec * r, int fd, int display_source_mode);
-int php_module_startup(sapi_functions_struct *sf);
+int php_module_startup(sapi_module_struct *sf);
void php_module_shutdown();
void php_module_shutdown_for_exec();
@@ -112,7 +112,7 @@ static int zend_apache_ub_write(const char *str, uint str_length)
}
-sapi_functions_struct sapi_functions = {
+sapi_module_struct sapi_module = {
zend_apache_ub_write
};
@@ -268,7 +268,7 @@ int php3_xbithack_handler(request_rec * r)
void php3_init_handler(server_rec *s, pool *p)
{
register_cleanup(p, NULL, php_module_shutdown, php_module_shutdown_for_exec);
- php_module_startup(&sapi_functions);
+ php_module_startup(&sapi_module);
#if MODULE_MAGIC_NUMBER >= 19980527
ap_add_version_component("PHP/" PHP_VERSION);
#endif
diff --git a/output.c b/output.c
index e1bf28b409..fdf55945dc 100644
--- a/output.c
+++ b/output.c
@@ -48,7 +48,7 @@ PHPAPI void zend_output_startup()
ob_buffer = NULL;
zend_body_write = zend_ub_body_write;
header_request=0;
- zend_header_write = sapi_functions.ub_write;
+ zend_header_write = sapi_module.ub_write;
}
diff --git a/request_info.c b/request_info.c
index 0ca88fb3f6..5b3958175b 100644
--- a/request_info.c
+++ b/request_info.c
@@ -38,10 +38,10 @@ PHPAPI php3_request_info request_info;
int php3_init_request_info(void *conf)
{
char *buf; /* temporary buffers */
+ SLS_FETCH();
request_info.path_info = getenv("PATH_INFO");
request_info.path_translated = getenv("PATH_TRANSLATED");
- request_info.query_string = getenv("QUERY_STRING");
request_info.current_user = NULL;
request_info.current_user_length = 0;
request_info.request_method = getenv("REQUEST_METHOD");
@@ -199,12 +199,12 @@ int php3_init_request_info(void *conf)
SLS_FETCH();
r = ((request_rec *) SG(server_context));
+ SG(request_info).query_string = r->args;
request_info.current_user = NULL;
request_info.current_user_length = 0;
request_info.filename = r->filename;
request_info.request_method = r->method;
- request_info.query_string = r->args;
request_info.content_type = table_get(r->subprocess_env, "CONTENT_TYPE");
buf = table_get(r->subprocess_env, "CONTENT_LENGTH");
@@ -227,7 +227,6 @@ int php3_init_request_info(void *conf)
request_info.filename = NULL;
request_info.path_info = sapi_rqst->path_info;
request_info.path_translated = sapi_rqst->path_translated;
- request_info.query_string = sapi_rqst->query_string;
request_info.current_user = sapi_rqst->current_user;
request_info.current_user_length = sapi_rqst->current_user_length;
request_info.request_method = sapi_rqst->request_method;
diff --git a/request_info.h b/request_info.h
index 71c50cc698..07cc873e38 100644
--- a/request_info.h
+++ b/request_info.h
@@ -34,7 +34,6 @@ typedef struct {
char *filename;
char *path_info;
const char *path_translated;
- char *query_string;
const char *request_method;
char *script_name;
char *current_user;