- Some work on moving stuff to SAPI.
}
-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 */
};
zend_compiler_globals *compiler_globals;
zend_executor_globals *executor_globals;
php_core_globals *core_globals;
+ sapi_globals_struct *sapi_globals;
#endif
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 */
#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;
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;
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];
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)))
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,
pval *array_ptr;
ELS_FETCH();
PLS_FETCH();
+ SLS_FETCH();
switch (arg) {
case PARSE_POST:
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);
}
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);
#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
#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
#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;
return SUCCESS;
}
- sapi_functions = *sf;
+ sapi_module = *sf;
zend_output_startup();
#endif
PG(header_is_being_sent) = 0;
- sapi_startup(sf);
#if HAVE_SETLOCALE
setlocale(LC_CTYPE, "");
/* 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() */
/* 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) {
/* 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;
}
{
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);
PG(unclean_shutdown) = 1;
return;
}
- _php3_hash_environment(PLS_C);
+ _php3_hash_environment(PLS_C ELS_CC);
#if WIN32||WINNT
UpdateIniFromRegistry(primary_file->filename);
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();
}
-sapi_functions_struct sapi_functions = {
+sapi_module_struct sapi_module = {
zend_apache_ub_write
};
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
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;
}
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");
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");
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;
char *filename;
char *path_info;
const char *path_translated;
- char *query_string;
const char *request_method;
char *script_name;
char *current_user;