[PHP4BETA] CVS update: php4

From: Date: Sat, 24 Apr 1999 00:11:50 +0000
Subject: [PHP4BETA] CVS update: php4
Groups: php.version4 
Request: Send a blank email to php-version4+get-422@lists.php.net to get a copy of this message
Date: Friday April 23, 1999 @ 20:11 Author: zeev Update of /repository/php4 In directory php:/tmp/cvs-serv8598 Modified Files: configuration-parser.y fhttpd.c fopen-wrappers.c main.c main.h mod_php3.c output.c php.h php4.dsp php4ts.dsp request_info.c safe_mode.c Removed Files: bison.simple control_structures.h php3_threads.c php3_threads.h Log Message: A lot of cleanups... Removed old thread-safe code and other redundant code and files Index: php4/configuration-parser.y diff -u php4/configuration-parser.y:1.8 php4/configuration-parser.y:1.9 --- php4/configuration-parser.y:1.8 Wed Apr 21 20:25:51 1999 +++ php4/configuration-parser.y Fri Apr 23 20:11:48 1999 @@ -30,7 +30,7 @@ -/* $Id: configuration-parser.y,v 1.8 1999/04/22 00:25:51 ssb Exp $ */ +/* $Id: configuration-parser.y,v 1.9 1999/04/24 00:11:48 zeev Exp $ */ #define DEBUG_CFG_PARSER 1 #include "php.h" @@ -177,8 +177,8 @@ } #if WIN32|WINNT { - if (GLOBAL(php3_ini_path)) { - default_location = GLOBAL(php3_ini_path); + if (php3_ini_path) { + default_location = php3_ini_path; } else { default_location = (char *) malloc(512); @@ -189,17 +189,17 @@ } } #else - if (!GLOBAL(php3_ini_path)) { + if (!php3_ini_path) { default_location = CONFIGURATION_FILE_PATH; } else { - default_location = GLOBAL(php3_ini_path); + default_location = php3_ini_path; } #endif /* build a path */ php_ini_path = (char *) malloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); - if (!GLOBAL(php3_ini_path)) { + if (!php3_ini_path) { #if WIN32|WINNT sprintf(php_ini_path,".;%s;%s",env_location,default_location); #else @@ -258,7 +258,7 @@ char *browscap = INI_STR("browscap"); if (browscap) { - if (_php3_hash_init(&GLOBAL(browser_hash), 0, NULL, (void (*)(void *))pvalue_browscap_destructor, 1)==FAILURE) { + if (_php3_hash_init(&browser_hash, 0, NULL, (void (*)(void *))pvalue_browscap_destructor, 1)==FAILURE) { return FAILURE; } @@ -268,7 +268,7 @@ return FAILURE; } init_cfg_scanner(); - active__php3_hash_table = &GLOBAL(browser_hash); + active__php3_hash_table = &browser_hash; parsing_mode = PARSING_MODE_BROWSCAP; currently_parsed_filename = browscap; yyparse(); @@ -289,7 +289,7 @@ int php3_mshutdown_browscap(SHUTDOWN_FUNC_ARGS) { if (INI_STR("browscap")) { - _php3_hash_destroy(&GLOBAL(browser_hash)); + _php3_hash_destroy(&browser_hash); } return SUCCESS; } Index: php4/fhttpd.c diff -u php4/fhttpd.c:1.2 php4/fhttpd.c:1.3 --- php4/fhttpd.c:1.2 Fri Apr 23 16:05:52 1999 +++ php4/fhttpd.c Fri Apr 23 20:11:48 1999 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fhttpd.c,v 1.2 1999/04/23 20:05:52 zeev Exp $ */ +/* $Id: fhttpd.c,v 1.3 1999/04/24 00:11:48 zeev Exp $ */ #include "php.h" #include <stdlib.h> @@ -169,7 +169,7 @@ } } -void fhttpd_flush( /*GLOBAL(php3_rqst)->connection */ void) +void fhttpd_flush( /*php3_rqst->connection */ void) { } Index: php4/fopen-wrappers.c diff -u php4/fopen-wrappers.c:1.9 php4/fopen-wrappers.c:1.10 --- php4/fopen-wrappers.c:1.9 Fri Apr 23 16:05:52 1999 +++ php4/fopen-wrappers.c Fri Apr 23 20:11:48 1999 @@ -27,7 +27,7 @@ | Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: fopen-wrappers.c,v 1.9 1999/04/23 20:05:52 zeev Exp $ */ +/* $Id: fopen-wrappers.c,v 1.10 1999/04/24 00:11:48 zeev Exp $ */ #include "php.h" #include "php_globals.h" @@ -109,10 +109,10 @@ /* Special case basedir==".": Use script-directory */ if ((strcmp(PG(open_basedir), ".") == 0) && - GLOBAL(request_info).filename && - *GLOBAL(request_info).filename + request_info.filename && + *request_info.filename ) { - strcpy(local_open_basedir, GLOBAL(request_info).filename); + strcpy(local_open_basedir, request_info.filename); local_open_basedir_pos = strlen(local_open_basedir) - 1; /* Strip filename */ @@ -206,8 +206,8 @@ int l; PLS_FETCH(); - fn = GLOBAL(request_info).filename; - path_info = GLOBAL(request_info).path_info; + fn = request_info.filename; + path_info = request_info.path_info; #if HAVE_PWD_H if (PG(user_dir) && *PG(user_dir) && path_info && '/' == path_info[0] && '~' == path_info[1]) { @@ -234,8 +234,8 @@ strcat(fn, PG(user_dir)); /* safe */ strcat(fn, "/"); /* safe */ strcat(fn, s + 1); /* safe (shorter than path_info) */ - STR_FREE(GLOBAL(request_info).filename); - GLOBAL(request_info).filename = fn; + STR_FREE(request_info.filename); + request_info.filename = fn; } } } @@ -257,8 +257,8 @@ if ('/' == path_info[0]) l--; strcpy(fn + l, path_info); - STR_FREE(GLOBAL(request_info).filename); - GLOBAL(request_info).filename = fn; + STR_FREE(request_info.filename); + request_info.filename = fn; } } /* if doc_root && path_info */ if (!fn) { @@ -266,8 +266,8 @@ php3_destroy_request_info assumes that it will get freed when the include_names hash is emptied, but we're not adding it in this case */ - STR_FREE(GLOBAL(request_info).filename); - GLOBAL(request_info).filename = NULL; + STR_FREE(request_info.filename); + request_info.filename = NULL; return NULL; } fp = fopen(fn, "r"); @@ -279,7 +279,7 @@ } if (!fp) { php3_error(E_CORE_ERROR, "Unable to open %s", fn); - STR_FREE(GLOBAL(request_info).filename); /* for same reason as above */ + STR_FREE(request_info.filename); /* for same reason as above */ return NULL; } Index: php4/main.c diff -u php4/main.c:1.28 php4/main.c:1.29 --- php4/main.c:1.28 Fri Apr 23 18:45:00 1999 +++ php4/main.c Fri Apr 23 20:11:49 1999 @@ -29,7 +29,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.28 1999/04/23 22:45:00 zeev Exp $ */ +/* $Id: main.c,v 1.29 1999/04/24 00:11:49 zeev Exp $ */ #include <stdio.h> @@ -57,7 +57,6 @@ #include "php_ini.h" #include "php_globals.h" #include "main.h" -#include "control_structures.h" #include "fopen-wrappers.h" #include "ext/standard/php3_standard.h" #include "snprintf.h" @@ -96,7 +95,7 @@ void _php3_build_argv(char * ELS_DC); static void php3_timeout(int dummy); -static void php3_set_timeout(long seconds INLINE_TLS); +static void php3_set_timeout(long seconds); void *gLock; /*mutex variable */ @@ -268,10 +267,8 @@ #if APACHE void php3_apache_puts(const char *s) { - TLS_VARS; - - if (GLOBAL(php3_rqst)) { - rputs(s, GLOBAL(php3_rqst)); + if (php3_rqst) { + rputs(s, php3_rqst); } else { fputs(s, stdout); } @@ -279,10 +276,8 @@ void php3_apache_putc(char c) { - TLS_VARS; - - if (GLOBAL(php3_rqst)) { - rputc(c, GLOBAL(php3_rqst)); + if (php3_rqst) { + rputc(c, php3_rqst); } else { fputc(c, stdout); } @@ -315,7 +310,7 @@ } /* Otherwise fall back to the default logging location. */ #if APACHE - if (GLOBAL(php3_rqst)) { + if (php3_rqst) { #if MODULE_MAGIC_NUMBER >= 19970831 aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, log_message); #else @@ -498,14 +493,14 @@ #define SIGPROF 27 #endif -static void php3_set_timeout(long seconds INLINE_TLS) +static void php3_set_timeout(long seconds) { #if WIN32|WINNT if (seconds > 0) { - GLOBAL(timerstart) = (unsigned int) clock(); - GLOBAL(wintimer) = GLOBAL(timerstart) + (CLOCKS_PER_SEC * seconds); + timerstart = (unsigned int) clock(); + wintimer = timerstart + (CLOCKS_PER_SEC * seconds); } else { - GLOBAL(wintimer) = 0; + wintimer = 0; } #else #if HAVE_SETITIMER @@ -521,10 +516,10 @@ } -static void php3_unset_timeout(INLINE_TLS_VOID) +static void php3_unset_timeout() { #if WIN32|WINNT - GLOBAL(wintimer) = 0; + wintimer = 0; #else #if HAVE_SETITIMER struct itimerval no_timeout; @@ -560,8 +555,8 @@ should work fine. Is this FIXME a WIN32 problem? Is there no way to do per-thread timers on WIN32? */ - php3_unset_timeout(_INLINE_TLS_VOID); - php3_set_timeout(new_timeout->value.lval _INLINE_TLS); + php3_unset_timeout(); + php3_set_timeout(new_timeout->value.lval); } @@ -606,9 +601,9 @@ 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, GLOBAL(php3_rqst)->server, memory_leak_buf); + aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, memory_leak_buf); # else - log_error(memory_leak_buf,GLOBAL(php3_rqst)->server); + log_error(memory_leak_buf,php3_rqst->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); @@ -625,7 +620,7 @@ { zend_output_startup(); - php3_set_timeout(PG(max_execution_time) _INLINE_TLS); + php3_set_timeout(PG(max_execution_time)); #if APACHE /* @@ -637,7 +632,7 @@ * memory. */ block_alarms(); - register_cleanup(GLOBAL(php3_rqst)->pool, NULL, php3_request_shutdown, php3_request_shutdown_for_exec); + register_cleanup(php3_rqst->pool, NULL, php3_request_shutdown, php3_request_shutdown_for_exec); unblock_alarms(); #endif @@ -663,8 +658,6 @@ void php3_request_shutdown_for_exec(void *dummy) { - TLS_VARS; - /* used to close fd's in the 3..255 range here, but it's problematic */ shutdown_memory_manager(1, 1); @@ -677,7 +670,7 @@ } -void php3_request_shutdown(void *dummy INLINE_TLS) +void php3_request_shutdown(void *dummy) { #if FHTTPD char tmpline[128]; @@ -701,14 +694,14 @@ php3_destroy_request_info(NULL); shutdown_memory_manager(0, 0); php3_error(E_WARNING, "Unknown resources in request shutdown function"); - php3_unset_timeout(_INLINE_TLS_VOID); + php3_unset_timeout(); #if CGI_BINARY fflush(stdout); - if(GLOBAL(request_info).php_argv0) { - free(GLOBAL(request_info).php_argv0); - GLOBAL(request_info).php_argv0 = NULL; + if(request_info.php_argv0) { + free(request_info.php_argv0); + request_info.php_argv0 = NULL; } #endif #if FHTTPD @@ -750,7 +743,7 @@ req = NULL; #endif #if USE_SAPI - GLOBAL(sapi_rqst)->flush(GLOBAL(sapi_rqst)->scid); + sapi_rqst->flush(sapi_rqst->scid); #endif } @@ -764,7 +757,7 @@ return SUCCESS; } -static void php3_config_ini_shutdown(INLINE_TLS_VOID) +static void php3_config_ini_shutdown() { php3_shutdown_config(); } @@ -855,9 +848,12 @@ CLS_FETCH(); ELS_FETCH(); + if (!module_initialized) { + return; + } #if !USE_SAPI /* close down the ini config */ - php3_config_ini_shutdown(_INLINE_TLS_VOID); + php3_config_ini_shutdown(); #endif #if (WIN32|WINNT) && !(USE_SAPI) @@ -865,14 +861,11 @@ WSACleanup(); #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(GLOBAL(sapi_rqst)->scid); + sapi_rqst->flush(sapi_rqst->scid); #endif zend_shutdown(); @@ -896,7 +889,7 @@ switch(*p++) { case 'p': case 'P': - if (!_gpc_flags[0] && php3_headers_unsent() && GLOBAL(request_info).request_method && !strcasecmp(GLOBAL(request_info).request_method, "post")) { + if (!_gpc_flags[0] && php3_headers_unsent() && request_info.request_method && !strcasecmp(request_info.request_method, "post")) { php3_treat_data(PARSE_POST, NULL); /* POST Data */ _gpc_flags[0]=1; } @@ -940,7 +933,7 @@ { pval **tmp_ptr; register int i; - array_header *arr = table_elts(GLOBAL(php3_rqst)->subprocess_env); + array_header *arr = table_elts(php3_rqst->subprocess_env); table_entry *elts = (table_entry *) arr->elts; int len; @@ -966,8 +959,8 @@ _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(GLOBAL(php3_rqst)->uri); - tmp->value.str.val = estrndup(GLOBAL(php3_rqst)->uri, tmp->value.str.len); + tmp->value.str.len = strlen(php3_rqst->uri); + tmp->value.str.val = estrndup(php3_rqst->uri, tmp->value.str.len); tmp->refcount=1; tmp->is_ref=0; tmp->type = IS_STRING; @@ -1026,7 +1019,7 @@ /* Build the special-case PHP_SELF variable for the CGI version */ char *pi; #if FORCE_CGI_REDIRECT - pi = GLOBAL(request_info).path_info; + pi = request_info.path_info; tmp = (pval *) emalloc(sizeof(pval)); tmp->value.str.val = emalloc(((pi)?strlen(pi):0) + 1); tmp->value.str.len = _php3_sprintf(tmp->value.str.val, "%s", (pi ? pi : "")); /* SAFE */ @@ -1036,8 +1029,8 @@ #else int l = 0; char *sn; - sn = GLOBAL(request_info).script_name; - pi = GLOBAL(request_info).path_info; + sn = request_info.script_name; + pi = request_info.path_info; if (sn) l += strlen(sn); if (pi) @@ -1059,7 +1052,7 @@ /* need argc/argv support as well */ - _php3_build_argv(GLOBAL(request_info).query_string ELS_CC); + _php3_build_argv(request_info.query_string ELS_CC); return SUCCESS; } @@ -1254,8 +1247,8 @@ || getenv("REQUEST_METHOD")) { cgi = 1; if (argc > 1) - GLOBAL(request_info).php_argv0 = strdup(argv[1]); - else GLOBAL(request_info).php_argv0 = NULL; + request_info.php_argv0 = strdup(argv[1]); + else request_info.php_argv0 = NULL; #if FORCE_CGI_REDIRECT if (!getenv("REDIRECT_STATUS")) { PUTS("<b>Security Alert!</b> PHP CGI cannot be accessed directly.\n\ @@ -1292,7 +1285,7 @@ CG(extended_info) = 0; if (!cgi) { /* never execute the arguments if you are a CGI */ - GLOBAL(request_info).php_argv0 = NULL; + request_info.php_argv0 = NULL; while ((c = getopt(argc, argv, "c:qvisnaeh?vf:")) != -1) { switch (c) { case 'f': @@ -1337,7 +1330,7 @@ behavior=PHP_MODE_INDENT; break; case 'c': - GLOBAL(php3_ini_path) = strdup(optarg); /* intentional leak */ + php3_ini_path = strdup(optarg); /* intentional leak */ break; case 'a': #if SUPPORT_INTERACTIVE @@ -1377,13 +1370,13 @@ file_handle.type = ZEND_HANDLE_FP; file_handle.handle.fp = stdin; if (_cgi_filename) { - GLOBAL(request_info).filename = _cgi_filename; + request_info.filename = _cgi_filename; } php3_TreatHeaders(); if (!cgi) { - if (!GLOBAL(request_info).query_string) { + if (!request_info.query_string) { for (i = optind, len = 0; i < argc; i++) len += strlen(argv[i]) + 1; @@ -1394,10 +1387,10 @@ if (i < (argc - 1)) strcat(s, "+"); } - GLOBAL(request_info).query_string = s; + request_info.query_string = s; } - if (!GLOBAL(request_info).filename && argc > optind) - GLOBAL(request_info).filename = argv[optind]; + if (!request_info.filename && argc > optind) + request_info.filename = argv[optind]; } /* If for some reason the CGI interface is not setting the PATH_TRANSLATED correctly, request_info.filename is NULL. @@ -1405,8 +1398,8 @@ 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(request_info).filename) { - file_handle.filename = GLOBAL(request_info).filename; + if (cgi || request_info.filename) { + file_handle.filename = request_info.filename; file_handle.handle.fp = php3_fopen_for_parser(); } @@ -1422,8 +1415,8 @@ } } #endif - php3_request_shutdown((void *) 0 _INLINE_TLS); - php3_module_shutdown(_INLINE_TLS_VOID); + php3_request_shutdown((void *) 0); + php3_module_shutdown(); return FAILURE; } else if (file_handle.handle.fp && file_handle.handle.fp!=stdin) { /* #!php support */ @@ -1462,8 +1455,8 @@ } php3_header(); /* Make sure headers have been sent */ - php3_request_shutdown((void *) 0 _INLINE_TLS); - php3_module_shutdown(_INLINE_TLS_VOID); + php3_request_shutdown((void *) 0); + php3_module_shutdown(); return SUCCESS; } #endif /* CGI_BINARY */ @@ -1482,7 +1475,7 @@ php_core_globals *core_globals=&pcg; #endif - GLOBAL(php3_rqst) = r; + php3_rqst = r; if (php3_request_startup(CLS_C ELS_CC PLS_CC) == FAILURE) { return FAILURE; @@ -1499,587 +1492,6 @@ } #endif /* APACHE */ -#if FHTTPD - -char *get_pretokenized_name(void) -{ - char *pretokenized_name = NULL; - - if (GLOBAL(request_info).filename) { - int length = strlen(GLOBAL(request_info).filename); - - if (length > (sizeof(".php3") - 1) && !strcmp(GLOBAL(request_info).filename + length - sizeof(".php3") + 1, ".php3")) { - pretokenized_name = (char *) emalloc(length + 2); - strcpy(pretokenized_name, GLOBAL(request_info).filename); - strcat(pretokenized_name, "p"); - } else { - length += sizeof(".php3p"); - pretokenized_name = (char *) emalloc(length + 1); - strcpy(pretokenized_name, GLOBAL(request_info).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 preprocess_mode = PREPROCESS_NONE; - int argc1; - char **argv1; - int human = 1, fd2; - int i0 = 0, i1 = 0; - char *pn; - struct stat statbuf, pstatbuf; -#ifdef ZTS - zend_compiler_globals cg; - zend_executor_globals eg; - zend_compiler_globals *compiler_globals=&cg; - zend_executor_globals *executor_globals=&eg; -#endif - -#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)) { - PUTS("TlsGetValue error\n"); - return FAILURE; - } -#endif - -#if HAVE_SETLOCALE - setlocale(LC_CTYPE, ""); -#endif - - if (php3_module_startup() == 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': - printf ("Not implemented yet\n"); - 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) { - 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 */ - } - CG(phplineno)++; - } else { - rewind(in); - } - } - GLOBAL(phpin) = in; - phprestart(GLOBAL(phpin)); - - 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; - - while (phplex(&yylval)); /* create the token cache */ - tcm_save(&GLOBAL(token_cache_manager)); - seek_token(&GLOBAL(token_cache_manager), 0, NULL); - GLOBAL(php3_preprocess) = PREPROCESS_NONE; - } - php3_parse(GLOBAL(phpin) CLS_CC ELS_CC); - - } - } - } - 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 0; -} -#endif /* FHTTPD */ - -#if USE_SAPI - -PHPAPI int php3_sapi_main(struct sapi_request_info *sapi_info) -{ -#if DEBUG - char logmessage[1024]; -#endif - FILE *in = NULL; - int c; - YY_TLS_VARS; - TLS_VARS; - - GLOBAL(php3_preprocess) = sapi_info->preprocess; - GLOBAL(php3_display_source) = sapi_info->display_source_mode; - GLOBAL(sapi_rqst) = sapi_info; - -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: entry\n",GLOBAL(sapi_rqst)->scid); - OutputDebugString(logmessage); -#endif - -/* if (php3_module_startup(php3_globals) == FAILURE) { - return FAILURE; - }*/ - - if (php3_request_startup(CLS_C ELS_CC PLS_CC) == FAILURE) { -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: request starup failed\n",GLOBAL(sapi_rqst)->scid); - OutputDebugString(logmessage); -#endif - return FAILURE; - } - if (sapi_info->preprocess == PREPROCESS_PREPROCESS || sapi_info->quiet_mode) { - php3_noheader(); - } - if (sapi_info->info_only) { - _php3_info(); - php3_request_shutdown((void *) GLOBAL(sapi_rqst), php3_globals); - /*php3_module_shutdown(php3_globals);*/ -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: info_only\n",GLOBAL(sapi_rqst)->scid); - OutputDebugString(logmessage); -#endif - return (1); - } - /* if its not cgi, require that we have a filename now */ -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: File: %s\n",GLOBAL(sapi_rqst)->scid,GLOBAL(sapi_rqst)->filename); - OutputDebugString(logmessage); -#endif - if (!sapi_info->cgi && !sapi_info->filename) { - php3_printf("No input file specified.\n"); - php3_request_shutdown((void *) GLOBAL(sapi_rqst), php3_globals); - /*php3_module_shutdown(php3_globals);*/ -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: No input file specified\n",GLOBAL(sapi_rqst)->scid); - OutputDebugString(logmessage); -#endif - return FAILURE; - } - /* - if request_info.filename is null and cgi, fopen_for_parser is responsible - request_info.filename will only be estrduped in fopen_for parser - if it is null at this point - */ - in = php3_fopen_for_parser(); - - if (sapi_info->cgi && !in) { - php3_printf("No input file specified for cgi.\n"); - php3_request_shutdown((void *) GLOBAL(sapi_rqst), php3_globals); - /*php3_module_shutdown(php3_globals);*/ -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: No input file specified for cgi.\n",GLOBAL(sapi_rqst)->scid); - OutputDebugString(logmessage); -#endif - return FAILURE; - } - if (sapi_info->cgi && in) { - /* #!php support */ - c = fgetc(in); - if (c == '#') { - while (c != 10 && c != 13) { - c = fgetc(in); /* skip to end of line */ - } - } else { - rewind(in); - } - } - if (in) { - GLOBAL(phpin) = in; - phprestart(GLOBAL(phpin)); - } - if (sapi_info->display_source_mode) { - GLOBAL(php3_display_source) = 1; - PUTS("<html><head><title>Source for "); - PUTS(sapi_info->filename); - PUTS("</title></head><body bgcolor=\""); - PUTS(php3_ini.highlight_bg); - PUTS("\" text=\""); - PUTS(php3_ini.highlight_html); - PUTS("\">\n"); /* color: seashell */ - } - if (sapi_info->display_source_mode && sapi_info->preprocess == PREPROCESS_PREPROCESS) { - php3_printf("Can't preprocess while displaying source.<br>\n"); - return FAILURE; - } - if (sapi_info->preprocess == PREPROCESS_EXECUTE) { - tcm_load(&GLOBAL(token_cache_manager)); - GLOBAL(php3_preprocess) = PREPROCESS_NONE; - } - if (sapi_info->preprocess==PREPROCESS_NONE) { -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: start php3_parse() file:%s\n",GLOBAL(sapi_rqst)->scid,GLOBAL(sapi_rqst)->filename); - OutputDebugString(logmessage); -#endif - php3_parse(GLOBAL(phpin) _INLINE_TLS); -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: done php3_parse()\n",GLOBAL(sapi_rqst)->scid); - OutputDebugString(logmessage); -#endif - } else { - pval yylval; - -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: entering phplex()\n",GLOBAL(sapi_rqst)->scid); - OutputDebugString(logmessage); -#endif -#ifdef THREAD_SAFE - while (phplex(&yylval, php3_globals, php_gbl)); /* create the token cache */ -#else - while (phplex(&yylval)); /* create the token cache */ -#endif -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: done phplex()\n",GLOBAL(sapi_rqst)->scid); - OutputDebugString(logmessage); -#endif - tcm_save(&GLOBAL(token_cache_manager)); - } - - if (sapi_info->display_source_mode) { - php3_printf("\n</html>\n"); - } - if (GLOBAL(initialized)) { - php3_header(); /* Make sure headers have been sent */ - php3_request_shutdown((void *) GLOBAL(sapi_rqst), php3_globals); - /*php3_module_shutdown(php3_globals);*/ -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: success!\n",GLOBAL(sapi_rqst)->scid); - OutputDebugString(logmessage); -#endif - return SUCCESS; - } else { -#if DEBUG - snprintf(logmessage,1024,"%d:php3_sapi_main: request not initialized!\n",GLOBAL(sapi_rqst)->scid); - OutputDebugString(logmessage); -#endif - return FAILURE; - } -} -#if WIN32|WINNT -extern int tls_create(void); -extern int tls_destroy(void); -extern int tls_startup(void); -extern int tls_shutdown(void); -extern flex_globals *yy_init_tls(void); -extern void yy_destroy_tls(void); -extern VOID ErrorExit(LPTSTR lpszMessage); - -BOOL WINAPI DllMain(HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved) -{ - php3_globals_struct *php3_globals; -#if DEBUG - OutputDebugString("PHP_Core DllMain Entry\n"); -#endif - switch (ul_reason_for_call) { - case DLL_PROCESS_ATTACH: - /* - I should be loading ini vars here - and doing whatever true global inits - need to be done - */ - _fmode = _O_BINARY; /*sets default for file streams to binary */ - /* make the stdio mode be binary */ - setmode(_fileno(stdin), O_BINARY); - setmode(_fileno(stdout), O_BINARY); - setmode(_fileno(stderr), O_BINARY); - setlocale(LC_CTYPE, ""); - - CREATE_MUTEX(gLock, "GENERAL"); - - if (!tls_startup()) - return 0; - if (!tls_create()) - return 0; - php3_globals = TlsGetValue(TlsIndex); - yy_init_tls(); - if (php3_config_ini_startup(_INLINE_TLS_VOID) == FAILURE) { - return 0; - } - if (php3_module_startup() == FAILURE) { - ErrorExit("module startup failed"); - return 0; - } - -#if DEBUG - OutputDebugString("PHP_Core DllMain Process Attached\n"); -#endif - break; - case DLL_THREAD_ATTACH: -#if DEBUG - OutputDebugString("PHP_Core DllMain Thread Attach\n"); -#endif - if (!tls_create()) - return 0; - php3_globals = TlsGetValue(TlsIndex); - yy_init_tls(); - if (php3_module_startup() == FAILURE) { - ErrorExit("module startup failed"); -#if DEBUG - OutputDebugString("PHP_Core DllMain module startup failed\n"); -#endif - return 0; - } - break; - case DLL_THREAD_DETACH: -#if DEBUG - OutputDebugString("PHP_Core DllMain Detache\n"); -#endif - php3_globals = TlsGetValue(TlsIndex); - php3_module_shutdown(php3_globals); - if (!tls_destroy()) -#if DEBUG - OutputDebugString("PHP_Core DllMain Detache Error tls_destroy\n"); -#endif - return 0; - yy_destroy_tls(); - break; - case DLL_PROCESS_DETACH: - /* - close down anything down in process_attach - */ - php3_globals = TlsGetValue(TlsIndex); - php3_module_shutdown(php3_globals); - - php3_config_ini_shutdown(_INLINE_TLS_VOID); - - if (!tls_destroy()) -#if DEBUG - OutputDebugString("PHP_Core DllMain tls_destroy failed\n"); -#endif - return 0; - if (!tls_shutdown()) -#if DEBUG - OutputDebugString("PHP_Core DllMain tls_shutdown failed\n"); -#endif - return 0; - yy_destroy_tls(); -#if DEBUG - OutputDebugString("PHP_Core DllMain Process Detatched\n"); -#endif - break; - } -#if DEBUG - OutputDebugString("PHP_Core DllMain Successful Exit\n"); -#endif - return 1; -} - -#endif -#endif /* * Local variables: * tab-width: 4 Index: php4/main.h diff -u php4/main.h:1.4 php4/main.h:1.5 --- php4/main.h:1.4 Fri Apr 23 18:45:00 1999 +++ php4/main.h Fri Apr 23 20:11:49 1999 @@ -29,7 +29,7 @@ */ -/* $Id: main.h,v 1.4 1999/04/23 22:45:00 zeev Exp $ */ +/* $Id: main.h,v 1.5 1999/04/24 00:11:49 zeev Exp $ */ #ifndef _MAIN_H @@ -39,7 +39,7 @@ #include "php_globals.h" int php3_request_startup(CLS_D ELS_DC PLS_DC); -extern void php3_request_shutdown(void *dummy INLINE_TLS); +extern void php3_request_shutdown(void *dummy); extern void php3_request_shutdown_for_exec(void *dummy); extern int php3_module_startup(); extern void php3_module_shutdown(); Index: php4/mod_php3.c diff -u php4/mod_php3.c:1.9 php4/mod_php3.c:1.10 --- php4/mod_php3.c:1.9 Fri Apr 23 16:05:52 1999 +++ php4/mod_php3.c Fri Apr 23 20:11:49 1999 @@ -28,7 +28,7 @@ | PHP4 patches by Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php3.c,v 1.9 1999/04/23 20:05:52 zeev Exp $ */ +/* $Id: mod_php3.c,v 1.10 1999/04/24 00:11:49 zeev Exp $ */ #include "httpd.h" #include "http_config.h" @@ -67,23 +67,8 @@ module MODULE_VAR_EXPORT php3_module; -#ifndef THREAD_SAFE int saved_umask; -#else -#define GLOBAL(a) php3_globals->a -#define STATIC GLOBAL -#define TLS_VARS \ - php3_globals_struct *php3_globals; \ - php3_globals = TlsGetValue(TlsIndex); -#endif -#ifndef TLS_VARS -#define TLS_VARS -#endif - -#ifndef GLOBAL -#define GLOBAL(x) x -#endif #if WIN32|WINNT /* popenf isn't working on Windows, use open instead*/ @@ -167,15 +152,13 @@ void php3_save_umask() { - TLS_VARS; - GLOBAL(saved_umask) = umask(077); - umask(GLOBAL(saved_umask)); + saved_umask = umask(077); + umask(saved_umask); } void php3_restore_umask() { - TLS_VARS; - umask(GLOBAL(saved_umask)); + umask(saved_umask); } int send_php3(request_rec *r, int display_source_mode, char *filename) Index: php4/output.c diff -u php4/output.c:1.2 php4/output.c:1.3 --- php4/output.c:1.2 Wed Apr 21 20:25:51 1999 +++ php4/output.c Fri Apr 23 20:11:49 1999 @@ -197,8 +197,8 @@ static int zend_apache_ub_write(const char *str, uint str_length) { - if (GLOBAL(php3_rqst)) { - return rwrite(str, str_length, GLOBAL(php3_rqst)); + if (php3_rqst) { + return rwrite(str, str_length, php3_rqst); } else { return fwrite(str, 1, str_length, stdout); } Index: php4/php.h diff -u php4/php.h:1.10 php4/php.h:1.11 --- php4/php.h:1.10 Wed Apr 21 19:27:59 1999 +++ php4/php.h Fri Apr 23 20:11:49 1999 @@ -28,7 +28,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h,v 1.10 1999/04/21 23:27:59 ssb Exp $ */ +/* $Id: php.h,v 1.11 1999/04/24 00:11:49 zeev Exp $ */ #ifndef _PHP_H #define _PHP_H @@ -117,42 +117,9 @@ # endif #endif -/*Thread Safety*/ -#if THREAD_SAFE -#define GLOBAL(a) php3_globals->a -#define STATIC GLOBAL -#define TLS_VARS \ - php3_globals_struct *php3_globals; \ - php3_globals = TlsGetValue(TlsIndex); -#define CREATE_MUTEX(a,b) a = CreateMutex (NULL, FALSE, b); -#define SET_MUTEX(a) WaitForSingleObject( a, INFINITE ); -#define FREE_MUTEX(a) ReleaseMutex(a); - -/*redirect variables to the flex structure*/ -#if !defined(YY_BUFFER_NEW) && !defined(COMPILE_DL) -#include "FlexSafe.h" -#endif - -#define INLINE_TLS ,struct php3_global_struct *php3_globals -#define INLINE_TLS_VOID struct php3_global_struct *php3_globals -#define _INLINE_TLS ,php3_globals -#define _INLINE_TLS_VOID php3_globals - -#else -#define GLOBAL(a) a -#define STATIC GLOBAL -#define TLS_VARS #define CREATE_MUTEX(a,b) #define SET_MUTEX(a) #define FREE_MUTEX(a) - -/* needed in control structures */ -#define INLINE_TLS -#define INLINE_TLS_VOID void -#define _INLINE_TLS -#define _INLINE_TLS_VOID - -#endif /* * Then the ODBC support can use both iodbc and Solid, Index: php4/php4.dsp diff -u php4/php4.dsp:1.9 php4/php4.dsp:1.10 --- php4/php4.dsp:1.9 Wed Apr 21 23:58:37 1999 +++ php4/php4.dsp Fri Apr 23 20:11:49 1999 @@ -161,10 +161,6 @@ # End Source File # Begin Source File -SOURCE=.\control_structures.h -# End Source File -# Begin Source File - SOURCE=.\ext\standard\cyr_convert.h # End Source File # Begin Source File Index: php4/php4ts.dsp diff -u php4/php4ts.dsp:1.3 php4/php4ts.dsp:1.4 --- php4/php4ts.dsp:1.3 Thu Apr 22 23:36:17 1999 +++ php4/php4ts.dsp Fri Apr 23 20:11:49 1999 @@ -161,10 +161,6 @@ # End Source File # Begin Source File -SOURCE=.\control_structures.h -# End Source File -# Begin Source File - SOURCE=.\ext\standard\cyr_convert.h # End Source File # Begin Source File Index: php4/request_info.c diff -u php4/request_info.c:1.3 php4/request_info.c:1.4 --- php4/request_info.c:1.3 Fri Apr 23 16:05:52 1999 +++ php4/request_info.c Fri Apr 23 20:11:49 1999 @@ -37,23 +37,22 @@ int php3_init_request_info(void *conf) { char *buf; /* temporary buffers */ - TLS_VARS; - GLOBAL(request_info).path_info = getenv("PATH_INFO"); - GLOBAL(request_info).path_translated = getenv("PATH_TRANSLATED"); - GLOBAL(request_info).query_string = getenv("QUERY_STRING"); - GLOBAL(request_info).current_user = NULL; - GLOBAL(request_info).current_user_length = 0; - GLOBAL(request_info).request_method = getenv("REQUEST_METHOD"); - GLOBAL(request_info).script_name = getenv("SCRIPT_NAME"); + request_info.path_info = getenv("PATH_INFO"); + request_info.path_translated = getenv("PATH_TRANSLATED"); + request_info.query_string = getenv("QUERY_STRING"); + request_info.current_user = NULL; + request_info.current_user_length = 0; + request_info.request_method = getenv("REQUEST_METHOD"); + request_info.script_name = getenv("SCRIPT_NAME"); buf = getenv("CONTENT_LENGTH"); - GLOBAL(request_info).content_length = (buf ? atoi(buf) : 0); - GLOBAL(request_info).content_type = getenv("CONTENT_TYPE"); - GLOBAL(request_info).cookies = getenv("HTTP_COOKIE"); - GLOBAL(request_info).script_filename = getenv("SCRIPT_FILENAME"); + request_info.content_length = (buf ? atoi(buf) : 0); + request_info.content_type = getenv("CONTENT_TYPE"); + request_info.cookies = getenv("HTTP_COOKIE"); + request_info.script_filename = getenv("SCRIPT_FILENAME"); /* Hack for annoying servers that do not set SCRIPT_FILENAME for us */ - if (!GLOBAL(request_info).script_filename) { - GLOBAL(request_info).script_filename = GLOBAL(request_info).php_argv0; + if (!request_info.script_filename) { + request_info.script_filename = request_info.php_argv0; } #if WIN32|WINNT /* FIXME WHEN APACHE NT IS FIXED */ @@ -61,10 +60,10 @@ script filename to php.exe thus makes us parse php.exe instead of file.php requires we get the info from path translated. This can be removed at such a time taht apache nt is fixed */ - else if (GLOBAL(request_info).path_translated) { - GLOBAL(request_info).script_filename = GLOBAL(request_info).path_translated; + else if (request_info.path_translated) { + request_info.script_filename = request_info.path_translated; } else { - GLOBAL(request_info).script_filename = NULL; + request_info.script_filename = NULL; } #endif @@ -76,16 +75,16 @@ Notice that this means that we don't need to efree() it in php3_destroy_request_info()! */ #if DISCARD_PATH - if (GLOBAL(request_info).script_filename) { - GLOBAL(request_info).filename = estrdup(GLOBAL(request_info).script_filename); + if (request_info.script_filename) { + request_info.filename = estrdup(request_info.script_filename); } else { - GLOBAL(request_info).filename = NULL; + request_info.filename = NULL; } #else - if (GLOBAL(request_info).path_translated) { - GLOBAL(request_info).filename = estrdup(GLOBAL(request_info).path_translated); + if (request_info.path_translated) { + request_info.filename = estrdup(request_info.path_translated); } else { - GLOBAL(request_info).filename = NULL; + request_info.filename = NULL; } #endif return SUCCESS; @@ -93,7 +92,7 @@ int php3_destroy_request_info(void *conf) { - STR_FREE(GLOBAL(request_info).current_user); + STR_FREE(request_info.current_user); return SUCCESS; } #endif @@ -107,7 +106,6 @@ { static int exit_requested = 0; int i, len; - TLS_VARS; req = NULL; setalarm(idle_timeout); @@ -123,22 +121,22 @@ strncpy(script_name_resolved_buffer, req->script_name_resolved, 2047); script_name_resolved_buffer[2047] = 0; - GLOBAL(request_info).path_info = NULL; /* Not supported */ - GLOBAL(request_info).path_translated = script_name_resolved_buffer; - GLOBAL(request_info).query_string = req->query_string; - GLOBAL(request_info).current_user = NULL; - GLOBAL(request_info).current_user_length = 0; - GLOBAL(request_info).request_method = method_names[req->method]; - GLOBAL(request_info).script_name = req->script_name; - GLOBAL(request_info).content_length = req->databuffsize; - GLOBAL(request_info).content_type = req->content_type; - GLOBAL(request_info).cookies = NULL; + request_info.path_info = NULL; /* Not supported */ + request_info.path_translated = script_name_resolved_buffer; + request_info.query_string = req->query_string; + request_info.current_user = NULL; + request_info.current_user_length = 0; + request_info.request_method = method_names[req->method]; + request_info.script_name = req->script_name; + request_info.content_length = req->databuffsize; + request_info.content_type = req->content_type; + request_info.cookies = NULL; for (i = 0; i < req->nlines; i++) { if (req->lines[i].paramc > 1) { if (req->lines[i].params[0]) { if (!strcasecmp(req->lines[i].params[0], "HTTP_COOKIE")) { if (req->lines[i].params[1]) { - GLOBAL(request_info).cookies = req->lines[i].params[1]; + request_info.cookies = req->lines[i].params[1]; } } } @@ -151,10 +149,10 @@ the include file hash table, and gets freed with that table. Notice that this means that we don't need to efree() it in php3_destroy_request_info()! */ - if (GLOBAL(request_info).path_translated) - GLOBAL(request_info).filename = estrdup(GLOBAL(request_info).path_translated); + if (request_info.path_translated) + request_info.filename = estrdup(request_info.path_translated); else - GLOBAL(request_info).filename = NULL; + request_info.filename = NULL; return SUCCESS; } else { @@ -196,20 +194,19 @@ int php3_init_request_info(void *conf) { const char *buf; - TLS_VARS; - GLOBAL(request_info).current_user = NULL; - GLOBAL(request_info).current_user_length = 0; + request_info.current_user = NULL; + request_info.current_user_length = 0; - GLOBAL(request_info).filename = GLOBAL(php3_rqst)->filename; - GLOBAL(request_info).request_method = GLOBAL(php3_rqst)->method; - GLOBAL(request_info).query_string = GLOBAL(php3_rqst)->args; - GLOBAL(request_info).content_type = table_get(GLOBAL(php3_rqst)->subprocess_env, "CONTENT_TYPE"); + 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"); - buf = table_get(GLOBAL(php3_rqst)->subprocess_env, "CONTENT_LENGTH"); - GLOBAL(request_info).content_length = (buf ? atoi(buf) : 0); + buf = table_get(php3_rqst->subprocess_env, "CONTENT_LENGTH"); + request_info.content_length = (buf ? atoi(buf) : 0); - GLOBAL(request_info).cookies = table_get(GLOBAL(php3_rqst)->subprocess_env, "HTTP_COOKIE"); + request_info.cookies = table_get(php3_rqst->subprocess_env, "HTTP_COOKIE"); return SUCCESS; } @@ -220,21 +217,20 @@ /* temporary until I figure a beter way to do it */ int php3_init_request_info(void *conf) { - TLS_VARS; - if (GLOBAL(sapi_rqst)->filename) - GLOBAL(request_info).filename = estrdup(GLOBAL(sapi_rqst)->filename); + if (sapi_rqst->filename) + request_info.filename = estrdup(sapi_rqst->filename); else - GLOBAL(request_info).filename = NULL; - GLOBAL(request_info).path_info = GLOBAL(sapi_rqst)->path_info; - GLOBAL(request_info).path_translated = GLOBAL(sapi_rqst)->path_translated; - GLOBAL(request_info).query_string = GLOBAL(sapi_rqst)->query_string; - GLOBAL(request_info).current_user = GLOBAL(sapi_rqst)->current_user; - GLOBAL(request_info).current_user_length = GLOBAL(sapi_rqst)->current_user_length; - GLOBAL(request_info).request_method = GLOBAL(sapi_rqst)->request_method; - GLOBAL(request_info).script_name = GLOBAL(sapi_rqst)->script_name; - GLOBAL(request_info).content_length = GLOBAL(sapi_rqst)->content_length; - GLOBAL(request_info).content_type = GLOBAL(sapi_rqst)->content_type; - GLOBAL(request_info).cookies = GLOBAL(sapi_rqst)->cookies; + request_info.filename = NULL; + request_info.path_info = sapi_rqst->path_info; + request_info.path_translated = sapi_rqst->path_translated; + request_info.query_string = sapi_rqst->query_string; + request_info.current_user = sapi_rqst->current_user; + request_info.current_user_length = sapi_rqst->current_user_length; + request_info.request_method = sapi_rqst->request_method; + request_info.script_name = sapi_rqst->script_name; + request_info.content_length = sapi_rqst->content_length; + request_info.content_type = sapi_rqst->content_type; + request_info.cookies = sapi_rqst->cookies; return SUCCESS; } Index: php4/safe_mode.c diff -u php4/safe_mode.c:1.3 php4/safe_mode.c:1.4 --- php4/safe_mode.c:1.3 Fri Apr 23 16:05:52 1999 +++ php4/safe_mode.c Fri Apr 23 20:11:49 1999 @@ -26,7 +26,7 @@ | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: safe_mode.c,v 1.3 1999/04/23 20:05:52 zeev Exp $ */ +/* $Id: safe_mode.c,v 1.4 1999/04/24 00:11:49 zeev Exp $ */ #include "php.h" @@ -125,30 +125,29 @@ #endif struct passwd *pwd; int uid; - TLS_VARS; - if (GLOBAL(request_info).current_user) { - return GLOBAL(request_info).current_user; + if (request_info.current_user) { + return request_info.current_user; } /* FIXME: I need to have this somehow handled if USE_SAPI is defined, because cgi will also be interfaced in USE_SAPI */ #if CGI_BINARY || USE_SAPI || FHTTPD - if (!GLOBAL(request_info).filename || (stat(GLOBAL(request_info).filename,&statbuf)==-1)) { + if (!request_info.filename || (stat(request_info.filename,&statbuf)==-1)) { return empty_string; } uid = statbuf.st_uid; #endif #if APACHE - uid = GLOBAL(php3_rqst)->finfo.st_uid; + uid = php3_rqst->finfo.st_uid; #endif if ((pwd=getpwuid(uid))==NULL) { return empty_string; } - GLOBAL(request_info).current_user_length = strlen(pwd->pw_name); - GLOBAL(request_info).current_user = estrndup(pwd->pw_name,GLOBAL(request_info).current_user_length); + request_info.current_user_length = strlen(pwd->pw_name); + request_info.current_user = estrndup(pwd->pw_name,request_info.current_user_length); - return GLOBAL(request_info).current_user; + return request_info.current_user; } -- PHP 4 Beta

« previous php.version4 (#422) next »