diff options
Diffstat (limited to 'main')
53 files changed, 0 insertions, 11974 deletions
diff --git a/main/Makefile.in b/main/Makefile.in deleted file mode 100644 index 6729b31f13..0000000000 --- a/main/Makefile.in +++ /dev/null @@ -1,16 +0,0 @@ -LTLIBRARY_NAME = libmain.la - -LTLIBRARY_SOURCES = \ - main.c internal_functions.c snprintf.c php_sprintf.c \ - safe_mode.c fopen_wrappers.c alloca.c \ - php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \ - strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c \ - streams.c network.c php_open_temporary_file.c php_logos.c \ - output.c - -include $(top_srcdir)/build/ltlib.mk - - -internal_functions.c: $(srcdir)/internal_functions.c.in $(top_builddir)/config.status - cd $(top_builddir) && \ - REDO_ALL=yes ./config.status diff --git a/main/SAPI.c b/main/SAPI.c deleted file mode 100644 index ac082fb6d3..0000000000 --- a/main/SAPI.c +++ /dev/null @@ -1,595 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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. | - +----------------------------------------------------------------------+ - | Original design: Shane Caraveo <shane@caraveo.com> | - | Authors: Andi Gutmans <andi@zend.com> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - -#include <ctype.h> -#include <sys/stat.h> - -#include "php.h" -#include "SAPI.h" -#ifdef ZTS -#include "TSRM.h" -#endif - -#include "rfc1867.h" - -#ifdef PHP_WIN32 -#define STRCASECMP stricmp -#else -#define STRCASECMP strcasecmp -#endif - -#include "php_content_types.h" - -static HashTable known_post_content_types; - -SAPI_API void (*sapi_error)(int error_type, const char *message, ...); - - -#ifdef ZTS -SAPI_API int sapi_globals_id; -#else -sapi_globals_struct sapi_globals; -#endif - -static void sapi_globals_ctor(sapi_globals_struct *sapi_globals TSRMLS_DC) -{ - memset(sapi_globals, 0, sizeof(*sapi_globals)); -} - -/* True globals (no need for thread safety) */ -SAPI_API sapi_module_struct sapi_module; -SAPI_API void (*sapi_error)(int error_type, const char *message, ...); - - -SAPI_API void sapi_startup(sapi_module_struct *sf) -{ - sapi_module = *sf; - zend_hash_init_ex(&known_post_content_types, 5, NULL, NULL, 1, 0); - -#ifdef ZTS - ts_allocate_id(&sapi_globals_id, sizeof(sapi_globals_struct), (ts_allocate_ctor) sapi_globals_ctor, NULL); -#else - sapi_globals_ctor(&sapi_globals TSRMLS_CC); -#endif - -#ifdef VIRTUAL_DIR - virtual_cwd_startup(); /* Could use shutdown to free the main cwd but it would just slow it down for CGI */ -#endif - -#ifdef PHP_WIN32 - tsrm_win32_startup(); -#endif - - reentrancy_startup(); -} - -SAPI_API void sapi_shutdown(void) -{ - reentrancy_shutdown(); -#ifdef VIRTUAL_DIR - virtual_cwd_shutdown(); -#endif - -#ifdef PHP_WIN32 - tsrm_win32_shutdown(); -#endif - - zend_hash_destroy(&known_post_content_types); -} - - -SAPI_API void sapi_free_header(sapi_header_struct *sapi_header) -{ - efree(sapi_header->header); -} - - -SAPI_API void sapi_handle_post(void *arg TSRMLS_DC) -{ - if (SG(request_info).post_entry && SG(request_info).content_type_dup) { - SG(request_info).post_entry->post_handler(SG(request_info).content_type_dup, arg TSRMLS_CC); - if (SG(request_info).post_data) { - efree(SG(request_info).post_data); - SG(request_info).post_data = NULL; - } - efree(SG(request_info).content_type_dup); - SG(request_info).content_type_dup = NULL; - } -} - -static void sapi_read_post_data(TSRMLS_D) -{ - sapi_post_entry *post_entry; - uint content_type_length = strlen(SG(request_info).content_type); - char *content_type = estrndup(SG(request_info).content_type, content_type_length); - char *p; - char oldchar=0; - void (*post_reader_func)(TSRMLS_D); - - - /* dedicated implementation for increased performance: - * - Make the content type lowercase - * - Trim descriptive data, stay with the content-type only - */ - for (p=content_type; p<content_type+content_type_length; p++) { - switch (*p) { - case ';': - case ',': - case ' ': - content_type_length = p-content_type; - oldchar = *p; - *p = 0; - break; - default: - *p = tolower(*p); - break; - } - } - - if (zend_hash_find(&known_post_content_types, content_type, content_type_length+1, (void **) &post_entry)==SUCCESS) { - SG(request_info).post_entry = post_entry; - post_reader_func = post_entry->post_reader; - } else { - if (!sapi_module.default_post_reader) { - sapi_module.sapi_error(E_WARNING, "Unsupported content type: '%s'", content_type); - return; - } - SG(request_info).post_entry = NULL; - post_reader_func = sapi_module.default_post_reader; - } - if (oldchar) { - *(p-1) = oldchar; - } - post_reader_func(TSRMLS_C); - SG(request_info).content_type_dup = content_type; - if(PG(always_populate_raw_post_data) && sapi_module.default_post_reader) { - sapi_module.default_post_reader(TSRMLS_C); - } -} - - -SAPI_POST_READER_FUNC(sapi_read_standard_form_data) -{ - int read_bytes; - int allocated_bytes=SAPI_POST_BLOCK_SIZE+1; - - if (SG(request_info).content_length > SG(post_max_size)) { - php_error(E_WARNING, "POST Content-Length of %d bytes exceeds the limit of %d bytes", - SG(request_info).content_length, SG(post_max_size)); - return; - } - SG(request_info).post_data = emalloc(allocated_bytes); - - for (;;) { - read_bytes = sapi_module.read_post(SG(request_info).post_data+SG(read_post_bytes), SAPI_POST_BLOCK_SIZE TSRMLS_CC); - if (read_bytes<=0) { - break; - } - SG(read_post_bytes) += read_bytes; - if (SG(read_post_bytes) > SG(post_max_size)) { - php_error(E_WARNING, "Actual POST length does not match Content-Length, and exceeds %d bytes", SG(post_max_size)); - return; - } - if (read_bytes < SAPI_POST_BLOCK_SIZE) { - break; - } - if (SG(read_post_bytes)+SAPI_POST_BLOCK_SIZE >= allocated_bytes) { - allocated_bytes = SG(read_post_bytes)+SAPI_POST_BLOCK_SIZE+1; - SG(request_info).post_data = erealloc(SG(request_info).post_data, allocated_bytes); - } - } - SG(request_info).post_data[SG(read_post_bytes)] = 0; /* terminating NULL */ - SG(request_info).post_data_length = SG(read_post_bytes); -} - - -SAPI_API char *sapi_get_default_content_type(TSRMLS_D) -{ - char *mimetype, *charset, *content_type; - - mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE; - charset = SG(default_charset) ? SG(default_charset) : SAPI_DEFAULT_CHARSET; - - if (strncasecmp(mimetype, "text/", 5) == 0 && *charset) { - int len = strlen(mimetype) + sizeof("; charset=") + strlen(charset); - content_type = emalloc(len); - snprintf(content_type, len, "%s; charset=%s", mimetype, charset); - } else { - content_type = estrdup(mimetype); - } - return content_type; -} - - -SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header TSRMLS_DC) -{ - char *default_content_type = sapi_get_default_content_type(TSRMLS_C); - int default_content_type_len = strlen(default_content_type); - - default_header->header_len = (sizeof("Content-type: ")-1) + default_content_type_len; - default_header->header = emalloc(default_header->header_len+1); - memcpy(default_header->header, "Content-type: ", sizeof("Content-type: ")); - memcpy(default_header->header+sizeof("Content-type: ")-1, default_content_type, default_content_type_len); - default_header->header[default_header->header_len] = 0; - efree(default_content_type); -} - -/* - * Add charset on content-type header if the MIME type starts with - * "text/", the default_charset directive is not empty and - * there is not already a charset option in there. - * - * If "mimetype" is non-NULL, it should point to a pointer allocated - * with emalloc(). If a charset is added, the string will be - * re-allocated and the new length is returned. If mimetype is - * unchanged, 0 is returned. - * - */ -SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len TSRMLS_DC) -{ - char *charset, *newtype; - size_t newlen; - charset = SG(default_charset) ? SG(default_charset) : SAPI_DEFAULT_CHARSET; - - if (*charset && strncmp(*mimetype, "text/", 5) == 0 && strstr(*mimetype, "charset=") == NULL) { - newlen = len + (sizeof(";charset=")-1) + strlen(charset); - newtype = emalloc(newlen + 1); - PHP_STRLCPY(newtype, *mimetype, newlen + 1, len); - strlcat(newtype, ";charset=", newlen + 1); - if (*mimetype != NULL) { - efree(*mimetype); - } - *mimetype = newtype; - return newlen; - } - return 0; -} - - -/* - * Called from php_request_startup() for every request. - */ -SAPI_API void sapi_activate(TSRMLS_D) -{ - zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0); - SG(sapi_headers).send_default_content_type = 1; - - /* - SG(sapi_headers).http_response_code = 200; - */ - SG(sapi_headers).http_status_line = NULL; - SG(headers_sent) = 0; - SG(read_post_bytes) = 0; - SG(request_info).post_data = NULL; - SG(request_info).current_user = NULL; - SG(request_info).current_user_length = 0; - SG(request_info).no_headers = 0; - - /* It's possible to override this general case in the activate() callback, if - * necessary. - */ - if (SG(request_info).request_method && !strcmp(SG(request_info).request_method, "HEAD")) { - SG(request_info).headers_only = 1; - } else { - SG(request_info).headers_only = 0; - } - SG(rfc1867_uploaded_files) = NULL; - - if (SG(server_context)) { - if (SG(request_info).request_method - && !strcmp(SG(request_info).request_method, "POST")) { - if (!SG(request_info).content_type) { - sapi_module.sapi_error(E_WARNING, "No content-type in POST request"); - SG(request_info).content_type_dup = NULL; - } else { - sapi_read_post_data(TSRMLS_C); - } - } else { - SG(request_info).content_type_dup = NULL; - } - SG(request_info).cookie_data = sapi_module.read_cookies(TSRMLS_C); - if (sapi_module.activate) { - sapi_module.activate(TSRMLS_C); - } - } -} - - -SAPI_API void sapi_deactivate(TSRMLS_D) -{ - zend_llist_destroy(&SG(sapi_headers).headers); - if (SG(request_info).post_data) { - efree(SG(request_info).post_data); - } - if (SG(request_info).auth_user) { - efree(SG(request_info).auth_user); - } - if (SG(request_info).auth_password) { - efree(SG(request_info).auth_password); - } - if (SG(request_info).content_type_dup) { - efree(SG(request_info).content_type_dup); - } - if (SG(request_info).current_user) { - efree(SG(request_info).current_user); - } - if (sapi_module.deactivate) { - sapi_module.deactivate(TSRMLS_C); - } - if (SG(rfc1867_uploaded_files)) { - destroy_uploaded_files_hash(TSRMLS_C); - } -} - - -SAPI_API void sapi_initialize_empty_request(TSRMLS_D) -{ - SG(server_context) = NULL; - SG(request_info).request_method = NULL; - SG(request_info).auth_user = SG(request_info).auth_password = NULL; - SG(request_info).content_type_dup = NULL; -} - - -static int sapi_extract_response_code(const char *header_line) -{ - int code = 200; - const char *ptr; - - for (ptr = header_line; *ptr; ptr++) { - if (*ptr == ' ' && *(ptr + 1) != ' ') { - code = atoi(ptr + 1); - break; - } - } - - return code; -} - -/* This function expects a *duplicated* string, that was previously emalloc()'d. - * Pointers sent to this functions will be automatically freed by the framework. - */ -SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC) -{ - int retval, free_header = 0; - sapi_header_struct sapi_header; - char *colon_offset; - - if (SG(headers_sent) && !SG(request_info).no_headers) { - char *output_start_filename = php_get_output_start_filename(TSRMLS_C); - int output_start_lineno = php_get_output_start_lineno(TSRMLS_C); - - if (output_start_filename) { - sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already sent by (output started at %s:%d)", - output_start_filename, output_start_lineno); - } else { - sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already sent"); - } - if (!duplicate) { - efree(header_line); - } - return FAILURE; - } - - if (duplicate) { - header_line = estrndup(header_line, header_line_len); - } - - /* cut of trailing spaces, linefeeds and carriage-returns */ - while(isspace(header_line[header_line_len-1])) - header_line[--header_line_len]='\0'; - - - sapi_header.header = header_line; - sapi_header.header_len = header_line_len; - sapi_header.replace = replace; - - /* Check the header for a few cases that we have special support for in SAPI */ - if (header_line_len>=5 - && !strncasecmp(header_line, "HTTP/", 5)) { - /* filter out the response code */ - SG(sapi_headers).http_response_code = sapi_extract_response_code(header_line); - SG(sapi_headers).http_status_line = header_line; - return SUCCESS; - } else { - colon_offset = strchr(header_line, ':'); - if (colon_offset) { - *colon_offset = 0; - if (!STRCASECMP(header_line, "Content-Type")) { - char *ptr = colon_offset, *mimetype = NULL, *newheader; - size_t len = header_line_len - (ptr - header_line), newlen; - while (*ptr == ' ' && *ptr != '\0') { - ptr++; - } - mimetype = estrdup(ptr); - newlen = sapi_apply_default_charset(&mimetype, len TSRMLS_CC); - if (newlen != 0) { - newlen += sizeof("Content-type: "); - newheader = emalloc(newlen); - PHP_STRLCPY(newheader, "Content-type: ", newlen, sizeof("Content-type: ")-1); - strlcat(newheader, mimetype, newlen); - sapi_header.header = newheader; - sapi_header.header_len = newlen - 1; - colon_offset = strchr(newheader, ':'); - *colon_offset = '\0'; - free_header = 1; - } - efree(mimetype); - SG(sapi_headers).send_default_content_type = 0; - } else if (!STRCASECMP(header_line, "Location")) { - if (SG(sapi_headers).http_response_code < 300 || - SG(sapi_headers).http_response_code > 307) { - /* Return a Found Redirect if one is not already specified */ - SG(sapi_headers).http_response_code = 302; - } - } else if (!STRCASECMP(header_line, "WWW-Authenticate")) { /* HTTP Authentication */ - SG(sapi_headers).http_response_code = 401; /* authentication-required */ - } - *colon_offset = ':'; - } - } - - if (sapi_module.header_handler) { - retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers) TSRMLS_CC); - } else { - retval = SAPI_HEADER_ADD; - } - if (retval & SAPI_HEADER_DELETE_ALL) { - zend_llist_clean(&SG(sapi_headers).headers); - } - if (retval & SAPI_HEADER_ADD) { - zend_llist_add_element(&SG(sapi_headers).headers, (void *) &sapi_header); - } - if (free_header) { - efree(sapi_header.header); - } - return SUCCESS; -} - - -SAPI_API int sapi_send_headers(TSRMLS_D) -{ - int retval; - int ret = FAILURE; - - if (SG(headers_sent) || SG(request_info).no_headers) { - return SUCCESS; - } - - /* Success-oriented. We set headers_sent to 1 here to avoid an infinite loop - * in case of an error situation. - */ - SG(headers_sent) = 1; - - if (sapi_module.send_headers) { - retval = sapi_module.send_headers(&SG(sapi_headers) TSRMLS_CC); - } else { - retval = SAPI_HEADER_DO_SEND; - } - - switch (retval) { - case SAPI_HEADER_SENT_SUCCESSFULLY: - ret = SUCCESS; - break; - case SAPI_HEADER_DO_SEND: - if (SG(sapi_headers).http_status_line) { - sapi_header_struct http_status_line; - - http_status_line.header = SG(sapi_headers).http_status_line; - http_status_line.header_len = strlen(SG(sapi_headers).http_status_line); - sapi_module.send_header(&http_status_line, SG(server_context) TSRMLS_CC); - } - zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) sapi_module.send_header, SG(server_context) TSRMLS_CC); - if(SG(sapi_headers).send_default_content_type) { - sapi_header_struct default_header; - - sapi_get_default_content_type_header(&default_header TSRMLS_CC); - sapi_module.send_header(&default_header, SG(server_context) TSRMLS_CC); - sapi_free_header(&default_header); - } - sapi_module.send_header(NULL, SG(server_context) TSRMLS_CC); - ret = SUCCESS; - break; - case SAPI_HEADER_SEND_FAILED: - SG(headers_sent) = 0; - ret = FAILURE; - break; - } - - if (SG(sapi_headers).http_status_line) { - efree(SG(sapi_headers).http_status_line); - } - - return ret; -} - - -SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entries) -{ - sapi_post_entry *p=post_entries; - - while (p->content_type) { - if (sapi_register_post_entry(p)==FAILURE) { - return FAILURE; - } - p++; - } - return SUCCESS; -} - - -SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry) -{ - return zend_hash_add(&known_post_content_types, post_entry->content_type, post_entry->content_type_len+1, (void *) post_entry, sizeof(sapi_post_entry), NULL); -} - -SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry) -{ - zend_hash_del(&known_post_content_types, post_entry->content_type, post_entry->content_type_len+1); -} - - -SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D)) -{ - sapi_module.default_post_reader = default_post_reader; - return SUCCESS; -} - - -SAPI_API int sapi_flush(TSRMLS_D) -{ - if (sapi_module.flush) { - sapi_module.flush(SG(server_context)); - return SUCCESS; - } else { - return FAILURE; - } -} - -SAPI_API struct stat *sapi_get_stat(TSRMLS_D) -{ - if (sapi_module.get_stat) { - return sapi_module.get_stat(TSRMLS_C); - } else { - if (!SG(request_info).path_translated || (VCWD_STAT(SG(request_info).path_translated, &SG(global_stat))==-1)) { - return NULL; - } - return &SG(global_stat); - } -} - - -SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC) -{ - if (sapi_module.getenv) { - return sapi_module.getenv(name, name_len TSRMLS_CC); - } else { - return NULL; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/SAPI.h b/main/SAPI.h deleted file mode 100644 index d1e8a3de19..0000000000 --- a/main/SAPI.h +++ /dev/null @@ -1,225 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - - -#ifndef SAPI_H -#define SAPI_H - -#include "zend.h" -#include "zend_llist.h" -#include "zend_operators.h" -#include <sys/stat.h> - -#define SAPI_OPTION_NO_CHDIR 1 - -#define SAPI_POST_BLOCK_SIZE 4000 - -#ifdef PHP_WIN32 -# ifdef SAPI_EXPORTS -# define SAPI_API __declspec(dllexport) -# else -# define SAPI_API __declspec(dllimport) -# endif -#else -#define SAPI_API -#endif - - -typedef struct { - char *header; - uint header_len; - zend_bool replace; -} sapi_header_struct; - - -typedef struct { - zend_llist headers; - int http_response_code; - unsigned char send_default_content_type; - char *http_status_line; -} sapi_headers_struct; - - -typedef struct _sapi_post_entry sapi_post_entry; -typedef struct _sapi_module_struct sapi_module_struct; - - -extern SAPI_API sapi_module_struct sapi_module; /* true global */ - -/* Some values in this structure needs to be filled in before - * calling sapi_activate(). We WILL change the `char *' entries, - * so make sure that you allocate a separate buffer for them - * and that you free them after sapi_deactivate(). - */ - -typedef struct { - const char *request_method; - char *query_string; - char *post_data; - char *cookie_data; - long content_length; - uint post_data_length; - - char *path_translated; - char *request_uri; - - const char *content_type; - - zend_bool headers_only; - zend_bool no_headers; - - sapi_post_entry *post_entry; - - char *content_type_dup; - - /* for HTTP authentication */ - char *auth_user; - char *auth_password; - - /* this is necessary for the CGI SAPI module */ - char *argv0; - - /* this is necessary for Safe Mode */ - char *current_user; - int current_user_length; -} sapi_request_info; - - -typedef struct { - void *server_context; - sapi_request_info request_info; - sapi_headers_struct sapi_headers; - int read_post_bytes; - unsigned char headers_sent; - struct stat global_stat; - char *default_mimetype; - char *default_charset; - HashTable *rfc1867_uploaded_files; - long post_max_size; - int options; -} sapi_globals_struct; - - -#ifdef ZTS -# define SG(v) TSRMG(sapi_globals_id, sapi_globals_struct *, v) -SAPI_API extern int sapi_globals_id; -#else -# define SG(v) (sapi_globals.v) -extern SAPI_API sapi_globals_struct sapi_globals; -#endif - - -SAPI_API void sapi_startup(sapi_module_struct *sf); -SAPI_API void sapi_shutdown(void); -SAPI_API void sapi_activate(TSRMLS_D); -SAPI_API void sapi_deactivate(TSRMLS_D); -SAPI_API void sapi_initialize_empty_request(TSRMLS_D); - -SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC); -#define sapi_add_header(header_line, header_line_len, duplicate) \ - sapi_add_header_ex((header_line), (header_line_len), (duplicate), 1 TSRMLS_CC) -SAPI_API int sapi_send_headers(TSRMLS_D); -SAPI_API void sapi_free_header(sapi_header_struct *sapi_header); -SAPI_API void sapi_handle_post(void *arg TSRMLS_DC); - -SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entry); -SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry); -SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry); -SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D)); - -SAPI_API int sapi_flush(TSRMLS_D); -SAPI_API struct stat *sapi_get_stat(TSRMLS_D); -SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC); - -SAPI_API char *sapi_get_default_content_type(TSRMLS_D); -SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header TSRMLS_DC); -SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len TSRMLS_DC); - -struct _sapi_module_struct { - char *name; - char *pretty_name; - - int (*startup)(struct _sapi_module_struct *sapi_module); - int (*shutdown)(struct _sapi_module_struct *sapi_module); - - int (*activate)(TSRMLS_D); - int (*deactivate)(TSRMLS_D); - - int (*ub_write)(const char *str, unsigned int str_length TSRMLS_DC); - void (*flush)(void *server_context); - struct stat *(*get_stat)(TSRMLS_D); - char *(*getenv)(char *name, size_t name_len TSRMLS_DC); - - void (*sapi_error)(int type, const char *error_msg, ...); - - int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC); - int (*send_headers)(sapi_headers_struct *sapi_headers TSRMLS_DC); - void (*send_header)(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC); - - int (*read_post)(char *buffer, uint count_bytes TSRMLS_DC); - char *(*read_cookies)(TSRMLS_D); - - void (*register_server_variables)(zval *track_vars_array TSRMLS_DC); - void (*log_message)(char *message); - - char *php_ini_path_override; - - void (*block_interruptions)(void); - void (*unblock_interruptions)(void); - - void (*default_post_reader)(TSRMLS_D); -}; - - -struct _sapi_post_entry { - char *content_type; - uint content_type_len; - void (*post_reader)(TSRMLS_D); - void (*post_handler)(char *content_type_dup, void *arg TSRMLS_DC); -}; - -/* header_handler() constants */ -#define SAPI_HEADER_ADD (1<<0) -#define SAPI_HEADER_DELETE_ALL (1<<1) -#define SAPI_HEADER_SEND_NOW (1<<2) - - -#define SAPI_HEADER_SENT_SUCCESSFULLY 1 -#define SAPI_HEADER_DO_SEND 2 -#define SAPI_HEADER_SEND_FAILED 3 - -#define SAPI_DEFAULT_MIMETYPE "text/html" -#define SAPI_DEFAULT_CHARSET "" -#define SAPI_PHP_VERSION_HEADER "X-Powered-By: PHP/" PHP_VERSION - -#define SAPI_POST_READER_FUNC(post_reader) SAPI_API void post_reader(TSRMLS_D) -#define SAPI_POST_HANDLER_FUNC(post_handler) SAPI_API void post_handler(char *content_type_dup, void *arg TSRMLS_DC) - -SAPI_POST_READER_FUNC(sapi_read_standard_form_data); -SAPI_POST_READER_FUNC(php_default_post_reader); - -#define STANDARD_SAPI_MODULE_PROPERTIES NULL - -#endif /* SAPI_H */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/main/alloca.c b/main/alloca.c deleted file mode 100644 index faba929ef8..0000000000 --- a/main/alloca.c +++ /dev/null @@ -1,499 +0,0 @@ -/* alloca.c -- allocate automatically reclaimed memory - (Mostly) portable public-domain implementation -- D A Gwyn - - This implementation of the PWB library alloca function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - J.Otto Tennant <jot@cray.com> contributed the Cray support. - - There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. */ - -#include "php_config.h" - -#if !HAVE_ALLOCA - -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef emacs -#include "blockinput.h" -#endif - -/* If compiling with GCC 2, this file's not needed. */ -#if !defined (__GNUC__) || __GNUC__ < 2 - -/* If someone has defined alloca as a macro, - there must be some other way alloca is supposed to work. */ -#ifndef alloca - -#ifdef emacs -#ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -#ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ - -/* If your stack is a linked list of frames, you have to - provide an "address metric" ADDRESS_FUNCTION macro. */ - -#if defined (CRAY) && defined (CRAY_STACKSEG_END) -long i00afunc (); -#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) -#else -#define ADDRESS_FUNCTION(arg) &(arg) -#endif - -#if __STDC__ -typedef void *pointer; -#else -typedef char *pointer; -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ - -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* Direction unknown. */ -#endif - -#if STACK_DIRECTION != 0 - -#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ - -#else /* STACK_DIRECTION == 0; need run-time code. */ - -static int stack_dir; /* 1 or -1 once known. */ -#define STACK_DIR stack_dir - -static void -find_stack_direction () -{ - static char *addr = NULL; /* Address of first `dummy', once known. */ - auto char dummy; /* To get stack address. */ - - if (addr == NULL) - { /* Initial entry. */ - addr = ADDRESS_FUNCTION (dummy); - - find_stack_direction (); /* Recurse once. */ - } - else - { - /* Second entry. */ - if (ADDRESS_FUNCTION (dummy) > addr) - stack_dir = 1; /* Stack grew upward. */ - else - stack_dir = -1; /* Stack grew downward. */ - } -} - -#endif /* STACK_DIRECTION == 0 */ - -/* An "alloca header" is used to: - (a) chain together all alloca'ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc - alignment chunk size. The following default should work okay. */ - -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* To force sizeof(header). */ - struct - { - union hdr *next; /* For chaining headers. */ - char *deep; /* For stack depth measure. */ - } h; -} header; - -static header *last_alloca_header = NULL; /* -> last alloca header. */ - -/* Return a pointer to at least SIZE bytes of storage, - which will be automatically reclaimed upon exit from - the procedure that called alloca. Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. */ - -pointer -alloca (size) - size_t size; -{ - auto char probe; /* Probes stack depth: */ - register char *depth = ADDRESS_FUNCTION (probe); - -#if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* Unknown growth direction. */ - find_stack_direction (); -#endif - - /* Reclaim garbage, defined as all alloca'd storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* Traverses linked list. */ - -#ifdef emacs - BLOCK_INPUT; -#endif - - for (hp = last_alloca_header; hp != NULL;) - if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; - - free ((pointer) hp); /* Collect garbage. */ - - hp = np; /* -> next header. */ - } - else - break; /* Rest are not deeper. */ - - last_alloca_header = hp; /* -> last valid storage. */ - -#ifdef emacs - UNBLOCK_INPUT; -#endif - } - - if (size == 0) - return NULL; /* No allocation required. */ - - /* Allocate combined header + user data storage. */ - - { - register pointer new = malloc (sizeof (header) + size); - /* Address of header. */ - - if (new == 0) - abort(); - - ((header *) new)->h.next = last_alloca_header; - ((header *) new)->h.deep = depth; - - last_alloca_header = (header *) new; - - /* User storage begins just after header. */ - - return (pointer) ((char *) new + sizeof (header)); - } -} - -#if defined (CRAY) && defined (CRAY_STACKSEG_END) - -#ifdef DEBUG_I00AFUNC -#include <stdio.h> -#endif - -#ifndef CRAY_STACK -#define CRAY_STACK -#ifndef CRAY2 -/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ -struct stack_control_header - { - long shgrow:32; /* Number of times stack has grown. */ - long shaseg:32; /* Size of increments to stack. */ - long shhwm:32; /* High water mark of stack. */ - long shsize:32; /* Current size of stack (all segments). */ - }; - -/* The stack segment linkage control information occurs at - the high-address end of a stack segment. (The stack - grows from low addresses to high addresses.) The initial - part of the stack segment linkage control information is - 0200 (octal) words. This provides for register storage - for the routine which overflows the stack. */ - -struct stack_segment_linkage - { - long ss[0200]; /* 0200 overflow words. */ - long sssize:32; /* Number of words in this segment. */ - long ssbase:32; /* Offset to stack base. */ - long:32; - long sspseg:32; /* Offset to linkage control of previous - segment of stack. */ - long:32; - long sstcpt:32; /* Pointer to task common address block. */ - long sscsnm; /* Private control structure number for - microtasking. */ - long ssusr1; /* Reserved for user. */ - long ssusr2; /* Reserved for user. */ - long sstpid; /* Process ID for pid based multi-tasking. */ - long ssgvup; /* Pointer to multitasking thread giveup. */ - long sscray[7]; /* Reserved for Cray Research. */ - long ssa0; - long ssa1; - long ssa2; - long ssa3; - long ssa4; - long ssa5; - long ssa6; - long ssa7; - long sss0; - long sss1; - long sss2; - long sss3; - long sss4; - long sss5; - long sss6; - long sss7; - }; - -#else /* CRAY2 */ -/* The following structure defines the vector of words - returned by the STKSTAT library routine. */ -struct stk_stat - { - long now; /* Current total stack size. */ - long maxc; /* Amount of contiguous space which would - be required to satisfy the maximum - stack demand to date. */ - long high_water; /* Stack high-water mark. */ - long overflows; /* Number of stack overflow ($STKOFEN) calls. */ - long hits; /* Number of internal buffer hits. */ - long extends; /* Number of block extensions. */ - long stko_mallocs; /* Block allocations by $STKOFEN. */ - long underflows; /* Number of stack underflow calls ($STKRETN). */ - long stko_free; /* Number of deallocations by $STKRETN. */ - long stkm_free; /* Number of deallocations by $STKMRET. */ - long segments; /* Current number of stack segments. */ - long maxs; /* Maximum number of stack segments so far. */ - long pad_size; /* Stack pad size. */ - long current_address; /* Current stack segment address. */ - long current_size; /* Current stack segment size. This - number is actually corrupted by STKSTAT to - include the fifteen word trailer area. */ - long initial_address; /* Address of initial segment. */ - long initial_size; /* Size of initial segment. */ - }; - -/* The following structure describes the data structure which trails - any stack segment. I think that the description in 'asdef' is - out of date. I only describe the parts that I am sure about. */ - -struct stk_trailer - { - long this_address; /* Address of this block. */ - long this_size; /* Size of this block (does not include - this trailer). */ - long unknown2; - long unknown3; - long link; /* Address of trailer block of previous - segment. */ - long unknown5; - long unknown6; - long unknown7; - long unknown8; - long unknown9; - long unknown10; - long unknown11; - long unknown12; - long unknown13; - long unknown14; - }; - -#endif /* CRAY2 */ -#endif /* not CRAY_STACK */ - -#ifdef CRAY2 -/* Determine a "stack measure" for an arbitrary ADDRESS. - I doubt that "lint" will like this much. */ - -static long -i00afunc (long *address) -{ - struct stk_stat status; - struct stk_trailer *trailer; - long *block, size; - long result = 0; - - /* We want to iterate through all of the segments. The first - step is to get the stack status structure. We could do this - more quickly and more directly, perhaps, by referencing the - $LM00 common block, but I know that this works. */ - - STKSTAT (&status); - - /* Set up the iteration. */ - - trailer = (struct stk_trailer *) (status.current_address - + status.current_size - - 15); - - /* There must be at least one stack segment. Therefore it is - a fatal error if "trailer" is null. */ - - if (trailer == 0) - abort (); - - /* Discard segments that do not contain our argument address. */ - - while (trailer != 0) - { - block = (long *) trailer->this_address; - size = trailer->this_size; - if (block == 0 || size == 0) - abort (); - trailer = (struct stk_trailer *) trailer->link; - if ((block <= address) && (address < (block + size))) - break; - } - - /* Set the result to the offset in this segment and add the sizes - of all predecessor segments. */ - - result = address - block; - - if (trailer == 0) - { - return result; - } - - do - { - if (trailer->this_size <= 0) - abort (); - result += trailer->this_size; - trailer = (struct stk_trailer *) trailer->link; - } - while (trailer != 0); - - /* We are done. Note that if you present a bogus address (one - not in any segment), you will get a different number back, formed - from subtracting the address of the first block. This is probably - not what you want. */ - - return (result); -} - -#else /* not CRAY2 */ -/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. - Determine the number of the cell within the stack, - given the address of the cell. The purpose of this - routine is to linearize, in some sense, stack addresses - for alloca. */ - -static long -i00afunc (long address) -{ - long stkl = 0; - - long size, pseg, this_segment, stack; - long result = 0; - - struct stack_segment_linkage *ssptr; - - /* Register B67 contains the address of the end of the - current stack segment. If you (as a subprogram) store - your registers on the stack and find that you are past - the contents of B67, you have overflowed the segment. - - B67 also points to the stack segment linkage control - area, which is what we are really interested in. */ - - stkl = CRAY_STACKSEG_END (); - ssptr = (struct stack_segment_linkage *) stkl; - - /* If one subtracts 'size' from the end of the segment, - one has the address of the first word of the segment. - - If this is not the first segment, 'pseg' will be - nonzero. */ - - pseg = ssptr->sspseg; - size = ssptr->sssize; - - this_segment = stkl - size; - - /* It is possible that calling this routine itself caused - a stack overflow. Discard stack segments which do not - contain the target address. */ - - while (!(this_segment <= address && address <= stkl)) - { -#ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); -#endif - if (pseg == 0) - break; - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - this_segment = stkl - size; - } - - result = address - this_segment; - - /* If you subtract pseg from the current end of the stack, - you get the address of the previous stack segment's end. - This seems a little convoluted to me, but I'll bet you save - a cycle somewhere. */ - - while (pseg != 0) - { -#ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o\n", pseg, size); -#endif - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - result += size; - } - return (result); -} - -#endif /* not CRAY2 */ -#endif /* CRAY */ - -#endif /* no alloca */ -#endif /* not GCC version 2 */ -#endif /* HAVE_ALLOCA */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/build-defs.h.in b/main/build-defs.h.in deleted file mode 100644 index 58e3d4a209..0000000000 --- a/main/build-defs.h.in +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- C -*- - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Stig Sæther Bakken <ssb@fast.no> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#define CONFIGURE_COMMAND "@CONFIGURE_COMMAND@" -#define PHP_ADA_INCLUDE "" -#define PHP_ADA_LFLAGS "" -#define PHP_ADA_LIBS "" -#define PHP_APACHE_INCLUDE "" -#define PHP_APACHE_TARGET "" -#define PHP_FHTTPD_INCLUDE "" -#define PHP_FHTTPD_LIB "" -#define PHP_FHTTPD_TARGET "" -#define PHP_CFLAGS "@CFLAGS@" -#define PHP_DBASE_LIB "" -#define PHP_BUILD_DEBUG "@DEBUG_CFLAGS@" -#define PHP_GDBM_INCLUDE "" -#define PHP_HSREGEX "" -#define PHP_IBASE_INCLUDE "" -#define PHP_IBASE_LFLAGS "" -#define PHP_IBASE_LIBS "" -#define PHP_IFX_INCLUDE "" -#define PHP_IFX_LFLAGS "" -#define PHP_IFX_LIBS "" -#define PHP_INSTALL_IT "@INSTALL_IT@" -#define PHP_IODBC_INCLUDE "" -#define PHP_IODBC_LFLAGS "" -#define PHP_IODBC_LIBS "" -#define PHP_MSQL_INCLUDE "" -#define PHP_MSQL_LFLAGS "" -#define PHP_MSQL_LIBS "" -#define PHP_MYSQL_INCLUDE "@MYSQL_INCLUDE@" -#define PHP_MYSQL_LIBS "@MYSQL_LIBS@" -#define PHP_MYSQL_TYPE "@MYSQL_MODULE_TYPE@" -#define PHP_ODBC_INCLUDE "@ODBC_INCLUDE@" -#define PHP_ODBC_LFLAGS "@ODBC_LFLAGS@" -#define PHP_ODBC_LIBS "@ODBC_LIBS@" -#define PHP_ODBC_TYPE "@ODBC_TYPE@" -#define PHP_OCI8_SHARED_LIBADD "@OCI8_SHARED_LIBADD@" -#define PHP_OCI8_DIR "@OCI8_DIR@" -#define PHP_OCI8_VERSION "@OCI8_VERSION@" -#define PHP_ORACLE_SHARED_LIBADD "@ORACLE_SHARED_LIBADD@" -#define PHP_ORACLE_DIR "@ORACLE_DIR@" -#define PHP_ORACLE_VERSION "@ORACLE_VERSION@" -#define PHP_PGSQL_INCLUDE "" -#define PHP_PGSQL_LFLAGS "" -#define PHP_PGSQL_LIBS "" -#define PHP_PROG_SENDMAIL "@PROG_SENDMAIL@" -#define PHP_REGEX_LIB "" -#define PHP_SOLID_INCLUDE "" -#define PHP_SOLID_LIBS "" -#define PHP_EMPRESS_INCLUDE "" -#define PHP_EMPRESS_LIBS "" -#define PHP_SYBASE_INCLUDE "" -#define PHP_SYBASE_LFLAGS "" -#define PHP_SYBASE_LIBS "" -#define PHP_DBM_TYPE "" -#define PHP_DBM_LIB "" -#define PHP_LDAP_LFLAGS "" -#define PHP_LDAP_INCLUDE "" -#define PHP_LDAP_LIBS "" -#define PHP_VELOCIS_INCLUDE "" -#define PHP_VELOCIS_LIBS "" -#define PEAR_INSTALLDIR "@EXPANDED_PEAR_INSTALLDIR@" -#define PHP_INCLUDE_PATH "@INCLUDE_PATH@" -#define PHP_EXTENSION_DIR "@EXPANDED_EXTENSION_DIR@" -#define PHP_BINDIR "@EXPANDED_BINDIR@" -#define PHP_LIBDIR "@EXPANDED_LIBDIR@" -#define PHP_DATADIR "@EXPANDED_DATADIR@" -#define PHP_SYSCONFDIR "@EXPANDED_SYSCONFDIR@" -#define PHP_LOCALSTATEDIR "@EXPANDED_LOCALSTATEDIR@" -#define PHP_CONFIG_FILE_PATH "@EXPANDED_PHP_CONFIG_FILE_PATH@" diff --git a/main/config.w32.h b/main/config.w32.h deleted file mode 100644 index 87b1841546..0000000000 --- a/main/config.w32.h +++ /dev/null @@ -1,264 +0,0 @@ -/* config.w32.h. Configure file for win32 platforms */ -/* tested only with MS Visual C++ V6 */ - - -/* Define if PHP to setup it's own SIGCHLD handler (not needed on Win32) */ -#define PHP_SIGCHILD 0 - -/* dns functions found in resolv.lib */ -#define HAVE_LIBBIND 1 - -#define HAVE_GETSERVBYNAME 1 -#define HAVE_GETSERVBYPORT 1 -#define HAVE_GETPROTOBYNAME 1 -#define HAVE_GETPROTOBYNUMBER 1 - -/* set to enable bcmath */ -#define WITH_BCMATH 1 - -/* set to enable mysql */ -#define HAVE_MYSQL 1 - -/* set to enable FTP support */ -#define HAVE_FTP 1 - -/* set to enable bundled PCRE library */ -#define HAVE_BUNDLED_PCRE 1 - -/* set to enable bundled expat library */ -#define HAVE_LIBEXPAT 1 -#define HAVE_WDDX 1 - -/* set to enable the crypt command */ -#define HAVE_CRYPT 0 -/* #define HAVE_CRYPT_H 1 */ - -/* set to enable trans sid */ -#define TRANS_SID 1 - -/* set to enable force cgi redirect */ -#define FORCE_CGI_REDIRECT 0 - -/* should be added to runtime config*/ -#define PHP_URL_FOPEN 1 - -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 - -/* ---------------------------------------------------------------- - The following are defaults for run-time configuration - ---------------------------------------------------------------*/ - -#define PHP_SAFE_MODE 0 -#define MAGIC_QUOTES 0 -/* This is the default configuration file to read */ -#define CONFIGURATION_FILE_PATH "php.ini" -#define USE_CONFIG_FILE 1 - -#define PHP_INCLUDE_PATH NULL - - -/* Undefine if you want stricter XML/SGML compliance by default */ -/* this disables "<?expression?>" and "<?=expression?>" */ -#define DEFAULT_SHORT_OPEN_TAG "1" - - -/* ---------------------------------------------------------------- - The following defines are for those modules which require - external libraries to compile. These will be removed from - here in a future beta, as these modules will be moved out to dll's - ---------------------------------------------------------------*/ -#define HAVE_ERRMSG_H 0 /*needed for mysql 3.21.17 and up*/ -#undef HAVE_ADABAS -#undef HAVE_SOLID - - -/* ---------------------------------------------------------------- - The following may or may not be (or need to be) ported to the - windows environment. - ---------------------------------------------------------------*/ - -/* Define if you have the link function. */ -#undef HAVE_LINK - -/* Define if you have the symlink function. */ -#undef HAVE_SYMLINK - -/* Define if you have the usleep function. */ -#undef HAVE_USLEEP - -#define HAVE_GETCWD 1 -#define HAVE_POSIX_READDIR_R 1 - -#define NEED_ISBLANK 1 - -/* ---------------------------------------------------------------- - The following should never need to be played with - Functions defined to 0 or remarked out are either already - handled by the standard VC libraries, or are no longer needed, or - simply will/can not be ported. - - DONT TOUCH!!!!! Unless you realy know what your messing with! - ---------------------------------------------------------------*/ - -#define DISCARD_PATH 0 -#undef HAVE_SETITIMER -#undef HAVE_IODBC -#define HAVE_UODBC 1 -#define HAVE_LIBDL 1 -#define HAVE_SENDMAIL 1 -#define HAVE_GETTIMEOFDAY 1 -#define HAVE_PUTENV 1 -#define HAVE_LIMITS_H 1 - -#define HAVE_TZSET 1 -#define HAVE_TZNAME 1 - -/* Define if you have the flock function. */ -#undef HAVE_FLOCK - -/* Define if you have alloca, as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define if you have <sys/time.h> */ -#undef HAVE_SYS_TIME_H - -/* Define if you have <signal.h> */ -#define HAVE_SIGNAL_H 1 - -/* Define if your struct stat has st_blksize. */ -#undef HAVE_ST_BLKSIZE - -/* Define if your struct stat has st_blocks. */ -#undef HAVE_ST_BLOCKS - -/* Define if your struct stat has st_rdev. */ -#define HAVE_ST_RDEV 1 - -/* Define if utime(file, NULL) sets file's timestamp to the present. */ -#define HAVE_UTIME_NULL 1 - -/* Define if you have the vprintf function. */ -#define HAVE_VPRINTF 1 - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define both of these if you want the bundled REGEX library */ -#define REGEX 1 -#define HSREGEX 1 - -#define HAVE_PCRE 1 - -/* Define if you have the gcvt function. */ -#define HAVE_GCVT 1 - -/* Define if you have the getlogin function. */ -#define HAVE_GETLOGIN 1 - -/* Define if you have the gettimeofday function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY 1 - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE 1 - -/* Define if you have the putenv function. */ -#define HAVE_PUTENV 1 - -/* Define if you have the regcomp function. */ -#define HAVE_REGCOMP 1 - -/* Define if you have the setlocale function. */ -#define HAVE_SETLOCALE 1 - -#define HAVE_LOCALECONV 1 - -#define HAVE_LOCALE_H 1 - -/* Define if you have the setvbuf function. */ -#ifndef HAVE_LIBBIND -#define HAVE_SETVBUF 1 -#endif - -/* Define if you have the snprintf function. */ -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strdup function. */ -#define HAVE_STRDUP 1 - -/* Define if you have the strerror function. */ -#define HAVE_STRERROR 1 - -/* Define if you have the strstr function. */ -#define HAVE_STRSTR 1 - -/* Define if you have the tempnam function. */ -#define HAVE_TEMPNAM 1 - -/* Define if you have the utime function. */ -#define HAVE_UTIME 1 - -/* Define if you have the <dirent.h> header file. */ -#undef HAVE_DIRENT_H - -/* Define if you have the <fcntl.h> header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the <grp.h> header file. */ -#define HAVE_GRP_H 0 - -/* Define if you have the <pwd.h> header file. */ -#define HAVE_PWD_H 1 - -/* Define if you have the <string.h> header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the <sys/file.h> header file. */ -#undef HAVE_SYS_FILE_H - -/* Define if you have the <sys/socket.h> header file. */ -#undef HAVE_SYS_SOCKET_H - -/* Define if you have the <sys/wait.h> header file. */ -#undef HAVE_SYS_WAIT_H - -/* Define if you have the <syslog.h> header file. */ -#define HAVE_SYSLOG_H 1 - -/* Define if you have the <unistd.h> header file. */ -#undef HAVE_UNISTD_H - -/* Define if you have the dl library (-ldl). */ -#define HAVE_LIBDL 1 - -/* Define if you have the m library (-lm). */ -#define HAVE_LIBM 1 - -/* Define if you have the cuserid function. */ -#define HAVE_CUSERID 0 - -/* Define if you have the rint function. */ -#undef HAVE_RINT - -#define HAVE_STRFTIME 1 - -/* Default directory for loading extensions. */ -#define PHP_EXTENSION_DIR NULL - -#define SIZEOF_INT 4 - -/* Define directory constants for php and pear */ -#define PHP_BINDIR "c:\\php4" -#define PHP_LIBDIR "c:\\php4" -#define PHP_DATADIR "c:\\php4" -#define PHP_SYSCONFDIR "c:\\php4" -#define PHP_LOCALSTATEDIR "c:\\php4" -#define PHP_CONFIG_FILE_PATH "c:\\winnt" -#define PEAR_INSTALLDIR "c:\\php4\\pear" diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c deleted file mode 100644 index b283de1ea4..0000000000 --- a/main/fopen_wrappers.c +++ /dev/null @@ -1,647 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | - | Jim Winstead <jimw@php.net> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -/* {{{ includes - */ -#include "php.h" -#include "php_globals.h" -#include "SAPI.h" - -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#ifdef PHP_WIN32 -#include <windows.h> -#include <winsock.h> -#define O_RDONLY _O_RDONLY -#include "win32/param.h" -#else -#include <sys/param.h> -#endif - -#include "safe_mode.h" -#include "ext/standard/head.h" -#include "ext/standard/php_standard.h" -#include "zend_compile.h" -#include "php_network.h" - -#if HAVE_PWD_H -#ifdef PHP_WIN32 -#include "win32/pwd.h" -#else -#include <pwd.h> -#endif -#endif - -#include <sys/types.h> -#if HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif - -#ifndef S_ISREG -#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) -#endif - -#ifdef PHP_WIN32 -#include <winsock.h> -#else -#include <netinet/in.h> -#include <netdb.h> -#if HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#endif - -#ifdef PHP_WIN32 -#undef AF_UNIX -#endif - -#if defined(AF_UNIX) -#include <sys/un.h> -#endif -/* }}} */ - -static FILE *php_fopen_url_wrapper(const char *, char *, int, int *, int *, char ** TSRMLS_DC); -static HashTable fopen_url_wrappers_hash; - -/* {{{ php_register_url_wrapper - */ -PHPAPI int php_register_url_wrapper(const char *protocol, php_fopen_url_wrapper_t wrapper TSRMLS_DC) -{ - if(PG(allow_url_fopen)) { - return zend_hash_add(&fopen_url_wrappers_hash, (char *) protocol, strlen(protocol), &wrapper, sizeof(wrapper), NULL); - } else { - return FAILURE; - } -} -/* }}} */ - -/* {{{ php_unregister_url_wrapper - */ -PHPAPI int php_unregister_url_wrapper(char *protocol TSRMLS_DC) -{ - if(PG(allow_url_fopen)) { - return zend_hash_del(&fopen_url_wrappers_hash, protocol, strlen(protocol)); - } else { - return SUCCESS; - } -} -/* }}} */ - -/* {{{ php_init_fopen_wrappers - */ -int php_init_fopen_wrappers(TSRMLS_D) -{ - if(PG(allow_url_fopen)) { - return zend_hash_init(&fopen_url_wrappers_hash, 0, NULL, NULL, 1); - } - return SUCCESS; -} -/* }}} */ - -/* {{{ php_shutdown_fopen_wrappers - */ -int php_shutdown_fopen_wrappers(TSRMLS_D) -{ - if(PG(allow_url_fopen)) { - zend_hash_destroy(&fopen_url_wrappers_hash); - } - return SUCCESS; -} -/* }}} */ - -/* {{{ php_check_specific_open_basedir - When open_basedir is not NULL, check if the given filename is located in - open_basedir. Returns -1 if error or not in the open_basedir, else 0 - - When open_basedir is NULL, always return 0 -*/ -PHPAPI int php_check_specific_open_basedir(char *basedir, char *path TSRMLS_DC) -{ - char resolved_name[MAXPATHLEN]; - char resolved_basedir[MAXPATHLEN]; - char local_open_basedir[MAXPATHLEN]; - int local_open_basedir_pos; - - /* Special case basedir==".": Use script-directory */ - if ((strcmp(basedir, ".") == 0) && - SG(request_info).path_translated && - *SG(request_info).path_translated - ) { - strlcpy(local_open_basedir, SG(request_info).path_translated, sizeof(local_open_basedir)); - local_open_basedir_pos = strlen(local_open_basedir) - 1; - - /* Strip filename */ - while (!IS_SLASH(local_open_basedir[local_open_basedir_pos]) - && (local_open_basedir_pos >= 0)) { - local_open_basedir[local_open_basedir_pos--] = 0; - } - } else { - /* Else use the unmodified path */ - strlcpy(local_open_basedir, basedir, sizeof(local_open_basedir)); - } - - /* Resolve the real path into resolved_name */ - if ((expand_filepath(path, resolved_name TSRMLS_CC) != NULL) && (expand_filepath(local_open_basedir, resolved_basedir TSRMLS_CC) != NULL)) { - /* Check the path */ -#ifdef PHP_WIN32 - if (strncasecmp(resolved_basedir, resolved_name, strlen(resolved_basedir)) == 0) { -#else - if (strncmp(resolved_basedir, resolved_name, strlen(resolved_basedir)) == 0) { -#endif - /* File is in the right directory */ - return 0; - } else { - return -1; - } - } else { - /* Unable to resolve the real path, return -1 */ - return -1; - } -} -/* }}} */ - -/* {{{ php_check_open_basedir - */ -PHPAPI int php_check_open_basedir(char *path TSRMLS_DC) -{ - /* Only check when open_basedir is available */ - if (PG(open_basedir) && *PG(open_basedir)) { - char *pathbuf; - char *ptr; - char *end; - - pathbuf = estrdup(PG(open_basedir)); - - ptr = pathbuf; - - while (ptr && *ptr) { - end = strchr(ptr, DEFAULT_DIR_SEPARATOR); - if (end != NULL) { - *end = '\0'; - end++; - } - - if (php_check_specific_open_basedir(ptr, path TSRMLS_CC) == 0) { - efree(pathbuf); - return 0; - } - - ptr = end; - } - php_error(E_WARNING, "open_basedir restriction in effect. File is in wrong directory"); - efree(pathbuf); - errno = EPERM; /* we deny permission to open it */ - return -1; - } - - /* Nothing to check... */ - return 0; -} -/* }}} */ - -/* {{{ php_fopen_and_set_opened_path - */ -static FILE *php_fopen_and_set_opened_path(const char *path, char *mode, char **opened_path TSRMLS_DC) -{ - FILE *fp; - - if (php_check_open_basedir((char *)path TSRMLS_CC)) { - return NULL; - } - fp = VCWD_FOPEN(path, mode); - if (fp && opened_path) { - *opened_path = expand_filepath(path, NULL TSRMLS_CC); - } - return fp; -} -/* }}} */ - -/* {{{ php_fopen_wrapper - */ -PHPAPI FILE *php_fopen_wrapper(char *path, char *mode, int options, int *issock, int *socketd, char **opened_path TSRMLS_DC) -{ - if (opened_path) { - *opened_path = NULL; - } - - if(!path || !*path) { - return NULL; - } - - - if(PG(allow_url_fopen)) { - if (!(options & IGNORE_URL)) { - return php_fopen_url_wrapper(path, mode, options, issock, socketd, opened_path TSRMLS_CC); - } - } - - if (options & USE_PATH && PG(include_path) != NULL) { - return php_fopen_with_path(path, mode, PG(include_path), opened_path TSRMLS_CC); - } else { - if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!php_checkuid(path, mode, CHECKUID_CHECK_MODE_PARAM))) { - return NULL; - } - return php_fopen_and_set_opened_path(path, mode, opened_path TSRMLS_CC); - } -} -/* }}} */ - -/* {{{ php_fopen_primary_script - */ -PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC) -{ - FILE *fp; - struct stat st; - char *path_info, *filename; - int length; - - filename = SG(request_info).path_translated; - path_info = SG(request_info).request_uri; -#if HAVE_PWD_H - if (PG(user_dir) && *PG(user_dir) - && path_info && '/' == path_info[0] && '~' == path_info[1]) { - - char user[32]; - struct passwd *pw; - char *s = strchr(path_info + 2, '/'); - - filename = NULL; /* discard the original filename, it must not be used */ - if (s) { /* if there is no path name after the file, do not bother */ - /* to try open the directory */ - length = s - (path_info + 2); - if (length > sizeof(user) - 1) - length = sizeof(user) - 1; - memcpy(user, path_info + 2, length); - user[length] = '\0'; - - pw = getpwnam(user); - if (pw && pw->pw_dir) { - filename = emalloc(strlen(PG(user_dir)) + strlen(path_info) + strlen(pw->pw_dir) + 4); - if (filename) { - sprintf(filename, "%s%c%s%c%s", pw->pw_dir, PHP_DIR_SEPARATOR, - PG(user_dir), PHP_DIR_SEPARATOR, s+1); /* Safe */ - STR_FREE(SG(request_info).path_translated); - SG(request_info).path_translated = filename; - } - } - } - } else -#endif - if (PG(doc_root) && path_info) { - length = strlen(PG(doc_root)); - if (IS_ABSOLUTE_PATH(PG(doc_root), length)) { - filename = emalloc(length + strlen(path_info) + 2); - if (filename) { - memcpy(filename, PG(doc_root), length); - if (!IS_SLASH(filename[length - 1])) { /* length is never 0 */ - filename[length++] = PHP_DIR_SEPARATOR; - } - if (IS_SLASH(path_info[0])) { - length--; - } - strcpy(filename + length, path_info); - STR_FREE(SG(request_info).path_translated); - SG(request_info).path_translated = filename; - } - } - } /* if doc_root && path_info */ - - if (!filename) { - /* we have to free SG(request_info).path_translated here because - php_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(SG(request_info).path_translated); - SG(request_info).path_translated = NULL; - return FAILURE; - } - fp = VCWD_FOPEN(filename, "rb"); - - /* refuse to open anything that is not a regular file */ - if (fp && (0 > fstat(fileno(fp), &st) || !S_ISREG(st.st_mode))) { - fclose(fp); - fp = NULL; - } - if (!fp) { - php_error(E_ERROR, "Unable to open %s", filename); - STR_FREE(SG(request_info).path_translated); /* for same reason as above */ - return FAILURE; - } - - file_handle->opened_path = expand_filepath(filename, NULL TSRMLS_CC); - - if (!(SG(options) & SAPI_OPTION_NO_CHDIR)) { - VCWD_CHDIR_FILE(filename); - } - SG(request_info).path_translated = filename; - - file_handle->filename = SG(request_info).path_translated; - file_handle->free_filename = 0; - file_handle->handle.fp = fp; - file_handle->type = ZEND_HANDLE_FP; - - return SUCCESS; -} -/* }}} */ - -/* {{{ php_fopen_with_path - * Tries to open a file with a PATH-style list of directories. - * If the filename starts with "." or "/", the path is ignored. - */ -PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **opened_path TSRMLS_DC) -{ - char *pathbuf, *ptr, *end; - char *exec_fname; - char trypath[MAXPATHLEN]; - char trydir[MAXPATHLEN]; - char safe_mode_include_dir[MAXPATHLEN]; - struct stat sb; - FILE *fp; - int path_length; - int filename_length; - int safe_mode_include_dir_length; - int exec_fname_length; - - if (opened_path) { - *opened_path = NULL; - } - - if(!filename) { - return NULL; - } - - filename_length = strlen(filename); - - /* Relative path open */ - if (*filename == '.') { - if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) { - return NULL; - } - return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC); - } - - /* - * files in safe_mode_include_dir (or subdir) are excluded from - * safe mode GID/UID checks - */ - *safe_mode_include_dir = 0; - safe_mode_include_dir_length = 0; - if(PG(safe_mode_include_dir) && VCWD_REALPATH(PG(safe_mode_include_dir), safe_mode_include_dir)) { - safe_mode_include_dir_length = strlen(safe_mode_include_dir); - } - - /* Absolute path open */ - if (IS_ABSOLUTE_PATH(filename, filename_length)) { - /* Check to see if file is in safe_mode_include_dir (or subdir) */ - if (PG(safe_mode) && *safe_mode_include_dir && VCWD_REALPATH(filename, trypath)) { -#ifdef PHP_WIN32 - if (strncasecmp(safe_mode_include_dir, trypath, safe_mode_include_dir_length) == 0) -#else - if (strncmp(safe_mode_include_dir, trypath, safe_mode_include_dir_length) == 0) -#endif - { - /* absolute path matches safe_mode_include_dir */ - fp = php_fopen_and_set_opened_path(trypath, mode, opened_path TSRMLS_CC); - if (fp) { - return fp; - } - } - } - if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) { - return NULL; - } - return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC); - } - - if (!path || (path && !*path)) { - if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) { - return NULL; - } - return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC); - } - - /* check in provided path */ - /* append the calling scripts' current working directory - * as a fall back case - */ - if (zend_is_executing(TSRMLS_C)) { - exec_fname = zend_get_executed_filename(TSRMLS_C); - exec_fname_length = strlen(exec_fname); - path_length = strlen(path); - - while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])); - if ((exec_fname && exec_fname[0] == '[') - || exec_fname_length<=0) { - /* [no active file] or no path */ - pathbuf = estrdup(path); - } else { - pathbuf = (char *) emalloc(exec_fname_length + path_length +1 +1); - memcpy(pathbuf, path, path_length); - pathbuf[path_length] = DEFAULT_DIR_SEPARATOR; - memcpy(pathbuf+path_length+1, exec_fname, exec_fname_length); - pathbuf[path_length + exec_fname_length +1] = '\0'; - } - } else { - pathbuf = estrdup(path); - } - - ptr = pathbuf; - - while (ptr && *ptr) { - end = strchr(ptr, DEFAULT_DIR_SEPARATOR); - if (end != NULL) { - *end = '\0'; - end++; - } - snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename); - /* Check to see trypath is in safe_mode_include_dir (or subdir) */ - if (PG(safe_mode) && *safe_mode_include_dir && VCWD_REALPATH(trypath, trydir)) { -#ifdef PHP_WIN32 - if (strncasecmp(safe_mode_include_dir, trydir, safe_mode_include_dir_length) == 0) -#else - if (strncmp(safe_mode_include_dir, trydir, safe_mode_include_dir_length) == 0) -#endif - { - /* trypath is in safe_mode_include_dir */ - fp = php_fopen_and_set_opened_path(trydir, mode, opened_path TSRMLS_CC); - if (fp) { - efree(pathbuf); - return fp; - } - } - } - if (PG(safe_mode)) { - if (VCWD_STAT(trypath, &sb) == 0 && (!php_checkuid(trypath, mode, CHECKUID_CHECK_MODE_PARAM))) { - efree(pathbuf); - return NULL; - } - } - fp = php_fopen_and_set_opened_path(trypath, mode, opened_path TSRMLS_CC); - if (fp) { - efree(pathbuf); - return fp; - } - ptr = end; - } /* end provided path */ - - efree(pathbuf); - return NULL; -} -/* }}} */ - -/* {{{ php_fopen_url_wrapper - */ -static FILE *php_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path TSRMLS_DC) -{ - FILE *fp = NULL; - const char *p; - const char *protocol=NULL; - int n=0; - - for (p=path; isalnum((int)*p); p++) { - n++; - } - if ((*p==':')&&(n>1)) { - protocol=path; - } - - if (protocol) { - php_fopen_url_wrapper_t *wrapper=NULL; - - if (FAILURE==zend_hash_find(&fopen_url_wrappers_hash, (char *) protocol, n, (void **)&wrapper)) { - wrapper=NULL; - protocol=NULL; - } - if (wrapper) { - return (*wrapper)(path, mode, options, issock, socketd, opened_path TSRMLS_CC); - } - } - - if (!protocol || !strncasecmp(protocol, "file", n)){ - *issock = 0; - - if(protocol) { - if(path[n+1]=='/') { - if(path[n+2]=='/') { - php_error(E_WARNING, "remote host file access not supported, %s", path); - return NULL; - } - } - path+= n+1; - } - - if (options & USE_PATH) { - fp = php_fopen_with_path((char *) path, mode, PG(include_path), opened_path TSRMLS_CC); - } else { - if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!php_checkuid(path, mode, CHECKUID_CHECK_MODE_PARAM))) { - fp = NULL; - } else { - fp = php_fopen_and_set_opened_path(path, mode, opened_path TSRMLS_CC); - } - } - return (fp); - } - - php_error(E_WARNING, "Invalid URL specified, %s", path); - return NULL; -} -/* }}} */ - -/* {{{ php_strip_url_passwd - */ -PHPAPI char *php_strip_url_passwd(char *url) -{ - register char *p = url, *url_start; - - while (*p) { - if (*p==':' && *(p+1)=='/' && *(p+2)=='/') { - /* found protocol */ - url_start = p = p+3; - - while (*p) { - if (*p=='@') { - int i; - - for (i=0; i<3 && url_start<p; i++, url_start++) { - *url_start = '.'; - } - for (; *p; p++) { - *url_start++ = *p; - } - *url_start=0; - break; - } - p++; - } - return url; - } - p++; - } - return url; -} -/* }}} */ - -/* {{{ expand_filepath - */ -PHPAPI char *expand_filepath(const char *filepath, char *real_path TSRMLS_DC) -{ - cwd_state new_state; - char cwd[MAXPATHLEN]; - char *result; - - result = VCWD_GETCWD(cwd, MAXPATHLEN); - if (!result) { - cwd[0] = '\0'; - } - - new_state.cwd = strdup(cwd); - new_state.cwd_length = strlen(cwd); - - if(virtual_file_ex(&new_state, filepath, NULL)) { - free(new_state.cwd); - return NULL; - } - - if(real_path) { - int copy_len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length; - memcpy(real_path, new_state.cwd, copy_len); - real_path[copy_len]='\0'; - } else { - real_path = estrndup(new_state.cwd, new_state.cwd_length); - } - free(new_state.cwd); - - return real_path; -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h deleted file mode 100644 index b46b60f3b4..0000000000 --- a/main/fopen_wrappers.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Jim Winstead <jimw@php.net> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -#ifndef FOPEN_WRAPPERS_H -#define FOPEN_WRAPPERS_H - -#include "php_globals.h" - -#define IGNORE_PATH 0 -#define USE_PATH 1 -#define IGNORE_URL 2 -/* There's no USE_URL. */ -#ifdef PHP_WIN32 -# define IGNORE_URL_WIN 2 -#else -# define IGNORE_URL_WIN 0 -#endif -#define ENFORCE_SAFE_MODE 4 - -#ifdef PHP_WIN32 -# define SOCK_ERR INVALID_SOCKET -# define SOCK_CONN_ERR SOCKET_ERROR -# define SOCK_RECV_ERR SOCKET_ERROR -#else -# define SOCK_ERR -1 -# define SOCK_CONN_ERR -1 -# define SOCK_RECV_ERR -1 -#endif -#define SOCK_WRITE(d, s) send(s, d, strlen(d), 0) -#define SOCK_WRITEL(d, l, s) send(s, d, l, 0) -#define SOCK_FGETC(s) php_sock_fgetc((s)) -#define SOCK_FGETS(b, l, s) php_sock_fgets((b), (l), (s)) -#define SOCK_FEOF(sock) php_sock_feof((sock)) -#define SOCK_FREAD(ptr, size, sock) php_sock_fread((ptr), (size), (sock)) -#define SOCK_FCLOSE(s) php_sock_close(s) - -#define FP_FGETS(buf, len, sock, fp, issock) \ - ((issock)?SOCK_FGETS(buf, len, sock):fgets(buf, len, fp)) -#define FP_FREAD(buf, len, sock, fp, issock) \ - ((issock)?SOCK_FREAD(buf, len, sock):fread(buf, 1, len, fp)) -#define FP_FEOF(sock, fp, issock) \ - ((issock)?SOCK_FEOF(sock):feof(fp)) -#define FP_FGETC(sock, fp, issock) \ - ((issock)?SOCK_FGETC(sock):fgetc(fp)) - -/* values for issock */ -#define IS_NOT_SOCKET 0 -#define IS_SOCKET 1 -#define BAD_URL 2 - -typedef FILE *(*php_fopen_url_wrapper_t)(const char *, char *, int, int *, int *, char ** TSRMLS_DC); - -PHPAPI FILE *php_fopen_wrapper(char *filename, char *mode, int options, int *issock, int *socketd, char **opened_path TSRMLS_DC); - -PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC); -PHPAPI char *expand_filepath(const char *filepath, char *real_path TSRMLS_DC); - -PHPAPI int php_check_open_basedir(char *path TSRMLS_DC); -PHPAPI int php_check_specific_open_basedir(char *basedir, char *path TSRMLS_DC); - -PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **opened_path TSRMLS_DC); - -PHPAPI int php_is_url(char *path); -PHPAPI char *php_strip_url_passwd(char *path); - - -int php_init_fopen_wrappers(TSRMLS_D); -int php_shutdown_fopen_wrappers(TSRMLS_D); -PHPAPI int php_register_url_wrapper(const char *protocol, php_fopen_url_wrapper_t wrapper TSRMLS_DC); -PHPAPI int php_unregister_url_wrapper(char *protocol TSRMLS_DC); - -#endif -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/main/internal_functions.c.in b/main/internal_functions.c.in deleted file mode 100644 index 44a6a465a7..0000000000 --- a/main/internal_functions.c.in +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- C -*- - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Andi Gutmans <andi@zend.com> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ - */ - - -/* $Id$ */ - -#include "php.h" -#include "php_main.h" -#include "zend_modules.h" -#include "internal_functions_registry.h" -#include "zend_compile.h" -#include <stdarg.h> -#include <stdlib.h> -#include <stdio.h> - -@EXT_INCLUDE_CODE@ - -zend_module_entry *php_builtin_extensions[] = { -@EXT_MODULE_PTRS@ -}; - -#define EXTCOUNT (sizeof(php_builtin_extensions)/sizeof(zend_module_entry *)) - - -int php_startup_internal_extensions(void) -{ - return php_startup_extensions(php_builtin_extensions, EXTCOUNT); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/main/internal_functions_registry.h b/main/internal_functions_registry.h deleted file mode 100644 index 3cc68943dc..0000000000 --- a/main/internal_functions_registry.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Andi Gutmans <andi@zend.com> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ - */ - - -/* $Id$ */ - -#ifndef INTERNAL_FUNCTIONS_REGISTRY_H -#define INTERNAL_FUNCTIONS_REGISTRY_H - -extern int php_init_mime(INIT_FUNC_ARGS); - -/* environment functions */ -extern int php_init_environment(void); - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/main/internal_functions_win32.c b/main/internal_functions_win32.c deleted file mode 100644 index 11990c0d1a..0000000000 --- a/main/internal_functions_win32.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Andi Gutmans <andi@zend.com> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ - */ - - -/* $Id$ */ - -/* {{{ includes - */ -#include "php.h" -#include "php_main.h" -#include "zend_modules.h" -#include "internal_functions_registry.h" -#include "zend_compile.h" -#include <stdarg.h> -#include <stdlib.h> -#include <stdio.h> - -#include "ext/bcmath/php_bcmath.h" -#include "ext/db/php_db.h" -#include "ext/gd/php_gd.h" -#include "ext/standard/dl.h" -#include "ext/standard/file.h" -#include "ext/standard/fsock.h" -#include "ext/standard/head.h" -#include "ext/standard/pack.h" -#include "ext/standard/php_browscap.h" -#include "ext/standard/php_crypt.h" -#include "ext/standard/php_dir.h" -#include "ext/standard/php_filestat.h" -#include "ext/standard/php_mail.h" -#include "ext/standard/php_ext_syslog.h" -#include "ext/standard/php_standard.h" -#include "ext/standard/php_lcg.h" -#include "ext/standard/php_array.h" -#include "ext/standard/php_assert.h" -#include "ext/calendar/php_calendar.h" -#include "ext/com/php_COM.h" -#include "ext/com/php_VARIANT.h" -#include "ext/ftp/php_ftp.h" -#include "ext/standard/reg.h" -#include "ext/pcre/php_pcre.h" -#include "ext/odbc/php_odbc.h" -#include "ext/session/php_session.h" -#include "ext/xml/php_xml.h" -#include "ext/wddx/php_wddx.h" -#include "ext/mysql/php_mysql.h" -#include "ext/mbstring/mbstring.h" -/* }}} */ - -/* {{{ php_builtin_extensions[] - */ -zend_module_entry *php_builtin_extensions[] = { - phpext_standard_ptr, -#if WITH_BCMATH - phpext_bcmath_ptr, -#endif - phpext_calendar_ptr, - COM_module_ptr, - VARIANT_module_ptr, - phpext_ftp_ptr, -#if defined(MBSTR_ENC_TRANS) - phpext_mbstring_ptr, -#endif - phpext_mysql_ptr, - phpext_odbc_ptr, - phpext_pcre_ptr, - phpext_session_ptr, - phpext_xml_ptr, - phpext_wddx_ptr -}; -/* }}} */ - -#define EXTCOUNT (sizeof(php_builtin_extensions)/sizeof(zend_module_entry *)) - - -int php_startup_internal_extensions(void) -{ - return php_startup_extensions(php_builtin_extensions, EXTCOUNT); -} - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/logos.h b/main/logos.h deleted file mode 100644 index 428cf6dc90..0000000000 --- a/main/logos.h +++ /dev/null @@ -1,1059 +0,0 @@ -#define CONTEXT_TYPE_IMAGE_GIF "Content-Type: image/gif" - -unsigned char zend_logo[] = { - 71, 73, 70, 56, 57, 97, 100, 0, 58, 0, - 247, 255, 0, 255, 255, 255, 8, 8, 8, 24, - 24, 24, 57, 57, 57, 74, 74, 74, 90, 90, - 90, 99, 99, 99, 123, 123, 123, 132, 132, 132, - 140, 140, 140, 148, 148, 148, 189, 189, 189, 214, - 214, 214, 231, 231, 231, 239, 239, 239, 90, 99, - 99, 222, 231, 239, 57, 66, 74, 165, 173, 181, - 0, 8, 16, 214, 222, 231, 57, 66, 82, 16, - 33, 66, 0, 8, 24, 24, 41, 82, 222, 231, - 255, 57, 66, 90, 198, 206, 231, 181, 189, 214, - 99, 107, 132, 0, 8, 33, 189, 198, 231, 123, - 132, 165, 148, 165, 231, 123, 140, 206, 123, 148, - 239, 49, 66, 132, 24, 33, 66, 49, 74, 165, - 214, 222, 255, 206, 214, 247, 181, 189, 222, 148, - 156, 189, 123, 132, 173, 156, 173, 247, 132, 148, - 214, 99, 115, 181, 49, 57, 90, 41, 49, 82, - 90, 107, 181, 82, 99, 173, 24, 33, 74, 57, - 82, 189, 49, 74, 173, 16, 24, 57, 8, 16, - 49, 198, 206, 247, 181, 189, 231, 165, 173, 214, - 99, 107, 148, 74, 82, 123, 140, 156, 239, 66, - 74, 115, 115, 132, 222, 41, 49, 90, 57, 74, - 165, 49, 66, 148, 49, 66, 156, 41, 57, 140, - 57, 82, 206, 33, 49, 123, 57, 82, 214, 16, - 24, 66, 198, 206, 255, 181, 189, 239, 189, 198, - 255, 156, 165, 214, 140, 148, 198, 132, 140, 189, - 115, 123, 173, 90, 99, 148, 132, 148, 247, 123, - 140, 239, 107, 123, 214, 115, 132, 231, 57, 66, - 115, 107, 123, 222, 115, 132, 239, 57, 66, 123, - 99, 115, 214, 90, 107, 214, 74, 90, 181, 74, - 90, 189, 66, 82, 173, 57, 74, 173, 49, 66, - 165, 66, 90, 231, 49, 66, 173, 24, 33, 90, - 41, 57, 156, 33, 49, 140, 8, 16, 66, 181, - 189, 247, 165, 173, 231, 148, 156, 214, 132, 140, - 198, 115, 123, 181, 82, 90, 148, 49, 57, 115, - 99, 115, 231, 90, 107, 231, 82, 99, 214, 82, - 99, 222, 74, 90, 206, 82, 99, 231, 66, 82, - 189, 33, 41, 99, 57, 74, 189, 57, 74, 198, - 57, 74, 206, 49, 66, 181, 41, 57, 165, 24, - 33, 99, 16, 24, 82, 8, 16, 74, 173, 181, - 247, 173, 181, 255, 165, 173, 247, 140, 148, 214, - 156, 165, 239, 165, 173, 255, 156, 165, 247, 132, - 140, 214, 140, 148, 231, 99, 107, 173, 107, 115, - 189, 115, 123, 206, 123, 132, 222, 99, 107, 189, - 82, 90, 165, 90, 99, 181, 74, 82, 156, 82, - 90, 173, 90, 99, 189, 66, 74, 140, 57, 66, - 140, 57, 66, 148, 41, 49, 115, 74, 90, 222, - 74, 90, 231, 41, 49, 132, 66, 82, 222, 33, - 41, 115, 33, 41, 123, 24, 33, 107, 24, 33, - 123, 16, 24, 90, 148, 156, 247, 140, 148, 239, - 132, 140, 231, 140, 148, 247, 132, 140, 239, 123, - 132, 231, 107, 115, 206, 123, 132, 239, 123, 132, - 247, 99, 107, 206, 99, 107, 214, 82, 90, 181, - 90, 99, 206, 49, 57, 148, 41, 49, 148, 33, - 41, 140, 239, 239, 247, 247, 247, 255, 198, 198, - 206, 214, 214, 222, 173, 173, 181, 189, 189, 198, - 148, 148, 156, 156, 156, 165, 231, 231, 247, 239, - 239, 255, 173, 173, 189, 90, 90, 99, 231, 231, - 255, 222, 222, 247, 140, 140, 156, 66, 66, 74, - 132, 132, 148, 198, 198, 222, 123, 123, 140, 173, - 173, 198, 107, 107, 123, 222, 222, 255, 57, 57, - 66, 49, 49, 57, 156, 156, 181, 198, 198, 231, - 140, 140, 165, 181, 181, 214, 90, 90, 107, 214, - 214, 255, 165, 165, 198, 82, 82, 99, 123, 123, - 148, 74, 74, 90, 115, 115, 140, 33, 33, 41, - 99, 99, 123, 156, 156, 198, 90, 90, 115, 132, - 132, 173, 173, 173, 231, 165, 165, 222, 24, 24, - 33, 82, 82, 115, 156, 156, 222, 115, 115, 165, - 57, 57, 82, 107, 107, 156, 123, 123, 181, 33, - 33, 49, 156, 156, 231, 82, 82, 123, 49, 49, - 74, 107, 107, 165, 74, 74, 115, 148, 148, 231, - 57, 57, 90, 41, 41, 66, 82, 82, 132, 66, - 66, 107, 132, 132, 214, 140, 140, 231, 99, 99, - 165, 123, 123, 206, 66, 66, 115, 82, 82, 148, - 123, 123, 222, 66, 66, 123, 8, 8, 16, 41, - 41, 82, 49, 49, 99, 24, 24, 49, 41, 41, - 90, 24, 24, 66, 8, 8, 24, 16, 16, 57, - 8, 8, 41, 8, 8, 49, 8, 8, 57, 0, - 0, 8, 0, 0, 16, 0, 0, 24, 0, 0, - 0, 44, 0, 0, 0, 0, 100, 0, 58, 0, - 0, 8, 255, 0, 255, 9, 28, 72, 176, 160, - 193, 131, 8, 19, 42, 92, 200, 176, 161, 195, - 135, 188, 146, 37, 131, 246, 176, 226, 193, 94, - 188, 10, 6, 203, 104, 177, 99, 67, 99, 31, - 140, 25, 75, 230, 177, 227, 200, 130, 39, 75, - 170, 60, 104, 12, 87, 128, 103, 198, 40, 174, - 108, 248, 1, 87, 193, 154, 51, 115, 10, 52, - 198, 236, 31, 175, 15, 196, 124, 246, 58, 150, - 17, 227, 203, 0, 2, 122, 9, 240, 121, 140, - 232, 191, 94, 201, 130, 57, 229, 213, 148, 227, - 63, 103, 199, 96, 218, 36, 104, 172, 89, 47, - 140, 2, 159, 57, 19, 232, 236, 153, 206, 143, - 199, 130, 33, 43, 118, 213, 216, 50, 96, 31, - 4, 24, 139, 230, 204, 152, 179, 100, 198, 4, - 240, 50, 166, 2, 88, 76, 144, 200, 144, 17, - 53, 86, 12, 46, 69, 188, 133, 113, 114, 229, - 11, 55, 104, 49, 14, 1, 226, 113, 56, 118, - 150, 33, 72, 99, 207, 2, 252, 3, 70, 249, - 222, 200, 98, 199, 122, 141, 236, 165, 226, 159, - 138, 98, 206, 150, 113, 240, 92, 44, 192, 215, - 211, 169, 145, 45, 93, 214, 235, 95, 128, 148, - 3, 63, 4, 179, 13, 172, 54, 177, 145, 184, - 140, 5, 173, 172, 176, 37, 87, 146, 255, 70, - 23, 251, 0, 90, 119, 114, 99, 28, 158, 45, - 197, 45, 50, 250, 210, 228, 200, 21, 15, 52, - 254, 175, 169, 192, 99, 129, 41, 19, 255, 231, - 103, 142, 31, 203, 158, 3, 139, 45, 227, 5, - 19, 26, 94, 96, 204, 66, 82, 124, 187, 173, - 236, 94, 244, 255, 150, 173, 103, 159, 177, 24, - 178, 8, 120, 225, 183, 211, 49, 196, 224, 149, - 76, 63, 252, 252, 6, 212, 66, 252, 152, 87, - 145, 57, 30, 176, 132, 156, 64, 208, 112, 0, - 82, 52, 255, 64, 163, 155, 0, 31, 44, 67, - 33, 50, 74, 228, 128, 12, 52, 184, 85, 8, - 24, 69, 208, 32, 35, 18, 78, 14, 254, 19, - 82, 72, 102, 245, 211, 207, 63, 130, 49, 56, - 163, 69, 48, 208, 115, 16, 52, 154, 17, 20, - 0, 49, 215, 253, 131, 75, 60, 255, 108, 227, - 141, 64, 252, 208, 163, 193, 112, 60, 22, 68, - 204, 112, 3, 17, 3, 141, 0, 68, 182, 56, - 37, 49, 247, 8, 116, 207, 5, 117, 89, 117, - 80, 63, 19, 180, 248, 144, 61, 230, 204, 196, - 15, 130, 252, 120, 83, 130, 152, 30, 177, 57, - 80, 63, 30, 168, 224, 97, 66, 112, 186, 217, - 208, 61, 224, 220, 168, 210, 4, 253, 204, 80, - 142, 78, 13, 30, 196, 143, 7, 214, 96, 67, - 103, 62, 122, 90, 196, 79, 59, 24, 204, 212, - 79, 60, 232, 228, 3, 168, 157, 255, 240, 147, - 143, 62, 148, 122, 224, 1, 165, 13, 149, 160, - 205, 13, 156, 50, 228, 79, 62, 80, 72, 170, - 83, 162, 5, 121, 80, 70, 62, 108, 242, 51, - 65, 62, 155, 170, 255, 212, 15, 15, 226, 220, - 224, 15, 159, 97, 226, 10, 230, 174, 97, 54, - 24, 232, 160, 85, 156, 147, 37, 160, 168, 34, - 233, 1, 31, 248, 120, 208, 107, 131, 23, 232, - 147, 44, 167, 215, 228, 115, 77, 177, 72, 222, - 144, 134, 19, 24, 224, 3, 171, 7, 247, 116, - 219, 45, 183, 223, 198, 19, 79, 0, 174, 246, - 67, 135, 33, 166, 2, 122, 129, 160, 249, 240, - 177, 71, 62, 247, 140, 27, 192, 61, 250, 240, - 161, 15, 181, 3, 221, 67, 79, 56, 229, 192, - 96, 14, 168, 3, 241, 19, 128, 7, 108, 4, - 98, 141, 59, 24, 216, 99, 195, 194, 12, 51, - 76, 15, 61, 210, 114, 235, 129, 61, 46, 208, - 17, 79, 168, 22, 249, 211, 42, 63, 55, 136, - 161, 7, 18, 55, 72, 124, 195, 30, 72, 196, - 202, 96, 60, 54, 148, 179, 195, 57, 155, 186, - 26, 207, 61, 54, 72, 130, 130, 25, 138, 68, - 194, 198, 36, 56, 231, 140, 51, 29, 98, 204, - 96, 129, 13, 244, 76, 130, 134, 17, 218, 226, - 235, 209, 5, 254, 20, 196, 207, 61, 248, 232, - 145, 137, 30, 51, 148, 64, 143, 13, 30, 235, - 67, 228, 67, 150, 142, 115, 142, 61, 19, 220, - 35, 173, 13, 108, 120, 146, 203, 18, 158, 88, - 49, 69, 22, 103, 79, 113, 202, 217, 169, 116, - 65, 2, 29, 116, 44, 242, 13, 36, 249, 228, - 179, 79, 62, 73, 43, 250, 101, 132, 72, 242, - 255, 19, 143, 7, 72, 104, 194, 10, 17, 152, - 96, 48, 131, 38, 152, 204, 224, 193, 197, 21, - 45, 61, 79, 19, 240, 212, 51, 3, 6, 24, - 24, 241, 67, 18, 174, 228, 146, 196, 18, 156, - 115, 190, 249, 18, 130, 128, 194, 69, 23, 228, - 152, 33, 9, 61, 209, 210, 83, 198, 13, 23, - 152, 23, 232, 5, 30, 92, 19, 175, 140, 247, - 132, 121, 177, 157, 253, 232, 179, 110, 131, 127, - 95, 51, 3, 38, 171, 124, 177, 138, 17, 70, - 168, 66, 7, 62, 215, 244, 26, 112, 131, 50, - 226, 126, 13, 36, 213, 144, 19, 131, 36, 108, - 64, 50, 133, 31, 185, 0, 0, 128, 43, 220, - 111, 207, 125, 230, 126, 72, 177, 4, 14, 93, - 248, 140, 4, 29, 152, 32, 206, 70, 21, 243, - 200, 83, 78, 57, 219, 208, 115, 65, 60, 176, - 75, 235, 79, 188, 189, 146, 75, 16, 63, 251, - 232, 115, 143, 223, 250, 154, 129, 24, 44, 49, - 4, 46, 60, 162, 17, 142, 24, 67, 61, 44, - 128, 4, 120, 45, 235, 76, 19, 208, 212, 176, - 12, 210, 143, 124, 96, 33, 16, 56, 240, 132, - 41, 136, 113, 13, 1, 64, 163, 131, 83, 10, - 161, 7, 71, 8, 141, 10, 173, 65, 18, 139, - 64, 68, 54, 190, 145, 142, 67, 24, 129, 14, - 51, 136, 161, 13, 22, 39, 174, 111, 105, 10, - 92, 241, 242, 155, 175, 252, 182, 15, 36, 220, - 205, 3, 55, 176, 128, 24, 255, 38, 65, 132, - 24, 112, 224, 131, 196, 88, 132, 17, 48, 161, - 135, 61, 36, 235, 30, 254, 64, 218, 61, 36, - 72, 169, 165, 221, 192, 29, 223, 80, 70, 18, - 130, 212, 144, 3, 228, 226, 15, 102, 248, 195, - 33, 26, 177, 10, 34, 104, 98, 6, 72, 128, - 88, 180, 174, 113, 13, 77, 229, 227, 6, 55, - 88, 216, 195, 110, 208, 70, 111, 141, 235, 101, - 251, 224, 4, 39, 98, 136, 129, 122, 16, 81, - 8, 136, 128, 133, 102, 4, 16, 131, 49, 172, - 34, 19, 154, 216, 195, 221, 46, 85, 55, 88, - 5, 74, 80, 241, 200, 135, 5, 136, 48, 133, - 36, 200, 164, 33, 3, 112, 133, 45, 146, 48, - 10, 35, 120, 12, 19, 155, 96, 162, 24, 12, - 103, 1, 123, 32, 97, 97, 37, 40, 193, 228, - 48, 48, 202, 61, 76, 78, 106, 106, 236, 86, - 62, 108, 160, 7, 77, 100, 2, 19, 153, 176, - 4, 17, 134, 16, 132, 64, 106, 230, 26, 169, - 192, 195, 42, 44, 161, 9, 78, 32, 161, 12, - 251, 184, 193, 182, 254, 87, 197, 8, 218, 0, - 3, 68, 24, 197, 53, 4, 114, 0, 90, 40, - 64, 1, 214, 196, 102, 2, 122, 244, 143, 5, - 0, 224, 15, 93, 152, 68, 61, 244, 64, 7, - 75, 144, 161, 140, 150, 120, 33, 220, 198, 57, - 78, 244, 101, 194, 8, 233, 92, 34, 220, 48, - 144, 74, 160, 77, 13, 3, 182, 36, 3, 17, - 86, 49, 255, 134, 47, 212, 160, 14, 63, 16, - 228, 63, 4, 144, 5, 47, 172, 130, 137, 122, - 68, 22, 188, 186, 165, 49, 133, 136, 139, 30, - 208, 252, 196, 117, 24, 160, 73, 87, 120, 15, - 0, 10, 24, 72, 1, 0, 224, 135, 57, 168, - 179, 156, 252, 12, 131, 72, 195, 96, 130, 49, - 8, 65, 8, 68, 72, 233, 42, 134, 240, 133, - 48, 124, 1, 15, 97, 168, 193, 23, 136, 96, - 137, 121, 174, 18, 19, 68, 24, 67, 30, 90, - 234, 133, 158, 210, 32, 160, 154, 129, 70, 22, - 194, 64, 4, 158, 113, 130, 100, 250, 192, 155, - 140, 16, 148, 16, 129, 121, 109, 18, 159, 176, - 69, 1, 8, 64, 0, 6, 36, 193, 15, 75, - 224, 158, 50, 100, 209, 35, 1, 52, 64, 25, - 169, 136, 196, 11, 49, 161, 203, 49, 132, 1, - 15, 115, 136, 195, 35, 82, 193, 5, 60, 224, - 161, 167, 117, 240, 66, 29, 236, 96, 135, 59, - 164, 53, 21, 143, 216, 66, 35, 134, 64, 4, - 156, 97, 2, 158, 121, 16, 41, 30, 234, 192, - 133, 84, 164, 226, 13, 63, 104, 192, 32, 181, - 16, 6, 98, 138, 225, 168, 253, 83, 214, 163, - 152, 218, 212, 123, 148, 128, 17, 202, 88, 2, - 10, 114, 193, 89, 63, 68, 97, 9, 0, 56, - 65, 18, 134, 49, 16, 90, 184, 226, 10, 38, - 176, 4, 206, 140, 144, 83, 19, 112, 225, 16, - 211, 136, 192, 147, 152, 241, 4, 45, 255, 20, - 225, 8, 69, 200, 130, 26, 180, 112, 132, 31, - 104, 195, 25, 79, 170, 64, 52, 92, 224, 5, - 33, 68, 66, 8, 47, 29, 108, 29, 70, 225, - 4, 102, 12, 131, 24, 195, 152, 70, 44, 130, - 154, 133, 47, 212, 84, 12, 123, 80, 100, 200, - 226, 209, 60, 78, 249, 45, 31, 116, 168, 6, - 14, 78, 225, 136, 69, 40, 34, 11, 109, 16, - 196, 38, 205, 48, 139, 129, 16, 0, 0, 102, - 224, 66, 95, 233, 48, 9, 18, 32, 247, 17, - 29, 224, 162, 64, 152, 33, 2, 74, 180, 161, - 25, 241, 56, 70, 19, 6, 96, 16, 1, 116, - 96, 11, 255, 164, 171, 29, 226, 192, 4, 3, - 112, 83, 32, 93, 29, 170, 37, 244, 128, 93, - 146, 193, 138, 187, 143, 106, 230, 196, 214, 144, - 132, 63, 160, 226, 164, 65, 208, 130, 25, 132, - 225, 7, 65, 80, 96, 154, 3, 109, 64, 46, - 74, 225, 5, 44, 76, 130, 172, 95, 152, 67, - 58, 182, 114, 16, 98, 84, 163, 52, 182, 185, - 218, 65, 162, 17, 135, 34, 220, 246, 13, 41, - 240, 146, 65, 160, 97, 138, 26, 212, 116, 15, - 144, 213, 135, 7, 118, 69, 89, 131, 44, 45, - 31, 51, 88, 135, 25, 112, 80, 8, 68, 168, - 227, 15, 73, 232, 195, 21, 212, 107, 128, 129, - 40, 0, 0, 75, 40, 69, 28, 186, 16, 132, - 71, 152, 226, 19, 228, 216, 141, 64, 226, 97, - 128, 4, 32, 32, 255, 40, 1, 136, 5, 10, - 40, 64, 128, 130, 16, 32, 1, 9, 192, 15, - 63, 156, 112, 132, 75, 196, 161, 15, 248, 129, - 70, 48, 20, 16, 140, 32, 9, 64, 11, 214, - 213, 68, 133, 241, 161, 100, 127, 112, 247, 145, - 78, 134, 147, 13, 230, 97, 8, 52, 152, 193, - 12, 125, 72, 135, 35, 226, 224, 7, 87, 112, - 85, 32, 196, 216, 222, 85, 253, 208, 135, 68, - 252, 128, 173, 77, 232, 17, 47, 24, 144, 1, - 205, 66, 160, 154, 56, 176, 130, 39, 40, 64, - 96, 219, 208, 98, 108, 56, 104, 197, 116, 5, - 130, 11, 55, 92, 34, 20, 18, 24, 136, 1, - 40, 176, 1, 28, 216, 162, 1, 5, 160, 144, - 41, 172, 107, 84, 69, 42, 25, 195, 77, 118, - 114, 0, 250, 225, 53, 123, 204, 67, 156, 154, - 216, 130, 25, 92, 161, 139, 225, 4, 224, 21, - 218, 115, 69, 6, 250, 112, 138, 26, 212, 128, - 6, 90, 232, 242, 63, 136, 225, 128, 64, 248, - 186, 18, 159, 64, 1, 14, 220, 0, 6, 48, - 4, 130, 22, 2, 33, 192, 18, 172, 64, 137, - 74, 80, 1, 5, 25, 29, 168, 40, 42, 145, - 3, 153, 48, 99, 3, 87, 168, 4, 37, 172, - 128, 3, 197, 14, 84, 194, 154, 192, 64, 118, - 35, 203, 221, 71, 51, 200, 101, 23, 160, 135, - 17, 216, 161, 12, 205, 97, 72, 32, 193, 8, - 119, 18, 72, 81, 4, 185, 114, 193, 20, 104, - 255, 144, 137, 2, 62, 144, 182, 44, 200, 65, - 14, 112, 0, 195, 37, 46, 209, 134, 93, 228, - 91, 20, 245, 190, 4, 37, 164, 0, 129, 171, - 165, 193, 10, 183, 128, 48, 7, 124, 61, 243, - 75, 80, 129, 2, 65, 77, 69, 99, 233, 128, - 100, 39, 42, 121, 169, 209, 174, 108, 61, 92, - 96, 134, 19, 152, 161, 19, 77, 24, 136, 0, - 28, 224, 10, 18, 183, 129, 176, 113, 240, 47, - 1, 184, 25, 128, 178, 151, 29, 26, 33, 184, - 132, 204, 213, 238, 6, 155, 255, 131, 0, 35, - 152, 121, 191, 229, 128, 130, 90, 175, 96, 4, - 1, 231, 69, 40, 212, 206, 247, 43, 8, 84, - 0, 203, 46, 234, 99, 157, 173, 172, 71, 99, - 140, 31, 54, 192, 130, 33, 206, 144, 229, 40, - 148, 34, 10, 164, 21, 72, 44, 92, 177, 132, - 78, 148, 66, 10, 140, 95, 66, 20, 164, 32, - 100, 130, 8, 160, 26, 107, 151, 121, 27, 18, - 144, 111, 82, 168, 93, 230, 149, 88, 66, 157, - 255, 177, 130, 30, 32, 64, 32, 5, 104, 131, - 204, 103, 47, 10, 129, 10, 245, 11, 47, 60, - 234, 30, 86, 181, 56, 4, 69, 189, 32, 253, - 192, 64, 19, 86, 152, 142, 31, 156, 162, 13, - 109, 216, 129, 123, 1, 96, 11, 206, 157, 64, - 24, 202, 16, 134, 43, 146, 16, 138, 206, 107, - 253, 12, 106, 127, 185, 27, 174, 224, 118, 2, - 72, 129, 18, 148, 224, 187, 255, 18, 86, 223, - 122, 210, 251, 196, 215, 179, 55, 250, 223, 171, - 251, 194, 236, 42, 116, 201, 221, 69, 72, 60, - 110, 0, 133, 38, 184, 163, 10, 144, 112, 196, - 90, 219, 160, 142, 235, 4, 128, 1, 218, 195, - 124, 87, 245, 7, 125, 80, 11, 40, 16, 10, - 178, 16, 11, 215, 129, 0, 177, 208, 128, 177, - 176, 0, 125, 32, 7, 200, 87, 9, 96, 208, - 118, 55, 151, 126, 151, 96, 6, 228, 23, 10, - 177, 32, 16, 2, 240, 3, 51, 71, 123, 72, - 55, 80, 169, 48, 4, 158, 52, 3, 72, 197, - 45, 59, 36, 40, 212, 118, 14, 58, 208, 14, - 51, 80, 5, 141, 176, 127, 165, 128, 31, 8, - 176, 61, 2, 120, 2, 182, 80, 104, 2, 32, - 1, 161, 48, 2, 102, 160, 110, 5, 96, 117, - 75, 96, 6, 75, 48, 8, 161, 112, 5, 107, - 87, 115, 249, 38, 5, 124, 167, 118, 26, 40, - 16, 43, 112, 116, 87, 19, 13, 49, 199, 119, - 84, 0, 1, 65, 245, 8, 145, 64, 7, 24, - 128, 4, 72, 160, 100, 247, 64, 89, 110, 194, - 60, 215, 112, 14, 213, 176, 14, 238, 112, 8, - 234, 224, 9, 81, 48, 8, 108, 145, 111, 1, - 200, 124, 39, 160, 61, 201, 246, 15, 180, 48, - 8, 143, 183, 0, 3, 17, 12, 74, 112, 5, - 110, 208, 6, 82, 64, 13, 221, 32, 7, 106, - 55, 122, 55, 87, 116, 50, 55, 126, 2, 65, - 13, 116, 255, 103, 126, 252, 176, 3, 68, 39, - 7, 103, 96, 126, 132, 100, 4, 245, 128, 4, - 140, 54, 134, 190, 98, 35, 55, 240, 4, 214, - 128, 3, 40, 160, 12, 186, 32, 12, 181, 112, - 73, 4, 16, 12, 6, 160, 138, 170, 184, 138, - 50, 113, 107, 202, 208, 113, 119, 248, 15, 222, - 16, 12, 218, 192, 13, 117, 22, 15, 210, 0, - 7, 151, 96, 129, 111, 39, 10, 69, 167, 118, - 125, 176, 122, 212, 112, 9, 61, 208, 10, 80, - 18, 1, 59, 0, 2, 191, 16, 121, 235, 22, - 3, 147, 48, 3, 16, 83, 59, 24, 179, 63, - 150, 50, 3, 88, 224, 8, 136, 64, 8, 133, - 208, 1, 21, 65, 11, 39, 240, 7, 161, 240, - 9, 27, 0, 37, 67, 150, 13, 148, 160, 5, - 110, 199, 11, 137, 64, 87, 113, 112, 4, 71, - 16, 133, 255, 0, 2, 151, 0, 7, 31, 240, - 10, 250, 69, 16, 241, 80, 12, 93, 128, 9, - 22, 32, 59, 58, 134, 53, 93, 51, 75, 208, - 164, 6, 22, 65, 11, 61, 64, 3, 65, 16, - 4, 34, 192, 0, 2, 18, 37, 177, 240, 1, - 71, 160, 5, 181, 241, 15, 3, 128, 8, 38, - 240, 79, 62, 86, 13, 28, 1, 2, 240, 152, - 5, 186, 240, 10, 181, 86, 16, 188, 32, 11, - 136, 144, 7, 116, 80, 2, 139, 83, 141, 144, - 228, 1, 244, 64, 2, 128, 48, 11, 5, 96, - 0, 52, 89, 147, 54, 121, 147, 6, 255, 240, - 10, 202, 176, 5, 186, 20, 4, 236, 0, 1, - 177, 96, 0, 3, 80, 66, 5, 64, 11, 13, - 144, 3, 169, 96, 7, 169, 112, 11, 52, 169, - 0, 79, 112, 92, 95, 48, 87, 57, 160, 0, - 52, 169, 2, 115, 32, 87, 89, 176, 1, 174, - 64, 11, 5, 80, 66, 196, 96, 0, 177, 224, - 11, 46, 96, 72, 116, 64, 15, 226, 194, 146, - 210, 70, 15, 144, 208, 7, 228, 160, 3, 27, - 176, 89, 22, 53, 135, 114, 201, 124, 40, 96, - 12, 56, 96, 6, 142, 64, 7, 36, 176, 10, - 143, 144, 13, 40, 160, 11, 181, 80, 11, 20, - 128, 12, 135, 16, 4, 66, 96, 2, 142, 160, - 3, 190, 224, 11, 28, 176, 6, 116, 0, 79, - 253, 36, 2, 34, 97, 12, 78, 32, 4, 67, - 160, 10, 95, 208, 5, 45, 240, 1, 186, 208, - 10, 181, 0, 1, 41, 224, 4, 144, 128, 9, - 100, 165, 7, 55, 240, 63, 109, 130, 50, 139, - 96, 6, 139, 128, 1, 147, 224, 8, 160, 160, - 12, 182, 240, 61, 180, 201, 61, 182, 144, 1, - 127, 224, 8, 70, 32, 4, 132, 240, 7, 144, - 128, 62, 171, 144, 7, 93, 32, 3, 50, 208, - 8, 238, 96, 4, 171, 69, 60, 150, 224, 98, - 243, 64, 7, 64, 0, 55, 172, 69, 4, 40, - 133, 5, 99, 5, 79, 252, 20, 4, 142, 32, - 3, 139, 224, 14, 108, 0, 55, 64, 32, 6, - 233, 211, 64, 97, 255, 98, 17, 55, 48, 15, - 238, 128, 6, 235, 80, 15, 11, 83, 15, 143, - 96, 6, 185, 96, 11, 39, 16, 139, 242, 41, - 159, 89, 150, 8, 150, 16, 53, 24, 192, 8, - 103, 208, 8, 191, 179, 10, 100, 80, 83, 60, - 83, 15, 125, 36, 6, 236, 100, 56, 62, 19, - 67, 98, 0, 55, 152, 96, 83, 148, 163, 160, - 240, 4, 160, 134, 83, 2, 63, 3, 134, 217, - 85, 50, 104, 249, 15, 254, 160, 50, 220, 32, - 14, 24, 112, 49, 94, 35, 6, 138, 176, 4, - 154, 131, 105, 127, 80, 162, 38, 90, 162, 234, - 208, 8, 245, 0, 49, 249, 80, 2, 144, 32, - 2, 104, 132, 75, 122, 64, 74, 11, 99, 1, - 22, 16, 67, 104, 36, 71, 83, 131, 4, 172, - 68, 97, 72, 160, 48, 54, 96, 74, 24, 64, - 78, 154, 64, 97, 51, 0, 52, 209, 178, 45, - 30, 160, 15, 145, 197, 146, 23, 80, 14, 47, - 176, 80, 174, 243, 55, 245, 128, 8, 162, 24, - 8, 228, 64, 8, 234, 176, 165, 92, 170, 14, - 233, 192, 8, 147, 176, 15, 220, 34, 46, 30, - 0, 15, 80, 128, 15, 72, 160, 7, 31, 3, - 71, 215, 160, 76, 55, 128, 15, 101, 112, 74, - 110, 250, 166, 72, 224, 46, 21, 10, 71, 116, - 138, 100, 106, 42, 6, 167, - 4, 43, 221, 34, 47, 211, 6, 68, 254, 131, - 49, 247, 16, 14, 124, 179, 63, 3, 83, 15, - 104, 128, 2, 214, 255, 192, 14, 134, 96, 8, - 235, 16, 169, 146, 186, 14, 80, 128, 14, 42, - 121, 150, 126, 131, 15, 162, 89, 167, 198, 164, - 76, 117, 3, 71, 61, 84, 6, 248, 0, 71, - 111, 116, 3, 117, 154, 93, 36, 163, 45, 111, - 234, 46, 122, 164, 71, 32, 67, 67, 191, 34, - 16, 21, 148, 44, 191, 151, 47, 244, 80, 69, - 247, 0, 5, 74, 144, 6, 231, 208, 14, 47, - 80, 15, 47, 48, 15, 47, 16, 172, 243, 32, - 172, 51, 112, 154, 14, 226, 58, 248, 0, 5, - 108, 80, 161, 154, 114, 1, 223, 114, 41, 73, - 245, 172, 83, 84, 55, 76, 250, 67, 83, 228, - 1, 118, 83, 167, 238, 210, 64, 204, 116, 16, - 23, 208, 72, 173, 243, 37, 183, 218, 84, 51, - 224, 4, 91, 211, 72, 55, 36, 65, 235, 106, - 113, 4, 209, 15, 123, 224, 14, 98, 128, 55, - 227, 178, 67, 13, 18, 38, 228, 66, 46, 190, - 18, 15, 19, 96, 120, 2, 243, 40, 110, 196, - 45, 70, 83, 41, 174, 114, 63, 13, 165, 143, - 215, 16, 42, 30, 176, 3, 232, 176, 146, 249, - 154, 175, 13, 82, 118, 2, 3, 105, 111, 178, - 15, 108, 208, 14, 172, 210, 56, 149, 34, 40, - 145, 193, 93, 88, 179, 52, 209, 54, 176, 2, - 33, 15, 207, 224, 1, 250, 170, 52, 27, 203, - 32, 118, 99, 3, 225, 144, 46, 57, 225, 58, - 23, 138, 36, 227, 137, 53, 227, 240, 2, 140, - 61, 163, 18, 131, 146, 15, 220, 229, 13, 19, - 100, 38, 20, 139, 53, 34, 171, 52, 224, 80, - 14, 181, 90, 17, 21, 212, 58, 253, 48, 45, - 47, 187, 130, 29, 241, 179, 10, 193, 15, 225, - 16, 14, 183, 131, 36, 109, 2, 173, 14, 114, - 179, 12, 225, 58, 78, 102, 175, 109, 226, 32, - 1, 1, 0, 59 }; - -unsigned char php_logo[] = { - 71, 73, 70, 56, 57, 97, 130, 0, 67, 0, - 213, 255, 0, 0, 0, 0, 48, 47, 49, 2, - 2, 3, 7, 7, 10, 152, 152, 203, 153, 153, - 204, 150, 150, 200, 147, 147, 195, 3, 3, 4, - 91, 91, 105, 164, 164, 178, 69, 69, 73, 196, - 196, 206, 141, 142, 189, 136, 137, 180, 152, 153, - 187, 101, 103, 134, 126, 129, 172, 176, 178, 205, - 25, 26, 36, 49, 52, 73, 33, 35, 49, 69, - 73, 100, 82, 88, 127, 111, 119, 168, 201, 204, - 221, 81, 95, 159, 85, 99, 163, 97, 105, 147, - 13, 14, 19, 162, 169, 205, 183, 189, 220, 88, - 103, 165, 92, 106, 169, 90, 104, 165, 91, 105, - 166, 95, 110, 172, 102, 115, 174, 93, 105, 158, - 139, 150, 197, 148, 158, 202, 219, 221, 229, 192, - 192, 192, 2, 2, 1, 3, 3, 2, 7, 7, - 6, 15, 15, 14, 133, 133, 131, 152, 152, 151, - 114, 113, 110, 5, 4, 3, 20, 19, 18, 31, - 30, 29, 39, 38, 37, 10, 9, 9, 25, 24, - 24, 61, 60, 60, 183, 183, 183, 81, 81, 81, - 12, 12, 12, 5, 5, 5, 1, 1, 1, 255, - 255, 255, 0, 0, 0, 33, 249, 4, 1, 0, - 0, 42, 0, 44, 0, 0, 0, 0, 130, 0, - 67, 0, 64, 6, 255, 64, 149, 112, 72, 44, - 26, 143, 200, 100, 146, 192, 108, 58, 159, 80, - 130, 114, 74, 173, 90, 175, 70, 130, 225, 112, - 48, 72, 24, 169, 112, 42, 227, 105, 96, 66, - 155, 52, 72, 36, 26, 185, 223, 240, 184, 124, - 78, 15, 185, 69, 38, 14, 100, 15, 73, 236, - 49, 14, 13, 92, 6, 88, 133, 72, 91, 13, - 15, 138, 24, 32, 32, 116, 143, 144, 112, 26, - 30, 48, 0, 150, 150, 59, 25, 140, 145, 156, - 157, 111, 33, 33, 23, 11, 1, 1, 11, 128, - 13, 132, 134, 66, 4, 7, 17, 24, 24, 158, - 35, 27, 31, 9, 151, 150, 51, 9, 49, 186, - 49, 58, 56, 46, 182, 151, 60, 57, 40, 25, - 51, 192, 52, 58, 201, 201, 56, 52, 192, 150, - 45, 12, 17, 62, 49, 192, 59, 185, 187, 9, - 190, 206, 0, 44, 48, 37, 142, 115, 33, 32, - 19, 0, 19, 16, 17, 168, 84, 91, 28, 28, - 38, 177, 27, 39, 57, 43, 192, 48, 30, 27, - 114, 26, 31, 212, 244, 149, 182, 52, 41, 223, - 36, 125, 120, 1, 204, 6, 131, 15, 12, 16, - 0, 123, 241, 65, 3, 190, 15, 253, 108, 197, - 136, 0, 238, 17, 137, 11, 2, 120, 248, 137, - 112, 128, 74, 43, 118, 109, 34, 129, 200, 176, - 96, 155, 73, 75, 60, 22, 228, 72, 129, 65, - 67, 132, 12, 60, 22, 54, 132, 3, 2, 67, - 134, 22, 192, 98, 100, 240, 81, 235, 228, 54, - 255, 22, 56, 20, 124, 32, 113, 175, 19, 9, - 13, 3, 0, 4, 216, 216, 17, 139, 1, 3, - 13, 34, 236, 105, 247, 102, 3, 10, 5, 206, - 114, 156, 40, 26, 171, 235, 195, 28, 206, 94, - 4, 244, 10, 39, 196, 197, 14, 0, 6, 80, - 240, 3, 168, 169, 42, 117, 7, 26, 56, 136, - 160, 135, 15, 132, 118, 33, 201, 234, 245, 100, - 54, 132, 137, 11, 22, 2, 212, 160, 65, 163, - 194, 218, 11, 16, 48, 68, 112, 208, 229, 173, - 227, 199, 66, 158, 110, 225, 210, 64, 174, 131, - 203, 17, 50, 107, 222, 204, 153, 243, 229, 203, - 149, 185, 116, 73, 5, 185, 180, 233, 44, 90, - 38, 115, 41, 224, 65, 130, 107, 6, 176, 25, - 184, 158, 173, 64, 129, 34, 69, 152, 51, 191, - 194, 192, 174, 119, 111, 197, 139, 67, 143, 38, - 125, 186, 184, 138, 201, 15, 90, 203, 110, 80, - 34, 77, 222, 189, 179, 98, 184, 152, 62, 29, - 71, 10, 18, 21, 247, 134, 243, 203, 33, 129, - 178, 4, 167, 26, 27, 223, 162, 121, 44, 29, - 16, 36, 82, 4, 160, 206, 190, 189, 139, 25, - 53, 116, 188, 200, 144, 161, 185, 172, 6, 57, - 88, 0, 107, 177, 195, 253, 141, 0, 242, 101, - 48, 84, 35, 210, 248, 226, 158, 123, 240, 201, - 39, 155, 56, 116, 92, 116, 131, 12, 230, 160, - 67, 156, 58, 116, 113, 208, 149, 6, 18, 68, - 100, 137, 65, 155, 208, 68, 255, 66, 6, 53, - 0, 115, 131, 15, 37, 217, 178, 64, 6, 35, - 228, 37, 194, 72, 58, 0, 19, 64, 6, 41, - 96, 101, 11, 11, 57, 56, 144, 93, 138, 34, - 100, 128, 3, 48, 51, 120, 16, 194, 115, 113, - 160, 129, 86, 0, 231, 52, 48, 5, 43, 188, - 185, 211, 9, 8, 37, 164, 240, 139, 68, 62, - 124, 32, 229, 7, 244, 229, 208, 98, 88, 62, - 200, 120, 201, 10, 57, 52, 192, 149, 44, 241, - 244, 64, 15, 140, 205, 216, 162, 67, 148, 83, - 86, 217, 83, 78, 246, 24, 69, 1, 0, 55, - 248, 193, 152, 21, 80, 233, 97, 33, 29, 249, - 16, 100, 203, 12, 0, 109, 208, 200, 159, 107, - 0, 249, 6, 160, 128, 158, 71, 104, 35, 41, - 104, 8, 128, 11, 10, 136, 115, 40, 27, 100, - 97, 71, 206, 14, 22, 92, 192, 193, 156, 144, - 33, 66, 215, 84, 28, 60, 170, 157, 118, 43, - 122, 218, 149, 89, 26, 88, 128, 86, 57, 149, - 38, 22, 200, 132, 198, 169, 131, 136, 92, 174, - 212, 101, 215, 172, 119, 245, 102, 194, 173, 184, - 178, 161, 43, 174, 183, 246, 182, 199, 5, 9, - 4, 171, 140, 14, 11, 20, 187, 128, 5, 9, - 32, 118, 151, 98, 129, 140, 214, 234, 179, 88, - 164, 38, 153, 106, 148, 85, 102, 237, 181, 215, - 138, 54, 200, 180, 79, 65, 235, 173, 21, 169, - 13, 242, 5, 140, 98, 132, 193, 128, 7, 7, - 204, 133, 255, 65, 9, 118, 172, 168, 198, 161, - 128, 66, 250, 6, 30, 184, 178, 67, 235, 93, - 193, 9, 210, 237, 183, 111, 105, 193, 133, 114, - 244, 73, 96, 134, 8, 126, 222, 216, 137, 8, - 37, 36, 172, 48, 187, 130, 238, 101, 71, 30, - 125, 4, 203, 86, 179, 172, 126, 139, 156, 2, - 30, 120, 224, 0, 81, 13, 239, 85, 83, 6, - 59, 200, 228, 208, 167, 157, 252, 120, 65, 47, - 56, 232, 192, 1, 58, 226, 157, 182, 197, 103, - 17, 164, 72, 71, 27, 11, 215, 108, 51, 118, - 26, 100, 215, 134, 142, 192, 232, 80, 223, 205, - 32, 228, 12, 135, 8, 33, 216, 108, 116, 194, - 216, 249, 89, 71, 8, 22, 212, 112, 67, 5, - 69, 186, 85, 8, 43, 14, 40, 214, 33, 36, - 86, 129, 229, 211, 73, 58, 176, 148, 207, 62, - 91, 111, 163, 128, 4, 249, 48, 32, 64, 216, - 219, 44, 48, 96, 131, 22, 136, 73, 193, 202, - 82, 31, 121, 64, 146, 177, 124, 108, 67, 78, - 13, 105, 160, 247, 61, 37, 100, 160, 40, 0, - 56, 100, 185, 95, 52, 5, 175, 145, 222, 154, - 150, 208, 248, 129, 147, 120, 235, 189, 247, 8, - 125, 43, 48, 143, 45, 1, 180, 249, 72, 8, - 21, 148, 83, 100, 197, 68, 176, 146, 135, 146, - 7, 135, 144, 65, 0, 61, 103, 176, 70, 28, - 118, 3, 179, 0, 3, 56, 217, 82, 207, 200, - 110, 128, 16, 1, 235, 57, 165, 64, 255, 34, - 48, 56, 100, 240, 35, 234, 77, 26, 67, 185, - 229, 22, 89, 0, 64, 7, 150, 58, 192, 121, - 100, 7, 176, 3, 58, 39, 95, 31, 115, 157, - 35, 108, 4, 29, 66, 10, 122, 154, 233, 67, - 153, 151, 36, 144, 193, 151, 34, 124, 24, 162, - 137, 59, 85, 111, 137, 11, 245, 129, 179, 98, - 206, 126, 59, 179, 0, 240, 22, 93, 208, 131, - 70, 231, 196, 109, 132, 1, 14, 40, 223, 201, - 6, 30, 104, 137, 118, 207, 41, 68, 64, 11, - 238, 186, 123, 78, 116, 142, 81, 165, 253, 165, - 141, 1, 230, 129, 196, 69, 4, 208, 3, 10, - 92, 0, 16, 199, 35, 66, 43, 238, 98, 2, - 59, 156, 199, 1, 12, 144, 65, 237, 232, 195, - 193, 48, 208, 231, 3, 13, 64, 67, 27, 54, - 16, 129, 49, 112, 144, 131, 36, 16, 96, 9, - 79, 200, 193, 197, 181, 46, 123, 44, 36, 151, - 128, 36, 64, 145, 47, 113, 130, 4, 109, 3, - 192, 90, 226, 87, 8, 242, 76, 69, 14, 76, - 74, 193, 13, 128, 161, 61, 27, 146, 44, 18, - 27, 112, 128, 15, 190, 119, 137, 5, 160, 192, - 136, 122, 33, 74, 230, 16, 176, 67, 9, 61, - 230, 41, 233, 170, 75, 59, 172, 82, 46, 49, - 124, 64, 94, 71, 228, 196, 138, 22, 215, 197, - 20, 176, 175, 43, 36, 184, 8, 57, 80, 133, - 152, 197, 200, 207, 101, 113, 217, 20, 31, 168, - 98, 193, 48, 218, 255, 17, 18, 125, 1, 204, - 4, 118, 192, 131, 14, 44, 5, 49, 225, 225, - 151, 18, 16, 161, 46, 89, 217, 165, 29, 38, - 104, 67, 29, 239, 248, 9, 80, 60, 140, 3, - 23, 16, 197, 2, 112, 128, 3, 82, 224, 96, - 1, 201, 194, 23, 197, 4, 233, 178, 201, 88, - 70, 55, 134, 188, 23, 31, 36, 70, 202, 82, - 154, 50, 147, 83, 121, 69, 102, 2, 161, 175, - 8, 114, 242, 149, 157, 139, 130, 44, 103, 217, - 4, 88, 218, 242, 52, 210, 226, 150, 46, 119, - 185, 175, 91, 250, 242, 72, 210, 210, 22, 23, - 110, 67, 204, 98, 230, 70, 55, 187, 1, 14, - 43, 5, 177, 173, 94, 254, 18, 90, 225, 90, - 141, 4, 168, 68, 46, 19, 198, 70, 2, 30, - 120, 192, 39, 145, 153, 204, 110, 246, 202, 55, - 190, 90, 214, 98, 154, 229, 172, 103, 190, 5, - 139, 7, 40, 128, 4, 170, 233, 65, 116, 69, - 128, 93, 32, 72, 67, 193, 116, 117, 199, 111, - 222, 139, 89, 173, 52, 231, 18, 38, 163, 78, - 250, 132, 225, 3, 173, 64, 131, 159, 58, 38, - 135, 80, 17, 138, 160, 94, 129, 88, 196, 130, - 117, 142, 77, 234, 19, 57, 95, 128, 205, 3, - 98, 54, 80, 232, 156, 192, 132, 29, 68, 145, - 193, 62, 245, 176, 136, 233, 32, 88, 225, 113, - 229, 120, 134, 233, 26, 141, 17, 101, 163, 100, - 33, 218, 232, 74, 135, 82, 59, 254, 168, 59, - 255, 198, 186, 128, 27, 69, 234, 24, 68, 60, - 160, 54, 14, 104, 14, 66, 245, 2, 15, 121, - 0, 67, 1, 79, 100, 36, 30, 255, 66, 73, - 28, 36, 96, 166, 35, 189, 204, 3, 54, 134, - 82, 131, 194, 75, 84, 113, 104, 158, 45, 106, - 144, 2, 71, 29, 116, 14, 79, 125, 42, 24, - 229, 32, 142, 166, 213, 224, 109, 86, 204, 84, - 186, 46, 195, 8, 130, 110, 64, 2, 24, 141, - 225, 9, 61, 248, 1, 12, 40, 109, 4, 76, - 202, 192, 147, 178, 151, 86, 127, 126, 208, 173, - 208, 75, 79, 93, 213, 218, 66, 15, 52, 7, - 165, 23, 161, 129, 11, 34, 36, 136, 115, 166, - 43, 51, 9, 196, 234, 236, 98, 98, 64, 56, - 189, 32, 5, 14, 72, 3, 37, 26, 107, 9, - 26, 192, 32, 5, 35, 208, 0, 10, 82, 112, - 183, 198, 206, 32, 6, 31, 72, 236, 27, 46, - 114, 55, 168, 133, 245, 10, 80, 217, 205, 78, - 221, 128, 161, 191, 25, 48, 6, 41, 24, 201, - 142, 40, 107, 137, 0, 96, 54, 70, 180, 189, - 132, 14, 206, 8, 7, 18, 188, 105, 0, 224, - 193, 84, 21, 234, 132, 129, 20, 30, 204, 123, - 61, 67, 83, 154, 252, 22, 178, 218, 229, 64, - 33, 174, 75, 1, 53, 253, 169, 128, 230, 94, - 162, 7, 57, 240, 128, 15, 102, 123, 9, 235, - 76, 73, 74, 244, 129, 129, 239, 204, 180, 149, - 224, 1, 160, 7, 22, 184, 255, 212, 27, 231, - 215, 0, 251, 121, 162, 167, 98, 114, 93, 80, - 231, 181, 129, 38, 205, 181, 178, 62, 16, 31, - 0, 254, 129, 29, 93, 137, 64, 170, 151, 32, - 31, 66, 160, 123, 137, 23, 144, 109, 104, 27, - 72, 15, 246, 44, 113, 3, 9, 32, 20, 135, - 0, 224, 65, 122, 133, 139, 4, 36, 81, 229, - 29, 250, 0, 6, 85, 141, 235, 161, 12, 12, - 113, 170, 66, 108, 28, 77, 154, 180, 96, 0, - 248, 44, 191, 34, 2, 200, 141, 84, 74, 58, - 91, 52, 184, 165, 110, 240, 109, 57, 30, 152, - 142, 36, 172, 227, 194, 75, 178, 137, 117, 45, - 1, 90, 216, 85, 5, 5, 57, 136, 239, 37, - 98, 160, 191, 8, 71, 35, 59, 86, 41, 50, - 0, 96, 0, 163, 241, 90, 162, 136, 114, 216, - 64, 3, 24, 160, 31, 19, 149, 87, 129, 23, - 72, 139, 156, 214, 139, 60, 247, 118, 98, 18, - 138, 226, 193, 145, 227, 176, 1, 12, 164, 160, - 196, 46, 72, 193, 149, 186, 27, 64, 56, 204, - 2, 113, 0, 168, 65, 1, 109, 209, 3, 5, - 92, 185, 42, 77, 106, 241, 37, 108, 160, 128, - 18, 236, 116, 129, 240, 227, 136, 18, 88, 161, - 188, 69, 62, 98, 103, 220, 181, 196, 137, 228, - 185, 129, 162, 109, 22, 6, 147, 219, 51, 140, - 24, 91, 224, 3, 15, 202, 38, 157, 29, 242, - 78, 214, 92, 91, 211, 105, 32, 13, 69, 187, - 168, 2, 255, 50, 253, 140, 62, 195, 56, 198, - 194, 179, 6, 15, 149, 240, 145, 59, 113, 66, - 202, 25, 212, 240, 71, 133, 181, 30, 147, 116, - 109, 32, 60, 82, 177, 36, 50, 4, 12, 97, - 80, 233, 133, 150, 136, 143, 196, 122, 225, 100, - 19, 125, 96, 119, 157, 32, 71, 5, 18, 112, - 41, 87, 222, 216, 213, 144, 200, 83, 110, 89, - 0, 91, 27, 129, 136, 136, 219, 27, 154, 232, - 244, 172, 104, 24, 185, 22, 109, 9, 64, 224, - 169, 71, 251, 166, 14, 88, 96, 115, 234, 104, - 47, 59, 68, 210, 59, 96, 32, 0, 65, 52, - 0, 208, 11, 86, 130, 130, 120, 246, 212, 61, - 90, 249, 210, 189, 219, 195, 228, 20, 48, 209, - 18, 50, 128, 55, 128, 98, 144, 131, 12, 108, - 101, 220, 228, 6, 0, 165, 30, 104, 60, 58, - 205, 237, 46, 102, 189, 10, 48, 4, 160, 21, - 163, 137, 227, 211, 207, 233, 158, 205, 144, 237, - 33, 155, 129, 224, 3, 90, 187, 238, 11, 114, - 90, 51, 18, 160, 33, 103, 171, 237, 173, 6, - 208, 50, 1, 182, 212, 216, 225, 245, 187, 203, - 121, 50, 192, 105, 192, 181, 89, 168, 231, 41, - 1, 79, 52, 44, 1, 40, 70, 81, 4, 153, - 75, 73, 27, 95, 238, 148, 9, 66, 156, 38, - 139, 21, 25, 206, 31, 161, 89, 206, 18, 209, - 70, 71, 60, 10, 57, 120, 176, 195, 182, 92, - 145, 60, 90, 100, 45, 68, 102, 192, 219, 117, - 174, 83, 85, 180, 75, 79, 17, 8, 98, 212, - 117, 174, 211, 64, 1, 28, 254, 57, 5, 206, - 214, 129, 5, 0, 146, 194, 98, 173, 218, 28, - 17, 102, 51, 153, 133, 125, 14, 52, 171, 187, - 94, 72, 181, 246, 180, 44, 5, 95, 133, 125, - 214, 83, 228, 130, 129, 57, 114, 128, 104, 119, - 79, 188, 27, 72, 101, 129, 9, 136, 169, 3, - 59, 92, 25, 99, 104, 90, 154, 151, 201, 113, - 42, 137, 28, 129, 161, 21, 239, 149, 190, 108, - 224, 2, 20, 168, 1, 215, 255, 147, 42, 197, - 232, 235, 153, 132, 188, 252, 28, 111, 197, 249, - 203, 57, 242, 191, 128, 169, 164, 96, 2, 64, - 129, 84, 113, 128, 89, 45, 211, 231, 16, 176, - 8, 171, 194, 139, 82, 121, 172, 255, 132, 230, - 55, 207, 85, 71, 26, 63, 69, 16, 3, 86, - 50, 138, 85, 212, 99, 101, 242, 246, 193, 201, - 189, 238, 7, 249, 170, 185, 196, 74, 148, 216, - 191, 215, 41, 73, 57, 44, 29, 32, 11, 149, - 208, 143, 190, 244, 167, 175, 10, 201, 84, 235, - 152, 175, 176, 87, 246, 215, 207, 14, 85, 174, - 146, 149, 229, 36, 63, 44, 167, 37, 204, 250, - 219, 255, 254, 206, 52, 103, 16, 0, 0, 59, - 10, 124, 165, 92, 136, 65, 105, 236, 247, 73, - 168, 224, 1, 35, 240, 0, 23, 226, 0, 154, - 225, 54, 178, 247, 74, 94, 17, 75, 229, 34, - 22, 137, 33, 128, 174, 3, 88, 10, 143, 65, - 21, 34, 48, 1, 51, 160, 3, 207, 151, 127, - 104, 37, 126, 248, 196, 4, 196, 18, 46, 202, - 52, 75, 2, 50, 129, 21, 88, 7, 209, 100, - 114, 95, 97, 12, 172, 96, 92, 36, 176, 128, - 104, 213, 128, 10, 117, 76, 254, 71, 8, 175, - 80, 130, 203, 164, 46, 186, 176, 130, 20, 24, - 7, 62, 24, 77, 199, 52, 47, 247, 177, 54, - 19, 128, 90, 60, 240, 43, 229, 132, 86, 180, - 161, 121, 58, 85, 11, 46, 115, 8, 175, 49, - 25, 155, 17, 8, 58, 184, 76, 9, 80, 46, - 3, 0, 85, 80, 165, 78, 235, 52, 13, 247, - 178, 47, 241, 164, 26, 177, 65, 27, 221, 241, - 132, 183, 193, 86, 189, 49, 78, 228, 84, 78, - 110, 248, 134, 112, 24, 135, 242, 68, 134, 28, - 37, 42, 103, 136, 134, 33, 104, 48, 39, 35, - 27, 109, 160, 48, 220, 242, 135, 21, 224, 25, - 220, 2, 49, 7, 53, 49, 32, 21, 4, 0, - 59, 0 }; - -unsigned char php_egg_logo[] = { - 71, 73, 70, 56, 57, 97, 130, 0, 67, 0, - 213, 255, 0, 0, 0, 0, 152, 138, 142, 104, - 95, 105, 89, 86, 93, 160, 151, 174, 102, 101, - 136, 164, 163, 205, 174, 173, 213, 102, 102, 153, - 99, 99, 149, 102, 102, 152, 96, 96, 143, 90, - 90, 134, 82, 82, 115, 87, 87, 121, 80, 80, - 108, 74, 74, 100, 110, 110, 147, 95, 95, 127, - 149, 149, 198, 118, 118, 157, 67, 67, 89, 144, - 144, 191, 128, 128, 169, 137, 137, 180, 155, 155, - 197, 186, 186, 227, 209, 209, 247, 242, 242, 254, - 64, 67, 65, 192, 192, 192, 32, 45, 25, 50, - 54, 36, 65, 63, 42, 75, 71, 53, 87, 79, - 61, 93, 85, 69, 231, 180, 110, 106, 92, 74, - 207, 155, 100, 121, 101, 80, 181, 131, 89, 141, - 110, 88, 158, 125, 103, 148, 118, 97, 169, 135, - 112, 131, 112, 99, 180, 141, 117, 135, 101, 81, - 191, 148, 124, 168, 126, 107, 201, 153, 130, 164, - 116, 97, 191, 139, 119, 213, 155, 135, 220, 164, - 146, 203, 142, 124, 180, 127, 112, 175, 118, 103, - 191, 127, 114, 162, 102, 91, 255, 255, 255, 0, - 0, 0, 0, 0, 0, 33, 249, 4, 1, 0, - 0, 30, 0, 44, 0, 0, 0, 0, 130, 0, - 67, 0, 64, 6, 255, 64, 143, 112, 72, 44, - 26, 143, 72, 226, 100, 105, 105, 98, 158, 151, - 40, 133, 18, 137, 20, 36, 18, 135, 118, 203, - 213, 74, 10, 133, 200, 52, 122, 121, 98, 154, - 150, 229, 50, 201, 110, 187, 223, 202, 137, 5, - 115, 137, 72, 30, 16, 72, 101, 15, 105, 48, - 24, 11, 9, 130, 10, 132, 10, 8, 135, 136, - 137, 137, 11, 3, 34, 31, 31, 32, 32, 33, - 147, 34, 149, 34, 35, 152, 153, 34, 33, 32, - 143, 143, 29, 2, 133, 130, 9, 11, 127, 14, - 13, 13, 91, 88, 18, 17, 101, 105, 19, 112, - 112, 114, 24, 17, 120, 123, 21, 14, 129, 132, - 138, 188, 189, 190, 137, 21, 31, 33, 38, 48, - 44, 52, 58, 57, 59, 53, 56, 203, 56, 206, - 206, 51, 207, 204, 53, 47, 57, 50, 44, 40, - 36, 35, 150, 33, 144, 191, 188, 132, 164, 12, - 14, 95, 96, 20, 103, 176, 111, 22, 20, 182, - 16, 12, 9, 134, 223, 242, 243, 138, 32, 36, - 48, 42, 52, 50, 57, 203, 205, 206, 54, 0, - 111, 8, 20, 8, 112, 198, 140, 24, 212, 86, - 184, 64, 97, 162, 33, 166, 77, 32, 36, 208, - 251, 165, 32, 193, 31, 49, 231, 44, 176, 185, - 3, 33, 87, 188, 137, 32, 229, 129, 24, 129, - 66, 5, 10, 23, 35, 62, 184, 112, 1, 163, - 134, 141, 26, 57, 98, 210, 88, 209, 2, 69, - 139, 24, 49, 94, 188, 136, 97, 16, 71, 181, - 255, 28, 42, 26, 170, 184, 105, 99, 199, 142, - 25, 20, 66, 130, 43, 101, 134, 13, 173, 44, - 126, 224, 41, 157, 170, 72, 129, 128, 124, 59, - 152, 225, 115, 121, 3, 161, 209, 29, 52, 118, - 228, 192, 97, 131, 160, 13, 28, 8, 173, 173, - 208, 183, 130, 133, 10, 131, 48, 73, 124, 156, - 90, 145, 65, 134, 13, 26, 50, 104, 116, 51, - 139, 2, 152, 43, 14, 222, 237, 162, 58, 113, - 0, 10, 26, 47, 100, 208, 40, 113, 2, 6, - 15, 30, 58, 190, 234, 72, 81, 162, 68, 179, - 131, 60, 11, 190, 88, 209, 150, 133, 11, 21, - 109, 77, 74, 149, 23, 110, 65, 1, 13, 61, - 56, 108, 48, 160, 38, 22, 27, 38, 116, 168, - 84, 169, 82, 224, 15, 160, 65, 133, 168, 38, - 0, 113, 162, 132, 138, 98, 156, 101, 200, 104, - 177, 83, 231, 138, 202, 59, 115, 182, 88, 190, - 188, 184, 206, 196, 161, 85, 184, 8, 76, 193, - 192, 134, 235, 120, 89, 171, 73, 231, 186, 123, - 119, 53, 104, 230, 152, 33, 67, 222, 204, 153, - 240, 232, 211, 167, 201, 192, 190, 189, 28, 245, - 175, 214, 120, 159, 79, 63, 142, 147, 11, 84, - 36, 52, 120, 192, 63, 143, 255, 10, 121, 240, - 151, 138, 109, 128, 44, 96, 224, 129, 6, 98, - 49, 0, 39, 158, 52, 8, 130, 8, 29, 116, - 16, 32, 127, 15, 160, 194, 197, 23, 98, 184, - 242, 74, 125, 243, 49, 81, 255, 7, 30, 122, - 0, 232, 71, 32, 240, 204, 69, 88, 3, 143, - 132, 80, 201, 8, 13, 161, 224, 34, 10, 197, - 12, 199, 28, 113, 45, 200, 208, 22, 75, 38, - 144, 176, 201, 35, 32, 48, 224, 75, 56, 226, - 156, 66, 14, 22, 5, 100, 36, 223, 119, 22, - 92, 32, 65, 136, 238, 148, 72, 24, 72, 144, - 16, 115, 76, 50, 254, 144, 21, 208, 64, 4, - 57, 83, 67, 13, 53, 98, 211, 16, 9, 58, - 66, 84, 1, 85, 225, 140, 19, 134, 24, 232, - 180, 81, 75, 30, 130, 61, 73, 88, 7, 35, - 196, 200, 79, 79, 86, 222, 96, 195, 12, 48, - 45, 199, 19, 78, 124, 62, 39, 214, 10, 12, - 145, 208, 16, 11, 47, 192, 36, 209, 147, 117, - 21, 16, 5, 6, 108, 68, 224, 64, 133, 186, - 184, 73, 213, 0, 38, 168, 96, 140, 112, 44, - 192, 0, 3, 13, 49, 25, 245, 204, 87, 210, - 60, 3, 83, 14, 250, 216, 168, 194, 80, 91, - 194, 36, 131, 143, 132, 85, 180, 64, 4, 7, - 24, 176, 87, 18, 115, 216, 129, 69, 46, 163, - 73, 74, 207, 0, 155, 110, 169, 2, 15, 52, - 4, 107, 77, 88, 151, 213, 176, 67, 98, 53, - 24, 148, 19, 78, 47, 180, 48, 147, 91, 248, - 172, 96, 146, 4, 38, 210, 227, 106, 4, 28, - 168, 166, 157, 119, 179, 212, 49, 91, 109, 183, - 57, 169, 43, 34, 9, 176, 136, 2, 101, 39, - 28, 19, 255, 217, 87, 89, 225, 208, 219, 9, - 60, 25, 116, 208, 102, 156, 177, 192, 89, 169, - 44, 228, 235, 194, 0, 85, 85, 36, 206, 5, - 27, 100, 139, 87, 6, 173, 113, 40, 203, 44, - 177, 77, 161, 48, 126, 84, 148, 98, 219, 129, - 163, 140, 82, 8, 3, 33, 208, 80, 192, 2, - 29, 8, 90, 146, 165, 246, 114, 214, 86, 10, - 49, 48, 215, 236, 114, 156, 181, 16, 0, 1, - 7, 104, 160, 178, 202, 7, 196, 74, 240, 118, - 6, 199, 252, 26, 19, 226, 73, 97, 199, 41, - 251, 81, 216, 159, 127, 60, 247, 220, 179, 206, - 2, 162, 146, 138, 42, 97, 80, 80, 198, 121, - 27, 202, 172, 180, 125, 177, 221, 1, 98, 30, - 124, 84, 248, 7, 196, 18, 23, 98, 117, 60, - 14, 52, 210, 73, 131, 144, 68, 178, 53, 215, - 33, 12, 144, 139, 195, 167, 4, 61, 52, 145, - 70, 163, 195, 221, 210, 73, 120, 72, 1, 71, - 76, 142, 72, 98, 110, 83, 49, 176, 181, 36, - 151, 128, 169, 55, 9, 47, 46, 100, 210, 73, - 129, 142, 192, 32, 36, 13, 244, 235, 106, 41, - 66, 14, 249, 133, 145, 107, 27, 220, 151, 3, - 80, 3, 24, 238, 96, 227, 34, 208, 193, 37, - 38, 108, 236, 150, 189, 50, 164, 26, 106, 170, - 212, 144, 154, 105, 54, 219, 116, 2, 66, 2, - 164, 249, 139, 248, 144, 230, 164, 233, 93, 173, - 182, 72, 30, 105, 229, 188, 116, 240, 255, 193, - 61, 249, 32, 163, 140, 52, 0, 5, 212, 251, - 157, 206, 88, 115, 77, 160, 218, 64, 244, 1, - 234, 33, 185, 106, 38, 24, 173, 164, 241, 134, - 28, 236, 132, 120, 91, 181, 180, 39, 18, 2, - 223, 185, 39, 195, 251, 239, 3, 149, 85, 208, - 188, 210, 50, 244, 229, 67, 145, 56, 208, 170, - 2, 165, 176, 82, 133, 235, 72, 40, 169, 71, - 147, 212, 87, 175, 136, 8, 184, 239, 211, 238, - 51, 189, 99, 105, 103, 239, 7, 81, 163, 211, - 240, 95, 2, 211, 138, 88, 213, 42, 113, 40, - 140, 81, 73, 224, 200, 3, 102, 39, 191, 111, - 192, 233, 36, 167, 178, 212, 62, 114, 16, 131, - 59, 229, 196, 70, 52, 97, 14, 159, 228, 181, - 37, 82, 193, 32, 71, 38, 88, 1, 79, 118, - 96, 131, 28, 196, 111, 34, 232, 99, 0, 25, - 54, 178, 31, 143, 52, 112, 30, 25, 43, 201, - 10, 132, 35, 28, 172, 24, 5, 25, 157, 170, - 1, 78, 60, 231, 140, 180, 12, 43, 83, 42, - 24, 11, 64, 248, 81, 0, 55, 165, 144, 96, - 8, 108, 31, 84, 0, 113, 194, 23, 34, 160, - 0, 149, 50, 198, 49, 104, 128, 2, 30, 220, - 80, 7, 88, 140, 140, 149, 126, 39, 170, 97, - 233, 131, 6, 167, 202, 193, 157, 10, 101, 130, - 5, 32, 202, 34, 6, 208, 128, 172, 216, 80, - 171, 91, 49, 177, 137, 242, 187, 138, 22, 107, - 240, 27, 77, 57, 255, 6, 139, 193, 90, 198, - 12, 98, 130, 3, 121, 45, 171, 6, 138, 153, - 73, 91, 74, 226, 150, 50, 158, 175, 20, 7, - 184, 206, 182, 218, 48, 1, 58, 252, 37, 11, - 186, 128, 163, 174, 20, 80, 18, 107, 192, 96, - 130, 84, 202, 1, 30, 129, 85, 131, 96, 33, - 68, 89, 51, 176, 224, 102, 242, 117, 170, 98, - 100, 234, 80, 32, 81, 30, 106, 56, 144, 151, - 35, 201, 98, 14, 84, 248, 75, 96, 34, 249, - 194, 4, 240, 141, 5, 50, 64, 215, 20, 143, - 113, 63, 116, 133, 242, 32, 161, 180, 65, 78, - 58, 67, 74, 123, 185, 101, 95, 39, 44, 13, - 3, 48, 144, 45, 109, 21, 140, 67, 176, 241, - 214, 183, 166, 134, 27, 73, 210, 3, 2, 36, - 160, 76, 10, 166, 148, 21, 207, 225, 169, 55, - 241, 154, 151, 141, 102, 68, 35, 12, 110, 46, - 20, 170, 99, 64, 4, 238, 162, 154, 236, 60, - 147, 109, 69, 136, 166, 194, 230, 25, 1, 2, - 25, 168, 154, 148, 243, 69, 185, 122, 3, 66, - 205, 229, 43, 131, 43, 64, 215, 140, 116, 194, - 172, 231, 44, 7, 131, 1, 176, 14, 118, 84, - 102, 128, 151, 185, 18, 158, 223, 161, 25, 20, - 200, 67, 81, 50, 200, 6, 12, 14, 35, 144, - 109, 40, 37, 168, 204, 245, 109, 37, 1, 8, - 41, 1, 50, 96, 0, 3, 180, 236, 164, 45, - 43, 41, 193, 208, 0, 51, 136, 186, 244, 165, - 255, 48, 141, 105, 76, 193, 227, 132, 132, 89, - 1, 42, 66, 3, 154, 78, 129, 38, 180, 46, - 148, 35, 67, 71, 99, 233, 67, 101, 170, 52, - 137, 74, 225, 10, 57, 219, 153, 207, 252, 99, - 182, 46, 104, 225, 1, 123, 136, 80, 132, 0, - 52, 161, 166, 122, 161, 104, 65, 77, 26, 81, - 35, 58, 7, 252, 56, 138, 66, 60, 139, 218, - 128, 10, 116, 207, 136, 225, 179, 0, 2, 24, - 193, 215, 184, 198, 181, 145, 144, 96, 28, 168, - 160, 80, 79, 175, 218, 138, 39, 104, 117, 171, - 70, 136, 166, 29, 158, 118, 139, 62, 204, 146, - 68, 37, 178, 26, 69, 6, 176, 86, 72, 76, - 226, 176, 136, 141, 4, 216, 6, 48, 10, 3, - 253, 33, 174, 22, 82, 92, 93, 239, 42, 211, - 110, 237, 53, 114, 21, 120, 192, 44, 171, 102, - 205, 68, 56, 160, 3, 221, 16, 134, 37, 50, - 49, 2, 48, 53, 228, 180, 95, 50, 222, 39, - 6, 96, 8, 171, 9, 194, 97, 115, 93, 69, - 218, 156, 247, 210, 190, 20, 0, 68, 124, 24, - 81, 53, 221, 20, 12, 72, 172, 168, 163, 167, - 61, 201, 103, 242, 101, 204, 124, 193, 128, 33, - 165, 227, 17, 242, 18, 33, 138, 32, 165, 98, - 21, 172, 112, 69, 227, 160, 217, 213, 219, 134, - 40, 179, 147, 235, 236, 60, 42, 32, 9, 76, - 128, 9, 70, 46, 146, 32, 5, 251, 129, 144, - 231, 88, 35, 95, 200, 221, 255, 209, 7, 32, - 240, 13, 81, 172, 110, 21, 97, 144, 46, 117, - 105, 17, 187, 10, 232, 54, 159, 186, 74, 0, - 4, 236, 1, 163, 236, 117, 106, 26, 161, 210, - 210, 150, 170, 113, 141, 15, 134, 137, 65, 99, - 154, 135, 50, 189, 80, 14, 35, 113, 11, 118, - 76, 154, 158, 118, 67, 18, 12, 146, 228, 131, - 155, 85, 250, 199, 239, 162, 49, 224, 243, 146, - 110, 27, 198, 91, 174, 130, 149, 71, 142, 191, - 56, 88, 22, 24, 136, 222, 30, 30, 32, 152, - 9, 79, 37, 18, 196, 200, 199, 127, 183, 167, - 191, 253, 161, 69, 85, 94, 2, 19, 136, 59, - 81, 56, 165, 148, 201, 1, 204, 107, 222, 116, - 143, 208, 200, 53, 73, 78, 92, 78, 60, 68, - 8, 44, 204, 203, 251, 245, 49, 127, 4, 49, - 203, 141, 55, 99, 146, 211, 22, 143, 19, 32, - 112, 241, 33, 126, 60, 155, 11, 208, 150, 86, - 24, 184, 237, 30, 26, 192, 192, 36, 31, 130, - 126, 248, 152, 210, 150, 160, 241, 100, 40, 19, - 196, 143, 128, 244, 210, 248, 74, 7, 130, 4, - 147, 73, 28, 103, 42, 195, 144, 135, 64, 95, - 61, 120, 68, 203, 79, 186, 94, 154, 169, 20, - 42, 55, 119, 15, 120, 3, 166, 50, 241, 180, - 193, 137, 30, 31, 82, 157, 99, 152, 213, 17, - 40, 208, 0, 63, 47, 0, 208, 110, 138, 161, - 140, 147, 21, 141, 58, 213, 88, 89, 49, 64, - 75, 78, 255, 116, 98, 141, 160, 128, 176, 33, - 194, 33, 129, 164, 82, 120, 64, 54, 88, 23, - 126, 102, 238, 197, 3, 57, 182, 143, 29, 254, - 18, 79, 214, 184, 73, 48, 49, 179, 195, 208, - 201, 32, 27, 66, 209, 73, 13, 110, 224, 2, - 76, 35, 64, 121, 43, 76, 32, 30, 200, 108, - 236, 64, 147, 164, 99, 10, 129, 17, 13, 200, - 130, 39, 197, 12, 37, 0, 32, 0, 128, 9, - 88, 160, 107, 101, 17, 216, 192, 42, 144, 65, - 40, 219, 101, 62, 68, 49, 229, 9, 27, 193, - 131, 11, 99, 205, 139, 145, 128, 215, 5, 217, - 246, 12, 12, 148, 177, 3, 100, 212, 64, 7, - 156, 154, 129, 64, 228, 229, 71, 177, 228, 0, - 27, 48, 106, 129, 75, 138, 130, 131, 164, 152, - 155, 1, 78, 112, 245, 126, 152, 205, 110, 94, - 64, 128, 24, 156, 139, 201, 10, 54, 197, 174, - 100, 196, 68, 147, 235, 122, 198, 14, 133, 55, - 19, 75, 137, 241, 37, 200, 64, 37, 153, 12, - 212, 80, 73, 27, 129, 2, 101, 107, 83, 195, - 17, 81, 129, 74, 5, 139, 6, 60, 168, 35, - 14, 249, 97, 165, 0, 63, 3, 79, 247, 214, - 7, 190, 79, 149, 239, 23, 224, 128, 7, 4, - 164, 139, 69, 46, 16, 43, 147, 23, 225, 2, - 5, 208, 2, 153, 115, 213, 112, 5, 72, 41, - 50, 157, 68, 129, 24, 113, 64, 42, 117, 105, - 145, 44, 221, 187, 177, 90, 216, 226, 255, 150, - 23, 8, 51, 6, 52, 96, 0, 166, 175, 149, - 29, 163, 19, 33, 73, 183, 90, 122, 179, 167, - 34, 199, 110, 106, 74, 56, 157, 18, 11, 22, - 153, 33, 196, 59, 113, 152, 26, 129, 180, 81, - 166, 146, 5, 148, 7, 156, 241, 85, 215, 57, - 192, 80, 149, 128, 118, 55, 50, 61, 214, 3, - 80, 1, 212, 73, 85, 199, 95, 173, 139, 93, - 48, 225, 244, 168, 113, 82, 35, 143, 1, 177, - 45, 134, 188, 179, 10, 85, 211, 202, 61, 15, - 65, 14, 72, 191, 2, 36, 15, 239, 196, 2, - 160, 128, 5, 150, 156, 210, 88, 96, 146, 149, - 80, 222, 96, 143, 57, 168, 6, 168, 149, 213, - 130, 122, 213, 49, 124, 102, 244, 49, 41, 10, - 16, 176, 13, 8, 126, 240, 121, 133, 229, 35, - 113, 133, 95, 249, 217, 242, 146, 53, 208, 84, - 13, 82, 160, 169, 199, 56, 31, 6, 232, 210, - 161, 228, 119, 61, 74, 82, 194, 160, 45, 48, - 8, 5, 10, 93, 37, 129, 85, 174, 6, 248, - 109, 19, 190, 44, 37, 236, 68, 195, 132, 251, - 5, 232, 114, 62, 100, 216, 245, 174, 95, 102, - 198, 130, 181, 39, 46, 207, 221, 130, 130, 220, - 183, 87, 28, 17, 216, 64, 106, 190, 15, 126, - 70, 194, 114, 54, 55, 67, 126, 242, 131, 77, - 37, 129, 46, 89, 132, 69, 158, 130, 3, 59, - 208, 27, 252, 102, 119, 205, 226, 49, 245, 50, - 67, 250, 34, 0, 255, 34, 134, 8, 64, 194, - 0, 5, 112, 0, 251, 167, 70, 239, 68, 31, - 239, 225, 85, 211, 148, 93, 180, 147, 0, 34, - 96, 2, 218, 4, 25, 66, 20, 42, 239, 146, - 25, 6, 241, 128, 52, 17, 28, 251, 160, 119, - 150, 130, 2, 200, 3, 36, 165, 0, 43, 2, - 227, 123, 45, 181, 52, 221, 34, 27, 33, 120, - 79, 116, 243, 36, 11, 16, 2, 148, 65, 3, - 184, 132, 73, 133, 210, 130, 232, 210, 39, 228, - 68, 28, 207, 33, 28, 157, 17, 20, 18, 128, - 127, 119, 177, 80, 218, 209, 127, 50, 35, 79, - 243, 148, 31, 83, 3, 88, 65, 72, 15, 67, - 216, 27, 217, 192, 49, 29, 51, 35, 43, 240, - 46, 207, 209, 44, 207, 81, 80, 58, 17, 127, - 38, 225, 2, 24, 160, 1, 216, 145, 29, 14, - 229, 121, 48, 245, 30, 9, 179, 133, 13, 243, - 48, 101, 21, 88, 87, 131, 8, 11, 48, 2, - 39, 208, 2, 112, 146, 57, 196, 213, 22, 51, - 52, 28, 103, 88, 2, 109, 232, 132, 6, 85, - 121, 38, 147, 70, 120, 177, 50, 177, 178, 29, - 118, 136, 87, 66, 32, 81, 121, 88, 81, 117, - 112, 49, 26, 69, 86, 7, 130, 11, 6, 210, - 0, 37, 232, 81, 248, 64, 134, 167, 2, 129, - 156, 33, 82, 41, 67, 137, 41, 213, 80, 239, - 209, 129, 152, 24, 11, 52, 53, 30, 156, 88, - 30, 102, 0, 31, 186, 56, 1, 236, 81, 82, - 30, 190, 248, 139, 42, 181, 82, 66, 133, 133, - 179, 232, 129, 52, 85, 83, 230, 145, 140, 202, - 184, 140, 230, 161, 139, 195, 120, 137, 108, 19, - 4, 0, 59, 0 }; - - diff --git a/main/main.c b/main/main.c deleted file mode 100644 index 9562470cef..0000000000 --- a/main/main.c +++ /dev/null @@ -1,1332 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Andi Gutmans <andi@zend.com> | - | Rasmus Lerdorf <rasmus@lerdorf.on.ca> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -/* {{{ includes - */ -#include <stdio.h> -#include "php.h" -#ifdef PHP_WIN32 -#include "win32/time.h" -#include "win32/signal.h" -#include <process.h> -#else -#include "build-defs.h" -#endif -#if HAVE_SYS_TIME_H -#include <sys/time.h> -#endif -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#if HAVE_SIGNAL_H -#include <signal.h> -#endif -#if HAVE_SETLOCALE -#include <locale.h> -#endif -#include "zend.h" -#include "zend_extensions.h" -#include "php_ini.h" -#include "php_globals.h" -#include "php_main.h" -#include "fopen_wrappers.h" -#include "ext/standard/php_standard.h" -#include "php_variables.h" -#include "ext/standard/credits.h" -#ifdef PHP_WIN32 -#include <io.h> -#include <fcntl.h> -#include "win32/php_registry.h" -#endif -#include "php_syslog.h" - -#if PHP_SIGCHILD -#include <sys/types.h> -#include <sys/wait.h> -#endif - -#include "zend_compile.h" -#include "zend_execute.h" -#include "zend_highlight.h" -#include "zend_indent.h" -#include "zend_extensions.h" - -#include "php_content_types.h" -#include "php_ticks.h" -#include "php_logos.h" - -#include "SAPI.h" -/* }}} */ - -#ifndef ZTS -php_core_globals core_globals; -#else -PHPAPI int core_globals_id; -#endif - -static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC); - -#define SAFE_FILENAME(f) ((f)?(f):"-") - -/* {{{ PHP_INI_MH - */ -static PHP_INI_MH(OnSetPrecision) -{ - EG(precision) = atoi(new_value); - return SUCCESS; -} -/* }}} */ - -#if MEMORY_LIMIT -/* {{{ PHP_INI_MH - */ -static PHP_INI_MH(OnChangeMemoryLimit) -{ - int new_limit; - - if (new_value) { - new_limit = zend_atoi(new_value, new_value_length); - } else { - new_limit = 1<<30; /* effectively, no limit */ - } - return zend_set_memory_limit(new_limit); -} -/* }}} */ -#endif - -/* {{{ PHP_INI_MH - */ -static PHP_INI_MH(OnUpdateErrorReporting) -{ - if (!new_value) { - EG(error_reporting) = E_ALL & ~E_NOTICE; - } else { - EG(error_reporting) = atoi(new_value); - } - return SUCCESS; -} -/* }}} */ - -/* {{{ php_disable_functions - */ -static void php_disable_functions(TSRMLS_D) -{ - char *func; - char *new_value_dup = strdup(INI_STR("disable_functions")); /* This is an intentional leak, - * it's not a big deal as it's process-wide - */ - - func = strtok(new_value_dup, ", "); - while (func) { - zend_disable_function(func, strlen(func) TSRMLS_CC); - func = strtok(NULL, ", "); - } -} -/* }}} */ - -/* {{{ PHP_INI_MH - */ -static PHP_INI_MH(OnUpdateTimeout) -{ - EG(timeout_seconds) = atoi(new_value); - if (stage==PHP_INI_STAGE_STARTUP) { - /* Don't set a timeout on startup, only per-request */ - return SUCCESS; - } - zend_unset_timeout(TSRMLS_C); - zend_set_timeout(EG(timeout_seconds)); - return SUCCESS; -} -/* }}} */ - -/* Need to convert to strings and make use of: - * PHP_SAFE_MODE - * - * Need to be read from the environment (?): - * PHP_AUTO_PREPEND_FILE - * PHP_AUTO_APPEND_FILE - * PHP_DOCUMENT_ROOT - * PHP_USER_DIR - * PHP_INCLUDE_PATH - */ - -#ifndef SAFE_MODE_EXEC_DIR -# define SAFE_MODE_EXEC_DIR "/" -#endif - -#ifdef PHP_PROG_SENDMAIL -# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL " -t -i " -#else -# define DEFAULT_SENDMAIL_PATH NULL -#endif -/* {{{ PHP_INI - */ -PHP_INI_BEGIN() - PHP_INI_ENTRY_EX("define_syslog_variables", "0", PHP_INI_ALL, NULL, php_ini_boolean_displayer_cb) - PHP_INI_ENTRY_EX("highlight.bg", HL_BG_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb) - PHP_INI_ENTRY_EX("highlight.comment", HL_COMMENT_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb) - PHP_INI_ENTRY_EX("highlight.default", HL_DEFAULT_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb) - PHP_INI_ENTRY_EX("highlight.html", HL_HTML_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb) - PHP_INI_ENTRY_EX("highlight.keyword", HL_KEYWORD_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb) - PHP_INI_ENTRY_EX("highlight.string", HL_STRING_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb) - - STD_PHP_INI_BOOLEAN("allow_call_time_pass_reference", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, allow_call_time_pass_reference, zend_compiler_globals, compiler_globals) - STD_PHP_INI_BOOLEAN("asp_tags", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, asp_tags, zend_compiler_globals, compiler_globals) - STD_PHP_INI_BOOLEAN("display_errors", "1", PHP_INI_ALL, OnUpdateBool, display_errors, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("display_startup_errors", "0", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("html_errors", "1", PHP_INI_SYSTEM, OnUpdateBool, html_errors, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("xmlrpc_errors", "0", PHP_INI_SYSTEM, OnUpdateBool, xmlrpc_errors, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("xmlrpc_error_number", "0", PHP_INI_ALL, OnUpdateInt, xmlrpc_error_number, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("ignore_user_abort", "0", PHP_INI_ALL, OnUpdateBool, ignore_user_abort, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("implicit_flush", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateBool, implicit_flush, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("log_errors", "0", PHP_INI_ALL, OnUpdateBool, log_errors, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("magic_quotes_gpc", "1", PHP_INI_ALL, OnUpdateBool, magic_quotes_gpc, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("magic_quotes_runtime", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_runtime, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("magic_quotes_sybase", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_sybase, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateBool, output_buffering, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateString, output_handler, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_ALL, OnUpdateBool, register_argc_argv, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("register_globals", "1", PHP_INI_ALL, OnUpdateBool, register_globals, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("safe_mode", "0", PHP_INI_SYSTEM, OnUpdateBool, safe_mode, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("safe_mode_include_dir", NULL, PHP_INI_SYSTEM, OnUpdateString, safe_mode_include_dir, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("safe_mode_gid", "0", PHP_INI_SYSTEM, OnUpdateBool, safe_mode_gid, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("short_open_tag",DEFAULT_SHORT_OPEN_TAG, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, short_tags, zend_compiler_globals, compiler_globals) - STD_PHP_INI_BOOLEAN("sql.safe_mode", "0", PHP_INI_SYSTEM, OnUpdateBool, sql_safe_mode, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals) - STD_PHP_INI_BOOLEAN("y2k_compliance", "0", PHP_INI_ALL, OnUpdateBool, y2k_compliance, php_core_globals, core_globals) - - STD_PHP_INI_ENTRY("arg_separator.output", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator.output, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("arg_separator.input", "&", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateStringUnempty, arg_separator.input, php_core_globals, core_globals) - - STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_ALL, OnUpdateString, auto_append_file, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_ALL, OnUpdateString, auto_prepend_file, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("default_charset", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateString, default_charset, sapi_globals_struct,sapi_globals) - STD_PHP_INI_ENTRY("default_mimetype",SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateString, default_mimetype, sapi_globals_struct,sapi_globals) - STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateString, error_log, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("extension_dir", PHP_EXTENSION_DIR, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, gpc_order, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("include_path", PHP_INCLUDE_PATH, PHP_INI_ALL, OnUpdateStringUnempty, include_path, php_core_globals, core_globals) - PHP_INI_ENTRY("max_execution_time", "30", PHP_INI_ALL, OnUpdateTimeout) - STD_PHP_INI_ENTRY("open_basedir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, open_basedir, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("safe_mode_exec_dir", "1", PHP_INI_SYSTEM, OnUpdateString, safe_mode_exec_dir, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("upload_max_filesize", "2M", PHP_INI_ALL, OnUpdateInt, upload_max_filesize, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("file_uploads", "1", PHP_INI_ALL, OnUpdateBool, file_uploads, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("post_max_size", "8M", PHP_INI_SYSTEM, OnUpdateInt, post_max_size, sapi_globals_struct,sapi_globals) - STD_PHP_INI_ENTRY("upload_tmp_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, upload_tmp_dir, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("user_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, user_dir, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("variables_order", NULL, PHP_INI_ALL, OnUpdateStringUnempty, variables_order, php_core_globals, core_globals) - - STD_PHP_INI_ENTRY("error_append_string", NULL, PHP_INI_ALL, OnUpdateStringUnempty, error_append_string, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("error_prepend_string", NULL, PHP_INI_ALL, OnUpdateStringUnempty, error_prepend_string, php_core_globals, core_globals) - - PHP_INI_ENTRY("SMTP", "localhost",PHP_INI_ALL, NULL) - PHP_INI_ENTRY("browscap", NULL, PHP_INI_SYSTEM, NULL) - PHP_INI_ENTRY("error_reporting", NULL, PHP_INI_ALL, OnUpdateErrorReporting) -#if MEMORY_LIMIT - PHP_INI_ENTRY("memory_limit", "8M", PHP_INI_ALL, OnChangeMemoryLimit) -#endif - PHP_INI_ENTRY("precision", "14", PHP_INI_ALL, OnSetPrecision) - PHP_INI_ENTRY("sendmail_from", NULL, PHP_INI_ALL, NULL) - PHP_INI_ENTRY("sendmail_path", DEFAULT_SENDMAIL_PATH, PHP_INI_SYSTEM, NULL) - PHP_INI_ENTRY("disable_functions", "", PHP_INI_SYSTEM, NULL) - - STD_PHP_INI_ENTRY("allow_url_fopen", "1", PHP_INI_ALL, OnUpdateBool, allow_url_fopen, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("always_populate_raw_post_data", "0", PHP_INI_ALL, OnUpdateBool, always_populate_raw_post_data, php_core_globals, core_globals) - -PHP_INI_END() -/* }}} */ - -/* True global (no need for thread safety */ -static int module_initialized = 0; - -/* {{{ php_log_err - */ -PHPAPI void php_log_err(char *log_message TSRMLS_DC) -{ - FILE *log_file; - char error_time_str[128]; - struct tm tmbuf; - time_t error_time; - - /* Try to use the specified logging location. */ - if (PG(error_log) != NULL) { -#ifdef HAVE_SYSLOG_H - if (!strcmp(PG(error_log), "syslog")) { - php_syslog(LOG_NOTICE, "%.500s", log_message); - return; - } -#endif - log_file = VCWD_FOPEN(PG(error_log), "a"); - if (log_file != NULL) { - time(&error_time); - strftime(error_time_str, 128, "%d-%b-%Y %H:%M:%S", php_localtime_r(&error_time, &tmbuf)); - fprintf(log_file, "[%s] ", error_time_str); - fprintf(log_file, "%s", log_message); - fprintf(log_file, "\n"); - fclose(log_file); - return; - } - } - - /* Otherwise fall back to the default logging location, if we have one */ - - if (sapi_module.log_message) { - sapi_module.log_message(log_message); - } -} -/* }}} */ - -/* is 4K big enough? */ -#define PRINTF_BUFFER_SIZE 1024*4 - -/* {{{ php_write - wrapper for modules to use PHPWRITE */ -PHPAPI int php_write(void *buf, uint size TSRMLS_DC) -{ - return PHPWRITE(buf, size); -} -/* }}} */ - -/* {{{ php_printf - */ -PHPAPI int php_printf(const char *format, ...) -{ - va_list args; - int ret; - char buffer[PRINTF_BUFFER_SIZE]; - int size; - TSRMLS_FETCH(); - - va_start(args, format); - size = vsnprintf(buffer, sizeof(buffer), format, args); - if(size > sizeof(buffer) - 1) { - size = sizeof(buffer) - 1; - } - ret = PHPWRITE(buffer, size); - va_end(args); - - return ret; -} -/* }}} */ - -/* {{{ php_error_cb - extended error handling function */ -static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) -{ - char buffer[1024]; - int buffer_len; - TSRMLS_FETCH(); - - buffer_len = vsnprintf(buffer, sizeof(buffer)-1, format, args); - buffer[sizeof(buffer)-1]=0; - if(buffer_len > sizeof(buffer) - 1 || buffer_len < 0) { - buffer_len = sizeof(buffer) - 1; - } - - /* display/log the error if necessary */ - if ((EG(error_reporting) & type || (type & E_CORE)) - && (PG(log_errors) || PG(display_errors) || (!module_initialized))) { - char *error_type_str; - - switch (type) { - case E_ERROR: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - case E_USER_ERROR: - error_type_str = "Fatal error"; - break; - case E_WARNING: - case E_CORE_WARNING: - case E_COMPILE_WARNING: - case E_USER_WARNING: - error_type_str = "Warning"; - break; - case E_PARSE: - error_type_str = "Parse error"; - break; - case E_NOTICE: - error_type_str = "Warning"; - break; - case E_USER_NOTICE: - error_type_str = "Notice"; - break; - default: - error_type_str = "Unknown error"; - break; - } - - if (!module_initialized || PG(log_errors)) { - char log_buffer[1024]; - -#ifdef PHP_WIN32 - if (type==E_CORE_ERROR || type==E_CORE_WARNING) { - MessageBox(NULL, buffer, error_type_str, MB_OK|ZEND_SERVICE_MB_STYLE); - } -#endif - snprintf(log_buffer, 1024, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno); - php_log_err(log_buffer TSRMLS_CC); - } - if (module_initialized && PG(display_errors) - && (!PG(during_request_startup) || PG(display_startup_errors))) { - char *prepend_string = INI_STR("error_prepend_string"); - char *append_string = INI_STR("error_append_string"); - char *error_format; - - error_format = PG(html_errors) ? - "<br>\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br>\n" - : "\n%s: %s in %s on line %d\n"; - if (PG(xmlrpc_errors)) { - error_format = do_alloca(1024); - snprintf(error_format, 1023, "<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>%ld</int></value></member><member><name>faultString</name><value><string>%%s:%%s in %%s on line %%d</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number)); - } - - if (prepend_string) { - PUTS(prepend_string); - } - php_printf(error_format, error_type_str, buffer, - error_filename, error_lineno); - if (PG(xmlrpc_errors)) { - free_alloca(error_format); - } - - if (append_string) { - PUTS(append_string); - } - } -#if ZEND_DEBUG - { - zend_bool trigger_break; - - switch (type) { - case E_ERROR: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - case E_USER_ERROR: - trigger_break=1; - break; - default: - trigger_break=0; - break; - } - zend_output_debug_string(trigger_break, "%s(%d) : %s - %s", error_filename, error_lineno, error_type_str, buffer); - } -#endif - } - - /* Bail out if we can't recover */ - switch (type) { - case E_CORE_ERROR: - if(!module_initialized) { - /* bad error in module startup - no way we can live with this */ - exit(-2); - } - /* no break - intentionally */ - case E_ERROR: - /*case E_PARSE: the parser would return 1 (failure), we can bail out nicely */ - case E_COMPILE_ERROR: - case E_USER_ERROR: - if (module_initialized) { - zend_bailout(); - return; - } - break; - } - - /* Log if necessary */ - if (PG(track_errors) && EG(active_symbol_table)) { - pval *tmp; - - ALLOC_ZVAL(tmp); - INIT_PZVAL(tmp); - tmp->value.str.val = (char *) estrndup(buffer, buffer_len); - tmp->value.str.len = buffer_len; - tmp->type = IS_STRING; - zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(pval *), NULL); - } -} -/* }}} */ - -/* {{{ proto void set_time_limit(int seconds) - Sets the maximum time a script can run */ -PHP_FUNCTION(set_time_limit) -{ - zval **new_timeout; - - if (PG(safe_mode)) { - php_error(E_WARNING, "Cannot set time limit in safe mode"); - RETURN_FALSE; - } - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &new_timeout) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_long_ex(new_timeout); - zend_unset_timeout(TSRMLS_C); - zend_set_timeout(Z_LVAL_PP(new_timeout)); -} -/* }}} */ - -/* {{{ php_fopen_wrapper_for_zend - */ -static FILE *php_fopen_wrapper_for_zend(const char *filename, char **opened_path) -{ - int issock=0, socketd=0; - int old_chunk_size; - FILE *retval; - TSRMLS_FETCH(); - - old_chunk_size = php_sock_set_def_chunk_size(1); - retval=php_fopen_wrapper((char *) filename, "rb", USE_PATH|IGNORE_URL_WIN, &issock, &socketd, opened_path TSRMLS_CC); - php_sock_set_def_chunk_size(old_chunk_size); - - if (issock) { - retval = fdopen(socketd, "rb"); - } - return retval; -} -/* }}} */ - -/* {{{ php_get_configuration_directive_for_zend - */ -static int php_get_configuration_directive_for_zend(char *name, uint name_length, zval *contents) -{ - zval *retval = cfg_get_entry(name, name_length); - - if (retval) { - *contents = *retval; - return SUCCESS; - } else { - return FAILURE; - } -} -/* }}} */ - -/* {{{ php_message_handler_for_zend - */ -static void php_message_handler_for_zend(long message, void *data) -{ - switch (message) { - case ZMSG_FAILED_INCLUDE_FOPEN: { - TSRMLS_FETCH(); - - php_error(E_WARNING, "Failed opening '%s' for inclusion (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path))); - } - break; - case ZMSG_FAILED_REQUIRE_FOPEN: { - TSRMLS_FETCH(); - - php_error(E_COMPILE_ERROR, "Failed opening required '%s' (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path))); - } - break; - case ZMSG_FAILED_HIGHLIGHT_FOPEN: - php_error(E_WARNING, "Failed opening '%s' for highlighting", php_strip_url_passwd((char *) data)); - break; - case ZMSG_MEMORY_LEAK_DETECTED: - case ZMSG_MEMORY_LEAK_REPEATED: { - TSRMLS_FETCH(); - - if (EG(error_reporting)&E_WARNING) { -#if ZEND_DEBUG - char memory_leak_buf[512]; - - if (message==ZMSG_MEMORY_LEAK_DETECTED) { - zend_mem_header *t = (zend_mem_header *) data; - void *ptr = (void *)((char *)t+sizeof(zend_mem_header)+MEM_HEADER_PADDING); - - snprintf(memory_leak_buf, 512, "%s(%d) : Freeing 0x%.8lX (%d bytes), script=%s\n", t->filename, t->lineno, (unsigned long)ptr, t->size, SAFE_FILENAME(SG(request_info).path_translated)); - if (t->orig_filename) { - char relay_buf[512]; - - snprintf(relay_buf, 512, "%s(%d) : Actual location (location was relayed)\n", t->orig_filename, t->orig_lineno); - strcat(memory_leak_buf, relay_buf); - } - } else { - unsigned long leak_count = (unsigned long) data; - - snprintf(memory_leak_buf, 512, "Last leak repeated %ld time%s\n", leak_count, (leak_count>1?"s":"")); - } -# if defined(PHP_WIN32) - OutputDebugString(memory_leak_buf); -# else - fprintf(stderr, memory_leak_buf); -# endif -#endif - } - } - break; - case ZMSG_LOG_SCRIPT_NAME: { - struct tm *ta, tmbuf; - time_t curtime; - char *datetime_str, asctimebuf[52]; - TSRMLS_FETCH(); - - time(&curtime); - ta = php_localtime_r(&curtime, &tmbuf); - datetime_str = php_asctime_r(ta, asctimebuf); - datetime_str[strlen(datetime_str)-1]=0; /* get rid of the trailing newline */ - fprintf(stderr, "[%s] Script: '%s'\n", datetime_str, SAFE_FILENAME(SG(request_info).path_translated)); - } - break; - } -} -/* }}} */ - -#if PHP_SIGCHILD -/* {{{ sigchld_handler - */ -static void sigchld_handler(int apar) -{ - while (waitpid(-1, NULL, WNOHANG) > 0) - ; - signal(SIGCHLD, sigchld_handler); -} -/* }}} */ -#endif - -static int php_hash_environment(TSRMLS_D); - -/* {{{ php_request_startup - */ -int php_request_startup(TSRMLS_D) -{ - int retval = SUCCESS; - -#if PHP_SIGCHILD - signal(SIGCHLD, sigchld_handler); -#endif - - zend_try { - PG(during_request_startup) = 1; - - php_output_activate(TSRMLS_C); - - /* initialize global variables */ - PG(modules_activated) = 0; - PG(header_is_being_sent) = 0; - PG(connection_status) = PHP_CONNECTION_NORMAL; - - zend_activate(TSRMLS_C); - sapi_activate(TSRMLS_C); - - zend_set_timeout(EG(timeout_seconds)); - - if (PG(expose_php)) { - sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1); - } - - if (PG(output_handler) && PG(output_handler)[0]) { - zval *output_handler; - - ALLOC_INIT_ZVAL(output_handler); - Z_STRLEN_P(output_handler) = strlen(PG(output_handler)); /* this can be optimized */ - Z_STRVAL_P(output_handler) = estrndup(PG(output_handler), Z_STRLEN_P(output_handler)); - Z_TYPE_P(output_handler) = IS_STRING; - php_start_ob_buffer(output_handler, 0 TSRMLS_CC); - } else if (PG(output_buffering)) { - php_start_ob_buffer(NULL, 0 TSRMLS_CC); - } else if (PG(implicit_flush)) { - php_start_implicit_flush(TSRMLS_C); - } - - /* We turn this off in php_execute_script() */ - /* PG(during_request_startup) = 0; */ - - php_hash_environment(TSRMLS_C); - zend_activate_modules(TSRMLS_C); - PG(modules_activated)=1; - } zend_catch { - retval = FAILURE; - } zend_end_try(); - - return retval; -} -/* }}} */ - -/* {{{ php_request_shutdown_for_exec - */ -void php_request_shutdown_for_exec(void *dummy) -{ - /* used to close fd's in the 3..255 range here, but it's problematic - */ - shutdown_memory_manager(1, 1); -} -/* }}} */ - -/* {{{ php_request_shutdown - */ -void php_request_shutdown(void *dummy) -{ - TSRMLS_FETCH(); - - zend_try { - php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1) TSRMLS_CC); - } zend_end_try(); - - zend_try { - sapi_send_headers(TSRMLS_C); - } zend_end_try(); - - if (PG(modules_activated)) zend_try { - php_call_shutdown_functions(); - } zend_end_try(); - - if (PG(modules_activated)) { - zend_deactivate_modules(TSRMLS_C); - } - - zend_deactivate(TSRMLS_C); - - zend_try { - sapi_deactivate(TSRMLS_C); - } zend_end_try(); - - zend_try { - shutdown_memory_manager(CG(unclean_shutdown), 0); - } zend_end_try(); - - zend_try { - zend_unset_timeout(TSRMLS_C); - } zend_end_try(); -} -/* }}} */ - - -/* {{{ php_body_write_wrapper - */ -static int php_body_write_wrapper(const char *str, uint str_length) -{ - TSRMLS_FETCH(); - return php_body_write(str, str_length TSRMLS_CC); -} -/* }}} */ - -#ifdef ZTS -/* {{{ core_globals_ctor - */ -static void core_globals_ctor(php_core_globals *core_globals TSRMLS_DC) -{ - memset(core_globals, 0, sizeof(*core_globals)); -} -/* }}} */ -#endif - -/* {{{ php_startup_extensions - */ -int php_startup_extensions(zend_module_entry **ptr, int count) -{ - zend_module_entry **end = ptr+count; - - while (ptr < end) { - if (*ptr) { - if (zend_startup_module(*ptr)==FAILURE) { - return FAILURE; - } - } - ptr++; - } - return SUCCESS; -} -/* }}} */ - - -/* {{{ php_module_startup - */ -int php_module_startup(sapi_module_struct *sf) -{ - zend_utility_functions zuf; - zend_utility_values zuv; - int module_number=0; /* for REGISTER_INI_ENTRIES() */ - char *php_os; -#ifdef ZTS - zend_executor_globals *executor_globals; - void ***tsrm_ls; - - php_core_globals *core_globals; - sapi_globals_struct *sapi_globals = ts_resource(sapi_globals_id); -#endif -#ifdef PHP_WIN32 - WORD wVersionRequested = MAKEWORD(2, 0); - WSADATA wsaData; -#endif -#ifdef PHP_WIN32 - { - DWORD dwVersion = GetVersion(); - - /* Get build numbers for Windows NT or Win95 */ - if (dwVersion < 0x80000000){ - php_os="WINNT"; - } else { - php_os="WIN32"; - } - } -#else - php_os=PHP_OS; -#endif - -#ifdef ZTS - tsrm_ls = ts_resource(0); -#endif - - sapi_initialize_empty_request(TSRMLS_C); - sapi_activate(TSRMLS_C); - - if (module_initialized) { - return SUCCESS; - } - - sapi_module = *sf; - - php_output_startup(); - php_output_activate(TSRMLS_C); - - zuf.error_function = php_error_cb; - zuf.printf_function = php_printf; - zuf.write_function = php_body_write_wrapper; - zuf.fopen_function = php_fopen_wrapper_for_zend; - zuf.message_handler = php_message_handler_for_zend; - zuf.block_interruptions = sapi_module.block_interruptions; - zuf.unblock_interruptions = sapi_module.unblock_interruptions; - zuf.get_configuration_directive = php_get_configuration_directive_for_zend; - zuf.ticks_function = php_run_ticks; - zend_startup(&zuf, NULL, 1); - -#ifdef ZTS - executor_globals = ts_resource(executor_globals_id); - ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, NULL); - core_globals = ts_resource(core_globals_id); -#endif - EG(bailout_set) = 0; - EG(error_reporting) = E_ALL & ~E_NOTICE; - - PG(header_is_being_sent) = 0; - SG(request_info).headers_only = 0; - SG(request_info).argv0 = NULL; - PG(connection_status) = PHP_CONNECTION_NORMAL; - PG(during_request_startup) = 0; - -#if HAVE_SETLOCALE - setlocale(LC_CTYPE, ""); -#endif - -#ifdef PHP_WIN32 - /* start up winsock services */ - if (WSAStartup(wVersionRequested, &wsaData) != 0) { - php_printf("\nwinsock.dll unusable. %d\n", WSAGetLastError()); - return FAILURE; - } -#endif - - le_index_ptr = zend_register_list_destructors_ex(NULL, NULL, "index pointer", 0); - - - /* this will read in php.ini, set up the configuration parameters, - load zend extensions and register php function extensions - to be loaded later */ - if (php_init_config(sf->php_ini_path_override) == FAILURE) { - return FAILURE; - } - - REGISTER_INI_ENTRIES(); - - /* initialize fopen wrappers registry - (this uses configuration parameters from php.ini) - */ - if (php_init_fopen_wrappers(TSRMLS_C) == FAILURE) { - php_printf("PHP: Unable to initialize fopen url wrappers.\n"); - return FAILURE; - } - - /* initialize registry for images to be used in phpinfo() - (this uses configuration parameters from php.ini) - */ - if (php_init_info_logos() == FAILURE) { - php_printf("PHP: Unable to initialize info phpinfo logos.\n"); - return FAILURE; - } - - zuv.import_use_extension = ".php"; - zend_set_utility_values(&zuv); - php_startup_sapi_content_types(); - - REGISTER_MAIN_STRINGL_CONSTANT("PHP_VERSION", PHP_VERSION, sizeof(PHP_VERSION)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os), CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("DEFAULT_INCLUDE_PATH", PHP_INCLUDE_PATH, sizeof(PHP_INCLUDE_PATH)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PEAR_INSTALL_DIR", PEAR_INSTALLDIR, sizeof(PEAR_INSTALLDIR)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PEAR_EXTENSION_DIR", PHP_EXTENSION_DIR, sizeof(PHP_EXTENSION_DIR)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PHP_EXTENSION_DIR", PHP_EXTENSION_DIR, sizeof(PHP_EXTENSION_DIR)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PHP_BINDIR", PHP_BINDIR, sizeof(PHP_BINDIR)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PHP_LIBDIR", PHP_LIBDIR, sizeof(PHP_LIBDIR)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PHP_DATADIR", PHP_DATADIR, sizeof(PHP_DATADIR)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PHP_SYSCONFDIR", PHP_SYSCONFDIR, sizeof(PHP_SYSCONFDIR)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PHP_LOCALSTATEDIR", PHP_LOCALSTATEDIR, sizeof(PHP_LOCALSTATEDIR)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_PATH", PHP_CONFIG_FILE_PATH, sizeof(PHP_CONFIG_FILE_PATH)-1, CONST_PERSISTENT | CONST_CS); - php_output_register_constants(TSRMLS_C); - - if (php_startup_ticks(TSRMLS_C) == FAILURE) { - php_printf("Unable to start PHP ticks\n"); - return FAILURE; - } - - /* startup extensions staticly compiled in */ - if (php_startup_internal_extensions() == FAILURE) { - php_printf("Unable to start builtin modules\n"); - return FAILURE; - } - - /* load and startup extensions compiled as shared objects (aka DLLs) - as requested by php.ini entries - theese are loaded after initialization of internal extensions - as extensions *might* rely on things from ext/standard - which is always an internal extension and to be initialized - ahead of all other internals - */ - php_ini_delayed_modules_startup(TSRMLS_C); - - /* disable certain functions as requested by php.ini */ - php_disable_functions(TSRMLS_C); - - zend_startup_extensions(); - - /* */ - module_initialized = 1; - sapi_deactivate(TSRMLS_C); - - /* we're done */ - return SUCCESS; -} -/* }}} */ - -void php_module_shutdown_for_exec() -{ - /* used to close fd's in the range 3.255 here, but it's problematic */ -} - -/* {{{ php_module_shutdown_wrapper - */ -int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals) -{ - TSRMLS_FETCH(); - php_module_shutdown(TSRMLS_C); - return SUCCESS; -} -/* }}} */ - -/* {{{ php_module_shutdown - */ -void php_module_shutdown(TSRMLS_D) -{ - int module_number=0; /* for UNREGISTER_INI_ENTRIES() */ - - if (!module_initialized) { - return; - } - - /* close down the ini config */ - php_shutdown_config(); - -#ifdef PHP_WIN32 - /*close winsock */ - WSACleanup(); -#endif - - php_shutdown_ticks(TSRMLS_C); - sapi_flush(TSRMLS_C); - - zend_shutdown(TSRMLS_C); - php_shutdown_fopen_wrappers(TSRMLS_C); - php_shutdown_info_logos(); - UNREGISTER_INI_ENTRIES(); -#ifdef ZTS - ts_free_thread(); -#else - zend_ini_shutdown(TSRMLS_C); - shutdown_memory_manager(0, 1); -#endif - module_initialized = 0; -} -/* }}} */ - -/* {{{ php_register_server_variables - */ -static inline void php_register_server_variables(TSRMLS_D) -{ - zval *array_ptr=NULL; - - ALLOC_ZVAL(array_ptr); - array_init(array_ptr); - INIT_PZVAL(array_ptr); - PG(http_globals)[TRACK_VARS_SERVER] = array_ptr; - - /* Server variables */ - if (sapi_module.register_server_variables) { - sapi_module.register_server_variables(array_ptr TSRMLS_CC); - } - - /* argv/argc support */ - if (PG(register_argc_argv)) { - php_build_argv(SG(request_info).query_string, array_ptr TSRMLS_CC); - } - - /* PHP Authentication support */ - if (SG(request_info).auth_user) { - php_register_variable("PHP_AUTH_USER", SG(request_info).auth_user, array_ptr TSRMLS_CC); - } - if (SG(request_info).auth_password) { - php_register_variable("PHP_AUTH_PW", SG(request_info).auth_password, array_ptr TSRMLS_CC); - } -} -/* }}} */ - -/* {{{ php_hash_environment - */ -static int php_hash_environment(TSRMLS_D) -{ - char *p; - unsigned char _gpc_flags[3] = {0, 0, 0}; - zend_bool have_variables_order; - zval *dummy_track_vars_array; - zend_bool initialized_dummy_track_vars_array=0; - int i; - char *track_vars_names[] = { - "HTTP_POST_VARS", - "HTTP_GET_VARS", - "HTTP_COOKIE_VARS", - "HTTP_SERVER_VARS", - "HTTP_ENV_VARS", - "HTTP_POST_FILES", - NULL - }; - int track_vars_names_length[] = { - sizeof("HTTP_POST_VARS"), - sizeof("HTTP_GET_VARS"), - sizeof("HTTP_COOKIE_VARS"), - sizeof("HTTP_SERVER_VARS"), - sizeof("HTTP_ENV_VARS"), - sizeof("HTTP_POST_FILES") - }; - - - for (i=0; i<6; i++) { - PG(http_globals)[i] = NULL; - } - - if (PG(variables_order)) { - p = PG(variables_order); - have_variables_order=1; - } else { - p = PG(gpc_order); - have_variables_order=0; - ALLOC_ZVAL(PG(http_globals)[TRACK_VARS_ENV]); - array_init(PG(http_globals)[TRACK_VARS_ENV]); - INIT_PZVAL(PG(http_globals)[TRACK_VARS_ENV]); - php_import_environment_variables(PG(http_globals)[TRACK_VARS_ENV] TSRMLS_CC); - } - - while(p && *p) { - switch(*p++) { - case 'p': - case 'P': - if (!_gpc_flags[0] && !SG(headers_sent) && SG(request_info).request_method && !strcasecmp(SG(request_info).request_method, "POST")) { - php_treat_data(PARSE_POST, NULL, NULL TSRMLS_CC); /* POST Data */ - _gpc_flags[0]=1; - } - break; - case 'c': - case 'C': - if (!_gpc_flags[1]) { - php_treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC); /* Cookie Data */ - _gpc_flags[1]=1; - } - break; - case 'g': - case 'G': - if (!_gpc_flags[2]) { - php_treat_data(PARSE_GET, NULL, NULL TSRMLS_CC); /* GET Data */ - _gpc_flags[2]=1; - } - break; - case 'e': - case 'E': - if (have_variables_order) { - ALLOC_ZVAL(PG(http_globals)[TRACK_VARS_ENV]); - array_init(PG(http_globals)[TRACK_VARS_ENV]); - INIT_PZVAL(PG(http_globals)[TRACK_VARS_ENV]); - php_import_environment_variables(PG(http_globals)[TRACK_VARS_ENV] TSRMLS_CC); - } else { - php_error(E_WARNING, "Unsupported 'e' element (environment) used in gpc_order - use variables_order instead"); - } - break; - case 's': - case 'S': - php_register_server_variables(TSRMLS_C); - break; - } - } - - if (!have_variables_order) { - php_register_server_variables(TSRMLS_C); - } - - for (i=0; i<6; i++) { - if (!PG(http_globals)[i]) { - if (!initialized_dummy_track_vars_array) { - ALLOC_ZVAL(dummy_track_vars_array); - array_init(dummy_track_vars_array); - INIT_PZVAL(dummy_track_vars_array); - initialized_dummy_track_vars_array = 1; - } else { - dummy_track_vars_array->refcount++; - } - PG(http_globals)[i] = dummy_track_vars_array; - } - zend_hash_update(&EG(symbol_table), track_vars_names[i], track_vars_names_length[i], &PG(http_globals)[i], sizeof(zval *), NULL); - } - return SUCCESS; -} -/* }}} */ - -/* {{{ php_build_argv - */ -static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC) -{ - pval *arr, *argc, *tmp; - int count = 0; - char *ss, *space; - - ALLOC_ZVAL(arr); - array_init(arr); - INIT_PZVAL(arr); - - /* Prepare argv */ - if (s && *s) { - ss = s; - while (ss) { - space = strchr(ss, '+'); - if (space) { - *space = '\0'; - } - /* auto-type */ - ALLOC_ZVAL(tmp); - tmp->type = IS_STRING; - tmp->value.str.len = strlen(ss); - tmp->value.str.val = estrndup(ss, tmp->value.str.len); - INIT_PZVAL(tmp); - count++; - if (zend_hash_next_index_insert(arr->value.ht, &tmp, sizeof(pval *), NULL)==FAILURE) { - if (tmp->type == IS_STRING) { - efree(tmp->value.str.val); - } - } - if (space) { - *space = '+'; - ss = space + 1; - } else { - ss = space; - } - } - } - - /* prepare argc */ - ALLOC_ZVAL(argc); - argc->value.lval = count; - argc->type = IS_LONG; - INIT_PZVAL(argc); - - if (PG(register_globals)) { - arr->refcount++; - argc->refcount++; - zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL); - zend_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL); - } - - zend_hash_update(track_vars_array->value.ht, "argv", sizeof("argv"), &arr, sizeof(pval *), NULL); - zend_hash_update(track_vars_array->value.ht, "argc", sizeof("argc"), &argc, sizeof(pval *), NULL); -} -/* }}} */ - -/* {{{ php_handle_special_queries - */ -PHPAPI int php_handle_special_queries(TSRMLS_D) -{ - if (SG(request_info).query_string && SG(request_info).query_string[0]=='=' - && PG(expose_php)) { - if (php_info_logos(SG(request_info).query_string+1 TSRMLS_CC)) { - return 1; - } else if (!strcmp(SG(request_info).query_string+1, PHP_CREDITS_GUID)) { - php_print_credits(PHP_CREDITS_ALL); - return 1; - } - } - return 0; -} -/* }}} */ - -/* {{{ php_execute_script - */ -PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC) -{ - zend_file_handle *prepend_file_p, *append_file_p; - zend_file_handle prepend_file, append_file; - char *old_cwd; - - EG(exit_status) = 0; - if (php_handle_special_queries(TSRMLS_C)) { - return 0; - } -#define OLD_CWD_SIZE 4096 - old_cwd = do_alloca(OLD_CWD_SIZE); - old_cwd[0] = '\0'; - - zend_try { -#ifdef PHP_WIN32 - UpdateIniFromRegistry(primary_file->filename TSRMLS_CC); -#endif - - PG(during_request_startup) = 0; - - if (primary_file->type == ZEND_HANDLE_FILENAME - && primary_file->filename) { - VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1); - VCWD_CHDIR_FILE(primary_file->filename); - } - - if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) { - prepend_file.filename = PG(auto_prepend_file); - prepend_file.opened_path = NULL; - prepend_file.free_filename = 0; - prepend_file.type = ZEND_HANDLE_FILENAME; - prepend_file_p = &prepend_file; - } else { - prepend_file_p = NULL; - } - if (PG(auto_append_file) && PG(auto_append_file)[0]) { - append_file.filename = PG(auto_append_file); - append_file.opened_path = NULL; - append_file.free_filename = 0; - append_file.type = ZEND_HANDLE_FILENAME; - append_file_p = &append_file; - } else { - append_file_p = NULL; - } - zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, 3, prepend_file_p, primary_file, append_file_p); - } zend_end_try(); - - if (old_cwd[0] != '\0') { - VCWD_CHDIR(old_cwd); - } - free_alloca(old_cwd); - return EG(exit_status); -} -/* }}} */ - -/* {{{ php_handle_aborted_connection - */ -PHPAPI void php_handle_aborted_connection(void) -{ - TSRMLS_FETCH(); - - PG(connection_status) = PHP_CONNECTION_ABORTED; - php_output_set_status(0 TSRMLS_CC); - - if (!PG(ignore_user_abort)) { - zend_bailout(); - } -} -/* }}} */ - -/* {{{ php_handle_auth_data - */ -PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC) -{ - int ret = -1; - - if (auth && auth[0] != '\0' - && strncmp(auth, "Basic ", 6) == 0) { - char *pass; - char *user; - - user = php_base64_decode(auth + 6, strlen(auth) - 6, NULL); - if (user) { - pass = strchr(user, ':'); - if (pass) { - *pass++ = '\0'; - SG(request_info).auth_user = user; - SG(request_info).auth_password = estrdup(pass); - ret = 0; - } else { - efree(user); - } - } - } - - if (ret == -1) - SG(request_info).auth_user = SG(request_info).auth_password = NULL; - - return ret; -} -/* }}} */ - -/* {{{ php_lint_script - */ -PHPAPI int php_lint_script(zend_file_handle *file TSRMLS_DC) -{ - zend_op_array *op_array; - - zend_try { - op_array = zend_compile_file(file, ZEND_INCLUDE TSRMLS_CC); - zend_destroy_file_handle(file TSRMLS_CC); - - if (op_array) { - destroy_op_array(op_array); - efree(op_array); - return SUCCESS; - } else { - return FAILURE; - } - } zend_end_try(); - - return FAILURE; -} -/* }}} */ - -#ifdef PHP_WIN32 -/* {{{ dummy_indent - just so that this symbol gets exported... */ -PHPAPI void dummy_indent() -{ - zend_indent(); -} -/* }}} */ -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/mergesort.c b/main/mergesort.c deleted file mode 100644 index 73c65c5100..0000000000 --- a/main/mergesort.c +++ /dev/null @@ -1,356 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Peter McIlroy. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)merge.c 8.2 (Berkeley) 2/14/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Hybrid exponential search/linear search merge sort with hybrid - * natural/pairwise first pass. Requires about .3% more comparisons - * for random data than LSMS with pairwise first pass alone. - * It works for objects as small as two bytes. - */ - -#define NATURAL -#define THRESHOLD 16 /* Best choice for natural merge cut-off. */ - -/* #define NATURAL to get hybrid natural merge. - * (The default is pairwise merging.) - */ - -#include <sys/types.h> - -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -#include "php.h" - -#ifdef PHP_WIN32 -#include <winsock.h> /* Includes definition for u_char */ -#endif - -static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void *)); -static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void *)); - -#define ISIZE sizeof(int) -#define PSIZE sizeof(u_char *) -#define ICOPY_LIST(src, dst, last) \ - do \ - *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE; \ - while(src < last) -#define ICOPY_ELT(src, dst, i) \ - do \ - *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE; \ - while (i -= ISIZE) - -#define CCOPY_LIST(src, dst, last) \ - do \ - *dst++ = *src++; \ - while (src < last) -#define CCOPY_ELT(src, dst, i) \ - do \ - *dst++ = *src++; \ - while (i -= 1) - -/* - * Find the next possible pointer head. (Trickery for forcing an array - * to do double duty as a linked list when objects do not align with word - * boundaries. - */ -/* Assumption: PSIZE is a power of 2. */ -#define EVAL(p) (u_char **) \ - ((u_char *)0 + \ - (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1))) - -/* {{{ php_mergesort - * Arguments are as for qsort. - */ -int php_mergesort(void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void *)) -{ - register unsigned int i; - register int sense; - int big, iflag; - register u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2; - u_char *list2, *list1, *p2, *p, *last, **p1; - - if (size < PSIZE / 2) { /* Pointers must fit into 2 * size. */ - errno = EINVAL; - return (-1); - } - - if (nmemb == 0) - return (0); - - /* - * XXX - * Stupid subtraction for the Cray. - */ - iflag = 0; - if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE)) - iflag = 1; - - if ((list2 = malloc(nmemb * size + PSIZE)) == NULL) - return (-1); - - list1 = base; - setup(list1, list2, nmemb, size, cmp); - last = list2 + nmemb * size; - i = big = 0; - while (*EVAL(list2) != last) { - l2 = list1; - p1 = EVAL(list1); - for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) { - p2 = *EVAL(p2); - f1 = l2; - f2 = l1 = list1 + (p2 - list2); - if (p2 != last) - p2 = *EVAL(p2); - l2 = list1 + (p2 - list2); - while (f1 < l1 && f2 < l2) { - if ((*cmp)(f1, f2) <= 0) { - q = f2; - b = f1, t = l1; - sense = -1; - } else { - q = f1; - b = f2, t = l2; - sense = 0; - } - if (!big) { /* here i = 0 */ - while ((b += size) < t && cmp(q, b) >sense) - if (++i == 6) { - big = 1; - goto EXPONENTIAL; - } - } else { -EXPONENTIAL: for (i = size; ; i <<= 1) - if ((p = (b + i)) >= t) { - if ((p = t - size) > b && - (*cmp)(q, p) <= sense) - t = p; - else - b = p; - break; - } else if ((*cmp)(q, p) <= sense) { - t = p; - if (i == size) - big = 0; - goto FASTCASE; - } else - b = p; - while (t > b+size) { - i = (((t - b) / size) >> 1) * size; - if ((*cmp)(q, p = b + i) <= sense) - t = p; - else - b = p; - } - goto COPY; -FASTCASE: while (i > size) - if ((*cmp)(q, - p = b + (i >>= 1)) <= sense) - t = p; - else - b = p; -COPY: b = t; - } - i = size; - if (q == f1) { - if (iflag) { - ICOPY_LIST(f2, tp2, b); - ICOPY_ELT(f1, tp2, i); - } else { - CCOPY_LIST(f2, tp2, b); - CCOPY_ELT(f1, tp2, i); - } - } else { - if (iflag) { - ICOPY_LIST(f1, tp2, b); - ICOPY_ELT(f2, tp2, i); - } else { - CCOPY_LIST(f1, tp2, b); - CCOPY_ELT(f2, tp2, i); - } - } - } - if (f2 < l2) { - if (iflag) - ICOPY_LIST(f2, tp2, l2); - else - CCOPY_LIST(f2, tp2, l2); - } else if (f1 < l1) { - if (iflag) - ICOPY_LIST(f1, tp2, l1); - else - CCOPY_LIST(f1, tp2, l1); - } - *p1 = l2; - } - tp2 = list1; /* swap list1, list2 */ - list1 = list2; - list2 = tp2; - last = list2 + nmemb*size; - } - if (base == list2) { - memmove(list2, list1, nmemb*size); - list2 = list1; - } - free(list2); - return (0); -} -/* }}} */ - -#define swap(a, b) { \ - s = b; \ - i = size; \ - do { \ - tmp = *a; *a++ = *s; *s++ = tmp; \ - } while (--i); \ - a -= size; \ - } -#define reverse(bot, top) { \ - s = top; \ - do { \ - i = size; \ - do { \ - tmp = *bot; *bot++ = *s; *s++ = tmp; \ - } while (--i); \ - s -= size2; \ - } while(bot < s); \ -} - -/* {{{ setup - * Optional hybrid natural/pairwise first pass. Eats up list1 in runs of - * increasing order, list2 in a corresponding linked list. Checks for runs - * when THRESHOLD/2 pairs compare with same sense. (Only used when NATURAL - * is defined. Otherwise simple pairwise merging is used.) - */ -static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void *)) -{ - int i, length, size2, tmp, sense; - u_char *f1, *f2, *s, *l2, *last, *p2; - - size2 = size*2; - if (n <= 5) { - insertionsort(list1, n, size, cmp); - *EVAL(list2) = (u_char*) list2 + n*size; - return; - } - /* - * Avoid running pointers out of bounds; limit n to evens - * for simplicity. - */ - i = 4 + (n & 1); - insertionsort(list1 + (n - i) * size, i, size, cmp); - last = list1 + size * (n - i); - *EVAL(list2 + (last - list1)) = list2 + n * size; - -#ifdef NATURAL - p2 = list2; - f1 = list1; - sense = (cmp(f1, f1 + size) > 0); - for (; f1 < last; sense = !sense) { - length = 2; - /* Find pairs with same sense. */ - for (f2 = f1 + size2; f2 < last; f2 += size2) { - if ((cmp(f2, f2+ size) > 0) != sense) - break; - length += 2; - } - if (length < THRESHOLD) { /* Pairwise merge */ - do { - p2 = *EVAL(p2) = f1 + size2 - list1 + list2; - if (sense > 0) - swap (f1, f1 + size); - } while ((f1 += size2) < f2); - } else { /* Natural merge */ - l2 = f2; - for (f2 = f1 + size2; f2 < l2; f2 += size2) { - if ((cmp(f2-size, f2) > 0) != sense) { - p2 = *EVAL(p2) = f2 - list1 + list2; - if (sense > 0) - reverse(f1, f2-size); - f1 = f2; - } - } - if (sense > 0) - reverse (f1, f2-size); - f1 = f2; - if (f2 < last || cmp(f2 - size, f2) > 0) - p2 = *EVAL(p2) = f2 - list1 + list2; - else - p2 = *EVAL(p2) = list2 + n*size; - } - } -#else /* pairwise merge only. */ - for (f1 = list1, p2 = list2; f1 < last; f1 += size2) { - p2 = *EVAL(p2) = p2 + size2; - if (cmp (f1, f1 + size) > 0) - swap(f1, f1 + size); - } -#endif /* NATURAL */ -} -/* }}} */ - -/* {{{ insertionsort - * This is to avoid out-of-bounds addresses in sorting the - * last 4 elements. - */ -static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void *)) -{ - u_char *ai, *s, *t, *u, tmp; - int i; - - for (ai = a+size; --n >= 1; ai += size) - for (t = ai; t > a; t -= size) { - u = t - size; - if (cmp(u, t) <= 0) - break; - swap(u, t); - } -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/network.c b/main/network.c deleted file mode 100644 index b2fb94b3b5..0000000000 --- a/main/network.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Stig Venaas <venaas@uninett.no> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -#include "php.h" - -#ifdef PHP_WIN32 -#include <windows.h> -#include <winsock.h> -#define O_RDONLY _O_RDONLY -#include "win32/param.h" -#else -#include <sys/param.h> -#endif - -#include <sys/types.h> -#if HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif - -#ifndef PHP_WIN32 -#include <netinet/in.h> -#include <netdb.h> -#if HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#endif - -#ifndef HAVE_INET_ATON -int inet_aton(const char *, struct in_addr *); -#endif - -#include "php_network.h" - -#ifdef PHP_WIN32 -#undef AF_UNIX -#endif - -#if defined(AF_UNIX) -#include <sys/un.h> -#endif - -#ifdef PHP_WIN32 -# define SOCK_ERR INVALID_SOCKET -# define SOCK_CONN_ERR SOCKET_ERROR -#else -# define SOCK_ERR -1 -# define SOCK_CONN_ERR -1 -#endif - -#ifdef HAVE_GETADDRINFO -#ifdef HAVE_GAI_STRERROR -# define PHP_GAI_STRERROR(x) (gai_strerror(x)) -#else -# define PHP_GAI_STRERROR(x) (php_gai_strerror(x)) -/* {{{ php_gai_strerror - */ -static char *php_gai_strerror(int code) -{ - static struct { - int code; - const char *msg; - } values[] = { -# ifdef EAI_ADDRFAMILY - {EAI_ADDRFAMILY, "Address family for hostname not supported"}, -# endif - {EAI_AGAIN, "Temporary failure in name resolution"}, - {EAI_BADFLAGS, "Bad value for ai_flags"}, - {EAI_FAIL, "Non-recoverable failure in name resolution"}, - {EAI_FAMILY, "ai_family not supported"}, - {EAI_MEMORY, "Memory allocation failure"}, -# ifdef EAI_NODATA - {EAI_NODATA, "No address associated with hostname"}, -# endif - {EAI_NONAME, "Name or service not known"}, - {EAI_SERVICE, "Servname not supported for ai_socktype"}, - {EAI_SOCKTYPE, "ai_socktype not supported"}, - {EAI_SYSTEM, "System error"}, - {0, NULL} - }; - int i; - - for (i = 0; values[i].msg != NULL; i++) { - if (values[i].code == code) { - return (char *)values[i].msg; - } - } - - return "Unknown error"; -} -/* }}} */ -#endif -#endif - -/* {{{ php_network_freeaddresses - */ -static void php_network_freeaddresses(struct sockaddr **sal) -{ - struct sockaddr **sap; - - if (sal == NULL) - return; - for (sap = sal; *sap != NULL; sap++) - efree(*sap); - efree(sal); -} -/* }}} */ - -/* {{{ php_network_getaddresses - */ -static int php_network_getaddresses(const char *host, struct sockaddr ***sal) -{ - struct sockaddr **sap; - - if (host == NULL) { - return -1; - } - - { -#ifdef HAVE_GETADDRINFO - struct addrinfo hints, *res, *sai; - int n; - - memset(&hints, '\0', sizeof(hints)); - hints.ai_family = AF_UNSPEC; - if ((n = getaddrinfo(host, NULL, &hints, &res))) { - php_error(E_WARNING, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n)); - return -1; - } - - sai = res; - for (n=2; (sai = sai->ai_next) != NULL; n++); - *sal = emalloc(n * sizeof(*sal)); - sai = res; - sap = *sal; - do { - switch (sai->ai_family) { -# ifdef HAVE_IPV6 - case AF_INET6: - *sap = emalloc(sizeof(struct sockaddr_in6)); - *(struct sockaddr_in6 *)*sap = - *((struct sockaddr_in6 *)sai->ai_addr); - sap++; - break; -# endif - case AF_INET: - *sap = emalloc(sizeof(struct sockaddr_in)); - *(struct sockaddr_in *)*sap = - *((struct sockaddr_in *)sai->ai_addr); - sap++; - break; - } - } while ((sai = sai->ai_next) != NULL); - freeaddrinfo(res); -#else - struct hostent *host_info; - struct in_addr in; - - if (!inet_aton(host, &in)) { - /* XXX NOT THREAD SAFE */ - host_info = gethostbyname(host); - if (host_info == NULL) { - php_error(E_WARNING, "php_network_getaddresses: gethostbyname failed"); - return -1; - } - in = *((struct in_addr *) host_info->h_addr); - } - - *sal = emalloc(2 * sizeof(*sal)); - sap = *sal; - *sap = emalloc(sizeof(struct sockaddr_in)); - (*sap)->sa_family = AF_INET; - ((struct sockaddr_in *)*sap)->sin_addr = in; - sap++; -#endif - } - *sap = NULL; - return 0; -} -/* }}} */ - -/* {{{ php_connect_nonb */ -PHPAPI int php_connect_nonb(int sockfd, - struct sockaddr *addr, - socklen_t addrlen, - struct timeval *timeout) -{ - /* probably won't work on Win32, someone else might try it (read: fix it ;) */ - -#if (!defined(__BEOS__) && !defined(PHP_WIN32)) && (defined(O_NONBLOCK) || defined(O_NDELAY)) - -#ifndef O_NONBLOCK -#define O_NONBLOCK O_NDELAY -#endif - - int flags; - int n; - int error = 0; - socklen_t len; - int ret = 0; - fd_set rset; - fd_set wset; - - if (timeout == NULL) { - /* blocking mode */ - return connect(sockfd, addr, addrlen); - } - - flags = fcntl(sockfd, F_GETFL, 0); - fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); - - if ((n = connect(sockfd, addr, addrlen)) < 0) { - if (errno != EINPROGRESS) { - return -1; - } - } - - if (n == 0) { - goto ok; - } - - FD_ZERO(&rset); - FD_SET(sockfd, &rset); - - wset = rset; - - if ((n = select(sockfd + 1, &rset, &wset, NULL, timeout)) == 0) { - error = ETIMEDOUT; - } - - if(FD_ISSET(sockfd, &rset) || FD_ISSET(sockfd, &wset)) { - len = sizeof(error); - /* - BSD-derived systems set errno correctly - Solaris returns -1 from getsockopt in case of error - */ - if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - ret = -1; - } - } else { - /* whoops: sockfd has disappeared */ - ret = -1; - } - -ok: - fcntl(sockfd, F_SETFL, flags); - - if(error) { - errno = error; - ret = -1; - } - return ret; -#else /* !defined(PHP_WIN32) && ... */ - return connect(sockfd, addr, addrlen); -#endif -} -/* }}} */ - -/* {{{ php_hostconnect - * Creates a socket of type socktype and connects to the given host and - * port, returns the created socket on success, else returns -1. - * timeout gives timeout in seconds, 0 means blocking mode. - */ -int php_hostconnect(char *host, unsigned short port, int socktype, int timeout) -{ - int s; - struct sockaddr **sal, **psal; - struct timeval timeoutval; - - if (php_network_getaddresses(host, &sal)) - return -1; - - if (timeout) { - timeoutval.tv_sec = timeout; - timeoutval.tv_usec = 0; - } - - psal = sal; - while (*sal != NULL) { - s = socket((*sal)->sa_family, socktype, 0); - if (s != SOCK_ERR) { - switch ((*sal)->sa_family) { -#if defined( HAVE_GETADDRINFO ) && defined( HAVE_IPV6 ) - case AF_INET6: - { - struct sockaddr_in6 *sa = - (struct sockaddr_in6 *)*sal; - - sa->sin6_family = (*sal)->sa_family; - sa->sin6_port = htons(port); - if (php_connect_nonb(s, (struct sockaddr *) sa, - sizeof(*sa), timeout ? &timeoutval : NULL) != SOCK_CONN_ERR) - goto ok; - } - break; -#endif - case AF_INET: - { - struct sockaddr_in *sa = - (struct sockaddr_in *)*sal; - - sa->sin_family = (*sal)->sa_family; - sa->sin_port = htons(port); - if (php_connect_nonb(s, (struct sockaddr *) sa, - sizeof(*sa), timeout ? &timeoutval : NULL) != SOCK_CONN_ERR) - goto ok; - - } - break; - } - close (s); - } - sal++; - } - php_network_freeaddresses(psal); - php_error(E_WARNING, "php_hostconnect: connect failed"); - return -1; - - ok: - php_network_freeaddresses(psal); - return s; -} -/* }}} */ - -/* - * Local variables: - * tab-width: 8 - * c-basic-offset: 8 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/output.c b/main/output.c deleted file mode 100644 index 63d9b2d8f1..0000000000 --- a/main/output.c +++ /dev/null @@ -1,618 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Zeev Suraski <zeev@zend.com> | - | Thies C. Arntzen <thies@thieso.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#include "php.h" -#include "ext/standard/head.h" -#include "ext/session/php_session.h" -#include "ext/standard/basic_functions.h" -#include "SAPI.h" - -/* output functions */ -static int php_ub_body_write(const char *str, uint str_length TSRMLS_DC); -static int php_ub_body_write_no_header(const char *str, uint str_length TSRMLS_DC); -static int php_b_body_write(const char *str, uint str_length TSRMLS_DC); - -static void php_ob_init(uint initial_size, uint block_size, zval *output_handler, uint chunk_size TSRMLS_DC); -static void php_ob_append(const char *text, uint text_length TSRMLS_DC); -#if 0 -static void php_ob_prepend(const char *text, uint text_length); -#endif - - -#ifdef ZTS -int output_globals_id; -#else -php_output_globals output_globals; -#endif - -static int php_default_output_func(const char *str, uint str_len TSRMLS_DC) -{ - fwrite(str, 1, str_len, stderr); - return str_len; -} - - -static void php_output_init_globals(php_output_globals *output_globals_p TSRMLS_DC) -{ - OG(php_body_write) = php_default_output_func; - OG(php_header_write) = php_default_output_func; - OG(implicit_flush) = 0; - OG(output_start_filename) = NULL; - OG(output_start_lineno) = 0; -} - - -/* Start output layer */ -PHPAPI void php_output_startup(void) -{ -#ifdef ZTS - ts_allocate_id(&output_globals_id, sizeof(php_output_globals), (ts_allocate_ctor) php_output_init_globals, NULL); -#else - php_output_init_globals(&output_globals TSRMLS_CC); -#endif -} - - -PHPAPI void php_output_activate(TSRMLS_D) -{ - OG(php_body_write) = php_ub_body_write; - OG(php_header_write) = sapi_module.ub_write; - OG(ob_nesting_level) = 0; - OG(ob_lock) = 0; - OG(disable_output) = 0; -} - - -PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC) -{ - OG(disable_output) = !status; -} - - -void php_output_register_constants(TSRMLS_D) -{ - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_START", PHP_OUTPUT_HANDLER_START, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_CONT", PHP_OUTPUT_HANDLER_CONT, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_END", PHP_OUTPUT_HANDLER_END, CONST_CS | CONST_PERSISTENT); -} - - -PHPAPI int php_body_write(const char *str, uint str_length TSRMLS_DC) -{ - return OG(php_body_write)(str, str_length TSRMLS_CC); -} - -PHPAPI int php_header_write(const char *str, uint str_length TSRMLS_DC) -{ - if (OG(disable_output)) { - return 0; - } else { - return OG(php_header_write)(str, str_length TSRMLS_CC); - } -} - -/* {{{ php_start_ob_buffer - * Start output buffering */ -PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size TSRMLS_DC) -{ - if (OG(ob_lock)) { - return FAILURE; - } - if (chunk_size) { - php_ob_init((chunk_size*3/2), chunk_size/2, output_handler, chunk_size TSRMLS_CC); - } else { - php_ob_init(40*1024, 10*1024, output_handler, chunk_size TSRMLS_CC); - } - OG(php_body_write) = php_b_body_write; - return SUCCESS; -} -/* }}} */ - -/* {{{ php_end_ob_buffer - * End output buffering (one level) */ -PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS_DC) -{ - char *final_buffer=NULL; - int final_buffer_length=0; - zval *alternate_buffer=NULL; - char *to_be_destroyed_buffer; - char *to_be_destroyed_handled_output[2] = { 0, 0 }; - int status; - - if (OG(ob_nesting_level)==0) { - return; - } - status = 0; - if (!OG(active_ob_buffer).status & PHP_OUTPUT_HANDLER_START) { - /* our first call */ - status |= PHP_OUTPUT_HANDLER_START; - } - if (just_flush) { - status |= PHP_OUTPUT_HANDLER_CONT; - } else { - status |= PHP_OUTPUT_HANDLER_END; - } - - if (OG(active_ob_buffer).internal_output_handler) { - final_buffer = OG(active_ob_buffer).internal_output_handler_buffer; - final_buffer_length = OG(active_ob_buffer).internal_output_handler_buffer_size; - OG(active_ob_buffer).internal_output_handler(OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, &final_buffer, &final_buffer_length, status TSRMLS_CC); - } else if (OG(active_ob_buffer).output_handler) { - zval **params[2]; - zval *orig_buffer; - zval *z_status; - - ALLOC_INIT_ZVAL(orig_buffer); - ZVAL_STRINGL(orig_buffer, OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, 0); - orig_buffer->refcount=2; /* don't let call_user_function() destroy our buffer */ - orig_buffer->is_ref=1; - - ALLOC_INIT_ZVAL(z_status); - ZVAL_LONG(z_status, status); - - params[0] = &orig_buffer; - params[1] = &z_status; - OG(ob_lock) = 1; - if (call_user_function_ex(CG(function_table), NULL, OG(active_ob_buffer).output_handler, &alternate_buffer, 2, params, 1, NULL TSRMLS_CC)==SUCCESS) { - convert_to_string_ex(&alternate_buffer); - final_buffer = alternate_buffer->value.str.val; - final_buffer_length = alternate_buffer->value.str.len; - } - OG(ob_lock) = 0; - zval_ptr_dtor(&OG(active_ob_buffer).output_handler); - if (orig_buffer->refcount==2) { /* free the zval */ - FREE_ZVAL(orig_buffer); - } else { - orig_buffer->refcount-=2; - } - zval_ptr_dtor(&z_status); - } - - if (!final_buffer) { - final_buffer = OG(active_ob_buffer).buffer; - final_buffer_length = OG(active_ob_buffer).text_length; - } - - if (OG(ob_nesting_level)==1) { /* end buffering */ - if (SG(headers_sent) && !SG(request_info).headers_only) { - OG(php_body_write) = php_ub_body_write_no_header; - } else { - OG(php_body_write) = php_ub_body_write; - } - } - - to_be_destroyed_buffer = OG(active_ob_buffer).buffer; - if (OG(active_ob_buffer).internal_output_handler - && (final_buffer != OG(active_ob_buffer).internal_output_handler_buffer)) { - to_be_destroyed_handled_output[0] = final_buffer; - } - - if (!just_flush) { - if (OG(active_ob_buffer).internal_output_handler) { - to_be_destroyed_handled_output[1] = OG(active_ob_buffer).internal_output_handler_buffer; - } - if (OG(ob_nesting_level)>1) { /* restore previous buffer */ - php_ob_buffer *ob_buffer_p; - - zend_stack_top(&OG(ob_buffers), (void **) &ob_buffer_p); - OG(active_ob_buffer) = *ob_buffer_p; - zend_stack_del_top(&OG(ob_buffers)); - if (OG(ob_nesting_level)==2) { /* destroy the stack */ - zend_stack_destroy(&OG(ob_buffers)); - } - } - OG(ob_nesting_level)--; - } - - if (send_buffer) { - OG(php_body_write)(final_buffer, final_buffer_length TSRMLS_CC); - } - - if (alternate_buffer) { - zval_ptr_dtor(&alternate_buffer); - } - - if (!just_flush) { - efree(to_be_destroyed_buffer); - } else { - OG(active_ob_buffer).text_length = 0; - OG(active_ob_buffer).status |= PHP_OUTPUT_HANDLER_START; - OG(php_body_write) = php_b_body_write; - } - if (to_be_destroyed_handled_output[0]) { - efree(to_be_destroyed_handled_output[0]); - } - if (to_be_destroyed_handled_output[1]) { - efree(to_be_destroyed_handled_output[1]); - } -} -/* }}} */ - -/* {{{ php_end_ob_buffers - * End output buffering (all buffers) */ -PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC) -{ - while (OG(ob_nesting_level)!=0) { - php_end_ob_buffer(send_buffer, 0 TSRMLS_CC); - } - - if (!OG(disable_output) && send_buffer && BG(use_trans_sid)) { - session_adapt_flush(OG(php_header_write) TSRMLS_CC); - } -} -/* }}} */ - -/* {{{ php_start_implicit_flush - */ -PHPAPI void php_start_implicit_flush(TSRMLS_D) -{ - php_end_ob_buffer(1, 0 TSRMLS_CC); /* Switch out of output buffering if we're in it */ - OG(implicit_flush)=1; -} -/* }}} */ - -/* {{{ php_end_implicit_flush - */ -PHPAPI void php_end_implicit_flush(TSRMLS_D) -{ - OG(implicit_flush)=0; -} -/* }}} */ - -/* {{{ php_ob_set_internal_handler - */ -PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t internal_output_handler, uint buffer_size TSRMLS_DC) -{ - if (OG(ob_nesting_level)==0) { - return; - } - - OG(active_ob_buffer).internal_output_handler = internal_output_handler; - OG(active_ob_buffer).internal_output_handler_buffer = (char *) emalloc(buffer_size); - OG(active_ob_buffer).internal_output_handler_buffer_size = buffer_size; -} -/* }}} */ - -/* - * Output buffering - implementation - */ - -/* {{{ php_ob_allocate - */ -static inline void php_ob_allocate(TSRMLS_D) -{ - if (OG(active_ob_buffer).size<OG(active_ob_buffer).text_length) { - while (OG(active_ob_buffer).size <= OG(active_ob_buffer).text_length) { - OG(active_ob_buffer).size+=OG(active_ob_buffer).block_size; - } - - OG(active_ob_buffer).buffer = (char *) erealloc(OG(active_ob_buffer).buffer, OG(active_ob_buffer).size+1); - } -} -/* }}} */ - -/* {{{ php_ob_init - */ -static void php_ob_init(uint initial_size, uint block_size, zval *output_handler, uint chunk_size TSRMLS_DC) -{ - if (OG(ob_nesting_level)>0) { - if (OG(ob_nesting_level)==1) { /* initialize stack */ - zend_stack_init(&OG(ob_buffers)); - } - zend_stack_push(&OG(ob_buffers), &OG(active_ob_buffer), sizeof(php_ob_buffer)); - } - OG(ob_nesting_level)++; - OG(active_ob_buffer).block_size = block_size; - OG(active_ob_buffer).size = initial_size; - OG(active_ob_buffer).buffer = (char *) emalloc(initial_size+1); - OG(active_ob_buffer).text_length = 0; - OG(active_ob_buffer).output_handler = output_handler; - OG(active_ob_buffer).chunk_size = chunk_size; - OG(active_ob_buffer).status = 0; - OG(active_ob_buffer).internal_output_handler = NULL; -} -/* }}} */ - -/* {{{ php_ob_append - */ -static void php_ob_append(const char *text, uint text_length TSRMLS_DC) -{ - char *target; - int original_ob_text_length; - - original_ob_text_length=OG(active_ob_buffer).text_length; - OG(active_ob_buffer).text_length = OG(active_ob_buffer).text_length + text_length; - - php_ob_allocate(TSRMLS_C); - target = OG(active_ob_buffer).buffer+original_ob_text_length; - memcpy(target, text, text_length); - target[text_length]=0; - - if (OG(active_ob_buffer).chunk_size - && OG(active_ob_buffer).text_length >= OG(active_ob_buffer).chunk_size) { - zval *output_handler = OG(active_ob_buffer).output_handler; - - if (output_handler) { - output_handler->refcount++; - } - php_end_ob_buffer(1, 1 TSRMLS_CC); - return; - } -} -/* }}} */ - -#if 0 -static void php_ob_prepend(const char *text, uint text_length) -{ - char *p, *start; - TSRMLS_FETCH(); - - OG(active_ob_buffer).text_length += text_length; - php_ob_allocate(TSRMLS_C); - - /* php_ob_allocate() may change OG(ob_buffer), so we can't initialize p&start earlier */ - p = OG(ob_buffer)+OG(ob_text_length); - start = OG(ob_buffer); - - while (--p>=start) { - p[text_length] = *p; - } - memcpy(OG(ob_buffer), text, text_length); - OG(ob_buffer)[OG(active_ob_buffer).text_length]=0; -} -#endif - - -/* {{{ php_ob_get_buffer - * Return the current output buffer */ -int php_ob_get_buffer(pval *p TSRMLS_DC) -{ - if (OG(ob_nesting_level)==0) { - return FAILURE; - } - ZVAL_STRINGL(p, OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, 1); - return SUCCESS; -} -/* }}} */ - -/* {{{ php_ob_get_length - * Return the size of the current output buffer */ -int php_ob_get_length(pval *p TSRMLS_DC) -{ - if (OG(ob_nesting_level) == 0) { - return FAILURE; - } - ZVAL_LONG(p, OG(active_ob_buffer).text_length); - return SUCCESS; -} -/* }}} */ - -/* - * Wrapper functions - implementation - */ - - -/* buffered output function */ -static int php_b_body_write(const char *str, uint str_length TSRMLS_DC) -{ - php_ob_append(str, str_length TSRMLS_CC); - return str_length; -} - -/* {{{ php_ub_body_write_no_header - */ -static int php_ub_body_write_no_header(const char *str, uint str_length TSRMLS_DC) -{ - char *newstr = NULL; - size_t new_length=0; - int result; - - if (OG(disable_output)) { - return 0; - } - if (BG(use_trans_sid)) { - session_adapt_uris(str, str_length, &newstr, &new_length TSRMLS_CC); - } - - if (newstr) { - str = newstr; - str_length = new_length; - } - - result = OG(php_header_write)(str, str_length TSRMLS_CC); - - if (OG(implicit_flush)) { - sapi_flush(TSRMLS_C); - } - - return result; -} -/* }}} */ - -/* {{{ php_ub_body_write - */ -static int php_ub_body_write(const char *str, uint str_length TSRMLS_DC) -{ - int result = 0; - - if (SG(request_info).headers_only) { - php_header(); - zend_bailout(); - } - if (php_header()) { - if (zend_is_compiling(TSRMLS_C)) { - OG(output_start_filename) = zend_get_compiled_filename(TSRMLS_C); - OG(output_start_lineno) = zend_get_compiled_lineno(TSRMLS_C); - } else if (zend_is_executing(TSRMLS_C)) { - OG(output_start_filename) = zend_get_executed_filename(TSRMLS_C); - OG(output_start_lineno) = zend_get_executed_lineno(TSRMLS_C); - } - - OG(php_body_write) = php_ub_body_write_no_header; - result = php_ub_body_write_no_header(str, str_length TSRMLS_CC); - } - - return result; -} -/* }}} */ - -/* - * HEAD support - */ - -/* {{{ proto void ob_start([ string user_function [, int chunk_size]]) - Turn on Output Buffering (specifying an optional output handler). */ -PHP_FUNCTION(ob_start) -{ - zval *output_handler; - uint chunk_size=0; - - switch (ZEND_NUM_ARGS()) { - case 0: - output_handler = NULL; - break; - case 1: { - zval **output_handler_p; - - if (zend_get_parameters_ex(1, &output_handler_p)==FAILURE) { - RETURN_FALSE; - } - SEPARATE_ZVAL(output_handler_p); - output_handler = *output_handler_p; - output_handler->refcount++; - } - break; - case 2: { - zval **output_handler_p, **chunk_size_p; - - if (zend_get_parameters_ex(2, &output_handler_p, &chunk_size_p)==FAILURE) { - RETURN_FALSE; - } - SEPARATE_ZVAL(output_handler_p); - output_handler = *output_handler_p; - output_handler->refcount++; - convert_to_long_ex(chunk_size_p); - chunk_size = (uint) Z_LVAL_PP(chunk_size_p); - } - break; - default: - ZEND_WRONG_PARAM_COUNT(); - break; - } - if (php_start_ob_buffer(output_handler, chunk_size TSRMLS_CC)==FAILURE) { - if (SG(headers_sent) && !SG(request_info).headers_only) { - OG(php_body_write) = php_ub_body_write_no_header; - } else { - OG(php_body_write) = php_ub_body_write; - } - OG(ob_nesting_level) = 0; - php_error(E_ERROR, "Cannot use output buffering in output buffering display handlers"); - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto void ob_end_flush(void) - Flush (send) the output buffer, and turn off output buffering */ -PHP_FUNCTION(ob_end_flush) -{ - php_end_ob_buffer(1, 0 TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto void ob_end_clean(void) - Clean (erase) the output buffer, and turn off output buffering */ -PHP_FUNCTION(ob_end_clean) -{ - php_end_ob_buffer(0, 0 TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto string ob_get_contents(void) - Return the contents of the output buffer */ -PHP_FUNCTION(ob_get_contents) -{ - if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto string ob_get_length(void) - Return the length of the output buffer */ -PHP_FUNCTION(ob_get_length) -{ - if (php_ob_get_length(return_value TSRMLS_CC)==FAILURE) { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto void ob_implicit_flush([int flag]) - Turn implicit flush on/off and is equivalent to calling flush() after every output call */ -PHP_FUNCTION(ob_implicit_flush) -{ - zval **zv_flag; - int flag; - - switch(ZEND_NUM_ARGS()) { - case 0: - flag = 1; - break; - case 1: - if (zend_get_parameters_ex(1, &zv_flag)==FAILURE) { - RETURN_FALSE; - } - convert_to_long_ex(zv_flag); - flag = (*zv_flag)->value.lval; - break; - default: - WRONG_PARAM_COUNT; - break; - } - if (flag) { - php_start_implicit_flush(TSRMLS_C); - } else { - php_end_implicit_flush(TSRMLS_C); - } -} -/* }}} */ - -PHPAPI char *php_get_output_start_filename(TSRMLS_D) -{ - return OG(output_start_filename); -} - - -PHPAPI int php_get_output_start_lineno(TSRMLS_D) -{ - return OG(output_start_lineno); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/php.h b/main/php.h deleted file mode 100644 index fb2f62f666..0000000000 --- a/main/php.h +++ /dev/null @@ -1,342 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Andi Gutmans <andi@zend.com> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifndef PHP_H -#define PHP_H - -#ifdef HAVE_DMALLOC -#include <dmalloc.h> -#endif - -#define PHP_API_VERSION 20010119 - -#define YYDEBUG 0 - -#include "php_version.h" -#include "zend.h" -#include "php_compat.h" - -#include "zend_API.h" - -#if PHP_BROKEN_SPRINTF -#undef sprintf -#define sprintf php_sprintf -#endif - -#ifdef PHP_WIN32 -#include "tsrm_win32.h" -#include "win95nt.h" -# ifdef PHP_EXPORTS -# define PHPAPI __declspec(dllexport) -# else -# define PHPAPI __declspec(dllimport) -# endif -#define PHP_DIR_SEPARATOR '\\' -#else -#define PHPAPI -#define THREAD_LS -#define PHP_DIR_SEPARATOR '/' -#endif - -#include "php_regex.h" - -/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */ -#undef PHP_DEBUG -#define PHP_DEBUG ZEND_DEBUG - - -#define APACHE 0 -#define CGI_BINARY 0 - -#if HAVE_UNIX_H -#include <unix.h> -#endif - -#if HAVE_ALLOCA_H -#include <alloca.h> -#endif - -/* - * This is a fast version of strlcpy which should be used, if you - * know the size of the destination buffer and if you know - * the length of the source string. - * - * size is the allocated number of bytes of dst - * src_size is the number of bytes excluding the NUL of src - */ - -#define PHP_STRLCPY(dst, src, size, src_size) \ - { \ - size_t php_str_len; \ - \ - if (src_size >= size) \ - php_str_len = size - 1; \ - else \ - php_str_len = src_size; \ - memcpy(dst, src, php_str_len); \ - dst[php_str_len] = '\0'; \ - } - -#ifndef HAVE_STRLCPY -PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz); -#define strlcpy php_strlcpy -#endif - -#ifndef HAVE_STRLCAT -PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz); -#define strlcat php_strlcat -#endif - -#ifndef HAVE_STRTOK_R -char *strtok_r(char *s, const char *delim, char **last); -#endif - -#ifndef HAVE_SOCKLEN_T -typedef unsigned int socklen_t; -#endif - -#define CREATE_MUTEX(a, b) -#define SET_MUTEX(a) -#define FREE_MUTEX(a) - -/* - * Then the ODBC support can use both iodbc and Solid, - * uncomment this. - * #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID) - */ - -#include <stdlib.h> -#include <ctype.h> -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#if HAVE_STDARG_H -#include <stdarg.h> -#else -# if HAVE_SYS_VARARGS_H -# include <sys/varargs.h> -# endif -#endif - - -#include "zend_hash.h" -#include "php3_compat.h" -#include "zend_alloc.h" -#include "zend_stack.h" - -#if STDC_HEADERS -# include <string.h> -#else -# ifndef HAVE_MEMCPY -# define memcpy(d, s, n) bcopy((s), (d), (n)) -# endif -# ifndef HAVE_MEMMOVE -# define memmove(d, s, n) bcopy ((s), (d), (n)) -# endif -#endif - -#include "safe_mode.h" - -#ifndef HAVE_STRERROR -char *strerror(int); -#endif - -#include "php_streams.h" -#include "fopen_wrappers.h" - -#if (REGEX == 1 || REGEX == 0) && !defined(NO_REGEX_EXTRA_H) -#include "regex/regex_extra.h" -#endif - -#if HAVE_PWD_H -# ifdef PHP_WIN32 -#include "win32/pwd.h" -#include "win32/param.h" -# else -#include <pwd.h> -#include <sys/param.h> -# endif -#endif - -#if HAVE_LIMITS_H -#include <limits.h> -#endif - -#ifndef LONG_MAX -#define LONG_MAX 2147483647L -#endif - -#ifndef LONG_MIN -#define LONG_MIN (- LONG_MAX - 1) -#endif - -#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || defined(BROKEN_SPRINTF) || defined(BROKEN_SNPRINTF) || defined(BROKEN_VSNPRINTF) -#include "snprintf.h" -#endif - -#define EXEC_INPUT_BUF 4096 - -#define PHP_MIME_TYPE "application/x-httpd-php" - -/* macros */ -#define STR_PRINT(str) ((str)?(str):"") - -#ifndef MAXPATHLEN -# ifdef PATH_MAX -# define MAXPATHLEN PATH_MAX -# else -# define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */ -# endif -#endif - -#define PHP_FN(name) php_if_##name -#define PHP_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS) -#define PHP_FUNCTION(name) PHP_NAMED_FUNCTION(PHP_FN(name)) - -#define PHP_NAMED_FE(php_name, name, arg_types) { #php_name, name, arg_types }, -#define PHP_FE(name, arg_types) PHP_NAMED_FE(name, PHP_FN(name), arg_types) -#define PHP_FALIAS(name, alias, arg_types) PHP_NAMED_FE(name, PHP_FN(alias), arg_types) -#define PHP_STATIC_FE(php_name, func_name, arg_types) { php_name, func_name, arg_types }, - -#define PHP_MINIT(module) php_minit_##module -#define PHP_MSHUTDOWN(module) php_mshutdown_##module -#define PHP_RINIT(module) php_rinit_##module -#define PHP_RSHUTDOWN(module) php_rshutdown_##module -#define PHP_MINFO(module) php_info_##module - -#define PHP_MINIT_FUNCTION(module) int PHP_MINIT(module)(INIT_FUNC_ARGS) -#define PHP_MSHUTDOWN_FUNCTION(module) int PHP_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS) -#define PHP_RINIT_FUNCTION(module) int PHP_RINIT(module)(INIT_FUNC_ARGS) -#define PHP_RSHUTDOWN_FUNCTION(module) int PHP_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS) -#define PHP_MINFO_FUNCTION(module) void PHP_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS) - - -/* global variables */ -extern pval *data; -#if !defined(PHP_WIN32) -extern char **environ; -#define php_sleep sleep -#endif - -#ifdef PHP_PWRITE_64 -ssize_t pwrite(int, void *, size_t, off64_t); -#endif - -#ifdef PHP_PREAD_64 -ssize_t pread(int, void *, size_t, off64_t); -#endif - -void phperror(char *error); -PHPAPI int php_write(void *buf, uint size TSRMLS_DC); -PHPAPI int php_printf(const char *format, ...); -PHPAPI void php_log_err(char *log_message TSRMLS_DC); -int Debug(char *format, ...); -int cfgparse(void); - -#define php_error zend_error - -#define zenderror phperror -#define zendlex phplex - -#define phpparse zendparse -#define phprestart zendrestart -#define phpin zendin - -/* functions */ -int php_startup_internal_extensions(void); - -int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp) (const void *, const void *)); - -PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata); - -PHPAPI int cfg_get_long(char *varname, long *result); -PHPAPI int cfg_get_double(char *varname, double *result); -PHPAPI int cfg_get_string(char *varname, char **result); - - -/* Output support */ -#include "main/php_output.h" -#define PHPWRITE(str, str_len) php_body_write((str), (str_len) TSRMLS_CC) -#define PUTS(str) php_body_write((str), strlen((str)) TSRMLS_CC) -#define PUTC(c) (php_body_write(&(c), 1 TSRMLS_CC), (c)) -#define PHPWRITE_H(str, str_len) php_header_write((str), (str_len) TSRMLS_CC) -#define PUTS_H(str) php_header_write((str), strlen((str)) TSRMLS_CC) -#define PUTC_H(c) (php_header_write(&(c), 1 TSRMLS_CC), (c)) - -#ifdef ZTS -#define VIRTUAL_DIR -#endif - -/* Virtual current working directory support */ -#include "tsrm_virtual_cwd.h" - -#include "zend_constants.h" - -/* connection status states */ -#define PHP_CONNECTION_NORMAL 0 -#define PHP_CONNECTION_ABORTED 1 -#define PHP_CONNECTION_TIMEOUT 2 - -#include "php_reentrancy.h" - -/* Finding offsets of elements within structures. - * Taken from the Apache code, which in turn, was taken from X code... - */ - -#if defined(CRAY) || (defined(__arm) && !defined(LINUX)) -#ifdef __STDC__ -#define XtOffset(p_type, field) _Offsetof(p_type, field) -#else -#ifdef CRAY2 -#define XtOffset(p_type, field) \ - (sizeof(int)*((unsigned int)&(((p_type)NULL)->field))) - -#else /* !CRAY2 */ - -#define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field)) - -#endif /* !CRAY2 */ -#endif /* __STDC__ */ -#else /* ! (CRAY || __arm) */ - -#define XtOffset(p_type, field) \ - ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) - -#endif /* !CRAY */ - -#ifdef offsetof -#define XtOffsetOf(s_type, field) offsetof(s_type, field) -#else -#define XtOffsetOf(s_type, field) XtOffset(s_type*, field) -#endif - -PHPAPI PHP_FUNCTION(warn_not_available); - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/php3_compat.h b/main/php3_compat.h deleted file mode 100644 index 4093a79a90..0000000000 --- a/main/php3_compat.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef PHP3_COMPAT_H -#define PHP3_COMPAT_H - -typedef zval pval; - -#define pval_copy_constructor zval_copy_ctor -#define pval_destructor zval_dtor - -#define _php3_hash_init zend_hash_init -#define _php3_hash_destroy zend_hash_destroy - -#define _php3_hash_clean zend_hash_clean - -#define _php3_hash_add_or_update zend_hash_add_or_update -#define _php3_hash_add zend_hash_add -#define _php3_hash_update zend_hash_update - -#define _php3_hash_quick_add_or_update zend_hash_quick_add_or_update -#define _php3_hash_quick_add zend_hash_quick_add -#define _php3_hash_quick_update zend_hash_quick_update - -#define _php3_hash_index_update_or_next_insert zend_hash_index_update_or_next_insert -#define _php3_hash_index_update zend_hash_index_update -#define _php3_hash_next_index_insert zend_hash_next_index_insert - -#define _php3_hash_pointer_update zend_hash_pointer_update - -#define _php3_hash_pointer_index_update_or_next_insert zend_hash_pointer_index_update_or_next_insert -#define _php3_hash_pointer_index_update zend_hash_pointer_index_update -#define _php3_hash_next_index_pointer_update zend_hash_next_index_pointer_update -#define _php3_hash_next_index_pointer_insert zend_hash_next_index_pointer_insert - -#define _php3_hash_del_key_or_index zend_hash_del_key_or_index -#define _php3_hash_del zend_hash_del -#define _php3_hash_index_del zend_hash_index_del - -#define _php3_hash_find zend_hash_find -#define _php3_hash_quick_find zend_hash_quick_find -#define _php3_hash_index_find zend_hash_index_find - -#define _php3_hash_exists zend_hash_exists -#define _php3_hash_index_exists zend_hash_index_exists -#define _php3_hash_is_pointer zend_hash_is_pointer -#define _php3_hash_index_is_pointer zend_hash_index_is_pointer -#define _php3_hash_next_free_element zend_hash_next_free_element - -#define _php3_hash_move_forward zend_hash_move_forward -#define _php3_hash_move_backwards zend_hash_move_backwards -#define _php3_hash_get_current_key zend_hash_get_current_key -#define _php3_hash_get_current_data zend_hash_get_current_data -#define _php3_hash_internal_pointer_reset zend_hash_internal_pointer_reset -#define _php3_hash_internal_pointer_end zend_hash_internal_pointer_end - -#define _php3_hash_copy zend_hash_copy -#define _php3_hash_merge zend_hash_merge -#define _php3_hash_sort zend_hash_sort -#define _php3_hash_minmax zend_hash_minmax - -#define _php3_hash_num_elements zend_hash_num_elements - -#define _php3_hash_apply zend_hash_apply -#define _php3_hash_apply_with_argument zend_hash_apply_with_argument - - -#define php3_error php_error - -#define php3_printf php_printf -#define _php3_sprintf php_sprintf - - - -#define php3_module_entry zend_module_entry - -#define php3_strndup zend_strndup -#define php3_str_tolower zend_str_tolower -#define php3_binary_strcmp zend_binary_strcmp - - -#define php3_list_insert zend_list_insert -#define php3_list_find zend_list_find -#define php3_list_delete zend_list_delete - -#define php3_plist_insert zend_plist_insert -#define php3_plist_find zend_plist_find -#define php3_plist_delete zend_plist_delete - -#define zend_print_pval zend_print_zval -#define zend_print_pval_r zend_print_zval_r - - -#define function_entry zend_function_entry - -#define _php3_addslashes php_addslashes -#define _php3_stripslashes php_stripslashes -#define php3_dl php_dl - -#define getParameters zend_get_parameters -#define getParametersArray zend_get_parameters_array - -#define list_entry zend_rsrc_list_entry - -#endif /* PHP3_COMPAT_H */ diff --git a/main/php_compat.h b/main/php_compat.h deleted file mode 100644 index 7c9a16480c..0000000000 --- a/main/php_compat.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef PHP_COMPAT_H -#define PHP_COMPAT_H - -#ifdef PHP_WIN32 -#include "config.w32.h" -#else -#include "php_config.h" -#endif - -#if defined(HAVE_BUNDLED_PCRE) || !defined(PHP_VERSION) -#define pcre_compile php_pcre_compile -#define pcre_copy_substring php_pcre_copy_substring -#define pcre_exec php_pcre_exec -#define pcre_get_substring php_pcre_substring -#define pcre_get_substring_list php_pcre_get_substring_list -#define pcre_info php_pcre_info -#define pcre_maketables php_pcre_maketables -#define pcre_study php_pcre_study -#define pcre_version php_pcre_version -#endif - -#define lookup php_lookup -#define hashTableInit php_hashTableInit -#define hashTableDestroy php_hashTableDestroy -#define hashTableIterInit php_hashTableIterInit -#define hashTableIterNext php_hashTableIterNext - -#ifdef HAVE_LIBEXPAT_BUNDLED -#define XML_DefaultCurrent php_XML_DefaultCurrent -#define XML_ErrorString php_XML_ErrorString -#define XML_ExpatVersion php_XML_ExpatVersion -#define XML_ExpatVersionInfo php_XML_ExpatVersionInfo -#define XML_ExternalEntityParserCreate php_XML_ExternalEntityParserCreate -#define XML_GetBase php_XML_GetBase -#define XML_GetBuffer php_XML_GetBuffer -#define XML_GetCurrentByteCount php_XML_GetCurrentByteCount -#define XML_GetCurrentByteIndex php_XML_GetCurrentByteIndex -#define XML_GetCurrentColumnNumber php_XML_GetCurrentColumnNumber -#define XML_GetCurrentLineNumber php_XML_GetCurrentLineNumber -#define XML_GetErrorCode php_XML_GetErrorCode -#define XML_GetIdAttributeIndex php_XML_GetIdAttributeIndex -#define XML_GetInputContext php_XML_GetInputContext -#define XML_GetSpecifiedAttributeCount php_XML_GetSpecifiedAttributeCount -#define XmlGetUtf16InternalEncodingNS php_XmlGetUtf16InternalEncodingNS -#define XmlGetUtf16InternalEncoding php_XmlGetUtf16InternalEncoding -#define XmlGetUtf8InternalEncodingNS php_XmlGetUtf8InternalEncodingNS -#define XmlGetUtf8InternalEncoding php_XmlGetUtf8InternalEncoding -#define XmlInitEncoding php_XmlInitEncoding -#define XmlInitUnknownEncoding php_XmlInitUnknownEncoding -#define XML_ParseBuffer php_XML_ParseBuffer -#define XML_Parse php_XML_Parse -#define XML_ParserCreate_MM php_XML_ParserCreate_MM -#define XML_ParserCreateNS php_XML_ParserCreateNS -#define XML_ParserCreate php_XML_ParserCreate -#define XML_ParserFree php_XML_ParserFree -#define XmlParseXmlDecl php_XmlParseXmlDecl -#define XmlPrologStateInitExternalEntity php_XmlPrologStateInitExternalEntity -#define XmlPrologStateInit php_XmlPrologStateInit -#define XML_SetAttlistDeclHandler php_XML_SetAttlistDeclHandler -#define XML_SetBase php_XML_SetBase -#define XML_SetCdataSectionHandler php_XML_SetCdataSectionHandler -#define XML_SetCharacterDataHandler php_XML_SetCharacterDataHandler -#define XML_SetCommentHandler php_XML_SetCommentHandler -#define XML_SetDefaultHandlerExpand php_XML_SetDefaultHandlerExpand -#define XML_SetDefaultHandler php_XML_SetDefaultHandler -#define XML_SetDoctypeDeclHandler php_XML_SetDoctypeDeclHandler -#define XML_SetElementDeclHandler php_XML_SetElementDeclHandler -#define XML_SetElementHandler php_XML_SetElementHandler -#define XML_SetEncoding php_XML_SetEncoding -#define XML_SetEndCdataSectionHandler php_XML_SetEndCdataSectionHandler -#define XML_SetEndDoctypeDeclHandler php_XML_SetEndDoctypeDeclHandler -#define XML_SetEndElementHandler php_XML_SetEndElementHandler -#define XML_SetEndNamespaceDeclHandler php_XML_SetEndNamespaceDeclHandler -#define XML_SetEntityDeclHandler php_XML_SetEntityDeclHandler -#define XML_SetExternalEntityRefHandlerArg php_XML_SetExternalEntityRefHandlerArg -#define XML_SetExternalEntityRefHandler php_XML_SetExternalEntityRefHandler -#define XML_SetNamespaceDeclHandler php_XML_SetNamespaceDeclHandler -#define XML_SetNotationDeclHandler php_XML_SetNotationDeclHandler -#define XML_SetNotStandaloneHandler php_XML_SetNotStandaloneHandler -#define XML_SetParamEntityParsing php_XML_SetParamEntityParsing -#define XML_SetProcessingInstructionHandler php_XML_SetProcessingInstructionHandler -#define XML_SetReturnNSTriplet php_XML_SetReturnNSTriplet -#define XML_SetStartCdataSectionHandler php_XML_SetStartCdataSectionHandler -#define XML_SetStartDoctypeDeclHandler php_XML_SetStartDoctypeDeclHandler -#define XML_SetStartElementHandler php_XML_SetStartElementHandler -#define XML_SetStartNamespaceDeclHandler php_XML_SetStartNamespaceDeclHandler -#define XML_SetUnknownEncodingHandler php_XML_SetUnknownEncodingHandler -#define XML_SetUnparsedEntityDeclHandler php_XML_SetUnparsedEntityDeclHandler -#define XML_SetUserData php_XML_SetUserData -#define XML_SetXmlDeclHandler php_XML_SetXmlDeclHandler -#define XmlSizeOfUnknownEncoding php_XmlSizeOfUnknownEncoding -#define XML_UseParserAsHandlerArg php_XML_UseParserAsHandlerArg -#define XmlUtf16Encode php_XmlUtf16Encode -#define XmlUtf8Encode php_XmlUtf8Encode -#endif - -#endif diff --git a/main/php_content_types.c b/main/php_content_types.c deleted file mode 100644 index aaa06e34a0..0000000000 --- a/main/php_content_types.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#include "php.h" -#include "SAPI.h" -#include "rfc1867.h" - -#include "php_content_types.h" - -/* {{{ php_post_entries[] - */ -static sapi_post_entry php_post_entries[] = { - { DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data, php_std_post_handler }, - { MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, sapi_read_standard_form_data, rfc1867_post_handler }, - { NULL, 0, NULL } -}; -/* }}} */ - -/* {{{ SAPI_POST_READER_FUNC - */ -SAPI_POST_READER_FUNC(php_default_post_reader) -{ - char *data; - - if(!SG(request_info).post_data) sapi_read_standard_form_data(TSRMLS_C); - data = estrndup(SG(request_info).post_data, SG(request_info).post_data_length); - SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, SG(request_info).post_data_length); -} -/* }}} */ - -/* {{{ php_startup_sapi_content_types - */ -int php_startup_sapi_content_types(void) -{ - sapi_register_post_entries(php_post_entries); - sapi_register_default_post_reader(php_default_post_reader); - return SUCCESS; -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/php_content_types.h b/main/php_content_types.h deleted file mode 100644 index 7752b8c121..0000000000 --- a/main/php_content_types.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef PHP_CONTENT_TYPES_H -#define PHP_CONTENT_TYPES_H - -#define DEFAULT_POST_CONTENT_TYPE "application/x-www-form-urlencoded" - -SAPI_POST_READER_FUNC(php_default_post_reader); -SAPI_POST_HANDLER_FUNC(php_std_post_handler); -int php_startup_sapi_content_types(void); - -#endif /* PHP_CONTENT_TYPES_H */ diff --git a/main/php_globals.h b/main/php_globals.h deleted file mode 100644 index 0499e8c133..0000000000 --- a/main/php_globals.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - - -#ifndef PHP_GLOBALS_H -#define PHP_GLOBALS_H - -#include "zend_globals.h" - -typedef struct _php_core_globals php_core_globals; - -#ifdef ZTS -# define PG(v) TSRMG(core_globals_id, php_core_globals *, v) -extern PHPAPI int core_globals_id; -#else -# define PG(v) (core_globals.v) -extern ZEND_API struct _php_core_globals core_globals; -#endif - - -#define TRACK_VARS_POST 0 -#define TRACK_VARS_GET 1 -#define TRACK_VARS_COOKIE 2 -#define TRACK_VARS_SERVER 3 -#define TRACK_VARS_ENV 4 -#define TRACK_VARS_FILES 5 - -struct _php_tick_function_entry; - -typedef struct _arg_separators { - char *output; - char *input; -} arg_separators; - -struct _php_core_globals { - zend_bool magic_quotes_gpc; - zend_bool magic_quotes_runtime; - zend_bool magic_quotes_sybase; - - zend_bool allow_call_time_pass_reference; - zend_bool zend_set_utility_values; - zend_bool output_buffering; - zend_bool implicit_flush; - - zend_bool safe_mode; - char *safe_mode_include_dir; - zend_bool safe_mode_gid; - zend_bool sql_safe_mode; - zend_bool enable_dl; - - char *output_handler; - - char *safe_mode_exec_dir; - - long memory_limit; - - zend_bool track_errors; - zend_bool display_errors; - zend_bool display_startup_errors; - zend_bool log_errors; - char *error_log; - - char *doc_root; - char *user_dir; - char *include_path; - char *open_basedir; - char *extension_dir; - - char *upload_tmp_dir; - long upload_max_filesize; - - char *error_append_string; - char *error_prepend_string; - - char *auto_prepend_file; - char *auto_append_file; - - arg_separators arg_separator; - - char *gpc_order; - char *variables_order; - - HashTable rfc1867_protected_variables; - - short connection_status; - short ignore_user_abort; - - unsigned char header_is_being_sent; - - zend_llist tick_functions; - - zval *http_globals[6]; - - zend_bool expose_php; - - zend_bool register_globals; - zend_bool register_argc_argv; - - zend_bool y2k_compliance; - - zend_bool html_errors; - zend_bool xmlrpc_errors; - - long xmlrpc_error_number; - - - zend_bool modules_activated; - - zend_bool file_uploads; - - zend_bool during_request_startup; - - zend_bool allow_url_fopen; - - zend_bool always_populate_raw_post_data; -}; - - -#endif /* PHP_GLOBALS_H */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/main/php_ini.c b/main/php_ini.c deleted file mode 100644 index b23cd5cbb6..0000000000 --- a/main/php_ini.c +++ /dev/null @@ -1,382 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ - */ - - -#include "php.h" -#ifndef PHP_WIN32 -#include "build-defs.h" -#endif -#include "ext/standard/info.h" -#include "zend_ini.h" -#include "php_ini.h" -#include "ext/standard/dl.h" -#include "zend_extensions.h" -#include "zend_highlight.h" - -typedef struct _php_extension_lists { - zend_llist engine; - zend_llist functions; -} php_extension_lists; - - -/* True globals */ -static HashTable configuration_hash; -PHPAPI char *php_ini_opened_path=NULL; -static php_extension_lists extension_lists; - -/* {{{ php_ini_displayer_cb - */ -static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type) -{ - if (ini_entry->displayer) { - ini_entry->displayer(ini_entry, type); - } else { - char *display_string; - uint display_string_length, esc_html=0; - - if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { - if (ini_entry->orig_value) { - display_string = ini_entry->orig_value; - display_string_length = ini_entry->orig_value_length; - esc_html=1; - } else { - display_string = "<i>no value</i>"; - display_string_length = sizeof("<i>no value</i>")-1; - } - } else if (ini_entry->value && ini_entry->value[0]) { - display_string = ini_entry->value; - display_string_length = ini_entry->value_length; - esc_html=1; - } else { - display_string = "<i>no value</i>"; - display_string_length = sizeof("<i>no value</i>")-1; - } - if(esc_html) { - zend_html_puts(display_string, display_string_length); - } else { - TSRMLS_FETCH(); - PHPWRITE(display_string, display_string_length); - } - } -} -/* }}} */ - -/* {{{ php_ini_displayer - */ -static int php_ini_displayer(zend_ini_entry *ini_entry, int module_number TSRMLS_DC) -{ - if (ini_entry->module_number != module_number) { - return 0; - } - - PUTS("<tr valign=\"baseline\" bgcolor=\"" PHP_CONTENTS_COLOR "\">"); - PUTS("<td bgcolor=\"" PHP_ENTRY_NAME_COLOR "\"><b>"); - PHPWRITE(ini_entry->name, ini_entry->name_length-1); - PUTS("</b><br></td><td align=\"center\">"); - php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE); - PUTS("</td><td align=\"center\">"); - php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG); - PUTS("</td></tr>\n"); - return 0; -} -/* }}} */ - -/* {{{ display_ini_entries - */ -PHPAPI void display_ini_entries(zend_module_entry *module) -{ - int module_number; - TSRMLS_FETCH(); - - if (module) { - module_number = module->module_number; - } else { - module_number = 0; - } - php_info_print_table_start(); - php_info_print_table_header(3, "Directive", "Local Value", "Master Value"); - zend_hash_apply_with_argument(&EG(ini_directives), (apply_func_arg_t) php_ini_displayer, (void *) (long) module_number TSRMLS_CC); - php_info_print_table_end(); -} -/* }}} */ - -/* php.ini support */ - -#ifdef ZTS -# if (ZEND_DEBUG) -# define ZEND_EXTENSION_TOKEN "zend_extension_debug_ts" -# else -# define ZEND_EXTENSION_TOKEN "zend_extension_ts" -# endif -#else -# if (ZEND_DEBUG) -# define ZEND_EXTENSION_TOKEN "zend_extension_debug" -# else -# define ZEND_EXTENSION_TOKEN "zend_extension" -# endif -#endif - -/* {{{ pvalue_config_destructor - */ -static void pvalue_config_destructor(zval *pvalue) -{ - if (pvalue->type == IS_STRING && pvalue->value.str.val != empty_string) { - free(pvalue->value.str.val); - } -} -/* }}} */ - -/* {{{ php_config_ini_parser_cb - */ -static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, void *arg) -{ - switch (callback_type) { - case ZEND_INI_PARSER_ENTRY: { - zval *entry; - - if (!arg2) { - break; - } - if (!strcasecmp(Z_STRVAL_P(arg1), "extension")) { /* load function module */ - zval copy; - - copy = *arg2; - zval_copy_ctor(©); - copy.refcount = 0; - zend_llist_add_element(&extension_lists.functions, ©); - } else if (!strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */ - char *extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2)); - - zend_llist_add_element(&extension_lists.engine, &extension_name); - } else { - zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, arg2, sizeof(zval), (void **) &entry); - Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry)); - } - } - break; - case ZEND_INI_PARSER_SECTION: - break; - } -} -/* }}} */ - -/* {{{ php_load_function_extension_cb - */ -static void php_load_function_extension_cb(void *arg TSRMLS_DC) -{ - zval *extension = (zval *) arg; - zval zval; - - php_dl(extension, MODULE_PERSISTENT, &zval TSRMLS_CC); -} -/* }}} */ - -/* {{{ php_load_zend_extension_cb - */ -static void php_load_zend_extension_cb(void *arg TSRMLS_DC) -{ - zend_load_extension(*((char **) arg)); -} -/* }}} */ - -/* {{{ php_init_config - */ -int php_init_config(char *php_ini_path_override) -{ - char *env_location, *php_ini_search_path; - int safe_mode_state; - char *open_basedir; - int free_ini_search_path=0; - zend_file_handle fh; - TSRMLS_FETCH(); - - if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1)==FAILURE) { - return FAILURE; - } - - zend_llist_init(&extension_lists.engine, sizeof(zval), (llist_dtor_func_t) free_estring, 1); - zend_llist_init(&extension_lists.functions, sizeof(zval), (llist_dtor_func_t) ZVAL_DESTRUCTOR, 1); - - safe_mode_state = PG(safe_mode); - open_basedir = PG(open_basedir); - - env_location = getenv("PHPRC"); - if (!env_location) { - env_location=""; - } - if (php_ini_path_override) { - php_ini_search_path = php_ini_path_override; - free_ini_search_path = 0; - } else { - char *default_location; - int free_default_location; - -#ifdef PHP_WIN32 - default_location = (char *) emalloc(512); - - if (!GetWindowsDirectory(default_location, 255)) { - default_location[0]=0; - } - free_default_location=1; -#else - default_location = PHP_CONFIG_FILE_PATH; - free_default_location=0; -#endif - php_ini_search_path = (char *) emalloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); - free_ini_search_path = 1; - if(env_location && env_location[0]) { - sprintf(php_ini_search_path, ".%c%s%c%s", ZEND_PATHS_SEPARATOR, env_location, ZEND_PATHS_SEPARATOR, default_location); - } else { - sprintf(php_ini_search_path, ".%c%s", ZEND_PATHS_SEPARATOR, default_location); - } - if (free_default_location) { - efree(default_location); - } - } - - PG(safe_mode) = 0; - PG(open_basedir) = NULL; - - fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC); - if (free_ini_search_path) { - efree(php_ini_search_path); - } - PG(safe_mode) = safe_mode_state; - PG(open_basedir) = open_basedir; - - if (!fh.handle.fp) { - return SUCCESS; /* having no configuration file is ok */ - } - fh.type = ZEND_HANDLE_FP; - fh.filename = php_ini_opened_path; - - zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists); - - if (php_ini_opened_path) { - zval tmp; - - tmp.value.str.len = strlen(php_ini_opened_path); - tmp.value.str.val = zend_strndup(php_ini_opened_path, tmp.value.str.len); - tmp.type = IS_STRING; - zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL); - efree(php_ini_opened_path); - php_ini_opened_path = zend_strndup(tmp.value.str.val, tmp.value.str.len); - } - - return SUCCESS; -} -/* }}} */ - -/* {{{ php_shutdown_config - */ -int php_shutdown_config(void) -{ - zend_hash_destroy(&configuration_hash); - if (php_ini_opened_path) { - free(php_ini_opened_path); - } - return SUCCESS; -} -/* }}} */ - -/* {{{ php_ini_delayed_modules_startup - */ -void php_ini_delayed_modules_startup(TSRMLS_D) -{ - zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb TSRMLS_CC); - zend_llist_apply(&extension_lists.functions, php_load_function_extension_cb TSRMLS_CC); - - zend_llist_destroy(&extension_lists.engine); - zend_llist_destroy(&extension_lists.functions); -} -/* }}} */ - -/* {{{ cfg_get_entry - */ -zval *cfg_get_entry(char *name, uint name_length) -{ - zval *tmp; - - if (zend_hash_find(&configuration_hash, name, name_length, (void **) &tmp)==SUCCESS) { - return tmp; - } else { - return NULL; - } -} -/* }}} */ - -/* {{{ cfg_get_long - */ -PHPAPI int cfg_get_long(char *varname, long *result) -{ - zval *tmp, var; - - if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) { - *result=(long)NULL; - return FAILURE; - } - var = *tmp; - zval_copy_ctor(&var); - convert_to_long(&var); - *result = var.value.lval; - return SUCCESS; -} -/* }}} */ - -/* {{{ cfg_get_double - */ -PHPAPI int cfg_get_double(char *varname, double *result) -{ - zval *tmp, var; - - if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) { - *result=(double)0; - return FAILURE; - } - var = *tmp; - zval_copy_ctor(&var); - convert_to_double(&var); - *result = var.value.dval; - return SUCCESS; -} -/* }}} */ - -/* {{{ cfg_get_string - */ -PHPAPI int cfg_get_string(char *varname, char **result) -{ - zval *tmp; - - if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp)==FAILURE) { - *result=NULL; - return FAILURE; - } - *result = tmp->value.str.val; - return SUCCESS; -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/php_ini.h b/main/php_ini.h deleted file mode 100644 index bc78876e79..0000000000 --- a/main/php_ini.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - -#ifndef PHP_INI_H -#define PHP_INI_H - -#include "zend_ini.h" - -int php_init_config(char *php_ini_path_override); -int php_shutdown_config(void); -void php_ini_delayed_modules_startup(TSRMLS_D); -zval *cfg_get_entry(char *name, uint name_length); - -#define PHP_INI_USER ZEND_INI_USER -#define PHP_INI_PERDIR ZEND_INI_PERDIR -#define PHP_INI_SYSTEM ZEND_INI_SYSTEM - -#define PHP_INI_ALL ZEND_INI_ALL - -#define php_ini_entry zend_ini_entry - -#define PHP_INI_MH ZEND_INI_MH -#define PHP_INI_DISP ZEND_INI_DISP - -#define PHP_INI_BEGIN ZEND_INI_BEGIN -#define PHP_INI_END ZEND_INI_END - -#define PHP_INI_ENTRY3_EX ZEND_INI_ENTRY3_EX -#define PHP_INI_ENTRY3 ZEND_INI_ENTRY3 -#define PHP_INI_ENTRY2_EX ZEND_INI_ENTRY2_EX -#define PHP_INI_ENTRY2 ZEND_INI_ENTRY2 -#define PHP_INI_ENTRY1_EX ZEND_INI_ENTRY1_EX -#define PHP_INI_ENTRY1 ZEND_INI_ENTRY1 -#define PHP_INI_ENTRY_EX ZEND_INI_ENTRY_EX -#define PHP_INI_ENTRY ZEND_INI_ENTRY - -#define STD_PHP_INI_ENTRY STD_ZEND_INI_ENTRY -#define STD_PHP_INI_ENTRY_EX STD_ZEND_INI_ENTRY_EX -#define STD_PHP_INI_BOOLEAN STD_ZEND_INI_BOOLEAN - -#define PHP_INI_DISPLAY_ORIG ZEND_INI_DISPLAY_ORIG -#define PHP_INI_DISPLAY_ACTIVE ZEND_INI_DISPLAY_ACTIVE - -#define PHP_INI_STAGE_STARTUP ZEND_INI_STAGE_STARTUP -#define PHP_INI_STAGE_SHUTDOWN ZEND_INI_STAGE_SHUTDOWN -#define PHP_INI_STAGE_ACTIVATE ZEND_INI_STAGE_ACTIVATE -#define PHP_INI_STAGE_DEACTIVATE ZEND_INI_STAGE_DEACTIVATE -#define PHP_INI_STAGE_RUNTIME ZEND_INI_STAGE_RUNTIME - -#define php_ini_boolean_displayer_cb zend_ini_boolean_displayer_cb -#define php_ini_color_displayer_cb zend_ini_color_displayer_cb - -#define php_alter_ini_entry zend_alter_ini_entry - -#define php_ini_long zend_ini_long -#define php_ini_double zend_ini_double -#define php_ini_string zend_ini_string - -#endif /* PHP_INI_H */ diff --git a/main/php_logos.c b/main/php_logos.c deleted file mode 100644 index 28329234ef..0000000000 --- a/main/php_logos.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Hartmut Holzgraefe <hartmut@six.de> | - +----------------------------------------------------------------------+ -*/ - -#include "php.h" -#include "logos.h" -#include "php_logos.h" -#include "ext/standard/info.h" -#include "SAPI.h" - -typedef struct _php_info_logo { - char *mimetype; - int mimelen; - unsigned char *data; - int size; -} php_info_logo; - -HashTable phpinfo_logo_hash; - -PHPAPI int php_register_info_logo(char *logo_string, char *mimetype, unsigned char *data, int size) -{ - php_info_logo info_logo; - - info_logo.mimetype = mimetype; - info_logo.mimelen = strlen(mimetype); - info_logo.data = data; - info_logo.size = size; - - return zend_hash_add(&phpinfo_logo_hash, logo_string, strlen(logo_string), &info_logo, sizeof(php_info_logo), NULL); -} - -PHPAPI int php_unregister_info_logo(char *logo_string) -{ - return zend_hash_del(&phpinfo_logo_hash, logo_string, strlen(logo_string)); -} - -int php_init_info_logos(void) -{ - if(zend_hash_init(&phpinfo_logo_hash, 0, NULL, NULL, 1)==FAILURE) - return FAILURE; - - php_register_info_logo(PHP_LOGO_GUID , "image/gif", php_logo , sizeof(php_logo)); - php_register_info_logo(PHP_EGG_LOGO_GUID, "image/gif", php_egg_logo, sizeof(php_egg_logo)); - php_register_info_logo(ZEND_LOGO_GUID , "image/gif", zend_logo , sizeof(zend_logo)); - - return SUCCESS; -} - -int php_shutdown_info_logos(void) -{ - zend_hash_destroy(&phpinfo_logo_hash); - return SUCCESS; -} - -#define CONTENT_TYPE_HEADER "Content-Type: " -int php_info_logos(const char *logo_string TSRMLS_DC) -{ - php_info_logo *logo_image; - char *content_header; - int len; - - if(FAILURE==zend_hash_find(&phpinfo_logo_hash, (char *) logo_string, strlen(logo_string), (void **)&logo_image)) - return 0; - - len=strlen(CONTENT_TYPE_HEADER)+logo_image->mimelen; - content_header=malloc(len+1); - if(!content_header) return 0; - strcpy(content_header, CONTENT_TYPE_HEADER); - strcat(content_header, logo_image->mimetype); - sapi_add_header(content_header, len, 1); - free(content_header); - - PHPWRITE(logo_image->data, logo_image->size); - return 1; -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/php_logos.h b/main/php_logos.h deleted file mode 100644 index e6e2028bae..0000000000 --- a/main/php_logos.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _PHP_LOGOS_H -#define _PHP_LOGOS_H - -PHPAPI int php_register_info_logo(char *logo_string, char *mimetype, unsigned char *data, int size); -PHPAPI int php_unregister_info_logo(char *logo_string); -int php_init_info_logos(void); -int php_shutdown_info_logos(void); -int php_info_logos(const char *logo_string TSRMLS_DC); - -#endif /* _PHP_LOGOS_H */ diff --git a/main/php_main.h b/main/php_main.h deleted file mode 100644 index 9595df11db..0000000000 --- a/main/php_main.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Andi Gutmans <andi@zend.com> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ - */ - - -/* $Id$ */ - - -#ifndef PHP_MAIN_H -#define PHP_MAIN_H - -#include "zend_globals.h" -#include "php_globals.h" -#include "SAPI.h" - -PHPAPI int php_request_startup(TSRMLS_D); -PHPAPI void php_request_shutdown(void *dummy); -PHPAPI void php_request_shutdown_for_exec(void *dummy); -PHPAPI int php_module_startup(sapi_module_struct *sf); -PHPAPI void php_module_shutdown(TSRMLS_D); -PHPAPI void php_module_shutdown_for_exec(void); -PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals); - -PHPAPI int php_startup_extensions(zend_module_entry **ptr, int count); - -PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC); -PHPAPI int php_handle_special_queries(TSRMLS_D); -PHPAPI int php_lint_script(zend_file_handle *file TSRMLS_DC); - -PHPAPI void php_handle_aborted_connection(void); -PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC); - -extern void php_call_shutdown_functions(void); - -/* environment module */ -extern int php_init_environ(void); -extern int php_shutdown_environ(void); - -#if defined(MBSTR_ENC_TRANS) -#define php_treat_data mbstr_treat_data -#endif - -#endif diff --git a/main/php_network.h b/main/php_network.h deleted file mode 100644 index 43ce3ce182..0000000000 --- a/main/php_network.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Stig Venaas <venaas@uninett.no> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -#ifndef _PHP_NETWORK_H -#define _PHP_NETWORK_H - -#ifdef PHP_WIN32 -# ifndef WINNT -# define WINNT 1 -# endif -# undef FD_SETSIZE -# include "arpa/inet.h" -# define socklen_t unsigned int -#endif - -#ifdef HAVE_NETINET_IN_H -# include <netinet/in.h> -#endif - -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif - -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#endif - - - -int php_hostconnect(char *host, unsigned short port, int socktype, int timeout); -PHPAPI int php_connect_nonb(int sockfd, struct sockaddr *addr, socklen_t addrlen, struct timeval *timeout); - -#endif /* _PHP_NETWORK_H */ - -/* - * Local variables: - * tab-width: 8 - * c-basic-offset: 8 - * End: - */ diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c deleted file mode 100644 index ebbc6211f3..0000000000 --- a/main/php_open_temporary_file.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ - */ - -#include "php.h" - -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#ifdef PHP_WIN32 -#include <windows.h> -#include <winsock.h> -#define O_RDONLY _O_RDONLY -#include "win32/param.h" -#include "win32/winutil.h" -#else -#include <sys/param.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netdb.h> -#if HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#endif -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#endif - -#ifdef HAVE_SYS_FILE_H -#include <sys/file.h> -#endif - -#if !defined(P_tmpdir) -#define P_tmpdir "" -#endif - -/* {{{ php_do_open_temporary_file */ - -/* Loosely based on a tempnam() implementation by UCLA */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -static FILE *php_do_open_temporary_file(char *path, const char *pfx, char **opened_path_p TSRMLS_DC) -{ - char *trailing_slash; - FILE *fp; - char *opened_path; -#ifndef PHP_WIN32 - int fd; -#endif - - if (!path) { - return NULL; - } - - if (!(opened_path = emalloc(MAXPATHLEN))) { - return NULL; - } - - if (*path+strlen(path)-1 == '/') { - trailing_slash = ""; - } else { - trailing_slash = "/"; - } - - (void)snprintf(opened_path, MAXPATHLEN, "%s%s%sXXXXXX", path, trailing_slash, pfx); - -#ifdef PHP_WIN32 - if (GetTempFileName(path, pfx, 0, opened_path)) { - fp = VCWD_FOPEN(opened_path, "wb"); - } else { - fp = NULL; - } -#elif defined(HAVE_MKSTEMP) - fd = mkstemp(opened_path); - if (fd==-1) { - fp = NULL; - } else { - fp = fdopen(fd, "wb"); - } -#else - if (mktemp(opened_path)) { - fp = VCWD_FOPEN(opened_path, "wb"); - } else { - fp = NULL; - } -#endif - if (!fp || !opened_path_p) { - efree(opened_path); - } else { - *opened_path_p = opened_path; - } - return fp; -} -/* }}} */ - -/* {{{ php_open_temporary_file - * - * Unlike tempnam(), the supplied dir argument takes precedence - * over the TMPDIR environment variable - * This function should do its best to return a file pointer to a newly created - * unique file, on every platform. - */ -PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC) -{ - static char path_tmp[] = "/tmp"; - FILE *fp; - - - if (!pfx) { - pfx = "tmp."; - } - - if (opened_path_p) { - *opened_path_p = NULL; - } - - if ((fp=php_do_open_temporary_file((char *) dir, pfx, opened_path_p TSRMLS_CC))) { - return fp; - } - - if ((fp=php_do_open_temporary_file(getenv("TMPDIR"), pfx, opened_path_p TSRMLS_CC))) { - return fp; - } -#if PHP_WIN32 - { - char *TempPath; - - TempPath = (char *) emalloc(MAXPATHLEN); - if (GetTempPath(MAXPATHLEN, TempPath)) { - fp = php_do_open_temporary_file(TempPath, pfx, opened_path_p TSRMLS_CC); - } - efree(TempPath); - return fp; - } -#else - if ((fp=php_do_open_temporary_file(P_tmpdir, pfx, opened_path_p TSRMLS_CC))) { - return fp; - } - - if ((fp=php_do_open_temporary_file(path_tmp, pfx, opened_path_p TSRMLS_CC))) { - return fp; - } -#endif - - return NULL; -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/php_open_temporary_file.h b/main/php_open_temporary_file.h deleted file mode 100644 index 743c7cca6b..0000000000 --- a/main/php_open_temporary_file.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - -#ifndef PHP_OPEN_TEMPORARY_FILE_H -#define PHP_OPEN_TEMPORARY_FILE_H - -PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC); - -#endif /* PHP_OPEN_TEMPORARY_FILE_H */ diff --git a/main/php_output.h b/main/php_output.h deleted file mode 100644 index f489532b0b..0000000000 --- a/main/php_output.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_OUTPUT_H -#define PHP_OUTPUT_H - -#include "php.h" - -typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC); - -PHPAPI void php_output_startup(void); -PHPAPI void php_output_activate(TSRMLS_D); -PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC); -void php_output_register_constants(TSRMLS_D); -PHPAPI int php_body_write(const char *str, uint str_length TSRMLS_DC); -PHPAPI int php_header_write(const char *str, uint str_length TSRMLS_DC); -PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size TSRMLS_DC); -PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS_DC); -PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC); -PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC); -PHPAPI int php_ob_get_length(zval *p TSRMLS_DC); -PHPAPI void php_start_implicit_flush(TSRMLS_D); -PHPAPI void php_end_implicit_flush(TSRMLS_D); -PHPAPI char *php_get_output_start_filename(TSRMLS_D); -PHPAPI int php_get_output_start_lineno(TSRMLS_D); -PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t internal_output_handler, uint buffer_size TSRMLS_DC); - -PHP_FUNCTION(ob_start); -PHP_FUNCTION(ob_end_flush); -PHP_FUNCTION(ob_end_clean); -PHP_FUNCTION(ob_get_contents); -PHP_FUNCTION(ob_get_length); -PHP_FUNCTION(ob_implicit_flush); - -typedef struct _php_ob_buffer { - char *buffer; - uint size; - uint text_length; - int block_size; - uint chunk_size; - int status; - zval *output_handler; - php_output_handler_func_t internal_output_handler; - char *internal_output_handler_buffer; - uint internal_output_handler_buffer_size; -} php_ob_buffer; - -typedef struct _php_output_globals { - int (*php_body_write)(const char *str, uint str_length TSRMLS_DC); /* string output */ - int (*php_header_write)(const char *str, uint str_length TSRMLS_DC); /* unbuffer string output */ - php_ob_buffer active_ob_buffer; - unsigned char implicit_flush; - char *output_start_filename; - int output_start_lineno; - zend_stack ob_buffers; - int ob_nesting_level; - zend_bool ob_lock; - zend_bool disable_output; -} php_output_globals; - - -#ifdef ZTS -#define OG(v) TSRMG(output_globals_id, php_output_globals *, v) -ZEND_API extern int output_globals_id; -#else -#define OG(v) (output_globals.v) -ZEND_API extern php_output_globals output_globals; -#endif - -#define PHP_OUTPUT_HANDLER_START (1<<0) -#define PHP_OUTPUT_HANDLER_CONT (1<<1) -#define PHP_OUTPUT_HANDLER_END (1<<2) - -#endif /* PHP_OUTPUT_H */ diff --git a/main/php_realpath.c b/main/php_realpath.c deleted file mode 100644 index 8c7cef5f86..0000000000 --- a/main/php_realpath.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sander Steffann (sander@steffann.nl) | - +----------------------------------------------------------------------+ - */ - -#include "php.h" - -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <sys/stat.h> - -#ifndef MAXSYMLINKS -#define MAXSYMLINKS 32 -#endif - -#ifndef S_ISDIR -#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) -#endif - -char *php_realpath(char *path, char resolved_path[]); - -#ifdef PHP_WIN32 -#define IS_SLASH(p) ((p) == '/' || (p) == '\\') -#else -#define IS_SLASH(p) ((p) == '/') -#endif - -char *php_realpath(char *path, char resolved_path []) { - char path_construction[MAXPATHLEN]; /* We build the result in here */ - char *writepos; /* Position to write next char */ - - char path_copy[MAXPATHLEN]; /* A work-copy of the path */ - char *workpos; /* working position in *path */ - -#if !defined(PHP_WIN32) - char buf[MAXPATHLEN]; /* Buffer for readlink */ - int linklength; /* The result from readlink */ -#endif - int linkcount = 0; /* Count symlinks to avoid loops */ - - struct stat filestat; /* result from stat */ - -#ifdef PHP_WIN32 - char *temppos; /* position while counting '.' */ - int dotcount; /* number of '.' */ - int t; /* counter */ -#endif - - /* Set the work-position to the beginning of the given path */ - strcpy(path_copy, path); - workpos = path_copy; - -#ifdef PHP_WIN32 - /* Find out where we start - Windows version */ - if (IS_SLASH(*workpos)) { - /* We start at the root of the current drive */ - /* Get the current directory */ - if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) { - /* Unable to get cwd */ - resolved_path[0] = 0; - return NULL; - } - /* We only need the first three chars (for example "C:\") */ - path_construction[3] = 0; - workpos++; - } else if (workpos[1] == ':') { - /* A drive-letter is specified, copy it */ - strncpy(path_construction, path, 2); - strcat(path_construction, "\\"); - workpos++; - workpos++; - } else { - /* Use the current directory */ - if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) { - /* Unable to get cwd */ - resolved_path[0] = 0; - return NULL; - } - strcat(path_construction, "\\"); - } -#else - /* Find out where we start - Unix version */ - if (*workpos == '/') { - /* We start at the root */ - strcpy(path_construction, "/"); - workpos++; - } else { - /* Use the current directory */ - if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) { - /* Unable to get cwd */ - resolved_path[0] = 0; - return NULL; - } - strcat(path_construction, "/"); - } -#endif - - /* Set the next-char-position */ - writepos = &path_construction[strlen(path_construction)]; - - /* Go to the end, then stop */ - while(*workpos != 0) { - /* Strip (back)slashes */ - while(IS_SLASH(*workpos)) workpos++; - -#ifdef PHP_WIN32 - /* reset dotcount */ - dotcount = 0; - - /* Look for .. */ - if ((workpos[0] == '.') && (workpos[1] != 0)) { - /* Windows accepts \...\ as \..\..\, \....\ as \..\..\..\, etc */ - /* At least Win98 does */ - - temppos = workpos; - while(*temppos++ == '.') { - dotcount++; - if (!IS_SLASH(*temppos) && (*temppos != 0) && (*temppos != '.')) { - /* This is not a /../ component, but a filename that starts with '.' */ - dotcount = 0; - } - } - - /* Go back dotcount-1 times */ - for (t=0 ; t<(dotcount-1) ; t++) { - workpos++; /* move to next '.' */ - - /* Can we still go back? */ - if ((writepos-3) <= path_construction) return NULL; - - /* Go back */ - writepos--; /* move to '\' */ - writepos--; - while(!IS_SLASH(*writepos)) writepos--; /* skip until previous '\\' */ - } - workpos++; - } - - /* No special case */ - if (dotcount == 0) { - /* Append */ - while(!IS_SLASH(*workpos) && (*workpos != 0)) { - *writepos++ = *workpos++; - } - } - - /* Just one '.', go to next element */ - if (dotcount == 1) { - while(!IS_SLASH(*workpos) && (*workpos != 0)) { - *workpos++; - } - - /* Avoid double \ in the result */ - writepos--; - } - - /* If it was a directory, append a slash */ - if (IS_SLASH(*workpos)) { - *writepos++ = *workpos++; - } - *writepos = 0; -#else /* defined(PHP_WIN32) */ - /* Look for .. */ - if ((workpos[0] == '.') && (workpos[1] != 0)) { - if ((workpos[1] == '.') && ((workpos[2] == '/') || (workpos[2] == 0))) { - /* One directory back */ - /* Set pointers to right position */ - workpos++; /* move to second '.' */ - workpos++; /* move to '/' */ - - /* Only apply .. if not in root */ - if ((writepos-1) > path_construction) { - writepos--; /* move to '/' */ - while(*--writepos != '/') ; /* skip until previous '/' */ - } - } else { - if (workpos[1] == '/') { - /* Found a /./ skip it */ - workpos++; /* move to '/' */ - - /* Avoid double / in the result */ - writepos--; - } else { - /* No special case, the name just started with a . */ - /* Append */ - while((*workpos != '/') && (*workpos != 0)) { - *writepos++ = *workpos++; - } - } - } - } else { - /* No special case */ - /* Append */ - while((*workpos != '/') && (*workpos != 0)) { - *writepos++ = *workpos++; - } - } - -#if HAVE_SYMLINK - /* We are going to use path_construction, so close it */ - *writepos = 0; - - /* Check the current location to see if it is a symlink */ - if((linklength = readlink(path_construction, buf, MAXPATHLEN)) != -1) { - /* Check linkcount */ - if (linkcount > MAXSYMLINKS) return NULL; - - /* Count this symlink */ - linkcount++; - - /* Set end of buf */ - buf[linklength] = 0; - - /* Check for overflow */ - if ((strlen(workpos) + strlen(buf) + 1) >= MAXPATHLEN) return NULL; - - /* Remove the symlink-component wrom path_construction */ - writepos--; /* move to '/' */ - while(*--writepos != '/') ; /* skip until previous '/' */ - *++writepos = 0; /* end of string after '/' */ - - /* If the symlink starts with a '/', empty path_construction */ - if (*buf == '/') { - *path_construction = 0; - writepos = path_construction; - } - - /* Insert symlink into path_copy */ - strcat(buf, workpos); - strcpy(path_copy, buf); - workpos = path_copy; - } -#endif /* HAVE_SYMLINK */ - - /* If it was a directory, append a slash */ - if (*workpos == '/') { - *writepos++ = *workpos++; - } - *writepos = 0; -#endif /* defined(PHP_WIN32) */ - } - - /* Check if the resolved path is a directory */ - if (V_STAT(path_construction, &filestat) != 0) { - if (errno != ENOENT) return NULL; - } else { - if (S_ISDIR(filestat.st_mode)) { - /* It's a directory, append a / if needed */ - if (*(writepos-1) != '/') { - /* Check for overflow */ - if ((strlen(workpos) + 2) >= MAXPATHLEN) { - return NULL; - } - *writepos++ = '/'; - *writepos = 0; - } - } - } - - strcpy(resolved_path, path_construction); - return resolved_path; -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/main/php_reentrancy.h b/main/php_reentrancy.h deleted file mode 100644 index 8e9c674a14..0000000000 --- a/main/php_reentrancy.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - - -#ifndef PHP_REENTRANCY_H -#define PHP_REENTRANCY_H - -#include "php.h" - -#include <sys/types.h> -#ifdef HAVE_DIRENT_H -#include <dirent.h> -#endif -#include <time.h> - -/* currently, PHP does not check for these functions, but assumes - that they are available on all systems. */ - -#define HAVE_LOCALTIME 1 -#define HAVE_GMTIME 1 -#define HAVE_ASCTIME 1 -#define HAVE_CTIME 1 - -#if defined(PHP_IRIX_TIME_R) -#undef HAVE_ASCTIME_R -#undef HAVE_CTIME_R -#endif - -#if defined(PHP_HPUX_TIME_R) -#undef HAVE_LOCALTIME_R -#undef HAVE_ASCTIME_R -#undef HAVE_CTIME_R -#undef HAVE_GMTIME_R -#endif - -#if defined(HAVE_POSIX_READDIR_R) -#define php_readdir_r readdir_r -#else -PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry, - struct dirent **result); -#endif - -#if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME) -#define PHP_NEED_REENTRANCY 1 -PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm); -#else -#define php_localtime_r localtime_r -#ifdef MISSING_LOCALTIME_R_DECL -struct tm *localtime_r(const time_t *const timep, struct tm *p_tm); -#endif -#endif - - -#if !defined(HAVE_CTIME_R) && defined(HAVE_CTIME) -#define PHP_NEED_REENTRANCY 1 -PHPAPI char *php_ctime_r(const time_t *clock, char *buf); -#else -#define php_ctime_r ctime_r -#ifdef MISSING_CTIME_R_DECL -char *ctime_r(const time_t *clock, char *buf); -#endif -#endif - - -#if !defined(HAVE_ASCTIME_R) && defined(HAVE_ASCTIME) -#define PHP_NEED_REENTRANCY 1 -PHPAPI char *php_asctime_r(const struct tm *tm, char *buf); -#else -#define php_asctime_r asctime_r -#ifdef MISSING_ASCTIME_R_DECL -char *asctime_r(const struct tm *tm, char *buf); -#endif -#endif - - -#if !defined(HAVE_GMTIME_R) && defined(HAVE_GMTIME) -#define PHP_NEED_REENTRANCY 1 -PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm); -#else -#define php_gmtime_r gmtime_r -#ifdef MISSING_GMTIME_R_DECL -struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm); -#endif -#endif - -#if !defined(HAVE_STRTOK_R) -PHPAPI char *php_strtok_r(char *s, const char *delim, char **last); -#else -#define php_strtok_r strtok_r -#ifdef MISSING_STRTOK_R_DECL -char *strtok_r(char *s, const char *delim, char **last); -#endif -#endif - -#if !defined(HAVE_RAND_R) -PHPAPI int php_rand_r(unsigned int *seed); -#else -#define php_rand_r rand_r -#endif - -#if !defined(ZTS) -#undef PHP_NEED_REENTRANCY -#endif - -#if defined(PHP_NEED_REENTRANCY) -void reentrancy_startup(void); -void reentrancy_shutdown(void); -#else -#define reentrancy_startup() -#define reentrancy_shutdown() -#endif - -#endif diff --git a/main/php_regex.h b/main/php_regex.h deleted file mode 100644 index c1d1e0c232..0000000000 --- a/main/php_regex.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef PHP_REGEX_H -#define PHP_REGEX_H - -/* - * REGEX means: - * 0.. system regex - * 1.. bundled regex - */ - -#if REGEX -/* get aliases */ -#include "regex/regex_extra.h" -#include "regex/regex.h" - -/* get rid of aliases */ -#define PHP_NO_ALIASES -#include "regex/regex_extra.h" -#undef PHP_NO_ALIASES - -#undef _PCREPOSIX_H -#define _PCREPOSIX_H 1 - -#ifndef _REGEX_H -#define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */ -#endif -#ifndef _REGEX_H_ -#define _REGEX_H_ 1 -#endif -#ifndef _RX_H -#define _RX_H 1 /* Try defining these for Linux to */ -#endif -#ifndef __REGEXP_LIBRARY_H__ -#define __REGEXP_LIBRARY_H__ 1 /* avoid Apache including regex.h */ -#endif -#ifndef _H_REGEX -#define _H_REGEX 1 /* This one is for AIX */ -#endif -#elif REGEX == 0 -#include <regex.h> -#ifndef _REGEX_H_ -#define _REGEX_H_ 1 -#endif -#endif - -#endif /* PHP_REGEX_H */ diff --git a/main/php_sprintf.c b/main/php_sprintf.c deleted file mode 100644 index ecbd6b0238..0000000000 --- a/main/php_sprintf.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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 <stdio.h> -#include <stdarg.h> -#include "php_config.h" - -#if PHP_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 */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/php_streams.h b/main/php_streams.h deleted file mode 100755 index 5083b5ba29..0000000000 --- a/main/php_streams.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: | - | Wez Furlong (wez@thebrainroom.com) | - +----------------------------------------------------------------------+ - */ - -#ifndef PHP_STREAMS_H -#define PHP_STREAMS_H - -#if HAVE_PHP_STREAM - -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#endif - -/* See README.STREAMS in php4 root dir for more info about this stuff */ - -typedef struct _php_stream php_stream; - -typedef struct _php_stream_ops { - /* stdio like functions - these are mandatory! */ - size_t (*write)(php_stream * stream, const char * buf, size_t count); - size_t (*read)(php_stream * stream, char * buf, size_t count); - int (*close)(php_stream * stream); - int (*flush)(php_stream * stream); - /* these are optional */ - int (*seek)(php_stream * stream, off_t offset, int whence); - char * (*gets)(php_stream * stream, char * buf, size_t size); - int (*cast)(php_stream * stream, int castas, void ** ret); - const char * label; /* label for this ops structure */ -} php_stream_ops; - -struct _php_stream { - php_stream_ops * ops; - void * abstract; /* convenience pointer for abstraction */ - int is_persistent; - char mode[16]; /* "rwb" etc. ala stdio */ - /* so we know how to clean it up correctly. This should be set to - * PHP_STREAM_FCLOSE_XXX as appropriate */ - int fclose_stdiocast; - FILE * stdiocast; /* cache this, otherwise we might leak! */ -}; /* php_stream */ -#define PHP_STREAM_FCLOSE_NONE 0 -#define PHP_STREAM_FCLOSE_FDOPEN 1 -#define PHP_STREAM_FCLOSE_FOPENCOOKIE 2 - - -/* allocate a new stream for a particular ops */ -PHPAPI php_stream * php_stream_alloc(php_stream_ops * ops, void * abstract, int persistent, const char * mode); - -PHPAPI int php_stream_free(php_stream * stream, int call_dtor); -#define php_stream_close(stream) php_stream_free(stream, 1) - -PHPAPI int php_stream_seek(php_stream * stream, off_t offset, int whence); -#define php_stream_rewind(stream) php_stream_seek(stream, 0L, SEEK_SET) -PHPAPI off_t php_stream_tell(php_stream * stream); -PHPAPI size_t php_stream_read(php_stream * stream, char * buf, size_t count); -PHPAPI size_t php_stream_write(php_stream * stream, const char * buf, size_t count); -PHPAPI int php_stream_eof(php_stream * stream); -PHPAPI int php_stream_getc(php_stream * stream); -PHPAPI int php_stream_flush(php_stream * stream); -PHPAPI char *php_stream_gets(php_stream * stream, char *buf, size_t maxlen); - -/* operations for a stdio FILE; the FILE * must be placed in stream->abstract */ -extern php_stream_ops php_stream_stdio_ops; -/* like fopen, but returns a stream */ -PHPAPI php_stream * php_stream_fopen(const char * filename, const char * mode); - -/* coerce the stream into some other form */ -/* cast as a stdio FILE * */ -#define PHP_STREAM_AS_STDIO 0 -/* cast as a POSIX fd or socketd */ -#define PHP_STREAM_AS_FD 1 -/* cast as a socketd */ -#define PHP_STREAM_AS_SOCKETD 2 - -PHPAPI int php_stream_cast(php_stream * stream, int castas, void ** ret, int show_err); -/* use this to check if a stream can be cast into another form */ -#define php_stream_can_cast(stream, as) php_stream_cast(stream, as, NULL, 0) - -/* use this to check if a stream is of a particular type: - * PHPAPI int php_stream_is(php_stream * stream, php_stream_ops * ops); */ -#define php_stream_is(stream, anops) (stream->ops == anops) - -#endif /* HAVE_PHP_STREAM */ - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/php_syslog.h b/main/php_syslog.h deleted file mode 100644 index 279da71c92..0000000000 --- a/main/php_syslog.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef PHP_SYSLOG_H -#define PHP_SYSLOG_H - -#ifdef PHP_WIN32 -#include "win32/syslog.h" -#else -#include "php_config.h" -#ifdef HAVE_SYSLOG_H -#include <syslog.h> -#endif -#endif - -/* - * The SCO OpenServer 5 Development System (not the UDK) - * defines syslog to std_syslog. - */ - -#ifdef syslog - -#ifdef HAVE_STD_SYSLOG -#define php_syslog std_syslog -#endif - -#undef syslog - -#endif - -#ifndef php_syslog -#define php_syslog syslog -#endif - -#endif diff --git a/main/php_ticks.c b/main/php_ticks.c deleted file mode 100644 index 684524ea82..0000000000 --- a/main/php_ticks.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Stig Bakken <ssb@fast.no> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#include "php.h" -#include "php_ticks.h" - -int php_startup_ticks(TSRMLS_D) -{ - zend_llist_init(&PG(tick_functions), sizeof(void(*)(int)), NULL, 1); - return SUCCESS; -} - -void php_shutdown_ticks(TSRMLS_D) -{ - zend_llist_destroy(&PG(tick_functions)); -} - -static int php_compare_tick_functions(void *elem1, void *elem2) -{ - void(*func1)(int); - void(*func2)(int); - memcpy(&func1, elem1, sizeof(void(*)(int))); - memcpy(&func2, elem2, sizeof(void(*)(int))); - return (func1 == func2); -} - -PHPAPI void php_add_tick_function(void (*func)(int)) -{ - TSRMLS_FETCH(); - - zend_llist_add_element(&PG(tick_functions), (void *)&func); -} - -PHPAPI void php_remove_tick_function(void (*func)(int)) -{ - TSRMLS_FETCH(); - - zend_llist_del_element(&PG(tick_functions), func, - (int(*)(void*, void*))php_compare_tick_functions); -} - -static void php_tick_iterator(void *data, void *arg TSRMLS_DC) -{ - void (*func)(int); - - memcpy(&func, data, sizeof(void(*)(int))); - func(*((int *)arg)); -} - -void php_run_ticks(int count) -{ - TSRMLS_FETCH(); - - zend_llist_apply_with_argument(&PG(tick_functions), (llist_apply_with_arg_func_t) php_tick_iterator, &count TSRMLS_CC); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/php_ticks.h b/main/php_ticks.h deleted file mode 100644 index d7c42bf037..0000000000 --- a/main/php_ticks.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Stig Bakken <ssb@fast.no> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_TICKS_H -#define PHP_TICKS_H - -int php_startup_ticks(TSRMLS_D); -void php_shutdown_ticks(TSRMLS_D); -void php_run_ticks(int count); -PHPAPI void php_add_tick_function(void (*func)(int)); -PHPAPI void php_remove_tick_function(void (*func)(int)); - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/main/php_variables.c b/main/php_variables.c deleted file mode 100644 index 59cb4d7cad..0000000000 --- a/main/php_variables.c +++ /dev/null @@ -1,337 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -#include <stdio.h> -#include "php.h" -#include "ext/standard/php_standard.h" -#include "php_variables.h" -#include "php_globals.h" -#include "php_content_types.h" -#include "SAPI.h" - -#include "zend_globals.h" - - -PHPAPI void php_register_variable(char *var, char *strval, zval *track_vars_array TSRMLS_DC) -{ - php_register_variable_safe(var, strval, strlen(strval), track_vars_array TSRMLS_CC); -} - -/* binary-safe version */ -PHPAPI void php_register_variable_safe(char *var, char *strval, int str_len, zval *track_vars_array TSRMLS_DC) -{ - zval new_entry; - - /* Prepare value */ - new_entry.value.str.len = str_len; - if (PG(magic_quotes_gpc)) { - new_entry.value.str.val = php_addslashes(strval, new_entry.value.str.len, &new_entry.value.str.len, 0 TSRMLS_CC); - } else { - new_entry.value.str.val = estrndup(strval, new_entry.value.str.len); - } - new_entry.type = IS_STRING; - - php_register_variable_ex(var, &new_entry, track_vars_array TSRMLS_CC); -} - - -PHPAPI void php_register_variable_ex(char *var, zval *val, pval *track_vars_array TSRMLS_DC) -{ - char *p = NULL; - char *ip; /* index pointer */ - char *index; - int var_len, index_len; - zval *gpc_element, **gpc_element_p, **top_gpc_p=NULL; - zend_bool is_array; - zend_bool free_index; - HashTable *symtable1=NULL; - HashTable *symtable2=NULL; - - if (PG(register_globals)) { - symtable1 = EG(active_symbol_table); - } - if (track_vars_array) { - if (symtable1) { - symtable2 = track_vars_array->value.ht; - } else { - symtable1 = track_vars_array->value.ht; - } - } - if (!symtable1) { - /* Nothing to do */ - zval_dtor(val); - return; - } - - /* - * Prepare variable name - */ - ip = strchr(var, '['); - if (ip) { - is_array = 1; - *ip = 0; - } else { - is_array = 0; - } - /* ignore leading spaces in the variable name */ - while (*var && *var==' ') { - var++; - } - var_len = strlen(var); - if (var_len==0) { /* empty variable name, or variable name with a space in it */ - zval_dtor(val); - return; - } - /* ensure that we don't have spaces or dots in the variable name (not binary safe) */ - for (p=var; *p; p++) { - switch(*p) { - case ' ': - case '.': - *p='_'; - break; - } - } - - index = var; - index_len = var_len; - free_index = 0; - - while (1) { - if (is_array) { - char *escaped_index; - - if (!index) { - MAKE_STD_ZVAL(gpc_element); - array_init(gpc_element); - zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p); - } else { - if (PG(magic_quotes_gpc) && (index!=var)) { - /* no need to addslashes() the index if it's the main variable name */ - escaped_index = php_addslashes(index, index_len, &index_len, 0 TSRMLS_CC); - } else { - escaped_index = index; - } - if (zend_hash_find(symtable1, escaped_index, index_len+1, (void **) &gpc_element_p)==FAILURE - || (*gpc_element_p)->type != IS_ARRAY) { - MAKE_STD_ZVAL(gpc_element); - array_init(gpc_element); - zend_hash_update(symtable1, escaped_index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p); - } - if (index!=escaped_index) { - efree(escaped_index); - } - } - if (!top_gpc_p) { - top_gpc_p = gpc_element_p; - } - symtable1 = (*gpc_element_p)->value.ht; - /* ip pointed to the '[' character, now obtain the key */ - index = ++ip; - index_len = 0; - if (*ip=='\n' || *ip=='\r' || *ip=='\t' || *ip==' ') { - ip++; - } - if (*ip==']') { - index = NULL; - } else { - ip = strchr(ip, ']'); - if (!ip) { - php_error(E_WARNING, "Missing ] in %s variable", var); - return; - } - *ip = 0; - index_len = strlen(index); - } - ip++; - if (*ip=='[') { - is_array = 1; - *ip = 0; - } else { - is_array = 0; - } - } else { - MAKE_STD_ZVAL(gpc_element); - gpc_element->value = val->value; - gpc_element->type = val->type; - if (!index) { - zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p); - } else { - zend_hash_update(symtable1, index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p); - } - if (!top_gpc_p) { - top_gpc_p = gpc_element_p; - } - break; - } - } - - if (top_gpc_p) { - if (symtable2) { - zend_hash_update(symtable2, var, var_len+1, top_gpc_p, sizeof(zval *), NULL); - (*top_gpc_p)->refcount++; - } - } -} - - -SAPI_POST_HANDLER_FUNC(php_std_post_handler) -{ - char *var, *val; - char *strtok_buf = NULL; - zval *array_ptr = (zval *) arg; - - var = php_strtok_r(SG(request_info).post_data, "&", &strtok_buf); - - while (var) { - val = strchr(var, '='); - if (val) { /* have a value */ - int val_len; - - *val++ = '\0'; - php_url_decode(var, strlen(var)); - val_len = php_url_decode(val, strlen(val)); - php_register_variable_safe(var, val, val_len, array_ptr TSRMLS_CC); - } - var = php_strtok_r(NULL, "&", &strtok_buf); - } -} - - -void php_treat_data(int arg, char *str, zval* destArray TSRMLS_DC) -{ - char *res = NULL, *var, *val, *separator=NULL; - const char *c_var; - pval *array_ptr; - int free_buffer=0; - char *strtok_buf = NULL; - - switch (arg) { - case PARSE_POST: - case PARSE_GET: - case PARSE_COOKIE: - ALLOC_ZVAL(array_ptr); - array_init(array_ptr); - INIT_PZVAL(array_ptr); - switch (arg) { - case PARSE_POST: - PG(http_globals)[TRACK_VARS_POST] = array_ptr; - break; - case PARSE_GET: - PG(http_globals)[TRACK_VARS_GET] = array_ptr; - break; - case PARSE_COOKIE: - PG(http_globals)[TRACK_VARS_COOKIE] = array_ptr; - break; - } - break; - default: - array_ptr=destArray; - break; - } - - if (arg==PARSE_POST) { - sapi_handle_post(array_ptr TSRMLS_CC); - return; - } - - if (arg == PARSE_GET) { /* GET data */ - c_var = SG(request_info).query_string; - if (c_var && *c_var) { - res = (char *) estrdup(c_var); - free_buffer = 1; - } else { - free_buffer = 0; - } - } else if (arg == PARSE_COOKIE) { /* Cookie data */ - c_var = SG(request_info).cookie_data; - if (c_var && *c_var) { - res = (char *) estrdup(c_var); - free_buffer = 1; - } else { - free_buffer = 0; - } - } else if (arg == PARSE_STRING) { /* String data */ - res = str; - free_buffer = 1; - } - - if (!res) { - return; - } - - switch (arg) { - case PARSE_GET: - case PARSE_STRING: - separator = (char *) estrdup(PG(arg_separator).input); - break; - case PARSE_COOKIE: - separator = ";\0"; - break; - } - - var = php_strtok_r(res, separator, &strtok_buf); - - while (var) { - val = strchr(var, '='); - if (val) { /* have a value */ - int val_len; - - *val++ = '\0'; - php_url_decode(var, strlen(var)); - val_len = php_url_decode(val, strlen(val)); - php_register_variable_safe(var, val, val_len, array_ptr TSRMLS_CC); - } - var = php_strtok_r(NULL, separator, &strtok_buf); - } - - if(arg != PARSE_COOKIE) { - efree(separator); - } - - if (free_buffer) { - efree(res); - } -} - - -void php_import_environment_variables(zval *array_ptr TSRMLS_DC) -{ - char **env, *p, *t; - - for (env = environ; env != NULL && *env != NULL; env++) { - p = strchr(*env, '='); - if (!p) { /* malformed entry? */ - continue; - } - t = estrndup(*env, p - *env); - php_register_variable(t, p+1, array_ptr TSRMLS_CC); - efree(t); - } -} - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/php_variables.h b/main/php_variables.h deleted file mode 100644 index c20ed1f5e1..0000000000 --- a/main/php_variables.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_VARIABLES_H -#define PHP_VARIABLES_H - -#include "php.h" -#include "SAPI.h" - -#define PARSE_POST 0 -#define PARSE_GET 1 -#define PARSE_COOKIE 2 -#define PARSE_STRING 3 - -void php_treat_data(int arg, char *str, zval* destArray TSRMLS_DC); -PHPAPI void php_import_environment_variables(zval *array_ptr TSRMLS_DC); -PHPAPI void php_register_variable(char *var, char *val, pval *track_vars_array TSRMLS_DC); -/* binary-safe version */ -PHPAPI void php_register_variable_safe(char *var, char *val, int val_len, pval *track_vars_array TSRMLS_DC); -PHPAPI void php_register_variable_ex(char *var, zval *val, pval *track_vars_array TSRMLS_DC); - - -#endif /* PHP_VARIABLES_H */ diff --git a/main/php_version.h b/main/php_version.h deleted file mode 100644 index cd8c544248..0000000000 --- a/main/php_version.h +++ /dev/null @@ -1,3 +0,0 @@ -/* automatically generated by configure */ -/* edit configure.in to change version number */ -#define PHP_VERSION "4.0.7-dev" diff --git a/main/reentrancy.c b/main/reentrancy.c deleted file mode 100644 index 80d169baed..0000000000 --- a/main/reentrancy.c +++ /dev/null @@ -1,441 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - - -#include <sys/types.h> -#include <string.h> -#include <errno.h> -#ifdef HAVE_DIRENT_H -#include <dirent.h> -#endif - -#ifdef PHP_WIN32 -#include "win32/readdir.h" -#endif - -#include "php_reentrancy.h" -#include "ext/standard/php_rand.h" /* for RAND_MAX */ - -enum { - LOCALTIME_R, - CTIME_R, - ASCTIME_R, - GMTIME_R, - READDIR_R, - NUMBER_OF_LOCKS -}; - -#if defined(PHP_NEED_REENTRANCY) - -#include <TSRM.h> - -static MUTEX_T reentrant_locks[NUMBER_OF_LOCKS]; - -#define local_lock(x) tsrm_mutex_lock(reentrant_locks[x]) -#define local_unlock(x) tsrm_mutex_unlock(reentrant_locks[x]) - -#else - -#define local_lock(x) -#define local_unlock(x) - -#endif - -#if defined(PHP_IRIX_TIME_R) - -#define HAVE_CTIME_R 1 -#define HAVE_ASCTIME_R 1 - -PHPAPI char *php_ctime_r(const time_t *clock, char *buf) -{ - if (ctime_r(clock, buf, 26) == buf) - return (buf); - return (NULL); -} - -PHPAPI char *php_asctime_r(const struct tm *tm, char *buf) -{ - if (asctime_r(tm, buf, 26) == buf) - return (buf); - return (NULL); -} - -#endif - -#if defined(PHP_HPUX_TIME_R) - -#define HAVE_LOCALTIME_R 1 -#define HAVE_CTIME_R 1 -#define HAVE_ASCTIME_R 1 -#define HAVE_GMTIME_R 1 - -PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm) -{ - if (localtime_r(timep, p_tm) == 0) - return (p_tm); - return (NULL); -} - -PHPAPI char *php_ctime_r(const time_t *clock, char *buf) -{ - if (ctime_r(clock, buf, 26) != -1) - return (buf); - return (NULL); -} - -PHPAPI char *php_asctime_r(const struct tm *tm, char *buf) -{ - if (asctime_r(tm, buf, 26) != -1) - return (buf); - return (NULL); -} - -PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm) -{ - if (gmtime_r(timep, p_tm) == 0) - return (p_tm); - return (NULL); -} - -#endif - -#if !defined(HAVE_POSIX_READDIR_R) - -PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry, - struct dirent **result) -{ -#if defined(HAVE_OLD_READDIR_R) - int ret = 0; - - /* We cannot rely on the return value of readdir_r - as it differs between various platforms - (HPUX returns 0 on success whereas Solaris returns non-zero) - */ - entry->d_name[0] = '\0'; - readdir_r(dirp, entry); - - if (entry->d_name[0] == '\0') { - *result = NULL; - ret = errno; - } else { - *result = entry; - } - return ret; -#else - struct dirent *ptr; - int ret = 0; - - local_lock(READDIR_R); - - errno = 0; - - ptr = readdir(dirp); - - if (!ptr && errno != 0) - ret = errno; - - if (ptr) - memcpy(entry, ptr, sizeof(*ptr)); - - *result = ptr; - - local_unlock(READDIR_R); - - return ret; -#endif -} - -#endif - -#if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME) - -PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm) -{ - struct tm *tmp; - - local_lock(LOCALTIME_R); - - tmp = localtime(timep); - if (tmp) { - memcpy(p_tm, tmp, sizeof(struct tm)); - tmp = p_tm; - } - - local_unlock(LOCALTIME_R); - - return tmp; -} - -#endif - -#if !defined(HAVE_CTIME_R) && defined(HAVE_CTIME) - -PHPAPI char *php_ctime_r(const time_t *clock, char *buf) -{ - char *tmp; - - local_lock(CTIME_R); - - tmp = ctime(clock); - strcpy(buf, tmp); - - local_unlock(CTIME_R); - - return buf; -} - -#endif - -#if !defined(HAVE_ASCTIME_R) && defined(HAVE_ASCTIME) - -PHPAPI char *php_asctime_r(const struct tm *tm, char *buf) -{ - char *tmp; - - local_lock(ASCTIME_R); - - tmp = asctime(tm); - strcpy(buf, tmp); - - local_unlock(ASCTIME_R); - - return buf; -} - -#endif - -#if !defined(HAVE_GMTIME_R) && defined(HAVE_GMTIME) - -PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm) -{ - struct tm *tmp; - - local_lock(GMTIME_R); - - tmp = gmtime(timep); - if (tmp) { - memcpy(p_tm, tmp, sizeof(struct tm)); - tmp = p_tm; - } - - local_unlock(GMTIME_R); - - return tmp; -} - -#endif - -#if defined(PHP_NEED_REENTRANCY) - -void reentrancy_startup(void) -{ - int i; - - for (i = 0; i < NUMBER_OF_LOCKS; i++) { - reentrant_locks[i] = tsrm_mutex_alloc(); - } -} - -void reentrancy_shutdown(void) -{ - int i; - - for (i = 0; i < NUMBER_OF_LOCKS; i++) { - tsrm_mutex_free(reentrant_locks[i]); - } -} - -#endif - -#ifndef HAVE_RAND_R - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>. - */ - -#include <sys/types.h> -#include <stdlib.h> - -static int -do_rand(unsigned long *ctx) -{ - return ((*ctx = *ctx * 1103515245 + 12345) % ((u_long)RAND_MAX + 1)); -} - - -PHPAPI int -php_rand_r(unsigned int *ctx) -{ - u_long val = (u_long) *ctx; - *ctx = do_rand(&val); - return (int) *ctx; -} - -#endif - - -#ifndef HAVE_STRTOK_R - -/* - * Copyright (c) 1998 Softweyr LLC. All rights reserved. - * - * strtok_r, from Berkeley strtok - * Oct 13, 1998 by Wes Peters <wes@softweyr.com> - * - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notices, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notices, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * - * This product includes software developed by Softweyr LLC, the - * University of California, Berkeley, and its contributors. - * - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE - * REGENTS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <stddef.h> - -PHPAPI char * -php_strtok_r(char *s, const char *delim, char **last) -{ - char *spanp; - int c, sc; - char *tok; - - if (s == NULL && (s = *last) == NULL) - { - return NULL; - } - - /* - * Skip (span) leading delimiters (s += strspn(s, delim), sort of). - */ -cont: - c = *s++; - for (spanp = (char *)delim; (sc = *spanp++) != 0; ) - { - if (c == sc) - { - goto cont; - } - } - - if (c == 0) /* no non-delimiter characters */ - { - *last = NULL; - return NULL; - } - tok = s - 1; - - /* - * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). - * Note that delim must have one NUL; we stop if we see that, too. - */ - for (;;) - { - c = *s++; - spanp = (char *)delim; - do - { - if ((sc = *spanp++) == c) - { - if (c == 0) - { - s = NULL; - } - else - { - char *w = s - 1; - *w = '\0'; - } - *last = s; - return tok; - } - } - while (sc != 0); - } - /* NOTREACHED */ -} - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/rfc1867.c b/main/rfc1867.c deleted file mode 100644 index e8efe0851d..0000000000 --- a/main/rfc1867.c +++ /dev/null @@ -1,484 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Rasmus Lerdorf <rasmus@php.net> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -#include <stdio.h> -#include "php.h" -#include "php_open_temporary_file.h" -#include "zend_globals.h" -#include "php_globals.h" -#include "php_variables.h" -#include "rfc1867.h" -#include "ext/standard/type.h" - - -#define NEW_BOUNDARY_CHECK 1 -#define SAFE_RETURN { if (namebuf) efree(namebuf); if (filenamebuf) efree(filenamebuf); if (lbuf) efree(lbuf); if (abuf) efree(abuf); if(arr_index) efree(arr_index); zend_hash_destroy(&PG(rfc1867_protected_variables)); return; } - -/* The longest property name we use in an uploaded file array */ -#define MAX_SIZE_OF_INDEX sizeof("[tmp_name]") - -static void add_protected_variable(char *varname TSRMLS_DC) -{ - int dummy=1; - - zend_hash_add(&PG(rfc1867_protected_variables), varname, strlen(varname)+1, &dummy, sizeof(int), NULL); -} - - -static zend_bool is_protected_variable(char *varname TSRMLS_DC) -{ - return zend_hash_exists(&PG(rfc1867_protected_variables), varname, strlen(varname)+1); -} - - -static void safe_php_register_variable(char *var, char *strval, zval *track_vars_array, zend_bool override_protection TSRMLS_DC) -{ - if (override_protection || !is_protected_variable(var TSRMLS_CC)) { - php_register_variable(var, strval, track_vars_array TSRMLS_CC); - } -} - - -static void safe_php_register_variable_ex(char *var, zval *val, pval *track_vars_array, zend_bool override_protection TSRMLS_DC) -{ - if (override_protection || !is_protected_variable(var TSRMLS_CC)) { - php_register_variable_ex(var, val, track_vars_array TSRMLS_CC); - } -} - - -static void register_http_post_files_variable(char *strvar, char *val, zval *http_post_files, zend_bool override_protection TSRMLS_DC) -{ - int register_globals = PG(register_globals); - - PG(register_globals) = 0; - safe_php_register_variable(strvar, val, http_post_files, override_protection TSRMLS_CC); - PG(register_globals) = register_globals; -} - - -static void register_http_post_files_variable_ex(char *var, zval *val, zval *http_post_files, zend_bool override_protection TSRMLS_DC) -{ - int register_globals = PG(register_globals); - - PG(register_globals) = 0; - safe_php_register_variable_ex(var, val, http_post_files, override_protection TSRMLS_CC); - PG(register_globals) = register_globals; -} - - -static int unlink_filename(char **filename TSRMLS_DC) -{ - VCWD_UNLINK(*filename); - return 0; -} - - -void destroy_uploaded_files_hash(TSRMLS_D) -{ - zend_hash_apply(SG(rfc1867_uploaded_files), (apply_func_t) unlink_filename TSRMLS_CC); - zend_hash_destroy(SG(rfc1867_uploaded_files)); - FREE_HASHTABLE(SG(rfc1867_uploaded_files)); -} - -/* - * Split raw mime stream up into appropriate components - */ -static void php_mime_split(char *buf, int cnt, char *boundary, zval *array_ptr TSRMLS_DC) -{ - char *ptr, *loc, *loc2, *loc3, *s, *name, *filename, *u, *temp_filename; - int len, state = 0, Done = 0, rem, urem; - int eolsize; - long bytes, max_file_size = 0; - char *namebuf=NULL, *filenamebuf=NULL, *lbuf=NULL, - *abuf=NULL, *start_arr=NULL, *end_arr=NULL, *arr_index=NULL; - FILE *fp; - int itype, is_arr_upload=0, arr_len=0; - zval *http_post_files=NULL; - zend_bool upload_successful; - zend_bool magic_quotes_gpc; - - zend_hash_init(&PG(rfc1867_protected_variables), 5, NULL, NULL, 0); - - ALLOC_HASHTABLE(SG(rfc1867_uploaded_files)); - zend_hash_init(SG(rfc1867_uploaded_files), 5, NULL, (dtor_func_t) free_estring, 0); - - ALLOC_ZVAL(http_post_files); - array_init(http_post_files); - INIT_PZVAL(http_post_files); - PG(http_globals)[TRACK_VARS_FILES] = http_post_files; - - ptr = buf; - rem = cnt; - len = strlen(boundary); - while ((ptr - buf < cnt) && !Done) { - switch (state) { - case 0: /* Looking for mime boundary */ - loc = memchr(ptr, *boundary, cnt); - if (loc) { - if (!strncmp(loc, boundary, len)) { - - state = 1; - - eolsize = 2; - if(*(loc+len)==0x0a) { - eolsize = 1; - } - - rem -= (loc - ptr) + len + eolsize; - ptr = loc + len + eolsize; - } else { - rem -= (loc - ptr) + 1; - ptr = loc + 1; - } - } else { - Done = 1; - } - break; - case 1: /* Check content-disposition */ - while (strncasecmp(ptr, "Content-Disposition: form-data;", 31)) { - if (rem < 31) { - SAFE_RETURN; - } - if (ptr[1] == '\n') { - /* empty line as end of header found */ - php_error(E_WARNING, "File Upload Mime headers garbled ptr: [%c%c%c%c%c]", *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3), *(ptr + 4)); - SAFE_RETURN; - } - /* some other headerfield found, skip it */ - loc = (char *) memchr(ptr, '\n', rem)+1; - while (*loc == ' ' || *loc == '\t') { - /* other field is folded, skip it */ - loc = (char *) memchr(loc, '\n', rem-(loc-ptr))+1; - } - rem -= (loc - ptr); - ptr = loc; - } - loc = memchr(ptr, '\n', rem); - while (loc[1] == ' ' || loc[1] == '\t') { - /* field is folded, look for end */ - loc = memchr(loc+1, '\n', rem-(loc-ptr)-1); - } - name = strstr(ptr, " name="); - if (name && name < loc) { - name += 6; - if ( *name == '\"' ) { - name++; - s = memchr(name, '\"', loc - name); - if(!s) { - php_error(E_WARNING, "File Upload Mime headers garbled name: [%c%c%c%c%c]", *name, *(name + 1), *(name + 2), *(name + 3), *(name + 4)); - SAFE_RETURN; - } - } else { - s = strpbrk(name, " \t()<>@,;:\\\"/[]?=\r\n"); - } - if (namebuf) { - efree(namebuf); - } - namebuf = estrndup(name, s-name); - if (lbuf) { - efree(lbuf); - } - lbuf = emalloc(s-name + MAX_SIZE_OF_INDEX + 1); - state = 2; - loc2 = loc; - while (loc2[2] != '\n') { - /* empty line as end of header not yet found */ - loc2 = memchr(loc2 + 1, '\n', rem-(loc2-ptr)-1); - } - rem -= (loc2 - ptr) + 3; - ptr = loc2 + 3; - /* is_arr_upload is true when name of file upload field - * ends in [.*] - * start_arr is set to point to 1st [ - * end_arr points to last ] - */ - is_arr_upload = (start_arr = strchr(namebuf,'[')) && - (end_arr = strrchr(namebuf,']')) && - (end_arr = namebuf+strlen(namebuf)-1); - if(is_arr_upload) { - arr_len = strlen(start_arr); - if(arr_index) efree(arr_index); - arr_index = estrndup(start_arr+1, arr_len-2); - } - } else { - php_error(E_WARNING, "File upload error - no name component in content disposition"); - SAFE_RETURN; - } - filename = strstr(s, "filename=\""); - if (filename && filename < loc) { - filename += 10; - s = memchr(filename, '\"', loc - filename); - if (!s) { - php_error(E_WARNING, "File Upload Mime headers garbled filename: [%c%c%c%c%c]", *filename, *(filename + 1), *(filename + 2), *(filename + 3), *(filename + 4)); - SAFE_RETURN; - } - if (filenamebuf) { - efree(filenamebuf); - } - filenamebuf = estrndup(filename, s-filename); - - /* Add $foo_name */ - if (is_arr_upload) { - if (abuf) { - efree(abuf); - } - abuf = estrndup(namebuf, strlen(namebuf)-arr_len); - sprintf(lbuf, "%s_name[%s]", abuf, arr_index); - } else { - sprintf(lbuf, "%s_name", namebuf); - } - s = strrchr(filenamebuf, '\\'); - if (s && s > filenamebuf) { - safe_php_register_variable(lbuf, s+1, NULL, 0 TSRMLS_CC); - } else { - safe_php_register_variable(lbuf, filenamebuf, NULL, 0 TSRMLS_CC); - } - - /* Add $foo[name] */ - if (is_arr_upload) { - sprintf(lbuf, "%s[name][%s]", abuf, arr_index); - } else { - sprintf(lbuf, "%s[name]", namebuf); - } - if (s && s > filenamebuf) { - register_http_post_files_variable(lbuf, s+1, http_post_files, 0 TSRMLS_CC); - } else { - register_http_post_files_variable(lbuf, filenamebuf, http_post_files, 0 TSRMLS_CC); - } - - state = 3; - s = ""; - if ((loc2 - loc) > 2) { - if (!strncasecmp(loc + 1, "Content-Type:", 13)) { - *(loc2 - 1) = '\0'; - s = loc+15; - } - loc3=memchr(loc2+1, '\n', rem-1); - if (loc3==NULL) { - php_error(E_WARNING, "File Upload Mime headers garbled header3: [%c%c%c%c%c]", *loc2, *(loc2 + 1), *(loc2 + 2), *(loc2 + 3), *(loc2 + 4)); - SAFE_RETURN; - } - if (loc3 - loc2 > 2) { /* we have a third header */ - rem -= (ptr-loc3)+3; - ptr = loc3+3; - } else { - rem -= (ptr-loc3)+1; - ptr = loc3+1; - } - } - - /* Add $foo_type */ - if (is_arr_upload) { - sprintf(lbuf, "%s_type[%s]", abuf, arr_index); - } else { - sprintf(lbuf, "%s_type", namebuf); - } - safe_php_register_variable(lbuf, s, NULL, 0 TSRMLS_CC); - - /* Add $foo[type] */ - if (is_arr_upload) { - sprintf(lbuf, "%s[type][%s]", abuf, arr_index); - } else { - sprintf(lbuf, "%s[type]", namebuf); - } - register_http_post_files_variable(lbuf, s, http_post_files, 0 TSRMLS_CC); - if(*s != '\0') { - *(loc2 - 1) = '\n'; - } - } - break; - - case 2: /* handle form-data fields */ - loc = memchr(ptr, *boundary, rem); - u = ptr; - while (loc) { - if (!strncmp(loc, boundary, len)) - break; - u = loc + 1; - urem = rem - (loc - ptr) - 1; - loc = memchr(u, *boundary, urem); - } - if (!loc) { - php_error(E_WARNING, "File Upload Field Data garbled"); - SAFE_RETURN; - } - *(loc - 4) = '\0'; - - /* Check to make sure we are not overwriting special file - * upload variables */ - safe_php_register_variable(namebuf, ptr, array_ptr, 0 TSRMLS_CC); - - /* And a little kludge to pick out special MAX_FILE_SIZE */ - itype = php_check_ident_type(namebuf); - if (itype) { - u = strchr(namebuf, '['); - if (u) - *u = '\0'; - } - if (!strcmp(namebuf, "MAX_FILE_SIZE")) { - max_file_size = atol(ptr); - } - if (itype) { - if (u) - *u = '['; - } - rem -= (loc - ptr); - ptr = loc; - state = 0; - break; - - case 3: /* Handle file */ - loc = memchr(ptr, *boundary, rem); - u = ptr; - while (loc) { - if (!strncmp(loc, boundary, len) -#if NEW_BOUNDARY_CHECK - && (loc-2>buf && *(loc-2)=='-' && *(loc-1)=='-') /* ensure boundary is prefixed with -- */ - && (loc-2==buf || *(loc-3)=='\n') /* ensure beginning of line */ -#endif - ) { - break; - } - u = loc + 1; - urem = rem - (loc - ptr) - 1; - loc = memchr(u, *boundary, urem); - } - if (!loc) { - php_error(E_WARNING, "File Upload Error - No Mime boundary found after start of file header"); - SAFE_RETURN; - } - bytes = 0; - - fp = php_open_temporary_file(PG(upload_tmp_dir), "php", &temp_filename TSRMLS_CC); - if (!fp) { - php_error(E_WARNING, "File upload error - unable to create a temporary file"); - SAFE_RETURN; - } - if ((loc - ptr - 4) > PG(upload_max_filesize)) { - php_error(E_WARNING, "Max file size of %ld bytes exceeded - file [%s] not saved", PG(upload_max_filesize), namebuf); - upload_successful = 0; - } else if (max_file_size && ((loc - ptr - 4) > max_file_size)) { - php_error(E_WARNING, "Max file size exceeded - file [%s] not saved", namebuf); - upload_successful = 0; - } else if ((loc - ptr - 4) <= 0) { - upload_successful = 0; - } else { - bytes = fwrite(ptr, 1, loc - ptr - 4, fp); - if (bytes < (loc - ptr - 4)) { - php_error(E_WARNING, "Only %d bytes were written, expected to write %ld", bytes, loc - ptr - 4); - } - upload_successful = 1; - } - fclose(fp); - add_protected_variable(namebuf TSRMLS_CC); - if (!upload_successful) { - if(temp_filename) { - unlink(temp_filename); - efree(temp_filename); - } - temp_filename = "none"; - } else { - zend_hash_add(SG(rfc1867_uploaded_files), temp_filename, strlen(temp_filename)+1, &temp_filename, sizeof(char *), NULL); - } - - magic_quotes_gpc = PG(magic_quotes_gpc); - PG(magic_quotes_gpc) = 0; - safe_php_register_variable(namebuf, temp_filename, NULL, 1 TSRMLS_CC); - /* Add $foo[tmp_name] */ - if(is_arr_upload) { - sprintf(lbuf, "%s[tmp_name][%s]", abuf, arr_index); - } else { - sprintf(lbuf, "%s[tmp_name]", namebuf); - } - add_protected_variable(lbuf TSRMLS_CC); - register_http_post_files_variable(lbuf, temp_filename, http_post_files, 1 TSRMLS_CC); - PG(magic_quotes_gpc) = magic_quotes_gpc; - - { - zval file_size; - - file_size.value.lval = bytes; - file_size.type = IS_LONG; - - /* Add $foo_size */ - if(is_arr_upload) { - sprintf(lbuf, "%s_size[%s]", abuf, arr_index); - } else { - sprintf(lbuf, "%s_size", namebuf); - } - safe_php_register_variable_ex(lbuf, &file_size, NULL, 0 TSRMLS_CC); - - /* Add $foo[size] */ - if(is_arr_upload) { - sprintf(lbuf, "%s[size][%s]", abuf, arr_index); - } else { - sprintf(lbuf, "%s[size]", namebuf); - } - register_http_post_files_variable_ex(lbuf, &file_size, http_post_files, 0 TSRMLS_CC); - } - state = 0; - rem -= (loc - ptr); - ptr = loc; - break; - } - } - SAFE_RETURN; -} - - -SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) -{ - char *boundary; - uint boundary_len; - zval *array_ptr = (zval *) arg; - - if (!PG(file_uploads)) { - php_error(E_WARNING, "File uploads are disabled"); - return; - } - - boundary = strstr(content_type_dup, "boundary"); - if (!boundary || !(boundary=strchr(boundary, '='))) { - sapi_module.sapi_error(E_COMPILE_ERROR, "Missing boundary in multipart/form-data POST data"); - return; - } - boundary++; - boundary_len = strlen(boundary); - - if (boundary[0] == '"' && boundary[boundary_len-1] == '"') { - boundary++; - boundary_len -= 2; - boundary[boundary_len] = '\0'; - } - - if (SG(request_info).post_data) { - php_mime_split(SG(request_info).post_data, SG(request_info).post_data_length, boundary, array_ptr TSRMLS_CC); - } -} - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/rfc1867.h b/main/rfc1867.h deleted file mode 100644 index 0e464760fa..0000000000 --- a/main/rfc1867.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef RFC1867_H -#define RFC1867_H - -#include "SAPI.h" - -#define MULTIPART_CONTENT_TYPE "multipart/form-data" - -SAPI_POST_READER_FUNC(rfc1867_post_reader); -SAPI_POST_HANDLER_FUNC(rfc1867_post_handler); - -#define FILE_UPLOAD_INPUT_BUFFER_SIZE 8192 - -void destroy_uploaded_files_hash(TSRMLS_D); - -#endif /* RFC1867_H */ diff --git a/main/safe_mode.c b/main/safe_mode.c deleted file mode 100644 index f570ca80fc..0000000000 --- a/main/safe_mode.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -#include "php.h" - -#include <stdio.h> -#include <stdlib.h> - -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <sys/stat.h> -#include "ext/standard/pageinfo.h" -#include "safe_mode.h" -#include "SAPI.h" -#include "php_globals.h" - - -/* - * php_checkuid - * - * This function has four modes: - * - * 0 - return invalid (0) if file does not exist - * 1 - return valid (1) if file does not exist - * 2 - if file does not exist, check directory - * 3 - only check directory (needed for mkdir) - */ - -PHPAPI int php_checkuid(const char *filename, char *fopen_mode, int mode) -{ - struct stat sb; - int ret; - long uid=0L, gid=0L, duid=0L, dgid=0L; - char path[MAXPATHLEN]; - char *s; - TSRMLS_FETCH(); - - if (!filename) { - return 0; /* path must be provided */ - } - - if (fopen_mode) { - if (fopen_mode[0] == 'r') { - mode = CHECKUID_DISALLOW_FILE_NOT_EXISTS; - } else { - mode = CHECKUID_CHECK_FILE_AND_DIR; - } - } - - /* - * If given filepath is a URL, allow - safe mode stuff - * related to URL's is checked in individual functions - */ - if (!strncasecmp(filename,"http://", 7) || !strncasecmp(filename,"ftp://", 6)) { - return 1; - } - - /* First we see if the file is owned by the same user... - * If that fails, passthrough and check directory... - */ - if (mode != CHECKUID_ALLOW_ONLY_DIR) { - VCWD_REALPATH(filename, path); - ret = VCWD_STAT(path, &sb); - if (ret < 0) { - if (mode == CHECKUID_DISALLOW_FILE_NOT_EXISTS) { - php_error(E_WARNING, "Unable to access %s", filename); - return 0; - } else if (mode == CHECKUID_ALLOW_FILE_NOT_EXISTS) - php_error(E_WARNING, "Unable to access %s", filename);{ - return 1; - } - } else { - uid = sb.st_uid; - gid = sb.st_gid; - if (uid == php_getuid()) { - return 1; - } else if (PG(safe_mode_gid) && gid == php_getgid()) { - return 1; - } - } - - /* Trim off filename */ - if ((s = strrchr(path, DEFAULT_SLASH))) { - *s = '\0'; - } - } else { /* CHECKUID_ALLOW_ONLY_DIR */ - s = strrchr(filename, DEFAULT_SLASH); - - if (s) { - *s = '\0'; - VCWD_REALPATH(filename, path); - *s = DEFAULT_SLASH; - } else { - VCWD_GETCWD(path, MAXPATHLEN); - } - } /* end CHECKUID_ALLOW_ONLY_DIR */ - - if (mode != CHECKUID_ALLOW_ONLY_FILE) { - /* check directory */ - ret = VCWD_STAT(path, &sb); - if (ret < 0) { - php_error(E_WARNING, "Unable to access %s", filename); - return 0; - } - duid = sb.st_uid; - dgid = sb.st_gid; - if (duid == php_getuid()) { - return 1; - } else if (PG(safe_mode_gid) && dgid == php_getgid()) { - return 1; - } else { - TSRMLS_FETCH(); - - if (SG(rfc1867_uploaded_files)) { - if (zend_hash_exists(SG(rfc1867_uploaded_files), (char *) filename, strlen(filename)+1)) { - return 1; - } - } - } - } - - if (mode == CHECKUID_ALLOW_ONLY_DIR) { - uid = duid; - gid = dgid; - if (s) { - *s = 0; - } - } - if (PG(safe_mode_gid)) { - php_error(E_WARNING, "SAFE MODE Restriction in effect. The script whose uid/gid is %ld/%ld is not allowed to access %s owned by uid/gid %ld/%ld", php_getuid(), php_getgid(), filename, uid, gid); - } 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", php_getuid(), filename, uid); - } - return 0; -} - - -PHPAPI char *php_get_current_user() -{ - struct passwd *pwd; - struct stat *pstat; - TSRMLS_FETCH(); - - if (SG(request_info).current_user) { - return SG(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 */ - - pstat = sapi_get_stat(TSRMLS_C); - - if (!pstat) { - return empty_string; - } - - if ((pwd=getpwuid(pstat->st_uid))==NULL) { - return empty_string; - } - SG(request_info).current_user_length = strlen(pwd->pw_name); - SG(request_info).current_user = estrndup(pwd->pw_name, SG(request_info).current_user_length); - - return SG(request_info).current_user; -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/safe_mode.h b/main/safe_mode.h deleted file mode 100644 index 307c557078..0000000000 --- a/main/safe_mode.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SAFE_MODE_H -#define SAFE_MODE_H - -/* mode's for php_checkuid() */ -#define CHECKUID_DISALLOW_FILE_NOT_EXISTS 0 -#define CHECKUID_ALLOW_FILE_NOT_EXISTS 1 -#define CHECKUID_CHECK_FILE_AND_DIR 2 -#define CHECKUID_ALLOW_ONLY_DIR 3 -#define CHECKUID_CHECK_MODE_PARAM 4 -#define CHECKUID_ALLOW_ONLY_FILE 5 - -extern PHPAPI int php_checkuid(const char *filename, char *fopen_mode, int mode); -extern PHPAPI char *php_get_current_user(void); - -#endif diff --git a/main/snprintf.c b/main/snprintf.c deleted file mode 100644 index 5fe1860d86..0000000000 --- a/main/snprintf.c +++ /dev/null @@ -1,949 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1995-1998 The Apache Group. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * 4. The names "Apache Server" and "Apache Group" must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * 5. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the Apache Group - * for use in the Apache HTTP server project (http://www.apache.org/)." - * - * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Group and was originally based - * on public domain software written at the National Center for - * Supercomputing Applications, University of Illinois, Urbana-Champaign. - * For more information on the Apache Group and the Apache HTTP server - * project, please see <http://www.apache.org/>. - * - * This code is based on, and used with the permission of, the - * SIO stdio-replacement strx_* functions by Panos Tsirigotis - * <panos@alumni.cs.colorado.edu> for xinetd. - */ - -#include "php.h" - -#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || defined(BROKEN_SNPRINTF) || defined(BROKEN_VSNPRINTF) - -#include <stdio.h> -#include <ctype.h> -#include <sys/types.h> -#include <stdarg.h> -#include <string.h> -#include <stdlib.h> -#include <math.h> - - -#ifdef HAVE_GCVT - -#define ap_php_ecvt ecvt -#define ap_php_fcvt fcvt -#define ap_php_gcvt gcvt - -#else - -/* - * cvt.c - IEEE floating point formatting routines for FreeBSD - * from GNU libc-4.6.27 - */ - -/* - * ap_php_ecvt converts to decimal - * the number of digits is specified by ndigit - * decpt is set to the position of the decimal point - * sign is set to 0 for positive, 1 for negative - */ - -#define NDIG 80 - -static char * - ap_php_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag) -{ - register int r2; - double fi, fj; - register char *p, *p1; - static char buf[NDIG]; - - if (ndigits >= NDIG - 1) - ndigits = NDIG - 2; - r2 = 0; - *sign = 0; - p = &buf[0]; - if (arg < 0) { - *sign = 1; - arg = -arg; - } - arg = modf(arg, &fi); - p1 = &buf[NDIG]; - /* - * Do integer part - */ - if (fi != 0) { - p1 = &buf[NDIG]; - while (p1 > &buf[0] && fi != 0) { - fj = modf(fi / 10, &fi); - *--p1 = (int) ((fj + .03) * 10) + '0'; - r2++; - } - while (p1 < &buf[NDIG]) - *p++ = *p1++; - } else if (arg > 0) { - while ((fj = arg * 10) < 1) { - arg = fj; - r2--; - } - } - p1 = &buf[ndigits]; - if (eflag == 0) - p1 += r2; - *decpt = r2; - if (p1 < &buf[0]) { - buf[0] = '\0'; - return (buf); - } - while (p <= p1 && p < &buf[NDIG]) { - arg *= 10; - arg = modf(arg, &fj); - *p++ = (int) fj + '0'; - } - if (p1 >= &buf[NDIG]) { - buf[NDIG - 1] = '\0'; - return (buf); - } - p = p1; - *p1 += 5; - while (*p1 > '9') { - *p1 = '0'; - if (p1 > buf) - ++ * --p1; - else { - *p1 = '1'; - (*decpt)++; - if (eflag == 0) { - if (p > buf) - *p = '0'; - p++; - } - } - } - *p = '\0'; - return (buf); -} - -static char * - ap_php_ecvt(double arg, int ndigits, int *decpt, int *sign) -{ - return (ap_php_cvt(arg, ndigits, decpt, sign, 1)); -} - -static char * - ap_php_fcvt(double arg, int ndigits, int *decpt, int *sign) -{ - return (ap_php_cvt(arg, ndigits, decpt, sign, 0)); -} - -/* - * ap_php_gcvt - Floating output conversion to - * minimal length string - */ - -static char * - ap_php_gcvt(double number, int ndigit, char *buf) -{ - int sign, decpt; - register char *p1, *p2; - register i; - - p1 = ap_php_ecvt(number, ndigit, &decpt, &sign); - p2 = buf; - if (sign) - *p2++ = '-'; - for (i = ndigit - 1; i > 0 && p1[i] == '0'; i--) - ndigit--; - if ((decpt >= 0 && decpt - ndigit > 4) - || (decpt < 0 && decpt < -3)) { /* use E-style */ - decpt--; - *p2++ = *p1++; - *p2++ = '.'; - for (i = 1; i < ndigit; i++) - *p2++ = *p1++; - *p2++ = 'e'; - if (decpt < 0) { - decpt = -decpt; - *p2++ = '-'; - } else - *p2++ = '+'; - if (decpt / 100 > 0) - *p2++ = decpt / 100 + '0'; - if (decpt / 10 > 0) - *p2++ = (decpt % 100) / 10 + '0'; - *p2++ = decpt % 10 + '0'; - } else { - if (decpt <= 0) { - if (*p1 != '0') - *p2++ = '.'; - while (decpt < 0) { - decpt++; - *p2++ = '0'; - } - } - for (i = 1; i <= ndigit; i++) { - *p2++ = *p1++; - if (i == decpt) - *p2++ = '.'; - } - if (ndigit < decpt) { - while (ndigit++ < decpt) - *p2++ = '0'; - *p2++ = '.'; - } - } - if (p2[-1] == '.') - p2--; - *p2 = '\0'; - return (buf); -} - -#endif /* HAVE_CVT */ - -typedef enum { - NO = 0, YES = 1 -} boolean_e; - -#define FALSE 0 -#define TRUE 1 -#define NUL '\0' -#define INT_NULL ((int *)0) -#define WIDE_INT long - -typedef WIDE_INT wide_int; -typedef unsigned WIDE_INT u_wide_int; -typedef int bool_int; - -#define S_NULL "(null)" -#define S_NULL_LEN 6 - -#define FLOAT_DIGITS 6 -#define EXPONENT_LENGTH 10 - -/* - * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions - * - * XXX: this is a magic number; do not decrease it - */ -#define NUM_BUF_SIZE 512 - - -/* - * Descriptor for buffer area - */ -struct buf_area { - char *buf_end; - char *nextb; /* pointer to next byte to read/write */ -}; - -typedef struct buf_area buffy; - -/* - * The INS_CHAR macro inserts a character in the buffer and writes - * the buffer back to disk if necessary - * It uses the char pointers sp and bep: - * sp points to the next available character in the buffer - * bep points to the end-of-buffer+1 - * While using this macro, note that the nextb pointer is NOT updated. - * - * NOTE: Evaluation of the c argument should not have any side-effects - */ -#define INS_CHAR( c, sp, bep, cc ) \ - { \ - if ( sp < bep ) \ - { \ - *sp++ = c ; \ - cc++ ; \ - } \ - } - -#define NUM( c ) ( c - '0' ) - -#define STR_TO_DEC( str, num ) \ - num = NUM( *str++ ) ; \ - while ( isdigit((int)*str ) ) \ - { \ - num *= 10 ; \ - num += NUM( *str++ ) ; \ - } - -/* - * This macro does zero padding so that the precision - * requirement is satisfied. The padding is done by - * adding '0's to the left of the string that is going - * to be printed. - */ -#define FIX_PRECISION( adjust, precision, s, s_len ) \ - if ( adjust ) \ - while ( s_len < precision ) \ - { \ - *--s = '0' ; \ - s_len++ ; \ - } - -/* - * Macro that does padding. The padding is done by printing - * the character ch. - */ -#define PAD( width, len, ch ) do \ - { \ - INS_CHAR( ch, sp, bep, cc ) ; \ - width-- ; \ - } \ - while ( width > len ) - -/* - * Prefix the character ch to the string str - * Increase length - * Set the has_prefix flag - */ -#define PREFIX( str, length, ch ) *--str = ch ; length++ ; has_prefix = YES - - -/* - * Convert num to its decimal format. - * Return value: - * - a pointer to a string containing the number (no sign) - * - len contains the length of the string - * - is_negative is set to TRUE or FALSE depending on the sign - * of the number (always set to FALSE if is_unsigned is TRUE) - * - * The caller provides a buffer for the string: that is the buf_end argument - * which is a pointer to the END of the buffer + 1 (i.e. if the buffer - * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) - */ -static char * - conv_10(register wide_int num, register bool_int is_unsigned, - register bool_int * is_negative, char *buf_end, register int *len) -{ - register char *p = buf_end; - register u_wide_int magnitude; - - if (is_unsigned) { - magnitude = (u_wide_int) num; - *is_negative = FALSE; - } else { - *is_negative = (num < 0); - - /* - * On a 2's complement machine, negating the most negative integer - * results in a number that cannot be represented as a signed integer. - * Here is what we do to obtain the number's magnitude: - * a. add 1 to the number - * b. negate it (becomes positive) - * c. convert it to unsigned - * d. add 1 - */ - if (*is_negative) { - wide_int t = num + 1; - - magnitude = ((u_wide_int) - t) + 1; - } else - magnitude = (u_wide_int) num; - } - - /* - * We use a do-while loop so that we write at least 1 digit - */ - do { - register u_wide_int new_magnitude = magnitude / 10; - - *--p = magnitude - new_magnitude * 10 + '0'; - magnitude = new_magnitude; - } - while (magnitude); - - *len = buf_end - p; - return (p); -} - - - -/* - * Convert a floating point number to a string formats 'f', 'e' or 'E'. - * The result is placed in buf, and len denotes the length of the string - * The sign is returned in the is_negative argument (and is not placed - * in buf). - */ -static char * - conv_fp(register char format, register double num, - boolean_e add_dp, int precision, bool_int * is_negative, char *buf, int *len) -{ - register char *s = buf; - register char *p; - int decimal_point; - - if (format == 'f') - p = ap_php_fcvt(num, precision, &decimal_point, is_negative); - else /* either e or E format */ - p = ap_php_ecvt(num, precision + 1, &decimal_point, is_negative); - - /* - * Check for Infinity and NaN - */ - if (isalpha((int)*p)) { - *len = strlen(strcpy(buf, p)); - *is_negative = FALSE; - return (buf); - } - if (format == 'f') { - if (decimal_point <= 0) { - *s++ = '0'; - if (precision > 0) { - *s++ = '.'; - while (decimal_point++ < 0) - *s++ = '0'; - } else if (add_dp) { - *s++ = '.'; - } - } else { - while (decimal_point-- > 0) { - *s++ = *p++; - } - if (precision > 0 || add_dp) { - *s++ = '.'; - } - } - } else { - *s++ = *p++; - if (precision > 0 || add_dp) - *s++ = '.'; - } - - /* - * copy the rest of p, the NUL is NOT copied - */ - while (*p) - *s++ = *p++; - - if (format != 'f') { - char temp[EXPONENT_LENGTH]; /* for exponent conversion */ - int t_len; - bool_int exponent_is_negative; - - *s++ = format; /* either e or E */ - decimal_point--; - if (decimal_point != 0) { - p = conv_10((wide_int) decimal_point, FALSE, &exponent_is_negative, - &temp[EXPONENT_LENGTH], &t_len); - *s++ = exponent_is_negative ? '-' : '+'; - - /* - * Make sure the exponent has at least 2 digits - */ - if (t_len == 1) - *s++ = '0'; - while (t_len--) - *s++ = *p++; - } else { - *s++ = '+'; - *s++ = '0'; - *s++ = '0'; - } - } - *len = s - buf; - return (buf); -} - - -/* - * Convert num to a base X number where X is a power of 2. nbits determines X. - * For example, if nbits is 3, we do base 8 conversion - * Return value: - * a pointer to a string containing the number - * - * The caller provides a buffer for the string: that is the buf_end argument - * which is a pointer to the END of the buffer + 1 (i.e. if the buffer - * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) - */ -static char * - conv_p2(register u_wide_int num, register int nbits, - char format, char *buf_end, register int *len) -{ - register int mask = (1 << nbits) - 1; - register char *p = buf_end; - static char low_digits[] = "0123456789abcdef"; - static char upper_digits[] = "0123456789ABCDEF"; - register char *digits = (format == 'X') ? upper_digits : low_digits; - - do { - *--p = digits[num & mask]; - num >>= nbits; - } - while (num); - - *len = buf_end - p; - return (p); -} - - -/* - * Do format conversion placing the output in buffer - */ -static int format_converter(register buffy * odp, const char *fmt, - va_list ap) -{ - register char *sp; - register char *bep; - register int cc = 0; - register int i; - - register char *s = NULL; - char *q; - int s_len; - - register int min_width = 0; - int precision = 0; - enum { - LEFT, RIGHT - } adjust; - char pad_char; - char prefix_char; - - double fp_num; - wide_int i_num = (wide_int) 0; - u_wide_int ui_num; - - char num_buf[NUM_BUF_SIZE]; - char char_buf[2]; /* for printing %% and %<unknown> */ - - /* - * Flag variables - */ - boolean_e is_long; - boolean_e alternate_form; - boolean_e print_sign; - boolean_e print_blank; - boolean_e adjust_precision; - boolean_e adjust_width; - bool_int is_negative; - - sp = odp->nextb; - bep = odp->buf_end; - - while (*fmt) { - if (*fmt != '%') { - INS_CHAR(*fmt, sp, bep, cc); - } else { - /* - * Default variable settings - */ - adjust = RIGHT; - alternate_form = print_sign = print_blank = NO; - pad_char = ' '; - prefix_char = NUL; - - fmt++; - - /* - * Try to avoid checking for flags, width or precision - */ - if (isascii((int)*fmt) && !islower((int)*fmt)) { - /* - * Recognize flags: -, #, BLANK, + - */ - for (;; fmt++) { - if (*fmt == '-') - adjust = LEFT; - else if (*fmt == '+') - print_sign = YES; - else if (*fmt == '#') - alternate_form = YES; - else if (*fmt == ' ') - print_blank = YES; - else if (*fmt == '0') - pad_char = '0'; - else - break; - } - - /* - * Check if a width was specified - */ - if (isdigit((int)*fmt)) { - STR_TO_DEC(fmt, min_width); - adjust_width = YES; - } else if (*fmt == '*') { - min_width = va_arg(ap, int); - fmt++; - adjust_width = YES; - if (min_width < 0) { - adjust = LEFT; - min_width = -min_width; - } - } else - adjust_width = NO; - - /* - * Check if a precision was specified - * - * XXX: an unreasonable amount of precision may be specified - * resulting in overflow of num_buf. Currently we - * ignore this possibility. - */ - if (*fmt == '.') { - adjust_precision = YES; - fmt++; - if (isdigit((int)*fmt)) { - STR_TO_DEC(fmt, precision); - } else if (*fmt == '*') { - precision = va_arg(ap, int); - fmt++; - if (precision < 0) - precision = 0; - } else - precision = 0; - } else - adjust_precision = NO; - } else - adjust_precision = adjust_width = NO; - - /* - * Modifier check - */ - if (*fmt == 'l') { - is_long = YES; - fmt++; - } else - is_long = NO; - - /* - * Argument extraction and printing. - * First we determine the argument type. - * Then, we convert the argument to a string. - * On exit from the switch, s points to the string that - * must be printed, s_len has the length of the string - * The precision requirements, if any, are reflected in s_len. - * - * NOTE: pad_char may be set to '0' because of the 0 flag. - * It is reset to ' ' by non-numeric formats - */ - switch (*fmt) { - case 'u': - if (is_long) - i_num = va_arg(ap, u_wide_int); - else - i_num = (wide_int) va_arg(ap, unsigned int); - /* - * The rest also applies to other integer formats, so fall - * into that case. - */ - case 'd': - case 'i': - /* - * Get the arg if we haven't already. - */ - if ((*fmt) != 'u') { - if (is_long) - i_num = va_arg(ap, wide_int); - else - i_num = (wide_int) va_arg(ap, int); - }; - s = conv_10(i_num, (*fmt) == 'u', &is_negative, - &num_buf[NUM_BUF_SIZE], &s_len); - FIX_PRECISION(adjust_precision, precision, s, s_len); - - if (*fmt != 'u') { - if (is_negative) - prefix_char = '-'; - else if (print_sign) - prefix_char = '+'; - else if (print_blank) - prefix_char = ' '; - } - break; - - - case 'o': - if (is_long) - ui_num = va_arg(ap, u_wide_int); - else - ui_num = (u_wide_int) va_arg(ap, unsigned int); - s = conv_p2(ui_num, 3, *fmt, - &num_buf[NUM_BUF_SIZE], &s_len); - FIX_PRECISION(adjust_precision, precision, s, s_len); - if (alternate_form && *s != '0') { - *--s = '0'; - s_len++; - } - break; - - - case 'x': - case 'X': - if (is_long) - ui_num = (u_wide_int) va_arg(ap, u_wide_int); - else - ui_num = (u_wide_int) va_arg(ap, unsigned int); - s = conv_p2(ui_num, 4, *fmt, - &num_buf[NUM_BUF_SIZE], &s_len); - FIX_PRECISION(adjust_precision, precision, s, s_len); - if (alternate_form && i_num != 0) { - *--s = *fmt; /* 'x' or 'X' */ - *--s = '0'; - s_len += 2; - } - break; - - - case 's': - s = va_arg(ap, char *); - if (s != NULL) { - s_len = strlen(s); - if (adjust_precision && precision < s_len) - s_len = precision; - } else { - s = S_NULL; - s_len = S_NULL_LEN; - } - pad_char = ' '; - break; - - - case 'f': - case 'e': - case 'E': - fp_num = va_arg(ap, double); - - if (zend_isnan(fp_num)) { - s = "nan"; - s_len = 3; - } else if (zend_isinf(fp_num)) { - s = "inf"; - s_len = 3; - } else { - s = conv_fp(*fmt, fp_num, alternate_form, - (adjust_precision == NO) ? FLOAT_DIGITS : precision, - &is_negative, &num_buf[1], &s_len); - if (is_negative) - prefix_char = '-'; - else if (print_sign) - prefix_char = '+'; - else if (print_blank) - prefix_char = ' '; - } - break; - - - case 'g': - case 'G': - if (adjust_precision == NO) - precision = FLOAT_DIGITS; - else if (precision == 0) - precision = 1; - /* - * * We use &num_buf[ 1 ], so that we have room for the sign - */ - s = ap_php_gcvt(va_arg(ap, double), precision, &num_buf[1]); - if (*s == '-') - prefix_char = *s++; - else if (print_sign) - prefix_char = '+'; - else if (print_blank) - prefix_char = ' '; - - s_len = strlen(s); - - if (alternate_form && (q = strchr(s, '.')) == NULL) - s[s_len++] = '.'; - if (*fmt == 'G' && (q = strchr(s, 'e')) != NULL) - *q = 'E'; - break; - - - case 'c': - char_buf[0] = (char) (va_arg(ap, int)); - s = &char_buf[0]; - s_len = 1; - pad_char = ' '; - break; - - - case '%': - char_buf[0] = '%'; - s = &char_buf[0]; - s_len = 1; - pad_char = ' '; - break; - - - case 'n': - *(va_arg(ap, int *)) = cc; - break; - - /* - * Always extract the argument as a "char *" pointer. We - * should be using "void *" but there are still machines - * that don't understand it. - * If the pointer size is equal to the size of an unsigned - * integer we convert the pointer to a hex number, otherwise - * we print "%p" to indicate that we don't handle "%p". - */ - case 'p': - ui_num = (u_wide_int) va_arg(ap, char *); - - if (sizeof(char *) <= sizeof(u_wide_int)) - s = conv_p2(ui_num, 4, 'x', - &num_buf[NUM_BUF_SIZE], &s_len); - else { - s = "%p"; - s_len = 2; - } - pad_char = ' '; - break; - - - case NUL: - /* - * The last character of the format string was %. - * We ignore it. - */ - continue; - - - /* - * The default case is for unrecognized %'s. - * We print %<char> to help the user identify what - * option is not understood. - * This is also useful in case the user wants to pass - * the output of format_converter to another function - * that understands some other %<char> (like syslog). - * Note that we can't point s inside fmt because the - * unknown <char> could be preceded by width etc. - */ - default: - char_buf[0] = '%'; - char_buf[1] = *fmt; - s = char_buf; - s_len = 2; - pad_char = ' '; - break; - } - - if (prefix_char != NUL) { - *--s = prefix_char; - s_len++; - } - if (adjust_width && adjust == RIGHT && min_width > s_len) { - if (pad_char == '0' && prefix_char != NUL) { - INS_CHAR(*s, sp, bep, cc) - s++; - s_len--; - min_width--; - } - PAD(min_width, s_len, pad_char); - } - /* - * Print the string s. - */ - for (i = s_len; i != 0; i--) { - INS_CHAR(*s, sp, bep, cc); - s++; - } - - if (adjust_width && adjust == LEFT && min_width > s_len) - PAD(min_width, s_len, pad_char); - } - fmt++; - } - odp->nextb = sp; - return (cc); -} - - -/* - * This is the general purpose conversion function. - */ -static void strx_printv(int *ccp, char *buf, size_t len, const char *format, - va_list ap) -{ - buffy od; - int cc; - - /* - * First initialize the descriptor - * Notice that if no length is given, we initialize buf_end to the - * highest possible address. - */ - od.buf_end = len ? &buf[len] : (char *) ~0; - od.nextb = buf; - - /* - * Do the conversion - */ - cc = format_converter(&od, format, ap); - if (len == 0 || od.nextb <= od.buf_end) - *(od.nextb) = '\0'; - if (ccp) - *ccp = cc; -} - - -int ap_php_snprintf(char *buf, size_t len, const char *format,...) -{ - int cc; - va_list ap; - - va_start(ap, format); - strx_printv(&cc, buf, (len - 1), format, ap); - va_end(ap); - return (cc); -} - - -int ap_php_vsnprintf(char *buf, size_t len, const char *format, va_list ap) -{ - int cc; - - strx_printv(&cc, buf, (len - 1), format, ap); - return (cc); -} - -#endif /* HAVE_SNPRINTF */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/snprintf.h b/main/snprintf.h deleted file mode 100644 index 3f9bb98503..0000000000 --- a/main/snprintf.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: Stig Sæther Bakken <ssb@guardian.no> | - +----------------------------------------------------------------------+ - */ - -#ifndef SNPRINTF_H -#define SNPRINTF_H - -#if !defined(HAVE_SNPRINTF) || defined(BROKEN_SNPRINTF) -extern int ap_php_snprintf(char *, size_t, const char *, ...); -#define snprintf ap_php_snprintf -#endif - -#if !defined(HAVE_VSNPRINTF) || defined(BROKEN_VSNPRINTF) -extern int ap_php_vsnprintf(char *, size_t, const char *, va_list ap); -#define vsnprintf ap_php_vsnprintf -#endif - -#if PHP_BROKEN_SPRINTF -int php_sprintf (char* s, const char* format, ...); -#define sprintf php_sprintf -#endif - -#endif /* SNPRINTF_H */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/main/streams.c b/main/streams.c deleted file mode 100755 index d221708ce1..0000000000 --- a/main/streams.c +++ /dev/null @@ -1,368 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 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_02.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: | - | Wez Furlong (wez@thebrainroom.com) | - +----------------------------------------------------------------------+ - */ - -#define _GNU_SOURCE -#include "php.h" - -#if HAVE_PHP_STREAM - -#ifdef PHP_WIN32 -#define EWOULDBLOCK WSAEWOULDBLOCK -#else -#include "build-defs.h" -#endif - -#define MAX_CHUNK_SIZE 8192 - -#define TOREAD(stream) ((stream)->readbuf.writepos - (stream)->readbuf.readpos) -#define TOWRITE(stream) ((stream)->readbuf.writepos - (stream)->readbuf.readpos) - -#define READPTR(stream) ((stream)->readbuf.buffer + (stream)->readbuf.readpos) -#define WRITEPTR(stream) ((stream)->readbuf.buffer + (stream)->readbuf.writepos) - -#define READ_MAX(stream, max) if (stream->is_blocked) stream_read_total(sock, max); else stream_readahead(sock) - -/* allocate a new stream for a particular ops */ -PHPAPI php_stream * php_stream_alloc(php_stream_ops * ops, void * abstract, int persistent, const char * mode) -{ - php_stream * ret; - - ret = (php_stream*)pemalloc(sizeof(php_stream), persistent); - - memset(ret, 0, sizeof(php_stream)); - - ret->ops = ops; - ret->abstract = abstract; - ret->is_persistent = persistent; - - strncpy(ret->mode, mode, sizeof(ret->mode)); - - return ret; -} - -PHPAPI int php_stream_free(php_stream * stream, int call_dtor) -{ - int ret = 1; - - if (call_dtor) { - - if (stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FOPENCOOKIE) { - /* calling fclose on an fopencookied stream will ultimately - call this very same function. If we were called via fclose, - the cookie_closer unsets the fclose_stdiocast flags, so - we can be sure that we only reach here when PHP code calls - php_stream_free. - Lets let the cookie code clean it all up. - */ - return fclose(stream->stdiocast); - } - - php_stream_flush(stream); - ret = stream->ops->close(stream); - - /* tidy up any FILE* that might have been fdopened */ - if (stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FDOPEN && stream->stdiocast) - { - fclose(stream->stdiocast); - stream->stdiocast = NULL; - } - } - pefree(stream, stream->is_persistent); - - return ret; -} - -PHPAPI size_t php_stream_read(php_stream * stream, char * buf, size_t size) -{ - return stream->ops->read(stream, buf, size); -} - -PHPAPI int php_stream_eof(php_stream * stream) -{ - /* we define our stream reading function so that it - must return EOF when an EOF condition occurs, when - working in unbuffered mode and called with these args */ - return stream->ops->read(stream, NULL, 0) == EOF ? 1 : 0; -} - -PHPAPI int php_stream_getc(php_stream * stream) -{ - char buf; - - if (php_stream_read(stream, &buf, 1) > 0) - return buf; - return EOF; -} - -PHPAPI char *php_stream_gets(php_stream * stream, char *buf, size_t maxlen) -{ - - if (maxlen == 0) { - buf[0] = 0; - return buf; - } - - if (stream->ops->gets) { - return stream->ops->gets(stream, buf, maxlen); - } - else { - /* unbuffered fgets - poor performance ! */ - size_t n = 0; - char * c = buf; - - /* TODO: look at error returns? */ - - while(n < maxlen && stream->ops->read(stream, c, 1) > 0) { - n++; - if (*c == '\n') { - c++; - break; - } - c++; - } - *c = 0; - return buf; - } -} - -PHPAPI int php_stream_flush(php_stream * stream) -{ - return stream->ops->flush(stream); -} - -PHPAPI size_t php_stream_write(php_stream * stream, const char * buf, size_t count) -{ - if (strchr(stream->mode, 'w') == NULL) { - TSRMLS_FETCH(); - - zend_error(E_WARNING, "%s(): stream was not opened for writing", get_active_function_name(TSRMLS_C)); - return 0; - } - - return stream->ops->write(stream, buf, count); -} - -PHPAPI off_t php_stream_tell(php_stream * stream) -{ - off_t ret = -1; - if (stream->ops->seek) { - ret = stream->ops->seek(stream, 0, SEEK_CUR); - } - return ret; -} - -PHPAPI int php_stream_seek(php_stream * stream, off_t offset, int whence) -{ - if (stream->ops->seek) - return stream->ops->seek(stream, offset, whence); - - zend_error(E_WARNING, "streams of type %s do not support seeking", stream->ops->label); - return -1; -} - -/*------- STDIO stream implementation -------*/ - -static size_t php_stdiop_write(php_stream * stream, const char * buf, size_t count) -{ - return fwrite(buf, 1, count, (FILE*)stream->abstract); -} - -static size_t php_stdiop_read(php_stream * stream, char * buf, size_t count) -{ - if (buf == NULL && count == 0) { - /* check for EOF condition */ - if (feof((FILE*)stream->abstract)) { - return EOF; - } - return 0; - } - return fread(buf, 1, count, (FILE*)stream->abstract); -} - -static int php_stdiop_close(php_stream * stream) -{ - return fclose((FILE*)stream->abstract); -} - -static int php_stdiop_flush(php_stream * stream) -{ - return fflush((FILE*)stream->abstract); -} - -static int php_stdiop_seek(php_stream * stream, off_t offset, int whence) -{ - return fseek((FILE*)stream->abstract, offset, whence); -} - -static char * php_stdiop_gets(php_stream * stream, char * buf, size_t size) -{ - return fgets(buf, size, (FILE*)stream->abstract); -} -static int php_stdiop_cast(php_stream * stream, int castas, void ** ret) -{ - int fd; - - switch (castas) { - case PHP_STREAM_AS_STDIO: - if (ret) - *ret = stream->abstract; - return SUCCESS; - - case PHP_STREAM_AS_FD: - fd = fileno((FILE*)stream->abstract); - if (fd < 0) - return FAILURE; - if (ret) - *ret = (void*)fd; - return SUCCESS; - default: - return FAILURE; - } -} - -php_stream_ops php_stream_stdio_ops = { - php_stdiop_write, php_stdiop_read, - php_stdiop_close, php_stdiop_flush, php_stdiop_seek, - php_stdiop_gets, php_stdiop_cast, - "STDIO" -}; - -PHPAPI php_stream * php_stream_fopen(const char * filename, const char * mode) -{ - FILE * fp = fopen(filename, mode); - - if (fp) { - php_stream * ret = php_stream_alloc(&php_stream_stdio_ops, fp, 0, mode); - - if (ret) - return ret; - - fclose(fp); - } - return NULL; -} - -#if HAVE_FOPENCOOKIE -static ssize_t stream_cookie_reader(void *cookie, char *buffer, size_t size) -{ - return php_stream_read(((php_stream *)cookie), buffer, size); -} - -static ssize_t stream_cookie_writer(void *cookie, const char *buffer, size_t size) { - return php_stream_write(((php_stream *)cookie), (char *)buffer, size); -} - -static int stream_cookie_seeker(void *cookie, off_t position, int whence) { - return php_stream_seek(((php_stream *)cookie), position, whence); -} - -static int stream_cookie_closer(void *cookie) { - php_stream * stream = (php_stream*)cookie; - /* prevent recursion */ - stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE; - return php_stream_close(stream); -} - -static COOKIE_IO_FUNCTIONS_T stream_cookie_functions = -{ - stream_cookie_reader, stream_cookie_writer, - stream_cookie_seeker, stream_cookie_closer -}; -#else -/* TODO: use socketpair() to emulate fopecookie, as suggested by Hartmut ? */ -#endif - -PHPAPI int php_stream_cast(php_stream * stream, int castas, void ** ret, int show_err) -{ - if (castas == PHP_STREAM_AS_STDIO) { - if (stream->stdiocast) { - if (ret) - *ret = stream->stdiocast; - return SUCCESS; - } - - if (stream->ops->cast && stream->ops->cast(stream, castas, ret) == SUCCESS) - goto exit_success; - - -#if HAVE_FOPENCOOKIE - /* if just checking, say yes we can be a FILE*, but don't actually create it yet */ - if (ret == NULL) - goto exit_success; - - *ret = fopencookie(stream, stream->mode, stream_cookie_functions); - - if (*ret != NULL) { - stream->fclose_stdiocast = 1; - goto exit_success; - } - - { - TSRMLS_FETCH(); - - /* must be either: - a) programmer error - b) no memory - -> lets bail - */ - zend_error(E_ERROR, "%s(): fopencookie failed", get_active_function_name(TSRMLS_C)); - return FAILURE; - } -#endif - - goto exit_fail; - } - if (stream->ops->cast && stream->ops->cast(stream, castas, ret) == SUCCESS) - goto exit_success; - - -exit_fail: - if (show_err) { - TSRMLS_FETCH(); - - /* these names depend on the values of the PHP_STREAM_AS_XXX defines in php_streams.h */ - static const char * cast_names[3] = { - "STDIO FILE*", "File Descriptor", "Socket Descriptor" - }; - zend_error(E_WARNING, "%s(): cannot represent a stream of type %s as a %s", - get_active_function_name(TSRMLS_C), - stream->ops->label, - cast_names[castas] - ); - } - - return FAILURE; - -exit_success: - if (castas == PHP_STREAM_AS_STDIO && ret) - stream->stdiocast = *ret; - - return SUCCESS; - -} - -#endif -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/strlcat.c b/main/strlcat.c deleted file mode 100644 index e6bc017cc0..0000000000 --- a/main/strlcat.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "php.h" - -#ifndef HAVE_STRLCAT - -/* $OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $ */ - -/* - * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/types.h> -#include <string.h> - -/* - * Appends src to string dst of size siz (unlike strncat, siz is the - * full size of dst, not space left). At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -PHPAPI size_t php_strlcat(dst, src, siz) - char *dst; - const char *src; - size_t siz; -{ - register char *d = dst; - register const char *s = src; - register size_t n = siz; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end */ - while (*d != '\0' && n-- != 0) - d++; - dlen = d - dst; - n = siz - dlen; - - if (n == 0) - return(dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; - n--; - } - s++; - } - *d = '\0'; - - return(dlen + (s - src)); /* count does not include NUL */ -} - -#endif /* !HAVE_STRLCAT */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/strlcpy.c b/main/strlcpy.c deleted file mode 100644 index 9c1f4da01d..0000000000 --- a/main/strlcpy.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "php.h" - -#ifndef HAVE_STRLCPY - -/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */ - -/* - * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/types.h> -#include <string.h> - -/* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -PHPAPI size_t php_strlcpy(dst, src, siz) - char *dst; - const char *src; - size_t siz; -{ - register char *d = dst; - register const char *s = src; - register size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ -} - -#endif /* !HAVE_STRLCPY */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/main/win95nt.h b/main/win95nt.h deleted file mode 100644 index 16412f9f05..0000000000 --- a/main/win95nt.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Defines and types for Windows 95/NT */ -#define HAVE_DECLARED_TIMEZONE -#define WIN32_LEAN_AND_MEAN -#include <io.h> -#include <malloc.h> -#include <direct.h> -#include <stdlib.h> -#include <stdio.h> -#include <stdarg.h> -#include <sys/types.h> -typedef int uid_t; -typedef int gid_t; -typedef char * caddr_t; -#define lstat(x, y) stat(x, y) -#define _IFIFO 0010000 /* fifo */ -#define _IFBLK 0060000 /* block special */ -#define _IFLNK 0120000 /* symbolic link */ -#define S_IFIFO _IFIFO -#define S_IFBLK _IFBLK -#define S_IFLNK _IFLNK -#define chdir(path) SetCurrentDirectory(path) -#define mkdir(a, b) _mkdir(a) -#define rmdir(a) _rmdir(a) -#define getpid _getpid -#define php_sleep(t) Sleep(t*1000) -#define getcwd(a, b) _getcwd(a, b) -#define snprintf _snprintf -#define off_t _off_t -#define vsnprintf _vsnprintf -typedef unsigned int uint; -typedef unsigned long ulong; -#if !NSAPI -#define strcasecmp(s1, s2) stricmp(s1, s2) -#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n) -typedef long pid_t; -#endif - -/* missing in vc5 math.h */ -#define M_PI 3.14159265358979323846 -#define M_TWOPI (M_PI * 2.0) -#define M_PI_2 1.57079632679489661923 -#ifndef M_PI_4 -#define M_PI_4 0.78539816339744830962 -#endif - -#if !PHP_DEBUG -#ifdef inline -#undef inline -#endif -#define inline __inline -#endif - -/* General Windows stuff */ -#define WINDOWS 1 - -/* Prevent use of VC5 OpenFile function */ -#define NOOPENFILE - -/* sendmail is built-in */ -#ifdef PHP_PROG_SENDMAIL -#undef PHP_PROG_SENDMAIL -#define PHP_PROG_SENDMAIL "Built in mailer" -#endif |