]> granicus.if.org Git - php/commitdiff
* Get the Apache module to compile again
authorZeev Suraski <zeev@php.net>
Mon, 26 Apr 1999 17:26:37 +0000 (17:26 +0000)
committerZeev Suraski <zeev@php.net>
Mon, 26 Apr 1999 17:26:37 +0000 (17:26 +0000)
* Get rid of php3_rqst, use SG(server_context) instead (there's still Apache-specific code,
  but it nuked a global)

21 files changed:
Makefile.in
configure.in.in
ext/apache/apache.c
ext/gd/gd.c
ext/gd/php3_gd.h
ext/hyperwave/hg_comm.c
ext/hyperwave/hw.c
ext/standard/basic_functions.c
ext/standard/exec.c
ext/standard/head.c
ext/standard/info.c
ext/standard/pageinfo.c
ext/standard/post.c
ext/sybase/sybase.c
fhttpd.c
main/SAPI.c
main/main.c
main/php.h
main/safe_mode.c
mod_php3.c
request_info.c

index 504158c01d56c45b232f544846b08c085dbb0600..c6cb22540b7ff0e80f5911753de9455e3b552ad8 100644 (file)
@@ -62,11 +62,11 @@ WARNING_LEVEL = @WARNING_LEVEL@
 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@
index c79da587f817edbd08209b654fbc8d316ddd04d7..c30f89f68e5772a67d0f566e0564cdc67cc45b90 100644 (file)
@@ -343,7 +343,7 @@ AC_ARG_WITH(apxs,
 ])
 
 
-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)
index c2fdeed19a7f11f841370900e66b7f1c8f141db5..1fe384e286074a73f64a810423b16f7b835bbc0b 100644 (file)
@@ -34,6 +34,7 @@
 #include "ext/standard/head.h"
 #include "php_globals.h"
 #include "php_ini.h"
+#include "SAPI.h"
 #include "mod_php3.h"
 
 #include <stdlib.h>
@@ -130,6 +131,7 @@ void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS)
        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 ) {
@@ -137,11 +139,11 @@ void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS)
        }
        
        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) {
@@ -158,13 +160,16 @@ void php3_info_apache(void) {
        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
@@ -214,13 +219,14 @@ void php3_virtual(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 = 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;
@@ -259,11 +265,12 @@ void php3_getallheaders(INTERNAL_FUNCTION_PARAMETERS)
     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 ||
@@ -284,13 +291,14 @@ void php3_apache_lookup_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 = 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;
        }
@@ -353,16 +361,18 @@ void php3_apache_lookup_uri(INTERNAL_FUNCTION_PARAMETERS)
 #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;
        }
index d0f0f9db22678143df94dc7b9fe09873c06cd177..eafea097508b92a8e04fd29f0001c00f1fd8c4d2 100644 (file)
@@ -39,6 +39,7 @@
 #include "php.h"
 #include "ext/standard/head.h"
 #include <math.h>
+#include "SAPI.h"
 #include "php3_gd.h"
 
 #if HAVE_SYS_WAIT_H
@@ -189,7 +190,8 @@ void php3_info_gd(void) {
 #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);
@@ -776,11 +778,13 @@ void php3_imagegif (INTERNAL_FUNCTION_PARAMETERS) {
                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);
index d65213f9ef1f7c390d5190b8011fbc9fd2ced4d6..912fa5d74020937ae3d96987bd730a6f6a3ab4ff 100644 (file)
@@ -49,7 +49,7 @@ extern php3_module_entry gd_module_entry;
 /* 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);
index 3e22b7f393042bd6de43bb1e374eb0b6eaadf553..eb10f00f19525c833ef2b35549278cce06eca06b 100644 (file)
@@ -461,7 +461,9 @@ char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag) {
 #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++) {
index 2ae3c26b745456f13270da1ecf081e349f66de74..8ac6dbd0700017b3a84c6c1c3f532c44e8ef6332 100644 (file)
@@ -1681,7 +1681,10 @@ void php3_hw_pipedocument(INTERNAL_FUNCTION_PARAMETERS) {
        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);
@@ -1748,7 +1751,10 @@ void php3_hw_pipecgi(INTERNAL_FUNCTION_PARAMETERS) {
        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) {
@@ -1809,7 +1815,10 @@ void php3_hw_insertdocument(INTERNAL_FUNCTION_PARAMETERS) {
        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) {
index d12fcddceafdef595b707730ceee29ae268e6e10..3c4041334f84d0956fc28fbb8a7638a85270aa8a 100644 (file)
@@ -56,6 +56,7 @@
 #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 };
@@ -396,6 +397,7 @@ void php3_getenv(INTERNAL_FUNCTION_PARAMETERS)
 #endif
        pval *str;
        char *ptr;
+       SLS_FETCH();
 
        if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
                WRONG_PARAM_COUNT;
@@ -423,7 +425,7 @@ void php3_getenv(INTERNAL_FUNCTION_PARAMETERS)
 
        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))
@@ -1166,11 +1168,13 @@ void php3_flush(HashTable *)
 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
index fe250c99859b6ed1fc910831442042145850bd12..3cd5b3a66b85577e8ed7efbe447dc79e6d93c41b 100644 (file)
@@ -36,6 +36,7 @@
 #include "ext/standard/head.h"
 #include "exec.h"
 #include "php_globals.h"
+#include "SAPI.h"
 
 #if HAVE_SYS_WAIT_H
 #include <sys/wait.h>
@@ -118,12 +119,14 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value)
        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
index 365728abd6cea0ffa564fa045048e26d87dd38ba..ad21e993541763682d6c77c7870bbc183f7602e5 100644 (file)
@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include "php.h"
 #include "ext/standard/php3_standard.h"
+#include "SAPI.h"
 #include "main.h"
 #include "head.h"
 #include "post.h"
@@ -84,6 +85,10 @@ void php4i_add_header_information(char *header_information)
        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) {
@@ -104,10 +109,10 @@ void php4i_add_header_information(char *header_information)
                *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;
@@ -126,26 +131,26 @@ void php4i_add_header_information(char *header_information)
                                                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, ':');
@@ -230,12 +235,13 @@ PHPAPI int php3_header(void)
        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;
@@ -244,7 +250,7 @@ PHPAPI int php3_header(void)
        }
 
 #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;
        }
@@ -305,7 +311,7 @@ PHPAPI int php3_header(void)
                        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);
@@ -317,8 +323,8 @@ PHPAPI int php3_header(void)
                }
                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);
index d0add9d66b5dff806db7af56876e0df9032e97a8..ceee00eb3ece4f7c320c66323a460766495b1b54 100644 (file)
@@ -33,6 +33,7 @@
 #include "php_globals.h"
 #include "ext/standard/head.h"
 #include "info.h"
+#include "SAPI.h"
 #ifndef MSVC5
 #include "build-defs.h"
 #endif
@@ -88,7 +89,6 @@ PHPAPI void _php3_info(void)
        ELS_FETCH();
        PLS_FETCH();
        
-       
 #if WIN32|WINNT
        // Get build numbers for Windows NT or Win95
        if (dwVersion < 0x80000000){
@@ -104,7 +104,7 @@ PHPAPI void _php3_info(void)
 
 
        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");
@@ -321,9 +321,15 @@ PHPAPI void _php3_info(void)
 #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");
@@ -343,14 +349,17 @@ PHPAPI void _php3_info(void)
                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("&nbsp;</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) {
@@ -362,7 +371,7 @@ PHPAPI void _php3_info(void)
                        }
                }
                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) {
@@ -383,7 +392,7 @@ PHPAPI void _php3_info(void)
        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");
 
index e22fce3afd017a8190e0545606e0b1ac0d9f0bc1..35b4a471a5ac5ba1be0313c9ef414ebb9ad2ee60 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "php.h"
 #include "pageinfo.h"
+#include "SAPI.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -59,6 +60,11 @@ static void _php3_statpage(void)
 #if !APACHE
        char *path;
        struct stat sb;
+#else
+       request_rec *r;
+       SLS_FETCH();
+       
+       r = ((request_rec *) SG(server_context));
 #endif
        
 #if APACHE
@@ -67,9 +73,9 @@ static void _php3_statpage(void)
           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   = ->finfo.st_uid;
+       page_inode = r->finfo.st_ino;
+       page_mtime = r->finfo.st_mtime;
 #else
        if (page_uid == -1) {
                path = request_info.filename;
index 7429cfeb7b8761013ece2c7714c17c9aacdf59c5..166c6799e7dcc525a876d83d8a4392dc3548bf23 100644 (file)
@@ -32,6 +32,7 @@
 #include "php.h"
 #include "php3_standard.h"
 #include "php_globals.h"
+#include "SAPI.h"
 
 #include "zend_globals.h"
 
@@ -54,6 +55,7 @@ static char *php3_getpost(pval *http_post_vars PLS_DC)
        int file_upload = 0;
        char *mb;
        char boundary[100];
+       SLS_FETCH();
        
        ctype = request_info.content_type;
        if (!ctype) {
@@ -92,29 +94,29 @@ static char *php3_getpost(pval *http_post_vars PLS_DC)
     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);
@@ -405,29 +407,33 @@ PHPAPI void php3_TreatHeaders(void)
        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";
 
index 11d5fcd768682edd0bacd9be2f3e5fe53d2683d5..df17867142bfc1f7b51bdedc9f8d06ecf2487071 100644 (file)
@@ -394,9 +394,6 @@ static void php3_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
                        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;
                        }
@@ -404,25 +401,13 @@ static void php3_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
                        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;
index 5bbc4c323373b0b207b905e03fcb43609c75d2e0..93ff105e42fb352ca67d0ccb9518dd5f22c1db20 100644 (file)
--- a/fhttpd.c
+++ b/fhttpd.c
@@ -169,7 +169,7 @@ PHPAPI void php3_fhttpd_puts_header(char *s)
        }
 }
 
-void fhttpd_flush( /*php3_rqst->connection */ void)
+void fhttpd_flush(void)
 {
 }
 
index 2456662401a9a3c275e983b1d6a9caf183ae5190..827bd2553f7742259edf6ea588e32bc001e3a032 100644 (file)
@@ -6,6 +6,8 @@
 
 #ifdef ZTS
 SAPI_API int sapi_globals_id;
+#else
+sapi_globals_struct sapi_globals;
 #endif
 
 /* A true global (no need for thread safety) */
index 0df2c4049e3e93740f80e8f1016ac356503e8749..6a3517c7cc80a31d44d1c83c9535b6e195c4c48e 100644 (file)
@@ -248,27 +248,14 @@ PHP_INI_END()
 /* 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);
        }
@@ -276,8 +263,10 @@ void php3_apache_puts(const char *s)
 
 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);
        }
@@ -288,6 +277,7 @@ void php3_log_err(char *log_message)
 {
        FILE *log_file;
        PLS_FETCH();
+       SLS_FETCH();
 
        /* Try to use the specified logging location. */
        if (PG(error_log) != NULL) {
@@ -310,11 +300,11 @@ void php3_log_err(char *log_message)
        }
        /* 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);
@@ -581,6 +571,7 @@ static void php_message_handler_for_zend(long message, void *data)
                        break;
                case ZMSG_MEMORY_LEAK_DETECTED: {
                                ELS_FETCH();
+                               SLS_FETCH();
 
                                if (EG(error_reporting)&E_WARNING) {
 #if ZEND_DEBUG
@@ -590,9 +581,9 @@ static void php_message_handler_for_zend(long message, void *data)
 
                                        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);
@@ -606,7 +597,7 @@ static void php_message_handler_for_zend(long message, void *data)
 
 
 
-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();
 
@@ -622,7 +613,7 @@ int php_request_startup(CLS_D ELS_DC PLS_DC)
         * 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
 
@@ -935,7 +926,7 @@ int _php3_hash_environment(PLS_D)
        {
                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;
 
@@ -961,8 +952,8 @@ int _php3_hash_environment(PLS_D)
                        _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;
@@ -1171,7 +1162,7 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
 /* 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
@@ -1182,8 +1173,9 @@ PHPAPI int apache_php3_module_main(request_rec * r, int fd, int display_source_m
        zend_executor_globals *executor_globals=&eg;
        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;
index ab4a159069d79b59c2c881c156646eed1bd8e478..f40528ea0024b1adbb53458bb8d72c82417c068f 100644 (file)
@@ -197,9 +197,6 @@ extern char *strerror(int);
 #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
index 7cf1d2214d0a6cb912bb8ef79182bf61be8ae879..422f8ba72f9980044fc7ce28fb3fb09c4bad7773 100644 (file)
@@ -39,6 +39,7 @@
 #include <sys/stat.h>
 #include "ext/standard/pageinfo.h"
 #include "safe_mode.h"
+#include "SAPI.h"
 
 /*
  * _php3_checkuid
@@ -125,6 +126,7 @@ PHPAPI char *_php3_get_current_user()
 #endif
        struct passwd *pwd;
        int uid;
+       SLS_FETCH();
 
        if (request_info.current_user) {
                return request_info.current_user;
@@ -140,7 +142,7 @@ PHPAPI char *_php3_get_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) {
index ba0d6b6db51aa731c23706d0cde9dc2d39f5f3ed..07641c7d37addd4e7b2e37b248d6eaef1918bc0b 100644 (file)
@@ -44,6 +44,7 @@
 #include "http_protocol.h"
 #include "http_request.h"
 #include "http_log.h"
+#include "SAPI.h"
 
 
 /* These are taken out of php_ini.h
@@ -101,8 +102,10 @@ void php3_save_umask()
 
 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);
        }
index b64ed54461219acb38ea55323aa2f40096a91628..0ca88fb3f623922c7589606976843145004a0dab 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include "php.h"
+#include "SAPI.h"
 
 #ifndef THREAD_SAFE
 PHPAPI php3_request_info request_info;
@@ -194,19 +195,22 @@ int php3_init_request_info(void *conf)
 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;
 }