Browse Source

request_info.c is dead! long live SAPI

@- 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)
PHP-4.0.5
Zeev Suraski 27 years ago
parent
commit
49e98c3ddd
  1. 7
      main/SAPI.c
  2. 4
      main/SAPI.h
  3. 6
      main/main.c
  4. 2
      main/php.h
  5. 10
      main/safe_mode.c
  6. 43
      request_info.c
  7. 41
      request_info.h

7
main/SAPI.c

@ -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);
}

4
main/SAPI.h

@ -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;

6
main/main.c

@ -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();

2
main/php.h

@ -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)

10
main/safe_mode.c

@ -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;
}

43
request_info.c

@ -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:
*/

41
request_info.h

@ -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:
*/
Loading…
Cancel
Save