Date: 05/31/98
- Next message: shane: "[PHP-DEV] CVS update: php31/sapi"
- Previous message: shane: "[PHP-DEV] CVS update: php31/ext/standard"
- Next in thread: shane: "[PHP-DEV] CVS update: php31/main"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sunday May 31, 1998 @ 15:44
Author: shane
Update of /repository/php31/main
In directory asf:/tmp/cvs-serv27884/main
Modified Files:
alloc.c hash.c main.c php.h
Log Message:
Moving much server specific code out to sapi interface files.
Index: php31/main/alloc.c
diff -c php31/main/alloc.c:1.3 php31/main/alloc.c:1.4
*** php31/main/alloc.c:1.3 Fri May 29 18:42:31 1998
--- php31/main/alloc.c Sun May 31 15:43:59 1998
***************
*** 258,263 ****
--- 258,264 ----
{
int length;
char *p;
+ TLS_VARS;
length = strlen(s)+1;
BLOCK_INTERRUPTIONS;
***************
*** 283,288 ****
--- 284,290 ----
#endif
{
char *p;
+ TLS_VARS;
BLOCK_INTERRUPTIONS;
#if DEBUG
Index: php31/main/hash.c
diff -c php31/main/hash.c:1.1.1.1 php31/main/hash.c:1.2
*** php31/main/hash.c:1.1.1.1 Tue May 26 22:27:01 1998
--- php31/main/hash.c Sun May 31 15:43:59 1998
***************
*** 29,35 ****
*/
! /* $Id: hash.c,v 1.1.1.1 1998/05/27 02:27:01 rasmus Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 29,35 ----
*/
! /* $Id: hash.c,v 1.2 1998/05/31 19:43:59 shane Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 532,537 ****
--- 532,538 ----
int if_full_do_resize(HashTable *ht)
{
Bucket **t;
+ TLS_VARS;
if ((ht->nNumOfElements > ht->nTableSize) && (ht->nHashSizeIndex < nNumPrimeNumbers - 1)) { /* Let's double the table
size */
***************
*** 570,575 ****
--- 571,577 ----
{
uint nIndex;
Bucket *p, *t = NULL; /* initialize just to shut gcc up with -Wall */
+ TLS_VARS;
if (flag == HASH_DEL_KEY) {
HANDLE_NUMERIC(arKey,nKeyLength,hash_del_key_or_index(ht,arKey,nKeyLength,idx,HASH_DEL_INDEX));
***************
*** 978,983 ****
--- 980,986 ----
Bucket **arTmp;
Bucket *p;
int i, j;
+ TLS_VARS;
if (ht->nNumOfElements <= 1) { /* Doesn't require sorting */
return SUCCESS;
Index: php31/main/main.c
diff -c php31/main/main.c:1.15 php31/main/main.c:1.16
*** php31/main/main.c:1.15 Sun May 31 12:44:28 1998
--- php31/main/main.c Sun May 31 15:44:00 1998
***************
*** 29,35 ****
+----------------------------------------------------------------------+
*/
! /* $Id: main.c,v 1.15 1998/05/31 16:44:28 shane Exp $ */
/* #define CRASH_DETECTION */
--- 29,35 ----
+----------------------------------------------------------------------+
*/
! /* $Id: main.c,v 1.16 1998/05/31 19:44:00 shane Exp $ */
/* #define CRASH_DETECTION */
***************
*** 105,113 ****
static int module_initialized = 0;
int shutdown_requested;
unsigned int max_execution_time = 0;
- #if APACHE
- request_rec *php3_rqst = NULL; /* request record pointer for apache module version */
- #endif
#if PHP_DEBUGGER
--- 105,110 ----
***************
*** 132,151 ****
static void php3_timeout(int dummy);
static void php3_set_timeout(long seconds INLINE_TLS);
!
! #if DEBUG && MSVC5
! #define DODEBUGGER 1
/******************************************************************************
! /* function to send messages to MSVC5 debugger
/*****************************************************************************/
! void msvc5_debug(const char *format,...)
{
va_list args;
char buffer[1024];
va_start(args, format);
vsprintf(buffer, format, args);
! OutputDebugString(buffer);
va_end(args);
}
#endif
--- 129,156 ----
static void php3_timeout(int dummy);
static void php3_set_timeout(long seconds INLINE_TLS);
! #if defined(CRASH_DETECTION)
/******************************************************************************
! /* function to log debug messages
/*****************************************************************************/
! void debug_log(const char *format,...)
{
va_list args;
char buffer[1024];
+ TLS_VARS;
va_start(args, format);
vsprintf(buffer, format, args);
! #if 0
! if(php3_globals && GLOBAL(sapi_rqst)){ /* be sure we realy are started up first!*/
! GLOBAL(sapi_rqst)->debug_log(php3_globals,buffer);
! }
! #if MSVC5
! else{
! }
! #endif
! #endif
! OutputDebugString(buffer);
va_end(args);
}
#endif
***************
*** 183,213 ****
php3_error(E_PARSE, error);
}
-
- #if APACHE
- void php3_apache_puts(const char *s)
- {
- TLS_VARS;
-
- if (GLOBAL(php3_rqst)) {
- rputs(s, GLOBAL(php3_rqst));
- } else {
- fputs(s, stdout);
- }
- }
-
- void php3_apache_putc(char c)
- {
- TLS_VARS;
-
- if (GLOBAL(php3_rqst)) {
- rputc(c, GLOBAL(php3_rqst));
- } else {
- fputc(c, stdout);
- }
- }
- #endif
-
void php3_log_err(char *log_message)
{
FILE *log_file;
--- 188,193 ----
***************
*** 233,262 ****
#endif
}
/* Otherwise fall back to the default logging location. */
- #if APACHE
- if (GLOBAL(php3_rqst)) {
- #if MODULE_MAGIC_NUMBER >= 19970831
- aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, log_message);
- #else
- log_error(log_message, php3_rqst->server);
- #endif
- } else {
- fprintf(stderr, log_message);
- fprintf(stderr, "\n");
- }
- #endif /*APACHE */
-
- #if CGI_BINARY
- if (php3_header()) {
- fprintf(stderr, log_message);
- fprintf(stderr, "\n");
- }
- #endif
- #if USE_SAPI
if (php3_header()) {
GLOBAL(sapi_rqst)->log(php3_globals, log_message);
}
- #endif
}
--- 213,221 ----
***************
*** 274,304 ****
{
va_list args;
int ret;
- #if WIN32_SERVER_MOD || USE_SAPI || FHTTPD
char buffer[PRINTF_BUFFER_SIZE];
int size;
- #endif
TLS_VARS;
va_start(args, format);
- #if APACHE
- if (GLOBAL(php3_rqst)) {
- ret = vbprintf(GLOBAL(php3_rqst)->connection->client, format, args);
- } else {
- ret = vfprintf(stdout, format, args);
- }
- #endif
-
- #if CGI_BINARY
- ret = vfprintf(stdout, format, args);
- #endif
-
- #if FHTTPD
- size = vsnprintf(buffer, PRINTF_BUFFER_SIZE, format, args);
- ret = PHPWRITE(buffer, size);
- #endif
-
- #if USE_SAPI
size = vsprintf(buffer, format, args);
#if DEBUG
/* fix for memory manager shutting down before request is started! */
--- 233,243 ----
***************
*** 308,319 ****
#if DEBUG
}
#endif
! #if DODEBUGGER
else{
! msvc5_debug(buffer);
}
#endif
- #endif
va_end(args);
return ret;
}
--- 247,257 ----
#if DEBUG
}
#endif
! #if defined(CRASH_DETECTION)
else{
! debug_log(buffer);
}
#endif
va_end(args);
return ret;
}
***************
*** 436,447 ****
if (!GLOBAL(initialized) || GLOBAL(shutdown_requested)) {
return 0;
}
! #if APACHE
! if (php3_rqst->connection->aborted) {
GLOBAL(shutdown_requested) = ABNORMAL_SHUTDOWN;
return 0;
}
- #endif
#ifdef THREAD_SAFE
switch (read_next_token(&GLOBAL(token_cache_manager), &token, phplval, php3_globals, php_flex_gbl)) {
--- 374,383 ----
if (!GLOBAL(initialized) || GLOBAL(shutdown_requested)) {
return 0;
}
! if (GLOBAL(sapi_rqst)->aborted) {
GLOBAL(shutdown_requested) = ABNORMAL_SHUTDOWN;
return 0;
}
#ifdef THREAD_SAFE
switch (read_next_token(&GLOBAL(token_cache_manager), &token, phplval, php3_globals, php_flex_gbl)) {
***************
*** 554,566 ****
int php3_request_startup(INLINE_TLS_VOID)
{
! #if APACHE && defined(CRASH_DETECTION)
! {
! char log_message[256];
!
! snprintf(log_message,256,"php3_request_startup(): script='%s', pid=%d",php3_rqst->filename,getpid());
! log_error(log_message, php3_rqst->server);
! }
#endif
GLOBAL(max_execution_time) = GLOBAL(php3_ini).max_execution_time;
--- 490,497 ----
int php3_request_startup(INLINE_TLS_VOID)
{
! #if defined(CRASH_DETECTION)
! debug_log("php3_request_startup()");
#endif
GLOBAL(max_execution_time) = GLOBAL(php3_ini).max_execution_time;
***************
*** 570,576 ****
start_memory_manager();
- #if APACHE
/*
* For the Apache module version, this bit of code registers a cleanup
* function that gets triggered when our request pool is destroyed.
--- 501,506 ----
***************
*** 579,588 ****
* The php3_shutdown function needs to free all outstanding allocated
* memory.
*/
! block_alarms();
! register_cleanup(GLOBAL(php3_rqst)->pool, NULL, php3_request_shutdown, php3_request_shutdown_for_exec);
! unblock_alarms();
! #endif
/* initialize global variables */
{
--- 509,517 ----
* The php3_shutdown function needs to free all outstanding allocated
* memory.
*/
! GLOBAL(sapi_rqst)->block_alarms(php3_globals);
! GLOBAL(sapi_rqst)->register_cleanup(php3_globals, NULL, php3_request_shutdown, php3_request_shutdown_for_exec);
! GLOBAL(sapi_rqst)->unblock_alarms(php3_globals);
/* initialize global variables */
{
***************
*** 702,718 ****
void php3_request_shutdown(void *dummy INLINE_TLS)
{
! #if FHTTPD
! char tmpline[128];
! int i, serverdefined;
! #endif
! #if APACHE && defined(CRASH_DETECTION)
! {
! char log_message[256];
!
! snprintf(log_message,256,"php3_request_shutdown(): script='%s', pid=%d",php3_rqst->filename,getpid());
! log_error(log_message, php3_rqst->server);
! }
#endif
if (GLOBAL(initialized) & INIT_SYMBOL_TABLE) {
hash_destroy(&GLOBAL(symbol_table));
--- 631,638 ----
void php3_request_shutdown(void *dummy INLINE_TLS)
{
! #if defined(CRASH_DETECTION)
! debug_log("php3_request_shutdown()");
#endif
if (GLOBAL(initialized) & INIT_SYMBOL_TABLE) {
hash_destroy(&GLOBAL(symbol_table));
***************
*** 720,755 ****
}
GLOBAL(initialized) &= ~INIT_ENVIRONMENT; /* does not require any special shutdown */
! #if DODEBUGGER
! msvc5_debug("%d:INIT_SYMBOL_TABLE\n",GetCurrentThreadId());
#endif
/* remove classes and user-functions */
if (GLOBAL(module_initialized) & INIT_FUNCTION_TABLE) {
hash_apply(&GLOBAL(function_table), (int (*)(void *)) is_not_internal_function);
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_FUNCTION_TABLE\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_TOKEN_CACHE) {
tcm_destroy(&GLOBAL(token_cache_manager));
GLOBAL(initialized) &= ~INIT_TOKEN_CACHE;
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_TOKEN_CACHE\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_CSS) {
stack_destroy(&GLOBAL(css));
GLOBAL(initialized) &= ~INIT_CSS;
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_CSS\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_FOR_STACK) {
stack_destroy(&GLOBAL(for_stack));
GLOBAL(initialized) &= ~INIT_FOR_STACK;
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_FOR_STACK\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_SWITCH_STACK) {
switch_expr *se;
--- 640,675 ----
}
GLOBAL(initialized) &= ~INIT_ENVIRONMENT; /* does not require any special shutdown */
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_SYMBOL_TABLE\n",GetCurrentThreadId());
#endif
/* remove classes and user-functions */
if (GLOBAL(module_initialized) & INIT_FUNCTION_TABLE) {
hash_apply(&GLOBAL(function_table), (int (*)(void *)) is_not_internal_function);
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_FUNCTION_TABLE\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_TOKEN_CACHE) {
tcm_destroy(&GLOBAL(token_cache_manager));
GLOBAL(initialized) &= ~INIT_TOKEN_CACHE;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_TOKEN_CACHE\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_CSS) {
stack_destroy(&GLOBAL(css));
GLOBAL(initialized) &= ~INIT_CSS;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_CSS\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_FOR_STACK) {
stack_destroy(&GLOBAL(for_stack));
GLOBAL(initialized) &= ~INIT_FOR_STACK;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_FOR_STACK\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_SWITCH_STACK) {
switch_expr *se;
***************
*** 761,775 ****
stack_destroy(&GLOBAL(switch_stack));
GLOBAL(initialized) &= ~INIT_SWITCH_STACK;
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_SWITCH_STACK\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_INCLUDE_STACK) {
clean_input_source_stack();
GLOBAL(initialized) &= ~INIT_INCLUDE_STACK;
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_INCLUDE_STACK\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_FUNCTION_STATE_STACK) {
FunctionState *tmp;
--- 681,695 ----
stack_destroy(&GLOBAL(switch_stack));
GLOBAL(initialized) &= ~INIT_SWITCH_STACK;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_SWITCH_STACK\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_INCLUDE_STACK) {
clean_input_source_stack();
GLOBAL(initialized) &= ~INIT_INCLUDE_STACK;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_INCLUDE_STACK\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_FUNCTION_STATE_STACK) {
FunctionState *tmp;
***************
*** 794,801 ****
stack_destroy(&GLOBAL(function_state_stack));
GLOBAL(initialized) &= ~INIT_FUNCTION_STATE_STACK;
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_FUNCTION_STATE_STACK\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_VARIABLE_UNASSIGN_STACK) {
variable_tracker *tmp;
--- 714,721 ----
stack_destroy(&GLOBAL(function_state_stack));
GLOBAL(initialized) &= ~INIT_FUNCTION_STATE_STACK;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_FUNCTION_STATE_STACK\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_VARIABLE_UNASSIGN_STACK) {
variable_tracker *tmp;
***************
*** 810,917 ****
GLOBAL(initialized) &= ~INIT_VARIABLE_UNASSIGN_STACK;
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_VARIABLE_UNASSIGN_STACK\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_LIST) {
destroy_resource_list();
GLOBAL(initialized) &= ~INIT_LIST;
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_LIST\n",GetCurrentThreadId());
#endif
/* clean temporary dl's, run request shutdown's for modules */
hash_apply(&GLOBAL(module_registry), (int (*)(void *)) module_registry_cleanup);
/* FIXME the above line causes access violations in threads*/
! #if DODEBUGGER
! msvc5_debug("%d:temporary dl's\n",GetCurrentThreadId());
#endif
if (GLOBAL(module_initialized) & INIT_CONSTANTS) {
/* clean temporary defined constants */
clean_non_persistent_constants();
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_CONSTANTS\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_INCLUDE_NAMES_HASH) {
hash_destroy(&GLOBAL(include_names));
GLOBAL(initialized) &= ~INIT_INCLUDE_NAMES_HASH;
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_INCLUDE_NAMES_HASH\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_SCANNER) {
reset_scanner();
GLOBAL(initialized) &= ~INIT_SCANNER;
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_SCANNER\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_MEMORY_MANAGER) {
shutdown_memory_manager();
}
! #if DODEBUGGER
! msvc5_debug("%d:INIT_MEMORY_MANAGER\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized)) {
php3_error(E_WARNING, "Unknown resources in request shutdown function");
}
php3_unset_timeout(_INLINE_TLS_VOID);
! #if DODEBUGGER
! msvc5_debug("%d:timer unset\n",GetCurrentThreadId());
#endif
! #if CGI_BINARY
! fflush(stdout);
! if(GLOBAL(sapi_rqst)->php_argv0) {
! free(GLOBAL(sapi_rqst)->php_argv0);
! GLOBAL(sapi_rqst)->php_argv0 = NULL;
! }
! #endif
! #if FHTTPD
! if (response) {
! if (!headermade) {
! makestandardheader(response, 200, "text/html", "fhttpd", req && req->keepalive);
! } else {
! if (headerfirstline)
! putlinetoheader(response, headerfirstline);
! else
! putlinetoheader(response, "HTTP/1.0 200 OK\r\n");
! serverdefined = 0;
! for (i = 0; i < headerlines; i++) {
! if (!strncmp(currentheader[i], "Server:", 7))
! serverdefined = 1;
! putlinetoheader(response, currentheader[i]);
! }
! if (!serverdefined)
! putlinetoheader(response, "Server: fhttpd\r\n");
! if (response->datasize) {
! sprintf(tmpline, "Content-Length: %ld\r\n", response->datasize);
! putlinetoheader(response, tmpline);
! if (req && req->keepalive)
! putlinetoheader(response,
! "Connection: Keep-Alive\r\nKeep-Alive: max=0, timeout=30\r\n");
! }
! php3_fhttpd_free_header();
! }
! sendresponse(server, response);
! if (response->datasize)
! finishresponse(server, response);
! else
! finishdropresponse(server, response);
! deleteresponse(response);
! }
! response = NULL;
! if (req)
! deleterequest(req);
! req = NULL;
! #endif
! #if USE_SAPI
GLOBAL(sapi_rqst)->flush(php3_globals);
- #endif
}
static int php3_config_ini_startup(INLINE_TLS_VOID)
--- 730,791 ----
GLOBAL(initialized) &= ~INIT_VARIABLE_UNASSIGN_STACK;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_VARIABLE_UNASSIGN_STACK\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_LIST) {
destroy_resource_list();
GLOBAL(initialized) &= ~INIT_LIST;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_LIST\n",GetCurrentThreadId());
#endif
/* clean temporary dl's, run request shutdown's for modules */
hash_apply(&GLOBAL(module_registry), (int (*)(void *)) module_registry_cleanup);
/* FIXME the above line causes access violations in threads*/
! #if defined(CRASH_DETECTION)
! debug_log("%d:temporary dl's\n",GetCurrentThreadId());
#endif
if (GLOBAL(module_initialized) & INIT_CONSTANTS) {
/* clean temporary defined constants */
clean_non_persistent_constants();
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_CONSTANTS\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_INCLUDE_NAMES_HASH) {
hash_destroy(&GLOBAL(include_names));
GLOBAL(initialized) &= ~INIT_INCLUDE_NAMES_HASH;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_INCLUDE_NAMES_HASH\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_SCANNER) {
reset_scanner();
GLOBAL(initialized) &= ~INIT_SCANNER;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_SCANNER\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized) & INIT_MEMORY_MANAGER) {
shutdown_memory_manager();
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INIT_MEMORY_MANAGER\n",GetCurrentThreadId());
#endif
if (GLOBAL(initialized)) {
php3_error(E_WARNING, "Unknown resources in request shutdown function");
}
php3_unset_timeout(_INLINE_TLS_VOID);
! #if defined(CRASH_DETECTION)
! debug_log("%d:timer unset\n",GetCurrentThreadId());
#endif
! GLOBAL(sapi_rqst)->request_shutdown(php3_globals);
GLOBAL(sapi_rqst)->flush(php3_globals);
}
static int php3_config_ini_startup(INLINE_TLS_VOID)
***************
*** 932,940 ****
if (cfg_get_long("max_execution_time", &php3_ini_master.max_execution_time) == FAILURE) {
php3_ini_master.max_execution_time = 30;
}
- #if DODEBUGGER
- msvc5_debug("%d:INI config long worked\n",GetCurrentThreadId());
- #endif
if (cfg_get_long("memory_limit", &php3_ini_master.memory_limit) == FAILURE) {
php3_ini_master.memory_limit = 8 * 1048576;
}
--- 806,811 ----
***************
*** 1097,1104 ****
php3_ini_master.gpc_order = "GPC";
}
}
! #if DODEBUGGER
! msvc5_debug("%d:INI OK\n",GetCurrentThreadId());
#endif
return SUCCESS;
}
--- 968,975 ----
php3_ini_master.gpc_order = "GPC";
}
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INI OK\n",GetCurrentThreadId());
#endif
return SUCCESS;
}
***************
*** 1117,1133 ****
int php3_module_startup(INLINE_TLS_VOID)
{
- #if (WIN32|WINNT) && !(USE_SAPI)
- WORD wVersionRequested;
- WSADATA wsaData;
-
- wVersionRequested = MAKEWORD(2, 0);
- #else
if (GLOBAL(module_initialized)) {
return SUCCESS;
}
- #endif
-
#if HAVE_SETLOCALE
setlocale(LC_CTYPE, "");
--- 988,996 ----
***************
*** 1135,1149 ****
GLOBAL(error_reporting) = E_ALL;
- #if (WIN32|WINNT) && !(USE_SAPI)
- /* start up winsock services */
- if (WSAStartup(wVersionRequested, &wsaData) != 0) {
- php3_printf("\nwinsock.dll unusable. %d\n", WSAGetLastError());
- return FAILURE;
- }
- GLOBAL(module_initialized) |= INIT_WINSOCK;
- #endif
-
/* prepare function table hash */
if (hash_init(&GLOBAL(function_table), 100, NULL, pval_DESTRUCTOR, 1) == FAILURE) {
php3_printf("Unable to initialize function table.\n");
--- 998,1003 ----
***************
*** 1178,1189 ****
}
GLOBAL(module_initialized) |= INIT_CONSTANTS;
- #if !USE_SAPI || !(WIN32|WINNT)
- if (php3_config_ini_startup(_INLINE_TLS_VOID) == FAILURE) {
- return FAILURE;
- }
- #endif
-
if (module_startup_modules() == FAILURE) {
php3_printf("Unable to start modules\n");
return FAILURE;
--- 1032,1037 ----
***************
*** 1219,1250 ****
php3_shutdown_constants();
GLOBAL(module_initialized) &= ~INIT_CONSTANTS;
}
- #if !USE_SAPI || !(WIN32|WINNT)
- /* close down the ini config */
- php3_config_ini_shutdown(_INLINE_TLS_VOID);
- #endif
if (GLOBAL(module_initialized) & INIT_FUNCTION_TABLE) {
hash_destroy(&GLOBAL(function_table));
GLOBAL(module_initialized) &= ~INIT_FUNCTION_TABLE;
}
- #if (WIN32|WINNT) && !(USE_SAPI)
- /*close winsock */
- if (GLOBAL(module_initialized) & INIT_WINSOCK) {
- WSACleanup();
- GLOBAL(module_initialized) &= ~INIT_WINSOCK;
- }
- #endif
if (GLOBAL(module_initialized)) {
php3_error(E_WARNING, "Unknown resource in module shutdown");
}
- #if CGI_BINARY
- fflush(stdout);
- #endif
- #if 0 /* SAPI */
GLOBAL(sapi_rqst)->flush(php3_globals);
- #endif
}
--- 1067,1082 ----
***************
*** 1299,1406 ****
efree(t);
}
! #if APACHE
! {
! pval *tmp_ptr, tmp2;
! register int i;
! array_header *arr = table_elts(GLOBAL(php3_rqst)->subprocess_env);
! table_entry *elts = (table_entry *) arr->elts;
! int len;
!
! for (i = 0; i < arr->nelts; i++) {
! len = strlen(elts[i].key);
! t = estrndup(elts[i].key, len);
! if (elts[i].val) {
! tmp.value.str.len = strlen(elts[i].val);
! tmp.value.str.val = estrndup(elts[i].val, tmp.value.str.len);
! } else {
! tmp.value.str.len = 0;
! tmp.value.str.val = empty_string;
! }
! tmp.type = IS_STRING;
! if (hash_update(&GLOBAL(symbol_table), t, len + 1, &tmp, sizeof(pval), NULL) == FAILURE) {
! STR_FREE(tmp.value.str.val);
! }
! efree(t);
! }
! /* insert special variables */
! if (hash_find(&GLOBAL(symbol_table), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) & tmp_ptr) == SUCCESS) {
! tmp2 = *tmp_ptr;
! yystype_copy_constructor(&tmp2);
! hash_update(&GLOBAL(symbol_table), "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void *) & tmp2, sizeof(pval), NULL);
! }
! tmp.value.str.len = strlen(GLOBAL(php3_rqst)->uri);
! tmp.value.str.val = estrndup(GLOBAL(php3_rqst)->uri, tmp.value.str.len);
! tmp.type = IS_STRING;
! hash_update(&GLOBAL(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval), NULL);
! }
! #else
! #if FHTTPD
! {
! int i, j;
! if (req) {
! for (i = 0; i < req->nlines; i++) {
! if (req->lines[i].paramc > 1 && req->lines[i].params[0] && req->lines[i].params[1]) {
! tmp.value.str.len = strlen(req->lines[i].params[1]);
! tmp.value.str.val = estrndup(req->lines[i].params[1], tmp.value.str.len);
! tmp.type = IS_STRING;
! if (hash_update(&GLOBAL(symbol_table), req->lines[i].params[0],
! strlen(req->lines[i].params[0]) + 1,
! &tmp, sizeof(pval), NULL) == FAILURE) {
! efree(tmp.value.str.val);
! }
! }
! }
! if (req->script_name_resolved) {
! i = strlen(req->script_name_resolved);
! tmp.value.str.len = i;
! tmp.value.str.val = estrndup(req->script_name_resolved, i);
! tmp.type = IS_STRING;
! if (hash_update(&GLOBAL(symbol_table), "PATH_TRANSLATED",
! sizeof("PATH_TRANSLATED"),
! &tmp, sizeof(pval), NULL) == FAILURE) {
! efree(tmp.value.str.val);
! }
! if (req->script_name) {
! j = i - strlen(req->script_name);
! if (j > 0
! && !strcmp(req->script_name_resolved + j,
! req->script_name)) {
! tmp.value.str.len = j;
! tmp.value.str.val = estrndup(req->script_name_resolved, j);
! tmp.type = IS_STRING;
! if (hash_update(&GLOBAL(symbol_table), "DOCUMENT_ROOT",
! sizeof("DOCUMENT_ROOT"),
! &tmp, sizeof(pval), NULL) == FAILURE) {
! efree(tmp.value.str.val);
! }
! }
! }
! }
! }
! }
! #endif
! {
! /* Build the special-case PHP_SELF variable for the CGI version */
! char *sn, *pi;
! int l = 0;
!
! sn = GLOBAL(sapi_rqst)->script_name;
! pi = GLOBAL(sapi_rqst)->path_info;
! if (sn)
! l += strlen(sn);
! if (pi)
! l += strlen(pi);
! if (pi && sn && !strcmp(pi, sn)) {
! l -= strlen(pi);
! pi = NULL;
! }
! tmp.value.str.val = emalloc(l + 1);
! tmp.value.str.len = _php3_sprintf(tmp.value.str.val, "%s%s", (sn ? sn : ""), (pi ? pi : "")); /* SAFE */
! tmp.type = IS_STRING;
! hash_update(&GLOBAL(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval), NULL);
! }
! #endif
/* need argc/argv support as well */
--- 1131,1139 ----
efree(t);
}
!
! /* this replaces server specific hashing by moving it into sapi*/
! GLOBAL(sapi_rqst)->hash_server_env(php3_globals);
/* need argc/argv support as well */
***************
*** 1551,2239 ****
}
}
- #if CGI_BINARY
-
- static void _php3_usage(char *argv0)
- {
- char *prog;
-
- prog = strrchr(argv0, '/');
- if (prog) {
- prog++;
- } else {
- prog = "php";
- }
-
- php3_printf("Usage: %s [-q] [-h]"
- " [-s]"
- " [-v] [-i] [-f <file>] | "
- "{<file> [args...]}\n"
- " -q Quiet-mode. Suppress HTTP Header output.\n"
- " -s Display colour syntax highlighted source.\n"
- " -f<file> Parse <file>. Implies `-q'\n"
- " -v Version number\n"
- " -p Pretokenize a script (creates a .php3p file)\n"
- " -e Execute a pretokenized (.php3p) script\n"
- " -c<path> Look for php3.ini file in this directory\n"
- " -i PHP information\n"
- " -h This help\n", prog);
- }
-
- /* some systems are missing these from their header files */
- extern char *optarg;
- extern int optind;
-
- #if THREAD_SAFE
- extern flex_globals *yy_init_tls(void);
- extern void yy_destroy_tls(void);
- #endif
-
- int main(int argc, char *argv[])
- {
- int cgi = 0, c, i, len;
- FILE *in = NULL;
- char *s;
- int display_source_mode = 0;
- /* temporary locals */
- char *_cgi_filename=NULL;
- int _cgi_preprocess=PREPROCESS_NONE;
- int _cgi_display_source_mode=0;
- int _cgi_started=0;
- /* end of temporary locals */
- #ifdef THREAD_SAFE
- php3_globals_struct *php3_globals;
- flex_globals *php_flex_gbl;
- tls_startup();
- tls_create();
- php_flex_gbl = yy_init_tls();
- php3_globals = TlsGetValue(TlsIndex);
-
- if ((php3_globals == 0) && (GetLastError() != 0)) {
- if (!php3_header())
- exit(0);
- PUTS("TlsGetValue error\n");
- return FAILURE;
- }
- #endif
- #if WIN32|WINNT
- _fmode = _O_BINARY; /*sets default for file streams to binary */
- setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
- #endif
-
- /* Make sure we detect we are a cgi - a bit redundancy here,
- but the default case is that we have to check only the first one. */
- if (getenv("SERVER_SOFTWARE")
- || getenv("SERVER_NAME")
- || getenv("GATEWAY_INTERFACE")
- || getenv("REQUEST_METHOD")) {
- cgi = 1;
- if (argc > 1)
- GLOBAL(sapi_rqst)->php_argv0 = strdup(argv[1]);
- else GLOBAL(sapi_rqst)->php_argv0 = NULL;
- #if FORCE_CGI_REDIRECT
- if (!getenv("REDIRECT_STATUS")) {
- if (php3_header())
- PUTS("<b>Security Alert!</b> PHP CGI cannot be accessed directly.\n\
- \n\
- <P>This PHP CGI binary was compiled with force-cgi-redirect enabled. This\n\
- means that a page will only be served up if the REDIRECT_STATUS CGI variable is\n\
- set. This variable is set, for example, by Apache's Action directive redirect.\n\
- <P>You may disable this restriction by recompiling the PHP binary with the\n\
- --disable-force-cgi-redirect switch. If you do this and you have your PHP CGI\n\
- binary accessible somewhere in your web tree, people will be able to circumvent\n\
- .htaccess security by loading files through the PHP parser. A good way around\n\
- this is to define doc_root in your php3.ini file to something other than your\n\
- top-level DOCUMENT_ROOT. This way you can separate the part of your web space\n\n\
- which uses PHP from the normal part using .htaccess security. If you do not have\n\
- any .htaccess restrictions anywhere on your site you can leave doc_root undefined.\n\
- \n");
-
- /* remove that detailed explanation some time */
-
- return FAILURE;
- }
- #endif /* FORCE_CGI_REDIRECT */
- }
-
-
-
- if (!cgi) { /* never execute the arguments if you are a CGI */
- GLOBAL(sapi_rqst)->php_argv0 = NULL;
- while ((c = getopt(argc, argv, "c:qvishpe?vf:")) != -1) {
- switch (c) {
- case 'f':
- if (!_cgi_started){
- if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE || php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
- return FAILURE;
- }
- }
- _cgi_started=1;
- _cgi_filename = estrdup(optarg);
- /* break missing intentionally */
- case 'q':
- php3_noheader();
- break;
- case 'v':
- php3_printf("%s\n", PHP_VERSION);
- exit(1);
- break;
- case 'i':
- if (!_cgi_started) {
- if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE || php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
- return FAILURE;
- }
- }
- _cgi_started=1;
- php3_TreatHeaders();
- _php3_info();
- exit(1);
- break;
- case 'p': /* preprocess */
- _cgi_preprocess = PREPROCESS_PREPROCESS;
- php3_noheader();
- break;
- case 'e': /* execute preprocessed script */
- _cgi_preprocess = PREPROCESS_EXECUTE;
- break;
- case 's':
- _cgi_display_source_mode = 1;
- break;
- case 'c':
- GLOBAL(php3_ini_path) = strdup(optarg); /* intentional leak */
- break;
- case 'h':
- case '?':
- _php3_usage(argv[0]);
- exit(1);
- break;
- default:
- php3_printf("Warning: unrecognized option `-%c'\n", c);
- break;
- }
- }
- } /* not cgi */
-
- if (!_cgi_started) {
- if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE || php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
- return FAILURE;
- }
- }
- GLOBAL(phpin) = stdin;
- if (_cgi_filename) {
- GLOBAL(sapi_rqst)->filename = _cgi_filename;
- }
- GLOBAL(php3_preprocess) = _cgi_preprocess;
- display_source_mode = _cgi_display_source_mode;
- php3_TreatHeaders();
-
- if (!cgi) {
- if (!GLOBAL(sapi_rqst)->query_string) {
- for (i = optind, len = 0; i < argc; i++)
- len += strlen(argv[i]) + 1;
-
- s = malloc(len + 1); /* leak - but only for command line version, so ok */
- *s = '\0'; /* we are pretending it came from the environment */
- for (i = optind, len = 0; i < argc; i++) {
- strcat(s, argv[i]);
- if (i < (argc - 1))
- strcat(s, "+");
- }
- GLOBAL(sapi_rqst)->query_string = s;
- }
- if (!GLOBAL(sapi_rqst)->filename && argc > optind)
- GLOBAL(sapi_rqst)->filename = estrdup(argv[optind]);
- }
- /* If for some reason the CGI interface is not setting the
- PATH_TRANSLATED correctly, sapi_rqst.filename is NULL.
- We still call php3_fopen_for_parser, because if you set doc_root
- or user_dir configuration directives, PATH_INFO is used to construct
- the filename as a side effect of php3_fopen_for_parser.
- */
- if (cgi || GLOBAL(sapi_rqst)->filename)
- in = php3_fopen_for_parser();
-
- if (cgi && !in) {
- if (php3_header()) {
- PUTS("No input file specified.\n");
- #if 0 /* this is here for debuging under windows */
- if (argc) {
- i = 0;
- php3_printf("\nargc %d\n",argc);
- while (i <= argc) {
- php3_printf("%s\n",argv[i]);
- i++;
- }
- }
- #endif
- }
- php3_request_shutdown((void *) 0 _INLINE_TLS);
- php3_module_shutdown(_INLINE_TLS_VOID);
- return FAILURE;
- } else if (in) {
- /* #!php support */
- c = fgetc(in);
- if (c == '#') {
- while (c != 10 && c != 13) {
- c = fgetc(in); /* skip to end of line */
- }
- GLOBAL(phplineno)++;
- } else {
- rewind(in);
- }
- GLOBAL(phpin) = in;
- GLOBAL(initialized) |= INIT_SCANNER;
- phprestart(GLOBAL(phpin));
- }
- if (display_source_mode) {
- GLOBAL(Execute) = 0;
- GLOBAL(ExecuteFlag) = DONT_EXECUTE;
- GLOBAL(php3_display_source) = 1;
- if (!php3_header())
- exit(0);
- PUTS("<html><head><title>Source for ");
- PUTS(GLOBAL(sapi_rqst)->filename);
- PUTS("</title></head><body bgcolor=\"");
- PUTS(GLOBAL(php3_ini).highlight_bg);
- PUTS("\" text=\"");
- PUTS(GLOBAL(php3_ini).highlight_html);
- PUTS("\">\n"); /* color: seashell */
- }
- if (GLOBAL(php3_display_source) && GLOBAL(php3_preprocess) == PREPROCESS_PREPROCESS) {
- php3_printf("Can't preprocess while displaying source.<br>\n");
- return 0;
- }
- if (GLOBAL(php3_preprocess) == PREPROCESS_EXECUTE) {
- if (tcm_load(&GLOBAL(token_cache_manager))==FAILURE) {
- return 0;
- }
- GLOBAL(php3_preprocess) = PREPROCESS_NONE;
- }
- if (GLOBAL(php3_preprocess)==PREPROCESS_NONE) {
- php3_parse(GLOBAL(phpin));
- } else {
- pval yylval;
-
- #ifdef THREAD_SAFE
- while (phplex(&yylval, php3_globals, php_flex_gbl)); /* create the token cache */
- #else
- while (phplex(&yylval)); /* create the token cache */
- #endif
- tcm_save(&GLOBAL(token_cache_manager));
- }
-
- if (GLOBAL(php3_display_source)) {
- php3_printf("\n</html>\n");
- }
- if (GLOBAL(initialized)) {
- php3_header(); /* Make sure headers have been sent */
- php3_request_shutdown((void *) 0 _INLINE_TLS);
- php3_module_shutdown(_INLINE_TLS_VOID);
- #ifdef THREAD_SAFE
- yy_destroy_tls();
- tls_shutdown();
- tls_destroy();
- #endif
- return SUCCESS;
- } else {
- return FAILURE;
- }
- }
- #endif /* CGI_BINARY */
-
-
- #if APACHE
- PHPAPI int apache_php3_module_main(request_rec * r, int fd, int display_source_mode, int preprocessed)
- {
- FILE *in = NULL;
- TLS_VARS;
-
- GLOBAL(php3_rqst) = r;
-
- if (php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
- return FAILURE;
- }
- php3_TreatHeaders();
- in = fdopen(fd, "r");
- if (in) {
- GLOBAL(phpin) = in;
- phprestart(GLOBAL(phpin));
- GLOBAL(initialized) |= INIT_SCANNER;
- hash_index_update(&GLOBAL(include_names), 0, (void *) &GLOBAL(sapi_rqst)->filename, sizeof(char *), NULL);
- } else {
- return OK;
- }
- if (display_source_mode) {
- GLOBAL(Execute) = 0;
- GLOBAL(ExecuteFlag) = DONT_EXECUTE;
- GLOBAL(php3_display_source) = 1;
- if (!php3_header())
- return (OK);
- PUTS("<html><head><title>Source for ");
- PUTS(r->uri);
- PUTS("</title></head><body bgcolor=\"");
- PUTS(GLOBAL(php3_ini).highlight_bg);
- PUTS("\" text=\"");
- PUTS(GLOBAL(php3_ini).highlight_html);
- PUTS("\">\n"); /* color: seashell */
- }
- if (preprocessed) {
- if (tcm_load(&GLOBAL(token_cache_manager))==FAILURE) {
- return OK;
- }
- }
- (void) php3_parse(GLOBAL(phpin));
-
- if (GLOBAL(php3_display_source)) {
- php3_printf("\n</html>\n");
- }
- if (GLOBAL(initialized)) {
- php3_header(); /* Make sure headers have been sent */
- }
- return (OK);
- }
- #endif /* APACHE */
-
- #if FHTTPD
-
- char *get_pretokenized_name(void)
- {
- char *pretokenized_name = NULL;
-
- if (GLOBAL(sapi_rqst)->filename) {
- int length = strlen(GLOBAL(sapi_rqst)->filename);
-
- if (length > (sizeof(".php3") - 1) && !strcmp(GLOBAL(sapi_rqst)->filename + length - sizeof(".php3") + 1, ".php3")) {
- pretokenized_name = (char *) emalloc(length + 2);
- strcpy(pretokenized_name, GLOBAL(sapi_rqst)->filename);
- strcat(pretokenized_name, "p");
- } else {
- length += sizeof(".php3p");
- pretokenized_name = (char *) emalloc(length + 1);
- strcpy(pretokenized_name, GLOBAL(sapi_rqst)->filename);
- strcat(pretokenized_name, ".php3p");
- }
- } else {
- pretokenized_name = estrdup("stdin.php3p");
- }
- return pretokenized_name;
- }
-
-
- void _php3_usage(char *progname)
- {
- fprintf(stderr,
- "Usage: %s [options] [appname] [username] [hostname] [portname]\n"
- "Options:\n"
- " -d Daemon mode -- never attempt terminal I/O\n"
- " -s Socket mode, fhttpd internal use only\n"
- " -p Pipe mode, fhttpd internal use only\n"
- " -u<mask> Set umask\n"
- " -t<time> Idle timeout in seconds, 0 - disable\n"
- " -S Display colour syntax highlighted source\n"
- " -P Make and execute a pretokenized script\n"
- " (.php3p file) or, if pretokenized script, newer\n"
- " than original file exists, execute it instead\n"
- " -E Execute a pretokenized (.php3p) script\n"
- " -c<path> Look for php3.ini file in this directory\n"
- " (must appear before any other options)\n"
- " -v Version number\n"
- " -h This help\n",
- progname);
- }
-
- int main(int argc, char **argv)
- {
- int c, i, processing_error;
- FILE *in = NULL;
- FILE *in2;
- int display_source_mode = 0;
- int preprocess_mode = PREPROCESS_NONE;
- int argc1;
- char **argv1;
- int human = 1, fd2;
- int i0 = 0, i1 = 0;
- char *pn;
- struct stat statbuf, pstatbuf;
-
- #ifdef THREAD_SAFE
- php3_globals_struct *php3_globals;
- flex_globals *php_flex_gbl;
- tls_startup();
- tls_create();
- php_flex_gbl = yy_init_tls();
- php3_globals = TlsGetValue(TlsIndex);
-
- if ((php3_globals == 0) && (GetLastError() != 0)) {
- if (!php3_header())
- exit(0);
- PUTS("TlsGetValue error\n");
- return FAILURE;
- }
- #endif
-
- #if HAVE_SETLOCALE
- setlocale(LC_CTYPE, "");
- #endif
-
- if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE) {
- return FAILURE;
- }
- signal(SIGPIPE, SIG_IGN);
- umask(077);
-
- while ((c = getopt(argc, argv, "spdu:t:c:PESvh")) != -1) {
- switch (c) {
- case 'd':
- human = 0;
- break;
- case 's':
- i0 = 1;
- break;
- case 'p':
- i1 = 1;
- break;
- case 'u':
- if (*optarg == '0')
- umask(strtoul(optarg, NULL, 8));
- else
- umask(strtoul(optarg, NULL, 10));
- break;
- case 't':
- idle_timeout = atoi(optarg);
- break;
- case 'c':
- GLOBAL(php3_ini_path) = strdup(optarg); /* intentional leak */
- break;
- case 'P': /* preprocess */
- preprocess_mode = PREPROCESS_PREPROCESS;
- break;
- case 'E': /* execute preprocessed script */
- preprocess_mode = PREPROCESS_EXECUTE;
- break;
- case 'S':
- display_source_mode = 1;
- break;
- case 'v':
- printf("%s\n", PHP_VERSION);
- exit(1);
- break;
- case 'h':
- case ':':
- case '?':
- _php3_usage(argv[0]);
- return -1;
- }
- }
-
- argc1 = argc - optind;
- argv1 = (char **) malloc(sizeof(char *) * (argc1 + 2));
- if (!argv1)
- return -1;
- argv1 += 2;
- for (i = optind; i < argc; i++)
- argv1[i - optind] = argv[i];
-
- if (i0) {
- argv1--;
- *argv1 = "-s";
- argc1++;
- } else {
- if (i1) {
- argv1--;
- *argv1 = "-p";
- argc1++;
- }
- }
- argv1--;
- argc1++;
- *argv1 = *argv;
-
- server = createserver();
- if (!server)
- return -1;
-
- switch (servproc_init(server, human, argc1, argv1)) {
- case 0:
- break;
- case APP_ERR_HUMAN:
- _php3_usage(argv[0]);
- exit(1);
- break;
- case APP_ERR_CONFIG:
- fprintf(stderr, "%s: configuration error\n", server->app_progname);
- exit(1);
- break;
- case APP_ERR_READ:
- fprintf(stderr, "%s: read error\n", server->app_progname);
- exit(1);
- break;
- case APP_ERR_HOSTNAME:
- fprintf(stderr, "%s: can't resolve server hostname\n", server->app_progname);
- exit(1);
- break;
- case APP_ERR_SOCKET:
- fprintf(stderr, "%s: can't create socket\n", server->app_progname);
- exit(1);
- break;
- case APP_ERR_CONNECT:
- fprintf(stderr, "%s: can't connect\n", server->app_progname);
- exit(1);
- break;
- case APP_ERR_APPCONNECT:
- fprintf(stderr, "%s: connect error\n", server->app_progname);
- exit(1);
- break;
- case APP_ERR_USER:
- fprintf(stderr, "%s: login error\n", server->app_progname);
- exit(1);
- break;
- case APP_ERR_PASSWORD:
- fprintf(stderr, "%s: login error\n", server->app_progname);
- exit(1);
- break;
- case APP_ERR_APPLICATION:
- fprintf(stderr, "%s: application rejected by server\n", server->app_progname);
- exit(1);
- break;
- case APP_ERR_INSANE:
- case APP_ERR_DAEMON:
- case APP_ERR_AUTH:
- default:
- if (server->infd < 0)
- exit(1);
- }
-
- if (server->infd == 0 && server->outfd == 1) {
- close(2);
- fd2 = open("/dev/null", O_WRONLY);
- if (fd2 != 2) {
- dup2(fd2, 2);
- close(fd2);
- }
- }
- setcapabilities(server, APP_CAP_KEEPALIVE);
-
- exit_status = 0;
- while (!exit_status) {
- processing_error = 0;
- if (php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
- processing_error = 1;
- }
- if (!processing_error) {
- GLOBAL(phpin) = NULL;
- GLOBAL(current_lineno) = 0;
-
- php3_TreatHeaders();
-
- in = php3_fopen_for_parser();
-
- GLOBAL(php3_preprocess) = preprocess_mode;
-
- if (!in) {
- if (php3_header())
- PUTS("No input file specified.\n");
- php3_request_shutdown((void *) 0 _INLINE_TLS);
- processing_error = 1;
- } else {
- if (GLOBAL(php3_preprocess) == PREPROCESS_PREPROCESS) {
- pn = get_pretokenized_name();
- if (pn) {
- if (!stat(pn, &pstatbuf)
- && !fstat(fileno(in), &statbuf)
- && S_ISREG(pstatbuf.st_mode)
- && statbuf.st_mtime < pstatbuf.st_mtime) {
- in2 = fopen(pn, "r");
- if (in2) {
- fclose(in);
- in = in2;
- GLOBAL(php3_preprocess) = PREPROCESS_EXECUTE;
- }
- }
- efree(pn);
- }
- }
- if (GLOBAL(php3_preprocess) != PREPROCESS_EXECUTE) {
- /* #!php support */
- c = fgetc(in);
- if (c == '#') {
- while (c != 10 && c != 13) {
- c = fgetc(in); /* skip to end of line */
- }
- GLOBAL(phplineno)++;
- } else {
- rewind(in);
- }
- }
- GLOBAL(phpin) = in;
- GLOBAL(initialized) |= INIT_SCANNER;
- phprestart(GLOBAL(phpin));
-
- if (display_source_mode) {
- GLOBAL(Execute) = 0;
- GLOBAL(ExecuteFlag) = DONT_EXECUTE;
- GLOBAL(php3_display_source) = 1;
- if (php3_header()) {
- PUTS("<html><head><title>Source for ");
- PUTS(GLOBAL(sapi_rqst)->filename);
- PUTS("</title></head><body bgcolor=\"");
- PUTS(GLOBAL(php3_ini).highlight_bg);
- PUTS("\" text=\"");
- PUTS(GLOBAL(php3_ini).highlight_html);
- PUTS("\">\n"); /* color: seashell */
- } else {
- processing_error = 1;
- }
- }
- if (GLOBAL(php3_display_source) && GLOBAL(php3_preprocess) == PREPROCESS_PREPROCESS) {
- php3_printf("Can't preprocess while displaying source.<br>\n");
- processing_error = 1;
- }
- if (!processing_error) {
- if (GLOBAL(php3_preprocess) == PREPROCESS_EXECUTE) {
- if (tcm_load(&GLOBAL(token_cache_manager), GLOBAL(phpin))==FAILURE) {
- /* should bail out on an error, don't know how to do it in fhttpd */
- }
- GLOBAL(php3_preprocess) = PREPROCESS_NONE;
- }
- if (GLOBAL(php3_preprocess)!=PREPROCESS_NONE) {
- pval yylval;
-
- #ifdef THREAD_SAFE
- while (phplex(&yylval, php3_globals, php_flex_gbl)); /* create the token cache */
- #else
- while (phplex(&yylval)); /* create the token cache */
- #endif
- tcm_save(&GLOBAL(token_cache_manager));
- seek_token(&GLOBAL(token_cache_manager), 0, NULL);
- GLOBAL(php3_preprocess) = PREPROCESS_NONE;
- }
- php3_parse(GLOBAL(phpin));
-
- if (GLOBAL(php3_display_source)) {
- php3_printf("\n</html>\n");
- }
- }
- }
- }
- if (GLOBAL(initialized)) {
- php3_header(); /* Make sure headers have been sent */
- php3_request_shutdown((void *) 0 _INLINE_TLS);
- }
- }
- php3_module_shutdown(_INLINE_TLS_VOID);
- #ifdef THREAD_SAFE
- if (GLOBAL(initialized)) {
- yy_destroy_tls();
- tls_shutdown();
- tls_destroy();
- }
- #endif
- return 0;
- }
- #endif /* FHTTPD */
/******************************************************************************
--- 1284,1290 ----
***************
*** 2243,2249 ****
/*
/*****************************************************************************/
- #if USE_SAPI
#ifdef THREAD_SAFE
extern flex_globals *yy_init_tls(void);
extern void yy_destroy_tls(void);
--- 1294,1299 ----
***************
*** 2266,2273 ****
#if HAVE_SETLOCAL
setlocale(LC_CTYPE, "");
#endif
! #if DODEBUGGER
! msvc5_debug("########################\n%d:Process Start\n",GetCurrentThreadId());
#endif
PHP3_MUTEX_ALLOC(gLock);
--- 1316,1323 ----
#if HAVE_SETLOCAL
setlocale(LC_CTYPE, "");
#endif
! #if defined(CRASH_DETECTION)
! debug_log("########################\n%d:Process Start\n",GetCurrentThreadId());
#endif
PHP3_MUTEX_ALLOC(gLock);
***************
*** 2276,2306 ****
if (!PHP3_TLS_THREAD_INIT(TlsIndex,php3_globals,php3_globals_struct))return 0;
PHP3_TLS_GET(TlsIndex,php3_globals);
if(!php3_globals){
! #if DODEBUGGER
! msvc5_debug("%d:Process Start Could not get TLS VAR!\n",GetCurrentThreadId());
#endif
return 0;
}
! #if DODEBUGGER
! msvc5_debug("%d:TLS Init Success\n",GetCurrentThreadId());
#endif
if(!yy_init_tls())
return 0;
start_memory_manager();
if (php3_config_ini_startup(_INLINE_TLS_VOID) == FAILURE) {
shutdown_memory_manager();
return 0;
}
! #if DODEBUGGER
! msvc5_debug("%d:INI Load Success\n",GetCurrentThreadId());
#endif
if (php3_module_startup(php3_globals) == FAILURE) {
shutdown_memory_manager();
return 0;
}
! #if DODEBUGGER
! msvc5_debug("%d:DLL Load Success\n########################\n",GetCurrentThreadId());
#endif
shutdown_memory_manager();
return 1;
--- 1326,1358 ----
if (!PHP3_TLS_THREAD_INIT(TlsIndex,php3_globals,php3_globals_struct))return 0;
PHP3_TLS_GET(TlsIndex,php3_globals);
if(!php3_globals){
! #if defined(CRASH_DETECTION)
! debug_log("%d:Process Start Could not get TLS VAR!\n",GetCurrentThreadId());
#endif
return 0;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:TLS Init Success\n",GetCurrentThreadId());
#endif
if(!yy_init_tls())
return 0;
+
+ php3_globals->sapi_rqst=NULL;
start_memory_manager();
if (php3_config_ini_startup(_INLINE_TLS_VOID) == FAILURE) {
shutdown_memory_manager();
return 0;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:INI Load Success\n",GetCurrentThreadId());
#endif
if (php3_module_startup(php3_globals) == FAILURE) {
shutdown_memory_manager();
return 0;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:DLL Load Success\n########################\n",GetCurrentThreadId());
#endif
shutdown_memory_manager();
return 1;
***************
*** 2312,2337 ****
int _php3_sapi_thread_start(){
php3_globals_struct *php3_globals;
! #if DODEBUGGER
! msvc5_debug("########################\n%d:Thread Start\n",GetCurrentThreadId());
#endif
if (!PHP3_TLS_THREAD_INIT(TlsIndex,php3_globals,php3_globals_struct))return 0;
PHP3_TLS_GET(TlsIndex,php3_globals);
if(!php3_globals){
! #if DODEBUGGER
! msvc5_debug("%d:Could not get TLS VAR!\n########################\n",GetCurrentThreadId());
#endif
return 0;
}
if(!yy_init_tls())return 0;
start_memory_manager();
if (php3_module_startup(php3_globals) == FAILURE){
shutdown_memory_manager();
return 0;
}
shutdown_memory_manager();
! #if DODEBUGGER
! msvc5_debug("%d:DLL Thread Start Success\n########################\n",GetCurrentThreadId());
#endif
return 1;
}
--- 1364,1392 ----
int _php3_sapi_thread_start(){
php3_globals_struct *php3_globals;
! #if defined(CRASH_DETECTION)
! debug_log("########################\n%d:Thread Start\n",GetCurrentThreadId());
#endif
if (!PHP3_TLS_THREAD_INIT(TlsIndex,php3_globals,php3_globals_struct))return 0;
PHP3_TLS_GET(TlsIndex,php3_globals);
if(!php3_globals){
! #if defined(CRASH_DETECTION)
! debug_log("%d:Could not get TLS VAR!\n########################\n",GetCurrentThreadId());
#endif
return 0;
}
if(!yy_init_tls())return 0;
+
+ php3_globals->sapi_rqst=NULL;
+
start_memory_manager();
if (php3_module_startup(php3_globals) == FAILURE){
shutdown_memory_manager();
return 0;
}
shutdown_memory_manager();
! #if defined(CRASH_DETECTION)
! debug_log("%d:DLL Thread Start Success\n########################\n",GetCurrentThreadId());
#endif
return 1;
}
***************
*** 2346,2353 ****
php3_module_shutdown(php3_globals);
PHP3_TLS_THREAD_FREE(php3_globals);
yy_destroy_tls();
! #if DODEBUGGER
! msvc5_debug("%d:DLL Thread End Success\n",GetCurrentThreadId());
#endif
return 1;
}
--- 1401,1408 ----
php3_module_shutdown(php3_globals);
PHP3_TLS_THREAD_FREE(php3_globals);
yy_destroy_tls();
! #if defined(CRASH_DETECTION)
! debug_log("%d:DLL Thread End Success\n",GetCurrentThreadId());
#endif
return 1;
}
***************
*** 2363,2370 ****
PHP3_TLS_THREAD_FREE(php3_globals);
PHP3_TLS_PROC_SHUTDOWN(TlsIndex);
yy_destroy_tls();
! #if DODEBUGGER
! msvc5_debug("%d:DLL UNLoad Success\n",GetCurrentThreadId());
#endif
PHP3_MUTEX_FREE(gLock);
PHP3_CRITICAL_FREE(Tls_crit);
--- 1418,1425 ----
PHP3_TLS_THREAD_FREE(php3_globals);
PHP3_TLS_PROC_SHUTDOWN(TlsIndex);
yy_destroy_tls();
! #if defined(CRASH_DETECTION)
! debug_log("%d:DLL UNLoad Success\n",GetCurrentThreadId());
#endif
PHP3_MUTEX_FREE(gLock);
PHP3_CRITICAL_FREE(Tls_crit);
***************
*** 2384,2396 ****
#if THREAD_SAFE
flex_globals *php_gbl;
php3_globals_struct *php3_globals;
! #if DODEBUGGER
! msvc5_debug("%d:main entered\n",GetCurrentThreadId());
! if(!TlsIndex)msvc5_debug("%d:Invalid TLSIndex!\n",GetCurrentThreadId());
#endif
if(TlsIndex){PHP3_TLS_GET(TlsIndex,php3_globals);}else{return FAILURE;}
! #if DODEBUGGER
! msvc5_debug("%d:main tls initialized\n",GetCurrentThreadId());
#endif
if(!php3_globals){
/* uninitialized thread, initialize now */
--- 1439,1451 ----
#if THREAD_SAFE
flex_globals *php_gbl;
php3_globals_struct *php3_globals;
! #if defined(CRASH_DETECTION)
! debug_log("%d:main entered\n",GetCurrentThreadId());
! if(!TlsIndex)debug_log("%d:Invalid TLSIndex!\n",GetCurrentThreadId());
#endif
if(TlsIndex){PHP3_TLS_GET(TlsIndex,php3_globals);}else{return FAILURE;}
! #if defined(CRASH_DETECTION)
! debug_log("%d:main tls initialized\n",GetCurrentThreadId());
#endif
if(!php3_globals){
/* uninitialized thread, initialize now */
***************
*** 2415,2429 ****
GLOBAL(php3_display_source) = sapi_info->display_source_mode;
GLOBAL(sapi_rqst) = sapi_info;
! #if DODEBUGGER
! msvc5_debug("%d:enter request startup\n",GetCurrentThreadId());
#endif
if (php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
return FAILURE;
}
! #if DODEBUGGER
! msvc5_debug("%d:request startup success\n",GetCurrentThreadId());
#endif
/* now we estrdup the rqst_filename into filename so the include hash works right */
if(sapi_info->rqst_filename)sapi_info->filename=estrdup(sapi_info->rqst_filename);
--- 1470,1484 ----
GLOBAL(php3_display_source) = sapi_info->display_source_mode;
GLOBAL(sapi_rqst) = sapi_info;
! #if defined(CRASH_DETECTION)
! debug_log("%d:enter request startup\n",GetCurrentThreadId());
#endif
if (php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
return FAILURE;
}
! #if defined(CRASH_DETECTION)
! debug_log("%d:request startup success\n",GetCurrentThreadId());
#endif
/* now we estrdup the rqst_filename into filename so the include hash works right */
if(sapi_info->rqst_filename)sapi_info->filename=estrdup(sapi_info->rqst_filename);
***************
*** 2448,2455 ****
sapi_rqst.filename will only be estrduped in fopen_for parser
&

