]> granicus.if.org Git - php/commitdiff
request_info.c is dead! long live SAPI
authorZeev Suraski <zeev@php.net>
Thu, 10 Feb 2000 20:13:08 +0000 (20:13 +0000)
committerZeev Suraski <zeev@php.net>
Thu, 10 Feb 2000 20:13:08 +0000 (20:13 +0000)
@- Finished the server abstraction layer;  All of the PHP code is now shared
@  across different servers (Apache, CGI, IIS, etc.), except for thin
@  interface modules (Zeev)

main/SAPI.c
main/SAPI.h
main/main.c
main/php.h
main/safe_mode.c
request_info.c [deleted file]
request_info.h [deleted file]

index 006789a474445364d71a2228c759d6957bcc3fd5..04000a8bb49deddfb1dd053941bf376b69e71d9f 100644 (file)
@@ -12,7 +12,7 @@
    | obtain it through the world-wide-web, please send a note to          |
    | license@php.net so we can mail you a copy immediately.               |
    +----------------------------------------------------------------------+
-   | Design:  Shane Caraveo <shane@caraveo.com>                           |
+   | Original design:  Shane Caraveo <shane@caraveo.com>                  |
    | Authors: Andi Gutmans <andi@zend.com>                                |
    |          Zeev Suraski <zeev@zend.com>                                |
    +----------------------------------------------------------------------+
@@ -176,6 +176,8 @@ SAPI_API void sapi_activate(SLS_D)
        SG(headers_sent) = 0;
        SG(read_post_bytes) = 0;
        SG(request_info).post_data = NULL;
+       SG(request_info).current_user = NULL;
+       SG(request_info).current_user_length = 0;
 
        if (SG(request_info).request_method && !strcmp(SG(request_info).request_method, "HEAD")) {
                SG(request_info).headers_only = 1;
@@ -205,6 +207,9 @@ SAPI_API void sapi_deactivate(SLS_D)
        if (SG(request_info).post_data) {
                efree(SG(request_info).post_data);
        }
+       if (SG(request_info).current_user) {
+               efree(SG(request_info).current_user);
+       }
        if (sapi_module.deactivate) {
                sapi_module.deactivate(SLS_C);
        }
index 8b773e7e03ef5c3eff2137650708e43d5bad09c8..bb42da48e1c7a3da6e29db551f414ebb0a0db7ae 100644 (file)
@@ -79,6 +79,10 @@ typedef struct {
 
        /* this is necessary for the CGI SAPI module */
        char *argv0;
+
+       /* this is necessary for Safe Mode */
+       char *current_user;
+       int current_user_length;
 } sapi_request_info;
 
 
index 558bae1e3ad6fa1562a05098b9e9f61dd756106b..03ee7ca637fd06b3401dc23491b9233b77bf4ba0 100644 (file)
@@ -625,11 +625,6 @@ int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC)
 
        /* initialize global variables */
        PG(header_is_being_sent)=0;
-
-       if (php_init_request_info(NULL)) {
-               php_printf("Unable to initialize request info.\n");
-               return FAILURE;
-       }
        
        zend_activate(CLS_C ELS_CC);
        sapi_activate(SLS_C);   
@@ -674,7 +669,6 @@ void php_request_shutdown(void *dummy)
        zend_deactivate(CLS_C ELS_CC);
        sapi_deactivate(SLS_C);
 
-       php_destroy_request_info(NULL);
        shutdown_memory_manager(CG(unclean_shutdown), 0);
        php_unset_timeout();
 
index ff8c3c8c4399c1583bdf8944589aba739e07f6c4..9d710dbac13fbe4e9eef3e52527fe565f281d55f 100644 (file)
@@ -114,8 +114,6 @@ char *strtok_r(char *s, const char *delim, char **last);
 typedef unsigned int socklen_t;
 #endif
 
-#include "request_info.h"
-
 #define CREATE_MUTEX(a,b)
 #define SET_MUTEX(a)
 #define FREE_MUTEX(a)
index f274d23da83b051cc30a08d1691be1bf099f56bd..c022d600da4d90efaf82a1f81ae9cba427ffbeda 100644 (file)
@@ -114,8 +114,8 @@ PHPAPI char *php_get_current_user()
        struct stat *pstat;
        SLS_FETCH();
 
-       if (request_info.current_user) {
-               return request_info.current_user;
+       if (SG(request_info).current_user) {
+               return SG(request_info).current_user;
        }
 
        /* FIXME: I need to have this somehow handled if
@@ -131,8 +131,8 @@ PHPAPI char *php_get_current_user()
        if ((pwd=getpwuid(pstat->st_uid))==NULL) {
                return empty_string;
        }
-       request_info.current_user_length = strlen(pwd->pw_name);
-       request_info.current_user = estrndup(pwd->pw_name,request_info.current_user_length);
+       SG(request_info).current_user_length = strlen(pwd->pw_name);
+       SG(request_info).current_user = estrndup(pwd->pw_name, SG(request_info).current_user_length);
        
-       return request_info.current_user;               
+       return SG(request_info).current_user;           
 }      
diff --git a/request_info.c b/request_info.c
deleted file mode 100644 (file)
index 24e4345..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP version 4.0                                                      |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group                   |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Jim Winstead (jimw@php.net)                                  |
-   +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "SAPI.h"
-
-PHPAPI php_request_info request_info;
-
-int php_destroy_request_info(void *conf)
-{
-       STR_FREE(request_info.current_user);
-       return SUCCESS;
-}
-
-int php_init_request_info(void *conf)
-{
-    request_info.current_user = NULL;
-    request_info.current_user_length = 0;
-       return SUCCESS;
-}
-
-
-
-/* * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/request_info.h b/request_info.h
deleted file mode 100644 (file)
index d05cb7b..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP version 4.0                                                      |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group                   |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Jim Winstead (jimw@php.net)                                  |
-   +----------------------------------------------------------------------+
- */
-
-#ifndef _REQUEST_INFO_H_
-#define _REQUEST_INFO_H_
-
-typedef struct {
-       char *current_user;
-       int current_user_length;
-       const char *script_filename;
-} php_request_info;
-
-#ifndef THREAD_SAFE
-PHPAPI extern php_request_info request_info;
-#endif
-
-extern int php_init_request_info(void *conf);
-extern int php_destroy_request_info(void *conf);
-
-#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */