diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/configuration-parser.y | 30 | ||||
-rw-r--r-- | main/configuration-scanner.l | 10 | ||||
-rw-r--r-- | main/fopen_wrappers.c | 28 | ||||
-rw-r--r-- | main/main.c | 48 | ||||
-rw-r--r-- | main/output.c | 2 | ||||
-rw-r--r-- | main/php_sprintf.c | 42 | ||||
-rw-r--r-- | main/rfc1867.c | 4 | ||||
-rw-r--r-- | main/safe_mode.c | 4 |
8 files changed, 90 insertions, 78 deletions
diff --git a/main/configuration-parser.y b/main/configuration-parser.y index a7661d7547..aca4c2dda0 100644 --- a/main/configuration-parser.y +++ b/main/configuration-parser.y @@ -48,7 +48,7 @@ static HashTable configuration_hash; #ifndef THREAD_SAFE extern HashTable browser_hash; -PHPAPI extern char *php3_ini_path; +PHPAPI extern char *php_ini_path; #endif static HashTable *active_zend_hash_table; static pval *current_section; @@ -155,7 +155,7 @@ int php_init_config(void) #if USE_CONFIG_FILE { - char *env_location,*default_location,*php_ini_path; + char *env_location,*default_location,*php_ini_search_path; int safe_mode_state = PG(safe_mode); char *open_basedir = PG(open_basedir); char *opened_path; @@ -167,8 +167,8 @@ int php_init_config(void) } #if WIN32|WINNT { - if (php3_ini_path) { - default_location = php3_ini_path; + if (php_ini_path) { + default_location = php_ini_path; } else { default_location = (char *) malloc(512); @@ -179,30 +179,30 @@ int php_init_config(void) } } #else - if (!php3_ini_path) { + if (!php_ini_path) { default_location = CONFIGURATION_FILE_PATH; } else { - default_location = php3_ini_path; + default_location = php_ini_path; } #endif /* build a path */ - php_ini_path = (char *) malloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); + php_ini_search_path = (char *) malloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); - if (!php3_ini_path) { + if (!php_ini_path) { #if WIN32|WINNT - sprintf(php_ini_path,".;%s;%s",env_location,default_location); + sprintf(php_ini_search_path,".;%s;%s",env_location,default_location); #else - sprintf(php_ini_path,".:%s:%s",env_location,default_location); + sprintf(php_ini_search_path,".:%s:%s",env_location,default_location); #endif } else { /* if path was set via -c flag, only look there */ - strcpy(php_ini_path,default_location); + strcpy(php_ini_search_path,default_location); } PG(safe_mode) = 0; PG(open_basedir) = NULL; - cfgin = php_fopen_with_path("php.ini","r",php_ini_path,&opened_path); - free(php_ini_path); + cfgin = php_fopen_with_path("php.ini","r",php_ini_search_path,&opened_path); + free(php_ini_search_path); if (free_default_location) { free(default_location); } @@ -360,7 +360,7 @@ statement: php_alter_ini_entry($1.value.str.val, $1.value.str.len+1, $3.value.str.val, $3.value.str.len+1, PHP_INI_SYSTEM); } } else if (parsing_mode==PARSING_MODE_BROWSCAP) { - php3_str_tolower($1.value.str.val,$1.value.str.len); + zend_str_tolower($1.value.str.val,$1.value.str.len); zend_hash_update(current_section->value.ht, $1.value.str.val, $1.value.str.len+1, &$3, sizeof(pval), NULL); } free($1.value.str.val); @@ -407,7 +407,7 @@ statement: zend_hash_init(tmp.value.ht, 0, NULL, (int (*)(void *))pvalue_config_destructor, 1); tmp.type = IS_OBJECT; zend_hash_update(active_zend_hash_table, $1.value.str.val, $1.value.str.len+1, (void *) &tmp, sizeof(pval), (void **) ¤t_section); - tmp.value.str.val = php3_strndup($1.value.str.val,$1.value.str.len); + tmp.value.str.val = zend_strndup($1.value.str.val,$1.value.str.len); tmp.value.str.len = $1.value.str.len; tmp.type = IS_STRING; convert_browscap_pattern(&tmp); diff --git a/main/configuration-scanner.l b/main/configuration-scanner.l index 91d5f3d6f2..d7fe0f862c 100644 --- a/main/configuration-scanner.l +++ b/main/configuration-scanner.l @@ -70,7 +70,7 @@ void init_cfg_scanner() <INITIAL>[ ]*("true"|"on"|"yes")[ ]* { - cfglval->value.str.val = php3_strndup("1",1); + cfglval->value.str.val = zend_strndup("1",1); cfglval->value.str.len = 1; cfglval->type = IS_STRING; return CFG_TRUE; @@ -78,7 +78,7 @@ void init_cfg_scanner() <INITIAL>[ ]*("false"|"off"|"no")[ ]* { - cfglval->value.str.val = php3_strndup("",0); + cfglval->value.str.val = zend_strndup("",0); cfglval->value.str.len = 0; cfglval->type = IS_STRING; return CFG_FALSE; @@ -98,7 +98,7 @@ void init_cfg_scanner() yytext++; yyleng--; - cfglval->value.str.val = php3_strndup(yytext,yyleng); + cfglval->value.str.val = zend_strndup(yytext,yyleng); cfglval->value.str.len = yyleng; cfglval->type = IS_STRING; return SECTION; @@ -114,7 +114,7 @@ void init_cfg_scanner() /* eat leading " */ yytext++; - cfglval->value.str.val = php3_strndup(yytext,yyleng); + cfglval->value.str.val = zend_strndup(yytext,yyleng); cfglval->value.str.len = yyleng; cfglval->type = IS_STRING; return TC_ENCAPSULATED_STRING; @@ -144,7 +144,7 @@ void init_cfg_scanner() } } if (yyleng!=0) { - cfglval->value.str.val = php3_strndup(yytext,yyleng); + cfglval->value.str.val = zend_strndup(yytext,yyleng); cfglval->value.str.len = yyleng; cfglval->type = IS_STRING; return TC_STRING; diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index c3601556a8..94c27437aa 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -79,9 +79,9 @@ #include <sys/un.h> #endif -static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path); +static FILE *php_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path); -int _php3_getftpresult(int socketd); +int php_get_ftp_result(int socketd); /* When open_basedir is not NULL, check if the given filename is located in @@ -194,7 +194,7 @@ PHPAPI FILE *php_fopen_wrapper(char *path, char *mode, int options, int *issock, be runtime enabled, NOT compile time. */ #if PHP3_URL_FOPEN if (!(options & IGNORE_URL)) { - return php3_fopen_url_wrapper(path, mode, options, issock, socketd, opened_path); + return php_fopen_url_wrapper(path, mode, options, issock, socketd, opened_path); } #endif @@ -432,7 +432,7 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char ** * Otherwise, fopen is called as usual and the file pointer is returned. */ -static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path) +static FILE *php_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path) { url *resource; int result; @@ -524,7 +524,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i strcpy(scratch, resource->user); strcat(scratch, ":"); strcat(scratch, resource->pass); - tmp = _php3_base64_encode((unsigned char *)scratch, strlen(scratch), NULL); + tmp = php_base64_encode((unsigned char *)scratch, strlen(scratch), NULL); if (snprintf(hdr_line, sizeof(hdr_line), "Authorization: Basic %s\r\n", tmp) > 0) { @@ -595,7 +595,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i *socketd = 0; free_url(resource); if (location[0] != '\0') { - return php3_fopen_url_wrapper(location, mode, options, issock, socketd, opened_path); + return php_fopen_url_wrapper(location, mode, options, issock, socketd, opened_path); } else { return NULL; } @@ -667,7 +667,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i #endif /* Start talking to ftp server */ - result = _php3_getftpresult(*socketd); + result = php_get_ftp_result(*socketd); if (result > 299 || result < 200) { free_url(resource); SOCK_FCLOSE(*socketd); @@ -677,7 +677,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i /* send the user name */ SOCK_WRITE("USER ", *socketd); if (resource->user != NULL) { - _php3_rawurldecode(resource->user, strlen(resource->user)); + php_raw_url_decode(resource->user, strlen(resource->user)); SOCK_WRITE(resource->user, *socketd); } else { SOCK_WRITE("anonymous", *socketd); @@ -685,13 +685,13 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i SOCK_WRITE("\r\n", *socketd); /* get the response */ - result = _php3_getftpresult(*socketd); + result = php_get_ftp_result(*socketd); /* if a password is required, send it */ if (result >= 300 && result <= 399) { SOCK_WRITE("PASS ", *socketd); if (resource->pass != NULL) { - _php3_rawurldecode(resource->pass, strlen(resource->pass)); + php_raw_url_decode(resource->pass, strlen(resource->pass)); SOCK_WRITE(resource->pass, *socketd); } else { /* if the user has configured who they are, @@ -705,7 +705,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i SOCK_WRITE("\r\n", *socketd); /* read the response */ - result = _php3_getftpresult(*socketd); + result = php_get_ftp_result(*socketd); if (result > 299 || result < 200) { free_url(resource); SOCK_FCLOSE(*socketd); @@ -721,7 +721,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i /* set the connection to be binary */ SOCK_WRITE("TYPE I\r\n", *socketd); - result = _php3_getftpresult(*socketd); + result = php_get_ftp_result(*socketd); if (result > 299 || result < 200) { free_url(resource); SOCK_FCLOSE(*socketd); @@ -735,7 +735,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i SOCK_WRITE("\r\n", *socketd); /* read the response */ - result = _php3_getftpresult(*socketd); + result = php_get_ftp_result(*socketd); if (mode[0] == 'r') { /* when reading file, it must exist */ if (result > 299 || result < 200) { @@ -918,7 +918,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i return NULL; } -int _php3_getftpresult(int socketd) +int php_get_ftp_result(int socketd) { char tmp_line[513]; diff --git a/main/main.c b/main/main.c index 2fc014eeac..2d0aee4991 100644 --- a/main/main.c +++ b/main/main.c @@ -105,7 +105,7 @@ void *gLock; /*mutex variable */ /* True globals (no need for thread safety) */ HashTable configuration_hash; -PHPAPI char *php3_ini_path = NULL; +PHPAPI char *php_ini_path = NULL; #define SAFE_FILENAME(f) ((f)?(f):"-") @@ -259,36 +259,6 @@ PHP_INI_END() /* True global (no need for thread safety */ static int module_initialized = 0; -#if 0 -#if APACHE -void php3_apache_puts(const char *s) -{ - SLS_FETCH(); - - if (SG(server_context)) { - if(rputs(s, (request_rec *) SG(server_context))==-1) { - PG(connection_status) |= PHP_CONNECTION_ABORTED; - } - } else { - fputs(s, stdout); - } -} - -void php3_apache_putc(char c) -{ - SLS_FETCH(); - - if (SG(server_context)) { - if(rputc(c, (request_rec *) SG(server_context))!=c) { - PG(connection_status) |= PHP_CONNECTION_ABORTED; - } - } else { - fputc(c, stdout); - } -} -#endif -#endif - void php_log_err(char *log_message) { FILE *log_file; @@ -337,7 +307,7 @@ void php_log_err(char *log_message) #endif /*APACHE */ #if CGI_BINARY - if (php3_header()) { + if (php_header()) { fprintf(stderr, log_message); fprintf(stderr, "\n"); } @@ -583,9 +553,9 @@ static FILE *php_fopen_wrapper_for_zend(const char *filename, char **opened_path int old_chunk_size; FILE *retval; - old_chunk_size = _php3_sock_set_def_chunk_size(1); + old_chunk_size = php_sock_set_def_chunk_size(1); retval=php_fopen_wrapper((char *) filename, "r", USE_PATH|IGNORE_URL_WIN, &issock, &socketd, opened_path); - _php3_sock_set_def_chunk_size(old_chunk_size); + php_sock_set_def_chunk_size(old_chunk_size); if (issock) { retval = fdopen(socketd, "r"); @@ -729,7 +699,7 @@ int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC) * function that gets triggered when our request pool is destroyed. * We need this because at any point in our code we can be interrupted * and that may happen before we have had time to free our memory. - * The php3_shutdown function needs to free all outstanding allocated + * The php_request_shutdown function needs to free all outstanding allocated * memory. */ block_alarms(); @@ -827,7 +797,7 @@ void php_request_shutdown(void *dummy) } -static int php3_config_ini_startup(void) +static int php_config_ini_startup(void) { if (php_init_config() == FAILURE) { php_printf("PHP: Unable to parse configuration file.\n"); @@ -836,7 +806,7 @@ static int php3_config_ini_startup(void) return SUCCESS; } -static void php3_config_ini_shutdown(void) +static void php_config_ini_shutdown(void) { php_shutdown_config(); } @@ -980,7 +950,7 @@ int php_module_startup(sapi_module_struct *sf) php_ini_mstartup(); - if (php3_config_ini_startup() == FAILURE) { + if (php_config_ini_startup() == FAILURE) { return FAILURE; } @@ -1026,7 +996,7 @@ void php_module_shutdown() } #if !USE_SAPI /* close down the ini config */ - php3_config_ini_shutdown(); + php_config_ini_shutdown(); #endif #if (WIN32|WINNT) && !(USE_SAPI) diff --git a/main/output.c b/main/output.c index a4b022313c..721379471b 100644 --- a/main/output.c +++ b/main/output.c @@ -334,7 +334,7 @@ static int php_ub_body_write(const char *str, uint str_length) if (SG(request_info).headers_only) { zend_bailout(); } - if (php3_header()) { + if (php_header()) { OG(php_body_write) = php_ub_body_write_no_header; result = php_ub_body_write_no_header(str, str_length); } diff --git a/main/php_sprintf.c b/main/php_sprintf.c new file mode 100644 index 0000000000..24b9bf15fd --- /dev/null +++ b/main/php_sprintf.c @@ -0,0 +1,42 @@ +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.0 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_0.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Jaakko Hyvätti <jaakko.hyvatti@iki.fi> | + +----------------------------------------------------------------------+ + */ + +/* $Id$ */ + +#include "php_config.h" +#include <stdio.h> +#include <stdarg.h> + +#if BROKEN_SPRINTF + +int +php_sprintf (char*s, const char* format, ...) +{ + va_list args; + char *ret; + + va_start (args, format); + s[0] = '\0'; + ret = vsprintf (s, format, args); + va_end (args); + if (!ret) + return -1; + return strlen (s); +} + +#endif /* BROKEN_SPRINTF */ diff --git a/main/rfc1867.c b/main/rfc1867.c index ea80949393..a32fd3f057 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -159,7 +159,7 @@ static void php_mime_split(char *buf, int cnt, char *boundary) php_parse_gpc_data2(ptr,namebuf,http_post_vars ELS_CC PLS_CC); /* And a little kludge to pick out special MAX_FILE_SIZE */ - itype = php3_check_ident_type(namebuf); + itype = php_check_ident_type(namebuf); if (itype) { u = strchr(namebuf, '['); if (u) @@ -217,7 +217,7 @@ static void php_mime_split(char *buf, int cnt, char *boundary) } bytes = fwrite(ptr, 1, loc - ptr - 4, fp); fclose(fp); - php3_list_insert(fn,php_file_le_uploads()); /* Tell PHP about the file so the destructor can unlink it later */ + zend_list_insert(fn,php_file_le_uploads()); /* Tell PHP about the file so the destructor can unlink it later */ if (bytes < (loc - ptr - 4)) { php_error(E_WARNING, "Only %d bytes were written, expected to write %ld", bytes, loc - ptr - 4); } diff --git a/main/safe_mode.c b/main/safe_mode.c index d7982e48dc..0b3a2c0483 100644 --- a/main/safe_mode.c +++ b/main/safe_mode.c @@ -64,7 +64,7 @@ PHPAPI int php_checkuid(const char *fn, int mode) { } if (ret>-1) { uid=sb.st_uid; - if (uid==_php3_getuid()) return(1); + if (uid==php_getuid()) return(1); } } s = strrchr(fn,'/'); @@ -100,7 +100,7 @@ PHPAPI int php_checkuid(const char *fn, int mode) { } duid = sb.st_uid; } - if (duid == (uid=_php3_getuid())) return(1); + if (duid == (uid=php_getuid())) return(1); else { php_error(E_WARNING, "SAFE MODE Restriction in effect. The script whose uid is %ld is not allowed to access %s owned by uid %ld",uid,fn,duid); return(0); |