* Get rid of php3_rqst, use SG(server_context) instead (there's still Apache-specific code,
but it nuked a global)
SOURCE = main.c internal_functions.c snprintf.c php3_sprintf.c \
configuration-parser.c configuration-scanner.c request_info.c \
safe_mode.c fopen-wrappers.c php3_realpath.c alloca.c output.c \
- php_ini.c
+ php_ini.c SAPI.c
OBJS = main.o internal_functions.o snprintf.o php3_sprintf.o \
configuration-parser.o configuration-scanner.o request_info.o \
safe_mode.o fopen-wrappers.o php3_realpath.o alloca.o output.o \
- php_ini.o
+ php_ini.o SAPI.o
PHPLIBS = -L@top_srcdir@/libzend -lzend -Lext -lphpext
LIBS = $(PHPLIBS) $(EXTRA_LIBS) @LIBS@
])
-APACHE_INSTALL_FILES="$srcdir/mod_php3.* $srcdir/php_version.h libphp3.module"
+APACHE_INSTALL_FILES="$srcdir/mod_php3.* $srcdir/php_version.h libphp3.module $srcdir/SAPI.h"
AC_MSG_CHECKING(for Apache module support via DSO through APACI)
#include "ext/standard/head.h"
#include "php_globals.h"
#include "php_ini.h"
+#include "SAPI.h"
#include "mod_php3.h"
#include <stdlib.h>
pval *arg_name,*arg_val;
char *note_val;
int arg_count = ARG_COUNT(ht);
+ SLS_FETCH();
if (arg_count<1 || arg_count>2 ||
getParameters(ht,arg_count,&arg_name,&arg_val) == FAILURE ) {
}
convert_to_string(arg_name);
- note_val = (char *) table_get(php3_rqst->notes,arg_name->value.str.val);
+ note_val = (char *) table_get(((request_rec *) SG(server_context))->notes,arg_name->value.str.val);
if (arg_count == 2) {
convert_to_string(arg_val);
- table_set(php3_rqst->notes,arg_name->value.str.val,arg_val->value.str.val);
+ table_set(((request_rec *) SG(server_context))->notes,arg_name->value.str.val,arg_val->value.str.val);
}
if (note_val) {
char name[64];
char *p;
#endif
- server_rec *serv = php3_rqst->server;
+ server_rec *serv;
extern char server_root[MAX_STRING_LEN];
extern uid_t user_id;
extern char *user_name;
extern gid_t group_id;
extern int max_requests_per_child;
+ SLS_FETCH();
+ serv = ((request_rec *) SG(server_context))->server;
+
#if WIN32|WINNT
PUTS("Apache for Windows 95/NT<br>");
#else
{
pval *filename;
request_rec *rr = NULL;
+ SLS_FETCH();
if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(filename);
- if (!(rr = sub_req_lookup_uri (filename->value.str.val, php3_rqst))) {
+ if (!(rr = sub_req_lookup_uri (filename->value.str.val, ((request_rec *) SG(server_context))))) {
php3_error(E_WARNING, "Unable to include '%s' - URI lookup failed", filename->value.str.val);
if (rr) destroy_sub_req (rr);
RETURN_FALSE;
array_header *env_arr;
table_entry *tenv;
int i;
+ SLS_FETCH();
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
- env_arr = table_elts(php3_rqst->headers_in);
+ env_arr = table_elts(((request_rec *) SG(server_context))->headers_in);
tenv = (table_entry *)env_arr->elts;
for (i = 0; i < env_arr->nelts; ++i) {
if (!tenv[i].key ||
{
pval *filename;
request_rec *rr=NULL;
+ SLS_FETCH();
if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(filename);
- if(!(rr = sub_req_lookup_uri(filename->value.str.val, php3_rqst))) {
+ if(!(rr = sub_req_lookup_uri(filename->value.str.val, ((request_rec *) SG(server_context))))) {
php3_error(E_WARNING, "URI lookup failed", filename->value.str.val);
RETURN_FALSE;
}
#if 0
This function is most likely a bad idea. Just playing with it for now.
-void php3_apache_exec_uri(INTERNAL_FUNCTION_PARAMETERS) {
+void php3_apache_exec_uri(INTERNAL_FUNCTION_PARAMETERS)
+{
pval *filename;
request_rec *rr=NULL;
+ SLS_FETCH();
if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(filename);
- if(!(rr = ap_sub_req_lookup_uri(filename->value.str.val, php3_rqst))) {
+ if(!(rr = ap_sub_req_lookup_uri(filename->value.str.val, ((request_rec *) SG(server_context))))) {
php3_error(E_WARNING, "URI lookup failed", filename->value.str.val);
RETURN_FALSE;
}
#include "php.h"
#include "ext/standard/head.h"
#include <math.h>
+#include "SAPI.h"
#include "php3_gd.h"
#if HAVE_SYS_WAIT_H
#endif
}
-int php3_mend_gd(void){
+int php3_mend_gd(SHUTDOWN_FUNC_ARGS)
+{
GD_TLS_VARS;
#ifdef THREAD_SAFE
PHP3_TLS_THREAD_FREE(gdlib_globals);
output = php3_header();
if (output) {
+ SLS_FETCH();
+
gdImageGif (im, tmp);
fseek(tmp, 0, SEEK_SET);
#if APACHE && defined(CHARSET_EBCDIC)
/* This is a binary file already: avoid EBCDIC->ASCII conversion */
- ap_bsetflag(php3_rqst->connection->client, B_EBCDIC2ASCII, 0);
+ ap_bsetflag(((request_rec *) SG(server_context))->connection->client, B_EBCDIC2ASCII, 0);
#endif
while ((b = fread(buf, 1, sizeof(buf), tmp)) > 0) {
php3_write(buf, b);
/* gd.c functions */
extern void php3_info_gd(void);
extern int php3_minit_gd(INIT_FUNC_ARGS);
-extern int php3_mend_gd(void);
+extern int php3_mend_gd(SHUTDOWN_FUNC_ARGS);
extern int gdImageColorResolve(gdImagePtr, int, int, int);
extern void php3_imagearc(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagechar(INTERNAL_FUNCTION_PARAMETERS);
#if APACHE
{
int j;
- array_header *arr = table_elts(php3_rqst->subprocess_env);
+ SLS_FETCH();
+
+ array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
table_entry *elts = (table_entry *)arr->elts;
for (j=0; j < arr->nelts; j++) {
hw_connection *ptr;
hw_document *doc;
#if APACHE
- server_rec *serv = php3_rqst->server;
+ server_rec *serv;
+ SLS_FETCH();
+
+ serv = ((request_rec *) SG(server_context))->server;
#endif
argc = ARG_COUNT(ht);
hw_document *doc;
char cgi_env_str[1000];
#if APACHE
- server_rec *serv = php3_rqst->server;
+ server_rec *serv;
+ SLS_FETCH();
+
+ serv = ((request_rec *) SG(server_context))->server;
#endif
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
hw_connection *ptr;
hw_document *docptr;
#if APACHE
- server_rec *serv = php3_rqst->server;
+ server_rec *serv;
+ SLS_FETCH();
+
+ serv = ((request_rec *) SG(server_context))->server;
#endif
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
#include "zend_globals.h"
#include "php_globals.h"
+#include "SAPI.h"
static unsigned char second_and_third_args_force_ref[] = { 3, BYREF_NONE, BYREF_FORCE, BYREF_FORCE };
static unsigned char third_and_fourth_args_force_ref[] = { 4, BYREF_NONE, BYREF_NONE, BYREF_FORCE, BYREF_FORCE };
#endif
pval *str;
char *ptr;
+ SLS_FETCH();
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
WRONG_PARAM_COUNT;
if (str->type == IS_STRING &&
#if APACHE
- ((ptr = (char *)table_get(php3_rqst->subprocess_env, str->value.str.val)) || (ptr = getenv(str->value.str.val)))
+ ((ptr = (char *)table_get(((request_rec *) SG(server_context))->subprocess_env, str->value.str.val)) || (ptr = getenv(str->value.str.val)))
#endif
#if CGI_BINARY
(ptr = getenv(str->value.str.val))
void php3_flush(INTERNAL_FUNCTION_PARAMETERS)
#endif
{
+ SLS_FETCH();
+
#if APACHE
# if MODULE_MAGIC_NUMBER > 19970110
- rflush(php3_rqst);
+ rflush(((request_rec *) SG(server_context)));
# else
- bflush(php3_rqst->connection->client);
+ bflush(((request_rec *) SG(server_context))->connection->client);
# endif
#endif
#if FHTTPD
#include "ext/standard/head.h"
#include "exec.h"
#include "php_globals.h"
+#include "SAPI.h"
#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
if (type != 3) {
while (fgets(buf, EXEC_INPUT_BUF - 1, fp)) {
if (type == 1) {
+ SLS_FETCH();
+
if (output) PUTS(buf);
#if APACHE
# if MODULE_MAGIC_NUMBER > 19970110
- if (output) rflush(php3_rqst);
+ if (output) rflush(((request_rec *) SG(server_context)));
# else
- if (output) bflush(php3_rqst->connection->client);
+ if (output) bflush(((request_rec *) SG(server_context))->connection->client);
# endif
#endif
#if CGI_BINARY
#include <stdio.h>
#include "php.h"
#include "ext/standard/php3_standard.h"
+#include "SAPI.h"
#include "main.h"
#include "head.h"
#include "post.h"
char *temp = NULL;
long myuid = 0L;
char temp2[32];
+ request_rec *req;
+ SLS_FETCH();
+
+ req = ((request_rec *) SG(server_context));
#endif
if (php3_HeaderPrinted == 1) {
*r = '\0';
if (!strcasecmp(header_information, "Content-type")) {
if (*(r + 1) == ' ')
- php3_rqst->content_type = pstrdup(php3_rqst->pool,r + 2);
+ req->content_type = pstrdup(req->pool,r + 2);
else
- php3_rqst->content_type = pstrdup(php3_rqst->pool,r + 1);
- cont_type = (char *)php3_rqst->content_type;
+ req->content_type = pstrdup(req->pool,r + 1);
+ cont_type = (char *) req->content_type;
} else {
if (*(r + 1) == ' ') {
rr = r + 2;
temp = _php3_regreplace("$", temp2, rr, 0, 0);
}
}
- table_set(php3_rqst->headers_out, header_information, temp);
+ table_set(req->headers_out, header_information, temp);
} else
- table_set(php3_rqst->headers_out, header_information, rr);
+ table_set(req->headers_out, header_information, rr);
}
if (!strcasecmp(header_information, "location")) {
- php3_rqst->status = REDIRECT;
+ req->status = REDIRECT;
}
*r = ':';
php3_HeaderPrinted = 2;
}
if (!strncasecmp(header_information, "http/", 5)) {
if (strlen(header_information) > 9) {
- php3_rqst->status = atoi(&((header_information)[9]));
+ req->status = atoi(&((header_information)[9]));
}
/* Use a pstrdup here to get the memory straight from Apache's per-request pool to
* avoid having our own memory manager complain about this memory not being freed
* because it really shouldn't be freed until the end of the request and it isn't
* easy for us to figure out when we allocated it vs. when something else might have.
*/
- php3_rqst->status_line = pstrdup(php3_rqst->pool,&((header_information)[9]));
+ req->status_line = pstrdup(req->pool,&((header_information)[9]));
}
#else
r = strchr(header_information, ':');
CookieList *cookie;
int len = 0;
time_t t;
- char *dt, *cookievalue = NULL;
+ char *dt, *cookievalue = NULL;
#endif
#if APACHE || defined(USE_SAPI) || FHTTPD
char *tempstr;
#endif
PLS_FETCH();
+ SLS_FETCH();
if (PG(header_is_being_sent)) {
return 0;
}
#if APACHE
- if (!php3_rqst) { /* we're not in a request, allow output */
+ if (!((request_rec *) SG(server_context))) { /* we're not in a request, allow output */
PG(header_is_being_sent) = 0;
return 1;
}
if (cookie->secure) {
strcat(tempstr, "; secure");
}
- table_add(php3_rqst->headers_out, "Set-Cookie", tempstr);
+ table_add(((request_rec *) SG(server_context))->headers_out, "Set-Cookie", tempstr);
if (cookie->domain) efree(cookie->domain);
if (cookie->path) efree(cookie->path);
if (cookie->name) efree(cookie->name);
}
php3_HeaderPrinted = 1;
header_called = 1;
- send_http_header(php3_rqst);
- if (php3_rqst->header_only) {
+ send_http_header(((request_rec *) SG(server_context)));
+ if (((request_rec *) SG(server_context))->header_only) {
set_header_request(1);
PG(header_is_being_sent) = 0;
return(0);
#include "php_globals.h"
#include "ext/standard/head.h"
#include "info.h"
+#include "SAPI.h"
#ifndef MSVC5
#include "build-defs.h"
#endif
ELS_FETCH();
PLS_FETCH();
-
#if WIN32|WINNT
// Get build numbers for Windows NT or Win95
if (dwVersion < 0x80000000){
PUTS("<img src=\"");
- /*PUTS(php3_rqst->uri);*/
+ /*PUTS(r->uri);*/
PUTS("?=PHPE9568F34-D428-11d2-A769-00AA001ACF42\" border=\"0\" width=\"100\" height=\"56\" align=\"right\">\n");
php3_printf("<center><h1>PHP Version %s</h1></center>\n", PHP_VERSION);
PUTS("<p>by <a href=\"mailto:rasmus@lerdorf.on.ca\">Rasmus Lerdorf</a>,\n");
#if APACHE
{
register int i;
- array_header *arr = table_elts(php3_rqst->subprocess_env);
- table_entry *elts = (table_entry *)arr->elts;
+ array_header *arr;
+ table_entry *elts;
+ request_rec *r;
+ SLS_FETCH();
+ r = ((request_rec *) SG(server_context));
+ arr = table_elts(r->subprocess_env);
+ elts = (table_entry *)arr->elts;
+
SECTION("Apache Environment");
PUTS("<table border=5 width=\"600\">\n");
PUTS("<tr><th bgcolor=\"" HEADER_COLOR "\">Variable</th><th bgcolor=\"" HEADER_COLOR "\">Value</th></tr>\n");
array_header *env_arr;
table_entry *env;
int i;
-
+ request_rec *r;
+ SLS_FETCH();
+
+ r = ((request_rec *) SG(server_context));
SECTION("HTTP Headers Information");
PUTS("<table border=5 width=\"600\">\n");
PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP Request Headers</th></tr>\n");
PUTS("<tr><td bgcolor=\"" ENTRY_NAME_COLOR "\">HTTP Request</td><td bgcolor=\"" CONTENTS_COLOR "\">");
- PUTS(php3_rqst->the_request);
+ PUTS(r->the_request);
PUTS(" </td></tr>\n");
- env_arr = table_elts(php3_rqst->headers_in);
+ env_arr = table_elts(r->headers_in);
env = (table_entry *)env_arr->elts;
for (i = 0; i < env_arr->nelts; ++i) {
if (env[i].key) {
}
}
PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP Response Headers</th></tr>\n");
- env_arr = table_elts(php3_rqst->headers_out);
+ env_arr = table_elts(r->headers_out);
env = (table_entry *)env_arr->elts;
for(i = 0; i < env_arr->nelts; ++i) {
if (env[i].key) {
PUTS("<table width=\"100%%\"><tr>\n");
php3_printf("<td><h2>Zend</h2>This program makes use of the Zend scripting language engine:<br><pre>%s</pre></td>", get_zend_version());
PUTS("<td width=\"100\"><a href=\"http://www.zend.com/\"><img src=\"");
- /*PUTS(php3_rqst->uri);*/
+ /*PUTS(r->uri);*/
PUTS("?=PHPE9568F35-D428-11d2-A769-00AA001ACF42\" border=\"0\" width=\"100\" height=\"89\"></a></td>\n");
PUTS("</tr></table>\n");
#include "php.h"
#include "pageinfo.h"
+#include "SAPI.h"
#include <stdio.h>
#include <stdlib.h>
#if !APACHE
char *path;
struct stat sb;
+#else
+ request_rec *r;
+ SLS_FETCH();
+
+ r = ((request_rec *) SG(server_context));
#endif
#if APACHE
values. We can afford it, and it means we don't have to
worry about resetting the static variables after every
hit. */
- page_uid = php3_rqst->finfo.st_uid;
- page_inode = php3_rqst->finfo.st_ino;
- page_mtime = php3_rqst->finfo.st_mtime;
+ page_uid = r ->finfo.st_uid;
+ page_inode = r->finfo.st_ino;
+ page_mtime = r->finfo.st_mtime;
#else
if (page_uid == -1) {
path = request_info.filename;
#include "php.h"
#include "php3_standard.h"
#include "php_globals.h"
+#include "SAPI.h"
#include "zend_globals.h"
int file_upload = 0;
char *mb;
char boundary[100];
+ SLS_FETCH();
ctype = request_info.content_type;
if (!ctype) {
buf[length]=0;
#else
#if MODULE_MAGIC_NUMBER > 19961007
- if (should_client_block(php3_rqst)) {
+ if (should_client_block(SG(server_context))) {
void (*handler) (int);
int dbsize, len_read, dbpos = 0;
- hard_timeout("copy script args", php3_rqst); /* start timeout timer */
+ hard_timeout("copy script args", ((request_rec *) SG(server_context))); /* start timeout timer */
handler = signal(SIGPIPE, SIG_IGN); /* Ignore sigpipes for now */
- while ((len_read = get_client_block(php3_rqst, argsbuffer, HUGE_STRING_LEN)) > 0) {
+ while ((len_read = get_client_block(((request_rec *) SG(server_context)), argsbuffer, HUGE_STRING_LEN)) > 0) {
if ((dbpos + len_read) > length)
dbsize = length - dbpos;
else
dbsize = len_read;
- reset_timeout(php3_rqst); /* Make sure we don't timeout */
+ reset_timeout(((request_rec *) SG(server_context))); /* Make sure we don't timeout */
memcpy(buf + dbpos, argsbuffer, dbsize);
dbpos += dbsize;
}
signal(SIGPIPE, handler); /* restore normal sigpipe handling */
- kill_timeout(php3_rqst); /* stop timeout timer */
+ kill_timeout(((request_rec *) SG(server_context))); /* stop timeout timer */
}
#else
cnt = 0;
do {
#if APACHE
- bytes = read_client_block(php3_rqst, buf + cnt, length - cnt);
+ bytes = read_client_block(((request_rec *) SG(server_context)), buf + cnt, length - cnt);
#endif
#if CGI_BINARY
bytes = fread(buf + cnt, 1, length - cnt, stdin);
char *user, *type;
int len;
char *escaped_str;
+ request_rec *r;
PLS_FETCH();
+ SLS_FETCH();
- if (php3_rqst->headers_in)
- s = table_get(php3_rqst->headers_in, "Authorization");
+ r = ((request_rec *) SG(server_context));
+
+ if (r->headers_in)
+ s = table_get(r->headers_in, "Authorization");
if (!s)
return;
/* Check to make sure that this URL isn't authenticated
using a traditional auth module mechanism */
- if (auth_type(php3_rqst)) {
+ if (auth_type(r)) {
/*php3_error(E_WARNING, "Authentication done by server module\n");*/
return;
}
- if (strcmp(t=getword(php3_rqst->pool, &s, ' '), "Basic")) {
+ if (strcmp(t=getword(r->pool, &s, ' '), "Basic")) {
/* Client tried to authenticate using wrong auth scheme */
php3_error(E_WARNING, "client used wrong authentication scheme (%s)", t);
return;
}
- t = uudecode(php3_rqst->pool, s);
+ t = uudecode(r->pool, s);
#if MODULE_MAGIC_NUMBER > 19961007
- user = getword_nulls_nc(php3_rqst->pool, &t, ':');
+ user = getword_nulls_nc(r->pool, &t, ':');
#else
- user = getword(php3_rqst->pool, &t, ':');
+ user = getword(r->pool, &t, ':');
#endif
type = "Basic";
php3_sybase_module.num_links++;
} else { /* we do */
if (le->type != php3_sybase_module.le_plink) {
-#if BROKEN_SYBASE_PCONNECTS
- log_error("PHP/Sybase: Hashed persistent link is not a Sybase link!",php3_rqst->server);
-#endif
php3_error(E_WARNING,"Sybase: Hashed persistent link is not a Sybase link!");
RETURN_FALSE;
}
sybase_ptr = (sybase_link *) le->ptr;
/* test that the link hasn't died */
if (DBDEAD(sybase_ptr->link)==TRUE) {
-#if BROKEN_SYBASE_PCONNECTS
- log_error("PHP/Sybase: Persistent link died, trying to reconnect...",php3_rqst->server);
-#endif
if ((sybase_ptr->link=dbopen(sybase_ptr->login,host))==FAIL) {
-#if BROKEN_SYBASE_PCONNECTS
- log_error("PHP/Sybase: Unable to reconnect!",php3_rqst->server);
-#endif
/*php3_error(E_WARNING,"Sybase: Link to server lost, unable to reconnect");*/
_php3_hash_del(plist, hashed_details, hashed_details_length+1);
efree(hashed_details);
RETURN_FALSE;
}
-#if BROKEN_SYBASE_PCONNECTS
- log_error("PHP/Sybase: Reconnect successful!",php3_rqst->server);
-#endif
if (dbsetopt(sybase_ptr->link,DBBUFFER,"2",-1)==FAIL) {
-#if BROKEN_SYBASE_PCONNECTS
- log_error("PHP/Sybase: Unable to set required options",php3_rqst->server);
-#endif
_php3_hash_del(plist, hashed_details, hashed_details_length+1);
efree(hashed_details);
RETURN_FALSE;
}
}
-void fhttpd_flush( /*php3_rqst->connection */ void)
+void fhttpd_flush(void)
{
}
#ifdef ZTS
SAPI_API int sapi_globals_id;
+#else
+sapi_globals_struct sapi_globals;
#endif
/* A true global (no need for thread safety) */
/* True global (no need for thread safety */
static int module_initialized = 0;
-#ifndef ZTS
-
-/*
- * Globals yet to be protected
- */
-
-#if APACHE
-request_rec *php3_rqst = NULL; /* request record pointer for apache module version */
-#endif
-
-/*
- * End of globals to be protected
- */
-
-#endif
#if APACHE
void php3_apache_puts(const char *s)
{
- if (php3_rqst) {
- rputs(s, php3_rqst);
+ SLS_FETCH();
+
+ if (SG(server_context)) {
+ rputs(s, (request_rec *) SG(server_context));
} else {
fputs(s, stdout);
}
void php3_apache_putc(char c)
{
- if (php3_rqst) {
- rputc(c, php3_rqst);
+ SLS_FETCH();
+
+ if (SG(server_context)) {
+ rputc(c, (request_rec *) SG(server_context));
} else {
fputc(c, stdout);
}
{
FILE *log_file;
PLS_FETCH();
+ SLS_FETCH();
/* Try to use the specified logging location. */
if (PG(error_log) != NULL) {
}
/* Otherwise fall back to the default logging location. */
#if APACHE
- if (php3_rqst) {
+ if (SG(server_context)) {
#if MODULE_MAGIC_NUMBER >= 19970831
- aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, log_message);
+ aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, log_message);
#else
- log_error(log_message, php3_rqst->server);
+ log_error(log_message, ((requset_rec *) SG(server_context))->server);
#endif
} else {
fprintf(stderr, log_message);
break;
case ZMSG_MEMORY_LEAK_DETECTED: {
ELS_FETCH();
+ SLS_FETCH();
if (EG(error_reporting)&E_WARNING) {
#if ZEND_DEBUG
snprintf(memory_leak_buf,512,"Possible PHP4 memory leak detected (harmless): 0x%0.8lX, %d bytes from %s:%d", (long) t, t->size, t->filename, t->lineno);
# if MODULE_MAGIC_NUMBER >= 19970831
- aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, memory_leak_buf);
+ aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, memory_leak_buf);
# else
- log_error(memory_leak_buf,php3_rqst->server);
+ log_error(memory_leak_buf, ((request_rec *) SG(server_context))->server);
# endif
# else
php3_printf("Freeing 0x%0.8X (%d bytes), allocated in %s on line %d<br>\n",(void *)((char *)t+sizeof(mem_header)+PLATFORM_PADDING),t->size,t->filename,t->lineno);
-int php_request_startup(CLS_D ELS_DC PLS_DC)
+int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC)
{
zend_output_startup();
* memory.
*/
block_alarms();
- register_cleanup(php3_rqst->pool, NULL, php_request_shutdown, php_request_shutdown_for_exec);
+ register_cleanup(((request_rec *) SG(server_context))->pool, NULL, php_request_shutdown, php_request_shutdown_for_exec);
unblock_alarms();
#endif
{
pval **tmp_ptr;
register int i;
- array_header *arr = table_elts(php3_rqst->subprocess_env);
+ array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
table_entry *elts = (table_entry *) arr->elts;
int len;
_php3_hash_update(&EG(symbol_table), "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), tmp_ptr, sizeof(pval *), NULL);
}
tmp = (pval *) emalloc(sizeof(pval));
- tmp->value.str.len = strlen(php3_rqst->uri);
- tmp->value.str.val = estrndup(php3_rqst->uri, tmp->value.str.len);
+ tmp->value.str.len = strlen(((request_rec *) SG(server_context))->uri);
+ tmp->value.str.val = estrndup(((request_rec *) SG(server_context))->uri, tmp->value.str.len);
tmp->refcount=1;
tmp->is_ref=0;
tmp->type = IS_STRING;
/* some systems are missing these from their header files */
#if APACHE
-PHPAPI int apache_php3_module_main(request_rec * r, int fd, int display_source_mode)
+PHPAPI int apache_php3_module_main(request_rec *r, int fd, int display_source_mode)
{
zend_file_handle file_handle;
#ifdef ZTS
zend_executor_globals *executor_globals=⪚
php_core_globals *core_globals=&pcg;
#endif
+ SLS_FETCH();
- php3_rqst = r;
+ SG(server_context) = r;
if (php_request_startup(CLS_C ELS_CC PLS_CC) == FAILURE) {
return FAILURE;
#include "http_log.h"
#define BLOCK_INTERRUPTIONS block_alarms
#define UNBLOCK_INTERRUPTIONS unblock_alarms
-# ifndef THREAD_SAFE
-extern request_rec *php3_rqst;
-# endif
#endif
#if HAVE_PWD_H
#include <sys/stat.h>
#include "ext/standard/pageinfo.h"
#include "safe_mode.h"
+#include "SAPI.h"
/*
* _php3_checkuid
#endif
struct passwd *pwd;
int uid;
+ SLS_FETCH();
if (request_info.current_user) {
return request_info.current_user;
uid = statbuf.st_uid;
#endif
#if APACHE
- uid = php3_rqst->finfo.st_uid;
+ uid = ((request_rec *) SG(server_context))->finfo.st_uid;
#endif
if ((pwd=getpwuid(uid))==NULL) {
#include "http_protocol.h"
#include "http_request.h"
#include "http_log.h"
+#include "SAPI.h"
/* These are taken out of php_ini.h
static int zend_apache_ub_write(const char *str, uint str_length)
{
- if (php3_rqst) {
- return rwrite(str, str_length, php3_rqst);
+ SLS_FETCH();
+
+ if (SG(server_context)) {
+ return rwrite(str, str_length, (request_rec *) SG(server_context));
} else {
return fwrite(str, 1, str_length, stdout);
}
*/
#include "php.h"
+#include "SAPI.h"
#ifndef THREAD_SAFE
PHPAPI php3_request_info request_info;
int php3_init_request_info(void *conf)
{
const char *buf;
+ request_rec *r;
+ SLS_FETCH();
+ r = ((request_rec *) SG(server_context));
request_info.current_user = NULL;
request_info.current_user_length = 0;
- request_info.filename = php3_rqst->filename;
- request_info.request_method = php3_rqst->method;
- request_info.query_string = php3_rqst->args;
- request_info.content_type = table_get(php3_rqst->subprocess_env, "CONTENT_TYPE");
+ 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(php3_rqst->subprocess_env, "CONTENT_LENGTH");
+ buf = table_get(r->subprocess_env, "CONTENT_LENGTH");
request_info.content_length = (buf ? atoi(buf) : 0);
- request_info.cookies = table_get(php3_rqst->subprocess_env, "HTTP_COOKIE");
+ request_info.cookies = table_get(r->subprocess_env, "HTTP_COOKIE");
return SUCCESS;
}