summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/SAPI.c909
-rw-r--r--main/SAPI.h288
-rw-r--r--main/alloca.c501
-rw-r--r--main/build-defs.h.in91
-rw-r--r--main/config.nw.h316
-rw-r--r--main/config.w32.h177
-rw-r--r--main/fopen_wrappers.c564
-rw-r--r--main/fopen_wrappers.h47
-rw-r--r--main/internal_functions.c.in56
-rw-r--r--main/internal_functions_nw.c102
-rw-r--r--main/internal_functions_registry.h37
-rw-r--r--main/internal_functions_win32.c166
-rw-r--r--main/logos.h1523
-rw-r--r--main/main.c1874
-rw-r--r--main/mergesort.c363
-rw-r--r--main/network.c940
-rw-r--r--main/output.c1059
-rw-r--r--main/php.h414
-rw-r--r--main/php3_compat.h122
-rw-r--r--main/php_compat.h129
-rw-r--r--main/php_content_types.c92
-rw-r--r--main/php_content_types.h30
-rw-r--r--main/php_globals.h155
-rw-r--r--main/php_ini.c580
-rw-r--r--main/php_ini.h76
-rw-r--r--main/php_logos.c100
-rw-r--r--main/php_logos.h31
-rw-r--r--main/php_main.h56
-rw-r--r--main/php_memory_streams.h64
-rw-r--r--main/php_network.h169
-rw-r--r--main/php_open_temporary_file.c257
-rw-r--r--main/php_open_temporary_file.h26
-rw-r--r--main/php_output.h109
-rw-r--r--main/php_realpath.c283
-rw-r--r--main/php_reentrancy.h129
-rw-r--r--main/php_regex.h65
-rw-r--r--main/php_scandir.c137
-rw-r--r--main/php_scandir.h50
-rw-r--r--main/php_sprintf.c55
-rwxr-xr-xmain/php_streams.h480
-rw-r--r--main/php_syslog.h57
-rw-r--r--main/php_ticks.c81
-rw-r--r--main/php_ticks.h37
-rw-r--r--main/php_variables.c365
-rw-r--r--main/php_variables.h41
-rw-r--r--main/php_version.h7
-rw-r--r--main/reentrancy.c504
-rw-r--r--main/rfc1867.c1073
-rw-r--r--main/rfc1867.h33
-rw-r--r--main/safe_mode.c224
-rw-r--r--main/safe_mode.h39
-rw-r--r--main/snprintf.c961
-rw-r--r--main/snprintf.h114
-rw-r--r--main/spprintf.c561
-rw-r--r--main/spprintf.h52
-rw-r--r--main/streams/cast.c354
-rw-r--r--main/streams/filter.c332
-rw-r--r--main/streams/memory.c471
-rw-r--r--main/streams/mmap.c52
-rw-r--r--main/streams/php_stream_context.h109
-rw-r--r--main/streams/php_stream_filter_api.h143
-rw-r--r--main/streams/php_stream_mmap.h82
-rw-r--r--main/streams/php_stream_plain_wrapper.h61
-rw-r--r--main/streams/php_stream_transport.h153
-rw-r--r--main/streams/php_stream_userspace.h35
-rw-r--r--main/streams/php_streams_int.h61
-rw-r--r--main/streams/plain_wrapper.c970
-rwxr-xr-xmain/streams/streams.c1590
-rw-r--r--main/streams/transports.c341
-rw-r--r--main/streams/userspace.c862
-rw-r--r--main/streams/xp_socket.c502
-rw-r--r--main/strlcat.c106
-rw-r--r--main/strlcpy.c103
-rw-r--r--main/win95nt.h82
74 files changed, 0 insertions, 23180 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
deleted file mode 100644
index 94a333c967..0000000000
--- a/main/SAPI.c
+++ /dev/null
@@ -1,909 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include <ctype.h>
-#include <sys/stat.h>
-
-#include "php.h"
-#include "SAPI.h"
-#include "php_ini.h"
-#include "ext/standard/php_string.h"
-#include "ext/standard/pageinfo.h"
-#if (HAVE_PCRE || HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
-#include "ext/pcre/php_pcre.h"
-#endif
-#if HAVE_ZLIB
-#include "ext/zlib/php_zlib.h"
-#endif
-#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;
-
-#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_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) = NULL;
-
-
- /* 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;
- }
- }
-
- /* now try to find an appropriate POST content handler */
- if (zend_hash_find(&known_post_content_types, content_type, content_type_length+1, (void **) &post_entry) == SUCCESS) {
- /* found one, register it for use */
- SG(request_info).post_entry = post_entry;
- post_reader_func = post_entry->post_reader;
- } else {
- /* fallback */
- SG(request_info).post_entry = NULL;
- if (!sapi_module.default_post_reader) {
- /* no default reader ? */
- sapi_module.sapi_error(E_WARNING, "Unsupported content type: '%s'", content_type);
- return;
- }
- }
- if (oldchar) {
- *(p-1) = oldchar;
- }
-
- SG(request_info).content_type_dup = content_type;
-
- if(post_reader_func) {
- post_reader_func(TSRMLS_C);
- }
-
- if(sapi_module.default_post_reader) {
- sapi_module.default_post_reader(TSRMLS_C);
- }
-}
-
-
-SAPI_API 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_docref(NULL TSRMLS_CC, 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_docref(NULL TSRMLS_CC, 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); /* sizeof() includes \0 */
- 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 (*mimetype != NULL) {
- 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);
- strlcat(newtype, charset, newlen + 1);
- efree(*mimetype);
- *mimetype = newtype;
- return newlen;
- }
- }
- return 0;
-}
-
-SAPI_API void sapi_activate_headers_only(TSRMLS_D)
-{
- if (SG(request_info).headers_read == 1)
- return;
- SG(request_info).headers_read = 1;
- 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(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;
- }
- if (SG(server_context)) {
- SG(request_info).cookie_data = sapi_module.read_cookies(TSRMLS_C);
- if (sapi_module.activate) {
- sapi_module.activate(TSRMLS_C);
- }
- }
-}
-
-/*
- * 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).raw_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;
-
- /* handle request mehtod */
- if (SG(server_context)) {
- if ( SG(request_info).request_method) {
- if(!strcmp(SG(request_info).request_method, "POST")
- && (SG(request_info).content_type)) {
- /* HTTP POST -> may contain form data to be read into variables
- depending on content type given
- */
- sapi_read_post_data(TSRMLS_C);
- } else {
- /* any other method with content payload will fill
- $HTTP_RAW_POST_DATA if enabled by always_populate_raw_post_data
- it is up to the webserver to decide whether to allow a method or not
- */
- SG(request_info).content_type_dup = NULL;
- if(sapi_module.default_post_reader) {
- sapi_module.default_post_reader(TSRMLS_C);
- }
- }
- } else {
- SG(request_info).content_type_dup = NULL;
- }
-
- /* Cookies */
- SG(request_info).cookie_data = sapi_module.read_cookies(TSRMLS_C);
- if (sapi_module.activate) {
- sapi_module.activate(TSRMLS_C);
- }
- }
-}
-
-
-static void sapi_send_headers_free(TSRMLS_D)
-{
- if (SG(sapi_headers).http_status_line) {
- efree(SG(sapi_headers).http_status_line);
- SG(sapi_headers).http_status_line = NULL;
- }
-}
-
-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);
- } else if (SG(server_context)) {
- if(sapi_module.read_post) {
- /* make sure we've consumed all request input data */
- char dummy[SAPI_POST_BLOCK_SIZE];
- int read_bytes;
-
- while((read_bytes = sapi_module.read_post(dummy, sizeof(dummy)-1 TSRMLS_CC)) > 0) {
- SG(read_post_bytes) += read_bytes;
- }
- }
- }
- if (SG(request_info).raw_post_data) {
- efree(SG(request_info).raw_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);
- }
- if (SG(sapi_headers).mimetype) {
- efree(SG(sapi_headers).mimetype);
- SG(sapi_headers).mimetype = NULL;
- }
- sapi_send_headers_free(TSRMLS_C);
- SG(sapi_started) = 0;
- SG(headers_sent) = 0;
- SG(request_info).headers_read = 0;
-}
-
-
-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;
-}
-
-
-static void sapi_update_response_code(int ncode TSRMLS_DC)
-{
- if (SG(sapi_headers).http_status_line) {
- efree(SG(sapi_headers).http_status_line);
- SG(sapi_headers).http_status_line = NULL;
- }
- SG(sapi_headers).http_response_code = ncode;
-}
-
-static int sapi_find_matching_header(void *element1, void *element2)
-{
- return strncasecmp(((sapi_header_struct*)element1)->header, (char*)element2, strlen((char*)element2)) == 0;
-}
-
-SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC)
-{
- sapi_header_line ctr = {0};
- int r;
-
- ctr.line = header_line;
- ctr.line_len = header_line_len;
-
- r = sapi_header_op(replace ? SAPI_HEADER_REPLACE : SAPI_HEADER_ADD,
- &ctr TSRMLS_CC);
-
- if (!duplicate)
- efree(header_line);
-
- return r;
-}
-
-SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
-{
- int retval;
- sapi_header_struct sapi_header;
- char *colon_offset;
- long myuid = 0L;
- char *header_line;
- uint header_line_len;
- zend_bool replace;
- int http_response_code;
-
- 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 modify 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 modify header information - headers already sent");
- }
- return FAILURE;
- }
-
- switch (op) {
- case SAPI_HEADER_SET_STATUS:
- sapi_update_response_code((int) arg TSRMLS_CC);
- return SUCCESS;
-
- case SAPI_HEADER_REPLACE:
- case SAPI_HEADER_ADD: {
- sapi_header_line *p = arg;
- header_line = p->line;
- header_line_len = p->line_len;
- http_response_code = p->response_code;
- replace = (op == SAPI_HEADER_REPLACE);
- break;
- }
-
- default:
- return FAILURE;
- }
-
- 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 */
- sapi_update_response_code(sapi_extract_response_code(header_line) TSRMLS_CC);
- 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+1, *mimetype = NULL, *newheader;
- size_t len = header_line_len - (ptr - header_line), newlen;
- while (*ptr == ' ' && *ptr != '\0') {
- ptr++;
- }
-#if HAVE_ZLIB
- if(!strncmp(ptr, "image/", sizeof("image/")-1)) {
- zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- }
-#endif
- mimetype = estrdup(ptr);
- newlen = sapi_apply_default_charset(&mimetype, len TSRMLS_CC);
- if (!SG(sapi_headers).mimetype){
- SG(sapi_headers).mimetype = estrdup(mimetype);
- }
-
- 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;
- efree(header_line);
- }
- 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 */
- sapi_update_response_code(302 TSRMLS_CC);
- }
- } else if (!STRCASECMP(header_line, "WWW-Authenticate")) { /* HTTP Authentication */
- int newlen;
- char *result, *newheader;
-
- sapi_update_response_code(401 TSRMLS_CC); /* authentication-required */
-
- if(PG(safe_mode))
-#if (HAVE_PCRE || HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
- {
- zval *repl_temp;
- char *ptr = colon_offset+1;
- int ptr_len=0, result_len = 0;
-
- myuid = php_getuid();
-
- ptr_len = strlen(ptr);
- MAKE_STD_ZVAL(repl_temp);
- Z_TYPE_P(repl_temp) = IS_STRING;
- Z_STRVAL_P(repl_temp) = emalloc(32);
- Z_STRLEN_P(repl_temp) = sprintf(Z_STRVAL_P(repl_temp), "realm=\"\\1-%ld\"", myuid);
- /* Modify quoted realm value */
- result = php_pcre_replace("/realm=\"(.*?)\"/i", 16,
- ptr, ptr_len,
- repl_temp,
- 0, &result_len, -1 TSRMLS_CC);
- if(result_len==ptr_len) {
- efree(result);
- sprintf(Z_STRVAL_P(repl_temp), "realm=\\1-%ld\\2", myuid);
- /* modify unquoted realm value */
- result = php_pcre_replace("/realm=([^\\s]+)(.*)/i", 21,
- ptr, ptr_len,
- repl_temp,
- 0, &result_len, -1 TSRMLS_CC);
- if(result_len==ptr_len) {
- char *lower_temp = estrdup(ptr);
- char conv_temp[32];
- int conv_len;
-
- php_strtolower(lower_temp,strlen(lower_temp));
- /* If there is no realm string at all, append one */
- if(!strstr(lower_temp,"realm")) {
- efree(result);
- conv_len = sprintf(conv_temp, " realm=\"%ld\"",myuid);
- result = emalloc(ptr_len+conv_len+1);
- result_len = ptr_len+conv_len;
- memcpy(result, ptr, ptr_len);
- memcpy(result+ptr_len, conv_temp, conv_len);
- *(result+ptr_len+conv_len) = '\0';
- }
- efree(lower_temp);
- }
- }
- newlen = sizeof("WWW-Authenticate: ") + result_len;
- newheader = emalloc(newlen+1);
- sprintf(newheader,"WWW-Authenticate: %s", result);
- efree(header_line);
- sapi_header.header = newheader;
- sapi_header.header_len = newlen;
- efree(result);
- efree(Z_STRVAL_P(repl_temp));
- efree(repl_temp);
- }
-#else
- {
- myuid = php_getuid();
- result = emalloc(sizeof("WWW-Authenticate: ")+20);
- newlen = sprintf(result, "WWW-Authenticate: %ld", myuid);
- newheader = estrndup(result,newlen);
- efree(header_line);
- sapi_header.header = newheader;
- sapi_header.header_len = newlen;
- efree(result);
- }
-#endif
- }
- if (sapi_header.header==header_line) {
- *colon_offset = ':';
- }
- }
- }
- if (http_response_code) {
- sapi_update_response_code(http_response_code TSRMLS_CC);
- }
- 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) {
- /* in replace mode first remove the header if it already exists in the headers llist */
- if (replace) {
- colon_offset = strchr(sapi_header.header, ':');
- if (colon_offset) {
- char sav;
- colon_offset++;
- sav = *colon_offset;
- *colon_offset = 0;
- zend_llist_del_element(&SG(sapi_headers).headers, sapi_header.header, (int(*)(void*, void*))sapi_find_matching_header);
- *colon_offset = sav;
- }
- }
-
- zend_llist_add_element(&SG(sapi_headers).headers, (void *) &sapi_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;
- }
-
-#if HAVE_ZLIB
- /* Add output compression headers at this late stage in order to make
- it possible to switch it off inside the script. */
-
- if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
- zval nm_zlib_get_coding_type;
- zval *uf_result = NULL;
-
- ZVAL_STRINGL(&nm_zlib_get_coding_type, "zlib_get_coding_type", sizeof("zlib_get_coding_type") - 1, 0);
-
- if (call_user_function_ex(CG(function_table), NULL, &nm_zlib_get_coding_type, &uf_result, 0, NULL, 1, NULL TSRMLS_CC) != FAILURE && uf_result != NULL && Z_TYPE_P(uf_result) == IS_STRING) {
- char buf[128];
- int len;
-
- assert(Z_STRVAL_P(uf_result) != NULL);
-
- len = snprintf(buf, sizeof(buf), "Content-Encoding: %s", Z_STRVAL_P(uf_result));
- if (len <= 0 || sapi_add_header(buf, len, 1) == FAILURE) {
- return FAILURE;
- }
- if (sapi_add_header("Vary: Accept-Encoding", sizeof("Vary: Accept-Encoding") - 1, 1) == FAILURE) {
- return FAILURE;
- }
- }
- if (uf_result != NULL) {
- zval_ptr_dtor(&uf_result);
- }
- }
-#endif
-
- /* 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: {
- sapi_header_struct http_status_line;
- char buf[255];
-
- if (SG(sapi_headers).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);
- } else {
- http_status_line.header = buf;
- http_status_line.header_len = sprintf(buf, "HTTP/1.0 %d X", SG(sapi_headers).http_response_code);
- }
- 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;
- }
-
- sapi_send_headers_free(TSRMLS_C);
-
- 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_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC))
-{
- sapi_module.treat_data = treat_data;
- return SUCCESS;
-}
-
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len TSRMLS_DC))
-{
- sapi_module.input_filter = input_filter;
- 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;
- }
-}
-
-SAPI_API int sapi_get_fd(int *fd TSRMLS_DC)
-{
- if (sapi_module.get_fd) {
- return sapi_module.get_fd(fd TSRMLS_CC);
- } else {
- return FAILURE;
- }
-}
-
-SAPI_API int sapi_force_http_10(TSRMLS_D)
-{
- if (sapi_module.force_http_10) {
- return sapi_module.force_http_10(TSRMLS_C);
- } else {
- return FAILURE;
- }
-}
-
-
-SAPI_API int sapi_get_target_uid(uid_t *obj TSRMLS_DC)
-{
- if (sapi_module.get_target_uid) {
- return sapi_module.get_target_uid(obj TSRMLS_CC);
- } else {
- return FAILURE;
- }
-}
-
-SAPI_API int sapi_get_target_gid(gid_t *obj TSRMLS_DC)
-{
- if (sapi_module.get_target_gid) {
- return sapi_module.get_target_gid(obj TSRMLS_CC);
- } else {
- return FAILURE;
- }
-}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/SAPI.h b/main/SAPI.h
deleted file mode 100644
index 88692d255b..0000000000
--- a/main/SAPI.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#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
-
-#undef shutdown
-
-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 *mimetype;
- 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, *raw_post_data;
- char *cookie_data;
- long content_length;
- uint post_data_length, raw_post_data_length;
-
- char *path_translated;
- char *request_uri;
-
- const char *content_type;
-
- zend_bool headers_only;
- zend_bool no_headers;
- zend_bool headers_read;
-
- 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;
-
- /* this is necessary for CLI module */
- int argc;
- char **argv;
-} sapi_request_info;
-
-
-typedef struct _sapi_globals_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;
- zend_bool sapi_started;
-} 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);
-
-/*
- * This is the preferred and maintained API for
- * operating on HTTP headers.
- */
-
-/*
- * Always specify a sapi_header_line this way:
- *
- * sapi_header_line ctr = {0};
- */
-
-typedef struct {
- char *line; /* If you allocated this, you need to free it yourself */
- uint line_len;
- long response_code; /* long due to zend_parse_parameters compatibility */
-} sapi_header_line;
-
-typedef enum { /* Parameter: */
- SAPI_HEADER_REPLACE, /* sapi_header_line* */
- SAPI_HEADER_ADD, /* sapi_header_line* */
- SAPI_HEADER_SET_STATUS /* int */
-} sapi_header_op_enum;
-
-SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC);
-
-
-/* Deprecated functions. Use sapi_header_op instead. */
-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(a, b, c) sapi_add_header_ex((a),(b),(c),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_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC));
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len TSRMLS_DC));
-
-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);
-SAPI_API void sapi_activate_headers_only(TSRMLS_D);
-
-SAPI_API int sapi_get_fd(int *fd TSRMLS_DC);
-SAPI_API int sapi_force_http_10(TSRMLS_D);
-
-SAPI_API int sapi_get_target_uid(uid_t * TSRMLS_DC);
-SAPI_API int sapi_get_target_gid(gid_t * 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);
- void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC);
- char *executable_location;
-
- int php_ini_ignore;
-
- int (*get_fd)(int *fd TSRMLS_DC);
-
- int (*force_http_10)(TSRMLS_D);
-
- int (*get_target_uid)(uid_t * TSRMLS_DC);
- int (*get_target_gid)(gid_t * TSRMLS_DC);
-
- unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len TSRMLS_DC);
-};
-
-
-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) void post_reader(TSRMLS_D)
-#define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg TSRMLS_DC)
-
-#define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray TSRMLS_DC)
-#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, char *var, char **val, unsigned int val_len TSRMLS_DC)
-
-SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
-SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader);
-SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data);
-SAPI_API SAPI_INPUT_FILTER_FUNC(php_default_input_filter);
-
-#define STANDARD_SAPI_MODULE_PROPERTIES
-
-#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 ae28159913..0000000000
--- a/main/alloca.c
+++ /dev/null
@@ -1,501 +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. */
-
-/* $Id$ */
-
-#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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/build-defs.h.in b/main/build-defs.h.in
deleted file mode 100644
index 04f7f4a920..0000000000
--- a/main/build-defs.h.in
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- C -*-
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2002 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: 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_BIRDSTEP_INCLUDE ""
-#define PHP_BIRDSTEP_LIBS ""
-#define PEAR_INSTALLDIR "@EXPANDED_PEAR_INSTALLDIR@"
-#define PHP_INCLUDE_PATH "@INCLUDE_PATH@"
-#define PHP_EXTENSION_DIR "@EXPANDED_EXTENSION_DIR@"
-#define PHP_PREFIX "@prefix@"
-#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@"
-#define PHP_CONFIG_FILE_SCAN_DIR "@EXPANDED_PHP_CONFIG_FILE_SCAN_DIR@"
-#define PHP_SHLIB_SUFFIX "@SHLIB_SUFFIX_NAME@"
diff --git a/main/config.nw.h b/main/config.nw.h
deleted file mode 100644
index e7b392ee1d..0000000000
--- a/main/config.nw.h
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-/* config.nw.h. Configure file for NetWare platform */
-
-
-/* Define if PHP to setup it's own SIGCHLD handler (not needed on NetWare) */
-#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 SNMP */
-/*#define HAVE_SNMP 1*/
-
-/* defines for PostgreSQL extension */
-#define HAVE_PGSQL 1
-#define PHP_PGSQL_PRIVATE 1
-#define HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT 1
-#define HAVE_PQCLIENTENCODING 1
-#define HAVE_PQCMDTUPLES 1
-#define HAVE_PQOIDVALUE 1
-
-/* set to enable bundled PCRE library */
-#define HAVE_BUNDLED_PCRE 1
-
-/* set to enable bundled expat library */
-/* #define HAVE_LIBEXPAT 1 */ /* For now */
-#define HAVE_WDDX 0
-
-/* set to enable the crypt command */
-/* #define HAVE_CRYPT 1 */
-/* #define HAVE_CRYPT_H 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
-
-
-/* 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 */ /* We will use readdir() from LibC */
-
-#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 if you have the gettimeofday function. */
-#define HAVE_GETTIMEOFDAY 1
-
-/* Define if you have the putenv function. */
-#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. */
-/* Though we have alloca(), this seems to be causing some problem with the stack pointer -- hence not using it */
-/* #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. */
-#define HAVE_ST_BLKSIZE
-
-/* Define if your struct stat has st_blocks. */
-#define 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 HAVE_LDAP 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 memcpy function. */
-#define HAVE_MEMCPY 1
-
-/* Define if you have the memmove function. */
-#define HAVE_MEMMOVE 1
-
-/* Define if you have the regcomp function. */
-#define HAVE_REGCOMP 1
-
-/* Define if you have the setlocale function. */
-/* #define HAVE_SETLOCALE 1 */ /* LibC doesn't seem to be supporting fully -- hence commenting for now */
-
-#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. */
-#define HAVE_DIRENT_H 1
-
-/* 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. */
-#ifdef USE_WINSOCK
-#undef HAVE_SYS_SOCKET_H
-#else
-#define HAVE_SYS_SOCKET_H 1 /* Added '1' for '#if' to work */
-#endif
-
-/* 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. */
-#define HAVE_UNISTD_H 1 /* Added '1' for '#if' to work */
-
-/* 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
-
-/* Defined since unsetenv function is defined in LibC.
- * This is used to destroy env values in the function php_putenv_destructor.
- * If we do not use unsetenv, then the environment variables are directlt manipulated.
- * This will then result in LibC not being able to do the maintenance
- * that is required for NetWare.
- */
-#define HAVE_UNSETENV 1
-
-/* Default directory for loading extensions. */
-#define PHP_EXTENSION_DIR "sys:/php/ext"
-
-#define SIZEOF_INT 4
-
-/* Define directory constants for PHP and PEAR */
-
-/* This is the default configuration file to read */
-#define CONFIGURATION_FILE_PATH "php.ini"
-
-#define APACHE_MODULE_DIR "sys:/apache/modules"
-#define PHP_BINDIR "sys:/php"
-#define PHP_LIBDIR PHP_BINDIR
-#define PHP_DATADIR PHP_BINDIR
-#define PHP_SYSCONFDIR PHP_BINDIR
-#define PHP_LOCALSTATEDIR PHP_BINDIR
-#define PHP_CONFIG_FILE_PATH "sys:/php"
-#define PEAR_INSTALLDIR "sys:/php/pear"
-
-#define PHP_CONFIG_FILE_SCAN_DIR NULL
-#define PHP_EXTENSION_DIR "sys:/php/ext"
-
-#define PHP_INCLUDE_PATH NULL
-
-#define PHP_PREFIX "sys:/php"
-#define PHP_SHLIB_SUFFIX "nlm"
-
-#define USE_CONFIG_FILE 1
-
diff --git a/main/config.w32.h b/main/config.w32.h
deleted file mode 100644
index 8654cb2fb1..0000000000
--- a/main/config.w32.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- Build Configuration for Win32.
- This has only been tested with MS VisualC++ 6 (and later).
-
- $Id$
-*/
-
-/* Default PHP / PEAR directories */
-#define CONFIGURATION_FILE_PATH "php.ini"
-#define PEAR_INSTALLDIR "c:\\php4\\pear"
-#define PHP_BINDIR "c:\\php4"
-#define PHP_CONFIG_FILE_PATH (getenv("SystemRoot"))?getenv("SystemRoot"):""
-#define PHP_CONFIG_FILE_SCAN_DIR ""
-#define PHP_DATADIR "c:\\php4"
-#define PHP_EXTENSION_DIR "c:\\php4"
-#define PHP_INCLUDE_PATH ".;c:\\php4\\pear"
-#define PHP_LIBDIR "c:\\php4"
-#define PHP_LOCALSTATEDIR "c:\\php4"
-#define PHP_PREFIX "c:\\php4"
-#define PHP_SYSCONFDIR "c:\\php4"
-
-/* Enable / Disable BCMATH extension (default: enabled) */
-#define WITH_BCMATH 1
-
-/* Enable / Disable crypt() function (default: enabled) */
-#define HAVE_CRYPT 1
-#define PHP_STD_DES_CRYPT 1
-#define PHP_EXT_DES_CRYPT 0
-#define PHP_MD5_CRYPT 1
-#define PHP_BLOWFISH_CRYPT 0
-
-/* Enable / Disable CALENDAR extension (default: enabled) */
-#define HAVE_CALENDAR 1
-
-/* Enable / Disable RPC extension (default: enabled) */
-#define HAVE_RPC 1
-
-/* Enable / Disable COM extension (default: enabled) */
-#define HAVE_COM 1
-
-/* Enable / Disable CTYPE extension (default: enabled) */
-#define HAVE_CTYPE 1
-
-/* Enable / Disable FTP extension (default: enabled) */
-#define HAVE_FTP 1
-
-/* Enable / Disable MBSTRING extension (default: disabled) */
-/* #define HAVE_MBSTRING 0 */
-/* #define HAVE_MBREGEX 0 */
-/* #define HAVE_MBSTR_CN 0 */
-/* #define HAVE_MBSTR_JA 0 */
-/* #define HAVE_MBSTR_KR 0 */
-/* #define HAVE_MBSTR_RU 0 */
-/* #define HAVE_MBSTR_TW 0 */
-
-/* Enable / Disable MySQL extension (default: enabled) */
-#define HAVE_MYSQL 1
-
-/* Enable / Disable ODBC extension (default: enabled) */
-#define HAVE_UODBC 1
-
-/* Enable / Disable PCRE extension (default: enabled) */
-#define HAVE_BUNDLED_PCRE 1
-#define HAVE_PCRE 1
-
-/* Enable / Disable SESSION extension (default: enabled) */
-#define HAVE_SESSION 1
-
-/* Enable / Disable TOKENIZER extension (default: enabled) */
-#define HAVE_TOKENIZER 1
-
-/* Enable / Disable WDDX extension (default: enabled) */
-#define HAVE_WDDX 1
-
-/* Enable / Disable XML extension (default: enabled) */
-#define HAVE_LIBEXPAT 1
-
-/* Enable / Disable ZLIB extension (default: enabled) */
-#define HAVE_ZLIB 1
-
-/* PHP Runtime Configuration */
-#define FORCE_CGI_REDIRECT 1
-#define PHP_URL_FOPEN 1
-#define PHP_SAFE_MODE 0
-#define MAGIC_QUOTES 0
-#define USE_CONFIG_FILE 1
-#define DEFAULT_SHORT_OPEN_TAG "1"
-#define ENABLE_PATHINFO_CHECK 1
-
-/* Platform-Specific Configuration. Should not be changed. */
-#define PHP_SIGCHILD 0
-#define HAVE_LIBBIND 1
-#define HAVE_GETSERVBYNAME 1
-#define HAVE_GETSERVBYPORT 1
-#define HAVE_GETPROTOBYNAME 1
-#define HAVE_GETPROTOBYNUMBER 1
-#define STDIN_FILENO 0
-#define STDOUT_FILENO 1
-#define STDERR_FILENO 2
-#define HAVE_ERRMSG_H 0
-#undef HAVE_ADABAS
-#undef HAVE_SOLID
-#undef HAVE_LINK
-#undef HAVE_SYMLINK
-#undef HAVE_USLEEP
-#define HAVE_GETCWD 1
-#define HAVE_POSIX_READDIR_R 1
-#define NEED_ISBLANK 1
-#define DISCARD_PATH 0
-#undef HAVE_SETITIMER
-#undef HAVE_IODBC
-#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
-#undef HAVE_FLOCK
-#define HAVE_ALLOCA 1
-#undef HAVE_SYS_TIME_H
-#define HAVE_SIGNAL_H 1
-#undef HAVE_ST_BLKSIZE
-#undef HAVE_ST_BLOCKS
-#define HAVE_ST_RDEV 1
-#define HAVE_UTIME_NULL 1
-#define HAVE_VPRINTF 1
-#define STDC_HEADERS 1
-#define REGEX 1
-#define HSREGEX 1
-#define HAVE_GCVT 1
-#define HAVE_GETLOGIN 1
-#define HAVE_GETTIMEOFDAY 1
-#define HAVE_MEMCPY 1
-#define HAVE_MEMMOVE 1
-#define HAVE_PUTENV 1
-#define HAVE_REGCOMP 1
-#define HAVE_SETLOCALE 1
-#define HAVE_LOCALECONV 1
-#define HAVE_LOCALE_H 1
-#ifndef HAVE_LIBBIND
-#define HAVE_SETVBUF 1
-#endif
-#define HAVE_SHUTDOWN 1
-#define HAVE_SNPRINTF 1
-#define HAVE_VSNPRINTF 1
-#define HAVE_STRCASECMP 1
-#define HAVE_STRDUP 1
-#define HAVE_STRERROR 1
-#define HAVE_STRSTR 1
-#define HAVE_TEMPNAM 1
-#define HAVE_UTIME 1
-#undef HAVE_DIRENT_H
-#define HAVE_ASSERT_H 1
-#define HAVE_FCNTL_H 1
-#define HAVE_GRP_H 0
-#define HAVE_PWD_H 1
-#define HAVE_STRING_H 1
-#undef HAVE_SYS_FILE_H
-#undef HAVE_SYS_SOCKET_H
-#undef HAVE_SYS_WAIT_H
-#define HAVE_SYSLOG_H 1
-#undef HAVE_UNISTD_H
-#define HAVE_LIBDL 1
-#define HAVE_LIBM 1
-#define HAVE_CUSERID 0
-#undef HAVE_RINT
-#define HAVE_STRFTIME 1
-#define SIZEOF_INT 4
-#define HAVE_GLOB
-#define PHP_SHLIB_SUFFIX "dll"
-
-/* Win32 supports strcoll */
-#define HAVE_STRCOLL 1
-
-/* Win32 support proc_open */
-#define PHP_CAN_SUPPORT_PROC_OPEN 1
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
deleted file mode 100644
index eac8e6f402..0000000000
--- a/main/fopen_wrappers.c
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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
-#define O_RDONLY _O_RDONLY
-#include "win32/param.h"
-#elif defined(NETWARE)
-/*#include <ws2nlm.h>*/
-/*#include <sys/socket.h>*/
-#ifdef NEW_LIBC
-#include <sys/param.h>
-#else
-#include "netware/param.h"
-#endif
-#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"
-#elif defined(NETWARE)
-#include "netware/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 <winsock2.h>
-#elif defined(NETWARE) && defined(USE_WINSOCK)
-/*#include <ws2nlm.h>*/
-#include <novsock2.h>
-#else
-#include <netinet/in.h>
-#include <netdb.h>
-#if HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-#endif
-
-#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
-#undef AF_UNIX
-#endif
-
-#if defined(AF_UNIX)
-#include <sys/un.h>
-#endif
-/* }}} */
-
-/* {{{ 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(const char *basedir, const char *path TSRMLS_DC)
-{
- char resolved_name[MAXPATHLEN];
- char resolved_basedir[MAXPATHLEN];
- char local_open_basedir[MAXPATHLEN];
- int local_open_basedir_pos;
- int resolved_basedir_len;
- int resolved_name_len;
-
- /* 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)) {
- /* Handler for basedirs that end with a / */
- if (basedir[strlen(basedir)-1] == PHP_DIR_SEPARATOR) {
- resolved_basedir_len = strlen(resolved_basedir);
- resolved_basedir[resolved_basedir_len] = '/';
- resolved_basedir[++resolved_basedir_len] = '\0';
- } else {
- resolved_basedir_len = strlen(resolved_basedir);
- }
-
- if (path[strlen(path)-1] == PHP_DIR_SEPARATOR) {
- resolved_name_len = strlen(resolved_name);
- resolved_name[resolved_name_len] = '/';
- resolved_name[++resolved_name_len] = '\0';
- }
-
- /* Check the path */
-#ifdef PHP_WIN32
- if (strncasecmp(resolved_basedir, resolved_name, resolved_basedir_len) == 0) {
-#else
- if (strncmp(resolved_basedir, resolved_name, resolved_basedir_len) == 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(const 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_docref(NULL TSRMLS_CC, E_WARNING,
- "open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s)", path, PG(open_basedir));
- efree(pathbuf);
- errno = EPERM; /* we deny permission to open it */
- return -1;
- }
-
- /* Nothing to check... */
- return 0;
-}
-/* }}} */
-
-/* {{{ php_check_safe_mode_include_dir
- */
-PHPAPI int php_check_safe_mode_include_dir(char *path TSRMLS_DC)
-{
- /* Only check when safe_mode or open_basedir is on and safe_mode_include_dir is available */
- if (((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) &&
- PG(safe_mode_include_dir) && *PG(safe_mode_include_dir))
- {
- char *pathbuf;
- char *ptr;
- char *end;
- char resolved_name[MAXPATHLEN];
-
- /* Resolve the real path into resolved_name */
- if (expand_filepath(path, resolved_name TSRMLS_CC) == NULL)
- return -1;
-
- pathbuf = estrdup(PG(safe_mode_include_dir));
-
- ptr = pathbuf;
-
- while (ptr && *ptr) {
- end = strchr(ptr, DEFAULT_DIR_SEPARATOR);
- if (end != NULL) {
- *end = '\0';
- end++;
- }
-
- /* Check the path */
-#ifdef PHP_WIN32
- if (strncasecmp(ptr, resolved_name, strlen(ptr)) == 0)
-#else
- if (strncmp(ptr, resolved_name, strlen(ptr)) == 0)
-#endif
- {
- /* File is in the right directory */
- efree(pathbuf);
- return 0;
- }
-
- ptr = end;
- }
- efree(pathbuf);
- 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_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) {
- STR_FREE(SG(request_info).path_translated); /* for same reason as above */
- SG(request_info).path_translated = NULL;
- 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];
- struct stat sb;
- FILE *fp;
- int path_length;
- int filename_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
- */
-
- /* Absolute path open */
- if (IS_ABSOLUTE_PATH(filename, filename_length)) {
- if ((php_check_safe_mode_include_dir(filename TSRMLS_CC)) == 0)
- /* filename is in safe_mode_include_dir (or subdir) */
- return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC);
-
- 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);
- if (PG(safe_mode)) {
- if (VCWD_STAT(trypath, &sb) == 0) {
- /* file exists ... check permission */
- if ((php_check_safe_mode_include_dir(trypath TSRMLS_CC) == 0) ||
- php_checkuid(trypath, mode, CHECKUID_CHECK_MODE_PARAM))
- /* UID ok, or trypath is in safe_mode_include_dir */
- fp = php_fopen_and_set_opened_path(trypath, mode, opened_path TSRMLS_CC);
- else
- fp = NULL;
-
- efree(pathbuf);
- return fp;
- }
- }
- 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_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, 1)) {
- 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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h
deleted file mode 100644
index 331360c267..0000000000
--- a/main/fopen_wrappers.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Jim Winstead <jimw@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef FOPEN_WRAPPERS_H
-#define FOPEN_WRAPPERS_H
-
-BEGIN_EXTERN_C()
-#include "php_globals.h"
-
-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(const char *path TSRMLS_DC);
-PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path TSRMLS_DC);
-
-PHPAPI int php_check_safe_mode_include_dir(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);
-END_EXTERN_C()
-
-#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 2af72800ac..0000000000
--- a/main/internal_functions.c.in
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- C -*-
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2002 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>
-
-#if HAVE_OPENSSL_EXT
-/* zlib typedefs free_func which causes problems if the SSL includes happen
- * after zlib.h is included */
-# include <openssl/ssl.h>
-#endif
-
-@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_nw.c b/main/internal_functions_nw.c
deleted file mode 100644
index 6d83ae60a2..0000000000
--- a/main/internal_functions_nw.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- | Modified for NetWare: Novell, Inc. |
- +----------------------------------------------------------------------+
- */
-
-/* $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/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"*/ /* Commented out for now */
-#include "ext/session/php_session.h"
-/*#include "ext/xml/php_xml.h"
-#include "ext/wddx/php_wddx.h"
-#include "ext/mysql/php_mysql.h"*/ /* Commented out for now */
-/* }}} */
-
-/* {{{ 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,*/
- phpext_ftp_ptr,
-#if defined(MBSTR_ENC_TRANS)
- phpext_mbstring_ptr,
-#endif
-/* phpext_mysql_ptr,*/ /* Commented out for now */
-/* phpext_odbc_ptr, */ /* Commented out for now */
- phpext_pcre_ptr,
- phpext_session_ptr,
-/* phpext_xml_ptr,
- phpext_wddx_ptr */ /* Commented out for now */
-};
-/* }}} */
-
-#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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/internal_functions_registry.h b/main/internal_functions_registry.h
deleted file mode 100644
index 60b254893a..0000000000
--- a/main/internal_functions_registry.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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 69d8cab177..0000000000
--- a/main/internal_functions_win32.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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>
-
-#ifndef ZEND_ENGINE_2
-#error HEAD does not work with ZendEngine1 anymore
-#endif
-
-#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"
-#if WITH_BCMATH
-#include "ext/bcmath/php_bcmath.h"
-#endif
-#if HAVE_CALENDAR
-#include "ext/calendar/php_calendar.h"
-#endif
-#if HAVE_CTYPE
-#include "ext/ctype/php_ctype.h"
-#endif
-#if HAVE_RPC
-#include "ext/rpc/php_rpc.h"
-#if HAVE_COM
-#include "ext/rpc/com/php_com.h"
-#endif
-#endif
-#if HAVE_FTP
-#include "ext/ftp/php_ftp.h"
-#endif
-#include "ext/standard/reg.h"
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
-#include "ext/pcre/php_pcre.h"
-#endif
-#if HAVE_UODBC
-#include "ext/odbc/php_odbc.h"
-#endif
-#if HAVE_SESSION
-#include "ext/session/php_session.h"
-#endif
-#if HAVE_LIBEXPAT
-#include "ext/xml/php_xml.h"
-#endif
-#if HAVE_LIBEXPAT && HAVE_WDDX
-#include "ext/wddx/php_wddx.h"
-#endif
-#if HAVE_MYSQL
-#include "ext/mysql/php_mysql.h"
-#endif
-#if HAVE_MBSTRING
-#include "ext/mbstring/mbstring.h"
-#endif
-#if HAVE_TOKENIZER
-#include "ext/tokenizer/php_tokenizer.h"
-#endif
-#if HAVE_ZLIB
-#include "ext/zlib/php_zlib.h"
-#endif
-/* }}} */
-
-/* {{{ php_builtin_extensions[]
- */
-zend_module_entry *php_builtin_extensions[] = {
- phpext_standard_ptr
-#if WITH_BCMATH
- ,phpext_bcmath_ptr
-#endif
-#if HAVE_CALENDAR
- ,phpext_calendar_ptr
-#endif
-#if HAVE_CTYPE
- ,phpext_ctype_ptr
-#endif
-#if HAVE_RPC
- ,phpext_rpc_ptr
-#if HAVE_COM
- ,phpext_com_ptr
-#endif
-#endif
-#if HAVE_FTP
- ,phpext_ftp_ptr
-#endif
-#if HAVE_MBSTRING
- ,phpext_mbstring_ptr
-#endif
-#if HAVE_MYSQL
- ,phpext_mysql_ptr
-#endif
-#if HAVE_UODBC
- ,phpext_odbc_ptr
-#endif
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
- ,phpext_pcre_ptr
-#endif
-#if HAVE_SESSION
- ,phpext_session_ptr
-#endif
-#if HAVE_TOKENIZER
- ,phpext_tokenizer_ptr
-#endif
-#if HAVE_LIBEXPAT
- ,phpext_xml_ptr
-#endif
-#if HAVE_LIBEXPAT && HAVE_WDDX
- ,phpext_wddx_ptr
-#endif
-#if HAVE_ZLIB
- ,phpext_zlib_ptr
-#endif
-};
-/* }}} */
-
-#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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/logos.h b/main/logos.h
deleted file mode 100644
index 4425dcec09..0000000000
--- a/main/logos.h
+++ /dev/null
@@ -1,1523 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#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,
- 247, 255, 0, 152, 134, 136, 108, 76, 84, 73,
- 70, 71, 166, 138, 148, 136, 108, 119, 192, 192,
- 192, 122, 106, 117, 139, 123, 134, 75, 59, 71,
- 167, 162, 166, 91, 85, 90, 41, 28, 39, 104,
- 91, 102, 152, 138, 150, 87, 75, 86, 105, 100,
- 105, 41, 39, 41, 152, 150, 152, 55, 43, 57,
- 160, 149, 166, 156, 140, 167, 56, 55, 57, 84,
- 76, 100, 92, 84, 116, 92, 84, 124, 116, 108,
- 148, 116, 114, 138, 85, 84, 107, 132, 131, 150,
- 84, 84, 116, 108, 108, 148, 132, 132, 180, 92,
- 92, 124, 140, 140, 188, 124, 124, 165, 105, 105,
- 140, 76, 76, 101, 100, 100, 132, 116, 116, 153,
- 156, 156, 204, 148, 148, 194, 132, 132, 172, 69,
- 69, 90, 140, 140, 180, 169, 169, 214, 92, 92,
- 116, 184, 184, 227, 203, 203, 246, 164, 165, 204,
- 232, 233, 249, 40, 41, 56, 52, 54, 72, 27,
- 31, 47, 106, 108, 116, 123, 125, 132, 106, 121,
- 166, 25, 27, 33, 17, 18, 21, 140, 156, 196,
- 108, 116, 136, 56, 65, 86, 80, 100, 136, 88,
- 94, 104, 76, 87, 101, 41, 52, 52, 71, 91,
- 88, 138, 167, 161, 183, 197, 194, 172, 183, 177,
- 100, 136, 115, 118, 177, 139, 156, 200, 172, 148,
- 223, 173, 131, 195, 153, 94, 126, 105, 105, 165,
- 123, 85, 114, 94, 88, 149, 105, 137, 165, 145,
- 73, 131, 88, 76, 153, 92, 106, 184, 123, 90,
- 167, 105, 141, 212, 152, 157, 180, 159, 120, 187,
- 123, 131, 198, 135, 106, 152, 108, 122, 168, 124,
- 77, 111, 78, 87, 151, 88, 137, 213, 138, 148,
- 225, 148, 104, 169, 103, 74, 154, 70, 70, 132,
- 67, 106, 183, 102, 140, 182, 138, 91, 135, 88,
- 154, 198, 151, 176, 228, 169, 91, 169, 78, 122,
- 199, 108, 163, 218, 153, 86, 156, 70, 105, 183,
- 88, 103, 169, 88, 138, 215, 120, 151, 216, 137,
- 49, 121, 31, 120, 185, 104, 136, 200, 120, 66,
- 122, 49, 134, 184, 120, 151, 228, 124, 121, 170,
- 104, 68, 96, 59, 180, 205, 171, 44, 93, 25,
- 79, 147, 52, 87, 135, 68, 105, 183, 72, 121,
- 201, 86, 138, 214, 105, 103, 150, 83, 154, 200,
- 135, 87, 162, 51, 104, 168, 74, 119, 185, 89,
- 134, 195, 104, 69, 132, 36, 154, 215, 120, 70,
- 148, 25, 102, 176, 57, 119, 167, 90, 176, 233,
- 143, 98, 161, 57, 164, 230, 122, 151, 199, 119,
- 92, 166, 37, 122, 192, 74, 135, 204, 86, 150,
- 216, 103, 145, 202, 104, 116, 190, 57, 45, 69,
- 26, 92, 172, 20, 118, 176, 69, 132, 186, 87,
- 168, 218, 124, 35, 50, 20, 152, 177, 112, 142,
- 162, 98, 70, 71, 38, 88, 87, 57, 166, 165,
- 109, 202, 200, 143, 173, 166, 91, 180, 177, 143,
- 134, 127, 89, 92, 84, 44, 88, 85, 71, 73,
- 69, 55, 57, 53, 40, 185, 168, 118, 114, 100,
- 63, 123, 118, 106, 156, 149, 134, 105, 84, 41,
- 230, 177, 85, 87, 71, 43, 239, 199, 124, 235,
- 205, 148, 170, 152, 119, 167, 121, 48, 51, 42,
- 27, 206, 173, 121, 167, 109, 22, 190, 132, 42,
- 202, 145, 60, 181, 143, 86, 228, 179, 109, 145,
- 116, 72, 201, 163, 107, 105, 86, 58, 37, 31,
- 22, 206, 151, 80, 216, 164, 91, 184, 151, 105,
- 166, 137, 99, 231, 207, 176, 111, 101, 87, 127,
- 78, 15, 150, 105, 52, 122, 87, 42, 152, 135,
- 114, 104, 58, 6, 72, 57, 41, 225, 185, 141,
- 179, 126, 70, 161, 115, 69, 138, 102, 64, 155,
- 122, 87, 183, 151, 118, 77, 49, 24, 114, 75,
- 39, 121, 88, 57, 168, 152, 137, 95, 57, 26,
- 103, 69, 40, 188, 138, 96, 88, 71, 56, 65,
- 35, 11, 143, 107, 79, 217, 171, 136, 88, 59,
- 39, 105, 86, 73, 225, 189, 163, 129, 94, 71,
- 199, 160, 135, 129, 103, 88, 148, 121, 105, 207,
- 172, 153, 137, 117, 105, 103, 73, 57, 188, 143,
- 121, 198, 182, 174, 204, 198, 195, 101, 60, 42,
- 116, 76, 57, 119, 88, 74, 166, 127, 109, 69,
- 43, 34, 55, 43, 39, 165, 133, 123, 182, 149,
- 139, 185, 162, 156, 135, 107, 101, 167, 154, 151,
- 84, 50, 44, 87, 59, 54, 139, 133, 132, 102,
- 76, 72, 119, 90, 86, 71, 58, 56, 150, 124,
- 120, 87, 73, 71, 136, 121, 119, 167, 139, 136,
- 182, 138, 134, 120, 104, 103, 116, 76, 76, 103,
- 87, 87, 122, 120, 120, 255, 255, 255, 0, 0,
- 0, 33, 249, 4, 1, 0, 0, 5, 0, 44,
- 0, 0, 0, 0, 130, 0, 67, 0, 64, 8,
- 255, 0, 11, 8, 28, 72, 176, 160, 193, 131,
- 8, 13, 162, 88, 24, 34, 196, 138, 15, 41,
- 82, 136, 16, 97, 194, 132, 135, 18, 37, 64,
- 180, 184, 192, 177, 99, 199, 22, 32, 64, 148,
- 24, 225, 193, 196, 68, 17, 41, 62, 124, 104,
- 24, 98, 33, 138, 132, 48, 99, 202, 156, 121,
- 144, 97, 10, 19, 32, 54, 144, 32, 161, 162,
- 39, 147, 34, 81, 214, 0, 50, 99, 166, 74,
- 20, 35, 73, 162, 36, 65, 194, 101, 138, 83,
- 51, 110, 246, 108, 177, 178, 134, 205, 158, 70,
- 101, 188, 164, 49, 147, 38, 205, 155, 41, 70,
- 164, 72, 137, 178, 100, 73, 19, 179, 79, 180,
- 148, 69, 43, 230, 75, 19, 43, 85, 2, 169,
- 209, 130, 6, 208, 220, 43, 74, 152, 248, 232,
- 112, 33, 164, 200, 12, 34, 86, 44, 164, 73,
- 184, 0, 138, 15, 30, 116, 170, 224, 193, 132,
- 143, 23, 41, 110, 182, 156, 177, 50, 167, 207,
- 27, 48, 108, 186, 148, 241, 83, 40, 16, 32,
- 70, 143, 2, 173, 113, 3, 168, 210, 35, 74,
- 140, 246, 116, 113, 66, 100, 8, 145, 8, 17,
- 226, 217, 168, 241, 160, 223, 0, 118, 184, 217,
- 121, 243, 102, 173, 247, 182, 109, 187, 189, 101,
- 243, 69, 156, 120, 182, 109, 221, 192, 201, 155,
- 55, 204, 147, 243, 56, 115, 164, 116, 153, 94,
- 133, 52, 164, 73, 106, 202, 100, 93, 228, 231,
- 77, 152, 58, 97, 240, 48, 255, 193, 56, 82,
- 196, 135, 151, 52, 67, 136, 80, 172, 224, 30,
- 0, 0, 13, 26, 0, 168, 7, 224, 25, 62,
- 0, 248, 220, 185, 3, 16, 175, 193, 1, 27,
- 54, 112, 64, 1, 5, 19, 36, 64, 196, 129,
- 84, 28, 113, 68, 28, 125, 80, 113, 74, 55,
- 191, 252, 98, 138, 2, 51, 204, 64, 3, 14,
- 56, 84, 96, 10, 0, 6, 164, 179, 0, 2,
- 218, 32, 115, 204, 44, 210, 132, 179, 77, 62,
- 4, 224, 179, 77, 56, 199, 244, 82, 15, 3,
- 7, 74, 96, 78, 55, 240, 72, 176, 0, 4,
- 252, 152, 50, 140, 53, 156, 244, 193, 198, 27,
- 80, 85, 177, 5, 87, 129, 196, 129, 197, 24,
- 88, 24, 161, 198, 29, 101, 104, 225, 214, 21,
- 78, 226, 161, 198, 21, 21, 153, 112, 30, 76,
- 57, 145, 0, 142, 57, 230, 204, 179, 28, 55,
- 221, 168, 179, 78, 3, 28, 28, 80, 15, 62,
- 234, 212, 211, 205, 55, 237, 180, 217, 230, 61,
- 112, 126, 99, 128, 1, 250, 212, 105, 74, 43,
- 189, 216, 34, 204, 53, 242, 32, 32, 0, 4,
- 57, 224, 112, 33, 14, 57, 228, 96, 207, 47,
- 154, 100, 2, 202, 47, 247, 204, 121, 192, 123,
- 7, 16, 112, 64, 3, 3, 172, 227, 141, 49,
- 198, 172, 82, 203, 46, 208, 192, 35, 202, 52,
- 175, 136, 162, 137, 51, 189, 220, 2, 11, 44,
- 180, 240, 226, 201, 24, 75, 222, 129, 8, 24,
- 94, 160, 255, 97, 70, 25, 105, 168, 145, 198,
- 26, 104, 8, 130, 198, 146, 105, 176, 17, 136,
- 33, 113, 136, 225, 208, 7, 48, 133, 128, 83,
- 11, 14, 168, 2, 142, 51, 201, 40, 227, 172,
- 50, 220, 152, 131, 141, 114, 243, 204, 195, 165,
- 57, 252, 32, 80, 225, 12, 60, 144, 160, 0,
- 63, 252, 40, 160, 0, 3, 42, 252, 96, 138,
- 3, 14, 240, 243, 13, 55, 21, 208, 32, 3,
- 4, 25, 166, 3, 47, 14, 185, 212, 43, 202,
- 47, 161, 152, 2, 231, 3, 60, 240, 16, 132,
- 2, 53, 24, 16, 79, 13, 10, 180, 194, 74,
- 43, 154, 136, 82, 1, 16, 16, 52, 76, 207,
- 40, 244, 124, 211, 202, 50, 188, 180, 114, 197,
- 28, 138, 196, 145, 70, 30, 107, 128, 129, 134,
- 31, 121, 96, 167, 134, 31, 110, 92, 33, 200,
- 29, 133, 44, 66, 200, 36, 113, 16, 241, 130,
- 11, 39, 160, 39, 211, 97, 38, 140, 48, 66,
- 9, 27, 20, 195, 204, 206, 215, 144, 67, 78,
- 52, 209, 144, 3, 13, 51, 233, 224, 32, 3,
- 2, 242, 152, 163, 13, 55, 213, 50, 192, 143,
- 3, 22, 218, 51, 205, 52, 206, 128, 67, 15,
- 14, 64, 228, 242, 202, 40, 92, 143, 130, 206,
- 52, 212, 52, 227, 202, 44, 178, 148, 29, 75,
- 44, 193, 8, 147, 76, 170, 164, 144, 194, 203,
- 219, 157, 108, 178, 9, 38, 110, 116, 33, 70,
- 162, 162, 20, 3, 113, 215, 153, 216, 255, 178,
- 201, 28, 134, 204, 113, 73, 32, 140, 64, 82,
- 8, 35, 140, 80, 210, 200, 36, 136, 20, 242,
- 135, 26, 227, 248, 19, 195, 11, 48, 12, 86,
- 24, 76, 54, 81, 84, 101, 6, 27, 72, 128,
- 3, 4, 244, 76, 35, 15, 46, 206, 104, 147,
- 76, 50, 34, 142, 56, 139, 43, 157, 22, 19,
- 141, 54, 216, 60, 60, 141, 61, 246, 96, 243,
- 77, 56, 181, 240, 226, 246, 219, 164, 44, 221,
- 205, 51, 226, 180, 226, 11, 39, 115, 136, 113,
- 135, 31, 119, 220, 161, 71, 30, 121, 44, 255,
- 135, 32, 109, 216, 33, 189, 29, 112, 220, 65,
- 8, 33, 214, 223, 113, 5, 17, 49, 76, 254,
- 114, 229, 150, 95, 46, 254, 248, 46, 177, 244,
- 16, 68, 18, 69, 164, 254, 10, 236, 179, 228,
- 254, 251, 13, 185, 180, 208, 9, 244, 199, 44,
- 255, 253, 46, 141, 175, 255, 254, 5, 49, 4,
- 81, 205, 32, 232, 192, 6, 116, 178, 19, 158,
- 244, 36, 8, 65, 96, 194, 19, 206, 178, 4,
- 41, 84, 193, 10, 112, 129, 32, 4, 151, 0,
- 7, 59, 124, 65, 13, 96, 104, 194, 89, 132,
- 96, 4, 37, 60, 225, 11, 95, 120, 194, 21,
- 138, 144, 151, 32, 252, 96, 128, 27, 232, 128,
- 10, 251, 18, 146, 18, 152, 36, 5, 43, 104,
- 137, 204, 248, 119, 57, 20, 132, 32, 5, 137,
- 217, 201, 1, 181, 240, 135, 59, 180, 161, 12,
- 102, 216, 131, 30, 255, 26, 193, 8, 61, 172,
- 97, 16, 135, 56, 132, 35, 20, 65, 134, 42,
- 216, 74, 15, 111, 232, 195, 25, 206, 80, 135,
- 58, 16, 225, 8, 68, 160, 66, 18, 166, 128,
- 5, 44, 132, 225, 64, 173, 25, 135, 24, 199,
- 72, 70, 50, 14, 97, 8, 99, 28, 66, 21,
- 195, 240, 134, 55, 168, 161, 11, 128, 112, 131,
- 21, 216, 208, 7, 55, 168, 97, 74, 95, 96,
- 146, 26, 248, 160, 4, 191, 96, 196, 74, 45,
- 217, 159, 122, 64, 192, 19, 30, 48, 160, 30,
- 103, 114, 7, 110, 18, 64, 5, 39, 96, 97,
- 9, 70, 24, 195, 25, 222, 144, 6, 52, 96,
- 102, 50, 96, 216, 66, 20, 204, 16, 136, 57,
- 128, 225, 17, 125, 56, 66, 21, 197, 113, 138,
- 120, 68, 128, 3, 27, 152, 1, 134, 32, 16,
- 10, 129, 225, 71, 29, 42, 242, 205, 111, 194,
- 145, 143, 117, 228, 35, 28, 183, 216, 197, 46,
- 120, 97, 13, 95, 28, 199, 28, 244, 144, 129,
- 12, 20, 240, 141, 101, 176, 162, 71, 93, 184,
- 130, 24, 194, 16, 135, 49, 144, 161, 14, 94,
- 196, 194, 23, 4, 1, 136, 71, 168, 225, 11,
- 109, 240, 3, 35, 208, 208, 5, 56, 100, 193,
- 102, 37, 185, 82, 76, 56, 199, 19, 126, 232,
- 163, 29, 221, 24, 198, 55, 234, 129, 27, 10,
- 112, 32, 30, 195, 128, 37, 154, 234, 113, 15,
- 2, 220, 227, 0, 241, 136, 7, 0, 78, 33,
- 255, 159, 3, 224, 51, 2, 167, 120, 6, 59,
- 134, 193, 13, 112, 160, 131, 30, 127, 162, 129,
- 66, 9, 37, 129, 7, 48, 64, 1, 246, 16,
- 128, 10, 72, 96, 1, 167, 205, 131, 0, 0,
- 24, 192, 4, 38, 192, 14, 113, 120, 3, 22,
- 214, 192, 148, 166, 106, 81, 141, 119, 24, 52,
- 29, 244, 224, 70, 47, 96, 129, 41, 76, 252,
- 65, 14, 105, 64, 89, 32, 2, 241, 7, 55,
- 60, 98, 13, 85, 88, 66, 21, 226, 240, 6,
- 55, 248, 244, 13, 108, 0, 195, 31, 30, 49,
- 7, 56, 40, 97, 34, 196, 74, 136, 7, 46,
- 176, 1, 4, 76, 3, 27, 92, 194, 6, 55,
- 218, 33, 143, 164, 113, 105, 30, 110, 106, 71,
- 181, 230, 129, 141, 170, 202, 67, 0, 51, 152,
- 168, 5, 4, 32, 0, 218, 69, 72, 25, 216,
- 138, 150, 4, 222, 181, 0, 12, 21, 234, 173,
- 185, 0, 69, 41, 64, 49, 13, 125, 0, 32,
- 2, 144, 106, 135, 1, 28, 106, 131, 1, 8,
- 135, 21, 183, 64, 69, 49, 52, 49, 10, 8,
- 228, 98, 20, 175, 80, 69, 43, 120, 161, 12,
- 88, 156, 34, 8, 89, 152, 27, 37, 244, 160,
- 135, 61, 152, 161, 112, 168, 129, 4, 35, 182,
- 208, 83, 196, 65, 162, 17, 160, 101, 196, 28,
- 156, 192, 130, 152, 197, 132, 102, 25, 1, 65,
- 49, 122, 230, 51, 114, 128, 163, 28, 92, 2,
- 7, 60, 192, 65, 91, 112, 255, 188, 67, 94,
- 160, 179, 7, 184, 194, 197, 128, 7, 40, 160,
- 39, 36, 120, 192, 57, 185, 17, 204, 119, 65,
- 32, 29, 163, 16, 5, 58, 138, 161, 51, 98,
- 16, 3, 24, 209, 152, 198, 61, 250, 241, 11,
- 165, 125, 66, 21, 175, 200, 46, 51, 108, 193,
- 10, 86, 192, 2, 19, 224, 205, 66, 97, 37,
- 48, 3, 178, 134, 130, 31, 18, 106, 5, 41,
- 48, 129, 8, 63, 252, 225, 13, 128, 248, 76,
- 104, 11, 1, 134, 46, 168, 193, 51, 51, 37,
- 4, 28, 248, 208, 61, 202, 133, 175, 48, 40,
- 88, 129, 8, 60, 64, 224, 139, 32, 0, 29,
- 59, 219, 217, 43, 110, 36, 1, 164, 65, 85,
- 27, 16, 214, 70, 53, 170, 161, 13, 85, 228,
- 226, 26, 224, 160, 70, 52, 202, 81, 12, 132,
- 142, 194, 30, 161, 80, 197, 52, 126, 129, 11,
- 92, 40, 227, 22, 181, 168, 197, 42, 86, 204,
- 226, 21, 179, 66, 83, 183, 232, 68, 220, 46,
- 17, 7, 64, 228, 1, 16, 124, 176, 131, 37,
- 34, 145, 137, 72, 88, 194, 18, 116, 240, 49,
- 30, 148, 240, 11, 60, 224, 65, 11, 88, 136,
- 130, 29, 4, 225, 7, 236, 197, 161, 123, 147,
- 131, 217, 127, 105, 56, 179, 134, 124, 224, 36,
- 88, 158, 136, 9, 12, 208, 14, 101, 28, 131,
- 22, 186, 208, 229, 46, 116, 65, 230, 89, 28,
- 195, 21, 174, 56, 134, 52, 104, 145, 170, 93,
- 164, 184, 255, 22, 186, 72, 70, 55, 72, 209,
- 221, 99, 94, 226, 15, 128, 40, 131, 26, 128,
- 148, 6, 63, 44, 162, 16, 126, 190, 195, 28,
- 176, 32, 4, 22, 184, 224, 208, 136, 102, 1,
- 12, 236, 55, 101, 42, 59, 90, 33, 54, 12,
- 1, 68, 40, 114, 179, 11, 8, 16, 133, 5,
- 204, 180, 166, 55, 173, 105, 20, 162, 80, 133,
- 124, 1, 9, 8, 70, 144, 1, 147, 124, 32,
- 134, 249, 123, 180, 170, 9, 98, 19, 19, 224,
- 172, 128, 61, 57, 96, 90, 180, 240, 132, 177,
- 72, 193, 11, 95, 240, 66, 25, 34, 195, 5,
- 77, 10, 201, 10, 81, 136, 66, 26, 170, 144,
- 20, 41, 36, 161, 11, 80, 128, 130, 20, 52,
- 120, 133, 38, 92, 1, 146, 143, 44, 203, 19,
- 52, 131, 6, 45, 104, 161, 10, 197, 203, 66,
- 16, 124, 144, 66, 190, 248, 101, 4, 38, 128,
- 97, 32, 87, 93, 229, 155, 100, 41, 214, 89,
- 184, 66, 23, 192, 112, 21, 51, 128, 1, 12,
- 107, 144, 195, 27, 206, 224, 20, 46, 176, 225,
- 12, 100, 56, 3, 18, 200, 48, 5, 43, 76,
- 1, 9, 253, 54, 195, 22, 146, 144, 132, 8,
- 214, 183, 139, 72, 33, 248, 17, 134, 160, 160,
- 36, 8, 33, 9, 71, 176, 130, 17, 176, 160,
- 160, 58, 80, 33, 12, 97, 240, 98, 21, 202,
- 192, 60, 55, 212, 202, 129, 106, 248, 195, 31,
- 240, 144, 5, 81, 139, 100, 4, 230, 255, 25,
- 183, 170, 105, 118, 1, 3, 170, 128, 9, 125,
- 176, 204, 26, 222, 64, 134, 62, 128, 193, 12,
- 133, 128, 4, 36, 160, 232, 8, 74, 84, 66,
- 52, 138, 8, 68, 37, 200, 96, 133, 46, 36,
- 97, 42, 75, 240, 226, 129, 18, 144, 0, 216,
- 68, 64, 145, 186, 17, 7, 110, 130, 35, 117,
- 113, 88, 221, 56, 197, 17, 7, 62, 234, 17,
- 208, 117, 120, 162, 138, 88, 152, 195, 27, 212,
- 82, 5, 47, 50, 40, 17, 108, 48, 66, 176,
- 193, 224, 83, 43, 44, 161, 143, 34, 193, 72,
- 96, 102, 8, 224, 15, 152, 64, 49, 47, 199,
- 130, 34, 180, 64, 240, 55, 228, 186, 223, 51,
- 13, 4, 27, 226, 8, 6, 43, 152, 65, 13,
- 148, 96, 158, 25, 244, 64, 137, 71, 84, 98,
- 232, 85, 92, 122, 211, 125, 80, 1, 8, 72,
- 192, 1, 253, 216, 231, 51, 158, 177, 140, 101,
- 244, 198, 55, 38, 242, 134, 110, 132, 147, 141,
- 221, 24, 99, 27, 231, 192, 134, 135, 14, 181,
- 142, 108, 112, 130, 15, 124, 0, 195, 28, 170,
- 128, 7, 67, 188, 161, 11, 145, 140, 3, 30,
- 192, 112, 235, 66, 128, 114, 14, 62, 85, 67,
- 22, 70, 98, 51, 17, 168, 60, 38, 234, 81,
- 140, 3, 218, 65, 159, 1, 12, 0, 31, 206,
- 31, 64, 124, 164, 191, 209, 2, 49, 50, 12,
- 129, 195, 62, 37, 28, 145, 136, 61, 188, 27,
- 16, 138, 8, 131, 255, 39, 158, 81, 15, 125,
- 29, 128, 4, 60, 144, 129, 160, 32, 240, 139,
- 83, 120, 212, 26, 186, 152, 197, 44, 220, 108,
- 141, 223, 164, 105, 29, 225, 144, 134, 138, 87,
- 1, 11, 224, 16, 103, 25, 240, 176, 0, 50,
- 32, 1, 250, 240, 13, 116, 198, 9, 138, 160,
- 8, 82, 212, 7, 142, 208, 8, 240, 5, 8,
- 91, 16, 77, 31, 147, 7, 123, 48, 8, 63,
- 114, 71, 82, 160, 5, 53, 224, 1, 165, 38,
- 78, 9, 145, 2, 132, 164, 2, 14, 160, 15,
- 247, 80, 15, 234, 0, 0, 254, 244, 30, 239,
- 129, 15, 235, 112, 31, 40, 232, 79, 255, 145,
- 130, 239, 209, 0, 250, 209, 116, 79, 247, 12,
- 173, 0, 45, 216, 112, 94, 21, 32, 76, 52,
- 80, 40, 11, 32, 0, 232, 183, 86, 60, 192,
- 1, 51, 80, 1, 230, 112, 14, 245, 80, 75,
- 7, 80, 41, 188, 113, 14, 117, 98, 87, 236,
- 96, 12, 231, 240, 14, 183, 37, 3, 14, 240,
- 13, 195, 0, 11, 156, 80, 7, 65, 119, 7,
- 107, 16, 134, 80, 81, 43, 90, 48, 29, 86,
- 208, 4, 79, 176, 4, 73, 128, 5, 12, 18,
- 7, 93, 128, 103, 128, 64, 37, 19, 17, 2,
- 48, 241, 106, 246, 48, 15, 220, 48, 85, 221,
- 80, 75, 47, 104, 0, 246, 100, 130, 234, 16,
- 136, 245, 240, 13, 4, 128, 72, 136, 4, 39,
- 249, 244, 30, 167, 16, 80, 173, 160, 39, 204,
- 255, 208, 97, 244, 48, 47, 110, 149, 3, 161,
- 160, 15, 12, 16, 10, 184, 0, 14, 57, 178,
- 87, 6, 240, 40, 240, 209, 0, 9, 160, 27,
- 217, 96, 12, 47, 150, 98, 183, 32, 91, 6,
- 69, 15, 161, 160, 13, 43, 101, 13, 166, 194,
- 9, 127, 80, 6, 185, 242, 7, 209, 81, 95,
- 99, 224, 6, 96, 80, 71, 144, 0, 8, 156,
- 225, 7, 136, 192, 8, 133, 80, 8, 147, 128,
- 7, 98, 160, 62, 88, 210, 1, 36, 32, 15,
- 93, 101, 14, 76, 131, 46, 1, 128, 85, 76,
- 195, 13, 223, 208, 13, 89, 69, 97, 75, 147,
- 135, 243, 16, 46, 223, 130, 94, 250, 212, 14,
- 182, 144, 12, 224, 192, 13, 246, 176, 48, 185,
- 144, 3, 10, 5, 87, 138, 130, 11, 165, 208,
- 14, 216, 192, 15, 158, 8, 131, 254, 228, 135,
- 219, 48, 138, 154, 18, 12, 203, 149, 93, 185,
- 160, 10, 197, 80, 10, 188, 32, 13, 183, 64,
- 10, 159, 240, 9, 155, 112, 9, 88, 96, 95,
- 127, 128, 8, 128, 64, 9, 110, 224, 73, 119,
- 116, 65, 128, 16, 8, 111, 48, 83, 107, 160,
- 6, 110, 16, 7, 87, 176, 16, 43, 0, 19,
- 34, 0, 2, 23, 96, 1, 175, 85, 14, 18,
- 150, 135, 220, 208, 85, 246, 240, 37, 250, 176,
- 85, 252, 208, 85, 14, 176, 24, 60, 160, 2,
- 22, 224, 3, 223, 130, 46, 34, 104, 10, 237,
- 160, 91, 121, 72, 15, 52, 255, 208, 48, 24,
- 66, 40, 111, 149, 3, 137, 165, 44, 166, 32,
- 31, 100, 146, 2, 55, 80, 148, 69, 41, 2,
- 28, 224, 13, 172, 48, 12, 161, 144, 14, 2,
- 80, 121, 199, 149, 14, 197, 80, 76, 202, 192,
- 11, 219, 16, 15, 98, 112, 9, 52, 246, 7,
- 123, 144, 6, 128, 118, 144, 214, 67, 8, 146,
- 240, 103, 41, 227, 7, 147, 0, 90, 110, 96,
- 8, 48, 224, 2, 149, 131, 57, 136, 17, 18,
- 22, 112, 13, 61, 19, 13, 206, 128, 12, 180,
- 208, 11, 218, 160, 52, 218, 224, 12, 229, 80,
- 14, 180, 85, 35, 228, 53, 3, 14, 176, 141,
- 227, 226, 80, 60, 176, 1, 15, 240, 0, 6,
- 96, 10, 221, 32, 15, 238, 98, 33, 199, 53,
- 10, 122, 163, 10, 215, 64, 13, 150, 41, 0,
- 181, 17, 133, 9, 229, 147, 163, 32, 0, 8,
- 48, 12, 152, 2, 144, 116, 0, 1, 57, 73,
- 154, 195, 228, 0, 2, 160, 15, 19, 67, 10,
- 131, 67, 9, 87, 177, 7, 123, 80, 77, 111,
- 224, 8, 144, 144, 7, 53, 101, 8, 124, 48,
- 9, 219, 20, 56, 112, 48, 4, 147, 3, 62,
- 85, 38, 2, 228, 177, 1, 232, 112, 13, 239,
- 48, 151, 64, 227, 51, 209, 208, 12, 209, 0,
- 13, 183, 5, 58, 216, 96, 45, 237, 200, 15,
- 12, 240, 80, 51, 32, 3, 62, 192, 15, 214,
- 34, 15, 13, 83, 121, 90, 83, 12, 202, 53,
- 13, 163, 255, 64, 13, 192, 112, 54, 177, 0,
- 12, 194, 80, 10, 216, 160, 13, 182, 160, 12,
- 189, 208, 13, 221, 192, 13, 202, 176, 12, 176,
- 64, 10, 189, 128, 9, 131, 131, 7, 116, 80,
- 1, 8, 37, 10, 252, 80, 86, 252, 16, 10,
- 159, 192, 11, 46, 197, 49, 114, 0, 8, 135,
- 3, 9, 139, 48, 9, 133, 224, 21, 149, 224,
- 8, 241, 181, 43, 145, 19, 3, 82, 70, 62,
- 118, 103, 51, 55, 115, 96, 59, 3, 13, 203,
- 73, 14, 204, 64, 13, 185, 0, 1, 21, 80,
- 146, 15, 6, 97, 210, 34, 15, 246, 0, 1,
- 175, 48, 13, 215, 144, 12, 168, 0, 14, 185,
- 80, 1, 135, 53, 59, 162, 240, 41, 37, 230,
- 10, 186, 144, 10, 241, 39, 127, 242, 151, 10,
- 62, 186, 10, 165, 184, 11, 255, 120, 9, 128,
- 3, 7, 94, 128, 7, 63, 102, 9, 91, 147,
- 11, 74, 90, 47, 154, 16, 144, 151, 192, 76,
- 110, 224, 5, 199, 115, 61, 132, 80, 8, 136,
- 32, 8, 152, 16, 3, 146, 227, 95, 116, 183,
- 63, 54, 116, 101, 25, 48, 166, 22, 97, 1,
- 239, 0, 13, 208, 64, 13, 2, 88, 1, 211,
- 0, 14, 184, 16, 97, 220, 80, 13, 200, 128,
- 12, 105, 179, 51, 197, 128, 14, 37, 54, 13,
- 197, 128, 13, 216, 80, 12, 211, 96, 14, 206,
- 82, 13, 243, 208, 11, 111, 86, 168, 100, 70,
- 11, 164, 176, 13, 235, 149, 155, 127, 255, 22,
- 8, 123, 144, 7, 32, 115, 7, 58, 86, 65,
- 59, 38, 6, 150, 96, 7, 133, 144, 7, 180,
- 134, 7, 112, 80, 65, 112, 112, 5, 84, 208,
- 95, 47, 99, 63, 228, 150, 16, 54, 180, 2,
- 18, 81, 37, 85, 2, 2, 168, 9, 15, 84,
- 83, 151, 199, 112, 12, 97, 166, 75, 179, 128,
- 12, 182, 80, 53, 180, 101, 15, 163, 144, 14,
- 175, 0, 13, 164, 35, 97, 182, 80, 13, 201,
- 160, 54, 170, 96, 15, 158, 48, 60, 156, 192,
- 154, 142, 17, 43, 84, 10, 50, 138, 195, 8,
- 136, 112, 7, 15, 249, 7, 142, 35, 6, 69,
- 144, 0, 47, 144, 173, 47, 195, 150, 242, 83,
- 170, 252, 83, 62, 15, 33, 17, 89, 166, 62,
- 234, 83, 38, 240, 233, 44, 115, 202, 102, 119,
- 169, 12, 233, 52, 12, 164, 112, 42, 156, 144,
- 172, 115, 195, 7, 196, 120, 5, 35, 196, 1,
- 43, 112, 2, 48, 192, 2, 252, 218, 175, 138,
- 70, 63, 248, 227, 173, 2, 59, 176, 4, 91,
- 176, 4, 203, 16, 146, 118, 101, 20, 113, 17,
- 33, 1, 106, 158, 246, 176, 16, 59, 64, 160,
- 22, 106, 162, 54, 18, 165, 134, 18, 167, 38,
- 67, 95, 106, 176, 43, 23, 166, 169, 58, 2,
- 1, 52, 64, 156, 182, 19, 63, 240, 3, 144,
- 197, 4, 40, 91, 4, 205, 214, 4, 70, 134,
- 7, 213, 70, 7, 89, 16, 179, 8, 52, 179,
- 5, 244, 105, 43, 255, 84, 177, 37, 145, 114,
- 50, 196, 177, 250, 147, 57, 32, 43, 178, 176,
- 166, 2, 8, 196, 4, 103, 17, 5, 98, 225,
- 111, 70, 224, 111, 78, 49, 21, 68, 177, 5,
- 253, 6, 66, 77, 240, 110, 98, 1, 73, 144,
- 116, 22, 70, 112, 22, 88, 80, 4, 105, 241,
- 5, 90, 32, 6, 40, 123, 66, 221, 214, 1,
- 21, 107, 106, 59, 203, 179, 166, 106, 67, 230,
- 70, 64, 177, 22, 4, 74, 80, 4, 75, 48,
- 29, 106, 0, 5, 74, 97, 180, 98, 33, 5,
- 239, 102, 6, 142, 80, 20, 85, 128, 4, 91,
- 176, 5, 96, 144, 7, 2, 39, 36, 154, 4,
- 5, 93, 240, 64, 80, 96, 109, 118, 115, 5,
- 73, 178, 22, 5, 169, 5, 77, 224, 64, 108,
- 224, 6, 95, 192, 77, 77, 192, 4, 63, 176,
- 66, 126, 68, 182, 27, 123, 176, 55, 132, 19,
- 120, 39, 180, 98, 224, 83, 81, 112, 115, 141,
- 32, 21, 72, 128, 4, 73, 161, 180, 78, 27,
- 112, 108, 208, 107, 92, 224, 110, 68, 17, 108,
- 107, 231, 6, 15, 148, 4, 85, 96, 4, 70,
- 112, 4, 99, 128, 187, 75, 112, 5, 85, 208,
- 5, 144, 148, 4, 73, 7, 73, 85, 80, 188,
- 93, 32, 5, 106, 48, 20, 122, 166, 110, 180,
- 198, 4, 98, 155, 185, 41, 112, 124, 222, 122,
- 24, 194, 249, 185, 89, 128, 7, 119, 192, 118,
- 111, 112, 21, 148, 101, 6, 114, 128, 111, 135,
- 255, 192, 6, 83, 176, 113, 107, 80, 9, 248,
- 198, 111, 99, 48, 6, 10, 114, 4, 91, 20,
- 108, 17, 148, 113, 78, 64, 5, 173, 113, 70,
- 103, 52, 14, 244, 171, 70, 9, 114, 32, 174,
- 161, 187, 72, 210, 7, 113, 128, 6, 104, 64,
- 43, 96, 48, 73, 238, 246, 7, 104, 208, 169,
- 67, 102, 114, 37, 224, 1, 115, 183, 185, 61,
- 171, 30, 37, 160, 67, 229, 2, 20, 86, 16,
- 124, 94, 144, 7, 144, 192, 189, 107, 144, 8,
- 149, 112, 8, 149, 192, 8, 131, 144, 111, 108,
- 96, 6, 128, 203, 73, 129, 48, 6, 117, 224,
- 26, 96, 68, 5, 44, 76, 4, 86, 247, 194,
- 48, 252, 194, 99, 148, 117, 49, 44, 14, 117,
- 144, 111, 61, 5, 6, 119, 176, 103, 115, 16,
- 7, 113, 96, 5, 70, 98, 109, 122, 6, 6,
- 85, 112, 5, 62, 208, 66, 11, 108, 124, 14,
- 76, 24, 135, 65, 78, 7, 36, 6, 192, 71,
- 192, 115, 16, 6, 99, 192, 83, 101, 112, 61,
- 140, 176, 189, 141, 240, 115, 69, 81, 77, 131,
- 208, 70, 91, 64, 108, 235, 187, 116, 17, 96,
- 3, 253, 96, 74, 185, 49, 117, 193, 33, 122,
- 187, 49, 28, 190, 84, 28, 217, 176, 14, 90,
- 53, 15, 221, 224, 117, 23, 7, 23, 103, 145,
- 83, 108, 24, 8, 141, 16, 8, 112, 145, 29,
- 121, 224, 21, 4, 231, 4, 71, 140, 17, 40,
- 231, 129, 53, 132, 24, 138, 255, 193, 24, 129,
- 128, 6, 74, 49, 145, 78, 97, 5, 129, 144,
- 6, 101, 240, 35, 108, 48, 145, 27, 51, 9,
- 147, 16, 8, 114, 192, 120, 73, 116, 8, 17,
- 57, 6, 96, 212, 116, 54, 160, 0, 168, 137,
- 121, 155, 39, 80, 191, 241, 121, 167, 247, 27,
- 193, 225, 198, 190, 116, 28, 231, 32, 15, 163,
- 128, 0, 252, 48, 12, 174, 71, 164, 111, 52,
- 29, 93, 224, 6, 129, 128, 8, 104, 144, 129,
- 106, 224, 5, 177, 82, 6, 52, 23, 7, 101,
- 0, 6, 69, 96, 200, 40, 39, 189, 167, 101,
- 44, 120, 247, 0, 0, 224, 14, 158, 224, 4,
- 78, 16, 113, 90, 0, 7, 101, 208, 5, 81,
- 160, 8, 131, 176, 6, 94, 225, 20, 112, 116,
- 160, 187, 6, 6, 15, 105, 129, 207, 100, 69,
- 238, 16, 1, 19, 160, 1, 60, 112, 33, 11,
- 96, 15, 103, 76, 31, 129, 184, 14, 190, 81,
- 127, 225, 176, 14, 250, 188, 14, 219, 96, 13,
- 253, 39, 28, 222, 16, 14, 230, 144, 14, 52,
- 80, 1, 234, 194, 9, 172, 224, 9, 134, 176,
- 71, 124, 16, 56, 16, 84, 7, 99, 48, 7,
- 121, 148, 21, 140, 80, 9, 134, 16, 43, 122,
- 160, 6, 222, 68, 124, 30, 16, 189, 52, 113,
- 24, 30, 96, 64, 10, 80, 15, 206, 135, 31,
- 80, 151, 0, 226, 64, 4, 6, 66, 4, 117,
- 16, 7, 197, 107, 206, 243, 118, 6, 108, 192,
- 6, 135, 255, 144, 8, 246, 21, 8, 125, 128,
- 194, 164, 116, 15, 253, 81, 3, 233, 183, 74,
- 242, 12, 117, 234, 224, 143, 32, 85, 127, 43,
- 34, 38, 249, 231, 102, 181, 16, 82, 110, 252,
- 13, 145, 40, 3, 2, 192, 152, 164, 136, 128,
- 61, 124, 36, 103, 16, 8, 124, 208, 5, 125,
- 112, 181, 104, 240, 8, 179, 34, 204, 118, 209,
- 5, 214, 166, 4, 5, 166, 196, 167, 245, 1,
- 35, 96, 64, 191, 64, 136, 239, 65, 31, 25,
- 181, 130, 3, 128, 130, 241, 209, 0, 27, 197,
- 116, 141, 132, 5, 115, 68, 111, 83, 16, 5,
- 110, 160, 8, 84, 224, 14, 195, 96, 10, 140,
- 226, 211, 63, 141, 53, 250, 160, 31, 245, 160,
- 12, 96, 70, 102, 66, 250, 27, 40, 162, 34,
- 210, 160, 11, 181, 16, 14, 74, 72, 0, 237,
- 16, 208, 1, 184, 0, 21, 240, 0, 119, 98,
- 12, 61, 226, 35, 145, 27, 95, 224, 252, 7,
- 101, 23, 6, 87, 32, 5, 101, 112, 56, 56,
- 214, 5, 115, 144, 21, 95, 192, 7, 59, 112,
- 177, 206, 76, 16, 136, 97, 64, 5, 184, 78,
- 51, 232, 14, 234, 224, 30, 238, 208, 130, 248,
- 48, 215, 28, 96, 3, 24, 161, 1, 28, 16,
- 31, 5, 98, 125, 140, 52, 126, 4, 245, 11,
- 230, 4, 86, 50, 48, 40, 56, 242, 0, 8,
- 240, 10, 50, 128, 1, 19, 64, 15, 184, 144,
- 12, 210, 112, 14, 180, 148, 34, 252, 255, 28,
- 14, 223, 64, 48, 54, 160, 1, 253, 176, 14,
- 234, 112, 167, 16, 48, 76, 247, 112, 10, 92,
- 88, 7, 190, 2, 68, 198, 187, 21, 61, 213,
- 70, 86, 0, 5, 112, 80, 134, 77, 144, 113,
- 87, 240, 4, 115, 176, 36, 59, 80, 17, 30,
- 157, 16, 235, 81, 78, 231, 180, 38, 236, 180,
- 31, 48, 104, 130, 248, 224, 130, 240, 8, 31,
- 42, 152, 136, 52, 152, 0, 250, 161, 14, 220,
- 160, 13, 211, 64, 15, 41, 250, 220, 63, 152,
- 3, 16, 192, 0, 62, 48, 81, 221, 194, 3,
- 97, 165, 15, 220, 224, 221, 148, 50, 122, 219,
- 160, 14, 189, 176, 13, 221, 85, 11, 202, 112,
- 156, 232, 0, 58, 140, 201, 82, 156, 112, 9,
- 118, 241, 7, 107, 96, 6, 97, 152, 7, 122,
- 38, 214, 88, 155, 4, 70, 176, 4, 113, 16,
- 116, 110, 144, 7, 142, 240, 6, 124, 96, 18,
- 230, 1, 19, 35, 160, 19, 14, 128, 135, 232,
- 4, 75, 244, 180, 206, 145, 162, 224, 243, 68,
- 0, 250, 96, 79, 138, 24, 15, 253, 112, 79,
- 137, 248, 12, 238, 240, 12, 202, 160, 13, 215,
- 240, 10, 244, 16, 137, 24, 114, 33, 57, 176,
- 0, 137, 169, 0, 161, 192, 167, 252, 32, 92,
- 113, 110, 38, 0, 64, 32, 184, 145, 13, 189,
- 225, 11, 172, 240, 102, 206, 96, 82, 232, 208,
- 153, 42, 117, 11, 198, 192, 133, 138, 160, 7,
- 96, 0, 7, 132, 255, 16, 8, 87, 16, 204,
- 93, 192, 6, 112, 49, 73, 135, 115, 99, 129,
- 224, 113, 136, 99, 8, 196, 104, 140, 9, 145,
- 37, 224, 176, 15, 251, 16, 0, 1, 160, 15,
- 245, 176, 14, 236, 224, 14, 54, 48, 39, 133,
- 24, 136, 231, 160, 14, 212, 216, 14, 220, 80,
- 39, 223, 192, 211, 60, 125, 0, 112, 114, 15,
- 235, 208, 11, 201, 208, 12, 204, 48, 13, 79,
- 9, 40, 59, 73, 40, 163, 240, 0, 248, 50,
- 13, 184, 32, 33, 142, 162, 130, 254, 212, 0,
- 162, 72, 138, 171, 224, 102, 201, 80, 12, 174,
- 106, 230, 154, 192, 138, 166, 2, 11, 255, 216,
- 7, 253, 237, 5, 251, 149, 29, 123, 22, 114,
- 253, 29, 71, 215, 211, 6, 212, 100, 71, 118,
- 113, 5, 225, 138, 37, 58, 241, 90, 93, 98,
- 14, 242, 224, 0, 1, 32, 141, 141, 82, 128,
- 136, 52, 141, 108, 34, 146, 237, 240, 13, 235,
- 242, 11, 14, 69, 157, 140, 242, 12, 231, 128,
- 12, 201, 160, 10, 230, 16, 81, 134, 21, 40,
- 147, 152, 14, 33, 6, 10, 184, 240, 13, 150,
- 152, 121, 254, 225, 79, 28, 80, 38, 234, 208,
- 207, 153, 178, 10, 199, 240, 136, 206, 158, 11,
- 211, 160, 10, 184, 240, 54, 245, 217, 11, 189,
- 192, 154, 253, 157, 60, 1, 156, 204, 122, 6,
- 192, 101, 32, 114, 68, 124, 95, 131, 48, 233,
- 86, 112, 145, 14, 81, 135, 2, 52, 91, 80,
- 255, 197, 140, 217, 168, 157, 158, 142, 85, 245,
- 62, 239, 209, 114, 45, 213, 194, 15, 98, 53,
- 152, 12, 208, 15, 166, 128, 13, 99, 206, 140,
- 216, 176, 86, 243, 178, 225, 133, 146, 11, 153,
- 80, 10, 165, 144, 137, 191, 48, 41, 40, 104,
- 3, 146, 98, 0, 12, 64, 0, 173, 151, 13,
- 154, 34, 12, 224, 249, 10, 245, 146, 9, 163,
- 176, 241, 189, 32, 13, 176, 96, 10, 116, 32,
- 144, 152, 48, 7, 124, 220, 8, 67, 196, 120,
- 120, 230, 6, 70, 80, 5, 105, 240, 89, 140,
- 208, 199, 128, 96, 8, 201, 68, 63, 116, 152,
- 16, 56, 209, 1, 14, 48, 91, 233, 110, 14,
- 90, 85, 85, 209, 89, 45, 109, 194, 52, 61,
- 143, 46, 14, 208, 47, 20, 101, 202, 246, 128,
- 0, 8, 160, 0, 191, 208, 13, 237, 88, 225,
- 193, 164, 147, 147, 184, 244, 197, 128, 11, 47,
- 26, 148, 192, 205, 1, 26, 96, 51, 38, 192,
- 1, 238, 48, 138, 173, 144, 55, 161, 16, 137,
- 135, 21, 42, 195, 176, 12, 243, 233, 9, 253,
- 144, 5, 224, 165, 49, 129, 64, 89, 193, 168,
- 155, 41, 163, 155, 136, 19, 140, 143, 224, 8,
- 122, 32, 90, 66, 192, 173, 48, 145, 2, 25,
- 209, 1, 246, 208, 151, 206, 80, 13, 207, 18,
- 45, 242, 0, 15, 242, 224, 233, 242, 176, 15,
- 210, 226, 37, 218, 34, 3, 97, 181, 1, 219,
- 56, 152, 59, 113, 15, 255, 255, 201, 15, 121,
- 216, 46, 239, 194, 225, 146, 8, 132, 161, 160,
- 9, 197, 176, 33, 47, 210, 3, 69, 217, 3,
- 30, 112, 3, 31, 160, 3, 28, 224, 9, 7,
- 243, 11, 162, 240, 148, 12, 3, 1, 136, 133,
- 13, 234, 48, 49, 203, 0, 16, 167, 174, 24,
- 122, 20, 167, 140, 25, 51, 82, 180, 228, 249,
- 51, 73, 16, 33, 66, 139, 238, 220, 241, 131,
- 72, 210, 34, 69, 113, 176, 188, 112, 1, 3,
- 69, 1, 144, 33, 69, 134, 16, 1, 2, 196,
- 5, 122, 240, 162, 149, 171, 166, 140, 22, 173,
- 106, 230, 180, 105, 195, 5, 206, 38, 184, 105,
- 244, 36, 200, 152, 49, 67, 133, 143, 7, 12,
- 248, 41, 80, 208, 66, 197, 15, 125, 10, 30,
- 252, 234, 246, 75, 6, 79, 8, 16, 70, 165,
- 27, 5, 33, 29, 58, 106, 89, 237, 153, 234,
- 103, 128, 43, 132, 92, 185, 94, 137, 18, 245,
- 42, 199, 43, 94, 198, 54, 137, 17, 5, 65,
- 6, 14, 184, 244, 66, 1, 177, 119, 239, 25,
- 47, 82, 151, 2, 41, 234, 99, 6, 208, 27,
- 64, 128, 204, 232, 41, 148, 199, 144, 33, 76,
- 98, 4, 49, 98, 244, 231, 15, 31, 44, 49,
- 56, 162, 248, 40, 210, 114, 1, 146, 37, 76,
- 34, 184, 70, 14, 92, 180, 104, 206, 170, 85,
- 227, 86, 206, 28, 54, 112, 229, 202, 129, 131,
- 71, 79, 167, 0, 7, 10, 134, 18, 13, 170,
- 162, 133, 255, 133, 26, 250, 190, 181, 179, 199,
- 83, 2, 13, 169, 162, 138, 161, 83, 5, 45,
- 43, 180, 98, 14, 226, 245, 211, 247, 75, 159,
- 61, 171, 163, 94, 77, 211, 183, 141, 21, 172,
- 86, 152, 240, 136, 2, 238, 91, 128, 130, 80,
- 252, 134, 145, 34, 133, 105, 18, 163, 70, 122,
- 242, 228, 41, 212, 200, 81, 35, 70, 128, 212,
- 252, 9, 164, 87, 207, 29, 52, 127, 34, 79,
- 174, 124, 217, 114, 136, 20, 70, 40, 161, 132,
- 11, 138, 185, 230, 64, 112, 200, 33, 231, 154,
- 104, 22, 76, 173, 65, 116, 22, 88, 32, 29,
- 123, 230, 249, 133, 31, 126, 24, 8, 74, 129,
- 25, 100, 216, 128, 1, 125, 184, 153, 39, 29,
- 28, 128, 136, 110, 20, 81, 208, 41, 230, 21,
- 106, 128, 113, 17, 152, 102, 126, 233, 231, 23,
- 109, 146, 233, 101, 25, 110, 166, 81, 165, 154,
- 101, 140, 97, 165, 60, 76, 2, 193, 131, 14,
- 8, 42, 128, 205, 30, 123, 176, 249, 229, 151,
- 94, 202, 35, 228, 14, 51, 222, 152, 195, 141,
- 71, 26, 129, 164, 145, 66, 222, 176, 34, 14,
- 55, 12, 9, 4, 144, 59, 180, 24, 199, 31,
- 254, 252, 51, 19, 133, 21, 76, 16, 176, 132,
- 13, 138, 97, 230, 192, 206, 82, 43, 39, 26,
- 104, 160, 185, 38, 194, 5, 16, 144, 103, 31,
- 115, 230, 153, 39, 67, 6, 20, 224, 65, 6,
- 5, 146, 44, 71, 158, 81, 74, 132, 255, 224,
- 149, 87, 138, 41, 38, 157, 105, 224, 161, 134,
- 24, 89, 100, 137, 229, 210, 96, 154, 81, 165,
- 20, 91, 122, 233, 165, 27, 79, 151, 225, 165,
- 151, 77, 54, 185, 196, 13, 53, 178, 8, 165,
- 152, 80, 70, 9, 197, 30, 81, 94, 45, 133,
- 150, 77, 222, 72, 227, 15, 64, 16, 41, 4,
- 146, 66, 38, 161, 228, 145, 52, 252, 184, 146,
- 145, 60, 248, 24, 83, 50, 143, 250, 51, 211,
- 63, 20, 62, 80, 115, 132, 17, 64, 160, 7,
- 29, 102, 222, 164, 19, 26, 5, 175, 121, 101,
- 129, 10, 16, 72, 82, 38, 63, 255, 180, 167,
- 2, 28, 70, 153, 230, 154, 100, 80, 17, 5,
- 135, 10, 114, 72, 167, 24, 215, 28, 197, 230,
- 154, 96, 102, 209, 101, 150, 89, 42, 149, 5,
- 95, 87, 92, 161, 229, 22, 128, 97, 129, 133,
- 20, 83, 13, 81, 163, 11, 49, 50, 25, 101,
- 97, 233, 194, 178, 196, 146, 82, 62, 193, 164,
- 143, 51, 250, 8, 228, 143, 66, 22, 209, 24,
- 145, 73, 38, 89, 68, 144, 57, 98, 240, 71,
- 50, 22, 40, 91, 246, 228, 144, 154, 21, 193,
- 3, 104, 61, 176, 96, 148, 106, 235, 132, 134,
- 153, 8, 139, 180, 71, 30, 108, 100, 154, 137,
- 27, 115, 204, 1, 103, 148, 92, 222, 97, 176,
- 25, 112, 210, 161, 39, 157, 116, 66, 17, 69,
- 149, 80, 176, 193, 5, 23, 100, 118, 169, 165,
- 150, 84, 170, 174, 255, 186, 150, 85, 86, 97,
- 133, 149, 85, 106, 185, 165, 19, 83, 231, 48,
- 36, 141, 52, 196, 136, 228, 236, 72, 70, 121,
- 248, 225, 92, 52, 249, 228, 19, 67, 230, 184,
- 34, 9, 40, 218, 184, 99, 17, 136, 238, 48,
- 164, 142, 145, 145, 53, 25, 101, 192, 65, 66,
- 1, 64, 19, 60, 48, 220, 131, 22, 232, 169,
- 150, 230, 5, 220, 170, 96, 26, 112, 156, 113,
- 70, 27, 153, 170, 65, 38, 152, 114, 138, 161,
- 230, 154, 81, 174, 41, 7, 23, 10, 229, 145,
- 171, 20, 92, 156, 225, 166, 20, 109, 110, 169,
- 101, 151, 172, 91, 159, 218, 107, 88, 190, 238,
- 4, 19, 74, 2, 9, 36, 141, 245, 242, 128,
- 227, 236, 221, 31, 54, 219, 146, 63, 212, 16,
- 131, 9, 60, 224, 128, 195, 11, 65, 38, 185,
- 3, 143, 33, 98, 144, 236, 133, 146, 255, 14,
- 124, 122, 193, 1, 20, 193, 4, 236, 77, 200,
- 64, 1, 205, 115, 129, 64, 2, 4, 166, 145,
- 71, 103, 203, 145, 57, 230, 24, 87, 130, 137,
- 230, 209, 98, 74, 49, 71, 20, 20, 53, 153,
- 6, 27, 110, 90, 89, 230, 156, 94, 98, 191,
- 197, 26, 99, 72, 225, 69, 25, 82, 136, 195,
- 19, 156, 240, 196, 28, 212, 112, 7, 66, 180,
- 193, 15, 234, 201, 131, 31, 10, 193, 7, 59,
- 192, 193, 14, 118, 160, 195, 217, 4, 129, 183,
- 50, 116, 161, 12, 248, 249, 2, 21, 156, 247,
- 255, 2, 142, 36, 75, 89, 212, 35, 97, 245,
- 86, 144, 130, 235, 101, 207, 4, 37, 80, 193,
- 12, 232, 49, 13, 92, 168, 166, 70, 193, 56,
- 134, 189, 116, 161, 11, 87, 52, 163, 38, 224,
- 192, 134, 210, 80, 100, 52, 92, 104, 3, 25,
- 203, 216, 134, 167, 180, 17, 141, 106, 21, 195,
- 20, 167, 128, 5, 43, 124, 17, 6, 60, 104,
- 1, 12, 106, 64, 67, 33, 172, 248, 136, 65,
- 252, 161, 13, 118, 104, 3, 28, 240, 224, 24,
- 47, 108, 209, 14, 87, 24, 2, 8, 65, 216,
- 145, 19, 80, 102, 132, 37, 100, 163, 72, 6,
- 119, 194, 20, 154, 64, 4, 115, 92, 33, 3,
- 176, 225, 140, 100, 152, 79, 23, 187, 216, 133,
- 213, 110, 152, 62, 97, 36, 35, 25, 194, 24,
- 90, 75, 104, 129, 175, 89, 184, 2, 28, 161,
- 248, 133, 47, 124, 193, 138, 75, 240, 97, 14,
- 95, 248, 2, 26, 208, 224, 5, 4, 34, 34,
- 15, 140, 128, 196, 36, 16, 241, 135, 57, 204,
- 1, 11, 68, 112, 129, 25, 93, 224, 2, 22,
- 164, 81, 141, 109, 100, 101, 224, 40, 19, 130,
- 21, 124, 0, 133, 115, 164, 101, 45, 15, 80,
- 15, 252, 29, 50, 95, 250, 146, 197, 49, 164,
- 113, 195, 170, 173, 2, 59, 195, 88, 135, 19,
- 183, 198, 9, 78, 24, 226, 15, 183, 242, 131,
- 32, 208, 128, 8, 63, 252, 225, 10, 88, 16,
- 2, 11, 78, 121, 77, 22, 79, 176, 0, 6,
- 170, 84, 227, 26, 91, 249, 77, 192, 169, 49,
- 4, 176, 148, 229, 44, 231, 152, 2, 116, 166,
- 51, 5, 31, 88, 193, 10, 198, 25, 130, 110,
- 198, 83, 158, 40, 56, 1, 12, 236, 121, 79,
- 124, 158, 128, 155, 241, 4, 103, 63, 253, 153,
- 50, 113, 190, 51, 150, 229, 68, 39, 59, 219,
- 121, 80, 132, 38, 244, 160, 239, 100, 232, 56,
- 249, 249, 207, 233, 5, 4, 0, 59 };
diff --git a/main/main.c b/main/main.c
deleted file mode 100644
index 94e8d8df12..0000000000
--- a/main/main.c
+++ /dev/null
@@ -1,1874 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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
- */
-
-#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
-
-#include <stdio.h>
-#include "php.h"
-#ifdef PHP_WIN32
-#include "win32/time.h"
-#include "win32/signal.h"
-#include <process.h>
-#elif defined(NETWARE)
-#ifdef NEW_LIBC
-#include <sys/timeval.h>
-#else
-#include "netware/time_nw.h"
-#endif
-/*#include "netware/signal_nw.h"*/
-/*#include "netware/env.h"*/ /* Temporary */
-/*#include <process.h>*/
-#ifdef USE_WINSOCK
-#include <novsock2.h>
-#endif
-#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 "zend_ini.h"
-
-#include "php_content_types.h"
-#include "php_ticks.h"
-#include "php_logos.h"
-#include "php_streams.h"
-
-#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING)
-#include "ext/mbstring/mbstring.h"
-#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */
-
-#include "SAPI.h"
-#include "rfc1867.h"
-/* }}} */
-
-#ifndef ZTS
-php_core_globals core_globals;
-#else
-PHPAPI int core_globals_id;
-#endif
-
-#define ERROR_BUF_LEN 1024
-
-typedef struct {
- char buf[ERROR_BUF_LEN];
- char filename[ERROR_BUF_LEN];
- uint lineno;
-} last_error_type;
-
-static last_error_type last_error;
-
-static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC);
-
-
-static char *short_track_vars_names[] = {
- "_POST",
- "_GET",
- "_COOKIE",
- "_SERVER",
- "_ENV",
- "_FILES",
- NULL
-};
-
-static int short_track_vars_names_length[] = {
- sizeof("_POST"),
- sizeof("_GET"),
- sizeof("_COOKIE"),
- sizeof("_SERVER"),
- sizeof("_ENV"),
- sizeof("_FILES")
-};
-
-#define NUM_TRACK_VARS (sizeof(short_track_vars_names_length)/sizeof(int))
-
-
-#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_disable_functions
- */
-static void php_disable_functions(TSRMLS_D)
-{
- char *s = NULL;
- char *e = INI_STR("disable_functions");
- char p;
-
- if (!*e) {
- return;
- }
-
- while (*e) {
- switch (*e) {
- case ' ':
- case ',':
- if (s) {
- p = *e;
- *e = '\0';
- zend_disable_function(s, e-s TSRMLS_CC);
- *e = p;
- s = NULL;
- }
- break;
- default:
- if (!s) {
- s = e;
- }
- break;
- }
- e++;
- }
- if (s) {
- zend_disable_function(s, e-s TSRMLS_CC);
- }
-}
-/* }}} */
-
-/* {{{ 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_ENTRY("docref_root", "http://www.php.net/", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("docref_ext", "", PHP_INI_ALL, OnUpdateString, docref_ext, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("html_errors", "1", PHP_INI_ALL, 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_ENTRY("max_input_time", "-1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateInt, max_input_time, 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_ALL, 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_ENTRY("log_errors_max_len", "1024", PHP_INI_ALL, OnUpdateInt, log_errors_max_len, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("ignore_repeated_errors", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_errors, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("ignore_repeated_source", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_source, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("report_memleaks", "1", PHP_INI_ALL, OnUpdateBool, report_memleaks, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("report_zend_debug", "1", PHP_INI_ALL, OnUpdateBool, report_zend_debug, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("magic_quotes_gpc", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, 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_ENTRY("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateInt, 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_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("register_globals", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_globals, php_core_globals, core_globals)
-#if PHP_SAFE_MODE
- STD_PHP_INI_BOOLEAN("safe_mode", "1", PHP_INI_SYSTEM, OnUpdateBool, safe_mode, php_core_globals, core_globals)
-#else
- STD_PHP_INI_BOOLEAN("safe_mode", "0", PHP_INI_SYSTEM, OnUpdateBool, safe_mode, php_core_globals, core_globals)
-#endif
- 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", "1", PHP_INI_ALL, OnUpdateBool, y2k_compliance, php_core_globals, core_globals)
-
- STD_PHP_INI_ENTRY("unserialize_callback_func", NULL, PHP_INI_ALL, OnUpdateString, unserialize_callback_func, 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_SYSTEM|PHP_INI_PERDIR, OnUpdateString, auto_append_file, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, 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, OnUpdateString, open_basedir, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("safe_mode_exec_dir", "", PHP_INI_SYSTEM, OnUpdateString, safe_mode_exec_dir, php_core_globals, core_globals)
-
- STD_PHP_INI_BOOLEAN("file_uploads", "1", PHP_INI_SYSTEM, OnUpdateBool, file_uploads, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("upload_max_filesize", "2M", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateInt, upload_max_filesize, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("post_max_size", "8M", PHP_INI_SYSTEM|PHP_INI_PERDIR, 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, OnUpdateString, 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, OnUpdateString, error_append_string, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("error_prepend_string", NULL, PHP_INI_ALL, OnUpdateString, error_prepend_string, php_core_globals, core_globals)
-
- PHP_INI_ENTRY("SMTP", "localhost",PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("smtp_port", "25", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("browscap", NULL, PHP_INI_SYSTEM, NULL)
-#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("mail_force_extra_parameters",NULL, PHP_INI_SYSTEM, NULL)
- PHP_INI_ENTRY("disable_functions", "", PHP_INI_SYSTEM, NULL)
-
- STD_PHP_INI_BOOLEAN("allow_url_fopen", "1", PHP_INI_ALL, OnUpdateBool, allow_url_fopen, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("always_populate_raw_post_data", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, 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, sizeof(error_time_str), "%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);
- }
-}
-/* }}} */
-
-/* {{{ 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;
- int size;
- TSRMLS_FETCH();
-
- va_start(args, format);
- size = vspprintf(&buffer, 0, format, args);
- if (buffer) {
- ret = PHPWRITE(buffer, size);
- efree(buffer);
- } else {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Out of memory");
- ret = 0;
- }
- va_end(args);
-
- return ret;
-}
-/* }}} */
-
-/* {{{ php_verror */
-/* php_verror is called from php_error_docref<n> functions.
- * Its purpose is to unify error messages and automatically generate clickable
- * html error messages if correcponding ini setting (html_errors) is activated.
- * See: CODING_STANDARDS for details.
- */
-PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC)
-{
- char *buffer = NULL, *docref_buf = NULL, *ref = NULL, *target = NULL;
- char *docref_target = "", *docref_root = "";
- char *function, *p;
- int buffer_len = 0;
-
- buffer_len = vspprintf(&buffer, 0, format, args);
- if (buffer) {
- if (docref && docref[0] == '#') {
- docref_target = strchr(docref, '#');
- docref = NULL;
- }
- if (!docref) {
- function = get_active_function_name(TSRMLS_C);
- if (function) {
- spprintf(&docref_buf, 0, "function.%s", function);
- if (docref_buf) {
- while((p=strchr(docref_buf, '_'))!=NULL) *p = '-';
- docref = docref_buf;
- }
- }
- }
- if (docref) {
- if (strncmp(docref, "http://", 7)) {
- docref_root = PG(docref_root);
- /* now check copy of extension */
- ref = estrdup(docref);
- if (ref) {
- if (docref_buf) {
- efree(docref_buf);
- }
- docref_buf = ref;
- docref = docref_buf;
- p = strrchr(ref, '#');
- if (p) {
- target = estrdup(p);
- if (target) {
- docref_target = target;
- *p = '\0';
- }
- }
- if ((!p || target) && PG(docref_ext) && strlen(PG(docref_ext))) {
- spprintf(&docref_buf, 0, "%s%s", ref, PG(docref_ext));
- if (docref_buf) {
- efree(ref);
- docref = docref_buf;
- }
- }
- }
- }
- if (PG(html_errors)) {
- php_error(type, "%s(%s) [<a href='%s%s%s'>%s</a>]: %s", get_active_function_name(TSRMLS_C), params, docref_root, docref, docref_target, docref, buffer);
- } else {
- php_error(type, "%s(%s) [%s%s%s]: %s", get_active_function_name(TSRMLS_C), params, docref_root, docref, docref_target, buffer);
- }
- if (target) {
- efree(target);
- }
- } else {
- docref = get_active_function_name(TSRMLS_C);
- if (!docref)
- docref = "Unknown";
- php_error(type, "%s(%s): %s", docref, params, buffer);
- }
-
- if (PG(track_errors) && EG(active_symbol_table)) {
- zval *tmp;
- ALLOC_ZVAL(tmp);
- INIT_PZVAL(tmp);
- Z_STRVAL_P(tmp) = (char *) estrndup(buffer, buffer_len);
- Z_STRLEN_P(tmp) = buffer_len;
- Z_TYPE_P(tmp) = IS_STRING;
- zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(pval *), NULL);
- }
- efree(buffer);
- if (docref_buf) {
- efree(docref_buf);
- }
- } else {
- php_error(E_ERROR, "%s(%s): Out of memory", get_active_function_name(TSRMLS_C), params);
- }
-}
-/* }}} */
-
-/* {{{ php_error_docref */
-/* See: CODING_STANDARDS for details. */
-PHPAPI void php_error_docref(const char *docref TSRMLS_DC, int type, const char *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- php_verror(docref, "", type, format, args TSRMLS_CC);
- va_end(args);
-}
-/* }}} */
-
-/* {{{ php_error_docref1 */
-/* See: CODING_STANDARDS for details. */
-PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- php_verror(docref, param1, type, format, args TSRMLS_CC);
- va_end(args);
-}
-/* }}} */
-
-/* {{{ php_error_docref2 */
-/* See: CODING_STANDARDS for details. */
-PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...)
-{
- char *params;
- va_list args;
-
- spprintf(&params, 0, "%s,%s", param1, param2);
- va_start(args, format);
- php_verror(docref, params ? params : "...", type, format, args TSRMLS_CC);
- va_end(args);
- if (params)
- efree(params);
-}
-/* }}} */
-
-/* {{{ php_html_puts */
-PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
-{
- zend_html_puts(str, size TSRMLS_CC);
-}
-/* }}} */
-
-/* {{{ 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;
- int buffer_len, display;
- TSRMLS_FETCH();
-
- buffer_len = vspprintf(&buffer, PG(log_errors_max_len), format, args);
- if (PG(ignore_repeated_errors)) {
- if (strncmp(last_error.buf, buffer, sizeof(last_error.buf))
- || (!PG(ignore_repeated_source)
- && ((last_error.lineno != error_lineno)
- || strncmp(last_error.filename, error_filename, sizeof(last_error.filename))))) {
- display = 1;
- } else {
- display = 0;
- }
- } else {
- display = 1;
- }
- strlcpy(last_error.buf, buffer, sizeof(last_error.buf));
- strlcpy(last_error.filename, error_filename, sizeof(last_error.filename));
- last_error.lineno = error_lineno;
-
- /* display/log the error if necessary */
- if (display && (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:
- 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;
-
-#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
- spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno);
- php_log_err(log_buffer TSRMLS_CC);
- efree(log_buffer);
- }
- 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(ERROR_BUF_LEN);
- snprintf(error_format, ERROR_BUF_LEN-1, "<?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
- if (PG(report_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();
- efree(buffer);
- return;
- }
- break;
- }
-
- /* Log if necessary */
- if (!display) {
- efree(buffer);
- return;
- }
- if (PG(track_errors) && EG(active_symbol_table)) {
- pval *tmp;
-
- ALLOC_ZVAL(tmp);
- INIT_PZVAL(tmp);
- Z_STRVAL_P(tmp) = (char *) estrndup(buffer, buffer_len);
- Z_STRLEN_P(tmp) = buffer_len;
- Z_TYPE_P(tmp) = IS_STRING;
- zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(pval *), NULL);
- }
- efree(buffer);
-}
-/* }}} */
-
-/* {{{ proto bool 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_docref(NULL TSRMLS_CC, 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_string_ex(new_timeout);
- if (zend_alter_ini_entry("max_execution_time", sizeof("max_execution_time"), Z_STRVAL_PP(new_timeout), Z_STRLEN_PP(new_timeout), PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == SUCCESS) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ php_fopen_wrapper_for_zend
- */
-static FILE *php_fopen_wrapper_for_zend(const char *filename, char **opened_path)
-{
- TSRMLS_FETCH();
-
- return php_stream_open_wrapper_as_file((char *)filename, "rb", ENFORCE_SAFE_MODE|USE_PATH|IGNORE_URL_WIN|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE, opened_path);
-}
-/* }}} */
-
-static void stream_closer_for_zend(void *handle TSRMLS_DC)
-{
- php_stream_close((php_stream*)handle);
-}
-
-static int php_stream_open_for_zend(const char *filename, zend_file_handle *handle TSRMLS_DC)
-{
- php_stream *stream;
-
- stream = php_stream_open_wrapper((char *)filename, "rb", ENFORCE_SAFE_MODE|USE_PATH|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE, &handle->opened_path);
-
- if (stream) {
- handle->type = ZEND_HANDLE_STREAM;
- handle->filename = (char*)filename;
- handle->free_filename = 0;
- handle->handle.stream.handle = stream;
- handle->handle.stream.reader = (zend_stream_reader_t)_php_stream_read;
- handle->handle.stream.closer = stream_closer_for_zend;
- handle->handle.stream.interactive = 0;
-
- return SUCCESS;
- }
- return FAILURE;
-}
-
-
-/* {{{ 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_docref("function.include" TSRMLS_CC, 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_docref("function.require" TSRMLS_CC, 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: {
- TSRMLS_FETCH();
-
- php_error_docref(NULL TSRMLS_CC, 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) && PG(report_memleaks)) {
-#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;
- }
-}
-/* }}} */
-
-
-void php_on_timeout(int seconds TSRMLS_DC)
-{
- PG(connection_status) |= PHP_CONNECTION_TIMEOUT;
-}
-
-#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_start_sapi()
- */
-static int php_start_sapi(TSRMLS_D)
-{
- int retval = SUCCESS;
-
- if(!SG(sapi_started)) {
- zend_try {
- PG(during_request_startup) = 1;
-
- /* initialize global variables */
- PG(modules_activated) = 0;
- PG(header_is_being_sent) = 0;
- PG(connection_status) = PHP_CONNECTION_NORMAL;
-
- zend_activate(TSRMLS_C);
- zend_set_timeout(EG(timeout_seconds));
- zend_activate_modules(TSRMLS_C);
- PG(modules_activated)=1;
- } zend_catch {
- retval = FAILURE;
- } zend_end_try();
-
- SG(sapi_started) = 1;
- }
- return retval;
-}
-
-/* }}} */
-
-/* {{{ php_request_startup
- */
- #ifndef APACHE_HOOKS
-int php_request_startup(TSRMLS_D)
-{
- int retval = SUCCESS;
-
-#ifdef PHP_WIN32
- CoInitialize(NULL);
-#endif
-
-#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);
-
- if (PG(max_input_time) == -1) {
- zend_set_timeout(EG(timeout_seconds));
- } else {
- zend_set_timeout(PG(max_input_time));
- }
-
- 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]) {
- php_start_ob_buffer_named(PG(output_handler), 0, 1 TSRMLS_CC);
- } else if (PG(output_buffering)) {
- if (PG(output_buffering)>1) {
- php_start_ob_buffer(NULL, PG(output_buffering), 0 TSRMLS_CC);
- } else {
- php_start_ob_buffer(NULL, 0, 1 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;
-}
-# else
-int php_request_startup(TSRMLS_D)
-{
- int retval = SUCCESS;
-
-#if PHP_SIGCHILD
- signal(SIGCHLD, sigchld_handler);
-#endif
-
- if (php_start_sapi() == FAILURE)
- return FAILURE;
-
- php_output_activate(TSRMLS_C);
- sapi_activate(TSRMLS_C);
- php_hash_environment(TSRMLS_C);
-
- zend_try {
- PG(during_request_startup) = 1;
- php_output_activate(TSRMLS_C);
- if (PG(expose_php)) {
- sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1);
- }
- } zend_catch {
- retval = FAILURE;
- } zend_end_try();
-
- return retval;
-}
-# endif
-/* }}} */
-
-/* {{{ php_request_startup_for_hook
- */
-int php_request_startup_for_hook(TSRMLS_D)
-{
- int retval = SUCCESS;
-
-#if PHP_SIGCHLD
- signal(SIGCHLD, sigchld_handler);
-#endif
-
- if (php_start_sapi(TSRMLS_C) == FAILURE)
- return FAILURE;
-
- php_output_activate(TSRMLS_C);
- sapi_activate_headers_only(TSRMLS_C);
- php_hash_environment(TSRMLS_C);
-
- return retval;
-}
-/* }}} */
-
-/* {{{ php_request_shutdown_for_exec
- */
-void php_request_shutdown_for_exec(void *dummy)
-{
- TSRMLS_FETCH();
-
- /* used to close fd's in the 3..255 range here, but it's problematic
- */
- shutdown_memory_manager(1, 1 TSRMLS_CC);
-}
-/* }}} */
-
-/* {{{ php_request_shutdown_for_hook
- */
-void php_request_shutdown_for_hook(void *dummy)
-{
- TSRMLS_FETCH();
- if (PG(modules_activated)) zend_try {
- php_call_shutdown_functions();
- } zend_end_try();
-
- if (PG(modules_activated)) {
- zend_deactivate_modules(TSRMLS_C);
- }
-
- zend_try {
- int i;
-
- for (i = 0; i < NUM_TRACK_VARS; i++) {
- zval_ptr_dtor(&PG(http_globals)[i]);
- }
- } zend_end_try();
-
- zend_deactivate(TSRMLS_C);
-
- zend_try {
- sapi_deactivate(TSRMLS_C);
- } zend_end_try();
-
- zend_try {
- shutdown_memory_manager(CG(unclean_shutdown), 0 TSRMLS_CC);
- } zend_end_try();
-
- zend_try {
- zend_unset_timeout(TSRMLS_C);
- } zend_end_try();
-}
-
-/* }}} */
-
-/* {{{ php_request_shutdown
- */
-void php_request_shutdown(void *dummy)
-{
- TSRMLS_FETCH();
-
- /* EG(opline_ptr) points into nirvana and therefore cannot be safely accessed
- inside zend_executor callback functions. */
- EG(opline_ptr) = NULL;
-
- 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_try {
- int i;
-
- for (i=0; i<NUM_TRACK_VARS; i++) {
- if (PG(http_globals)[i]) {
- zval_ptr_dtor(&PG(http_globals)[i]);
- }
- }
- } zend_end_try();
-
-
- zend_deactivate(TSRMLS_C);
-
- zend_try {
- sapi_deactivate(TSRMLS_C);
- } zend_end_try();
-
- zend_try {
- shutdown_memory_manager(CG(unclean_shutdown), 0 TSRMLS_CC);
- } zend_end_try();
-
- zend_try {
- zend_unset_timeout(TSRMLS_C);
- } zend_end_try();
-
-#ifdef PHP_WIN32
- CoUninitialize();
-#endif
-}
-/* }}} */
-
-
-/* {{{ 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_module_entry *additional_modules, uint num_additional_modules)
-{
- zend_utility_functions zuf;
- zend_utility_values zuv;
- int module_number=0; /* for REGISTER_INI_ENTRIES() */
- char *php_os;
- int i;
-#ifdef ZTS
- zend_executor_globals *executor_globals;
- void ***tsrm_ls;
-
- php_core_globals *core_globals;
-#endif
-#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
- 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;
- zuf.on_timeout = php_on_timeout;
- zuf.stream_open_function = php_stream_open_for_zend;
- 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;
- SG(request_info).argc=0;
- SG(request_info).argv=(char **)NULL;
- PG(connection_status) = PHP_CONNECTION_NORMAL;
- PG(during_request_startup) = 0;
-
-#if HAVE_SETLOCALE
- setlocale(LC_CTYPE, "");
-#endif
-
-#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
- /* 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() == FAILURE) {
- return FAILURE;
- }
-
- REGISTER_INI_ENTRIES();
- zend_register_standard_ini_entries(TSRMLS_C);
-
- /* initialize stream wrappers registry
- * (this uses configuration parameters from php.ini)
- */
- if (php_init_stream_wrappers(module_number TSRMLS_CC) == FAILURE) {
- php_printf("PHP: Unable to initialize stream 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";
- for (i=0; i<NUM_TRACK_VARS; i++) {
- zend_register_auto_global(short_track_vars_names[i], short_track_vars_names_length[i]-1 TSRMLS_CC);
- }
- zend_register_auto_global("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC);
- 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("PHP_SAPI", sapi_module.name, strlen(sapi_module.name), 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_PREFIX", PHP_PREFIX, sizeof(PHP_PREFIX)-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);
- REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_SCAN_DIR", PHP_CONFIG_FILE_SCAN_DIR, sizeof(PHP_CONFIG_FILE_SCAN_DIR)-1, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_STRINGL_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, sizeof(PHP_SHLIB_SUFFIX)-1, CONST_PERSISTENT | CONST_CS);
- php_output_register_constants(TSRMLS_C);
- php_rfc1867_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;
- }
- /* start additional PHP extensions */
- php_startup_extensions(&additional_modules, num_additional_modules);
-
-
- /* 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);
-
- /* start Zend extensions */
- zend_startup_extensions();
-
-#ifdef ZTS
- zend_post_startup(TSRMLS_C);
-#endif
-
- /* */
- 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;
- }
-
-#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
- /*close winsock */
- WSACleanup();
-#endif
-
- php_shutdown_ticks(TSRMLS_C);
- sapi_flush(TSRMLS_C);
-
- zend_shutdown(TSRMLS_C);
-
- php_shutdown_stream_wrappers(module_number TSRMLS_CC);
-
- php_shutdown_info_logos();
- UNREGISTER_INI_ENTRIES();
-
- /* close down the ini config */
- php_shutdown_config();
-
-#ifndef ZTS
- zend_ini_shutdown(TSRMLS_C);
- shutdown_memory_manager(CG(unclean_shutdown), 1 TSRMLS_CC);
-#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 = NULL;
- zend_bool initialized_dummy_track_vars_array=0;
- int i;
- char *variables_order;
- 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<NUM_TRACK_VARS; i++) {
- PG(http_globals)[i] = NULL;
- }
-
- if (PG(variables_order)) {
- variables_order = PG(variables_order);
- have_variables_order=1;
- } else {
- variables_order = 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);
- }
-
- for (p=variables_order; p && *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")) {
- sapi_module.treat_data(PARSE_POST, NULL, NULL TSRMLS_CC); /* POST Data */
- _gpc_flags[0]=1;
- }
- break;
- case 'c':
- case 'C':
- if (!_gpc_flags[1]) {
- sapi_module.treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC); /* Cookie Data */
- _gpc_flags[1]=1;
- }
- break;
- case 'g':
- case 'G':
- if (!_gpc_flags[2]) {
- sapi_module.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_docref(NULL TSRMLS_CC, 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<NUM_TRACK_VARS; 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);
- PG(http_globals)[i]->refcount++;
- zend_hash_update(&EG(symbol_table), short_track_vars_names[i], short_track_vars_names_length[i], &PG(http_globals)[i], sizeof(zval *), NULL);
- PG(http_globals)[i]->refcount++;
- }
-
- {
- zval *form_variables;
-
- ALLOC_ZVAL(form_variables);
- array_init(form_variables);
- INIT_PZVAL(form_variables);
-
- for (p=variables_order; p && *p; p++) {
- switch (*p) {
- case 'g':
- case 'G':
- zend_hash_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_GET]), (void (*)(void *pData)) zval_add_ref, NULL, sizeof(zval *), 1);
- break;
- case 'p':
- case 'P':
- zend_hash_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_POST]), (void (*)(void *pData)) zval_add_ref, NULL, sizeof(zval *), 1);
- break;
- case 'c':
- case 'C':
- zend_hash_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_COOKIE]), (void (*)(void *pData)) zval_add_ref, NULL, sizeof(zval *), 1);
- break;
- }
- }
-
- zend_hash_update(&EG(symbol_table), "_REQUEST", sizeof("_REQUEST"), &form_variables, 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 (SG(request_info).argc) { /* are we in cli sapi? */
- int i;
- for (i=0; i<SG(request_info).argc; i++) {
- ALLOC_ZVAL(tmp);
- Z_TYPE_P(tmp) = IS_STRING;
- Z_STRLEN_P(tmp) = strlen(SG(request_info).argv[i]);
- Z_STRVAL_P(tmp) = estrndup(SG(request_info).argv[i], Z_STRLEN_P(tmp));
- INIT_PZVAL(tmp);
- if (zend_hash_next_index_insert(Z_ARRVAL_P(arr), &tmp, sizeof(pval *), NULL)==FAILURE) {
- if (Z_TYPE_P(tmp) == IS_STRING) {
- efree(Z_STRVAL_P(tmp));
- }
- }
- }
- } else if (s && *s) {
- ss = s;
- while (ss) {
- space = strchr(ss, '+');
- if (space) {
- *space = '\0';
- }
- /* auto-type */
- ALLOC_ZVAL(tmp);
- Z_TYPE_P(tmp) = IS_STRING;
- Z_STRLEN_P(tmp) = strlen(ss);
- Z_STRVAL_P(tmp) = estrndup(ss, Z_STRLEN_P(tmp));
- INIT_PZVAL(tmp);
- count++;
- if (zend_hash_next_index_insert(Z_ARRVAL_P(arr), &tmp, sizeof(pval *), NULL)==FAILURE) {
- if (Z_TYPE_P(tmp) == IS_STRING) {
- efree(Z_STRVAL_P(tmp));
- }
- }
- if (space) {
- *space = '+';
- ss = space + 1;
- } else {
- ss = space;
- }
- }
- }
-
- /* prepare argc */
- ALLOC_ZVAL(argc);
- if (SG(request_info).argc) {
- Z_LVAL_P(argc) = SG(request_info).argc;
- } else {
- Z_LVAL_P(argc) = count;
- }
- Z_TYPE_P(argc) = IS_LONG;
- INIT_PZVAL(argc);
-
- if (PG(register_globals) || SG(request_info).argc) {
- 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(Z_ARRVAL_P(track_vars_array), "argv", sizeof("argv"), &arr, sizeof(pval *), NULL);
- zend_hash_update(Z_ARRVAL_P(track_vars_array), "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;
- char *old_primary_file_path = NULL;
- int retval = 0;
-
- 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 (primary_file->filename) {
- char realfile[MAXPATHLEN];
- int realfile_len;
- int dummy = 1;
- if (VCWD_REALPATH(primary_file->filename, realfile)) {
- realfile_len = strlen(realfile);
- zend_hash_add(&EG(included_files), realfile, realfile_len+1, (void *)&dummy, sizeof(int), NULL);
- if (strncmp(realfile, primary_file->filename, realfile_len)) {
- old_primary_file_path = primary_file->filename;
- primary_file->filename = realfile;
- }
- }
- }
-
- 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;
- }
-#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING)
- php_mb_set_zend_encoding(TSRMLS_C);
-#endif /* ZEND_MULTIBYTE && HAVE_MBSTRING */
-#ifdef PHP_WIN32
- zend_unset_timeout(TSRMLS_C);
-#endif
- zend_set_timeout(INI_INT("max_execution_time"));
- retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 3, prepend_file_p, primary_file, append_file_p) == SUCCESS);
-
- if (old_primary_file_path) {
- primary_file->filename = old_primary_file_path;
- }
-
- } zend_end_try();
-
- if (old_cwd[0] != '\0') {
- VCWD_CHDIR(old_cwd);
- }
- free_alloca(old_cwd);
- return retval;
-}
-/* }}} */
-
-/* {{{ php_execute_simple_script
- */
-PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval **ret TSRMLS_DC)
-{
- char *old_cwd;
-
- EG(exit_status) = 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);
- }
- zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, ret, 1, primary_file);
- } 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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/mergesort.c b/main/mergesort.c
deleted file mode 100644
index 117f859e94..0000000000
--- a/main/mergesort.c
+++ /dev/null
@@ -1,363 +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.
- */
-
-/* $Id$ */
-
-#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 <winsock2.h> /* Includes definition for u_char */
-#endif
-
-#if defined(NETWARE) && !defined(NEW_LIBC)
-/*#include <ws2nlm.h>*/
-#include <sys/socket.h>
-#endif
-
-static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
-static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
-
-#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 * TSRMLS_DC) TSRMLS_DC)
-{
- 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 TSRMLS_CC);
- 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 TSRMLS_CC) <= 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 TSRMLS_CC) >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 TSRMLS_CC) <= sense)
- t = p;
- else
- b = p;
- break;
- } else if ((*cmp)(q, p TSRMLS_CC) <= 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 TSRMLS_CC) <= sense)
- t = p;
- else
- b = p;
- }
- goto COPY;
-FASTCASE: while (i > size)
- if ((*cmp)(q,
- p = b + (i >>= 1) TSRMLS_CC) <= 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 * TSRMLS_DC) TSRMLS_DC)
-{
- 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 TSRMLS_CC);
- *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 TSRMLS_CC);
- last = list1 + size * (n - i);
- *EVAL(list2 + (last - list1)) = list2 + n * size;
-
-#ifdef NATURAL
- p2 = list2;
- f1 = list1;
- sense = (cmp(f1, f1 + size TSRMLS_CC) > 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 TSRMLS_CC) > 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 TSRMLS_CC) > 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 TSRMLS_CC) > 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 TSRMLS_CC) > 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 * TSRMLS_DC) TSRMLS_DC)
-{
- 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 TSRMLS_CC) <= 0)
- break;
- swap(u, t);
- }
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: fdm=marker
- * vim: noet sw=4 ts=4
- */
diff --git a/main/network.c b/main/network.c
deleted file mode 100644
index 905af64813..0000000000
--- a/main/network.c
+++ /dev/null
@@ -1,940 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Stig Venaas <venaas@uninett.no> |
- | Streams work by Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/*#define DEBUG_MAIN_NETWORK 1*/
-
-#include "php.h"
-
-#include <stddef.h>
-
-#ifdef PHP_WIN32
-#define O_RDONLY _O_RDONLY
-#include "win32/param.h"
-#elif defined(NETWARE)
-#ifdef NEW_LIBC
-#include <sys/timeval.h>
-#include <sys/param.h>
-#else
-#include "netware/time_nw.h"
-#endif
-#else
-#include <sys/param.h>
-#endif
-
-#include <sys/types.h>
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#ifndef _FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-#if HAVE_SYS_POLL_H
-#include <sys/poll.h>
-#endif
-
-#if defined(NETWARE)
-#ifdef USE_WINSOCK
-/*#include <ws2nlm.h>*/
-#include <novsock2.h>
-#else
-/* New headers for socket stuff */
-#ifdef NEW_LIBC
-#include <netinet/in.h>
-#include <netdb.h>
-#include <sys/select.h>
-#endif
-#include <sys/socket.h>
-#endif
-#elif !defined(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"
-
-#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
-#undef AF_UNIX
-#endif
-
-#if defined(AF_UNIX)
-#include <sys/un.h>
-#endif
-
-#include "ext/standard/file.h"
-
-#ifdef PHP_WIN32
-# define SOCK_ERR INVALID_SOCKET
-# define SOCK_CONN_ERR SOCKET_ERROR
-# define PHP_TIMEOUT_ERROR_VALUE WSAETIMEDOUT
-#else
-# define SOCK_ERR -1
-# define SOCK_CONN_ERR -1
-# define PHP_TIMEOUT_ERROR_VALUE ETIMEDOUT
-#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
- * Returns number of addresses, 0 for none/error
- */
-static int php_network_getaddresses(const char *host, struct sockaddr ***sal, char **error_string TSRMLS_DC)
-{
- struct sockaddr **sap;
- int n;
-#ifdef HAVE_GETADDRINFO
- struct addrinfo hints, *res, *sai;
-#else
- struct hostent *host_info;
- struct in_addr in;
-#endif
-
- if (host == NULL) {
- return 0;
- }
-
-#ifdef HAVE_GETADDRINFO
- memset(&hints, '\0', sizeof(hints));
-
-# ifdef HAVE_IPV6
- hints.ai_family = AF_UNSPEC;
-# else
- hints.ai_family = AF_INET;
-# endif
-
- if ((n = getaddrinfo(host, NULL, &hints, &res)) || res == NULL) {
- char *str = res == NULL ? "null result pointer" : PHP_GAI_STRERROR(n);
-
- if (error_string) {
- spprintf(error_string, 0, "getaddrinfo: %s", str);
- } else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: getaddrinfo failed: %s", str);
- }
- return 0;
- }
-
- sai = res;
-
- for (n = 1; (sai = sai->ai_next) != NULL; n++) {
- ;
- }
-
- *sal = emalloc((n + 1) * sizeof(*sal));
- sai = res;
- sap = *sal;
- do {
- switch (sai->ai_family) {
-# if 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
-
- if (!inet_aton(host, &in)) {
- /* XXX NOT THREAD SAFE
- * (but it *is* thread safe under win32)
- */
- host_info = gethostbyname(host);
- if (host_info == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: gethostbyname failed");
- return 0;
- }
- 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++;
- n = 1;
-#endif
-
- *sap = NULL;
- return n;
-}
-/* }}} */
-
-#ifndef O_NONBLOCK
-#define O_NONBLOCK O_NDELAY
-#endif
-
-#if !defined(__BEOS__)
-# define HAVE_NON_BLOCKING_CONNECT 1
-# ifdef PHP_WIN32
-typedef u_long php_non_blocking_flags_t;
-# define SET_SOCKET_BLOCKING_MODE(sock, save) \
- save = TRUE; ioctlsocket(sock, FIONBIO, &save)
-# define RESTORE_SOCKET_BLOCKING_MODE(sock, save) \
- ioctlsocket(sock, FIONBIO, &save)
-# else
-typedef int php_non_blocking_flags_t;
-# define SET_SOCKET_BLOCKING_MODE(sock, save) \
- save = fcntl(sock, F_GETFL, 0); \
- fcntl(sock, F_SETFL, save | O_NONBLOCK)
-# define RESTORE_SOCKET_BLOCKING_MODE(sock, save) \
- fcntl(sock, F_SETFL, save)
-# endif
-#endif
-
-
-
-
-/* Connect to a socket using an interruptible connect with optional timeout.
- * Optionally, the connect can be made asynchronously, which will implicitly
- * enable non-blocking mode on the socket.
- * */
-/* {{{ php_network_connect_socket */
-PHPAPI int php_network_connect_socket(int sockfd,
- const struct sockaddr *addr,
- socklen_t addrlen,
- int asynchronous,
- struct timeval *timeout,
- char **error_string,
- int *error_code)
-{
-#if HAVE_NON_BLOCKING_CONNECT
- php_non_blocking_flags_t orig_flags;
- int n;
- int error = 0;
- socklen_t len;
- int ret = 0;
- fd_set rset;
- fd_set wset;
- fd_set eset;
-
- SET_SOCKET_BLOCKING_MODE(sockfd, orig_flags);
-
- if ((n = connect(sockfd, addr, addrlen)) < 0) {
- error = php_socket_errno();
-
- if (error_code) {
- *error_code = error;
- }
-
- if (error != EINPROGRESS) {
- if (error_string) {
- *error_string = php_socket_strerror(error, NULL, 0);
- }
-
- return -1;
- }
- if (asynchronous && error == EINPROGRESS) {
- /* this is fine by us */
- return 0;
- }
- }
-
- if (n == 0) {
- goto ok;
- }
-
- FD_ZERO(&rset);
- FD_ZERO(&eset);
- FD_SET(sockfd, &rset);
- FD_SET(sockfd, &eset);
-
- wset = rset;
-
- if ((n = select(sockfd + 1, &rset, &wset, &eset, 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:
- if (!asynchronous) {
- /* back to blocking mode */
- RESTORE_SOCKET_BLOCKING_MODE(sockfd, orig_flags);
- }
-
- if (error_code) {
- *error_code = error;
- }
-
- if (error && error_string) {
- *error_string = php_socket_strerror(error, NULL, 0);
- ret = -1;
- }
- return ret;
-#else
- if (asynchronous) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Asynchronous connect() not supported on this platform");
- }
- return connect(sockfd, addr, addrlen);
-#endif
-}
-/* }}} */
-
-/* {{{ php_connect_nonb */
-PHPAPI int php_connect_nonb(int sockfd,
- const struct sockaddr *addr,
- socklen_t addrlen,
- struct timeval *timeout)
-{
-#if (!defined(__BEOS__) && !defined(PHP_WIN32)) && (defined(O_NONBLOCK) || defined(O_NDELAY))
-
-
- int flags;
- int n;
- int error = 0;
- socklen_t len;
- int ret = 0;
- fd_set rset;
- fd_set wset;
- fd_set eset;
-
- 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_ZERO(&eset);
- FD_SET(sockfd, &rset);
- FD_SET(sockfd, &eset);
-
- wset = rset;
-
- if ((n = select(sockfd + 1, &rset, &wset, &eset, 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) && ... */
-#ifdef PHP_WIN32
- return php_connect_nonb_win32((SOCKET) sockfd, addr, addrlen, timeout);
-#endif
- return connect(sockfd, addr, addrlen);
-#endif
-}
-/* }}} */
-
-#ifdef PHP_WIN32
-/* {{{ php_connect_nonb_win32 */
-PHPAPI int php_connect_nonb_win32(SOCKET sockfd,
- const struct sockaddr *addr,
- socklen_t addrlen,
- struct timeval *timeout)
-{
- int error = 0, error_len, ret;
- u_long non_block = TRUE, block = FALSE;
-
- fd_set rset, wset;
-
- if (timeout == NULL) {
- /* blocking mode */
- return connect(sockfd, addr, addrlen);
- }
-
- /* Set the socket to be non-blocking */
- ioctlsocket(sockfd, FIONBIO, &non_block);
-
- if (connect(sockfd, addr, addrlen) == SOCKET_ERROR) {
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
- return SOCKET_ERROR;
- }
- }
-
- FD_ZERO(&rset);
- FD_SET(sockfd, &rset);
-
- FD_ZERO(&wset);
- FD_SET(sockfd, &wset);
-
- if ((ret = select(sockfd + 1, &rset, &wset, NULL, timeout)) == 0) {
- WSASetLastError(WSAETIMEDOUT);
- return SOCKET_ERROR;
- }
-
- if (ret == SOCKET_ERROR) {
- return SOCKET_ERROR;
- }
-
- if(FD_ISSET(sockfd, &rset) || FD_ISSET(sockfd, &wset)) {
- error_len = sizeof(error);
- if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (char *) &error, &error_len) == SOCKET_ERROR) {
- return SOCKET_ERROR;
- }
- } else {
- /* whoops: sockfd has disappeared */
- return SOCKET_ERROR;
- }
-
- /* Set the socket back to blocking */
- ioctlsocket(sockfd, FIONBIO, &block);
-
- if (error) {
- WSASetLastError(error);
- return SOCKET_ERROR;
- }
-
- return 0;
-}
-/* }}} */
-#endif
-
-/* {{{ sub_times */
-static inline void sub_times(struct timeval a, struct timeval b, struct timeval *result)
-{
- result->tv_usec = a.tv_usec - b.tv_usec;
- if (result->tv_usec < 0L) {
- a.tv_sec--;
- result->tv_usec += 1000000L;
- }
- result->tv_sec = a.tv_sec - b.tv_sec;
- if (result->tv_sec < 0L) {
- result->tv_sec++;
- result->tv_usec -= 1000000L;
- }
-}
-/* }}} */
-
-/* Connect to a remote host using an interruptible connect with optional timeout.
- * Optionally, the connect can be made asynchronously, which will implicitly
- * enable non-blocking mode on the socket.
- * Returns the connected (or connecting) socket, or -1 on failure.
- * */
-
-/* {{{ php_network_connect_socket_to_host */
-int php_network_connect_socket_to_host(const char *host, unsigned short port,
- int socktype, int asynchronous, struct timeval *timeout, char **error_string,
- int *error_code
- TSRMLS_DC)
-{
- int num_addrs, sock, n, fatal = 0;
- struct sockaddr **sal, **psal, *sa;
- struct timeval working_timeout;
- socklen_t socklen;
-#if HAVE_GETTIMEOFDAY
- struct timeval limit_time, time_now;
-#endif
-
- num_addrs = php_network_getaddresses(host, &psal, error_string TSRMLS_CC);
-
- if (num_addrs == 0) {
- /* could not resolve address(es) */
- return -1;
- }
-
- if (timeout) {
- memcpy(&working_timeout, timeout, sizeof(working_timeout));
-#if HAVE_GETTIMEOFDAY
- gettimeofday(&limit_time, NULL);
- limit_time.tv_sec += working_timeout.tv_sec;
- limit_time.tv_usec += working_timeout.tv_usec;
- if (limit_time.tv_usec >= 1000000) {
- limit_time.tv_usec -= 1000000;
- limit_time.tv_sec++;
- }
-#endif
- }
-
- for (sal = psal; !fatal && *sal != NULL; sal++) {
- sa = *sal;
-
- /* create a socket for this address */
- sock = socket(sa->sa_family, socktype, 0);
-
- if (sock == SOCK_ERR) {
- continue;
- }
-
- switch (sa->sa_family) {
-#if HAVE_GETADDRINFO && HAVE_IPV6
- case AF_INET6:
- ((struct sockaddr_in6 *)sa)->sin6_family = sa->sa_family;
- ((struct sockaddr_in6 *)sa)->sin6_port = htons(port);
- socklen = sizeof(struct sockaddr_in6);
- break;
-#endif
- case AF_INET:
- ((struct sockaddr_in *)sa)->sin_family = sa->sa_family;
- ((struct sockaddr_in *)sa)->sin_port = htons(port);
- socklen = sizeof(struct sockaddr_in);
- break;
- default:
- /* Unknown family */
- sa = NULL;
- }
-
- if (sa) {
- /* make a connection attempt */
-
- n = php_network_connect_socket(sock, sa, socklen, asynchronous,
- timeout ? &working_timeout : NULL,
- error_string, error_code);
-
- if (n != SOCK_CONN_ERR) {
- goto connected;
- }
-
- /* adjust timeout for next attempt */
-#if HAVE_GETTIMEOFDAY
- if (timeout) {
- gettimeofday(&time_now, NULL);
-
- if (timercmp(&time_now, &limit_time, >=)) {
- /* time limit expired; don't attempt any further connections */
- fatal = 1;
- } else {
- /* work out remaining time */
- sub_times(limit_time, time_now, &working_timeout);
- }
- }
-#else
- if (err == PHP_TIMEOUT_ERROR_VALUE) {
- /* Don't even bother trying to connect to the next alternative;
- * we have no way to determine how long we have already taken
- * and it is quite likely that the next attempt will fail too. */
- fatal = 1;
- } else {
- /* re-use the same initial timeout.
- * Not the best thing, but in practice it should be good-enough */
- if (timeout) {
- memcpy(&working_timeout, timeout, sizeof(working_timeout));
- }
- }
-#endif
- }
-
- close(sock);
- }
- sock = -1;
-
-connected:
-
- php_network_freeaddresses(psal);
-
- return sock;
-}
-/* }}} */
-
-
-
-/* {{{ 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(const char *host, unsigned short port, int socktype, struct timeval *timeout TSRMLS_DC)
-{
- int n, repeatto, s;
- struct sockaddr **sal, **psal;
- struct timeval individual_timeout;
- int set_timeout = 0;
- int err;
-
- n = php_network_getaddresses(host, &sal, NULL TSRMLS_CC);
-
- if (n == 0)
- return -1;
-
- if (timeout != NULL) {
- /* is this a good idea? 5s? */
- repeatto = timeout->tv_sec / n > 5;
- if (repeatto) {
- individual_timeout.tv_sec = timeout->tv_sec / n;
- } else {
- individual_timeout.tv_sec = timeout->tv_sec;
- }
-
- individual_timeout.tv_usec = timeout->tv_usec;
- } else {
- individual_timeout.tv_sec = 0;
- individual_timeout.tv_usec = 0;
- }
-
- /* Boolean indicating whether to pass a timeout */
- set_timeout = individual_timeout.tv_sec + individual_timeout.tv_usec;
-
- 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), (set_timeout) ? &individual_timeout : 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), (set_timeout) ? &individual_timeout : NULL) != SOCK_CONN_ERR)
- goto ok;
-
- }
- break;
- }
-#ifdef PHP_WIN32
- /* Preserve the last error */
- err = WSAGetLastError();
-#else
- err = errno;
-#endif
- close (s);
- }
- sal++;
-
- if (err == PHP_TIMEOUT_ERROR_VALUE) {
- /* if the first attempt timed out, it's highly likely
- * that any subsequent attempts will do so also */
- break;
- }
-
- }
- php_network_freeaddresses(psal);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_hostconnect: connect failed");
-
-#ifdef PHP_WIN32
- /* Restore the last error */
- WSASetLastError(err);
-#endif
-
- return -1;
-
- ok:
- php_network_freeaddresses(psal);
- return s;
-}
-/* }}} */
-
-/* {{{ php_any_addr
- * Fills the any (wildcard) address into php_sockaddr_storage
- */
-void php_any_addr(int family, php_sockaddr_storage *addr, unsigned short port)
-{
- memset(addr, 0, sizeof(php_sockaddr_storage));
- switch (family) {
-#ifdef HAVE_IPV6
- case AF_INET6: {
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) addr;
- sin6->sin6_family = AF_INET6;
- sin6->sin6_port = htons(port);
- sin6->sin6_addr = in6addr_any;
- break;
- }
-#endif
- case AF_INET: {
- struct sockaddr_in *sin = (struct sockaddr_in *) addr;
- sin->sin_family = AF_INET;
- sin->sin_port = htons(port);
- sin->sin_addr.s_addr = htonl(INADDR_ANY);
- break;
- }
- }
-}
-/* }}} */
-
-/* {{{ php_sockaddr_size
- * Returns the size of struct sockaddr_xx for the family
- */
-int php_sockaddr_size(php_sockaddr_storage *addr)
-{
- switch (((struct sockaddr *)addr)->sa_family) {
- case AF_INET:
- return sizeof(struct sockaddr_in);
-#ifdef HAVE_IPV6
- case AF_INET6:
- return sizeof(struct sockaddr_in6);
-#endif
-#ifdef AF_UNIX
- case AF_UNIX:
- return sizeof(struct sockaddr_un);
-#endif
- default:
- return 0;
- }
-}
-/* }}} */
-
-/* Given a socket error code, if buf == NULL:
- * emallocs storage for the error message and returns
- * else
- * sprintf message into provided buffer and returns buf
- */
-/* {{{ php_socket_strerror */
-PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize)
-{
-#ifndef PHP_WIN32
- char *errstr;
-
- errstr = strerror(err);
- if (buf == NULL) {
- buf = estrdup(errstr);
- } else {
- strncpy(buf, errstr, bufsize);
- }
- return buf;
-#else
- char *sysbuf;
- int free_it = 1;
-
- if (!FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&sysbuf,
- 0,
- NULL)) {
- free_it = 0;
- sysbuf = "Unknown Error";
- }
-
- if (buf == NULL) {
- buf = estrdup(sysbuf);
- } else {
- strncpy(buf, sysbuf, bufsize);
- }
-
- if (free_it) {
- LocalFree(sysbuf);
- }
-
- return buf;
-#endif
-}
-/* }}} */
-
-/* deprecated */
-PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, const char *persistent_id STREAMS_DC TSRMLS_DC)
-{
- php_stream *stream;
- php_netstream_data_t *sock;
-
- sock = pemalloc(sizeof(php_netstream_data_t), persistent_id ? 1 : 0);
- memset(sock, 0, sizeof(php_netstream_data_t));
-
- sock->is_blocked = 1;
- sock->timeout.tv_sec = FG(default_socket_timeout);
- sock->timeout.tv_usec = 0;
- sock->socket = socket;
-
- stream = php_stream_alloc_rel(&php_stream_generic_socket_ops, sock, persistent_id, "r+");
- stream->flags |= PHP_STREAM_FLAG_AVOID_BLOCKING;
-
- if (stream == NULL)
- pefree(sock, persistent_id ? 1 : 0);
-
- return stream;
-}
-
-PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short port,
- int socktype, struct timeval *timeout, const char *persistent_id STREAMS_DC TSRMLS_DC)
-{
- char *res;
- long reslen;
- php_stream *stream;
-
- reslen = spprintf(&res, 0, "tcp://%s:%d", host, port);
-
- stream = php_stream_xport_create(res, reslen, ENFORCE_SAFE_MODE | REPORT_ERRORS,
- STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, persistent_id, timeout, NULL, NULL, NULL);
-
- efree(res);
-
- return stream;
-}
-
-PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC)
-{
- int ret = SUCCESS;
- int flags;
- int myflag = 0;
-
-#ifdef PHP_WIN32
- /* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking */
- flags = !block;
- if (ioctlsocket(socketd, FIONBIO, &flags)==SOCKET_ERROR){
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", WSAGetLastError());
- ret = FALSE;
- }
-#else
- flags = fcntl(socketd, F_GETFL);
-#ifdef O_NONBLOCK
- myflag = O_NONBLOCK; /* POSIX version */
-#elif defined(O_NDELAY)
- myflag = O_NDELAY; /* old non-POSIX version */
-#endif
- if (!block) {
- flags |= myflag;
- } else {
- flags &= ~myflag;
- }
- fcntl(socketd, F_SETFL, flags);
-#endif
- return ret;
-}
-
-
-/*
- * Local variables:
- * tab-width: 8
- * c-basic-offset: 8
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/output.c b/main/output.c
deleted file mode 100644
index de5b9faaec..0000000000
--- a/main/output.c
+++ /dev/null
@@ -1,1059 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- | Marcus Boerger <helly@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php.h"
-#include "ext/standard/head.h"
-#include "ext/standard/basic_functions.h"
-#include "ext/standard/url_scanner_ex.h"
-#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
-#include "ext/zlib/php_zlib.h"
-#endif
-#include "SAPI.h"
-
-#define OB_DEFAULT_HANDLER_NAME "default output handler"
-
-/* 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 int php_ob_init(uint initial_size, uint block_size, zval *output_handler, uint chunk_size, zend_bool erase 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
-
-/* {{{ php_default_output_func */
-static inline int php_default_output_func(const char *str, uint str_len TSRMLS_DC)
-{
- fwrite(str, 1, str_len, stderr);
- return str_len;
-}
-/* }}} */
-
-/* {{{ php_output_init_globals */
-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;
-}
-/* }}} */
-
-
-/* {{{ php_output_startup
- 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
-}
-/* }}} */
-
-
-/* {{{ php_output_activate
- Initilize output global for activation */
-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;
- OG(output_start_filename) = NULL;
- OG(output_start_lineno) = 0;
-}
-/* }}} */
-
-
-/* {{{ php_output_set_status
- Toggle output status. Do NOT use in application code, only in SAPIs where appropriate. */
-PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC)
-{
- OG(disable_output) = !status;
-}
-/* }}} */
-
-/* {{{ php_output_register_constants */
-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);
-}
-/* }}} */
-
-
-/* {{{ php_body_wirte
- * Write body part */
-PHPAPI int php_body_write(const char *str, uint str_length TSRMLS_DC)
-{
- return OG(php_body_write)(str, str_length TSRMLS_CC);
-}
-/* }}} */
-
-/* {{{ php_header_wirte
- * Write HTTP header */
-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, zend_bool erase TSRMLS_DC)
-{
- uint initial_size, block_size;
-
- if (OG(ob_lock)) {
- 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_docref("ref.outcontrol" TSRMLS_CC, E_ERROR, "Cannot use output buffering in output buffering display handlers");
- return FAILURE;
- }
- if (chunk_size) {
- if (chunk_size==1) {
- chunk_size = 4096;
- }
- initial_size = (chunk_size*3/2);
- block_size = chunk_size/2;
- } else {
- initial_size = 40*1024;
- block_size = 10*1024;
- }
- return php_ob_init(initial_size, block_size, output_handler, chunk_size, erase TSRMLS_CC);
-}
-/* }}} */
-
-/* {{{ php_start_ob_buffer_named
- * Start output buffering */
-PHPAPI int php_start_ob_buffer_named(const char *output_handler_name, uint chunk_size, zend_bool erase TSRMLS_DC)
-{
- zval *output_handler;
- int result;
-
- ALLOC_INIT_ZVAL(output_handler);
- Z_STRLEN_P(output_handler) = strlen(output_handler_name); /* this can be optimized */
- Z_STRVAL_P(output_handler) = estrndup(output_handler_name, Z_STRLEN_P(output_handler));
- Z_TYPE_P(output_handler) = IS_STRING;
- result = php_start_ob_buffer(output_handler, chunk_size, erase TSRMLS_CC);
- zval_dtor(output_handler);
- FREE_ZVAL(output_handler);
- return result;
-}
-/* }}} */
-
-/* {{{ 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;
- unsigned int final_buffer_length=0;
- zval *alternate_buffer=NULL;
- char *to_be_destroyed_buffer, *to_be_destroyed_handler_name;
- char *to_be_destroyed_handled_output[2] = { 0, 0 };
- int status;
- php_ob_buffer *prev_ob_buffer_p=NULL;
- php_ob_buffer orig_ob_buffer;
-
- 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 0
- {
- FILE *fp;
- fp = fopen("/tmp/ob_log", "a");
- fprintf(fp, "NestLevel: %d ObStatus: %d HandlerName: %s\n", OG(ob_nesting_level), status, OG(active_ob_buffer).handler_name);
- fclose(fp);
- }
-#endif
-
- 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, 1);
- 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) {
- if (!(Z_TYPE_P(alternate_buffer)==IS_BOOL && Z_BVAL_P(alternate_buffer)==0)) {
- convert_to_string_ex(&alternate_buffer);
- final_buffer = Z_STRVAL_P(alternate_buffer);
- final_buffer_length = Z_STRLEN_P(alternate_buffer);
- }
- }
- OG(ob_lock) = 0;
- zval_ptr_dtor(&OG(active_ob_buffer).output_handler);
- orig_buffer->refcount -=2;
- if (orig_buffer->refcount <= 0) { /* free the zval */
- zval_dtor(orig_buffer);
- FREE_ZVAL(orig_buffer);
- }
- 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;
- to_be_destroyed_handler_name = OG(active_ob_buffer).handler_name;
- if (OG(active_ob_buffer).internal_output_handler
- && (final_buffer != OG(active_ob_buffer).internal_output_handler_buffer)
- && (final_buffer != OG(active_ob_buffer).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 */
- zend_stack_top(&OG(ob_buffers), (void **) &prev_ob_buffer_p);
- orig_ob_buffer = OG(active_ob_buffer);
- OG(active_ob_buffer) = *prev_ob_buffer_p;
- zend_stack_del_top(&OG(ob_buffers));
- if (!just_flush && 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 (just_flush) { /* we restored the previous ob, return to the current */
- if (prev_ob_buffer_p) {
- zend_stack_push(&OG(ob_buffers), &OG(active_ob_buffer), sizeof(php_ob_buffer));
- OG(active_ob_buffer) = orig_ob_buffer;
- }
- OG(ob_nesting_level)++;
- }
-
- if (alternate_buffer) {
- zval_ptr_dtor(&alternate_buffer);
- }
-
- if (status & PHP_OUTPUT_HANDLER_END) {
- efree(to_be_destroyed_handler_name);
- }
- 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);
- }
-}
-/* }}} */
-
-/* {{{ php_start_implicit_flush
- */
-PHPAPI void php_start_implicit_flush(TSRMLS_D)
-{
- 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, char *handler_name, zend_bool erase TSRMLS_DC)
-{
- if (OG(ob_nesting_level)==0 || OG(active_ob_buffer).internal_output_handler || strcmp(OG(active_ob_buffer).handler_name, OB_DEFAULT_HANDLER_NAME)) {
- php_start_ob_buffer(NULL, buffer_size, erase TSRMLS_CC);
- }
-
- 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;
- if (OG(active_ob_buffer).handler_name) {
- efree(OG(active_ob_buffer).handler_name);
- }
- OG(active_ob_buffer).handler_name = estrdup(handler_name);
- OG(active_ob_buffer).erase = erase;
-}
-/* }}} */
-
-/*
- * 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_conflict
- * Returns 1 if handler_set is already used and generates error message
- */
-PHPAPI int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC)
-{
- if (php_ob_handler_used(handler_set TSRMLS_CC)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler '%s' conflicts with '%s'", handler_new, handler_set);
- return 1;
- }
- return 0;
-}
-/* }}} */
-
-/* {{{ php_ob_init_named
- */
-static int php_ob_init_named(uint initial_size, uint block_size, char *handler_name, zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC)
-{
- if (OG(ob_nesting_level)>0) {
-#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
- if (!strncmp(handler_name, "ob_gzhandler", sizeof("ob_gzhandler")) && php_ob_gzhandler_check(TSRMLS_C)) {
- return FAILURE;
- }
-#endif
- 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;
- OG(active_ob_buffer).handler_name = estrdup(handler_name&&handler_name[0]?handler_name:OB_DEFAULT_HANDLER_NAME);
- OG(active_ob_buffer).erase = erase;
- OG(php_body_write) = php_b_body_write;
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ php_ob_handler_from_string
- * Create zval output handler from string
- */
-static zval* php_ob_handler_from_string(const char *handler_name TSRMLS_DC)
-{
- zval *output_handler;
-
- ALLOC_INIT_ZVAL(output_handler);
- Z_STRLEN_P(output_handler) = strlen(handler_name); /* this can be optimized */
- Z_STRVAL_P(output_handler) = estrndup(handler_name, Z_STRLEN_P(output_handler));
- Z_TYPE_P(output_handler) = IS_STRING;
- return output_handler;
-}
-/* }}} */
-
-/* {{{ php_ob_init
- */
-static int php_ob_init(uint initial_size, uint block_size, zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC)
-{
- int result, len;
- char *handler_name, *next_handler_name;
- HashPosition pos;
- zval **tmp;
- zval *handler_zval;
-
- if (output_handler && output_handler->type == IS_STRING) {
- handler_name = Z_STRVAL_P(output_handler);
- while ((next_handler_name=strchr(handler_name, ',')) != NULL) {
- len = next_handler_name-handler_name;
- next_handler_name = estrndup(handler_name, len);
- handler_zval = php_ob_handler_from_string(next_handler_name TSRMLS_CC);
- result = php_ob_init_named(initial_size, block_size, next_handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
- if (result != SUCCESS) {
- zval_dtor(handler_zval);
- FREE_ZVAL(handler_zval);
- }
- handler_name += len+1;
- efree(next_handler_name);
- }
- handler_zval = php_ob_handler_from_string(handler_name TSRMLS_CC);
- result = php_ob_init_named(initial_size, block_size, handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
- if (result != SUCCESS) {
- zval_dtor(handler_zval);
- FREE_ZVAL(handler_zval);
- }
- } else if (output_handler && output_handler->type == IS_ARRAY) {
- /* do we have array(object,method) */
- if (zend_is_callable(output_handler, 1, &handler_name)) {
- SEPARATE_ZVAL(&output_handler);
- output_handler->refcount++;
- result = php_ob_init_named(initial_size, block_size, handler_name, output_handler, chunk_size, erase TSRMLS_CC);
- efree(handler_name);
- } else {
- /* init all array elements recursively */
- zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(output_handler), &pos);
- while (zend_hash_get_current_data_ex(Z_ARRVAL_P(output_handler), (void **)&tmp, &pos) == SUCCESS) {
- result = php_ob_init(initial_size, block_size, *tmp, chunk_size, erase TSRMLS_CC);
- zend_hash_move_forward_ex(Z_ARRVAL_P(output_handler), &pos);
- }
- }
- } else if (output_handler && output_handler->type == IS_OBJECT) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "No method name given: use ob_start(array($object,'method')) to specify instance $object and the name of a method of class %s to use as output handler", Z_OBJCE_P(output_handler)->name);
- result = FAILURE;
- } else {
- if (output_handler) {
- SEPARATE_ZVAL(&output_handler);
- output_handler->refcount++;
- }
- result = php_ob_init_named(initial_size, block_size, OB_DEFAULT_HANDLER_NAME, output_handler, chunk_size, erase TSRMLS_CC);
- }
- return result;
-}
-/* }}} */
-
-/* {{{ php_ob_list_each
- */
-static int php_ob_list_each(php_ob_buffer *ob_buffer, zval *ob_handler_array)
-{
- add_next_index_string(ob_handler_array, ob_buffer->handler_name, 1);
- return 0;
-}
-/* }}} */
-
-/* {{{ proto false|array ob_list_handlers()
- * List all output_buffers in an array
- */
-PHP_FUNCTION(ob_list_handlers)
-{
- if (ZEND_NUM_ARGS()!=0) {
- ZEND_WRONG_PARAM_COUNT();
- RETURN_FALSE;
- }
-
- array_init(return_value);
- if (OG(ob_nesting_level)) {
- if (OG(ob_nesting_level)>1) {
- zend_stack_apply_with_argument(&OG(ob_buffers), ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_ob_list_each, return_value);
- }
- php_ob_list_each(&OG(active_ob_buffer), return_value);
- }
-}
-/* }}} */
-
-/* {{{ php_ob_used_each
- * Sets handler_name to NULL is found
- */
-static int php_ob_handler_used_each(php_ob_buffer *ob_buffer, char **handler_name)
-{
- if (!strcmp(ob_buffer->handler_name, *handler_name)) {
- *handler_name = NULL;
- return 1;
- }
- return 0;
-}
-/* }}} */
-
-/* {{{ php_ob_used
- * returns 1 if given handler_name is used as output_handler
- */
-PHPAPI int php_ob_handler_used(char *handler_name TSRMLS_DC)
-{
- char *tmp = handler_name;
-
- if (OG(ob_nesting_level)) {
- if (!strcmp(OG(active_ob_buffer).handler_name, handler_name)) {
- return 1;
- }
- if (OG(ob_nesting_level)>1) {
- zend_stack_apply_with_argument(&OG(ob_buffers), ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_ob_handler_used_each, &tmp);
- }
- }
- return tmp ? 0 : 1;
-}
-/* }}} */
-
-/* {{{ php_ob_append
- */
-static inline 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 implicit_flush is On or chunked buffering, send contents to next buffer and return. */
- 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 inline 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 */
-PHPAPI int php_ob_get_buffer(zval *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 */
-PHPAPI int php_ob_get_length(zval *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)
-{
- int result;
-
- if (OG(disable_output)) {
- return 0;
- }
-
- 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 bool ob_start([ string|array user_function [, int chunk_size [, bool erase]]])
- Turn on Output Buffering (specifying an optional output handler). */
-PHP_FUNCTION(ob_start)
-{
- zval *output_handler=NULL;
- uint chunk_size=0;
- zend_bool erase=1;
- int argc = ZEND_NUM_ARGS();
-
- if (zend_parse_parameters(argc TSRMLS_CC, "|zlb", &output_handler, &chunk_size, &erase) == FAILURE) {
- RETURN_FALSE;
- }
-
- if (php_start_ob_buffer(output_handler, chunk_size, erase TSRMLS_CC)==FAILURE) {
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool ob_flush(void)
- Flush (send) contents of the output buffer. The last buffer content is sent to next buffer */
-PHP_FUNCTION(ob_flush)
-{
- if (ZEND_NUM_ARGS() != 0) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- if (!OG(ob_nesting_level)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer. No buffer to flush.");
- RETURN_FALSE;
- }
-
- php_end_ob_buffer(1, 1 TSRMLS_CC);
- RETURN_TRUE;
-}
-/* }}} */
-
-
-/* {{{ proto bool ob_clean(void)
- Clean (delete) the current output buffer */
-PHP_FUNCTION(ob_clean)
-{
- if (ZEND_NUM_ARGS() != 0) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- if (!OG(ob_nesting_level)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete.");
- RETURN_FALSE;
- }
-
- if (!OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
- RETURN_FALSE;
- }
-
- php_end_ob_buffer(0, 1 TSRMLS_CC);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool ob_end_flush(void)
- Flush (send) the output buffer, and delete current output buffer */
-PHP_FUNCTION(ob_end_flush)
-{
- if (ZEND_NUM_ARGS() != 0) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- if (!OG(ob_nesting_level)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush.");
- RETURN_FALSE;
- }
- if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
- RETURN_FALSE;
- }
-
- php_end_ob_buffer(1, 0 TSRMLS_CC);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool ob_end_clean(void)
- Clean the output buffer, and delete current output buffer */
-PHP_FUNCTION(ob_end_clean)
-{
- if (ZEND_NUM_ARGS() != 0) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- if (!OG(ob_nesting_level)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete.");
- RETURN_FALSE;
- }
- if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
- RETURN_FALSE;
- }
-
- php_end_ob_buffer(0, 0 TSRMLS_CC);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool ob_get_flush(void)
- Get current buffer contents, flush (send) the output buffer, and delete current output buffer */
-PHP_FUNCTION(ob_get_flush)
-{
- if (ZEND_NUM_ARGS() != 0) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- /* get contents */
- if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
- RETURN_FALSE;
- }
- /* error checks */
- if (!OG(ob_nesting_level)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush.");
- RETURN_FALSE;
- }
- if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
- RETURN_FALSE;
- }
- /* flush */
- php_end_ob_buffer(1, 0 TSRMLS_CC);
-}
-/* }}} */
-
-/* {{{ proto bool ob_get_clean(void)
- Get current buffer contents and delete current output buffer */
-PHP_FUNCTION(ob_get_clean)
-{
- if (ZEND_NUM_ARGS() != 0)
- ZEND_WRONG_PARAM_COUNT();
-
- /* get contents */
- if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
- RETURN_FALSE;
- }
- /* error checks */
- if (!OG(ob_nesting_level)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete.");
- RETURN_FALSE;
- }
- if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
- RETURN_FALSE;
- }
- /* delete buffer */
- 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 (ZEND_NUM_ARGS() != 0) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int ob_get_level(void)
- Return the nesting level of the output buffer */
-PHP_FUNCTION(ob_get_level)
-{
- if (ZEND_NUM_ARGS() != 0) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- RETURN_LONG (OG(ob_nesting_level));
-}
-/* }}} */
-
-/* {{{ proto int ob_get_length(void)
- Return the length of the output buffer */
-PHP_FUNCTION(ob_get_length)
-{
- if (ZEND_NUM_ARGS() != 0) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- if (php_ob_get_length(return_value TSRMLS_CC)==FAILURE) {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ int php_ob_buffer_status(php_ob_buffer *ob_buffer, zval *result) */
-static int php_ob_buffer_status(php_ob_buffer *ob_buffer, zval *result)
-{
- zval *elem;
-
- MAKE_STD_ZVAL(elem);
- array_init(elem);
-
- add_assoc_long(elem, "chunk_size", ob_buffer->chunk_size);
- if (!ob_buffer->chunk_size) {
- add_assoc_long(elem, "size", ob_buffer->size);
- add_assoc_long(elem, "block_size", ob_buffer->block_size);
- }
- if (ob_buffer->internal_output_handler) {
- add_assoc_long(elem, "type", PHP_OUTPUT_HANDLER_INTERNAL);
- add_assoc_long(elem, "buffer_size", ob_buffer->internal_output_handler_buffer_size);
- }
- else {
- add_assoc_long(elem, "type", PHP_OUTPUT_HANDLER_USER);
- }
- add_assoc_long(elem, "status", ob_buffer->status);
- add_assoc_string(elem, "name", ob_buffer->handler_name, 1);
- add_assoc_bool(elem, "del", ob_buffer->erase);
- add_next_index_zval(result, elem);
-
- return SUCCESS;
-}
-/* }}} */
-
-
-/* {{{ proto false|array ob_get_status([bool full_status])
- Return the status of the active or all output buffers */
-PHP_FUNCTION(ob_get_status)
-{
- int argc = ZEND_NUM_ARGS();
- zend_bool full_status = 0;
-
- if (zend_parse_parameters(argc TSRMLS_CC, "|b", &full_status) == FAILURE )
- RETURN_FALSE;
-
- array_init(return_value);
-
- if (full_status) {
- if (OG(ob_nesting_level)>1) {
- zend_stack_apply_with_argument(&OG(ob_buffers), ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *elem, void *))php_ob_buffer_status, return_value);
- }
- if (OG(ob_nesting_level)>0 && php_ob_buffer_status(&OG(active_ob_buffer), return_value)==FAILURE) {
- RETURN_FALSE;
- }
- } else if (OG(ob_nesting_level)>0) {
- add_assoc_long(return_value, "level", OG(ob_nesting_level));
- if (OG(active_ob_buffer).internal_output_handler) {
- add_assoc_long(return_value, "type", PHP_OUTPUT_HANDLER_INTERNAL);
- } else {
- add_assoc_long(return_value, "type", PHP_OUTPUT_HANDLER_USER);
- }
- add_assoc_long(return_value, "status", OG(active_ob_buffer).status);
- add_assoc_string(return_value, "name", OG(active_ob_buffer).handler_name, 1);
- add_assoc_bool(return_value, "del", OG(active_ob_buffer).erase);
- }
-}
-/* }}} */
-
-
-/* {{{ 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 = Z_LVAL_PP(zv_flag);
- break;
- default:
- ZEND_WRONG_PARAM_COUNT();
- break;
- }
- if (flag) {
- php_start_implicit_flush(TSRMLS_C);
- } else {
- php_end_implicit_flush(TSRMLS_C);
- }
-}
-/* }}} */
-
-
-/* {{{ char *php_get_output_start_filename(TSRMLS_D)
- Return filename start output something */
-PHPAPI char *php_get_output_start_filename(TSRMLS_D)
-{
- return OG(output_start_filename);
-}
-/* }}} */
-
-
-/* {{{ char *php_get_output_start_lineno(TSRMLS_D)
- Return line number start output something */
-PHPAPI int php_get_output_start_lineno(TSRMLS_D)
-{
- return OG(output_start_lineno);
-}
-/* }}} */
-
-
-/* {{{ proto bool output_reset_rewrite_vars(void)
- Reset(clear) URL rewriter values */
-PHP_FUNCTION(output_reset_rewrite_vars)
-{
- if (php_url_scanner_reset_vars(TSRMLS_C) == SUCCESS) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-
-/* {{{ proto bool output_add_rewrite_var(string name, string value)
- Add URL rewriter values */
-PHP_FUNCTION(output_add_rewrite_var)
-{
- char *name, *value;
- int name_len, value_len;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &value, &value_len) == FAILURE) {
- RETURN_FALSE;
- }
-
- if (php_url_scanner_add_var(name, name_len, value, value_len, 1 TSRMLS_CC) == SUCCESS) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php.h b/main/php.h
deleted file mode 100644
index f02dade94a..0000000000
--- a/main/php.h
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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 20020918
-#define PHP_HAVE_STREAMS
-#define YYDEBUG 0
-
-#include "php_version.h"
-#include "zend.h"
-#include "zend_qsort.h"
-#include "php_compat.h"
-
-#include "zend_API.h"
-
-#if PHP_BROKEN_SPRINTF
-#undef sprintf
-#define sprintf php_sprintf
-#endif
-
-/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
-#undef PHP_DEBUG
-#define PHP_DEBUG ZEND_DEBUG
-
-#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
-
-#ifdef NETWARE
-/* For php_get_uname() function */
-#define PHP_UNAME "NetWare"
-/*
- * This is obtained using uname(2) on Unix and assigned in the case of Windows;
- * we'll do it this way at least for now.
- */
-#define PHP_OS PHP_UNAME
-#endif
-
-#include "php_regex.h"
-
-#if HAVE_ASSERT_H
-#if PHP_DEBUG
-#undef NDEBUG
-#else
-#ifndef NDEBUG
-#define NDEBUG
-#endif
-#endif
-#include <assert.h>
-#else /* HAVE_ASSERT_H */
-#define assert(expr) ((void) (0))
-#endif /* HAVE_ASSERT_H */
-
-#define APACHE 0
-
-#if HAVE_UNIX_H
-#include <unix.h>
-#endif
-
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
-#if HAVE_BUILD_DEFS_H
-#include "build-defs.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
-
-#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"
-#elif defined(NETWARE)
-#ifdef NEW_LIBC
-#include <sys/param.h>
-#else
-#include "NetWare/param.h"
-#endif
-#include "NetWare/pwd.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) || PHP_BROKEN_SPRINTF || PHP_BROKEN_SNPRINTF || PHP_BROKEN_VSNPRINTF
-#include "snprintf.h"
-#endif
-#include "spprintf.h"
-
-#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
-
-
-/* global variables */
-extern pval *data;
-#if !defined(PHP_WIN32)
-#ifdef NETWARE
-#ifdef NEW_LIBC
-#define php_sleep sleep
-#else /* NEW_LIBC */
-#define php_sleep delay /* sleep() and usleep() are not available */
-#define usleep delay
-#endif /* NEW_LIBC */
-extern char **environ;
-#else /* NETWARE */
-extern char **environ;
-#define php_sleep sleep
-#endif /* NETWARE */
-#endif /* !defined(PHP_WIN32) */
-
-#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
-
-PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC) ;
-
-/* PHPAPI void php_error(int type, const char *format, ...); */
-PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...);
-PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...);
-PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...);
-
-#define php_error_docref php_error_docref0
-
-#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 * TSRMLS_DC) TSRMLS_DC);
-
-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);
-
-
-/* PHP-named Zend macro wrappers */
-#define PHP_FN ZEND_FN
-#define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
-#define PHP_FUNCTION ZEND_FUNCTION
-
-#define PHP_NAMED_FE ZEND_NAMED_FE
-#define PHP_FE ZEND_FE
-#define PHP_FALIAS ZEND_FALIAS
-#define PHP_STATIC_FE ZEND_STATIC_FE
-
-#define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N
-#define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N
-#define PHP_MODULE_ACTIVATE_N ZEND_MODULE_ACTIVATE_N
-#define PHP_MODULE_DEACTIVATE_N ZEND_MODULE_DEACTIVATE_N
-#define PHP_MODULE_INFO_N ZEND_MODULE_INFO_N
-
-#define PHP_MODULE_STARTUP_D ZEND_MODULE_STARTUP_D
-#define PHP_MODULE_SHUTDOWN_D ZEND_MODULE_SHUTDOWN_D
-#define PHP_MODULE_ACTIVATE_D ZEND_MODULE_ACTIVATE_D
-#define PHP_MODULE_DEACTIVATE_D ZEND_MODULE_DEACTIVATE_D
-#define PHP_MODULE_INFO_D ZEND_MODULE_INFO_D
-
-/* Compatibility macros */
-#define PHP_MINIT ZEND_MODULE_STARTUP_N
-#define PHP_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
-#define PHP_RINIT ZEND_MODULE_ACTIVATE_N
-#define PHP_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
-#define PHP_MINFO ZEND_MODULE_INFO_N
-
-#define PHP_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
-#define PHP_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
-#define PHP_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
-#define PHP_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
-#define PHP_MINFO_FUNCTION ZEND_MODULE_INFO_D
-
-
-/* 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
-
-#include "php_streams.h"
-#include "php_memory_streams.h"
-#include "fopen_wrappers.h"
-
-
-/* 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...
- */
-
-#ifndef XtOffset
-#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 */
-#endif /* ! XtOffset */
-
-#ifndef XtOffsetOf
-#ifdef offsetof
-#define XtOffsetOf(s_type, field) offsetof(s_type, field)
-#else
-#define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
-#endif
-#endif /* !XtOffsetOf */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php3_compat.h b/main/php3_compat.h
deleted file mode 100644
index be0758e34d..0000000000
--- a/main/php3_compat.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#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 a9ab40550f..0000000000
--- a/main/php_compat.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_COMPAT_H
-#define PHP_COMPAT_H
-
-#ifdef PHP_WIN32
-#include "config.w32.h"
-#elif defined(NETWARE)
-#include "config.nw.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
-
-/* Define to specify how much context to retain around the current parse
- point. */
-#define XML_CONTEXT_BYTES 1024
-
-/* Define to make parameter entity parsing functionality available. */
-#define XML_DTD 1
-
-/* Define to make XML Namespaces functionality available. */
-#define XML_NS 1
-#endif
-
-#endif
diff --git a/main/php_content_types.c b/main/php_content_types.c
deleted file mode 100644
index 53c241cbe3..0000000000
--- a/main/php_content_types.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $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, NULL, rfc1867_post_handler },
- { NULL, 0, NULL, NULL }
-};
-/* }}} */
-
-/* {{{ SAPI_POST_READER_FUNC
- */
-SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
-{
- char *data = NULL;
- int length = 0;
-
- /* $HTTP_RAW_POST_DATA registration */
- if(!strcmp(SG(request_info).request_method, "POST")) {
- if(NULL == SG(request_info).post_entry) {
- /* no post handler registered, so we just swallow the data */
- sapi_read_standard_form_data(TSRMLS_C);
- length = SG(request_info).post_data_length;
- data = estrndup(SG(request_info).post_data, length);
- } else if(PG(always_populate_raw_post_data) && SG(request_info).post_data) {
- length = SG(request_info).post_data_length;
- data = estrndup(SG(request_info).post_data, length);
- }
- if(data) {
- SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length);
- }
- }
-
- /* for php://input stream:
- some post handlers modify the content of request_info.post_data
- so for now we need a copy for the php://input stream
- in the long run post handlers should be changed to not touch
- request_info.post_data for memory preservation reasons
- */
- if(SG(request_info).post_data) {
- SG(request_info).raw_post_data = estrndup(SG(request_info).post_data, SG(request_info).post_data_length);
- SG(request_info).raw_post_data_length = 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);
- sapi_register_treat_data(php_default_treat_data);
- sapi_register_input_filter(php_default_input_filter);
- return SUCCESS;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_content_types.h b/main/php_content_types.h
deleted file mode 100644
index 27f8c3fe62..0000000000
--- a/main/php_content_types.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_CONTENT_TYPES_H
-#define PHP_CONTENT_TYPES_H
-
-#define DEFAULT_POST_CONTENT_TYPE "application/x-www-form-urlencoded"
-
-SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader);
-SAPI_API 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 122fea904b..0000000000
--- a/main/php_globals.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#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 safe_mode;
-
- zend_bool allow_call_time_pass_reference;
- zend_bool implicit_flush;
-
- int output_buffering;
-
- char *safe_mode_include_dir;
- zend_bool safe_mode_gid;
- zend_bool sql_safe_mode;
- zend_bool enable_dl;
-
- char *output_handler;
-
- char *unserialize_callback_func;
-
- char *safe_mode_exec_dir;
-
- long memory_limit;
- long max_input_time;
-
- zend_bool track_errors;
- zend_bool display_errors;
- zend_bool display_startup_errors;
- zend_bool log_errors;
- long log_errors_max_len;
- zend_bool ignore_repeated_errors;
- zend_bool ignore_repeated_source;
- zend_bool report_memleaks;
- 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;
-
- char *docref_root;
- char *docref_ext;
-
- 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;
-
- zend_bool report_zend_debug;
-};
-
-
-#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 6d845719bc..0000000000
--- a/main/php_ini.c
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* Check CWD for php.ini */
-#define INI_CHECK_CWD
-
-#include "php.h"
-#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"
-#include "SAPI.h"
-#include "php_main.h"
-#include "php_scandir.h"
-
-#if HAVE_SCANDIR && HAVE_ALPHASORT && HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
-#endif
-
-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;
-PHPAPI char *php_ini_scanned_files=NULL;
-
-/* {{{ 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;
- TSRMLS_FETCH();
-
- if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
- if (ini_entry->orig_value && ini_entry->orig_value[0]) {
- display_string = ini_entry->orig_value;
- display_string_length = ini_entry->orig_value_length;
- esc_html = 1;
- } else {
- if (PG(html_errors)) {
- display_string = "<i>no value</i>";
- display_string_length = sizeof("<i>no value</i>") - 1;
- } else {
- display_string = "no value";
- display_string_length = sizeof("no value") - 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 {
- if (PG(html_errors)) {
- display_string = "<i>no value</i>";
- display_string_length = sizeof("<i>no value</i>") - 1;
- } else {
- display_string = "no value";
- display_string_length = sizeof("no value") - 1;
- }
- }
-
- if (esc_html) {
- php_html_puts(display_string, display_string_length TSRMLS_CC);
- } else {
- 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;
- }
- if (PG(html_errors)) {
- PUTS("<tr>");
- PUTS("<td class=\"e\">");
- PHPWRITE(ini_entry->name, ini_entry->name_length - 1);
- PUTS("</td><td class=\"v\">");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
- PUTS("</td><td class=\"v\">");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
- PUTS("</td></tr>\n");
- } else {
- PHPWRITE(ini_entry->name, ini_entry->name_length - 1);
- PUTS(" => ");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
- PUTS(" => ");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
- PUTS("\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 (Z_TYPE_P(pvalue) == IS_STRING && Z_STRVAL_P(pvalue) != empty_string) {
- free(Z_STRVAL_P(pvalue));
- }
-}
-/* }}} */
-
-/* {{{ 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);
- copy.refcount = 0;
- zend_llist_add_element(&extension_lists.functions, &copy);
- } 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_POP_ENTRY: {
- zval *hash;
- zval **find_hash;
- zval *element;
-
- if (!arg2) {
- /* bare string - nothing to do */
- break;
- }
-
- if (zend_hash_find(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, (void **) &find_hash) == FAILURE) {
- ALLOC_ZVAL(hash);
- array_init(hash);
-
- zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, &hash, sizeof(zval *), NULL);
- } else {
- hash = *find_hash;
- }
-
- ALLOC_ZVAL(element);
- *element = *arg2;
- zval_copy_ctor(element);
- INIT_PZVAL(element);
- add_next_index_zval(hash, element);
- }
- 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 *env_location, *php_ini_search_path;
- char *binary_location;
- int safe_mode_state;
- char *open_basedir;
- int free_ini_search_path=0;
- zend_file_handle fh;
- struct stat sb;
- char ini_file[MAXPATHLEN];
- char *p;
- zend_llist scanned_ini_list;
- int l, total_l=0;
- zend_llist_element *element;
- 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(char *), (llist_dtor_func_t) free_estring, 1);
- zend_llist_init(&extension_lists.functions, sizeof(zval), (llist_dtor_func_t) ZVAL_DESTRUCTOR, 1);
- zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
-
- safe_mode_state = PG(safe_mode);
- open_basedir = PG(open_basedir);
-
- env_location = getenv("PHPRC");
- if (!env_location) {
- env_location = "";
- }
- if (sapi_module.php_ini_path_override) {
- php_ini_search_path = sapi_module.php_ini_path_override;
- free_ini_search_path = 0;
- } else {
- char *default_location;
- static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
-
- php_ini_search_path = (char *) emalloc(MAXPATHLEN * 3 + strlen(env_location) + 3 + 1);
- free_ini_search_path = 1;
- php_ini_search_path[0] = 0;
-
- /*
- * Prepare search path
- */
-
- /* Add cwd */
-#ifdef INI_CHECK_CWD
- if (strcmp(sapi_module.name, "cli") != 0) {
- if (*php_ini_search_path) {
- strcat(php_ini_search_path, paths_separator);
- }
- strcat(php_ini_search_path, ".");
- }
-#endif
-
- /* Add binary directory */
-#ifdef PHP_WIN32
- binary_location = (char *) emalloc(MAXPATHLEN);
- if (GetModuleFileName(0, binary_location, MAXPATHLEN) == 0) {
- efree(binary_location);
- binary_location = NULL;
- }
-#else
- if (sapi_module.executable_location) {
- binary_location = estrdup(sapi_module.executable_location);
- } else {
- binary_location = NULL;
- }
-#endif
- if (binary_location) {
- char *separator_location = strrchr(binary_location, DEFAULT_SLASH);
-
- if (separator_location) {
- *(separator_location+1) = 0;
- }
- if (*php_ini_search_path) {
- strcat(php_ini_search_path, paths_separator);
- }
- strcat(php_ini_search_path, binary_location);
- efree(binary_location);
- }
-
- /* Add environment location */
- if (env_location[0]) {
- if (*php_ini_search_path) {
- strcat(php_ini_search_path, paths_separator);
- }
- strcat(php_ini_search_path, env_location);
- }
-
- /* Add default location */
-#ifdef PHP_WIN32
- default_location = (char *) emalloc(MAXPATHLEN + 1);
-
- if (0 < GetWindowsDirectory(default_location, MAXPATHLEN)) {
- if (*php_ini_search_path) {
- strcat(php_ini_search_path, paths_separator);
- }
- strcat(php_ini_search_path, default_location);
- }
- efree(default_location);
-#else
- default_location = PHP_CONFIG_FILE_PATH;
- if (*php_ini_search_path) {
- strcat(php_ini_search_path, paths_separator);
- }
- strcat(php_ini_search_path, default_location);
-#endif
- }
-
- PG(safe_mode) = 0;
- PG(open_basedir) = NULL;
-
- memset(&fh, 0, sizeof(fh));
- /* Check if php_ini_path_override is a file */
- if (!sapi_module.php_ini_ignore) {
- if (sapi_module.php_ini_path_override && sapi_module.php_ini_path_override[0]) {
- struct stat statbuf;
-
- if (!VCWD_STAT(sapi_module.php_ini_path_override, &statbuf)) {
- if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) {
- fh.handle.fp = VCWD_FOPEN(sapi_module.php_ini_path_override, "r");
- fh.filename = sapi_module.php_ini_path_override;
- }
- }
- }
- /* Search php-%sapi-module-name%.ini file in search path */
- if (!fh.handle.fp) {
- const char *fmt = "php-%s.ini";
- char *ini_fname = emalloc(strlen(fmt) + strlen(sapi_module.name));
- sprintf(ini_fname, fmt, sapi_module.name);
- fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
- efree(ini_fname);
- if (fh.handle.fp) {
- fh.filename = php_ini_opened_path;
- }
- }
- /* Search php.ini file in search path */
- if (!fh.handle.fp) {
- fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
- if (fh.handle.fp) {
- fh.filename = php_ini_opened_path;
- }
- }
- }
-
- 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) {
- fh.type = ZEND_HANDLE_FP;
-
- zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
-
- {
- zval tmp;
-
- Z_STRLEN(tmp) = strlen(fh.filename);
- Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp));
- Z_TYPE(tmp) = IS_STRING;
- zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL);
- if (php_ini_opened_path) {
- efree(php_ini_opened_path);
- }
- php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
- }
- }
-
- /* If the config_file_scan_dir is set at compile-time, go and scan this directory and
- * parse any .ini files found in this directory. */
- if (!sapi_module.php_ini_ignore && strlen(PHP_CONFIG_FILE_SCAN_DIR)) {
- struct dirent **namelist;
- int ndir, i;
-
- if ((ndir = php_scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0, php_alphasort)) > 0) {
- for (i = 0; i < ndir; i++) {
- /* check for a .ini extension */
- if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
- free(namelist[i]);
- continue;
- }
- snprintf(ini_file, MAXPATHLEN, "%s%c%s", PHP_CONFIG_FILE_SCAN_DIR, DEFAULT_SLASH, namelist[i]->d_name);
- if (VCWD_STAT(ini_file, &sb) == 0) {
- if (S_ISREG(sb.st_mode)) {
- if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
- fh.filename = ini_file;
- zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
- /* Here, add it to the list of ini files read */
- l = strlen(ini_file);
- total_l += l + 2;
- p = estrndup(ini_file, l);
- zend_llist_add_element(&scanned_ini_list, &p);
- }
- }
- }
- free(namelist[i]);
- }
- free(namelist);
-
- /*
- * Don't need an extra byte for the \0 in this malloc as the last
- * element will not get a trailing , which gives us the byte for the \0
- */
- php_ini_scanned_files = (char *) malloc(total_l);
- *php_ini_scanned_files = '\0';
- for (element = scanned_ini_list.head; element; element = element->next) {
- strcat(php_ini_scanned_files, *(char **)element->data);
- strcat(php_ini_scanned_files, element->next ? ",\n" : "\n");
- }
- zend_llist_destroy(&scanned_ini_list);
- }
- }
- 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);
- }
- if (php_ini_scanned_files) {
- free(php_ini_scanned_files);
- }
- 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 = Z_LVAL(var);
- 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 = Z_DVAL(var);
- 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 = Z_STRVAL_P(tmp);
- return SUCCESS;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * indent-tabs-mode: t
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_ini.h b/main/php_ini.h
deleted file mode 100644
index 352b37ef7f..0000000000
--- a/main/php_ini.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_INI_H
-#define PHP_INI_H
-
-#include "zend_ini.h"
-
-int php_init_config();
-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 56c32ede00..0000000000
--- a/main/php_logos.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Hartmut Holzgraefe <hholzgra@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_logos.h b/main/php_logos.h
deleted file mode 100644
index 31e3b234c8..0000000000
--- a/main/php_logos.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-
-#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 9c5e6c0d03..0000000000
--- a/main/php_main.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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, zend_module_entry *additional_modules, uint num_additional_modules);
-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_request_startup_for_hook(TSRMLS_D);
-
-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_execute_simple_script(zend_file_handle *primary_file, zval **ret 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);
-
-PHPAPI void php_html_puts(const char *str, uint siz TSRMLS_DC);
-
-extern void php_call_shutdown_functions(void);
-
-/* environment module */
-extern int php_init_environ(void);
-extern int php_shutdown_environ(void);
-
-#endif
diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h
deleted file mode 100644
index 5d8c452ad0..0000000000
--- a/main/php_memory_streams.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Marcus Boerger <helly@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef PHP_MEMORY_STREAM_H
-#define PHP_MEMORY_STREAM_H
-
-#include "php_streams.h"
-
-#define PHP_STREAM_MAX_MEM 2 * 1024 * 1024
-
-#define TEMP_STREAM_DEFAULT 0
-#define TEMP_STREAM_READONLY 1
-
-#define php_stream_memory_create(mode) _php_stream_memory_create((mode) STREAMS_CC TSRMLS_CC)
-#define php_stream_memory_create_rel(mode) _php_stream_memory_create((mode) STREAMS_REL_CC TSRMLS_CC)
-#define php_stream_memory_open(mode, buf, length) _php_stream_memory_open((mode), (buf), (length) STREAMS_CC TSRMLS_CC)
-#define php_stream_memory_get_buffer(stream, length) _php_stream_memory_get_buffer((stream), (length) STREAMS_CC TSRMLS_CC)
-
-#define php_stream_temp_new() php_stream_temp_create(TEMP_STREAM_DEFAULT, PHP_STREAM_MAX_MEM)
-#define php_stream_temp_create(mode, max_memory_usage) _php_stream_temp_create((mode), (max_memory_usage) STREAMS_CC TSRMLS_CC)
-#define php_stream_temp_create_rel(mode, max_memory_usage) _php_stream_temp_create((mode), (max_memory_usage) STREAMS_REL_CC TSRMLS_CC)
-#define php_stream_temp_open(mode, max_memory_usage, buf, length) _php_stream_temp_open((mode), (max_memory_usage), (buf), (length) STREAMS_CC TSRMLS_CC)
-
-
-PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC TSRMLS_DC);
-PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC TSRMLS_DC);
-PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC TSRMLS_DC);
-
-PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC);
-PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC);
-
-extern php_stream_ops php_stream_memory_ops;
-extern php_stream_ops php_stream_temp_ops;
-
-#define PHP_STREAM_IS_MEMORY &php_stream_memory_ops
-#define PHP_STREAM_IS_TEMP &php_stream_temp_ops
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_network.h b/main/php_network.h
deleted file mode 100644
index 57dc41f96c..0000000000
--- a/main/php_network.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: 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
-#else
-# undef closesocket
-# define closesocket close
-#endif
-
-#ifndef HAVE_SHUTDOWN
-#undef shutdown
-#define shutdown(s,n) /* nothing */
-#endif
-
-#ifdef PHP_WIN32
-#define EWOULDBLOCK WSAEWOULDBLOCK
-#define EINPROGRESS WSAEWOULDBLOCK
-# define fsync _commit
-# define ftruncate(a, b) chsize(a, b)
-#endif /* defined(PHP_WIN32) */
-
-#ifdef PHP_WIN32
-#define php_socket_errno() WSAGetLastError()
-#else
-#define php_socket_errno() errno
-#endif
-
-/* like strerror, but caller must efree the returned string,
- * unless buf is not NULL.
- * Also works sensibly for win32 */
-PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize);
-
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-/* These are here, rather than with the win32 counterparts above,
- * since <sys/socket.h> defines them. */
-#ifndef SHUT_RD
-# define SHUT_RD 0
-# define SHUT_WR 1
-# define SHUT_RDWR 2
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-#if HAVE_OPENSSL_EXT
-#include <openssl/ssl.h>
-#endif
-
-#ifdef HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-
-#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 PHP_SOCK_CHUNK_SIZE 8192
-
-#ifdef HAVE_SOCKADDR_STORAGE
-typedef struct sockaddr_storage php_sockaddr_storage;
-#else
-typedef struct {
-#ifdef HAVE_SOCKADDR_LEN
- unsigned char ss_len;
- unsigned char ss_family;
-#else
- unsigned short ss_family;
-#endif
- char info[126];
-} php_sockaddr_storage;
-#endif
-
-PHPAPI int php_network_connect_socket_to_host(const char *host, unsigned short port,
- int socktype, int asynchronous, struct timeval *timeout, char **error_string,
- int *error_code
- TSRMLS_DC);
-
-PHPAPI int php_network_connect_socket(int sockfd,
- const struct sockaddr *addr,
- socklen_t addrlen,
- int asynchronous,
- struct timeval *timeout,
- char **error_string,
- int *error_code);
-
-int php_hostconnect(const char *host, unsigned short port, int socktype, struct timeval *timeout TSRMLS_DC);
-PHPAPI int php_connect_nonb(int sockfd, const struct sockaddr *addr, socklen_t addrlen, struct timeval *timeout);
-
-#ifdef PHP_WIN32
-PHPAPI int php_connect_nonb_win32(SOCKET sockfd, const struct sockaddr *addr, socklen_t addrlen, struct timeval *timeout);
-#endif
-
-void php_any_addr(int family, php_sockaddr_storage *addr, unsigned short port);
-int php_sockaddr_size(php_sockaddr_storage *addr);
-
-struct _php_netstream_data_t {
- int socket;
- char is_blocked;
- struct timeval timeout;
- char timeout_event;
-};
-typedef struct _php_netstream_data_t php_netstream_data_t;
-extern php_stream_ops php_stream_socket_ops;
-extern php_stream_ops php_stream_generic_socket_ops;
-#define PHP_STREAM_IS_SOCKET (&php_stream_socket_ops)
-
-PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, const char *persistent_id STREAMS_DC TSRMLS_DC );
-/* open a connection to a host using php_hostconnect and return a stream */
-PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short port,
- int socktype, struct timeval *timeout, const char *persistent_id STREAMS_DC TSRMLS_DC);
-
-#define php_stream_sock_open_from_socket(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_CC TSRMLS_CC)
-#define php_stream_sock_open_host(host, port, socktype, timeout, persistent) _php_stream_sock_open_host((host), (port), (socktype), (timeout), (persistent) STREAMS_CC TSRMLS_CC)
-
-/* {{{ memory debug */
-#define php_stream_sock_open_from_socket_rel(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_REL_CC TSRMLS_CC)
-#define php_stream_sock_open_host_rel(host, port, socktype, timeout, persistent) _php_stream_sock_open_host((host), (port), (socktype), (timeout), (persistent) STREAMS_REL_CC TSRMLS_CC)
-#define php_stream_sock_open_unix_rel(path, pathlen, persistent, timeval) _php_stream_sock_open_unix((path), (pathlen), (persistent), (timeval) STREAMS_REL_CC TSRMLS_CC)
-
-/* }}} */
-
-#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 acf804b2e4..0000000000
--- a/main/php_open_temporary_file.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#ifdef PHP_WIN32
-#define O_RDONLY _O_RDONLY
-#include "win32/param.h"
-#include "win32/winutil.h"
-#elif defined(NETWARE)
-#ifdef USE_WINSOCK
-/*#include <ws2nlm.h>*/
-#include <novsock2.h>
-#else
-#include <sys/socket.h>
-#endif
-#ifdef NEW_LIBC
-#include <sys/param.h>
-#else
-#include "netware/param.h"
-#endif
-#include "netware/mktemp.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(const 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
-#ifdef NETWARE
- char *file_path = NULL;
-#endif
-
- if (!path) {
- return NULL;
- }
-
- if (!(opened_path = emalloc(MAXPATHLEN))) {
- return NULL;
- }
-
- if (IS_SLASH(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, "r+b");
- } else {
- fp = NULL;
- }
-#elif defined(NETWARE)
- /* Using standard mktemp() implementation for NetWare */
- file_path = mktemp(opened_path);
- if (file_path) {
- fp = VCWD_FOPEN(file_path, "r+b");
- } else {
- fp = NULL;
- }
-#elif defined(HAVE_MKSTEMP)
- fd = mkstemp(opened_path);
- if (fd==-1) {
- fp = NULL;
- } else {
- fp = fdopen(fd, "r+b");
- }
-#else
- if (mktemp(opened_path)) {
- fp = VCWD_FOPEN(opened_path, "r+b");
- } else {
- fp = NULL;
- }
-#endif
- if (!fp || !opened_path_p) {
- efree(opened_path);
- } else {
- *opened_path_p = opened_path;
- }
- return fp;
-}
-/* }}} */
-
-/*
- * Determine where to place temporary files.
- */
-const char* get_temporary_directory()
-{
- /* Cache the chosen temporary directory. */
- static char* temporary_directory;
-
- /* Did we determine the temporary directory already? */
- if (temporary_directory) {
- return temporary_directory;
- }
-
-#ifdef PHP_WIN32
- /* We can't count on the environment variables TEMP or TMP,
- * and so must make the Win32 API call to get the default
- * directory for temporary files. Note this call checks
- * the environment values TMP and TEMP (in order) first.
- */
- {
- char sTemp[MAX_PATH];
- DWORD n = GetTempPath(sizeof(sTemp),sTemp);
- assert(0 < n); /* should *never* fail! */
- temporary_directory = strdup(sTemp);
- return temporary_directory;
- }
-#else
- /* On Unix use the (usual) TMPDIR environment variable. */
- {
- char* s = getenv("TMPDIR");
- if (s) {
- temporary_directory = strdup(s);
- return temporary_directory;
- }
- }
-#ifdef P_tmpdir
- /* Use the standard default temporary directory. */
- if (P_tmpdir) {
- temporary_directory = P_tmpdir;
- return temporary_directory;
- }
-#endif
- /* Shouldn't ever(!) end up here ... last ditch default. */
- temporary_directory = "/tmp";
- return temporary_directory;
-#endif
-}
-
-/* {{{ 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)
-{
- FILE* fp = 0;
-
- if (!pfx) {
- pfx = "tmp.";
- }
- if (opened_path_p) {
- *opened_path_p = NULL;
- }
-
- /* Try the directory given as parameter. */
- fp = php_do_open_temporary_file(dir, pfx, opened_path_p TSRMLS_CC);
- if (fp) {
- return fp;
- }
-
- /* Use default temporary directory. */
- fp = php_do_open_temporary_file(get_temporary_directory(), pfx, opened_path_p TSRMLS_CC);
- if (fp) {
- return fp;
- }
-
- return 0;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_open_temporary_file.h b/main/php_open_temporary_file.h
deleted file mode 100644
index 0342f92ca7..0000000000
--- a/main/php_open_temporary_file.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#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 b5e1b7ad8b..0000000000
--- a/main/php_output.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_OUTPUT_H
-#define PHP_OUTPUT_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);
-PHPAPI 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, zend_bool erase TSRMLS_DC);
-PHPAPI int php_start_ob_buffer_named(const char *output_handler_name, uint chunk_size, zend_bool erase 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, char *handler_name, zend_bool erase TSRMLS_DC);
-PHPAPI int php_ob_handler_used(char *handler_name TSRMLS_DC);
-PHPAPI int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC);
-PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC);
-PHPAPI int php_ob_get_length(zval *p TSRMLS_DC);
-
-PHP_FUNCTION(ob_start);
-PHP_FUNCTION(ob_flush);
-PHP_FUNCTION(ob_clean);
-PHP_FUNCTION(ob_end_flush);
-PHP_FUNCTION(ob_end_clean);
-PHP_FUNCTION(ob_get_flush);
-PHP_FUNCTION(ob_get_clean);
-PHP_FUNCTION(ob_get_contents);
-PHP_FUNCTION(ob_get_length);
-PHP_FUNCTION(ob_get_level);
-PHP_FUNCTION(ob_get_status);
-PHP_FUNCTION(ob_implicit_flush);
-PHP_FUNCTION(ob_list_handlers);
-
-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;
- char *handler_name;
- zend_bool erase;
-} 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)
-
-#define PHP_OUTPUT_HANDLER_INTERNAL 0
-#define PHP_OUTPUT_HANDLER_USER 1
-
-PHP_FUNCTION(output_add_rewrite_var);
-PHP_FUNCTION(output_reset_rewrite_vars);
-
-
-#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 d888c59622..0000000000
--- a/main/php_reentrancy.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Sascha Schumann <sascha@schumann.cx> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#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) || defined(__BEOS__)
-#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 b573745797..0000000000
--- a/main/php_regex.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#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_scandir.c b/main/php_scandir.c
deleted file mode 100644
index 139e1c27cb..0000000000
--- a/main/php_scandir.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Shane Caraveo <shane@caraveo.com> |
- | Ilia Alshanetsky <ilia@prohost.org> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifdef PHP_WIN32
-#include "config.w32.h"
-#else
-#include "php_config.h"
-#endif
-
-#include "php_scandir.h"
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-
-#ifndef HAVE_SCANDIR
-
-#ifdef PHP_WIN32
-#include "win32/readdir.h"
-#endif
-
-#include <stdlib.h>
-#include <search.h>
-
-#endif /* HAVE_SCANDIR */
-
-#ifndef HAVE_ALPHASORT
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-int php_alphasort(const struct dirent **a, const struct dirent **b)
-{
- return strcoll((*a)->d_name,(*b)->d_name);
-}
-#endif /* HAVE_ALPHASORT */
-
-#ifndef HAVE_SCANDIR
-int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b))
-{
- DIR *dirp = NULL;
- struct dirent **vector = NULL;
- struct dirent *dp = NULL;
- int vector_size = 0;
- int nfiles = 0;
-
- if (namelist == NULL) {
- return -1;
- }
-
- if (!(dirp = opendir(dirname))) {
- return -1;
- }
-
- while ((dp = readdir(dirp)) != NULL) {
- int dsize = 0;
- struct dirent *newdp = NULL;
-
- if (selector && (*selector)(dp) == 0) {
- continue;
- }
-
- if (nfiles == vector_size) {
- struct dirent **newv;
- if (vector_size == 0) {
- vector_size = 10;
- } else {
- vector_size *= 2;
- }
-
- newv = (struct dirent **) realloc (vector, vector_size * sizeof (struct dirent *));
- if (!newv) {
- return -1;
- }
- vector = newv;
- }
-
- dsize = sizeof (struct dirent) + ((strlen(dp->d_name) + 1) * sizeof(char));
- newdp = (struct dirent *) malloc(dsize);
-
- if (newdp == NULL) {
- goto fail;
- }
-
- vector[nfiles++] = (struct dirent *) memcpy(newdp, dp, dsize);
- }
-
- closedir(dirp);
-
- *namelist = vector;
-
- if (compare) {
- qsort (*namelist, nfiles, sizeof(struct dirent *), compare);
- }
-
- return nfiles;
-
-fail:
- while (nfiles-- > 0) {
- free(vector[nfiles]);
- }
- free(vector);
- return -1;
-}
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_scandir.h b/main/php_scandir.h
deleted file mode 100644
index 961188e7ad..0000000000
--- a/main/php_scandir.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Shane Caraveo <shane@caraveo.com> |
- | Ilia Alshanetsky <ilia@prohost.org> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_SCANDIR_H
-#define PHP_SCANDIR_H
-
-#include <sys/types.h>
-
-#ifdef PHP_WIN32
-#include "config.w32.h"
-#include "win32/readdir.h"
-#else
-#include "php_config.h"
-#endif
-
-#ifdef HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-
-#ifdef HAVE_SCANDIR
-#define php_scandir scandir
-#else
-int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b));
-#endif
-
-#ifdef HAVE_ALPHASORT
-#define php_alphasort alphasort
-#else
-int php_alphasort(const struct dirent **a, const struct dirent **b);
-#endif
-
-#endif /* PHP_SCANDIR_H */
diff --git a/main/php_sprintf.c b/main/php_sprintf.c
deleted file mode 100644
index e3fdb00531..0000000000
--- a/main/php_sprintf.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Jaakko Hyvätti <jaakko.hyvatti@iki.fi> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include <stdio.h>
-#include <stdarg.h>
-#ifdef NETWARE
-#include "config.nw.h"
-#else
-#include "php_config.h"
-#endif
-
-#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 /* PHP_BROKEN_SPRINTF */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_streams.h b/main/php_streams.h
deleted file mode 100755
index 008bcdb1a4..0000000000
--- a/main/php_streams.h
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong (wez@thebrainroom.com) |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifndef PHP_STREAMS_H
-#define PHP_STREAMS_H
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#include <sys/types.h>
-#include <sys/stat.h>
-
-PHPAPI int php_file_le_stream(void);
-PHPAPI int php_file_le_pstream(void);
-
-/* {{{ Streams memory debugging stuff */
-
-#if ZEND_DEBUG
-/* these have more of a dependency on the definitions of the zend macros than
- * I would prefer, but doing it this way saves loads of idefs :-/ */
-# define STREAMS_D int __php_stream_call_depth ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC
-# define STREAMS_C 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC
-# define STREAMS_REL_C __php_stream_call_depth + 1 ZEND_FILE_LINE_CC, \
- __php_stream_call_depth ? __zend_orig_filename : __zend_filename, \
- __php_stream_call_depth ? __zend_orig_lineno : __zend_lineno
-
-# define STREAMS_DC , STREAMS_D
-# define STREAMS_CC , STREAMS_C
-# define STREAMS_REL_CC , STREAMS_REL_C
-
-#else
-# define STREAMS_D
-# define STREAMS_C
-# define STREAMS_REL_C
-# define STREAMS_DC
-# define STREAMS_CC
-# define STREAMS_REL_CC
-#endif
-
-/* these functions relay the file/line number information. They are depth aware, so they will pass
- * the ultimate ancestor, which is useful, because there can be several layers of calls */
-#define php_stream_alloc_rel(ops, thisptr, persistent, mode) _php_stream_alloc((ops), (thisptr), (persistent), (mode) STREAMS_REL_CC TSRMLS_CC)
-
-#define php_stream_copy_to_mem_rel(src, buf, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_REL_CC TSRMLS_CC)
-
-#define php_stream_fopen_rel(filename, mode, opened, options) _php_stream_fopen((filename), (mode), (opened), (options) STREAMS_REL_CC TSRMLS_CC)
-
-#define php_stream_fopen_with_path_rel(filename, mode, path, opened, options) _php_stream_fopen_with_path((filename), (mode), (path), (opened), (options) STREAMS_REL_CC TSRMLS_CC)
-
-#define php_stream_fopen_from_fd_rel(fd, mode) _php_stream_fopen_from_fd((fd), (mode) STREAMS_REL_CC TSRMLS_CC)
-#define php_stream_fopen_from_file_rel(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_REL_CC TSRMLS_CC)
-
-#define php_stream_fopen_from_pipe_rel(file, mode) _php_stream_fopen_from_pipe((file), (mode) STREAMS_REL_CC TSRMLS_CC)
-
-#define php_stream_fopen_tmpfile_rel() _php_stream_fopen_tmpfile(0 STREAMS_REL_CC TSRMLS_CC)
-
-#define php_stream_fopen_temporary_file_rel(dir, pfx, opened_path) _php_stream_fopen_temporary_file((dir), (pfx), (opened_path) STREAMS_REL_CC TSRMLS_CC)
-
-#define php_stream_open_wrapper_rel(path, mode, options, opened) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), NULL STREAMS_REL_CC TSRMLS_CC)
-#define php_stream_open_wrapper_ex_rel(path, mode, options, opened, context) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), (context) STREAMS_REL_CC TSRMLS_CC)
-
-#define php_stream_make_seekable_rel(origstream, newstream, flags) _php_stream_make_seekable((origstream), (newstream), (flags) STREAMS_REL_CC TSRMLS_CC)
-
-/* }}} */
-
-/* The contents of the php_stream_ops and php_stream should only be accessed
- * using the functions/macros in this header.
- * If you need to get at something that doesn't have an API,
- * drop me a line <wez@thebrainroom.com> and we can sort out a way to do
- * it properly.
- *
- * The only exceptions to this rule are that stream implementations can use
- * the php_stream->abstract pointer to hold their context, and streams
- * opened via stream_open_wrappers can use the zval ptr in
- * php_stream->wrapperdata to hold meta data for php scripts to
- * retrieve using file_get_wrapper_data(). */
-
-typedef struct _php_stream php_stream;
-typedef struct _php_stream_wrapper php_stream_wrapper;
-typedef struct _php_stream_context php_stream_context;
-typedef struct _php_stream_filter php_stream_filter;
-
-#include "streams/php_stream_context.h"
-#include "streams/php_stream_filter_api.h"
-
-typedef struct _php_stream_statbuf {
-#if defined(NETWARE) && defined(CLIB_STAT_PATCH)
- struct stat_libc sb; /* regular info */
-#else
- struct stat sb; /* regular info */
-#endif
- /* extended info to go here some day: content-type etc. etc. */
-} php_stream_statbuf;
-
-typedef struct _php_stream_dirent {
- char d_name[MAXPATHLEN];
-} php_stream_dirent;
-
-/* operations on streams that are file-handles */
-typedef struct _php_stream_ops {
- /* stdio like functions - these are mandatory! */
- size_t (*write)(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
- size_t (*read)(php_stream *stream, char *buf, size_t count TSRMLS_DC);
- int (*close)(php_stream *stream, int close_handle TSRMLS_DC);
- int (*flush)(php_stream *stream TSRMLS_DC);
-
- const char *label; /* label for this ops structure */
-
- /* these are optional */
- int (*seek)(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
- int (*cast)(php_stream *stream, int castas, void **ret TSRMLS_DC);
- int (*stat)(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
- int (*set_option)(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC);
-} php_stream_ops;
-
-typedef struct _php_stream_wrapper_ops {
- /* open/create a wrapped stream */
- php_stream *(*stream_opener)(php_stream_wrapper *wrapper, char *filename, char *mode,
- int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
- /* close/destroy a wrapped stream */
- int (*stream_closer)(php_stream_wrapper *wrapper, php_stream *stream TSRMLS_DC);
- /* stat a wrapped stream */
- int (*stream_stat)(php_stream_wrapper *wrapper, php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
- /* stat a URL */
- int (*url_stat)(php_stream_wrapper *wrapper, char *url, php_stream_statbuf *ssb TSRMLS_DC);
- /* open a "directory" stream */
- php_stream *(*dir_opener)(php_stream_wrapper *wrapper, char *filename, char *mode,
- int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
-
- const char *label;
-} php_stream_wrapper_ops;
-
-struct _php_stream_wrapper {
- php_stream_wrapper_ops *wops; /* operations the wrapper can perform */
- void *abstract; /* context for the wrapper */
- int is_url; /* so that PG(allow_url_fopen) can be respected */
-
- /* support for wrappers to return (multiple) error messages to the stream opener */
- int err_count;
- char **err_stack;
-};
-
-#define PHP_STREAM_FLAG_NO_SEEK 1
-#define PHP_STREAM_FLAG_NO_BUFFER 2
-
-#define PHP_STREAM_FLAG_EOL_UNIX 0 /* also includes DOS */
-#define PHP_STREAM_FLAG_DETECT_EOL 4
-#define PHP_STREAM_FLAG_EOL_MAC 8
-
-/* set this when the stream might represent "interactive" data.
- * When set, the read buffer will avoid certain operations that
- * might otherwise cause the read to block for much longer than
- * is strictly required. */
-#define PHP_STREAM_FLAG_AVOID_BLOCKING 16
-
-struct _php_stream {
- php_stream_ops *ops;
- void *abstract; /* convenience pointer for abstraction */
-
- php_stream_filter_chain readfilters, writefilters;
-
- php_stream_wrapper *wrapper; /* which wrapper was used to open the stream */
- void *wrapperthis; /* convenience pointer for a instance of a wrapper */
- zval *wrapperdata; /* fgetwrapperdata retrieves this */
-
- int fgetss_state; /* for fgetss to handle multiline tags */
- int is_persistent;
- char mode[16]; /* "rwb" etc. ala stdio */
- int rsrc_id; /* used for auto-cleanup */
- int in_free; /* to prevent recursion during free */
- /* 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! */
-#if ZEND_DEBUG
- int __exposed; /* non-zero if exposed as a zval somewhere */
- char *__orig_path; /* it really helps when debugging "unclosed" streams */
-#endif
-
- php_stream_context *context;
- int flags; /* PHP_STREAM_FLAG_XXX */
-
- /* buffer */
- off_t position; /* of underlying stream */
- unsigned char *readbuf;
- size_t readbuflen;
- off_t readpos;
- off_t writepos;
-
- /* how much data to read when filling buffer */
- size_t chunk_size;
-
- int eof;
-
-}; /* php_stream */
-/* state definitions when closing down; these are private to streams.c */
-#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,
- const char *persistent_id, const char *mode STREAMS_DC TSRMLS_DC);
-#define php_stream_alloc(ops, thisptr, persistent_id, mode) _php_stream_alloc((ops), (thisptr), (persistent_id), (mode) STREAMS_CC TSRMLS_CC)
-
-
-#define php_stream_get_resource_id(stream) (stream)->rsrc_id
-#if ZEND_DEBUG
-/* use this to tell the stream that it is OK if we don't explicitly close it */
-# define php_stream_auto_cleanup(stream) { (stream)->__exposed++; }
-/* use this to assign the stream to a zval and tell the stream that is
- * has been exported to the engine; it will expect to be closed automatically
- * when the resources are auto-destructed */
-# define php_stream_to_zval(stream, zval) { ZVAL_RESOURCE(zval, (stream)->rsrc_id); (stream)->__exposed++; }
-#else
-# define php_stream_auto_cleanup(stream) /* nothing */
-# define php_stream_to_zval(stream, zval) { ZVAL_RESOURCE(zval, (stream)->rsrc_id); }
-#endif
-
-#define php_stream_from_zval(xstr, ppzval) ZEND_FETCH_RESOURCE2((xstr), php_stream *, (ppzval), -1, "stream", php_file_le_stream(), php_file_le_pstream())
-#define php_stream_from_zval_no_verify(xstr, ppzval) (xstr) = (php_stream*)zend_fetch_resource((ppzval) TSRMLS_CC, -1, "stream", NULL, 2, php_file_le_stream(), php_file_le_pstream())
-
-PHPAPI int php_stream_from_persistent_id(const char *persistent_id, php_stream **stream TSRMLS_DC);
-#define PHP_STREAM_PERSISTENT_SUCCESS 0 /* id exists */
-#define PHP_STREAM_PERSISTENT_FAILURE 1 /* id exists but is not a stream! */
-#define PHP_STREAM_PERSISTENT_NOT_EXIST 2 /* id does not exist */
-
-#define PHP_STREAM_FREE_CALL_DTOR 1 /* call ops->close */
-#define PHP_STREAM_FREE_RELEASE_STREAM 2 /* pefree(stream) */
-#define PHP_STREAM_FREE_PRESERVE_HANDLE 4 /* tell ops->close to not close it's underlying handle */
-#define PHP_STREAM_FREE_RSRC_DTOR 8 /* called from the resource list dtor */
-#define PHP_STREAM_FREE_CLOSE (PHP_STREAM_FREE_CALL_DTOR | PHP_STREAM_FREE_RELEASE_STREAM)
-#define PHP_STREAM_FREE_CLOSE_CASTED (PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_PRESERVE_HANDLE)
-PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC);
-#define php_stream_free(stream, close_options) _php_stream_free((stream), (close_options) TSRMLS_CC)
-#define php_stream_close(stream) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE TSRMLS_CC)
-
-PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC);
-#define php_stream_rewind(stream) _php_stream_seek((stream), 0L, SEEK_SET TSRMLS_CC)
-#define php_stream_seek(stream, offset, whence) _php_stream_seek((stream), (offset), (whence) TSRMLS_CC)
-
-PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC);
-#define php_stream_tell(stream) _php_stream_tell((stream) TSRMLS_CC)
-
-PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC);
-#define php_stream_read(stream, buf, count) _php_stream_read((stream), (buf), (count) TSRMLS_CC)
-
-PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
-#define php_stream_write_string(stream, str) _php_stream_write(stream, str, strlen(str) TSRMLS_CC)
-#define php_stream_write(stream, buf, count) _php_stream_write(stream, (buf), (count) TSRMLS_CC)
-
-PHPAPI size_t _php_stream_printf(php_stream *stream TSRMLS_DC, const char *fmt, ...);
-/* php_stream_printf macro & function require TSRMLS_CC */
-#define php_stream_printf _php_stream_printf
-
-PHPAPI int _php_stream_eof(php_stream *stream TSRMLS_DC);
-#define php_stream_eof(stream) _php_stream_eof((stream) TSRMLS_CC)
-
-PHPAPI int _php_stream_getc(php_stream *stream TSRMLS_DC);
-#define php_stream_getc(stream) _php_stream_getc((stream) TSRMLS_CC)
-
-PHPAPI int _php_stream_putc(php_stream *stream, int c TSRMLS_DC);
-#define php_stream_putc(stream, c) _php_stream_putc((stream), (c) TSRMLS_CC)
-
-PHPAPI int _php_stream_flush(php_stream *stream, int closing TSRMLS_DC);
-#define php_stream_flush(stream) _php_stream_flush((stream), 0 TSRMLS_CC)
-
-PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen, size_t *returned_len TSRMLS_DC);
-#define php_stream_gets(stream, buf, maxlen) _php_stream_get_line((stream), (buf), (maxlen), NULL TSRMLS_CC)
-
-#define php_stream_get_line(stream, buf, maxlen, retlen) _php_stream_get_line((stream), (buf), (maxlen), (retlen) TSRMLS_CC)
-PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *returned_len, char *delim, size_t delim_len TSRMLS_DC);
-
-/* CAREFUL! this is equivalent to puts NOT fputs! */
-PHPAPI int _php_stream_puts(php_stream *stream, char *buf TSRMLS_DC);
-#define php_stream_puts(stream, buf) _php_stream_puts((stream), (buf) TSRMLS_CC)
-
-PHPAPI int _php_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
-#define php_stream_stat(stream, ssb) _php_stream_stat((stream), (ssb) TSRMLS_CC)
-
-PHPAPI int _php_stream_stat_path(char *path, php_stream_statbuf *ssb TSRMLS_DC);
-#define php_stream_stat_path(path, ssb) _php_stream_stat_path((path), (ssb) TSRMLS_CC)
-
-PHPAPI php_stream *_php_stream_opendir(char *path, int options, php_stream_context *context STREAMS_DC TSRMLS_DC);
-#define php_stream_opendir(path, options, context) _php_stream_opendir((path), (options), (context) STREAMS_CC TSRMLS_CC)
-PHPAPI php_stream_dirent *_php_stream_readdir(php_stream *dirstream, php_stream_dirent *ent TSRMLS_DC);
-#define php_stream_readdir(dirstream, dirent) _php_stream_readdir((dirstream), (dirent) TSRMLS_CC)
-#define php_stream_closedir(dirstream) php_stream_close((dirstream))
-#define php_stream_rewinddir(dirstream) php_stream_rewind((dirstream))
-
-PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC);
-#define php_stream_set_option(stream, option, value, ptrvalue) _php_stream_set_option((stream), (option), (value), (ptrvalue) TSRMLS_CC)
-
-#define php_stream_set_chunk_size(stream, size) _php_stream_set_option((stream), PHP_STREAM_OPTION_SET_CHUNK_SIZE, (size), NULL TSRMLS_CC)
-
-/* change the blocking mode of stream: value == 1 => blocking, value == 0 => non-blocking. */
-#define PHP_STREAM_OPTION_BLOCKING 1
-
-/* change the buffering mode of stream. value is a PHP_STREAM_BUFFER_XXXX value, ptrparam is a ptr to a size_t holding
- * the required buffer size */
-#define PHP_STREAM_OPTION_READ_BUFFER 2
-#define PHP_STREAM_OPTION_WRITE_BUFFER 3
-
-#define PHP_STREAM_BUFFER_NONE 0 /* unbuffered */
-#define PHP_STREAM_BUFFER_LINE 1 /* line buffered */
-#define PHP_STREAM_BUFFER_FULL 2 /* fully buffered */
-
-/* set the timeout duration for reads on the stream. ptrparam is a pointer to a struct timeval * */
-#define PHP_STREAM_OPTION_READ_TIMEOUT 4
-#define PHP_STREAM_OPTION_SET_CHUNK_SIZE 5
-
-/* set or release lock on a stream */
-#define PHP_STREAM_OPTION_LOCKING 6
-
-/* whether or not locking is supported */
-#define PHP_STREAM_LOCK_SUPPORTED 1
-
-#define php_stream_supports_lock(stream) _php_stream_set_option((stream), PHP_STREAM_OPTION_LOCKING, 0, (void *) PHP_STREAM_LOCK_SUPPORTED TSRMLS_CC) == 0 ? 1 : 0
-#define php_stream_lock(stream, mode) _php_stream_set_option((stream), PHP_STREAM_OPTION_LOCKING, (mode), (void *) NULL TSRMLS_CC)
-
-/* option code used by the php_stream_xport_XXX api */
-#define PHP_STREAM_OPTION_XPORT_API 7 /* see php_stream_transport.h */
-#define PHP_STREAM_OPTION_CRYPTO_API 8 /* see php_stream_transport.h */
-#define PHP_STREAM_OPTION_MMAP_API 9 /* see php_stream_mmap.h */
-#define PHP_STREAM_OPTION_TRUNCATE_API 10
-
-#define PHP_STREAM_TRUNCATE_SUPPORTED 0
-#define PHP_STREAM_TRUNCATE_SET_SIZE 1 /* ptrparam is a pointer to a size_t */
-
-#define php_stream_truncate_supported(stream) (_php_stream_set_option((stream), PHP_STREAM_OPTION_TRUNCATE_API, PHP_STREAM_TRUNCATE_SUPPORTED, NULL TSRMLS_CC) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0)
-
-PHPAPI int _php_stream_truncate_set_size(php_stream *stream, size_t newsize TSRMLS_DC);
-#define php_stream_truncate_set_size(stream, size) _php_stream_truncate_set_size((stream), (size) TSRMLS_CC)
-
-#define PHP_STREAM_OPTION_RETURN_OK 0 /* option set OK */
-#define PHP_STREAM_OPTION_RETURN_ERR -1 /* problem setting option */
-#define PHP_STREAM_OPTION_RETURN_NOTIMPL -2 /* underlying stream does not implement; streams can handle it instead */
-
-/* copy up to maxlen bytes from src to dest. If maxlen is PHP_STREAM_COPY_ALL, copy until eof(src).
- * Uses mmap if the src is a plain file and at offset 0 */
-#define PHP_STREAM_COPY_ALL -1
-PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC TSRMLS_DC);
-#define php_stream_copy_to_stream(src, dest, maxlen) _php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC TSRMLS_CC)
-
-
-/* read all data from stream and put into a buffer. Caller must free buffer when done.
- * The copy will use mmap if available. */
-PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen,
- int persistent STREAMS_DC TSRMLS_DC);
-#define php_stream_copy_to_mem(src, buf, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_CC TSRMLS_CC)
-
-/* output all data from a stream */
-PHPAPI size_t _php_stream_passthru(php_stream * src STREAMS_DC TSRMLS_DC);
-#define php_stream_passthru(stream) _php_stream_passthru((stream) STREAMS_CC TSRMLS_CC)
-
-#include "streams/php_stream_transport.h"
-#include "streams/php_stream_plain_wrapper.h"
-#include "streams/php_stream_userspace.h"
-#include "streams/php_stream_mmap.h"
-
-/* 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
-
-/* try really, really hard to make sure the cast happens (avoid using this flag if possible) */
-#define PHP_STREAM_CAST_TRY_HARD 0x80000000
-#define PHP_STREAM_CAST_RELEASE 0x40000000 /* stream becomes invalid on success */
-#define PHP_STREAM_CAST_INTERNAL 0x20000000 /* stream cast for internal use */
-#define PHP_STREAM_CAST_MASK (PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE | PHP_STREAM_CAST_INTERNAL)
-PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err TSRMLS_DC);
-/* 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 TSRMLS_CC)
-#define php_stream_cast(stream, as, ret, show_err) _php_stream_cast((stream), (as), (ret), (show_err) TSRMLS_CC)
-
-/* 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)
-#define PHP_STREAM_IS_STDIO &php_stream_stdio_ops
-
-#define php_stream_is_persistent(stream) (stream)->is_persistent
-
-/* Wrappers support */
-
-#define IGNORE_PATH 0
-#define USE_PATH 1
-#define IGNORE_URL 2
-#define ENFORCE_SAFE_MODE 4
-#define REPORT_ERRORS 8
-/* If you don't need to write to the stream, but really need to
- * be able to seek, use this flag in your options. */
-#define STREAM_MUST_SEEK 16
-/* If you are going to end up casting the stream into a FILE* or
- * a socket, pass this flag and the streams/wrappers will not use
- * buffering mechanisms while reading the headers, so that HTTP
- * wrapped streams will work consistently.
- * If you omit this flag, streams will use buffering and should end
- * up working more optimally.
- * */
-#define STREAM_WILL_CAST 32
-
-/* this flag applies to php_stream_locate_url_wrapper */
-#define STREAM_LOCATE_WRAPPERS_ONLY 64
-
-/* this flag is only used by include/require functions */
-#define STREAM_OPEN_FOR_INCLUDE 128
-
-/* this flag tells streams to ONLY open urls */
-#define STREAM_USE_URL 256
-
-/* this flag is used when only the headers from HTTP request are to be fetched */
-#define STREAM_ONLY_GET_HEADERS 512
-
-/* don't apply open_basedir checks */
-#define STREAM_DISABLE_OPEN_BASEDIR 1024
-
-/* Antique - no longer has meaning */
-#define IGNORE_URL_WIN 0
-
-int php_init_stream_wrappers(int module_number TSRMLS_DC);
-int php_shutdown_stream_wrappers(int module_number TSRMLS_DC);
-PHP_RSHUTDOWN_FUNCTION(streams);
-
-PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC);
-PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC);
-PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
-PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char **path_for_open, int options TSRMLS_DC);
-PHPAPI char *php_stream_locate_eol(php_stream *stream, char *buf, size_t buf_len TSRMLS_DC);
-
-#define php_stream_open_wrapper(path, mode, options, opened) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), NULL STREAMS_CC TSRMLS_CC)
-#define php_stream_open_wrapper_ex(path, mode, options, opened, context) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), (context) STREAMS_CC TSRMLS_CC)
-
-/* pushes an error message onto the stack for a wrapper instance */
-PHPAPI void php_stream_wrapper_log_error(php_stream_wrapper *wrapper, int options TSRMLS_DC, const char *fmt, ...);
-
-
-#define PHP_STREAM_UNCHANGED 0 /* orig stream was seekable anyway */
-#define PHP_STREAM_RELEASED 1 /* newstream should be used; origstream is no longer valid */
-#define PHP_STREAM_FAILED 2 /* an error occurred while attempting conversion */
-#define PHP_STREAM_CRITICAL 3 /* an error occurred; origstream is in an unknown state; you should close origstream */
-#define PHP_STREAM_NO_PREFERENCE 0
-#define PHP_STREAM_PREFER_STDIO 1
-#define PHP_STREAM_FORCE_CONVERSION 2
-/* DO NOT call this on streams that are referenced by resources! */
-PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream, int flags STREAMS_DC TSRMLS_DC);
-#define php_stream_make_seekable(origstream, newstream, flags) _php_stream_make_seekable((origstream), (newstream), (flags) STREAMS_CC TSRMLS_CC)
-
-/* Give other modules access to the url_stream_wrappers_hash and stream_filters_hash */
-PHPAPI HashTable *php_stream_get_url_stream_wrappers_hash();
-PHPAPI HashTable *php_get_stream_filters_hash();
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_syslog.h b/main/php_syslog.h
deleted file mode 100644
index e3adf00f31..0000000000
--- a/main/php_syslog.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_SYSLOG_H
-#define PHP_SYSLOG_H
-
-#ifdef PHP_WIN32
-#include "win32/syslog.h"
-#elif defined(NETWARE)
-# include "config.nw.h"
-#ifdef HAVE_SYSLOG_H
-#include <syslog.h>
-#endif
-#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 b8bfc4e1e0..0000000000
--- a/main/php_ticks.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: 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), (void *)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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_ticks.h b/main/php_ticks.h
deleted file mode 100644
index cf752fa4af..0000000000
--- a/main/php_ticks.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: 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 cb354c7dcd..0000000000
--- a/main/php_variables.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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"
-
-/* for systems that need to override reading of environment variables */
-void _php_import_environment_variables(zval *array_ptr TSRMLS_DC);
-PHPAPI void (*php_import_environment_variables)(zval *array_ptr TSRMLS_DC) = _php_import_environment_variables;
-
-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;
- assert(strval != NULL);
-
- /* Prepare value */
- Z_STRLEN(new_entry) = str_len;
- if (PG(magic_quotes_gpc)) {
- Z_STRVAL(new_entry) = php_addslashes(strval, Z_STRLEN(new_entry), &Z_STRLEN(new_entry), 0 TSRMLS_CC);
- } else {
- Z_STRVAL(new_entry) = estrndup(strval, Z_STRLEN(new_entry));
- }
- Z_TYPE(new_entry) = 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;
- HashTable *symtable1=NULL;
- HashTable *symtable2=NULL;
-
- assert(var != NULL);
-
- if (track_vars_array) {
- symtable1 = Z_ARRVAL_P(track_vars_array);
- }
- if (PG(register_globals)) {
- if (symtable1) {
- symtable2 = EG(active_symbol_table);
- } else {
- symtable1 = EG(active_symbol_table);
- }
- }
- 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;
-
- while (1) {
- if (is_array) {
- char *escaped_index = NULL, *index_s;
- int new_idx_len = 0;
-
- ip++;
- index_s = ip;
- if (isspace(*ip)) {
- ip++;
- }
- if (*ip==']') {
- index_s = NULL;
- } else {
- ip = strchr(ip, ']');
- if (!ip) {
- /* PHP variables cannot contain '[' in their names, so we replace the character with a '_' */
- *(index_s - 1) = '_';
- index_len = var_len = strlen(var);
- goto plain_var;
- return;
- }
- *ip = 0;
- new_idx_len = strlen(index_s);
- }
-
- 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
- || Z_TYPE_PP(gpc_element_p) != 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 = Z_ARRVAL_PP(gpc_element_p);
- /* ip pointed to the '[' character, now obtain the key */
- index = index_s;
- index_len = new_idx_len;
-
- ip++;
- if (*ip=='[') {
- is_array = 1;
- *ip = 0;
- } else {
- is_array = 0;
- }
- } else {
-plain_var:
- MAKE_STD_ZVAL(gpc_element);
- gpc_element->value = val->value;
- Z_TYPE_P(gpc_element) = Z_TYPE_P(val);
- 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_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
-{
- char *var, *val;
- char *strtok_buf = NULL;
- zval *array_ptr = (zval *) arg;
-
- if (SG(request_info).post_data==NULL) {
- return;
- }
-
- 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));
- val_len = sapi_module.input_filter(PARSE_POST, var, &val, val_len TSRMLS_CC);
- php_register_variable_safe(var, val, val_len, array_ptr TSRMLS_CC);
- }
- var = php_strtok_r(NULL, "&", &strtok_buf);
- }
-}
-
-SAPI_API SAPI_INPUT_FILTER_FUNC(php_default_input_filter)
-{
- /* TODO: check .ini setting here and apply user-defined input filter */
- return val_len;
-}
-
-SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
-{
- 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));
- val_len = sapi_module.input_filter(arg, var, &val, val_len TSRMLS_CC);
- php_register_variable_safe(var, val, val_len, array_ptr TSRMLS_CC);
- } else {
- php_url_decode(var, strlen(var));
- php_register_variable_safe(var, "", 0, 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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_variables.h b/main/php_variables.h
deleted file mode 100644
index 77fed233c2..0000000000
--- a/main/php_variables.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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);
-extern 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 3d13b2abe6..0000000000
--- a/main/php_version.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* automatically generated by configure */
-/* edit configure.in to change version number */
-#define PHP_MAJOR_VERSION 5
-#define PHP_MINOR_VERSION 0
-#define PHP_RELEASE_VERSION 0
-#define PHP_EXTRA_VERSION "-dev"
-#define PHP_VERSION "5.0.0-dev"
diff --git a/main/reentrancy.c b/main/reentrancy.c
deleted file mode 100644
index c20b3a2bdf..0000000000
--- a/main/reentrancy.c
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Sascha Schumann <sascha@schumann.cx> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#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
-
-#if defined(NETWARE) && !(NEW_LIBC)
-/*#include <ws2nlm.h>*/
-#include <sys/socket.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(NETWARE)
-/*
- Re-entrant versions of functions seem to be better for loading NLMs in different address space.
- Since we have them now in LibC, we might as well make use of them.
-*/
-
-#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)
-{
- /* Modified according to LibC definition */
- if (localtime_r(timep, p_tm) != NULL)
- return (p_tm);
- return (NULL);
-}
-
-PHPAPI char *php_ctime_r(const time_t *clock, char *buf)
-{
- /* Modified according to LibC definition */
- if (ctime_r(clock, buf) != NULL)
- return (buf);
- return (NULL);
-}
-
-PHPAPI char *php_asctime_r(const struct tm *tm, char *buf)
-{
- /* Modified according to LibC definition */
- if (asctime_r(tm, buf) != NULL)
- return (buf);
- return (NULL);
-}
-
-PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm)
-{
- /* Modified according to LibC definition */
- if (gmtime_r(timep, p_tm) != NULL)
- return (p_tm);
- return (NULL);
-}
-
-#endif /* NETWARE */
-
-#if defined(__BEOS__)
-
-PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm)
-{
- /* Modified according to LibC definition */
- if (((struct tm*)gmtime_r(timep, p_tm)) == p_tm)
- return (p_tm);
- return (NULL);
-}
-
-#endif /* BEOS */
-
-#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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/rfc1867.c b/main/rfc1867.c
deleted file mode 100644
index 202dc8ee8d..0000000000
--- a/main/rfc1867.c
+++ /dev/null
@@ -1,1073 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- | Jani Taskinen <sniper@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/*
- * This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/).
- *
- */
-
-#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"
-
-#if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
-#include "ext/mbstring/mbstring.h"
-#endif
-
-#undef DEBUG_FILE_UPLOAD
-
-#define SAFE_RETURN { \
- if (lbuf) efree(lbuf); \
- if (abuf) efree(abuf); \
- if (array_index) efree(array_index); \
- zend_hash_destroy(&PG(rfc1867_protected_variables)); \
- zend_llist_destroy(&header); \
- if (mbuff->boundary_next) efree(mbuff->boundary_next); \
- if (mbuff->boundary) efree(mbuff->boundary); \
- if (mbuff->buffer) efree(mbuff->buffer); \
- if (mbuff) efree(mbuff); \
- return; }
-
-
-/* The longest property name we use in an uploaded file array */
-#define MAX_SIZE_OF_INDEX sizeof("[tmp_name]")
-
-/* The longest anonymous name */
-#define MAX_SIZE_ANONNAME 33
-
-/* Errors */
-#define UPLOAD_ERROR_OK 0 /* File upload succesful */
-#define UPLOAD_ERROR_A 1 /* Uploaded file exceeded upload_max_filesize */
-#define UPLOAD_ERROR_B 2 /* Uploaded file exceeded MAX_FILE_SIZE */
-#define UPLOAD_ERROR_C 3 /* Partially uploaded */
-#define UPLOAD_ERROR_D 4 /* No file uploaded */
-
-void php_rfc1867_register_constants(TSRMLS_D)
-{
- REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_OK", UPLOAD_ERROR_OK, CONST_CS | CONST_PERSISTENT);
- REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_INI_SIZE", UPLOAD_ERROR_A, CONST_CS | CONST_PERSISTENT);
- REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_FORM_SIZE", UPLOAD_ERROR_B, CONST_CS | CONST_PERSISTENT);
- REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_PARTIAL", UPLOAD_ERROR_C, CONST_CS | CONST_PERSISTENT);
- REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_NO_FILE", UPLOAD_ERROR_D, CONST_CS | CONST_PERSISTENT);
-}
-
-static void normalize_protected_variable(char *varname TSRMLS_DC)
-{
- char *s=varname, *index=NULL, *indexend=NULL, *p;
-
- /* overjump leading space */
- while (*s == ' ') {
- s++;
- }
-
- /* and remove it */
- if (s != varname) {
- memcpy(varname, s, strlen(s)+1);
- }
-
- for (p=varname; *p && *p != '['; p++) {
- switch(*p) {
- case ' ':
- case '.':
- *p='_';
- break;
- }
- }
-
- /* find index */
- index = strchr(varname, '[');
- if (index) {
- index++;
- s=index;
- } else {
- return;
- }
-
- /* done? */
- while (index) {
-
- while (*index == ' ' || *index == '\r' || *index == '\n' || *index=='\t') {
- index++;
- }
- indexend = strchr(index, ']');
- indexend = indexend ? indexend + 1 : index + strlen(index);
-
- if (s != index) {
- memcpy(s, index, strlen(s)+1);
- s += indexend-index;
- } else {
- s = indexend;
- }
-
- if (*s == '[') {
- s++;
- index = s;
- } else {
- index = NULL;
- }
- }
- *s++='\0';
-}
-
-
-static void add_protected_variable(char *varname TSRMLS_DC)
-{
- int dummy=1;
-
- normalize_protected_variable(varname TSRMLS_CC);
- 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)
-{
- normalize_protected_variable(varname TSRMLS_CC);
- 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, zval *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));
-}
-
-
-/*
- * Following code is based on apache_multipart_buffer.c from libapreq-0.33 package.
- *
- */
-
-#define FILLUNIT (1024 * 5)
-
-typedef struct {
-
- /* read buffer */
- char *buffer;
- char *buf_begin;
- int bufsize;
- int bytes_in_buffer;
-
- /* boundary info */
- char *boundary;
- char *boundary_next;
- int boundary_next_len;
-
-} multipart_buffer;
-
-
-typedef struct {
- char *key;
- char *value;
-} mime_header_entry;
-
-
-/*
- fill up the buffer with client data.
- returns number of bytes added to buffer.
-*/
-static int fill_buffer(multipart_buffer *self TSRMLS_DC)
-{
- int bytes_to_read, total_read = 0, actual_read = 0;
-
- /* shift the existing data if necessary */
- if (self->bytes_in_buffer > 0 && self->buf_begin != self->buffer) {
- memmove(self->buffer, self->buf_begin, self->bytes_in_buffer);
- }
-
- self->buf_begin = self->buffer;
-
- /* calculate the free space in the buffer */
- bytes_to_read = self->bufsize - self->bytes_in_buffer;
-
- /* read the required number of bytes */
- while (bytes_to_read > 0) {
-
- char *buf = self->buffer + self->bytes_in_buffer;
-
- actual_read = sapi_module.read_post(buf, bytes_to_read TSRMLS_CC);
-
- /* update the buffer length */
- if (actual_read > 0) {
- self->bytes_in_buffer += actual_read;
- SG(read_post_bytes) += actual_read;
- total_read += actual_read;
- bytes_to_read -= actual_read;
- } else {
- break;
- }
- }
-
- return total_read;
-}
-
-
-/* eof if we are out of bytes, or if we hit the final boundary */
-static int multipart_buffer_eof(multipart_buffer *self TSRMLS_DC)
-{
- if ( (self->bytes_in_buffer == 0 && fill_buffer(self TSRMLS_CC) < 1) ) {
- return 1;
- } else {
- return 0;
- }
-}
-
-
-/* create new multipart_buffer structure */
-static multipart_buffer *multipart_buffer_new(char *boundary, int boundary_len)
-{
- multipart_buffer *self = (multipart_buffer *) ecalloc(1, sizeof(multipart_buffer));
-
- int minsize = boundary_len + 6;
- if (minsize < FILLUNIT) minsize = FILLUNIT;
-
- self->buffer = (char *) ecalloc(1, minsize + 1);
- self->bufsize = minsize;
-
- self->boundary = (char *) ecalloc(1, boundary_len + 3);
- sprintf(self->boundary, "--%s", boundary);
-
- self->boundary_next = (char *) ecalloc(1, boundary_len + 4);
- sprintf(self->boundary_next, "\n--%s", boundary);
- self->boundary_next_len = boundary_len + 3;
-
- self->buf_begin = self->buffer;
- self->bytes_in_buffer = 0;
-
- return self;
-}
-
-
-/*
- gets the next CRLF terminated line from the input buffer.
- if it doesn't find a CRLF, and the buffer isn't completely full, returns
- NULL; otherwise, returns the beginning of the null-terminated line,
- minus the CRLF.
-
- note that we really just look for LF terminated lines. this works
- around a bug in internet explorer for the macintosh which sends mime
- boundaries that are only LF terminated when you use an image submit
- button in a multipart/form-data form.
- */
-static char *next_line(multipart_buffer *self)
-{
- /* look for LF in the data */
- char* line = self->buf_begin;
- char* ptr = memchr(self->buf_begin, '\n', self->bytes_in_buffer);
-
- if (ptr) { /* LF found */
-
- /* terminate the string, remove CRLF */
- if ((ptr - line) > 0 && *(ptr-1) == '\r') {
- *(ptr-1) = 0;
- } else {
- *ptr = 0;
- }
-
- /* bump the pointer */
- self->buf_begin = ptr + 1;
- self->bytes_in_buffer -= (self->buf_begin - line);
-
- } else { /* no LF found */
-
- /* buffer isn't completely full, fail */
- if (self->bytes_in_buffer < self->bufsize) {
- return NULL;
- }
- /* return entire buffer as a partial line */
- line[self->bufsize] = 0;
- self->buf_begin = ptr;
- self->bytes_in_buffer = 0;
- }
-
- return line;
-}
-
-
-/* returns the next CRLF terminated line from the client */
-static char *get_line(multipart_buffer *self TSRMLS_DC)
-{
- char* ptr = next_line(self);
-
- if (!ptr) {
- fill_buffer(self TSRMLS_CC);
- ptr = next_line(self);
- }
-
- return ptr;
-}
-
-
-/* Free header entry */
-static void php_free_hdr_entry(mime_header_entry *h)
-{
- if (h->key) {
- efree(h->key);
- }
- if (h->value) {
- efree(h->value);
- }
-}
-
-
-/* finds a boundary */
-static int find_boundary(multipart_buffer *self, char *boundary TSRMLS_DC)
-{
- char *line;
-
- /* loop thru lines */
- while( (line = get_line(self TSRMLS_CC)) )
- {
- /* finished if we found the boundary */
- if (!strcmp(line, boundary)) {
- return 1;
- }
- }
-
- /* didn't find the boundary */
- return 0;
-}
-
-
-/* parse headers */
-static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header TSRMLS_DC)
-{
- char *line;
- mime_header_entry prev_entry, entry;
- int prev_len, cur_len;
-
- /* didn't find boundary, abort */
- if (!find_boundary(self, self->boundary TSRMLS_CC)) {
- return 0;
- }
-
- /* get lines of text, or CRLF_CRLF */
-
- while( (line = get_line(self TSRMLS_CC)) && strlen(line) > 0 )
- {
- /* add header to table */
-
- char *key = line;
- char *value = NULL;
-
- /* space in the beginning means same header */
- if (!isspace(line[0])) {
- value = strchr(line, ':');
- }
-
- if (value) {
- *value = 0;
- do { value++; } while(isspace(*value));
-
- entry.value = estrdup(value);
- entry.key = estrdup(key);
-
- } else if (zend_llist_count(header)) { /* If no ':' on the line, add to previous line */
-
- prev_len = strlen(prev_entry.value);
- cur_len = strlen(line);
-
- entry.value = emalloc(prev_len + cur_len + 1);
- memcpy(entry.value, prev_entry.value, prev_len);
- memcpy(entry.value + prev_len, line, cur_len);
- entry.value[cur_len + prev_len] = '\0';
-
- entry.key = estrdup(prev_entry.key);
-
- zend_llist_remove_tail(header);
- } else {
- continue;
- }
-
- zend_llist_add_element(header, &entry);
- prev_entry = entry;
- }
-
- return 1;
-}
-
-
-static char *php_mime_get_hdr_value(zend_llist header, char *key)
-{
- mime_header_entry *entry;
-
- if (key == NULL) {
- return NULL;
- }
-
- entry = zend_llist_get_first(&header);
- while (entry) {
- if (!strcasecmp(entry->key, key)) {
- return entry->value;
- }
- entry = zend_llist_get_next(&header);
- }
-
- return NULL;
-}
-
-
-static char *php_ap_getword(char **line, char stop)
-{
- char *pos = *line, quote;
- char *res;
-
- while (*pos && *pos != stop) {
-
- if ((quote = *pos) == '"' || quote == '\'') {
- ++pos;
- while (*pos && *pos != quote) {
- if (*pos == '\\' && pos[1] && pos[1] == quote) {
- pos += 2;
- } else {
- ++pos;
- }
- }
- if (*pos) {
- ++pos;
- }
- } else ++pos;
-
- }
- if (*pos == '\0') {
- res = estrdup(*line);
- *line += strlen(*line);
- return res;
- }
-
- res = estrndup(*line, pos - *line);
-
- while (*pos == stop) {
- ++pos;
- }
-
- *line = pos;
- return res;
-}
-
-
-static char *substring_conf(char *start, int len, char quote TSRMLS_DC)
-{
- char *result = emalloc(len + 2);
- char *resp = result;
- int i;
-
- for (i = 0; i < len; ++i) {
- if (start[i] == '\\' && (start[i + 1] == '\\' || (quote && start[i + 1] == quote))) {
- *resp++ = start[++i];
- } else {
-#if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
- if (php_mb_encoding_translation(TSRMLS_C)) {
- size_t j = php_mb_mbchar_bytes(start+i TSRMLS_CC);
- while (j-- > 0 && i < len) {
- *resp++ = start[i++];
- }
- --i;
- } else {
- *resp++ = start[i];
- }
-#else
- *resp++ = start[i];
-#endif
- }
- }
-
- *resp++ = '\0';
- return result;
-}
-
-
-static char *php_ap_getword_conf(char **line TSRMLS_DC)
-{
- char *str = *line, *strend, *res, quote;
-
- while (*str && isspace(*str)) {
- ++str;
- }
-
- if (!*str) {
- *line = str;
- return estrdup("");
- }
-
- if ((quote = *str) == '"' || quote == '\'') {
- strend = str + 1;
- while (*strend && *strend != quote) {
- if (*strend == '\\' && strend[1] && strend[1] == quote) {
- strend += 2;
- } else {
- ++strend;
- }
- }
- res = substring_conf(str + 1, strend - str - 1, quote TSRMLS_CC);
-
- if (*strend == quote) {
- ++strend;
- }
-
- } else {
-
- strend = str;
- while (*strend && !isspace(*strend)) {
- ++strend;
- }
- res = substring_conf(str, strend - str, 0 TSRMLS_CC);
- }
-
- while (*strend && isspace(*strend)) {
- ++strend;
- }
-
- *line = strend;
- return res;
-}
-
-
-/*
- search for a string in a fixed-length byte string.
- if partial is true, partial matches are allowed at the end of the buffer.
- returns NULL if not found, or a pointer to the start of the first match.
-*/
-static void *php_ap_memstr(char *haystack, int haystacklen, char *needle, int needlen, int partial)
-{
- int len = haystacklen;
- char *ptr = haystack;
-
- /* iterate through first character matches */
- while( (ptr = memchr(ptr, needle[0], len)) ) {
-
- /* calculate length after match */
- len = haystacklen - (ptr - (char *)haystack);
-
- /* done if matches up to capacity of buffer */
- if (memcmp(needle, ptr, needlen < len ? needlen : len) == 0 && (partial || len >= needlen)) {
- break;
- }
-
- /* next character */
- ptr++; len--;
- }
-
- return ptr;
-}
-
-
-/* read until a boundary condition */
-static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes TSRMLS_DC)
-{
- int len, max;
- char *bound;
-
- /* fill buffer if needed */
- if (bytes > self->bytes_in_buffer) {
- fill_buffer(self TSRMLS_CC);
- }
-
- /* look for a potential boundary match, only read data up to that point */
- if ((bound = php_ap_memstr(self->buf_begin, self->bytes_in_buffer, self->boundary_next, self->boundary_next_len, 1))) {
- max = bound - self->buf_begin;
- } else {
- max = self->bytes_in_buffer;
- }
-
- /* maximum number of bytes we are reading */
- len = max < bytes-1 ? max : bytes-1;
-
- /* if we read any data... */
- if (len > 0) {
-
- /* copy the data */
- memcpy(buf, self->buf_begin, len);
- buf[len] = 0;
-
- if (bound && len > 0 && buf[len-1] == '\r') {
- buf[--len] = 0;
- }
-
- /* update the buffer */
- self->bytes_in_buffer -= len;
- self->buf_begin += len;
- }
-
- return len;
-}
-
-
-/*
- XXX: this is horrible memory-usage-wise, but we only expect
- to do this on small pieces of form data.
-*/
-static char *multipart_buffer_read_body(multipart_buffer *self TSRMLS_DC)
-{
- char buf[FILLUNIT], *out=NULL;
- int total_bytes=0, read_bytes=0;
-
- while((read_bytes = multipart_buffer_read(self, buf, sizeof(buf) TSRMLS_CC))) {
- out = erealloc(out, total_bytes + read_bytes + 1);
- memcpy(out + total_bytes, buf, read_bytes);
- total_bytes += read_bytes;
- }
-
- if (out) out[total_bytes] = '\0';
-
- return out;
-}
-
-
-/*
- * The combined READER/HANDLER
- *
- */
-
-SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
-{
- char *boundary, *s=NULL, *boundary_end = NULL, *start_arr=NULL, *array_index=NULL;
- char *temp_filename=NULL, *lbuf=NULL, *abuf=NULL;
- int boundary_len=0, total_bytes=0, cancel_upload=0, is_arr_upload=0, array_len=0, max_file_size=0, skip_upload=0, anonindex=0, is_anonymous;
- zval *http_post_files=NULL;
- zend_bool magic_quotes_gpc;
- multipart_buffer *mbuff;
- zval *array_ptr = (zval *) arg;
- FILE *fp;
- zend_llist header;
-
- if (SG(request_info).content_length > SG(post_max_size)) {
- sapi_module.sapi_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;
- }
-
- /* Get the boundary */
- boundary = strstr(content_type_dup, "boundary");
- if (!boundary || !(boundary=strchr(boundary, '='))) {
- sapi_module.sapi_error(E_WARNING, "Missing boundary in multipart/form-data POST data");
- return;
- }
-
- boundary++;
- boundary_len = strlen(boundary);
-
- if (boundary[0] == '"') {
- boundary++;
- boundary_end = strchr(boundary, '"');
- if (!boundary_end) {
- sapi_module.sapi_error(E_WARNING, "Invalid boundary in multipart/form-data POST data");
- return;
- }
- } else {
- /* search for the end of the boundary */
- boundary_end = strchr(boundary, ',');
- }
- if (boundary_end) {
- boundary_end[0] = '\0';
- boundary_len = boundary_end-boundary;
- }
-
- /* Initialize the buffer */
- if (!(mbuff = multipart_buffer_new(boundary, boundary_len))) {
- sapi_module.sapi_error(E_WARNING, "Unable to initialize the input buffer");
- return;
- }
-
- /* Initialize $_FILES[] */
- 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;
-
- zend_llist_init(&header, sizeof(mime_header_entry), (llist_dtor_func_t) php_free_hdr_entry, 0);
-
- while (!multipart_buffer_eof(mbuff TSRMLS_CC))
- {
- char buff[FILLUNIT];
- char *cd=NULL,*param=NULL,*filename=NULL;
- int blen=0, wlen=0;
-
- zend_llist_clean(&header);
-
- if (!multipart_buffer_headers(mbuff, &header TSRMLS_CC)) {
- SAFE_RETURN;
- }
-
- if ((cd = php_mime_get_hdr_value(header, "Content-Disposition"))) {
- char *pair=NULL;
-
- while (isspace(*cd)) {
- ++cd;
- }
-
- while (*cd && (pair = php_ap_getword(&cd, ';')))
- {
- char *key=NULL, *word = pair;
-
- while (isspace(*cd)) {
- ++cd;
- }
-
- if (strchr(pair, '=')) {
- key = php_ap_getword(&pair, '=');
-
- if (!strcmp(key, "name")) {
- if (param) {
- efree(param);
- }
- param = php_ap_getword_conf(&pair TSRMLS_CC);
- } else if (!strcmp(key, "filename")) {
- if (filename) {
- efree(filename);
- }
- filename = php_ap_getword_conf(&pair TSRMLS_CC);
- }
- }
- if (key) {
- efree(key);
- }
- efree(word);
- }
-
- /* Normal form variable, safe to read all data into memory */
- if (!filename && param) {
-
- char *value = multipart_buffer_read_body(mbuff TSRMLS_CC);
-
- if (!value) {
- value = estrdup("");
- }
-
- sapi_module.input_filter(PARSE_POST, param, &value, strlen(value) TSRMLS_CC);
- safe_php_register_variable(param, value, array_ptr, 0 TSRMLS_CC);
- if (!strcmp(param, "MAX_FILE_SIZE")) {
- max_file_size = atol(value);
- }
-
- efree(param);
- efree(value);
- continue;
- }
-
- /* If file_uploads=off, skip the file part */
- if (!PG(file_uploads)) {
- skip_upload = 1;
- }
-
- /* Return with an error if the posted data is garbled */
- if (!param && !filename) {
- sapi_module.sapi_error(E_WARNING, "File Upload Mime headers garbled");
- SAFE_RETURN;
- }
-
- if (!param) {
- is_anonymous = 1;
- param = emalloc(MAX_SIZE_ANONNAME);
- snprintf(param, MAX_SIZE_ANONNAME, "%u", anonindex++);
- } else {
- is_anonymous = 0;
- }
-
- if (!skip_upload) {
- /* Handle file */
- fp = php_open_temporary_file(PG(upload_tmp_dir), "php", &temp_filename TSRMLS_CC);
- if (!fp) {
- sapi_module.sapi_error(E_WARNING, "File upload error - unable to create a temporary file");
- skip_upload = 1;
- }
- }
- if (skip_upload) {
- efree(param);
- efree(filename);
- continue;
- }
-
- total_bytes = 0;
- cancel_upload = 0;
-
- if(strlen(filename) == 0) {
-#ifdef DEBUG_FILE_UPLOAD
- sapi_module.sapi_error(E_NOTICE, "No file uploaded");
-#endif
- cancel_upload = UPLOAD_ERROR_D;
- }
-
- while (!cancel_upload && (blen = multipart_buffer_read(mbuff, buff, sizeof(buff) TSRMLS_CC)))
- {
- if (total_bytes > PG(upload_max_filesize)) {
- sapi_module.sapi_error(E_WARNING, "upload_max_filesize of %ld bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename);
- cancel_upload = UPLOAD_ERROR_A;
- } else if (max_file_size && (total_bytes > max_file_size)) {
- sapi_module.sapi_error(E_WARNING, "MAX_FILE_SIZE of %ld bytes exceeded - file [%s=%s] not saved", max_file_size, param, filename);
- cancel_upload = UPLOAD_ERROR_B;
- } else if (blen > 0) {
- wlen = fwrite(buff, 1, blen, fp);
-
- if (wlen < blen) {
- sapi_module.sapi_error(E_WARNING, "Only %d bytes were written, expected to write %ld", wlen, blen);
- cancel_upload = UPLOAD_ERROR_C;
- } else {
- total_bytes += wlen;
- }
- }
- }
- fclose(fp);
-
-#ifdef DEBUG_FILE_UPLOAD
- if(strlen(filename) > 0 && total_bytes == 0) {
- sapi_module.sapi_error(E_WARNING, "Uploaded file size 0 - file [%s=%s] not saved", param, filename);
- cancel_upload = 5;
- }
-#endif
-
- if (cancel_upload) {
- if (temp_filename) {
- unlink(temp_filename);
- efree(temp_filename);
- }
- temp_filename="";
- } else {
- zend_hash_add(SG(rfc1867_uploaded_files), temp_filename, strlen(temp_filename) + 1, &temp_filename, sizeof(char *), NULL);
- }
-
- /* is_arr_upload is true when name of file upload field
- * ends in [.*]
- * start_arr is set to point to 1st [
- */
- is_arr_upload = (start_arr = strchr(param,'[')) && (param[strlen(param)-1] == ']');
- /* handle unterminated [ */
- if (!is_arr_upload && start_arr) {
- *start_arr = '_';
- }
-
- if (is_arr_upload) {
- array_len = strlen(start_arr);
- if (array_index) {
- efree(array_index);
- }
- array_index = estrndup(start_arr+1, array_len-2);
- }
-
- /* Add $foo_name */
- if (lbuf) {
- efree(lbuf);
- }
- lbuf = (char *) emalloc(strlen(param) + MAX_SIZE_OF_INDEX + 1);
-
- if (is_arr_upload) {
- if (abuf) efree(abuf);
- abuf = estrndup(param, strlen(param)-array_len);
- sprintf(lbuf, "%s_name[%s]", abuf, array_index);
- } else {
- sprintf(lbuf, "%s_name", param);
- }
-
-#if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
- if (php_mb_encoding_translation(TSRMLS_C)) {
- s = php_mb_strrchr(filename, '\\' TSRMLS_CC);
- } else {
- s = strrchr(filename, '\\');
- }
-#else
- s = strrchr(filename, '\\');
-#endif
- if (!is_anonymous) {
- if (s && s > filename) {
- safe_php_register_variable(lbuf, s+1, NULL, 0 TSRMLS_CC);
- } else {
- safe_php_register_variable(lbuf, filename, NULL, 0 TSRMLS_CC);
- }
- }
-
- /* Add $foo[name] */
- if (is_arr_upload) {
- sprintf(lbuf, "%s[name][%s]", abuf, array_index);
- } else {
- sprintf(lbuf, "%s[name]", param);
- }
- if (s && s > filename) {
- register_http_post_files_variable(lbuf, s+1, http_post_files, 0 TSRMLS_CC);
- } else {
- register_http_post_files_variable(lbuf, filename, http_post_files, 0 TSRMLS_CC);
- }
- efree(filename);
- s = NULL;
-
- /* Possible Content-Type: */
- if (cancel_upload || !(cd = php_mime_get_hdr_value(header, "Content-Type"))) {
- cd = "";
- } else {
- /* fix for Opera 6.01 */
- s = strchr(cd, ';');
- if (s != NULL) {
- *s = '\0';
- }
- }
-
- /* Add $foo_type */
- if (is_arr_upload) {
- sprintf(lbuf, "%s_type[%s]", abuf, array_index);
- } else {
- sprintf(lbuf, "%s_type", param);
- }
- if (!is_anonymous) {
- safe_php_register_variable(lbuf, cd, NULL, 0 TSRMLS_CC);
- }
-
- /* Add $foo[type] */
- if (is_arr_upload) {
- sprintf(lbuf, "%s[type][%s]", abuf, array_index);
- } else {
- sprintf(lbuf, "%s[type]", param);
- }
- register_http_post_files_variable(lbuf, cd, http_post_files, 0 TSRMLS_CC);
-
- /* Restore Content-Type Header */
- if (s != NULL) {
- *s = ';';
- }
- s = "";
-
- /* Initialize variables */
- add_protected_variable(param TSRMLS_CC);
-
- magic_quotes_gpc = PG(magic_quotes_gpc);
- PG(magic_quotes_gpc) = 0;
- /* if param is of form xxx[.*] this will cut it to xxx */
- if (!is_anonymous) {
- safe_php_register_variable(param, temp_filename, NULL, 1 TSRMLS_CC);
- }
-
- /* Add $foo[tmp_name] */
- if (is_arr_upload) {
- sprintf(lbuf, "%s[tmp_name][%s]", abuf, array_index);
- } else {
- sprintf(lbuf, "%s[tmp_name]", param);
- }
- 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, error_type;
-
- error_type.value.lval = cancel_upload;
- error_type.type = IS_LONG;
-
- /* Add $foo[error] */
- if (cancel_upload) {
- file_size.value.lval = 0;
- file_size.type = IS_LONG;
- } else {
- file_size.value.lval = total_bytes;
- file_size.type = IS_LONG;
- }
-
- if (is_arr_upload) {
- sprintf(lbuf, "%s[error][%s]", abuf, array_index);
- } else {
- sprintf(lbuf, "%s[error]", param);
- }
- register_http_post_files_variable_ex(lbuf, &error_type, http_post_files, 0 TSRMLS_CC);
-
- /* Add $foo_size */
- if (is_arr_upload) {
- sprintf(lbuf, "%s_size[%s]", abuf, array_index);
- } else {
- sprintf(lbuf, "%s_size", param);
- }
- if (!is_anonymous) {
- 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, array_index);
- } else {
- sprintf(lbuf, "%s[size]", param);
- }
- register_http_post_files_variable_ex(lbuf, &file_size, http_post_files, 0 TSRMLS_CC);
- }
- efree(param);
- }
- }
-
- SAFE_RETURN;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/rfc1867.h b/main/rfc1867.h
deleted file mode 100644
index d1c8c7749f..0000000000
--- a/main/rfc1867.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef RFC1867_H
-#define RFC1867_H
-
-#include "SAPI.h"
-
-#define MULTIPART_CONTENT_TYPE "multipart/form-data"
-
-SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler);
-
-void destroy_uploaded_files_hash(TSRMLS_D);
-void php_rfc1867_register_constants(TSRMLS_D);
-
-#endif /* RFC1867_H */
diff --git a/main/safe_mode.c b/main/safe_mode.c
deleted file mode 100644
index 4c21cb49d7..0000000000
--- a/main/safe_mode.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: 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 six 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)
- * 4 - check mode and param
- * 5 - only check file
- */
-
-PHPAPI int php_checkuid_ex(const char *filename, char *fopen_mode, int mode, int flags)
-{
- struct stat sb;
- int ret, nofile=0;
- long uid=0L, gid=0L, duid=0L, dgid=0L;
- char path[MAXPATHLEN];
- char *s, filenamecopy[MAXPATHLEN];
- php_stream_wrapper *wrapper = NULL;
- TSRMLS_FETCH();
-
- strlcpy(filenamecopy, filename, MAXPATHLEN);
- filename=(char *)&filenamecopy;
-
- 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
- */
- wrapper = php_stream_locate_url_wrapper(filename, NULL, STREAM_LOCATE_WRAPPERS_ONLY TSRMLS_CC);
- if (wrapper != NULL)
- 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) {
- if ((flags & CHECKUID_NO_ERRORS) == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to access %s", filename);
- }
- return 0;
- } else if (mode == CHECKUID_ALLOW_FILE_NOT_EXISTS) {
- if ((flags & CHECKUID_NO_ERRORS) == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to access %s", filename);
- }
- return 1;
- }
- nofile = 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))) {
- if (s == path)
- path[1] = '\0';
- else
- *s = '\0';
- }
- } else { /* CHECKUID_ALLOW_ONLY_DIR */
- s = strrchr(filename, DEFAULT_SLASH);
-
- if (s == filename) {
- /* root dir */
- path[0] = DEFAULT_SLASH;
- path[1] = '\0';
- } else if (s) {
- *s = '\0';
- VCWD_REALPATH(filename, path);
- *s = DEFAULT_SLASH;
- } else {
- VCWD_GETCWD(path, sizeof(path));
- }
- } /* end CHECKUID_ALLOW_ONLY_DIR */
-
- if (mode != CHECKUID_ALLOW_ONLY_FILE) {
- /* check directory */
- ret = VCWD_STAT(path, &sb);
- if (ret < 0) {
- if ((flags & CHECKUID_NO_ERRORS) == 0) {
- php_error_docref(NULL TSRMLS_CC, 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 (nofile) {
- uid = duid;
- gid = dgid;
- filename = path;
- }
-
- if ((flags & CHECKUID_NO_ERRORS) == 0) {
- if (PG(safe_mode_gid)) {
- php_error_docref(NULL TSRMLS_CC, 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_docref(NULL TSRMLS_CC, 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 int php_checkuid(const char *filename, char *fopen_mode, int mode) {
- return php_checkuid_ex(filename, fopen_mode, mode, 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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/safe_mode.h b/main/safe_mode.h
deleted file mode 100644
index 4e4d01848b..0000000000
--- a/main/safe_mode.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#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
-
-/* flags for php_checkuid_ex() */
-#define CHECKUID_NO_ERRORS 0x01
-
-extern PHPAPI int php_checkuid(const char *filename, char *fopen_mode, int mode);
-extern PHPAPI int php_checkuid_ex(const char *filename, char *fopen_mode, int mode, int flags);
-extern PHPAPI char *php_get_current_user(void);
-
-#endif
diff --git a/main/snprintf.c b/main/snprintf.c
deleted file mode 100644
index fc3d5de153..0000000000
--- a/main/snprintf.c
+++ /dev/null
@@ -1,961 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-/* ====================================================================
- * 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"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-
-#define FALSE 0
-#define TRUE 1
-#define NUL '\0'
-#define INT_NULL ((int *)0)
-
-#define S_NULL "(null)"
-#define S_NULL_LEN 6
-
-#define FLOAT_DIGITS 6
-#define EXPONENT_LENGTH 10
-
-
-/*
- * 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 ])
- */
-char *
-ap_php_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 = (char)(magnitude - new_magnitude * 10 + '0');
- magnitude = new_magnitude;
- }
- while (magnitude);
-
- *len = buf_end - p;
- return (p);
-}
-
-#define NDIG 80
-
-
-/*
- * 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).
- */
-char *
- ap_php_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;
- char buf1[NDIG];
-
- if (format == 'f')
- p = ap_php_fcvt(num, precision, &decimal_point, is_negative, buf1);
- else /* either e or E format */
- p = ap_php_ecvt(num, precision + 1, &decimal_point, is_negative, buf1);
-
- /*
- * Check for Infinity and NaN
- */
- if (isalpha((int)*p)) {
- *len = strlen(p);
- memcpy(buf, p, *len + 1);
- *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 = ap_php_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 ])
- */
-char *
- ap_php_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);
-}
-
-/*
- * 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
- */
-
-
-char *
-ap_php_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf)
-{
- register int r2;
- double fi, fj;
- register char *p, *p1;
-
- 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) {
- if (!eflag && (r2 * -1) < ndigits) {
- break;
- }
- 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 = modf(arg * 10, &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);
-}
-
-char *
-ap_php_ecvt(double arg, int ndigits, int *decpt, int *sign, char *buf)
-{
- return (ap_php_cvt(arg, ndigits, decpt, sign, 1, buf));
-}
-
-char *
-ap_php_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf)
-{
- return (ap_php_cvt(arg, ndigits, decpt, sign, 0, buf));
-}
-
-/*
- * ap_php_gcvt - Floating output conversion to
- * minimal length string
- */
-
-char *
-ap_php_gcvt(double number, int ndigit, char *buf, boolean_e altform)
-{
- int sign, decpt;
- register char *p1, *p2;
- register int i;
- char buf1[NDIG];
-
- p1 = ap_php_ecvt(number, ndigit, &decpt, &sign, buf1);
- 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++ = '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] == '.' && !altform)
- p2--;
- *p2 = '\0';
- return (buf);
-}
-
-#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || PHP_BROKEN_SNPRINTF || PHP_BROKEN_VSNPRINTF
-
-/*
- * 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
-
-
-/*
- * 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 = ap_php_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 = ap_php_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 = ap_php_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 = ap_php_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],
- alternate_form);
- 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 = ap_php_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.
- */
- if (len == 0) {
- od.buf_end = (char *) ~0;
- od.nextb = (char *) ~0;
- } else {
- od.buf_end = &buf[len-1];
- 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, 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, format, ap);
- return (cc);
-}
-
-#endif /* HAVE_SNPRINTF */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/snprintf.h b/main/snprintf.h
deleted file mode 100644
index 0b811eb739..0000000000
--- a/main/snprintf.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Stig Sæther Bakken <ssb@fast.no> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-/*
-
-Comparing: sprintf, snprintf, spprintf
-
-sprintf offers the ability to make a lot of failures since it does not know
- the size of the buffer it uses. Therefore usage of sprintf often
- results in possible entries for buffer overrun attacks. So please
- use this version only if you are sure the call is safe. sprintf
- allways terminstes the buffer it writes to.
-
-snprintf knows the buffers size and will not write behind it. But you will
- have to use either a static buffer or allocate a dynamic buffer
- before beeing able to call the function. In other words you must
- be sure that you really know the maximum size of the buffer required.
- A bad thing is having a big maximum while in most cases you would
- only need a small buffer. If the size of the resulting string is
- longer or equal to the buffer size than the buffer is not terminated.
-
-spprintf is the dynamical version of snprintf. It allocates the buffer in size
- as needed and allows a maximum setting as snprintf (turn this feature
- off by setting max_len to 0). spprintf is a little bit slower than
- snprintf and offers possible memory leakes if you miss freeing the
- buffer allocated by the function. Therfore this function should be
- used where either no maximum is known or the maximum is much bigger
- than normal size required. spprintf allways terminates the buffer.
-
-Example:
-
- #define MAX 1024 | #define MAX 1024 | #define MAX 1024
- char buffer[MAX] | char buffer[MAX] | char *buffer;
- | |
- | | // No need to initialize buffer:
- | | // spprintf ignores value of buffer
- sprintf(buffer, "test"); | snprintf(buffer, MAX, "test"); | spprintf(&buffer, MAX, "text");
- | | if (!buffer)
- | | return OUT_OF_MEMORY
- // sprintf allways terminates | // manual termination of | // spprintf allays terminates buffer
- // buffer | // buffer *IS* required |
- | buffer[MAX-1] = 0; |
- action_with_buffer(buffer); | action_with_buffer(buffer); | action_with_buffer(buffer);
- | | efree(buffer);
-*/
-
-#ifndef SNPRINTF_H
-#define SNPRINTF_H
-
-#if !defined(HAVE_SNPRINTF) || PHP_BROKEN_SNPRINTF
-extern int ap_php_snprintf(char *, size_t, const char *, ...);
-#define snprintf ap_php_snprintf
-#endif
-
-#if !defined(HAVE_VSNPRINTF) || PHP_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
-
-typedef enum {
- NO = 0, YES = 1
-} boolean_e;
-
-extern char * ap_php_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf);
-extern char * ap_php_ecvt(double arg, int ndigits, int *decpt, int *sign, char *buf);
-extern char * ap_php_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf);
-extern char * ap_php_gcvt(double number, int ndigit, char *buf, boolean_e altform);
-
-#define WIDE_INT long
-typedef WIDE_INT wide_int;
-typedef unsigned WIDE_INT u_wide_int;
-
-typedef int bool_int;
-
-extern char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
- register bool_int * is_negative, char *buf_end, register int *len);
-
-extern char * ap_php_conv_fp(register char format, register double num,
- boolean_e add_dp, int precision, bool_int * is_negative, char *buf, int *len);
-
-extern char * ap_php_conv_p2(register u_wide_int num, register int nbits,
- char format, char *buf_end, register int *len);
-
-
-#endif /* SNPRINTF_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/spprintf.c b/main/spprintf.c
deleted file mode 100644
index 124865909f..0000000000
--- a/main/spprintf.c
+++ /dev/null
@@ -1,561 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Marcus Boerger <helly@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-/* This is the spprintf implementation.
- * It has emerged from apache snprintf. See original header:
- */
-
-/* ====================================================================
- * 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"
-#include "snprintf.h"
-
-#define FALSE 0
-#define TRUE 1
-#define NUL '\0'
-#define INT_NULL ((int *)0)
-
-#define S_NULL "(null)"
-#define S_NULL_LEN 6
-
-#define FLOAT_DIGITS 6
-#define EXPONENT_LENGTH 10
-
-#include "ext/standard/php_smart_str.h"
-
-/*
- * 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
-
-/*
- * The INS_CHAR macro inserts a character in the buffer.
- *
- * NOTE: Evaluation of the ch argument should not have any side-effects
- */
-#define INS_CHAR_NR(xbuf, ch) do { \
- smart_str_appendc(xbuf, ch); \
-} while (0)
-
-#define INS_STRING(xbuf, s, slen) do { \
- smart_str_appendl(xbuf, s, slen); \
-} while (0)
-
-#define INS_CHAR(xbuf, ch) \
- INS_CHAR_NR(xbuf, ch)
-
-/*
- * Macro that does padding. The padding is done by printing
- * the character ch.
- */
-#define PAD(xbuf, count, ch) do { \
- if ((count) > 0) { \
- size_t newlen; \
- smart_str_alloc(xbuf, (count), 0); \
- memset(xbuf->c + xbuf->len, ch, (count)); \
- xbuf->len += (count); \
- } \
-} while (0)
-
-#define NUM(c) (c - '0')
-
-#define STR_TO_DEC(str, num) do { \
- num = NUM(*str++); \
- while (isdigit((int)*str)) { \
- num *= 10; \
- num += NUM(*str++); \
- if (num >= LONG_MAX / 10) { \
- while (isdigit((int)*str++)); \
- break; \
- } \
- } \
-} while (0)
-
-/*
- * 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) do { \
- if (adjust) \
- while (s_len < precision) { \
- *--s = '0'; \
- s_len++; \
- } \
-} while (0)
-
-
-
-/*
- * Do format conversion placing the output in buffer
- */
-static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
-{
- 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;
-
- while (*fmt) {
- if (*fmt != '%') {
- INS_CHAR(xbuf, *fmt);
- } 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 = ap_php_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 = ap_php_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 = ap_php_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 = ap_php_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],
- alternate_form);
- 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 *)) = xbuf->len;
- 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 = ap_php_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(xbuf, *s);
- s++;
- s_len--;
- min_width--;
- }
- PAD(xbuf, min_width - s_len, pad_char);
- }
- /*
- * Print the string s.
- */
- INS_STRING(xbuf, s, s_len);
-
- if (adjust_width && adjust == LEFT && min_width > s_len)
- PAD(xbuf, min_width - s_len, pad_char);
- }
- fmt++;
- }
- return;
-}
-
-
-/*
- * This is the general purpose conversion function.
- */
-PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap)
-{
- smart_str xbuf = {0};
-
- xbuf_format_converter(&xbuf, format, ap);
-
- if (max_len && xbuf.len > max_len) {
- xbuf.len = max_len;
- }
- smart_str_0(&xbuf);
-
- *pbuf = xbuf.c;
-
- return xbuf.len;
-}
-
-
-PHPAPI int spprintf(char **pbuf, size_t max_len, const char *format, ...)
-{
- int cc;
- va_list ap;
-
- va_start(ap, format);
- cc = vspprintf(pbuf, max_len, format, ap);
- va_end(ap);
- return (cc);
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/spprintf.h b/main/spprintf.h
deleted file mode 100644
index 5db2c8c9ec..0000000000
--- a/main/spprintf.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Marcus Boerger <helly@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/*
-
-The pbuf parameter of all spprintf version receives a pointer to the allocated
-buffer. This buffer must be freed manually after usage using efree() function.
-The buffer will allways be terminated by a zero character. When pbuf is NULL
-the function can be used to calculate the required size of the buffer but for
-that purpose snprintf is faster. When both pbuf and the return value are 0
-than you are out of memory.
-
-There is also snprintf: See difference explained in snprintf.h
-
-*/
-
-#ifndef SPPRINTF_H
-#define SPPRINTF_H
-
-#include "snprintf.h"
-
-BEGIN_EXTERN_C()
-PHPAPI extern int spprintf( char **pbuf, size_t max_len, const char *format, ...);
-
-PHPAPI extern int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap);
-END_EXTERN_C()
-
-#endif /* SNPRINTF_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/streams/cast.c b/main/streams/cast.c
deleted file mode 100644
index 1ebc6af877..0000000000
--- a/main/streams/cast.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#define _GNU_SOURCE
-#include "php.h"
-#include "php_globals.h"
-#include "php_network.h"
-#include "php_open_temporary_file.h"
-#include "ext/standard/file.h"
-#include <stddef.h>
-#include <fcntl.h>
-
-#include "php_streams_int.h"
-
-/* Under BSD, emulate fopencookie using funopen */
-#if HAVE_FUNOPEN
-typedef struct {
- int (*reader)(void *, char *, int);
- int (*writer)(void *, const char *, int);
- fpos_t (*seeker)(void *, fpos_t, int);
- int (*closer)(void *);
-} COOKIE_IO_FUNCTIONS_T;
-
-FILE *fopencookie(void *cookie, const char *mode, COOKIE_IO_FUNCTIONS_T *funcs)
-{
- return funopen(cookie, funcs->reader, funcs->writer, funcs->seeker, funcs->closer);
-}
-# define HAVE_FOPENCOOKIE 1
-# define PHP_STREAM_COOKIE_FUNCTIONS &stream_cookie_functions
-#elif HAVE_FOPENCOOKIE
-# define PHP_STREAM_COOKIE_FUNCTIONS stream_cookie_functions
-#endif
-
-/* {{{ STDIO with fopencookie */
-#if HAVE_FUNOPEN
-/* use our fopencookie emulation */
-static int stream_cookie_reader(void *cookie, char *buffer, int size)
-{
- int ret;
- TSRMLS_FETCH();
- ret = php_stream_read((php_stream*)cookie, buffer, size);
- return ret;
-}
-
-static int stream_cookie_writer(void *cookie, const char *buffer, int size)
-{
- TSRMLS_FETCH();
- return php_stream_write((php_stream *)cookie, (char *)buffer, size);
-}
-
-static fpos_t stream_cookie_seeker(void *cookie, off_t position, int whence)
-{
- TSRMLS_FETCH();
- return (fpos_t)php_stream_seek((php_stream *)cookie, position, whence);
-}
-
-static int stream_cookie_closer(void *cookie)
-{
- php_stream *stream = (php_stream*)cookie;
- TSRMLS_FETCH();
-
- /* prevent recursion */
- stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE;
- return php_stream_close(stream);
-}
-
-#elif HAVE_FOPENCOOKIE
-static ssize_t stream_cookie_reader(void *cookie, char *buffer, size_t size)
-{
- ssize_t ret;
- TSRMLS_FETCH();
- ret = php_stream_read(((php_stream *)cookie), buffer, size);
- return ret;
-}
-
-static ssize_t stream_cookie_writer(void *cookie, const char *buffer, size_t size)
-{
- TSRMLS_FETCH();
- return php_stream_write(((php_stream *)cookie), (char *)buffer, size);
-}
-
-#ifdef COOKIE_SEEKER_USES_OFF64_T
-static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence)
-{
- TSRMLS_FETCH();
-
- *position = php_stream_seek((php_stream *)cookie, (off_t)*position, whence);
-
- if (*position == -1)
- return -1;
- return 0;
-}
-#else
-static int stream_cookie_seeker(void *cookie, off_t position, int whence)
-{
- TSRMLS_FETCH();
- return php_stream_seek((php_stream *)cookie, position, whence);
-}
-#endif
-
-static int stream_cookie_closer(void *cookie)
-{
- php_stream *stream = (php_stream*)cookie;
- TSRMLS_FETCH();
-
- /* prevent recursion */
- stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE;
- return php_stream_close(stream);
-}
-#endif /* elif HAVE_FOPENCOOKIE */
-
-#if HAVE_FOPENCOOKIE
-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 fopencookie, as suggested by Hartmut ? */
-#endif
-/* }}} */
-
-
-
-
-
-/* {{{ php_stream_cast */
-PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err TSRMLS_DC)
-{
- int flags = castas & PHP_STREAM_CAST_MASK;
- castas &= ~PHP_STREAM_CAST_MASK;
-
- /* synchronize our buffer (if possible) */
- if (ret) {
- php_stream_flush(stream);
- if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
- off_t dummy;
-
- stream->ops->seek(stream, stream->position, SEEK_SET, &dummy TSRMLS_CC);
- stream->readpos = stream->writepos = 0;
- }
- }
-
- /* filtered streams can only be cast as stdio, and only when fopencookie is present */
-
- if (castas == PHP_STREAM_AS_STDIO) {
- if (stream->stdiocast) {
- if (ret) {
- *ret = stream->stdiocast;
- }
- goto exit_success;
- }
-
- /* if the stream is a stdio stream let's give it a chance to respond
- * first, to avoid doubling up the layers of stdio with an fopencookie */
- if (php_stream_is(stream, PHP_STREAM_IS_STDIO) &&
- stream->ops->cast &&
- !php_stream_is_filtered(stream) &&
- stream->ops->cast(stream, castas, ret TSRMLS_CC) == 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, PHP_STREAM_COOKIE_FUNCTIONS);
-
- if (*ret != NULL) {
- off_t pos;
-
- stream->fclose_stdiocast = PHP_STREAM_FCLOSE_FOPENCOOKIE;
-
- /* If the stream position is not at the start, we need to force
- * the stdio layer to believe it's real location. */
- pos = php_stream_tell(stream);
- if (pos > 0)
- fseek(*ret, pos, SEEK_SET);
-
- goto exit_success;
- }
-
- /* must be either:
- a) programmer error
- b) no memory
- -> lets bail
- */
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "fopencookie failed");
- return FAILURE;
-#endif
-
- if (!php_stream_is_filtered(stream) && stream->ops->cast && stream->ops->cast(stream, castas, NULL TSRMLS_CC) == SUCCESS) {
- if (FAILURE == stream->ops->cast(stream, castas, ret TSRMLS_CC)) {
- return FAILURE;
- }
- goto exit_success;
- } else if (flags & PHP_STREAM_CAST_TRY_HARD) {
- php_stream *newstream;
-
- newstream = php_stream_fopen_tmpfile();
- if (newstream) {
- size_t copied = php_stream_copy_to_stream(stream, newstream, PHP_STREAM_COPY_ALL);
-
- if (copied == 0) {
- php_stream_close(newstream);
- } else {
- int retcode = php_stream_cast(newstream, castas | flags, ret, show_err);
-
- if (retcode == SUCCESS)
- rewind((FILE*)*ret);
-
- /* do some specialized cleanup */
- if ((flags & PHP_STREAM_CAST_RELEASE)) {
- php_stream_free(stream, PHP_STREAM_FREE_CLOSE_CASTED);
- }
-
- return retcode;
- }
- }
- }
- }
-
- if (php_stream_is_filtered(stream)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot cast a filtered stream on this system");
- return FAILURE;
- } else if (stream->ops->cast && stream->ops->cast(stream, castas, ret TSRMLS_CC) == SUCCESS) {
- goto exit_success;
- }
-
- if (show_err) {
- /* 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"
- };
-
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot represent a stream of type %s as a %s",
- stream->ops->label,
- cast_names[castas]
- );
- }
-
- return FAILURE;
-
-exit_success:
-
- if ((stream->writepos - stream->readpos) > 0 &&
- stream->fclose_stdiocast != PHP_STREAM_FCLOSE_FOPENCOOKIE &&
- (flags & PHP_STREAM_CAST_INTERNAL) == 0) {
- /* the data we have buffered will be lost to the third party library that
- * will be accessing the stream. Emit a warning so that the end-user will
- * know that they should try something else */
-
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "%d bytes of buffered data lost during stream conversion!",
- stream->writepos - stream->readpos);
- }
-
- if (castas == PHP_STREAM_AS_STDIO && ret)
- stream->stdiocast = *ret;
-
- if (flags & PHP_STREAM_CAST_RELEASE) {
- php_stream_free(stream, PHP_STREAM_FREE_CLOSE_CASTED);
- }
-
- return SUCCESS;
-
-}
-/* }}} */
-
-/* {{{ php_stream_open_wrapper_as_file */
-PHPAPI FILE * _php_stream_open_wrapper_as_file(char *path, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC)
-{
- FILE *fp = NULL;
- php_stream *stream = NULL;
-
- stream = php_stream_open_wrapper_rel(path, mode, options|STREAM_WILL_CAST, opened_path);
-
- if (stream == NULL)
- return NULL;
-
- if (php_stream_cast(stream, PHP_STREAM_AS_STDIO|PHP_STREAM_CAST_TRY_HARD|PHP_STREAM_CAST_RELEASE,
- (void**)&fp, REPORT_ERRORS) == FAILURE)
- {
- php_stream_close(stream);
- if (opened_path && *opened_path)
- efree(*opened_path);
- return NULL;
- }
- return fp;
-}
-/* }}} */
-
-/* {{{ php_stream_make_seekable */
-PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream, int flags STREAMS_DC TSRMLS_DC)
-{
- assert(newstream != NULL);
-
- *newstream = NULL;
-
- if (((flags & PHP_STREAM_FORCE_CONVERSION) == 0) && origstream->ops->seek != NULL) {
- *newstream = origstream;
- return PHP_STREAM_UNCHANGED;
- }
-
- /* Use a tmpfile and copy the old streams contents into it */
-
- if (flags & PHP_STREAM_PREFER_STDIO)
- *newstream = php_stream_fopen_tmpfile();
- else
- *newstream = php_stream_temp_new();
-
- if (*newstream == NULL)
- return PHP_STREAM_FAILED;
-
- if (php_stream_copy_to_stream(origstream, *newstream, PHP_STREAM_COPY_ALL) == 0) {
- php_stream_close(*newstream);
- *newstream = NULL;
- return PHP_STREAM_CRITICAL;
- }
-
- php_stream_close(origstream);
- php_stream_seek(*newstream, 0, SEEK_SET);
-
- return PHP_STREAM_RELEASED;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/filter.c b/main/streams/filter.c
deleted file mode 100644
index 678df03a46..0000000000
--- a/main/streams/filter.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#include "php_globals.h"
-#include "php_network.h"
-#include "php_open_temporary_file.h"
-#include "ext/standard/file.h"
-#include <stddef.h>
-#include <fcntl.h>
-
-#include "php_streams_int.h"
-
-static HashTable stream_filters_hash;
-
-PHPAPI HashTable *php_get_stream_filters_hash()
-{
- return &stream_filters_hash;
-}
-
-PHPAPI int php_stream_filter_register_factory(const char *filterpattern, php_stream_filter_factory *factory TSRMLS_DC)
-{
- return zend_hash_add(&stream_filters_hash, (char*)filterpattern, strlen(filterpattern), factory, sizeof(*factory), NULL);
-}
-
-PHPAPI int php_stream_filter_unregister_factory(const char *filterpattern TSRMLS_DC)
-{
- return zend_hash_del(&stream_filters_hash, (char*)filterpattern, strlen(filterpattern));
-}
-
-/* Buckets */
-
-PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, int own_buf, int buf_persistent TSRMLS_DC)
-{
- int is_persistent = php_stream_is_persistent(stream);
- php_stream_bucket *bucket;
-
- bucket = (php_stream_bucket*)pemalloc(sizeof(php_stream_bucket), is_persistent);
-
- if (bucket == NULL) {
- return NULL;
- }
-
- bucket->next = bucket->prev = NULL;
-
- if (is_persistent && !buf_persistent) {
- /* all data in a persistent bucket must also be persistent */
- bucket->buf = pemalloc(buflen, 1);
-
- if (bucket->buf == NULL) {
- pefree(bucket, 1);
- return NULL;
- }
-
- memcpy(bucket->buf, buf, buflen);
- bucket->buflen = buflen;
- bucket->own_buf = 1;
- } else {
- bucket->buf = buf;
- bucket->buflen = buflen;
- bucket->own_buf = own_buf;
- }
- bucket->is_persistent = is_persistent;
- bucket->refcount = 1;
-
- return bucket;
-}
-
-/* Given a bucket, returns a version of that bucket with a writeable buffer.
- * If the original bucket has a refcount of 1 and owns its buffer, then it
- * is returned unchanged.
- * Otherwise, a copy of the buffer is made.
- * In both cases, the original bucket is unlinked from its brigade.
- * If a copy is made, the original bucket is delref'd.
- * */
-PHPAPI php_stream_bucket *php_stream_bucket_make_writeable(php_stream_bucket *bucket TSRMLS_DC)
-{
- php_stream_bucket *retval;
-
- php_stream_bucket_unlink(bucket TSRMLS_CC);
-
- if (bucket->refcount == 1 && bucket->own_buf) {
- return bucket;
- }
-
- retval = (php_stream_bucket*)pemalloc(sizeof(php_stream_bucket), bucket->is_persistent);
- memcpy(retval, bucket, sizeof(*retval));
-
- retval->buf = pemalloc(retval->buflen, retval->is_persistent);
- memcpy(retval->buf, bucket->buf, retval->buflen);
-
- retval->refcount = 1;
- retval->own_buf = 1;
-
- php_stream_bucket_delref(bucket TSRMLS_CC);
-
- return retval;
-}
-
-PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **left, php_stream_bucket **right, size_t length TSRMLS_DC)
-{
- *left = (php_stream_bucket*)pecalloc(1, sizeof(php_stream_bucket), in->is_persistent);
- *right = (php_stream_bucket*)pecalloc(1, sizeof(php_stream_bucket), in->is_persistent);
-
- if (*left == NULL || *right == NULL) {
- goto exit_fail;
- }
-
- (*left)->buf = pemalloc(length, in->is_persistent);
- (*left)->buflen = length;
- memcpy((*left)->buf, in->buf, length);
- (*left)->refcount = 1;
- (*left)->own_buf = 1;
- (*left)->is_persistent = in->is_persistent;
-
- (*right)->buflen = in->buflen - length;
- (*right)->buf = pemalloc((*right)->buflen, in->is_persistent);
- memcpy((*right)->buf, in->buf + length, (*right)->buflen);
- (*right)->refcount = 1;
- (*right)->own_buf = 1;
- (*right)->is_persistent = in->is_persistent;
-
- return SUCCESS;
-
-exit_fail:
- if (*right) {
- if ((*right)->buf) {
- pefree((*right)->buf, in->is_persistent);
- }
- pefree(*right, in->is_persistent);
- }
- if (*left) {
- if ((*left)->buf) {
- pefree((*left)->buf, in->is_persistent);
- }
- pefree(*left, in->is_persistent);
- }
- return FAILURE;
-}
-
-PHPAPI void php_stream_bucket_delref(php_stream_bucket *bucket TSRMLS_DC)
-{
- if (--bucket->refcount == 0) {
- if (bucket->own_buf) {
- pefree(bucket->buf, bucket->is_persistent);
- }
- pefree(bucket, bucket->is_persistent);
- }
-}
-
-PHPAPI void php_stream_bucket_prepend(php_stream_bucket_brigade *brigade, php_stream_bucket *bucket TSRMLS_DC)
-{
- bucket->next = brigade->head;
- bucket->prev = NULL;
-
- if (brigade->head) {
- brigade->head->prev = bucket;
- } else {
- brigade->tail = bucket;
- }
- brigade->head = bucket;
- bucket->brigade = brigade;
-}
-
-PHPAPI void php_stream_bucket_append(php_stream_bucket_brigade *brigade, php_stream_bucket *bucket TSRMLS_DC)
-{
- bucket->prev = brigade->tail;
- bucket->next = NULL;
-
- if (brigade->tail) {
- brigade->tail->next = bucket;
- } else {
- brigade->head = bucket;
- }
- brigade->tail = bucket;
- bucket->brigade = brigade;
-}
-
-PHPAPI void php_stream_bucket_unlink(php_stream_bucket *bucket TSRMLS_DC)
-{
- if (bucket->prev) {
- bucket->prev->next = bucket->next;
- } else {
- bucket->brigade->head = bucket->next;
- }
- if (bucket->next) {
- bucket->next->prev = bucket->prev;
- } else {
- bucket->brigade->tail = bucket->prev;
- }
- bucket->brigade = NULL;
- bucket->next = bucket->prev = NULL;
-}
-
-
-
-
-
-
-
-
-/* We allow very simple pattern matching for filter factories:
- * if "charset.utf-8/sjis" is requested, we search first for an exact
- * match. If that fails, we try "charset.*".
- * This means that we don't need to clog up the hashtable with a zillion
- * charsets (for example) but still be able to provide them all as filters */
-PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, const char *filterparams, int filterparamslen, int persistent TSRMLS_DC)
-{
- php_stream_filter_factory *factory;
- php_stream_filter *filter = NULL;
- int n;
- char *period;
-
- n = strlen(filtername);
-
- if (SUCCESS == zend_hash_find(&stream_filters_hash, (char*)filtername, n, (void**)&factory)) {
- filter = factory->create_filter(filtername, filterparams, filterparamslen, persistent TSRMLS_CC);
- } else if ((period = strchr(filtername, '.'))) {
- /* try a wildcard */
- char wildname[128];
-
- PHP_STRLCPY(wildname, filtername, sizeof(wildname) - 1, period-filtername + 1);
- strcat(wildname, "*");
-
- if (SUCCESS == zend_hash_find(&stream_filters_hash, wildname, strlen(wildname), (void**)&factory)) {
- filter = factory->create_filter(filtername, filterparams, filterparamslen, persistent TSRMLS_CC);
- }
- }
-
- if (filter == NULL) {
- /* TODO: these need correct docrefs */
- if (factory == NULL)
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to locate filter \"%s\"", filtername);
- else
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to create or locate filter \"%s\"", filtername);
- }
-
- return filter;
-}
-
-PHPAPI php_stream_filter *_php_stream_filter_alloc(php_stream_filter_ops *fops, void *abstract, int persistent STREAMS_DC TSRMLS_DC)
-{
- php_stream_filter *filter;
-
- filter = (php_stream_filter*) pemalloc_rel_orig(sizeof(php_stream_filter), persistent);
- memset(filter, 0, sizeof(php_stream_filter));
-
- filter->fops = fops;
- filter->abstract = abstract;
- filter->is_persistent = persistent;
-
- return filter;
-}
-
-PHPAPI void php_stream_filter_free(php_stream_filter *filter TSRMLS_DC)
-{
- if (filter->fops->dtor)
- filter->fops->dtor(filter TSRMLS_CC);
- pefree(filter, filter->is_persistent);
-}
-
-PHPAPI void php_stream_filter_prepend(php_stream_filter_chain *chain, php_stream_filter *filter)
-{
- filter->next = chain->head;
- filter->prev = NULL;
-
- if (chain->head) {
- chain->head->prev = filter;
- } else {
- chain->tail = filter;
- }
- chain->head = filter;
- filter->chain = chain;
-}
-
-PHPAPI void php_stream_filter_append(php_stream_filter_chain *chain, php_stream_filter *filter)
-{
- filter->prev = chain->tail;
- filter->next = NULL;
- if (chain->tail) {
- chain->tail->next = filter;
- } else {
- chain->head = filter;
- }
- chain->tail = filter;
- filter->chain = chain;
-}
-
-PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, int call_dtor TSRMLS_DC)
-{
- if (filter->prev) {
- filter->prev->next = filter->next;
- } else {
- filter->chain->head = filter->next;
- }
- if (filter->next) {
- filter->next->prev = filter->prev;
- } else {
- filter->chain->tail = filter->prev;
- }
- if (call_dtor) {
- php_stream_filter_free(filter TSRMLS_CC);
- return NULL;
- }
- return filter;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/memory.c b/main/streams/memory.c
deleted file mode 100644
index 3446a9906d..0000000000
--- a/main/streams/memory.c
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Marcus Boerger <helly@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#define _GNU_SOURCE
-#include "php.h"
-
-/* Memory streams use a dynamic memory buffer to emulate a stream.
- * You can use php_stream_memory_open to create a readonly stream
- * from an existing memory buffer.
- */
-
-/* Temp streams are streams that uses memory streams as long their
- * size is less than a given memory amount. When a write operation
- * exceeds that limit the content is written to a temporary file.
- */
-
-/* {{{ ------- MEMORY stream implementation -------*/
-
-typedef struct {
- char *data;
- size_t fpos;
- size_t fsize;
- size_t smax;
- int mode;
-} php_stream_memory_data;
-
-
-/* {{{ */
-static size_t php_stream_memory_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
-{
- php_stream_memory_data *ms;
-
- assert(stream != NULL);
- ms = stream->abstract;
- assert(ms != NULL);
-
- if (ms->mode & TEMP_STREAM_READONLY) {
- return 0;
- }
- if (ms->fpos + count > ms->fsize) {
- char *tmp;
-
- if (!ms->data) {
- tmp = emalloc(ms->fpos + count);
- } else {
- tmp = erealloc(ms->data, ms->fpos + count);
- }
- if (!tmp) {
- count = ms->fsize - ms->fpos + 1;
- } else {
- ms->data = tmp;
- ms->fsize = ms->fpos + count;
- }
- }
- if (!ms->data)
- count = 0;
- if (count) {
- assert(buf!= NULL);
- memcpy(ms->data+ms->fpos, (char*)buf, count);
- ms->fpos += count;
- }
- return count;
-}
-/* }}} */
-
-
-/* {{{ */
-static size_t php_stream_memory_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
-{
- php_stream_memory_data *ms;
-
- assert(stream != NULL);
- ms = stream->abstract;
- assert(ms != NULL);
-
- if (ms->fpos + count > ms->fsize) {
- count = ms->fsize - ms->fpos;
- }
- if (count) {
- assert(ms->data!= NULL);
- assert(buf!= NULL);
- memcpy(buf, ms->data+ms->fpos, count);
- ms->fpos += count;
- } else {
- stream->eof = 1;
- }
- return count;
-}
-/* }}} */
-
-
-/* {{{ */
-static int php_stream_memory_close(php_stream *stream, int close_handle TSRMLS_DC)
-{
- php_stream_memory_data *ms;
-
- assert(stream != NULL);
- ms = stream->abstract;
- assert(ms != NULL);
-
- if (ms->data && close_handle && ms->mode != TEMP_STREAM_READONLY) {
- efree(ms->data);
- }
- efree(ms);
- return 0;
-}
-/* }}} */
-
-
-/* {{{ */
-static int php_stream_memory_flush(php_stream *stream TSRMLS_DC)
-{
- /* nothing to do here */
- return 0;
-}
-/* }}} */
-
-
-/* {{{ */
-static int php_stream_memory_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
-{
- php_stream_memory_data *ms;
-
- assert(stream != NULL);
- ms = stream->abstract;
- assert(ms != NULL);
-
- switch(whence) {
- case SEEK_CUR:
- if (offset < 0) {
- if (ms->fpos < (size_t)(-offset)) {
- ms->fpos = 0;
- /*return EINVAL;*/
- } else {
- ms->fpos = ms->fpos + offset;
- }
- } else {
- if (ms->fpos < (size_t)(offset)) {
- ms->fpos = ms->fsize;
- /*return EINVAL;*/
- } else {
- ms->fpos = ms->fpos + offset;
- }
- }
- *newoffs = ms->fpos;
- return 0;
- case SEEK_SET:
- if (ms->fsize < (size_t)(offset)) {
- ms->fpos = ms->fsize;
- /*return EINVAL;*/
- } else {
- ms->fpos = offset;
- }
- *newoffs = ms->fpos;
- return 0;
- case SEEK_END:
- if (offset > 0) {
- ms->fpos = ms->fsize;
- /*return EINVAL;*/
- } else if (ms->fpos < (size_t)(-offset)) {
- ms->fpos = 0;
- /*return EINVAL;*/
- } else {
- ms->fpos = ms->fsize + offset;
- }
- *newoffs = ms->fpos;
- return 0;
- default:
- return 0;
- /*return EINVAL;*/
- }
-}
-/* }}} */
-
-/* {{{ */
-static int php_stream_memory_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
-{
- return FAILURE;
-}
-/* }}} */
-
-
-php_stream_ops php_stream_memory_ops = {
- php_stream_memory_write, php_stream_memory_read,
- php_stream_memory_close, php_stream_memory_flush,
- "MEMORY",
- php_stream_memory_seek,
- php_stream_memory_cast,
- NULL, /* stat */
- NULL /* set_option */
-};
-
-
-/* {{{ */
-PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC TSRMLS_DC)
-{
- php_stream_memory_data *self;
- php_stream *stream;
-
- self = emalloc(sizeof(*self));
- self->data = NULL;
- self->fpos = 0;
- self->fsize = 0;
- self->smax = -1;
- self->mode = mode;
-
- stream = php_stream_alloc(&php_stream_memory_ops, self, 0, "r+b");
- stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
- return stream;
-}
-/* }}} */
-
-
-/* {{{ */
-PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC TSRMLS_DC)
-{
- php_stream *stream;
- php_stream_memory_data *ms;
-
- if ((stream = php_stream_memory_create_rel(mode)) != NULL) {
- ms = stream->abstract;
-
- if (mode == TEMP_STREAM_READONLY) {
- /* use the buffer directly */
- ms->data = buf;
- ms->fsize = length;
- } else {
- if (length) {
- assert(buf != NULL);
- php_stream_write(stream, buf, length);
- }
- }
- }
- return stream;
-}
-/* }}} */
-
-
-/* {{{ */
-PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC TSRMLS_DC)
-{
- php_stream_memory_data *ms;
-
- assert(stream != NULL);
- ms = stream->abstract;
- assert(ms != NULL);
- assert(length != 0);
-
- *length = ms->fsize;
- return ms->data;
-}
-/* }}} */
-
-/* }}} */
-
-/* {{{ ------- TEMP stream implementation -------*/
-
-typedef struct {
- php_stream *innerstream;
- size_t smax;
- int mode;
-} php_stream_temp_data;
-
-
-/* {{{ */
-static size_t php_stream_temp_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
-{
- php_stream_temp_data *ts;
-
- assert(stream != NULL);
- ts = stream->abstract;
- assert(ts != NULL);
-
- if (php_stream_is(ts->innerstream, PHP_STREAM_IS_MEMORY)) {
- size_t memsize;
- char *membuf = php_stream_memory_get_buffer(ts->innerstream, &memsize);
-
- if (memsize + count >= ts->smax) {
- php_stream *file = php_stream_fopen_tmpfile();
- php_stream_write(file, membuf, memsize);
- php_stream_close(ts->innerstream);
- ts->innerstream = file;
- }
- }
- return php_stream_write(ts->innerstream, buf, count);
-}
-/* }}} */
-
-
-/* {{{ */
-static size_t php_stream_temp_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
-{
- php_stream_temp_data *ts;
-
- assert(stream != NULL);
- ts = stream->abstract;
- assert(ts != NULL);
-
- return php_stream_read(ts->innerstream, buf, count);
-}
-/* }}} */
-
-
-/* {{{ */
-static int php_stream_temp_close(php_stream *stream, int close_handle TSRMLS_DC)
-{
- php_stream_temp_data *ts;
- int ret;
-
- assert(stream != NULL);
- ts = stream->abstract;
- assert(ts != NULL);
-
- ret = php_stream_free(ts->innerstream, PHP_STREAM_FREE_CLOSE | (close_handle ? 0 : PHP_STREAM_FREE_PRESERVE_HANDLE));
-
- efree(ts);
-
- return ret;
-}
-/* }}} */
-
-
-/* {{{ */
-static int php_stream_temp_flush(php_stream *stream TSRMLS_DC)
-{
- php_stream_temp_data *ts;
-
- assert(stream != NULL);
- ts = stream->abstract;
- assert(ts != NULL);
-
- return php_stream_flush(ts->innerstream);
-}
-/* }}} */
-
-
-/* {{{ */
-static int php_stream_temp_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
-{
- php_stream_temp_data *ts;
- int ret;
-
- assert(stream != NULL);
- ts = stream->abstract;
- assert(ts != NULL);
-
- ret = php_stream_seek(ts->innerstream, offset, whence);
- *newoffs = php_stream_tell(ts->innerstream);
-
- return ret;
-}
-/* }}} */
-
-/* {{{ */
-static int php_stream_temp_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
-{
- php_stream_temp_data *ts;
- php_stream *file;
- size_t memsize;
- char *membuf;
- off_t pos;
-
- assert(stream != NULL);
- ts = stream->abstract;
- assert(ts != NULL);
-
- if (php_stream_is(ts->innerstream, PHP_STREAM_IS_STDIO)) {
- return php_stream_cast(ts->innerstream, castas, ret, 0);
- }
-
- /* we are still using a memory based backing. If they are if we can be
- * a FILE*, say yes because we can perform the conversion.
- * If they actually want to perform the conversion, we need to switch
- * the memory stream to a tmpfile stream */
-
- if (ret == NULL && castas == PHP_STREAM_AS_STDIO) {
- return SUCCESS;
- }
-
- /* say "no" to other stream forms */
- if (ret == NULL) {
- return FAILURE;
- }
-
- /* perform the conversion and then pass the request on to the innerstream */
- membuf = php_stream_memory_get_buffer(ts->innerstream, &memsize);
- file = php_stream_fopen_tmpfile();
- php_stream_write(file, membuf, memsize);
- pos = php_stream_tell(ts->innerstream);
-
- php_stream_close(ts->innerstream);
- ts->innerstream = file;
- php_stream_seek(ts->innerstream, pos, SEEK_SET);
-
- return php_stream_cast(ts->innerstream, castas, ret, 1);
-}
-/* }}} */
-
-php_stream_ops php_stream_temp_ops = {
- php_stream_temp_write, php_stream_temp_read,
- php_stream_temp_close, php_stream_temp_flush,
- "TEMP",
- php_stream_temp_seek,
- php_stream_temp_cast,
- NULL, /* stat */
- NULL /* set_option */
-};
-
-
-/* {{{ */
-PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC)
-{
- php_stream_temp_data *self;
- php_stream *stream;
-
- self = ecalloc(1, sizeof(*self));
- self->smax = max_memory_usage;
- self->mode = mode;
- stream = php_stream_alloc(&php_stream_temp_ops, self, 0, "r+b");
- stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
- self->innerstream = php_stream_memory_create(mode);
-
- return stream;
-}
-/* }}} */
-
-
-/* {{{ */
-PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC)
-{
- php_stream *stream;
- php_stream_temp_data *ms;
-
- if ((stream = php_stream_temp_create_rel(mode & ~TEMP_STREAM_READONLY, max_memory_usage)) != NULL) {
- if (length) {
- assert(buf != NULL);
- php_stream_temp_write(stream, buf, length TSRMLS_CC);
- }
- ms = stream->abstract;
- assert(ms != NULL);
- ms->mode = mode;
- }
- return stream;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
deleted file mode 100644
index 791b96436f..0000000000
--- a/main/streams/mmap.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-/* Memory Mapping interface for streams */
-#include "php.h"
-#include "php_streams_int.h"
-
-PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t length, php_stream_mmap_operation_t mode, size_t *mapped_len TSRMLS_DC)
-{
- php_stream_mmap_range range = { offset, length, mode, NULL };
-
- /* TODO: Enforce system policy and limits for mmap sizes ? */
-
- if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_MAP_RANGE, &range)) {
- if (mapped_len) {
- *mapped_len = range.length;
- }
- return range.mapped;
- }
- return NULL;
-}
-
-PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC)
-{
- return php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_UNMAP, NULL) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h
deleted file mode 100644
index 2094b4c8a3..0000000000
--- a/main/streams/php_stream_context.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* Stream context and status notification related definitions */
-
-/* callback for status notifications */
-typedef void (*php_stream_notification_func)(php_stream_context *context,
- int notifycode, int severity,
- char *xmsg, int xcode,
- size_t bytes_sofar, size_t bytes_max,
- void * ptr TSRMLS_DC);
-
-#define PHP_STREAM_NOTIFIER_PROGRESS 1
-
-typedef struct _php_stream_notifier {
- php_stream_notification_func func;
- void *ptr;
- int mask;
- size_t progress, progress_max; /* position for progress notification */
-} php_stream_notifier;
-
-struct _php_stream_context {
- php_stream_notifier *notifier;
- zval *options; /* hash keyed by wrapper family or specific wrapper */
-};
-
-PHPAPI void php_stream_context_free(php_stream_context *context);
-PHPAPI php_stream_context *php_stream_context_alloc(void);
-PHPAPI int php_stream_context_get_option(php_stream_context *context,
- const char *wrappername, const char *optionname, zval ***optionvalue);
-PHPAPI int php_stream_context_set_option(php_stream_context *context,
- const char *wrappername, const char *optionname, zval *optionvalue);
-
-PHPAPI php_stream_notifier *php_stream_notification_alloc(void);
-PHPAPI void php_stream_notification_free(php_stream_notifier *notifier);
-
-/* not all notification codes are implemented */
-#define PHP_STREAM_NOTIFY_RESOLVE 1
-#define PHP_STREAM_NOTIFY_CONNECT 2
-#define PHP_STREAM_NOTIFY_AUTH_REQUIRED 3
-#define PHP_STREAM_NOTIFY_MIME_TYPE_IS 4
-#define PHP_STREAM_NOTIFY_FILE_SIZE_IS 5
-#define PHP_STREAM_NOTIFY_REDIRECTED 6
-#define PHP_STREAM_NOTIFY_PROGRESS 7
-#define PHP_STREAM_NOTIFY_COMPLETED 8
-#define PHP_STREAM_NOTIFY_FAILURE 9
-#define PHP_STREAM_NOTIFY_AUTH_RESULT 10
-
-#define PHP_STREAM_NOTIFY_SEVERITY_INFO 0
-#define PHP_STREAM_NOTIFY_SEVERITY_WARN 1
-#define PHP_STREAM_NOTIFY_SEVERITY_ERR 2
-
-PHPAPI void php_stream_notification_notify(php_stream_context *context, int notifycode, int severity,
- char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void * ptr TSRMLS_DC);
-PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream_context *context);
-
-#define php_stream_notify_info(context, code, xmsg, xcode) do { if ((context) && (context)->notifier) { \
- php_stream_notification_notify((context), (code), PHP_STREAM_NOTIFY_SEVERITY_INFO, \
- (xmsg), (xcode), 0, 0, NULL TSRMLS_CC); } } while (0)
-
-#define php_stream_notify_progress(context, bsofar, bmax) do { if ((context) && (context)->notifier) { \
- php_stream_notification_notify((context), PHP_STREAM_NOTIFY_PROGRESS, PHP_STREAM_NOTIFY_SEVERITY_INFO, \
- NULL, 0, (bsofar), (bmax), NULL TSRMLS_CC); } } while(0)
-
-#define php_stream_notify_progress_init(context, sofar, bmax) do { if ((context) && (context)->notifier) { \
- (context)->notifier->progress = (sofar); \
- (context)->notifier->progress_max = (bmax); \
- (context)->notifier->mask |= PHP_STREAM_NOTIFIER_PROGRESS; \
- php_stream_notify_progress((context), (sofar), (bmax)); } } while (0)
-
-#define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && (context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS) { \
- (context)->notifier->progress += (dsofar); \
- (context)->notifier->progress_max += (dmax); \
- php_stream_notify_progress((context), (context)->notifier->progress, (context)->notifier->progress_max); } } while (0)
-
-#define php_stream_notify_file_size(context, file_size, xmsg, xcode) do { if ((context) && (context)->notifier) { \
- php_stream_notification_notify((context), PHP_STREAM_NOTIFY_FILE_SIZE_IS, PHP_STREAM_NOTIFY_SEVERITY_INFO, \
- (xmsg), (xcode), 0, (file_size), NULL TSRMLS_CC); } } while(0)
-
-#define php_stream_notify_error(context, code, xmsg, xcode) do { if ((context) && (context)->notifier) {\
- php_stream_notification_notify((context), (code), PHP_STREAM_NOTIFY_SEVERITY_ERR, \
- (xmsg), (xcode), 0, 0, NULL TSRMLS_CC); } } while(0)
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h
deleted file mode 100644
index c23f7f70c7..0000000000
--- a/main/streams/php_stream_filter_api.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong <wez@thebrainroom.com> |
- | With suggestions from: |
- | Moriyoshi Koizumi <moriyoshi@at.wakwak.com> |
- | Sara Golemon <pollita@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* The filter API works on the principle of "Bucket-Brigades". This is
- * partially inspired by the Apache 2 method of doing things, although
- * it is intentially a light-weight implementation.
- *
- * Each stream can have a chain of filters for reading and another for writing.
- *
- * When data is written to the stream, is is placed into a bucket and placed at
- * the start of the input brigade.
- *
- * The first filter in the chain is invoked on the brigade and (depending on
- * it's return value), the next filter is invoked and so on.
- * */
-
-#define PHP_STREAM_FILTER_READ 0x0001
-#define PHP_STREAM_FILTER_WRITE 0x0002
-#define PHP_STREAM_FILTER_ALL (PHP_STREAM_FILTER_READ | PHP_STREAM_FILTER_WRITE)
-
-typedef struct _php_stream_bucket php_stream_bucket;
-typedef struct _php_stream_bucket_brigade php_stream_bucket_brigade;
-
-struct _php_stream_bucket {
- php_stream_bucket *next, *prev;
- php_stream_bucket_brigade *brigade;
-
- char *buf;
- size_t buflen;
- /* if non-zero, buf should be pefreed when the bucket is destroyed */
- int own_buf;
- int is_persistent;
-
- /* destroy this struct when refcount falls to zero */
- int refcount;
-};
-
-struct _php_stream_bucket_brigade {
- php_stream_bucket *head, *tail;
-};
-
-typedef enum {
- PSFS_ERR_FATAL, /* error in data stream */
- PSFS_FEED_ME, /* filter needs more data; stop processing chain until more is available */
- PSFS_PASS_ON, /* filter generated output buckets; pass them on to next in chain */
-} php_stream_filter_status_t;
-
-/* Buckets API. */
-PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, int own_buf, int buf_persistent TSRMLS_DC);
-PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **left, php_stream_bucket **right, size_t length TSRMLS_DC);
-PHPAPI void php_stream_bucket_delref(php_stream_bucket *bucket TSRMLS_DC);
-#define php_stream_bucket_addref(bucket) (bucket)->refcount++
-PHPAPI void php_stream_bucket_prepend(php_stream_bucket_brigade *brigade, php_stream_bucket *bucket TSRMLS_DC);
-PHPAPI void php_stream_bucket_append(php_stream_bucket_brigade *brigade, php_stream_bucket *bucket TSRMLS_DC);
-PHPAPI void php_stream_bucket_unlink(php_stream_bucket *bucket TSRMLS_DC);
-PHPAPI php_stream_bucket *php_stream_bucket_make_writeable(php_stream_bucket *bucket TSRMLS_DC);
-
-#define PSFS_FLAG_NORMAL 0 /* regular read/write */
-#define PSFS_FLAG_FLUSH_INC 1 /* an incremental flush */
-#define PSFS_FLAG_FLUSH_CLOSE 2 /* final flush prior to closing */
-
-typedef struct _php_stream_filter_ops {
-
- php_stream_filter_status_t (*filter)(
- php_stream *stream,
- php_stream_filter *thisfilter,
- php_stream_bucket_brigade *buckets_in,
- php_stream_bucket_brigade *buckets_out,
- size_t *bytes_consumed,
- int flags
- TSRMLS_DC);
-
- void (*dtor)(php_stream_filter *thisfilter TSRMLS_DC);
-
- const char *label;
-
-} php_stream_filter_ops;
-
-typedef struct _php_stream_filter_chain {
- php_stream_filter *head, *tail;
-} php_stream_filter_chain;
-
-struct _php_stream_filter {
- php_stream_filter_ops *fops;
- void *abstract; /* for use by filter implementation */
- php_stream_filter *next;
- php_stream_filter *prev;
- int is_persistent;
-
- /* link into stream and chain */
- php_stream_filter_chain *chain;
-
- /* buffered buckets */
- php_stream_bucket_brigade buffer;
-};
-
-/* stack filter onto a stream */
-PHPAPI void php_stream_filter_prepend(php_stream_filter_chain *chain, php_stream_filter *filter);
-PHPAPI void php_stream_filter_append(php_stream_filter_chain *chain, php_stream_filter *filter);
-PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, int call_dtor TSRMLS_DC);
-PHPAPI void php_stream_filter_free(php_stream_filter *filter TSRMLS_DC);
-PHPAPI php_stream_filter *_php_stream_filter_alloc(php_stream_filter_ops *fops, void *abstract, int persistent STREAMS_DC TSRMLS_DC);
-#define php_stream_filter_alloc(fops, thisptr, persistent) _php_stream_filter_alloc((fops), (thisptr), (persistent) STREAMS_CC TSRMLS_CC)
-#define php_stream_filter_alloc_rel(fops, thisptr, persistent) _php_stream_filter_alloc((fops), (thisptr), (persistent) STREAMS_REL_CC TSRMLS_CC)
-
-#define php_stream_is_filtered(stream) ((stream)->readfilters.head || (stream)->writefilters.head)
-
-typedef struct _php_stream_filter_factory {
- php_stream_filter *(*create_filter)(const char *filtername, const char *filterparams, int filterparamslen, int persistent TSRMLS_DC);
-} php_stream_filter_factory;
-
-PHPAPI int php_stream_filter_register_factory(const char *filterpattern, php_stream_filter_factory *factory TSRMLS_DC);
-PHPAPI int php_stream_filter_unregister_factory(const char *filterpattern TSRMLS_DC);
-PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, const char *filterparams, int filterparamslen, int persistent TSRMLS_DC);
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h
deleted file mode 100644
index ccfc767246..0000000000
--- a/main/streams/php_stream_mmap.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-/* Memory Mapping interface for streams.
- * The intention is to provide a uniform interface over the most common
- * operations that are used within PHP itself, rather than a complete
- * API for all memory mapping needs.
- *
- * ATM, we support only mmap(), but win32 memory mapping support will
- * follow soon.
- * */
-
-typedef enum {
- /* Does the stream support mmap ? */
- PHP_STREAM_MMAP_SUPPORTED,
- /* Request a range and offset to be mapped;
- * while mapped, you MUST NOT use any read/write functions
- * on the stream (win9x compatibility) */
- PHP_STREAM_MMAP_MAP_RANGE,
- /* Unmap the last range that was mapped for the stream */
- PHP_STREAM_MMAP_UNMAP
-} php_stream_mmap_operation_t;
-
-typedef enum {
- PHP_STREAM_MAP_MODE_READONLY,
- PHP_STREAM_MAP_MODE_READWRITE,
- PHP_STREAM_MAP_MODE_SHARED_READONLY,
- PHP_STREAM_MAP_MODE_SHARED_READWRITE
-} php_stream_mmap_access_t;
-
-typedef struct {
- /* requested offset and length.
- * If length is 0, the whole file is mapped */
- size_t offset;
- size_t length;
-
- php_stream_mmap_access_t mode;
-
- /* returned mapped address */
- char *mapped;
-
-} php_stream_mmap_range;
-
-#define php_stream_mmap_supported(stream) (_php_stream_set_option((stream), PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_SUPPORTED, NULL TSRMLS_CC) == 0 ? 1 : 0)
-
-/* Returns 1 if the stream in its current state can be memory mapped,
- * 0 otherwise */
-#define php_stream_mmap_possible(stream) (!php_stream_is_filtered((stream)) && php_stream_mmap_supported((stream)))
-
-PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t length, php_stream_mmap_operation_t mode, size_t *mapped_len TSRMLS_DC);
-#define php_stream_mmap_range(stream, offset, length, mode, mapped_len) _php_stream_mmap_range((stream), (offset), (length), (mode), (mapped_len) TSRMLS_CC)
-
-/* un-maps the last mapped range */
-PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC);
-#define php_stream_mmap_unmap(stream) _php_stream_mmap_unmap((stream) TSRMLS_CC)
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h
deleted file mode 100644
index 6568494433..0000000000
--- a/main/streams/php_stream_plain_wrapper.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* definitions for the plain files wrapper */
-
-/* operations for a plain file; use the php_stream_fopen_XXX funcs below */
-PHPAPI 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, char **opened_path, int options STREAMS_DC TSRMLS_DC);
-#define php_stream_fopen(filename, mode, opened) _php_stream_fopen((filename), (mode), (opened), 0 STREAMS_CC TSRMLS_CC)
-
-PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path, int options STREAMS_DC TSRMLS_DC);
-#define php_stream_fopen_with_path(filename, mode, path, opened) _php_stream_fopen_with_path((filename), (mode), (path), (opened) STREAMS_CC TSRMLS_CC)
-
-PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC TSRMLS_DC);
-#define php_stream_fopen_from_file(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_CC TSRMLS_CC)
-
-PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode STREAMS_DC TSRMLS_DC);
-#define php_stream_fopen_from_fd(fd, mode) _php_stream_fopen_from_fd((fd), (mode) STREAMS_CC TSRMLS_CC)
-
-PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STREAMS_DC TSRMLS_DC);
-#define php_stream_fopen_from_pipe(file, mode) _php_stream_fopen_from_pipe((file), (mode) STREAMS_CC TSRMLS_CC)
-
-PHPAPI php_stream *_php_stream_fopen_tmpfile(int dummy STREAMS_DC TSRMLS_DC);
-#define php_stream_fopen_tmpfile() _php_stream_fopen_tmpfile(0 STREAMS_CC TSRMLS_CC)
-
-PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path STREAMS_DC TSRMLS_DC);
-#define php_stream_fopen_temporary_file(dir, pfx, opened_path) _php_stream_fopen_temporary_file((dir), (pfx), (opened_path) STREAMS_CC TSRMLS_CC)
-
-/* This is a utility API for extensions that are opening a stream, converting it
- * to a FILE* and then closing it again. Be warned that fileno() on the result
- * will most likely fail on systems with fopencookie. */
-PHPAPI FILE * _php_stream_open_wrapper_as_file(char * path, char * mode, int options, char **opened_path STREAMS_DC TSRMLS_DC);
-#define php_stream_open_wrapper_as_file(path, mode, options, opened_path) _php_stream_open_wrapper_as_file((path), (mode), (options), (opened_path) STREAMS_CC TSRMLS_CC)
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h
deleted file mode 100644
index 89642b5652..0000000000
--- a/main/streams/php_stream_transport.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-typedef php_stream *(php_stream_transport_factory_func)(const char *proto, long protolen,
- char *resourcename, long resourcenamelen,
- const char *persistent_id, int options, int flags,
- struct timeval *timeout,
- php_stream_context *context STREAMS_DC TSRMLS_DC);
-typedef php_stream_transport_factory_func *php_stream_transport_factory;
-
-PHPAPI int php_stream_xport_register(char *protocol, php_stream_transport_factory factory TSRMLS_DC);
-PHPAPI int php_stream_xport_unregister(char *protocol TSRMLS_DC);
-
-#define STREAM_XPORT_CLIENT 0
-#define STREAM_XPORT_SERVER 1
-
-#define STREAM_XPORT_CONNECT 2
-#define STREAM_XPORT_BIND 4
-#define STREAM_XPORT_LISTEN 8
-#define STREAM_XPORT_CONNECT_ASYNC 16
-
-/* Open a client or server socket connection */
-PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int options,
- int flags, const char *persistent_id,
- struct timeval *timeout,
- php_stream_context *context,
- char **error_string,
- int *error_code
- STREAMS_DC TSRMLS_DC);
-
-#define php_stream_xport_create(name, namelen, options, flags, persistent_id, timeout, context, estr, ecode) \
- _php_stream_xport_create(name, namelen, options, flags, persistent_id, timeout, context, estr, ecode STREAMS_CC TSRMLS_CC)
-
-/* Bind the stream to a local address */
-PHPAPI int php_stream_xport_bind(php_stream *stream,
- const char *name, long namelen,
- char **error_text
- TSRMLS_DC);
-
-/* Connect to a remote address */
-PHPAPI int php_stream_xport_connect(php_stream *stream,
- const char *name, long namelen,
- int asynchronous,
- struct timeval *timeout,
- char **error_text,
- int *error_code
- TSRMLS_DC);
-
-/* Prepare to listen */
-PHPAPI int php_stream_xport_listen(php_stream *stream,
- int backlog,
- char **error_text
- TSRMLS_DC);
-
-/* Get the next client and their address as a string, or the underlying address
- * structure. You must efree either of these if you request them */
-PHPAPI int php_stream_xport_accept(php_stream *stream, php_stream **client,
- char **textaddr, long *textaddrlen,
- void **addr, size_t *addrlen,
- struct timeval *timeout,
- char **error_text
- TSRMLS_DC);
-
-/* Structure definition for the set_option interface that the above functions wrap */
-
-typedef struct _php_stream_xport_param {
- enum {
- STREAM_XPORT_OP_BIND, STREAM_XPORT_OP_CONNECT,
- STREAM_XPORT_OP_LISTEN, STREAM_XPORT_OP_ACCEPT,
- STREAM_XPORT_OP_CONNECT_ASYNC
- } op;
- int want_addr:1;
- int want_textaddr:1;
- int want_errortext:1;
-
- struct {
- char *name;
- long namelen;
- int backlog;
- struct timeval *timeout;
- } inputs;
- struct {
- php_stream *client;
- int returncode;
- void *addr;
- size_t addrlen;
- char *textaddr;
- long textaddrlen;
-
- char *error_text;
- int error_code;
- } outputs;
-} php_stream_xport_param;
-
-
-/* These functions provide crypto support on the underlying transport */
-typedef enum {
- STREAM_CRYPTO_METHOD_SSLv2_CLIENT,
- STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
- STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
- STREAM_CRYPTO_METHOD_TLS_CLIENT,
- STREAM_CRYPTO_METHOD_SSLv2_SERVER,
- STREAM_CRYPTO_METHOD_SSLv3_SERVER,
- STREAM_CRYPTO_METHOD_SSLv23_SERVER,
- STREAM_CRYPTO_METHOD_TLS_SERVER
-} php_stream_xport_crypt_method_t;
-
-PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_crypt_method_t crypto_method, php_stream *session_stream TSRMLS_DC);
-PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate TSRMLS_DC);
-
-typedef struct _php_stream_xport_crypto_param {
- enum {
- STREAM_XPORT_CRYPTO_OP_SETUP,
- STREAM_XPORT_CRYPTO_OP_ENABLE
- } op;
- struct {
- int activate;
- php_stream_xport_crypt_method_t method;
- php_stream *session;
- } inputs;
- struct {
- int returncode;
- } outputs;
-} php_stream_xport_crypto_param;
-
-PHPAPI HashTable *php_stream_xport_get_hash(void);
-PHPAPI php_stream_transport_factory_func php_stream_generic_socket_factory;
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/php_stream_userspace.h b/main/streams/php_stream_userspace.h
deleted file mode 100644
index 349cdd7fa5..0000000000
--- a/main/streams/php_stream_userspace.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-
-/* for user-space streams */
-PHPAPI extern php_stream_ops php_stream_userspace_ops;
-PHPAPI extern php_stream_ops php_stream_userspace_dir_ops;
-#define PHP_STREAM_IS_USERSPACE &php_stream_userspace_ops
-#define PHP_STREAM_IS_USERSPACE_DIR &php_stream_userspace_dir_ops
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h
deleted file mode 100644
index ddf569399d..0000000000
--- a/main/streams/php_streams_int.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#if ZEND_DEBUG
-#define emalloc_rel_orig(size) \
- ( __php_stream_call_depth == 0 \
- ? _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_RELAY_CC) \
- : _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) )
-
-#define erealloc_rel_orig(ptr, size) \
- ( __php_stream_call_depth == 0 \
- ? _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_RELAY_CC) \
- : _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) )
-
-
-#define pemalloc_rel_orig(size, persistent) ((persistent) ? malloc((size)) : emalloc_rel_orig((size)))
-#define perealloc_rel_orig(ptr, size, persistent) ((persistent) ? realloc((ptr), (size)) : erealloc_rel_orig((ptr), (size)))
-#else
-# define pemalloc_rel_orig(size, persistent) pemalloc((size), (persistent))
-# define perealloc_rel_orig(ptr, size, persistent) perealloc((ptr), (size), (persistent))
-# define emalloc_rel_orig(size) emalloc((size))
-#endif
-
-#define STREAM_DEBUG 0
-#define STREAM_WRAPPER_PLAIN_FILES ((php_stream_wrapper*)-1)
-extern php_stream_wrapper php_plain_files_wrapper;
-
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *) -1)
-#endif
-
-#define CHUNK_SIZE 8192
-
-#ifdef PHP_WIN32
-#define EWOULDBLOCK WSAEWOULDBLOCK
-#endif
-
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
-#endif
-
-void php_stream_tidy_wrapper_error_log(php_stream_wrapper *wrapper TSRMLS_DC);
-void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char *path, const char *caption TSRMLS_DC);
-
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
deleted file mode 100644
index f121b8ce15..0000000000
--- a/main/streams/plain_wrapper.c
+++ /dev/null
@@ -1,970 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include "php.h"
-#include "php_globals.h"
-#include "php_network.h"
-#include "php_open_temporary_file.h"
-#include "ext/standard/file.h"
-#include "ext/standard/flock_compat.h"
-#include <stddef.h>
-#include <fcntl.h>
-#if HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-
-#include "php_streams_int.h"
-
-/* parse standard "fopen" modes into open() flags */
-PHPAPI int php_stream_parse_fopen_modes(const char *mode, int *open_flags)
-{
- int flags;
-
- switch (mode[0]) {
- case 'r':
- flags = 0;
- break;
- case 'w':
- flags = O_TRUNC|O_CREAT;
- break;
- case 'a':
- flags = O_CREAT|O_APPEND;
- break;
- case 'x':
- flags = O_CREAT|O_EXCL;
- break;
- default:
- /* unknown mode */
- return FAILURE;
- }
-
- if (strchr(mode, '+')) {
- flags |= O_RDWR;
- } else if (flags) {
- flags |= O_WRONLY;
- } else {
- flags |= O_RDONLY;
- }
-
-#ifdef O_BINARY
- if (strchr(mode, 'b')) {
- flags |= O_BINARY;
- }
-#endif
-
- *open_flags = flags;
- return SUCCESS;
-}
-
-
-/* {{{ php_stream_fopen */
-PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, char **opened_path, int options STREAMS_DC TSRMLS_DC)
-{
- char *realpath = NULL;
- struct stat st;
- int open_flags;
- int fd;
- php_stream *ret;
-
- if (FAILURE == php_stream_parse_fopen_modes(mode, &open_flags)) {
- if (options & REPORT_ERRORS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "`%s' is not a valid mode for fopen", mode);
- }
- return NULL;
- }
-
- realpath = expand_filepath(filename, NULL TSRMLS_CC);
-
- fd = open(realpath, open_flags, 0666);
-
- if (fd != -1) {
- /* sanity checks for include/require */
- if (options & STREAM_OPEN_FOR_INCLUDE && (fstat(fd, &st) == -1 || !S_ISREG(st.st_mode))) {
-#ifdef PHP_WIN32
- /* skip the sanity check; fstat doesn't appear to work on
- * UNC paths */
- if (!IS_UNC_PATH(filename, strlen(filename)))
-#endif
- goto err;
- }
-
- ret = php_stream_fopen_from_fd_rel(fd, mode);
-
- if (ret) {
- if (opened_path) {
- *opened_path = realpath;
- realpath = NULL;
- }
- if (realpath)
- efree(realpath);
-
- return ret;
- }
-err:
- close(fd);
- }
- efree(realpath);
- return NULL;
-}
-/* }}} */
-
-/* {{{ ------- STDIO stream implementation -------*/
-
-typedef struct {
- FILE *file;
- int fd; /* underlying file descriptor */
- int is_process_pipe; /* use pclose instead of fclose */
- int is_pipe; /* don't try and seek */
- int lock_flag; /* stores the lock state */
- char *temp_file_name; /* if non-null, this is the path to a temporary file that
- * is to be deleted when the stream is closed */
-#if HAVE_FLUSHIO
- char last_op;
-#endif
-
-#if HAVE_MMAP
- char *last_mapped_addr;
- size_t last_mapped_len;
-#endif
-} php_stdio_stream_data;
-
-PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path STREAMS_DC TSRMLS_DC)
-{
- FILE *fp = php_open_temporary_file(dir, pfx, opened_path TSRMLS_CC);
-
- if (fp) {
- php_stream *stream = php_stream_fopen_from_file_rel(fp, "r+b");
- if (stream) {
- return stream;
- }
- fclose(fp);
-
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to allocate stream");
-
- return NULL;
- }
- return NULL;
-}
-
-PHPAPI php_stream *_php_stream_fopen_tmpfile(int dummy STREAMS_DC TSRMLS_DC)
-{
- char *opened_path = NULL;
- FILE *fp = php_open_temporary_file(NULL, "php", &opened_path TSRMLS_CC);
-
- if (fp) {
- php_stream *stream = php_stream_fopen_from_file_rel(fp, "r+b");
- if (stream) {
- php_stdio_stream_data *self = (php_stdio_stream_data*)stream->abstract;
-
- self->temp_file_name = opened_path;
- self->lock_flag = LOCK_UN;
-
- return stream;
- }
- fclose(fp);
-
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to allocate stream");
-
- return NULL;
- }
- return NULL;
-}
-
-PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode STREAMS_DC TSRMLS_DC)
-{
- php_stdio_stream_data *self;
- php_stream *stream;
-
- self = emalloc_rel_orig(sizeof(*self));
- self->file = NULL;
- self->is_pipe = 0;
- self->lock_flag = LOCK_UN;
- self->is_process_pipe = 0;
- self->temp_file_name = NULL;
- self->fd = fd;
-
-#ifdef S_ISFIFO
- /* detect if this is a pipe */
- if (self->fd >= 0) {
- struct stat sb;
- self->is_pipe = (fstat(self->fd, &sb) == 0 && S_ISFIFO(sb.st_mode)) ? 1 : 0;
- }
-#elif defined(PHP_WIN32)
- {
- long handle = _get_osfhandle(self->fd);
- DWORD in_buf_size, out_buf_size;
-
- if (handle != 0xFFFFFFFF) {
- self->is_pipe = GetNamedPipeInfo((HANDLE)handle, NULL, &out_buf_size, &in_buf_size, NULL);
- }
- }
-#endif
-
- stream = php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
-
- if (stream) {
- if (self->is_pipe) {
- stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
- } else {
- stream->position = lseek(self->fd, 0, SEEK_CUR);
- }
- }
-
- return stream;
-}
-
-PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC TSRMLS_DC)
-{
- php_stdio_stream_data *self;
- php_stream *stream;
-
- self = emalloc_rel_orig(sizeof(*self));
- self->file = file;
- self->is_pipe = 0;
- self->lock_flag = LOCK_UN;
- self->is_process_pipe = 0;
- self->temp_file_name = NULL;
- self->fd = fileno(file);
-
-#ifdef S_ISFIFO
- /* detect if this is a pipe */
- if (self->fd >= 0) {
- struct stat sb;
- self->is_pipe = (fstat(self->fd, &sb) == 0 && S_ISFIFO(sb.st_mode)) ? 1 : 0;
- }
-#elif defined(PHP_WIN32)
- {
- long handle = _get_osfhandle(self->fd);
- DWORD in_buf_size, out_buf_size;
-
- if (handle != 0xFFFFFFFF) {
- self->is_pipe = GetNamedPipeInfo((HANDLE)handle, NULL, &out_buf_size, &in_buf_size, NULL);
- }
- }
-#endif
-
- stream = php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
-
- if (stream) {
- if (self->is_pipe) {
- stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
- } else {
- stream->position = ftell(file);
- }
- }
-
- return stream;
-}
-
-PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STREAMS_DC TSRMLS_DC)
-{
- php_stdio_stream_data *self;
- php_stream *stream;
-
- self = emalloc_rel_orig(sizeof(*self));
- self->file = file;
- self->is_pipe = 1;
- self->lock_flag = LOCK_UN;
- self->is_process_pipe = 1;
- self->fd = fileno(file);
- self->temp_file_name = NULL;
-
- stream = php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
- stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
- return stream;
-}
-
-#define PHP_STDIOP_GET_FD(anfd, data) anfd = (data)->file ? fileno((data)->file) : (data)->fd
-
-static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
-{
- php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
-
- assert(data != NULL);
-
- if (data->fd >= 0) {
- int bytes_written = write(data->fd, buf, count);
- if (bytes_written < 0) return 0;
- return (size_t) bytes_written;
- } else {
-
-#if HAVE_FLUSHIO
- if (!data->is_pipe && data->last_op == 'r') {
- fseek(data->file, 0, SEEK_CUR);
- }
- data->last_op = 'w';
-#endif
-
- return fwrite(buf, 1, count, data->file);
- }
-}
-
-static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
-{
- php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
- size_t ret;
-
- assert(data != NULL);
-
- if (data->fd >= 0) {
- ret = read(data->fd, buf, count);
-
- if (ret == 0 || (ret == -1 && errno != EWOULDBLOCK))
- stream->eof = 1;
-
- } else {
-#if HAVE_FLUSHIO
- if (!data->is_pipe && data->last_op == 'w')
- fseek(data->file, 0, SEEK_CUR);
- data->last_op = 'r';
-#endif
-
- ret = fread(buf, 1, count, data->file);
-
- if (feof(data->file))
- stream->eof = 1;
- }
- return ret;
-}
-
-static int php_stdiop_close(php_stream *stream, int close_handle TSRMLS_DC)
-{
- int ret;
- php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
-
- assert(data != NULL);
-
-#if HAVE_MMAP
- if (data->last_mapped_addr) {
- munmap(data->last_mapped_addr, data->last_mapped_len);
- data->last_mapped_addr = NULL;
- }
-#endif
-
- if (close_handle) {
- if (data->lock_flag != LOCK_UN) {
- php_stream_lock(stream, LOCK_UN);
- }
- if (data->file) {
- if (data->is_process_pipe) {
- errno = 0;
- ret = pclose(data->file);
-
-#if HAVE_SYS_WAIT_H
- if (WIFEXITED(ret)) {
- ret = WEXITSTATUS(ret);
- }
-#endif
- } else {
- ret = fclose(data->file);
- data->file = NULL;
- }
- } else if (data->fd != -1) {
- ret = close(data->fd);
- data->fd = -1;
- } else {
- return 0; /* everything should be closed already -> success */
- }
- if (data->temp_file_name) {
- unlink(data->temp_file_name);
- efree(data->temp_file_name);
- data->temp_file_name = NULL;
- }
- } else {
- ret = 0;
- data->file = NULL;
- data->fd = -1;
- }
-
- /* STDIO streams are never persistent! */
- efree(data);
-
- return ret;
-}
-
-static int php_stdiop_flush(php_stream *stream TSRMLS_DC)
-{
- php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
-
- assert(data != NULL);
-
- /*
- * stdio buffers data in user land. By calling fflush(3), this
- * data is send to the kernel using write(2). fsync'ing is
- * something completely different.
- */
- if (data->file) {
- return fflush(data->file);
- }
- return 0;
-}
-
-static int php_stdiop_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC)
-{
- php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
- int ret;
-
- assert(data != NULL);
-
- if (data->is_pipe) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot seek on a pipe");
- return -1;
- }
-
- if (data->fd >= 0) {
- off_t result;
-
- result = lseek(data->fd, offset, whence);
- if (result == (off_t)-1)
- return -1;
-
- *newoffset = result;
- return 0;
-
- } else {
- ret = fseek(data->file, offset, whence);
- *newoffset = ftell(data->file);
- return ret;
- }
-}
-
-static int php_stdiop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
-{
- int fd;
- php_stdio_stream_data *data = (php_stdio_stream_data*) stream->abstract;
-
- assert(data != NULL);
-
- /* as soon as someone touches the stdio layer, buffering may ensue,
- * so we need to stop using the fd directly in that case */
-
- switch (castas) {
- case PHP_STREAM_AS_STDIO:
- if (ret) {
-
- if (data->file == NULL) {
- /* we were opened as a plain file descriptor, so we
- * need fdopen now */
- data->file = fdopen(data->fd, stream->mode);
- }
-
- *ret = data->file;
- data->fd = -1;
- }
- return SUCCESS;
-
- case PHP_STREAM_AS_FD:
- /* fetch the fileno rather than using data->fd, since we may
- * have zeroed that member if someone requested the FILE*
- * first (see above case) */
- PHP_STDIOP_GET_FD(fd, data);
-
- if (fd < 0) {
- return FAILURE;
- }
- if (data->file) {
- fflush(data->file);
- }
- if (ret) {
- *ret = (void*)fd;
- }
- return SUCCESS;
- default:
- return FAILURE;
- }
-}
-
-static int php_stdiop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)
-{
- int fd;
- php_stdio_stream_data *data = (php_stdio_stream_data*) stream->abstract;
-
- assert(data != NULL);
-
- PHP_STDIOP_GET_FD(fd, data);
-
- return fstat(fd, &ssb->sb);
-}
-
-static int php_stdiop_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC)
-{
- php_stdio_stream_data *data = (php_stdio_stream_data*) stream->abstract;
- size_t size;
- int fd;
-#ifdef O_NONBLOCK
- /* FIXME: make this work for win32 */
- int flags;
- int oldval;
-#endif
-
- PHP_STDIOP_GET_FD(fd, data);
-
- switch(option) {
- case PHP_STREAM_OPTION_BLOCKING:
- if (fd == -1)
- return -1;
-#ifdef O_NONBLOCK
- flags = fcntl(fd, F_GETFL, 0);
- oldval = (flags & O_NONBLOCK) ? 0 : 1;
- if (value)
- flags ^= O_NONBLOCK;
- else
- flags |= O_NONBLOCK;
-
- if (-1 == fcntl(fd, F_SETFL, flags))
- return -1;
- return oldval;
-#else
- return -1; /* not yet implemented */
-#endif
-
- case PHP_STREAM_OPTION_WRITE_BUFFER:
-
- if (data->file == NULL) {
- return -1;
- }
-
- if (ptrparam)
- size = *(size_t *)ptrparam;
- else
- size = BUFSIZ;
-
- switch(value) {
- case PHP_STREAM_BUFFER_NONE:
- stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
- return setvbuf(data->file, NULL, _IONBF, 0);
-
- case PHP_STREAM_BUFFER_LINE:
- stream->flags ^= PHP_STREAM_FLAG_NO_BUFFER;
- return setvbuf(data->file, NULL, _IOLBF, size);
-
- case PHP_STREAM_BUFFER_FULL:
- stream->flags ^= PHP_STREAM_FLAG_NO_BUFFER;
- return setvbuf(data->file, NULL, _IOFBF, size);
-
- default:
- return -1;
- }
- break;
-
- case PHP_STREAM_OPTION_LOCKING:
- if (fd == -1) {
- return -1;
- }
-
- if ((int) ptrparam == PHP_STREAM_LOCK_SUPPORTED) {
- return 0;
- }
-
- if (!flock(fd, value) || (errno == EWOULDBLOCK && value & LOCK_NB)) {
- data->lock_flag = value;
- return 0;
- } else {
- return -1;
- }
- break;
-
- case PHP_STREAM_OPTION_MMAP_API:
-#if HAVE_MMAP
- {
- php_stream_mmap_range *range = (php_stream_mmap_range*)ptrparam;
- struct stat sbuf;
- int prot, flags;
-
- switch (value) {
- case PHP_STREAM_MMAP_SUPPORTED:
- return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
-
- case PHP_STREAM_MMAP_MAP_RANGE:
- fstat(fd, &sbuf);
- if (range->length == 0 || range->length > sbuf.st_size) {
- range->length = sbuf.st_size;
- }
- switch (range->mode) {
- case PHP_STREAM_MAP_MODE_READONLY:
- prot = PROT_READ;
- flags = MAP_PRIVATE;
- break;
- case PHP_STREAM_MAP_MODE_READWRITE:
- prot = PROT_READ | PROT_WRITE;
- flags = MAP_PRIVATE;
- break;
- case PHP_STREAM_MAP_MODE_SHARED_READONLY:
- prot = PROT_READ;
- flags = MAP_SHARED;
- break;
- case PHP_STREAM_MAP_MODE_SHARED_READWRITE:
- prot = PROT_READ | PROT_WRITE;
- flags = MAP_SHARED;
- break;
- default:
- return PHP_STREAM_OPTION_RETURN_ERR;
- }
- range->mapped = (char*)mmap(NULL, range->length, prot, flags, fd, range->offset);
- if (range->mapped == (char*)MAP_FAILED) {
- range->mapped = NULL;
- return PHP_STREAM_OPTION_RETURN_ERR;
- }
- /* remember the mapping */
- data->last_mapped_addr = range->mapped;
- data->last_mapped_len = range->length;
- return PHP_STREAM_OPTION_RETURN_OK;
-
- case PHP_STREAM_MMAP_UNMAP:
- if (data->last_mapped_addr) {
- munmap(data->last_mapped_addr, data->last_mapped_len);
- data->last_mapped_addr = NULL;
-
- return PHP_STREAM_OPTION_RETURN_OK;
- }
- return PHP_STREAM_OPTION_RETURN_ERR;
- }
- }
-#endif
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
-
- case PHP_STREAM_OPTION_TRUNCATE_API:
- switch (value) {
- case PHP_STREAM_TRUNCATE_SUPPORTED:
- return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
-
- case PHP_STREAM_TRUNCATE_SET_SIZE:
- return ftruncate(fd, *(size_t*)ptrparam) == 0 ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR;
- }
-
- default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
- }
-}
-
-PHPAPI php_stream_ops php_stream_stdio_ops = {
- php_stdiop_write, php_stdiop_read,
- php_stdiop_close, php_stdiop_flush,
- "STDIO",
- php_stdiop_seek,
- php_stdiop_cast,
- php_stdiop_stat,
- php_stdiop_set_option
-};
-/* }}} */
-
-/* {{{ plain files opendir/readdir implementation */
-static size_t php_plain_files_dirstream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
-{
- DIR *dir = (DIR*)stream->abstract;
- /* avoid libc5 readdir problems */
- char entry[sizeof(struct dirent)+MAXPATHLEN];
- struct dirent *result = (struct dirent *)&entry;
- php_stream_dirent *ent = (php_stream_dirent*)buf;
-
- /* avoid problems if someone mis-uses the stream */
- if (count != sizeof(php_stream_dirent))
- return 0;
-
- if (php_readdir_r(dir, (struct dirent *)entry, &result) == 0 && result) {
- PHP_STRLCPY(ent->d_name, result->d_name, sizeof(ent->d_name), strlen(result->d_name));
- return sizeof(php_stream_dirent);
- }
- return 0;
-}
-
-static int php_plain_files_dirstream_close(php_stream *stream, int close_handle TSRMLS_DC)
-{
- return closedir((DIR *)stream->abstract);
-}
-
-static int php_plain_files_dirstream_rewind(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
-{
- rewinddir((DIR *)stream->abstract);
- return 0;
-}
-
-static php_stream_ops php_plain_files_dirstream_ops = {
- NULL, php_plain_files_dirstream_read,
- php_plain_files_dirstream_close, NULL,
- "dir",
- php_plain_files_dirstream_rewind,
- NULL, /* cast */
- NULL, /* stat */
- NULL /* set_option */
-};
-
-static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, char *path, char *mode,
- int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
-{
- DIR *dir = NULL;
- php_stream *stream = NULL;
-
- if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(path TSRMLS_CC)) {
- return NULL;
- }
-
- if (PG(safe_mode) &&(!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
- return NULL;
- }
-
- dir = VCWD_OPENDIR(path);
-
-#ifdef PHP_WIN32
- if (dir && dir->finished) {
- closedir(dir);
- dir = NULL;
- }
-#endif
- if (dir) {
- stream = php_stream_alloc(&php_plain_files_dirstream_ops, dir, 0, mode);
- if (stream == NULL)
- closedir(dir);
- }
-
- return stream;
-}
-/* }}} */
-
-
-static php_stream *php_plain_files_stream_opener(php_stream_wrapper *wrapper, char *path, char *mode,
- int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
-{
- if ((options & USE_PATH) && PG(include_path) != NULL) {
- return php_stream_fopen_with_path_rel(path, mode, PG(include_path), opened_path, options);
- }
-
- if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(path TSRMLS_CC)) {
- return NULL;
- }
-
- if ((options & ENFORCE_SAFE_MODE) && PG(safe_mode) && (!php_checkuid(path, mode, CHECKUID_CHECK_MODE_PARAM)))
- return NULL;
-
- return php_stream_fopen_rel(path, mode, opened_path, options);
-}
-
-static int php_plain_files_url_stater(php_stream_wrapper *wrapper, char *url, php_stream_statbuf *ssb TSRMLS_DC)
-{
- return VCWD_STAT(url, &ssb->sb);
-}
-
-static php_stream_wrapper_ops php_plain_files_wrapper_ops = {
- php_plain_files_stream_opener,
- NULL,
- NULL,
- php_plain_files_url_stater,
- php_plain_files_dir_opener,
- "plainfile"
-};
-
-php_stream_wrapper php_plain_files_wrapper = {
- &php_plain_files_wrapper_ops,
- NULL,
- 0
-};
-
-/* {{{ php_stream_fopen_with_path */
-PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path, int options STREAMS_DC TSRMLS_DC)
-{
- /* code ripped off from fopen_wrappers.c */
- char *pathbuf, *ptr, *end;
- char *exec_fname;
- char trypath[MAXPATHLEN];
- struct stat sb;
- php_stream *stream;
- int path_length;
- int filename_length;
- int exec_fname_length;
-
- if (opened_path) {
- *opened_path = NULL;
- }
-
- if(!filename) {
- return NULL;
- }
-
- filename_length = strlen(filename);
-
- /* Relative path open */
- if (*filename == '.' && (IS_SLASH(filename[1]) || filename[1] == '.')) {
- /* further checks, we could have ....... filenames */
- ptr = filename + 1;
- if (*ptr == '.') {
- while (*(++ptr) == '.');
- if (!IS_SLASH(*ptr)) { /* not a relative path after all */
- goto not_relative_path;
- }
- }
-
-
- if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(filename TSRMLS_CC)) {
- return NULL;
- }
-
- if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
- return NULL;
- }
- return php_stream_fopen_rel(filename, mode, opened_path, options);
- }
-
- /*
- * files in safe_mode_include_dir (or subdir) are excluded from
- * safe mode GID/UID checks
- */
-
-not_relative_path:
-
- /* Absolute path open */
- if (IS_ABSOLUTE_PATH(filename, filename_length)) {
-
- if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(filename TSRMLS_CC)) {
- return NULL;
- }
-
- if ((php_check_safe_mode_include_dir(filename TSRMLS_CC)) == 0)
- /* filename is in safe_mode_include_dir (or subdir) */
- return php_stream_fopen_rel(filename, mode, opened_path, options);
-
- if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM)))
- return NULL;
-
- return php_stream_fopen_rel(filename, mode, opened_path, options);
- }
-
-#ifdef PHP_WIN32
- if (IS_SLASH(filename[0])) {
- int cwd_len;
- char *cwd;
- cwd = virtual_getcwd_ex(&cwd_len TSRMLS_CC);
- /* getcwd() will return always return [DRIVE_LETTER]:/) on windows. */
- *(cwd+3) = '\0';
-
- snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename);
-
- free(cwd);
-
- if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(trypath TSRMLS_CC)) {
- return NULL;
- }
- if ((php_check_safe_mode_include_dir(trypath TSRMLS_CC)) == 0) {
- return php_stream_fopen_rel(trypath, mode, opened_path, options);
- }
- if (PG(safe_mode) && (!php_checkuid(trypath, mode, CHECKUID_CHECK_MODE_PARAM))) {
- return NULL;
- }
-
- return php_stream_fopen_rel(trypath, mode, opened_path, options);
- }
-#endif
-
- if (!path || (path && !*path)) {
-
- if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(path TSRMLS_CC)) {
- return NULL;
- }
-
- if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
- return NULL;
- }
- return php_stream_fopen_rel(filename, mode, opened_path, options);
- }
-
- /* 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);
-
- if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(trypath TSRMLS_CC)) {
- stream = NULL;
- goto stream_done;
- }
-
- if (PG(safe_mode)) {
- if (VCWD_STAT(trypath, &sb) == 0) {
- /* file exists ... check permission */
- if ((php_check_safe_mode_include_dir(trypath TSRMLS_CC) == 0) ||
- php_checkuid(trypath, mode, CHECKUID_CHECK_MODE_PARAM)) {
- /* UID ok, or trypath is in safe_mode_include_dir */
- stream = php_stream_fopen_rel(trypath, mode, opened_path, options);
- } else {
- stream = NULL;
- }
- goto stream_done;
- }
- }
- stream = php_stream_fopen_rel(trypath, mode, opened_path, options);
- if (stream) {
-stream_done:
- efree(pathbuf);
- return stream;
- }
- ptr = end;
- } /* end provided path */
-
- efree(pathbuf);
- return NULL;
-
-}
-/* }}} */
-
-
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/streams.c b/main/streams/streams.c
deleted file mode 100755
index b46dcc97aa..0000000000
--- a/main/streams/streams.c
+++ /dev/null
@@ -1,1590 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- | Borrowed code from: |
- | Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- | Jim Winstead <jimw@php.net> |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#define _GNU_SOURCE
-#include "php.h"
-#include "php_globals.h"
-#include "php_network.h"
-#include "php_open_temporary_file.h"
-#include "ext/standard/file.h"
-#include "ext/standard/basic_functions.h" /* for BG(mmap_file) (not strictly required) */
-#include "ext/standard/php_string.h" /* for php_memnstr, used by php_stream_get_record() */
-#include <stddef.h>
-#include <fcntl.h>
-#include "php_streams_int.h"
-
-/* {{{ resource and registration code */
-static HashTable url_stream_wrappers_hash;
-static int le_stream = FAILURE; /* true global */
-static int le_pstream = FAILURE; /* true global */
-
-PHPAPI int php_file_le_stream(void)
-{
- return le_stream;
-}
-
-PHPAPI int php_file_le_pstream(void)
-{
- return le_pstream;
-}
-
-PHPAPI HashTable *php_stream_get_url_stream_wrappers_hash()
-{
- return &url_stream_wrappers_hash;
-}
-
-static int forget_persistent_resource_id_numbers(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
- php_stream *stream;
-
- if (Z_TYPE_P(rsrc) != le_pstream)
- return 0;
-
- stream = (php_stream*)rsrc->ptr;
-
-#if STREAM_DEBUG
-fprintf(stderr, "forget_persistent: %s:%p\n", stream->ops->label, stream);
-#endif
-
- stream->rsrc_id = FAILURE;
-
- return 0;
-}
-
-PHP_RSHUTDOWN_FUNCTION(streams)
-{
- zend_hash_apply(&EG(persistent_list), (apply_func_t)forget_persistent_resource_id_numbers TSRMLS_CC);
- return SUCCESS;
-}
-
-PHPAPI int php_stream_from_persistent_id(const char *persistent_id, php_stream **stream TSRMLS_DC)
-{
- list_entry *le;
-
- if (zend_hash_find(&EG(persistent_list), (char*)persistent_id, strlen(persistent_id)+1, (void*) &le) == SUCCESS) {
- if (Z_TYPE_P(le) == le_pstream) {
- if (stream) {
- *stream = (php_stream*)le->ptr;
- if ((*stream)->rsrc_id == FAILURE) {
- /* first access this request; give it a valid id */
- (*stream)->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, *stream, le_pstream);
- }
- }
- return PHP_STREAM_PERSISTENT_SUCCESS;
- }
- return PHP_STREAM_PERSISTENT_FAILURE;
- }
- return PHP_STREAM_PERSISTENT_NOT_EXIST;
-}
-
-/* }}} */
-
-/* {{{ wrapper error reporting */
-void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char *path, const char *caption TSRMLS_DC)
-{
- char *tmp = estrdup(path);
- char *msg;
- int free_msg = 0;
-
- if (wrapper) {
- if (wrapper->err_count > 0) {
- int i;
- size_t l;
- int brlen;
- char *br;
-
- if (PG(html_errors)) {
- brlen = 7;
- br = "<br />\n";
- } else {
- brlen = 1;
- br = "\n";
- }
-
- for (i = 0, l = 0; i < wrapper->err_count; i++) {
- l += strlen(wrapper->err_stack[i]);
- if (i < wrapper->err_count - 1)
- l += brlen;
- }
- msg = emalloc(l + 1);
- msg[0] = '\0';
- for (i = 0; i < wrapper->err_count; i++) {
- strcat(msg, wrapper->err_stack[i]);
- if (i < wrapper->err_count - 1)
- strcat(msg, br);
- }
-
- free_msg = 1;
- } else {
- msg = strerror(errno);
- }
- } else {
- msg = "no suitable wrapper could be found";
- }
-
- php_strip_url_passwd(tmp);
- php_error_docref1(NULL TSRMLS_CC, tmp, E_WARNING, "%s: %s", caption, msg);
- efree(tmp);
- if (free_msg)
- efree(msg);
-}
-
-void php_stream_tidy_wrapper_error_log(php_stream_wrapper *wrapper TSRMLS_DC)
-{
- if (wrapper) {
- /* tidy up the error stack */
- int i;
-
- for (i = 0; i < wrapper->err_count; i++)
- efree(wrapper->err_stack[i]);
- if (wrapper->err_stack)
- efree(wrapper->err_stack);
- wrapper->err_stack = NULL;
- wrapper->err_count = 0;
- }
-}
-
-PHPAPI void php_stream_wrapper_log_error(php_stream_wrapper *wrapper, int options TSRMLS_DC, const char *fmt, ...)
-{
- va_list args;
- char *buffer = NULL;
-
- va_start(args, fmt);
- vspprintf(&buffer, 0, fmt, args);
- va_end(args);
-
- if (options & REPORT_ERRORS || wrapper == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, buffer);
- efree(buffer);
- } else {
- /* append to stack */
- wrapper->err_stack = erealloc(wrapper->err_stack, (wrapper->err_count + 1) * sizeof(char *));
- if (wrapper->err_stack)
- wrapper->err_stack[wrapper->err_count++] = buffer;
- }
-}
-
-
-/* }}} */
-
-/* allocate a new stream for a particular ops */
-PHPAPI php_stream *_php_stream_alloc(php_stream_ops *ops, void *abstract, const char *persistent_id, const char *mode STREAMS_DC TSRMLS_DC) /* {{{ */
-{
- php_stream *ret;
-
- ret = (php_stream*) pemalloc_rel_orig(sizeof(php_stream), persistent_id ? 1 : 0);
-
- memset(ret, 0, sizeof(php_stream));
-
-#if STREAM_DEBUG
-fprintf(stderr, "stream_alloc: %s:%p persistent=%s\n", ops->label, ret, persistent_id);
-#endif
-
- ret->ops = ops;
- ret->abstract = abstract;
- ret->is_persistent = persistent_id ? 1 : 0;
- ret->chunk_size = FG(def_chunk_size);
-
- if (FG(auto_detect_line_endings))
- ret->flags |= PHP_STREAM_FLAG_DETECT_EOL;
-
- if (persistent_id) {
- list_entry le;
-
- Z_TYPE(le) = le_pstream;
- le.ptr = ret;
-
- if (FAILURE == zend_hash_update(&EG(persistent_list), (char *)persistent_id,
- strlen(persistent_id) + 1,
- (void *)&le, sizeof(list_entry), NULL)) {
-
- pefree(ret, 1);
- return NULL;
- }
- }
-
- ret->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ret, persistent_id ? le_pstream : le_stream);
- strlcpy(ret->mode, mode, sizeof(ret->mode));
-
- return ret;
-}
-/* }}} */
-
-PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC) /* {{{ */
-{
- int ret = 1;
- int remove_rsrc = 1;
- int preserve_handle = close_options & PHP_STREAM_FREE_PRESERVE_HANDLE ? 1 : 0;
- int release_cast = 1;
-
-#if STREAM_DEBUG
-fprintf(stderr, "stream_free: %s:%p[%s] in_free=%d opts=%08x\n", stream->ops->label, stream, stream->__orig_path, stream->in_free, close_options);
-#endif
-
- /* recursion protection */
- if (stream->in_free)
- return 1;
-
- stream->in_free++;
-
- /* if we are releasing the stream only (and preserving the underlying handle),
- * we need to do things a little differently.
- * We are only ever called like this when the stream is cast to a FILE*
- * for include (or other similar) purposes.
- * */
- if (preserve_handle) {
- if (stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FOPENCOOKIE) {
- /* If the stream was fopencookied, we must NOT touch anything
- * here, as the cookied stream relies on it all.
- * Instead, mark the stream as OK to auto-clean */
- php_stream_auto_cleanup(stream);
- stream->in_free--;
- return 0;
- }
- /* otherwise, make sure that we don't close the FILE* from a cast */
- release_cast = 0;
- }
-
-#if STREAM_DEBUG
-fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remove_rsrc=%d\n",
- stream->ops->label, stream, stream->__orig_path, preserve_handle, release_cast, remove_rsrc);
-#endif
-
- /* make sure everything is saved */
- _php_stream_flush(stream, 1 TSRMLS_CC);
-
- /* If not called from the resource dtor, remove the stream
- * from the resource list.
- * */
- if ((close_options & PHP_STREAM_FREE_RSRC_DTOR) == 0 && remove_rsrc) {
- zend_list_delete(stream->rsrc_id);
- }
-
- if (close_options & PHP_STREAM_FREE_CALL_DTOR) {
- if (release_cast && 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.
- */
- stream->in_free = 0;
- return fclose(stream->stdiocast);
- }
-
- ret = stream->ops->close(stream, preserve_handle ? 0 : 1 TSRMLS_CC);
- stream->abstract = NULL;
-
- /* tidy up any FILE* that might have been fdopened */
- if (release_cast && stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FDOPEN && stream->stdiocast) {
- fclose(stream->stdiocast);
- stream->stdiocast = NULL;
- stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE;
- }
- }
-
- if (close_options & PHP_STREAM_FREE_RELEASE_STREAM) {
-
- while (stream->readfilters.head) {
- php_stream_filter_remove(stream->readfilters.head, 1 TSRMLS_CC);
- }
- while (stream->writefilters.head) {
- php_stream_filter_remove(stream->writefilters.head, 1 TSRMLS_CC);
- }
-
- if (stream->wrapper && stream->wrapper->wops && stream->wrapper->wops->stream_closer) {
- stream->wrapper->wops->stream_closer(stream->wrapper, stream TSRMLS_CC);
- stream->wrapper = NULL;
- }
-
- if (stream->wrapperdata) {
- zval_ptr_dtor(&stream->wrapperdata);
- stream->wrapperdata = NULL;
- }
-
- if (stream->readbuf) {
- pefree(stream->readbuf, stream->is_persistent);
- stream->readbuf = NULL;
- }
-
-#if ZEND_DEBUG
- if ((close_options & PHP_STREAM_FREE_RSRC_DTOR) && (stream->__exposed == 0) && (EG(error_reporting) & E_WARNING)) {
- /* it leaked: Lets deliberately NOT pefree it so that the memory manager shows it
- * as leaked; it will log a warning, but lets help it out and display what kind
- * of stream it was. */
- char leakbuf[512];
- snprintf(leakbuf, sizeof(leakbuf), __FILE__ "(%d) : Stream of type '%s' 0x%08X (path:%s) was not closed\n", __LINE__, stream->ops->label, (unsigned int)stream, stream->__orig_path);
-
- STR_FREE(stream->__orig_path);
-
-# if defined(PHP_WIN32)
- OutputDebugString(leakbuf);
-# else
- fprintf(stderr, leakbuf);
-# endif
- } else {
- STR_FREE(stream->__orig_path);
- pefree(stream, stream->is_persistent);
- }
-#else
- pefree(stream, stream->is_persistent);
-#endif
- }
-
- return ret;
-}
-/* }}} */
-
-/* {{{ generic stream operations */
-
-static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC)
-{
- /* allocate/fill the buffer */
-
- if (stream->readfilters.head) {
- char *chunk_buf;
- int err_flag = 0;
- php_stream_bucket_brigade brig_in = { NULL, NULL }, brig_out = { NULL, NULL };
- php_stream_bucket_brigade *brig_inp = &brig_in, *brig_outp = &brig_out, *brig_swap;
-
- /* allocate a buffer for reading chunks */
- chunk_buf = emalloc(stream->chunk_size);
-
- while (!err_flag && (stream->writepos - stream->readpos < (off_t)size)) {
- size_t justread = 0;
- int flags;
- php_stream_bucket *bucket;
- php_stream_filter_status_t status;
- php_stream_filter *filter;
-
- /* read a chunk into a bucket */
- justread = stream->ops->read(stream, chunk_buf, stream->chunk_size TSRMLS_CC);
- if (justread > 0) {
- bucket = php_stream_bucket_new(stream, chunk_buf, justread, 0, 0 TSRMLS_CC);
-
- /* after this call, bucket is owned by the brigade */
- php_stream_bucket_append(brig_inp, bucket TSRMLS_CC);
-
- flags = PSFS_FLAG_NORMAL;
- } else {
- flags = stream->eof ? PSFS_FLAG_FLUSH_CLOSE : PSFS_FLAG_FLUSH_INC;
- }
-
- /* wind the handle... */
- for (filter = stream->readfilters.head; filter; filter = filter->next) {
- status = filter->fops->filter(stream, filter, brig_inp, brig_outp, NULL, flags TSRMLS_CC);
-
- if (status != PSFS_PASS_ON) {
- break;
- }
-
- /* brig_out becomes brig_in.
- * brig_in will always be empty here, as the filter MUST attach any un-consumed buckets
- * to its own brigade */
- brig_swap = brig_inp;
- brig_inp = brig_outp;
- brig_outp = brig_swap;
- memset(brig_outp, 0, sizeof(*brig_outp));
- }
-
- switch (status) {
- case PSFS_PASS_ON:
- /* we get here when the last filter in the chain has data to pass on.
- * in this situation, we are passing the brig_in brigade into the
- * stream read buffer */
- while (brig_inp->head) {
- bucket = brig_inp->head;
- /* grow buffer to hold this bucket
- * TODO: this can fail for persistent streams */
- if (stream->readbuflen - stream->writepos < bucket->buflen) {
- stream->readbuflen += bucket->buflen;
- stream->readbuf = perealloc(stream->readbuf, stream->readbuflen,
- stream->is_persistent);
- }
- memcpy(stream->readbuf + stream->writepos, bucket->buf, bucket->buflen);
- stream->writepos += bucket->buflen;
-
- php_stream_bucket_unlink(bucket TSRMLS_CC);
- php_stream_bucket_delref(bucket TSRMLS_CC);
- }
-
- break;
-
- case PSFS_FEED_ME:
- /* when a filter needs feeding, there is no brig_out to deal with.
- * we simply continue the loop; if the caller needs more data,
- * we will read again, otherwise out job is done here */
- if (justread == 0) {
- /* there is no data */
- err_flag = 1;
- break;
- }
- continue;
-
- case PSFS_ERR_FATAL:
- /* some fatal error. Theoretically, the stream is borked, so all
- * further reads should fail. */
- err_flag = 1;
- break;
- }
-
- if (justread == 0) {
- break;
- }
- }
-
- efree(chunk_buf);
-
- } else {
- /* is there enough data in the buffer ? */
- if (stream->writepos - stream->readpos < (off_t)size) {
- size_t justread = 0;
-
- /* reduce buffer memory consumption if possible, to avoid a realloc */
- if (stream->readbuf && stream->readbuflen - stream->writepos < stream->chunk_size) {
- memmove(stream->readbuf, stream->readbuf + stream->readpos, stream->readbuflen - stream->readpos);
- stream->writepos -= stream->readpos;
- stream->readpos = 0;
- }
-
- /* grow the buffer if required
- * TODO: this can fail for persistent streams */
- if (stream->readbuflen - stream->writepos < stream->chunk_size) {
- stream->readbuflen += stream->chunk_size;
- stream->readbuf = perealloc(stream->readbuf, stream->readbuflen,
- stream->is_persistent);
- }
-
- justread = stream->ops->read(stream, stream->readbuf + stream->writepos,
- stream->readbuflen - stream->writepos
- TSRMLS_CC);
-
- if (justread != (size_t)-1) {
- stream->writepos += justread;
- }
- }
- }
-}
-
-PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size TSRMLS_DC)
-{
- size_t toread = 0, didread = 0;
-
- while (size > 0) {
-
- /* take from the read buffer first.
- * It is possible that a buffered stream was switched to non-buffered, so we
- * drain the remainder of the buffer before using the "raw" read mode for
- * the excess */
- if (stream->writepos > stream->readpos) {
-
- toread = stream->writepos - stream->readpos;
- if (toread > size)
- toread = size;
-
- memcpy(buf, stream->readbuf + stream->readpos, toread);
- stream->readpos += toread;
- size -= toread;
- buf += toread;
- didread += toread;
- }
-
- /* ignore eof here; the underlying state might have changed */
- if (size == 0) {
- break;
- }
-
- if (!stream->readfilters.head && (stream->flags & PHP_STREAM_FLAG_NO_BUFFER || stream->chunk_size == 1)) {
- toread = stream->ops->read(stream, buf, size TSRMLS_CC);
- } else {
- php_stream_fill_read_buffer(stream, size TSRMLS_CC);
-
- toread = stream->writepos - stream->readpos;
- if (toread > size)
- toread = size;
-
- if (toread > 0) {
- memcpy(buf, stream->readbuf + stream->readpos, toread);
- stream->readpos += toread;
- }
- }
- if (toread > 0) {
- didread += toread;
- buf += toread;
- size -= toread;
- } else {
- /* EOF, or temporary end of data (for non-blocking mode). */
- break;
- }
- }
-
- if (didread > 0)
- stream->position += didread;
-
- return didread;
-}
-
-PHPAPI int _php_stream_eof(php_stream *stream TSRMLS_DC)
-{
- /* if there is data in the buffer, it's not EOF */
- if (stream->writepos - stream->readpos > 0)
- return 0;
-
- return stream->eof;
-}
-
-PHPAPI int _php_stream_putc(php_stream *stream, int c TSRMLS_DC)
-{
- unsigned char buf = c;
-
- if (php_stream_write(stream, &buf, 1) > 0) {
- return 1;
- }
- return EOF;
-}
-
-PHPAPI int _php_stream_getc(php_stream *stream TSRMLS_DC)
-{
- char buf;
-
- if (php_stream_read(stream, &buf, 1) > 0) {
- return buf & 0xff;
- }
- return EOF;
-}
-
-PHPAPI int _php_stream_puts(php_stream *stream, char *buf TSRMLS_DC)
-{
- int len;
- char newline[2] = "\n"; /* is this OK for Win? */
- len = strlen(buf);
-
- if (len > 0 && php_stream_write(stream, buf, len) && php_stream_write(stream, newline, 1)) {
- return 1;
- }
- return 0;
-}
-
-PHPAPI int _php_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)
-{
- memset(ssb, 0, sizeof(*ssb));
-
- /* if the stream was wrapped, allow the wrapper to stat it */
- if (stream->wrapper && stream->wrapper->wops->stream_stat != NULL) {
- return stream->wrapper->wops->stream_stat(stream->wrapper, stream, ssb TSRMLS_CC);
- }
-
- /* if the stream doesn't directly support stat-ing, return with failure.
- * We could try and emulate this by casting to a FD and fstat-ing it,
- * but since the fd might not represent the actual underlying content
- * this would give bogus results. */
- if (stream->ops->stat == NULL) {
- return -1;
- }
-
- return (stream->ops->stat)(stream, ssb TSRMLS_CC);
-}
-
-PHPAPI char *php_stream_locate_eol(php_stream *stream, char *buf, size_t buf_len TSRMLS_DC)
-{
- size_t avail;
- char *cr, *lf, *eol = NULL;
- char *readptr;
-
- if (!buf) {
- readptr = stream->readbuf + stream->readpos;
- avail = stream->writepos - stream->readpos;
- } else {
- readptr = buf;
- avail = buf_len;
- }
-
- /* Look for EOL */
- if (stream->flags & PHP_STREAM_FLAG_DETECT_EOL) {
- cr = memchr(readptr, '\r', avail);
- lf = memchr(readptr, '\n', avail);
-
- if (cr && lf != cr + 1 && !(lf && lf < cr)) {
- /* mac */
- stream->flags ^= PHP_STREAM_FLAG_DETECT_EOL;
- stream->flags |= PHP_STREAM_FLAG_EOL_MAC;
- eol = cr;
- } else if ((cr && lf && cr == lf - 1) || (lf)) {
- /* dos or unix endings */
- stream->flags ^= PHP_STREAM_FLAG_DETECT_EOL;
- eol = lf;
- }
- } else if (stream->flags & PHP_STREAM_FLAG_EOL_MAC) {
- eol = memchr(readptr, '\r', avail);
- } else {
- /* unix (and dos) line endings */
- eol = memchr(readptr, '\n', avail);
- }
-
- return eol;
-}
-
-/* If buf == NULL, the buffer will be allocated automatically and will be of an
- * appropriate length to hold the line, regardless of the line length, memory
- * permitting */
-PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen,
- size_t *returned_len TSRMLS_DC)
-{
- size_t avail = 0;
- size_t current_buf_size = 0;
- size_t total_copied = 0;
- int grow_mode = 0;
- char *bufstart = buf;
-
- if (buf == NULL)
- grow_mode = 1;
- else if (maxlen == 0)
- return NULL;
-
- /*
- * If the underlying stream operations block when no new data is readable,
- * we need to take extra precautions.
- *
- * If there is buffered data available, we check for a EOL. If it exists,
- * we pass the data immediately back to the caller. This saves a call
- * to the read implementation and will not block where blocking
- * is not necessary at all.
- *
- * If the stream buffer contains more data than the caller requested,
- * we can also avoid that costly step and simply return that data.
- */
-
- for (;;) {
- avail = stream->writepos - stream->readpos;
-
- if (avail > 0) {
- size_t cpysz = 0;
- char *readptr;
- char *eol;
- int done = 0;
-
- readptr = stream->readbuf + stream->readpos;
- eol = php_stream_locate_eol(stream, NULL, 0 TSRMLS_CC);
-
- if (eol) {
- cpysz = eol - readptr + 1;
- done = 1;
- } else {
- cpysz = avail;
- }
-
- if (grow_mode) {
- /* allow room for a NUL. If this realloc is really a realloc
- * (ie: second time around), we get an extra byte. In most
- * cases, with the default chunk size of 8K, we will only
- * incur that overhead once. When people have lines longer
- * than 8K, we waste 1 byte per additional 8K or so.
- * That seems acceptable to me, to avoid making this code
- * hard to follow */
- bufstart = erealloc(bufstart, current_buf_size + cpysz + 1);
- current_buf_size += cpysz + 1;
- buf = bufstart + total_copied;
- } else {
- if (cpysz >= maxlen - 1) {
- cpysz = maxlen - 1;
- done = 1;
- }
- }
-
- memcpy(buf, readptr, cpysz);
-
- stream->position += cpysz;
- stream->readpos += cpysz;
- buf += cpysz;
- maxlen -= cpysz;
- total_copied += cpysz;
-
- if (done) {
- break;
- }
- } else if (stream->eof) {
- break;
- } else {
- /* XXX: Should be fine to always read chunk_size */
- size_t toread;
-
- if (grow_mode) {
- toread = stream->chunk_size;
- } else {
- toread = maxlen - 1;
- if (toread > stream->chunk_size)
- toread = stream->chunk_size;
- }
-
- php_stream_fill_read_buffer(stream, toread TSRMLS_CC);
-
- if (stream->writepos - stream->readpos == 0) {
- break;
- }
- }
- }
-
- if (total_copied == 0) {
- if (grow_mode) {
- assert(bufstart == NULL);
- }
- return NULL;
- }
-
- buf[0] = '\0';
- if (returned_len)
- *returned_len = total_copied;
-
- return bufstart;
-}
-
-PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *returned_len, char *delim, size_t delim_len TSRMLS_DC)
-{
- char *e, *buf;
- size_t toread;
-
- php_stream_fill_read_buffer(stream, maxlen TSRMLS_CC);
-
- if (delim_len == 0) {
- toread = maxlen;
- } else {
- if (delim_len == 1) {
- e = memchr(stream->readbuf, *delim, stream->readbuflen);
- } else {
- e = php_memnstr(stream->readbuf, delim, delim_len, (stream->readbuf + stream->readbuflen));
- }
-
- if (!e) {
- toread = maxlen;
- } else {
- toread = e - (char *) stream->readbuf;
- }
- }
-
- buf = emalloc(toread + 1);
- *returned_len = php_stream_read(stream, buf, toread);
-
- if (*returned_len >= 0) {
- return buf;
- } else {
- efree(buf);
- return NULL;
- }
-}
-
-/* Writes a buffer directly to a stream, using multiple of the chunk size */
-static size_t _php_stream_write_buffer(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
-{
- size_t didwrite = 0, towrite, justwrote;
-
- /* if we have a seekable stream we need to ensure that data is written at the
- * current stream->position. This means invalidating the read buffer and then
- * performing a low-level seek */
- if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
- stream->readpos = stream->writepos = 0;
-
- stream->ops->seek(stream, stream->position, SEEK_SET, &stream->position TSRMLS_CC);
- }
-
-
- while (count > 0) {
- towrite = count;
- if (towrite > stream->chunk_size)
- towrite = stream->chunk_size;
-
- justwrote = stream->ops->write(stream, buf, towrite TSRMLS_CC);
-
- if (justwrote > 0) {
- buf += justwrote;
- count -= justwrote;
- didwrite += justwrote;
-
- /* Only screw with the buffer if we can seek, otherwise we lose data
- * buffered from fifos and sockets */
- if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0 && !php_stream_is_filtered(stream)) {
- stream->position += justwrote;
- }
- } else {
- break;
- }
- }
- return didwrite;
-
-}
-
-/* push some data through the write filter chain.
- * buf may be NULL, if flags are set to indicate a flush.
- * This may trigger a real write to the stream.
- * Returns the number of bytes consumed from buf by the first filter in the chain.
- * */
-static size_t _php_stream_write_filtered(php_stream *stream, const char *buf, size_t count, int flags TSRMLS_DC)
-{
- size_t consumed = 0;
- php_stream_bucket *bucket;
- php_stream_bucket_brigade brig_in = { NULL, NULL }, brig_out = { NULL, NULL };
- php_stream_bucket_brigade *brig_inp = &brig_in, *brig_outp = &brig_out, *brig_swap;
- php_stream_filter_status_t status;
- php_stream_filter *filter;
-
- if (buf) {
- bucket = php_stream_bucket_new(stream, (char *)buf, count, 0, 0 TSRMLS_CC);
- php_stream_bucket_append(&brig_in, bucket TSRMLS_CC);
- }
-
- for (filter = stream->writefilters.head; filter; filter = filter->next) {
- /* for our return value, we are interested in the number of bytes consumed from
- * the first filter in the chain */
- status = filter->fops->filter(stream, filter, brig_inp, brig_outp,
- filter == stream->writefilters.head ? &consumed : NULL, flags TSRMLS_CC);
-
- if (status != PSFS_PASS_ON) {
- break;
- }
- /* brig_out becomes brig_in.
- * brig_in will always be empty here, as the filter MUST attach any un-consumed buckets
- * to its own brigade */
- brig_swap = brig_inp;
- brig_inp = brig_outp;
- brig_outp = brig_swap;
- memset(brig_outp, 0, sizeof(*brig_outp));
- }
-
- switch (status) {
- case PSFS_PASS_ON:
- /* filter chain generated some output; push it through to the
- * underlying stream */
- while (brig_inp->head) {
- bucket = brig_inp->head;
- _php_stream_write_buffer(stream, bucket->buf, bucket->buflen TSRMLS_CC);
- /* Potential error situation - eg: no space on device. Perhaps we should keep this brigade
- * hanging around and try to write it later.
- * At the moment, we just drop it on the floor
- * */
-
- php_stream_bucket_unlink(bucket TSRMLS_CC);
- php_stream_bucket_delref(bucket TSRMLS_CC);
- }
- break;
- case PSFS_FEED_ME:
- /* need more data before we can push data through to the stream */
- break;
-
- case PSFS_ERR_FATAL:
- /* some fatal error. Theoretically, the stream is borked, so all
- * further writes should fail. */
- break;
- }
-
- return consumed;
-}
-
-PHPAPI int _php_stream_flush(php_stream *stream, int closing TSRMLS_DC)
-{
- int ret = 0;
-
- if (stream->writefilters.head) {
- _php_stream_write_filtered(stream, NULL, 0, closing ? PSFS_FLAG_FLUSH_CLOSE : PSFS_FLAG_FLUSH_INC TSRMLS_CC);
- }
-
- if (stream->ops->flush) {
- ret = stream->ops->flush(stream TSRMLS_CC);
- }
-
- return ret;
-}
-
-PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
-{
- if (buf == NULL || count == 0 || stream->ops->write == NULL)
- return 0;
-
- if (stream->writefilters.head) {
- return _php_stream_write_filtered(stream, buf, count, PSFS_FLAG_NORMAL TSRMLS_CC);
- } else {
- return _php_stream_write_buffer(stream, buf, count TSRMLS_CC);
- }
-}
-
-PHPAPI size_t _php_stream_printf(php_stream *stream TSRMLS_DC, const char *fmt, ...)
-{
- size_t count;
- char *buf;
- va_list ap;
-
- va_start(ap, fmt);
- count = vspprintf(&buf, 0, fmt, ap);
- va_end(ap);
-
- if (!buf)
- return 0; /* error condition */
-
- count = php_stream_write(stream, buf, count);
- efree(buf);
-
- return count;
-}
-
-PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC)
-{
- return stream->position;
-}
-
-PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC)
-{
- /* handle the case where we are in the buffer */
- if ((stream->flags & PHP_STREAM_FLAG_NO_BUFFER) == 0) {
- switch(whence) {
- case SEEK_CUR:
- if (offset > 0 && offset < stream->writepos - stream->readpos) {
- stream->readpos += offset;
- stream->position += offset;
- stream->eof = 0;
- return 0;
- }
- break;
- case SEEK_SET:
- if (offset > stream->position &&
- offset < stream->position + stream->writepos - stream->readpos) {
- stream->readpos += offset - stream->position;
- stream->position = offset;
- stream->eof = 0;
- return 0;
- }
- break;
- }
- }
-
-
- if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
- int ret;
-
- if (stream->writefilters.head) {
- _php_stream_flush(stream, 0 TSRMLS_CC);
- }
-
- switch(whence) {
- case SEEK_CUR:
- offset = stream->position + offset;
- whence = SEEK_SET;
- break;
- }
- ret = stream->ops->seek(stream, offset, whence, &stream->position TSRMLS_CC);
-
- if (((stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) || ret == 0) {
- if (ret == 0)
- stream->eof = 0;
-
- /* invalidate the buffer contents */
- stream->readpos = stream->writepos = 0;
-
- return ret;
- }
- /* else the stream has decided that it can't support seeking after all;
- * fall through to attempt emulation */
- }
-
- /* emulate forward moving seeks with reads */
- if (whence == SEEK_CUR && offset > 0) {
- char tmp[1024];
- while(offset >= sizeof(tmp)) {
- if (php_stream_read(stream, tmp, sizeof(tmp)) == 0)
- return -1;
- offset -= sizeof(tmp);
- }
- if (offset) {
- if (php_stream_read(stream, tmp, offset) == 0)
- return -1;
- }
- stream->eof = 0;
- return 0;
- }
-
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "stream does not support seeking");
-
- return -1;
-}
-
-PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC)
-{
- int ret = PHP_STREAM_OPTION_RETURN_NOTIMPL;
-
- if (stream->ops->set_option) {
- ret = stream->ops->set_option(stream, option, value, ptrparam TSRMLS_CC);
- }
-
- if (ret == PHP_STREAM_OPTION_RETURN_NOTIMPL) {
- switch(option) {
- case PHP_STREAM_OPTION_SET_CHUNK_SIZE:
- ret = stream->chunk_size;
- stream->chunk_size = value;
- return ret;
-
- case PHP_STREAM_OPTION_READ_BUFFER:
- /* try to match the buffer mode as best we can */
- if (value == PHP_STREAM_BUFFER_NONE) {
- stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
- } else {
- stream->flags ^= PHP_STREAM_FLAG_NO_BUFFER;
- }
- ret = PHP_STREAM_OPTION_RETURN_OK;
- break;
-
- default:
- ret = PHP_STREAM_OPTION_RETURN_ERR;
- }
- }
-
- return ret;
-}
-
-PHPAPI int _php_stream_truncate_set_size(php_stream *stream, size_t newsize TSRMLS_DC)
-{
- return php_stream_set_option(stream, PHP_STREAM_OPTION_TRUNCATE_API, PHP_STREAM_TRUNCATE_SET_SIZE, &newsize);
-}
-
-PHPAPI size_t _php_stream_passthru(php_stream * stream STREAMS_DC TSRMLS_DC)
-{
- size_t bcount = 0;
- char buf[8192];
- int b;
-
- if (php_stream_mmap_possible(stream)) {
- char *p;
- size_t mapped;
-
- p = php_stream_mmap_range(stream, php_stream_tell(stream), 0, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
-
- if (p) {
- PHPWRITE(p, mapped);
-
- php_stream_mmap_unmap(stream);
-
- return mapped;
- }
- }
-
- while ((b = php_stream_read(stream, buf, sizeof(buf))) > 0) {
- PHPWRITE(buf, b);
- bcount += b;
- }
-
- return bcount;
-}
-
-
-PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen, int persistent STREAMS_DC TSRMLS_DC)
-{
- size_t ret = 0;
- char *ptr;
- size_t len = 0, max_len;
- int step = CHUNK_SIZE;
- int min_room = CHUNK_SIZE / 4;
-
- if (buf)
- *buf = NULL;
-
- if (maxlen == 0)
- return 0;
-
- if (maxlen == PHP_STREAM_COPY_ALL)
- maxlen = 0;
-
- if (php_stream_mmap_possible(src)) {
- char *p;
- size_t mapped;
-
- p = php_stream_mmap_range(src, php_stream_tell(src), maxlen, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
-
- if (p) {
- *buf = pemalloc_rel_orig(mapped + 1, persistent);
-
- if (*buf) {
- memcpy(*buf, p, mapped);
- (*buf)[mapped] = '\0';
- }
-
- php_stream_mmap_unmap(src);
-
- return mapped;
- }
- }
-
- ptr = *buf = pemalloc_rel_orig(step, persistent);
- max_len = step;
-
- while((ret = php_stream_read(src, ptr, max_len - len))) {
- len += ret;
- if (len + min_room >= max_len) {
- *buf = perealloc_rel_orig(*buf, max_len + step, persistent);
- max_len += step;
- ptr = *buf + len;
- }
- }
- if (len) {
- *buf = perealloc_rel_orig(*buf, len + 1, persistent);
- (*buf)[len] = '\0';
- } else {
- pefree(*buf, persistent);
- *buf = NULL;
- }
- return len;
-}
-
-PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC TSRMLS_DC)
-{
- char buf[CHUNK_SIZE];
- size_t readchunk;
- size_t haveread = 0;
- size_t didread;
- php_stream_statbuf ssbuf;
-
- if (maxlen == 0)
- return 0;
-
- if (maxlen == PHP_STREAM_COPY_ALL)
- maxlen = 0;
-
- if (php_stream_stat(src, &ssbuf) == 0) {
- /* in the event that the source file is 0 bytes, return 1 to indicate success
- * because opening the file to write had already created a copy */
- if (ssbuf.sb.st_size == 0) {
- return 1;
- }
- }
-
- if (php_stream_mmap_possible(src)) {
- char *p;
- size_t mapped;
-
- p = php_stream_mmap_range(src, php_stream_tell(src), maxlen, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
-
- if (p) {
- haveread = php_stream_write(dest, p, mapped);
-
- php_stream_mmap_unmap(src);
-
- return mapped;
- }
- }
-
- while(1) {
- readchunk = sizeof(buf);
-
- if (maxlen && (maxlen - haveread) < readchunk)
- readchunk = maxlen - haveread;
-
- didread = php_stream_read(src, buf, readchunk);
-
- if (didread) {
- /* extra paranoid */
- size_t didwrite, towrite;
- char *writeptr;
-
- towrite = didread;
- writeptr = buf;
- haveread += didread;
-
- while(towrite) {
- didwrite = php_stream_write(dest, writeptr, towrite);
- if (didwrite == 0)
- return 0; /* error */
-
- towrite -= didwrite;
- writeptr += didwrite;
- }
- } else {
- if (maxlen == 0) {
- return haveread;
- } else {
- return 0; /* error */
- }
- }
-
- if (maxlen - haveread == 0) {
- break;
- }
- }
- return haveread;
-
-}
-/* }}} */
-
-/* {{{ wrapper init and registration */
-
-static void stream_resource_regular_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
- php_stream *stream = (php_stream*)rsrc->ptr;
- /* set the return value for pclose */
- FG(pclose_ret) = php_stream_free(stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_RSRC_DTOR);
-}
-
-static void stream_resource_persistent_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
- php_stream *stream = (php_stream*)rsrc->ptr;
- FG(pclose_ret) = php_stream_free(stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_RSRC_DTOR);
-}
-
-int php_init_stream_wrappers(int module_number TSRMLS_DC)
-{
- le_stream = zend_register_list_destructors_ex(stream_resource_regular_dtor, NULL, "stream", module_number);
- le_pstream = zend_register_list_destructors_ex(NULL, stream_resource_persistent_dtor, "persistent stream", module_number);
-
- return (
- zend_hash_init(&url_stream_wrappers_hash, 0, NULL, NULL, 1) == SUCCESS
- &&
- zend_hash_init(php_get_stream_filters_hash(), 0, NULL, NULL, 1) == SUCCESS
- &&
- zend_hash_init(php_stream_xport_get_hash(), 0, NULL, NULL, 1) == SUCCESS
- &&
- php_stream_xport_register("tcp", php_stream_generic_socket_factory TSRMLS_CC) == SUCCESS
- &&
- php_stream_xport_register("udp", php_stream_generic_socket_factory TSRMLS_CC) == SUCCESS
-#ifdef AF_UNIX
- &&
- php_stream_xport_register("unix", php_stream_generic_socket_factory TSRMLS_CC) == SUCCESS
- &&
- php_stream_xport_register("udg", php_stream_generic_socket_factory TSRMLS_CC) == SUCCESS
-#endif
- ) ? SUCCESS : FAILURE;
-}
-
-int php_shutdown_stream_wrappers(int module_number TSRMLS_DC)
-{
- zend_hash_destroy(&url_stream_wrappers_hash);
- zend_hash_destroy(php_get_stream_filters_hash());
- zend_hash_destroy(php_stream_xport_get_hash());
- return SUCCESS;
-}
-
-PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC)
-{
- return zend_hash_add(&url_stream_wrappers_hash, protocol, strlen(protocol), wrapper, sizeof(*wrapper), NULL);
-}
-
-PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC)
-{
- return zend_hash_del(&url_stream_wrappers_hash, protocol, strlen(protocol));
-}
-/* }}} */
-
-/* {{{ php_stream_locate_url_wrapper */
-PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char **path_for_open, int options TSRMLS_DC)
-{
- php_stream_wrapper *wrapper = NULL;
- const char *p, *protocol = NULL;
- int n = 0;
-
- if (path_for_open)
- *path_for_open = (char*)path;
-
- if (options & IGNORE_URL)
- return (options & STREAM_LOCATE_WRAPPERS_ONLY) ? NULL : &php_plain_files_wrapper;
-
- for (p = path; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++) {
- n++;
- }
-
- if ((*p == ':') && (n > 1) && !strncmp("://", p, 3)) {
- protocol = path;
- } else if (strncasecmp(path, "zlib:", 5) == 0) {
- /* BC with older php scripts and zlib wrapper */
- protocol = "compress.zlib";
- n = 13;
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Use of \"zlib:\" wrapper is deprecated; please use \"compress.zlib://\" instead.");
- }
-
- if (protocol) {
- if (FAILURE == zend_hash_find(&url_stream_wrappers_hash, (char*)protocol, n, (void**)&wrapper)) {
- char wrapper_name[32];
-
- if (n >= sizeof(wrapper_name))
- n = sizeof(wrapper_name) - 1;
- PHP_STRLCPY(wrapper_name, protocol, sizeof(wrapper_name), n);
-
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find the wrapper \"%s\" - did you forget to enable it when you configured PHP?",
- wrapper_name);
-
- wrapper = NULL;
- protocol = NULL;
- }
- }
- /* TODO: curl based streams probably support file:// properly */
- if (!protocol || !strncasecmp(protocol, "file", n)) {
- if (protocol && path[n+1] == '/' && path[n+2] == '/') {
- if (options & REPORT_ERRORS)
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "remote host file access not supported, %s", path);
- return NULL;
- }
- if (protocol && path_for_open)
- *path_for_open = (char*)path + n + 1;
-
- /* fall back on regular file access */
- return (options & STREAM_LOCATE_WRAPPERS_ONLY) ? NULL : &php_plain_files_wrapper;
- }
-
- if (wrapper && wrapper->is_url && !PG(allow_url_fopen)) {
- if (options & REPORT_ERRORS)
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL file-access is disabled in the server configuration");
- return NULL;
- }
-
- return wrapper;
-}
-/* }}} */
-
-/* {{{ _php_stream_stat_path */
-PHPAPI int _php_stream_stat_path(char *path, php_stream_statbuf *ssb TSRMLS_DC)
-{
- php_stream_wrapper *wrapper = NULL;
- char *path_to_open = path;
-
- wrapper = php_stream_locate_url_wrapper(path, &path_to_open, ENFORCE_SAFE_MODE TSRMLS_CC);
- if (wrapper && wrapper->wops->url_stat) {
- return wrapper->wops->url_stat(wrapper, path_to_open, ssb TSRMLS_CC);
- }
- return -1;
-}
-/* }}} */
-
-/* {{{ php_stream_opendir */
-PHPAPI php_stream *_php_stream_opendir(char *path, int options,
- php_stream_context *context STREAMS_DC TSRMLS_DC)
-{
- php_stream *stream = NULL;
- php_stream_wrapper *wrapper = NULL;
- char *path_to_open;
-
- if (!path || !*path)
- return NULL;
-
- path_to_open = path;
-
- wrapper = php_stream_locate_url_wrapper(path, &path_to_open, options TSRMLS_CC);
-
- if (wrapper && wrapper->wops->dir_opener) {
- stream = wrapper->wops->dir_opener(wrapper,
- path_to_open, "r", options ^ REPORT_ERRORS, NULL,
- context STREAMS_REL_CC TSRMLS_CC);
-
- if (stream) {
- stream->wrapper = wrapper;
- stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
- }
- } else if (wrapper) {
- php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, "not implemented");
- }
- if (stream == NULL && (options & REPORT_ERRORS)) {
- php_stream_display_wrapper_errors(wrapper, path, "failed to open dir" TSRMLS_CC);
- }
- php_stream_tidy_wrapper_error_log(wrapper TSRMLS_CC);
-
- return stream;
-}
-/* }}} */
-
-/* {{{ _php_stream_readdir */
-PHPAPI php_stream_dirent *_php_stream_readdir(php_stream *dirstream, php_stream_dirent *ent TSRMLS_DC)
-{
-
- if (sizeof(php_stream_dirent) == php_stream_read(dirstream, (char*)ent, sizeof(php_stream_dirent)))
- return ent;
-
- return NULL;
-}
-/* }}} */
-
-/* {{{ php_stream_open_wrapper_ex */
-PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int options,
- char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
-{
- php_stream *stream = NULL;
- php_stream_wrapper *wrapper = NULL;
- char *path_to_open;
-#if ZEND_DEBUG
- char *copy_of_path = NULL;
-#endif
-
-
- if (opened_path)
- *opened_path = NULL;
-
- if (!path || !*path)
- return NULL;
-
- path_to_open = path;
-
- wrapper = php_stream_locate_url_wrapper(path, &path_to_open, options TSRMLS_CC);
- if (options & STREAM_USE_URL && (!wrapper || !wrapper->is_url)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function may only be used against URLs.");
- return NULL;
- }
-
- if (wrapper) {
-
- stream = wrapper->wops->stream_opener(wrapper,
- path_to_open, mode, options ^ REPORT_ERRORS,
- opened_path, context STREAMS_REL_CC TSRMLS_CC);
-
- if (stream) {
- stream->wrapper = wrapper;
- }
- }
-
-#if ZEND_DEBUG
- if (stream) {
- copy_of_path = estrdup(path);
- stream->__orig_path = copy_of_path;
- }
-#endif
-
- if (stream != NULL && (options & STREAM_MUST_SEEK)) {
- php_stream *newstream;
-
- switch(php_stream_make_seekable_rel(stream, &newstream,
- (options & STREAM_WILL_CAST)
- ? PHP_STREAM_PREFER_STDIO : PHP_STREAM_NO_PREFERENCE)) {
- case PHP_STREAM_UNCHANGED:
- return stream;
- case PHP_STREAM_RELEASED:
-#if ZEND_DEBUG
- newstream->__orig_path = estrdup(path);
-#endif
- return newstream;
- default:
- php_stream_close(stream);
- stream = NULL;
- if (options & REPORT_ERRORS) {
- char *tmp = estrdup(path);
- php_strip_url_passwd(tmp);
- php_error_docref1(NULL TSRMLS_CC, tmp, E_WARNING, "could not make seekable - %s",
- tmp, strerror(errno));
- efree(tmp);
-
- options ^= REPORT_ERRORS;
- }
- }
- }
-
- if (stream && stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0 && strchr(mode, 'a') && stream->position == 0) {
- off_t newpos = 0;
-
- /* if opened for append, we need to revise our idea of the initial file position */
- if (0 == stream->ops->seek(stream, 0, SEEK_CUR, &newpos TSRMLS_CC)) {
- stream->position = newpos;
- }
- }
-
- if (stream == NULL && (options & REPORT_ERRORS)) {
- php_stream_display_wrapper_errors(wrapper, path, "failed to open stream" TSRMLS_CC);
- }
- php_stream_tidy_wrapper_error_log(wrapper TSRMLS_CC);
-#if ZEND_DEBUG
- if (stream == NULL && copy_of_path != NULL) {
- efree(copy_of_path);
- }
-#endif
- return stream;
-}
-/* }}} */
-
-/* {{{ context API */
-PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream_context *context)
-{
- php_stream_context *oldcontext = stream->context;
- stream->context = context;
- return oldcontext;
-}
-
-PHPAPI void php_stream_notification_notify(php_stream_context *context, int notifycode, int severity,
- char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void * ptr TSRMLS_DC)
-{
- if (context && context->notifier)
- context->notifier->func(context, notifycode, severity, xmsg, xcode, bytes_sofar, bytes_max, ptr TSRMLS_CC);
-}
-
-PHPAPI void php_stream_context_free(php_stream_context *context)
-{
- zval_ptr_dtor(&context->options);
- efree(context);
-}
-
-PHPAPI php_stream_context *php_stream_context_alloc(void)
-{
- php_stream_context *context;
-
- context = ecalloc(1, sizeof(php_stream_context));
- MAKE_STD_ZVAL(context->options);
- array_init(context->options);
-
- return context;
-}
-
-PHPAPI php_stream_notifier *php_stream_notification_alloc(void)
-{
- return ecalloc(1, sizeof(php_stream_notifier));
-}
-
-PHPAPI void php_stream_notification_free(php_stream_notifier *notifier)
-{
- efree(notifier);
-}
-
-PHPAPI int php_stream_context_get_option(php_stream_context *context,
- const char *wrappername, const char *optionname, zval ***optionvalue)
-{
- zval **wrapperhash;
-
- if (FAILURE == zend_hash_find(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)&wrapperhash))
- return FAILURE;
- return zend_hash_find(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)optionvalue);
-}
-
-PHPAPI int php_stream_context_set_option(php_stream_context *context,
- const char *wrappername, const char *optionname, zval *optionvalue)
-{
- zval **wrapperhash;
- zval *category;
-
- if (FAILURE == zend_hash_find(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)&wrapperhash)) {
-
- MAKE_STD_ZVAL(category);
- array_init(category);
- if (FAILURE == zend_hash_update(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)&category, sizeof(zval *), NULL))
- return FAILURE;
-
- ZVAL_ADDREF(optionvalue);
- wrapperhash = &category;
- }
- return zend_hash_update(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)&optionvalue, sizeof(zval *), NULL);
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/transports.c b/main/streams/transports.c
deleted file mode 100644
index dc8c5a942e..0000000000
--- a/main/streams/transports.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php.h"
-#include "php_streams_int.h"
-#include "ext/standard/file.h"
-
-static HashTable xport_hash;
-
-PHPAPI HashTable *php_stream_xport_get_hash(void)
-{
- return &xport_hash;
-}
-
-PHPAPI int php_stream_xport_register(char *protocol, php_stream_transport_factory factory TSRMLS_DC)
-{
- return zend_hash_update(&xport_hash, protocol, strlen(protocol), &factory, sizeof(factory), NULL);
-}
-
-PHPAPI int php_stream_xport_unregister(char *protocol TSRMLS_DC)
-{
- return zend_hash_del(&xport_hash, protocol, strlen(protocol));
-}
-
-#define ERR_REPORT(out_err, fmt, arg) \
- if (out_err) { spprintf(out_err, 0, fmt, arg); } \
- else { php_error_docref(NULL TSRMLS_CC, E_WARNING, fmt, arg); }
-
-#define ERR_RETURN(out_err, local_err, fmt) \
- if (out_err) { *out_err = local_err; } \
- else { php_error_docref(NULL TSRMLS_CC, E_WARNING, fmt, local_err ? local_err : "Unspecified error"); \
- if (local_err) { efree(local_err); local_err = NULL; } \
- }
-
-PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int options,
- int flags, const char *persistent_id,
- struct timeval *timeout,
- php_stream_context *context,
- char **error_string,
- int *error_code
- STREAMS_DC TSRMLS_DC)
-{
- php_stream *stream = NULL;
- php_stream_transport_factory *factory = NULL;
- const char *p, *protocol = NULL;
- int n = 0, failed = 0;
- char *error_text = NULL;
- struct timeval default_timeout = { FG(default_socket_timeout), 0 };
-
- if (timeout == NULL) {
- timeout = &default_timeout;
- }
-
- /* check for a cached persistent socket */
- if (persistent_id) {
- switch(php_stream_from_persistent_id(persistent_id, &stream TSRMLS_CC)) {
- case PHP_STREAM_PERSISTENT_SUCCESS:
- /* TODO: check if the socket is still live */
- return stream;
-
- case PHP_STREAM_PERSISTENT_FAILURE:
- default:
- /* failed; get a new one */
- }
- }
-
- for (p = name; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++) {
- n++;
- }
-
- if ((*p == ':') && (n > 1) && !strncmp("://", p, 3)) {
- protocol = name;
- name = p + 3;
- namelen -= n + 3;
- } else {
- protocol = "tcp";
- n = 3;
- }
-
- if (protocol) {
- if (FAILURE == zend_hash_find(&xport_hash, (char*)protocol, n, (void**)&factory)) {
- char wrapper_name[32];
-
- if (n >= sizeof(wrapper_name))
- n = sizeof(wrapper_name) - 1;
- PHP_STRLCPY(wrapper_name, protocol, sizeof(wrapper_name), n);
-
- ERR_REPORT(error_string, "Unable to find the socket transport \"%s\" - did you forget to enable it when you configured PHP?",
- wrapper_name);
-
- return NULL;
- }
- }
-
- if (factory == NULL) {
- /* should never happen */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not find a factory !?");
- return NULL;
- }
-
- stream = (*factory)(protocol, n,
- (char*)name, namelen, persistent_id, options, flags, timeout,
- context STREAMS_REL_CC TSRMLS_CC);
-
- if (stream) {
- stream->context = context;
-
- if ((flags & STREAM_XPORT_SERVER) == 0) {
- /* client */
-
- if (flags & STREAM_XPORT_CONNECT) {
- if (0 != php_stream_xport_connect(stream, name, namelen,
- flags & STREAM_XPORT_OP_CONNECT_ASYNC ? 1 : 0,
- timeout, &error_text, error_code TSRMLS_CC)) {
-
- ERR_RETURN(error_string, error_text, "connect() failed: %s");
-
- failed = 1;
- }
- }
-
- } else {
- /* server */
- if (flags & STREAM_XPORT_BIND) {
- if (0 != php_stream_xport_bind(stream, name, namelen, &error_text TSRMLS_CC)) {
- ERR_RETURN(error_string, error_text, "bind() failed: %s");
- failed = 1;
- } else if (flags & STREAM_XPORT_LISTEN) {
- if (0 != php_stream_xport_listen(stream, 5, &error_text TSRMLS_CC)) {
- ERR_RETURN(error_string, error_text, "listen() failed: %s");
- failed = 1;
- }
- }
- }
- }
- }
-
- if (failed) {
- /* failure means that they don't get a stream to play with */
- php_stream_close(stream);
- stream = NULL;
- }
-
- return stream;
-}
-
-/* Bind the stream to a local address */
-PHPAPI int php_stream_xport_bind(php_stream *stream,
- const char *name, long namelen,
- char **error_text
- TSRMLS_DC)
-{
- php_stream_xport_param param;
- int ret;
-
- memset(&param, 0, sizeof(param));
- param.op = STREAM_XPORT_OP_BIND;
- param.inputs.name = (char*)name;
- param.inputs.namelen = namelen;
- param.want_errortext = error_text ? 1 : 0;
-
- ret = php_stream_set_option(stream, PHP_STREAM_OPTION_XPORT_API, 0, &param);
-
- if (ret == PHP_STREAM_OPTION_RETURN_OK) {
- if (error_text) {
- *error_text = param.outputs.error_text;
- }
-
- return param.outputs.returncode;
- }
-
- return ret;
-}
-
-/* Connect to a remote address */
-PHPAPI int php_stream_xport_connect(php_stream *stream,
- const char *name, long namelen,
- int asynchronous,
- struct timeval *timeout,
- char **error_text,
- int *error_code
- TSRMLS_DC)
-{
- php_stream_xport_param param;
- int ret;
-
- memset(&param, 0, sizeof(param));
- param.op = asynchronous ? STREAM_XPORT_OP_CONNECT_ASYNC: STREAM_XPORT_OP_CONNECT;
- param.inputs.name = (char*)name;
- param.inputs.namelen = namelen;
- param.inputs.timeout = timeout;
-
- param.want_errortext = error_text ? 1 : 0;
-
- ret = php_stream_set_option(stream, PHP_STREAM_OPTION_XPORT_API, 0, &param);
-
- if (ret == PHP_STREAM_OPTION_RETURN_OK) {
- if (error_text) {
- *error_text = param.outputs.error_text;
- }
- if (error_code) {
- *error_code = param.outputs.error_code;
- }
- return param.outputs.returncode;
- }
-
- return ret;
-
-}
-
-/* Prepare to listen */
-PHPAPI int php_stream_xport_listen(php_stream *stream, int backlog, char **error_text TSRMLS_DC)
-{
- php_stream_xport_param param;
- int ret;
-
- memset(&param, 0, sizeof(param));
- param.op = STREAM_XPORT_OP_LISTEN;
- param.inputs.backlog = backlog;
- param.want_errortext = error_text ? 1 : 0;
-
- ret = php_stream_set_option(stream, PHP_STREAM_OPTION_XPORT_API, 0, &param);
-
- if (ret == PHP_STREAM_OPTION_RETURN_OK) {
- if (error_text) {
- *error_text = param.outputs.error_text;
- }
-
- return param.outputs.returncode;
- }
-
- return ret;
-}
-
-/* Get the next client and their address (as a string) */
-PHPAPI int php_stream_xport_accept(php_stream *stream, php_stream **client,
- char **textaddr, long *textaddrlen,
- void **addr, size_t *addrlen,
- struct timeval *timeout,
- char **error_text
- TSRMLS_DC)
-{
- php_stream_xport_param param;
- int ret;
-
- memset(&param, 0, sizeof(param));
-
- param.op = STREAM_XPORT_OP_BIND;
- param.inputs.timeout = timeout;
- param.want_addr = addr ? 1 : 0;
- param.want_textaddr = textaddr ? 1 : 0;
- param.want_errortext = error_text ? 1 : 0;
-
- ret = php_stream_set_option(stream, PHP_STREAM_OPTION_XPORT_API, 0, &param);
-
- if (ret == PHP_STREAM_OPTION_RETURN_OK) {
- *client = param.outputs.client;
- if (addr) {
- *addr = param.outputs.addr;
- *addrlen = param.outputs.addrlen;
- }
- if (textaddr) {
- *textaddr = param.outputs.textaddr;
- *textaddrlen = param.outputs.textaddrlen;
- }
- if (error_text) {
- *error_text = param.outputs.error_text;
- }
-
- return param.outputs.returncode;
- }
- return ret;
-}
-
-PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_crypt_method_t crypto_method, php_stream *session_stream TSRMLS_DC)
-{
- php_stream_xport_crypto_param param;
- int ret;
-
- memset(&param, 0, sizeof(param));
- param.op = STREAM_XPORT_CRYPTO_OP_SETUP;
- param.inputs.method = crypto_method;
- param.inputs.session = session_stream;
-
- ret = php_stream_set_option(stream, PHP_STREAM_OPTION_CRYPTO_API, 0, &param);
-
- if (ret == PHP_STREAM_OPTION_RETURN_OK) {
- return param.outputs.returncode;
- }
-
- php_error_docref("streams.crypto" TSRMLS_CC, E_WARNING, "this stream does not support SSL/crypto");
-
- return ret;
-}
-
-PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate TSRMLS_DC)
-{
- php_stream_xport_crypto_param param;
- int ret;
-
- memset(&param, 0, sizeof(param));
- param.op = STREAM_XPORT_CRYPTO_OP_ENABLE;
- param.inputs.activate = activate;
-
- ret = php_stream_set_option(stream, PHP_STREAM_OPTION_CRYPTO_API, 0, &param);
-
- if (ret == PHP_STREAM_OPTION_RETURN_OK) {
- return param.outputs.returncode;
- }
-
- php_error_docref("streams.crypto" TSRMLS_CC, E_WARNING, "this stream does not support SSL/crypto");
-
- return ret;
-}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
deleted file mode 100644
index 096eaac841..0000000000
--- a/main/streams/userspace.c
+++ /dev/null
@@ -1,862 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php.h"
-#include "php_globals.h"
-#include "ext/standard/file.h"
-
-static int le_protocols;
-
-struct php_user_stream_wrapper {
- char * protoname;
- char * classname;
- zend_class_entry *ce;
- php_stream_wrapper wrapper;
-};
-
-static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
-static int user_wrapper_stat_url(php_stream_wrapper *wrapper, char *url, php_stream_statbuf *ssb TSRMLS_DC);
-static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, char *filename, char *mode,
- int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
-
-static php_stream_wrapper_ops user_stream_wops = {
- user_wrapper_opener,
- NULL, /* close - the streams themselves know how */
- NULL, /* stat - the streams themselves know how */
- user_wrapper_stat_url,
- user_wrapper_opendir,
- "user-space"
-};
-
-
-static void stream_wrapper_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
- struct php_user_stream_wrapper * uwrap = (struct php_user_stream_wrapper*)rsrc->ptr;
-
- php_unregister_url_stream_wrapper(uwrap->protoname TSRMLS_CC);
- efree(uwrap->protoname);
- efree(uwrap->classname);
- efree(uwrap);
-}
-
-
-PHP_MINIT_FUNCTION(user_streams)
-{
- le_protocols = zend_register_list_destructors_ex(stream_wrapper_dtor, NULL, "stream factory", 0);
- if (le_protocols == FAILURE)
- return FAILURE;
-
- REGISTER_LONG_CONSTANT("STREAM_USE_PATH", USE_PATH, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("STREAM_IGNORE_URL", IGNORE_URL, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("STREAM_ENFORCE_SAFE_MODE", ENFORCE_SAFE_MODE, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("STREAM_REPORT_ERRORS", REPORT_ERRORS, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("STREAM_MUST_SEEK", STREAM_MUST_SEEK, CONST_CS|CONST_PERSISTENT);
-
- return SUCCESS;
-}
-
-struct _php_userstream_data {
- struct php_user_stream_wrapper * wrapper;
- zval * object;
-};
-typedef struct _php_userstream_data php_userstream_data_t;
-
-/* names of methods */
-#define USERSTREAM_OPEN "stream_open"
-#define USERSTREAM_CLOSE "stream_close"
-#define USERSTREAM_READ "stream_read"
-#define USERSTREAM_WRITE "stream_write"
-#define USERSTREAM_FLUSH "stream_flush"
-#define USERSTREAM_SEEK "stream_seek"
-#define USERSTREAM_TELL "stream_tell"
-#define USERSTREAM_EOF "stream_eof"
-#define USERSTREAM_STAT "stream_stat"
-#define USERSTREAM_STATURL "url_stat"
-#define USERSTREAM_DIR_OPEN "dir_opendir"
-#define USERSTREAM_DIR_READ "dir_readdir"
-#define USERSTREAM_DIR_REWIND "dir_rewinddir"
-#define USERSTREAM_DIR_CLOSE "dir_closedir"
-
-/* {{{ class should have methods like these:
-
- function stream_open($path, $mode, $options, &$opened_path)
- {
- return true/false;
- }
-
- function stream_read($count)
- {
- return false on error;
- else return string;
- }
-
- function stream_write($data)
- {
- return false on error;
- else return count written;
- }
-
- function stream_close()
- {
- }
-
- function stream_flush()
- {
- return true/false;
- }
-
- function stream_seek($offset, $whence)
- {
- return true/false;
- }
-
- function stream_tell()
- {
- return (int)$position;
- }
-
- function stream_eof()
- {
- return true/false;
- }
-
- function stream_stat()
- {
- return array( just like that returned by fstat() );
- }
-
- function url_stat(string $url)
- {
- return array( just like that returned by stat() );
- }
-
- function dir_opendir(string $url, int $options)
- {
- return true / false;
- }
-
- function dir_readdir()
- {
- return string next filename in dir ;
- }
-
- function dir_closedir()
- {
- release dir related resources;
- }
-
- function dir_rewinddir()
- {
- reset to start of dir list;
- }
-
- }}} **/
-
-static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
-{
- struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract;
- php_userstream_data_t *us;
- zval *zfilename, *zmode, *zopened, *zoptions, *zretval = NULL, *zfuncname;
- zval **args[4];
- int call_result;
- php_stream *stream = NULL;
-
- /* Try to catch bad usage without preventing flexibility */
- if (FG(user_stream_current_filename) != NULL && strcmp(filename, FG(user_stream_current_filename)) == 0) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "infinite recursion prevented");
- return NULL;
- }
- FG(user_stream_current_filename) = filename;
-
- us = emalloc(sizeof(*us));
- us->wrapper = uwrap;
-
- /* create an instance of our class */
- ALLOC_ZVAL(us->object);
- object_init_ex(us->object, uwrap->ce);
- ZVAL_REFCOUNT(us->object) = 1;
- PZVAL_IS_REF(us->object) = 1;
-
- /* call it's stream_open method - set up params first */
- MAKE_STD_ZVAL(zfilename);
- ZVAL_STRING(zfilename, filename, 1);
- args[0] = &zfilename;
-
- MAKE_STD_ZVAL(zmode);
- ZVAL_STRING(zmode, mode, 1);
- args[1] = &zmode;
-
- MAKE_STD_ZVAL(zoptions);
- ZVAL_LONG(zoptions, options);
- args[2] = &zoptions;
-
- MAKE_STD_ZVAL(zopened);
- ZVAL_REFCOUNT(zopened) = 1;
- PZVAL_IS_REF(zopened) = 1;
- ZVAL_NULL(zopened);
- args[3] = &zopened;
-
- MAKE_STD_ZVAL(zfuncname);
- ZVAL_STRING(zfuncname, USERSTREAM_OPEN, 1);
-
- call_result = call_user_function_ex(NULL,
- &us->object,
- zfuncname,
- &zretval,
- 4, args,
- 0, NULL TSRMLS_CC);
-
- if (call_result == SUCCESS && zretval != NULL && zval_is_true(zretval)) {
- /* the stream is now open! */
- stream = php_stream_alloc_rel(&php_stream_userspace_ops, us, 0, mode);
-
- /* if the opened path is set, copy it out */
- if (Z_TYPE_P(zopened) == IS_STRING && opened_path) {
- *opened_path = estrndup(Z_STRVAL_P(zopened), Z_STRLEN_P(zopened));
- }
-
- /* set wrapper data to be a reference to our object */
- stream->wrapperdata = us->object;
- zval_add_ref(&stream->wrapperdata);
- } else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "\"%s::" USERSTREAM_OPEN "\" call failed",
- us->wrapper->classname);
- }
-
- /* destroy everything else */
- if (stream == NULL) {
- zval_ptr_dtor(&us->object);
- efree(us);
- }
- if (zretval)
- zval_ptr_dtor(&zretval);
-
- zval_ptr_dtor(&zfuncname);
- zval_ptr_dtor(&zopened);
- zval_ptr_dtor(&zoptions);
- zval_ptr_dtor(&zmode);
- zval_ptr_dtor(&zfilename);
-
- FG(user_stream_current_filename) = NULL;
-
- return stream;
-}
-
-static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, char *filename, char *mode,
- int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
-{
- struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract;
- php_userstream_data_t *us;
- zval *zfilename, *zoptions, *zretval = NULL, *zfuncname;
- zval **args[2];
- int call_result;
- php_stream *stream = NULL;
-
- /* Try to catch bad usage without preventing flexibility */
- if (FG(user_stream_current_filename) != NULL && strcmp(filename, FG(user_stream_current_filename)) == 0) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "infinite recursion prevented");
- return NULL;
- }
- FG(user_stream_current_filename) = filename;
-
- us = emalloc(sizeof(*us));
- us->wrapper = uwrap;
-
- /* create an instance of our class */
- ALLOC_ZVAL(us->object);
- object_init_ex(us->object, uwrap->ce);
- ZVAL_REFCOUNT(us->object) = 1;
- PZVAL_IS_REF(us->object) = 1;
-
- /* call it's dir_open method - set up params first */
- MAKE_STD_ZVAL(zfilename);
- ZVAL_STRING(zfilename, filename, 1);
- args[0] = &zfilename;
-
- MAKE_STD_ZVAL(zoptions);
- ZVAL_LONG(zoptions, options);
- args[1] = &zoptions;
-
- MAKE_STD_ZVAL(zfuncname);
- ZVAL_STRING(zfuncname, USERSTREAM_DIR_OPEN, 1);
-
- call_result = call_user_function_ex(NULL,
- &us->object,
- zfuncname,
- &zretval,
- 2, args,
- 0, NULL TSRMLS_CC);
-
- if (call_result == SUCCESS && zretval != NULL && zval_is_true(zretval)) {
- /* the stream is now open! */
- stream = php_stream_alloc_rel(&php_stream_userspace_dir_ops, us, 0, mode);
-
- /* set wrapper data to be a reference to our object */
- stream->wrapperdata = us->object;
- zval_add_ref(&stream->wrapperdata);
- } else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "\"%s::" USERSTREAM_DIR_OPEN "\" call failed",
- us->wrapper->classname);
- }
-
- /* destroy everything else */
- if (stream == NULL) {
- zval_ptr_dtor(&us->object);
- efree(us);
- }
- if (zretval)
- zval_ptr_dtor(&zretval);
-
- zval_ptr_dtor(&zfuncname);
- zval_ptr_dtor(&zoptions);
- zval_ptr_dtor(&zfilename);
-
- FG(user_stream_current_filename) = NULL;
-
- return stream;
-}
-
-
-/* {{{ proto bool stream_register_wrapper(string protocol, string classname)
- Registers a custom URL protocol handler class */
-PHP_FUNCTION(stream_register_wrapper)
-{
- char *protocol, *classname;
- int protocol_len, classname_len;
- struct php_user_stream_wrapper * uwrap;
- int rsrc_id;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &protocol, &protocol_len, &classname, &classname_len) == FAILURE) {
- RETURN_FALSE;
- }
-
- uwrap = (struct php_user_stream_wrapper *)ecalloc(1, sizeof(*uwrap));
- uwrap->protoname = estrndup(protocol, protocol_len);
- uwrap->classname = estrndup(classname, classname_len);
- uwrap->wrapper.wops = &user_stream_wops;
- uwrap->wrapper.abstract = uwrap;
-
- zend_str_tolower(uwrap->classname, classname_len);
- rsrc_id = ZEND_REGISTER_RESOURCE(NULL, uwrap, le_protocols);
-
- if (zend_hash_find(EG(class_table), uwrap->classname, classname_len + 1, (void**)&uwrap->ce) == SUCCESS) {
-#ifdef ZEND_ENGINE_2
- uwrap->ce = *(zend_class_entry**)uwrap->ce;
-#endif
- if (php_register_url_stream_wrapper(protocol, &uwrap->wrapper TSRMLS_CC) == SUCCESS) {
- RETURN_TRUE;
- }
- } else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "class '%s' is undefined",
- classname);
- }
-
- zend_list_delete(rsrc_id);
- RETURN_FALSE;
-}
-/* }}} */
-
-
-static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
-{
- zval func_name;
- zval *retval = NULL;
- int call_result;
- php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
- zval **args[1];
- zval zbuff, *zbufptr;
- size_t didwrite = 0;
-
- assert(us != NULL);
-
- ZVAL_STRINGL(&func_name, USERSTREAM_WRITE, sizeof(USERSTREAM_WRITE)-1, 0);
-
- ZVAL_STRINGL(&zbuff, (char*)buf, count, 0);
- zbufptr = &zbuff;
- args[0] = &zbufptr;
-
- call_result = call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 1, args,
- 0, NULL TSRMLS_CC);
-
- didwrite = 0;
- if (call_result == SUCCESS && retval != NULL) {
- convert_to_long(retval);
- didwrite = Z_LVAL_P(retval);
- } else if (call_result == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " is not implemented!",
- us->wrapper->classname);
- }
-
- /* don't allow strange buffer overruns due to bogus return */
- if (didwrite > count) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " wrote %d bytes more data than requested (%d written, %d max)",
- us->wrapper->classname,
- didwrite - count, didwrite, count);
- didwrite = count;
- }
-
- if (retval)
- zval_ptr_dtor(&retval);
-
- return didwrite;
-}
-
-static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
-{
- zval func_name;
- zval *retval = NULL;
- zval **args[1];
- int call_result;
- size_t didread = 0;
- php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
- zval *zcount;
-
- assert(us != NULL);
-
- ZVAL_STRINGL(&func_name, USERSTREAM_READ, sizeof(USERSTREAM_READ)-1, 0);
-
- MAKE_STD_ZVAL(zcount);
- ZVAL_LONG(zcount, count);
- args[0] = &zcount;
-
- call_result = call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 1, args,
- 0, NULL TSRMLS_CC);
-
- if (call_result == SUCCESS && retval != NULL) {
- convert_to_string(retval);
- didread = Z_STRLEN_P(retval);
- if (didread > count) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_READ " - read %d bytes more data than requested (%d read, %d max) - excess data will be lost",
- us->wrapper->classname, didread - count, didread, count);
- didread = count;
- }
- if (didread > 0)
- memcpy(buf, Z_STRVAL_P(retval), didread);
- } else if (call_result == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_READ " is not implemented!",
- us->wrapper->classname);
- }
- zval_ptr_dtor(&zcount);
-
- if (retval) {
- zval_ptr_dtor(&retval);
- retval = NULL;
- }
-
- /* since the user stream has no way of setting the eof flag directly, we need to ask it if we hit eof */
-
- ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1, 0);
-
- call_result = call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 0, NULL, 0, NULL TSRMLS_CC);
-
- if (call_result == SUCCESS && retval != NULL && zval_is_true(retval)) {
- stream->eof = 1;
- } else if (call_result == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "%s::" USERSTREAM_EOF " is not implemented! Assuming EOF",
- us->wrapper->classname);
-
- stream->eof = 1;
- }
-
- if (retval) {
- zval_ptr_dtor(&retval);
- retval = NULL;
- }
-
- return didread;
-}
-
-static int php_userstreamop_close(php_stream *stream, int close_handle TSRMLS_DC)
-{
- zval func_name;
- zval *retval = NULL;
- php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
-
- assert(us != NULL);
-
- ZVAL_STRINGL(&func_name, USERSTREAM_CLOSE, sizeof(USERSTREAM_CLOSE)-1, 0);
-
- call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 0, NULL, 0, NULL TSRMLS_CC);
-
- if (retval)
- zval_ptr_dtor(&retval);
-
- zval_ptr_dtor(&us->object);
-
- efree(us);
-
- return 0;
-}
-
-static int php_userstreamop_flush(php_stream *stream TSRMLS_DC)
-{
- zval func_name;
- zval *retval = NULL;
- int call_result;
- php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
-
- assert(us != NULL);
-
- ZVAL_STRINGL(&func_name, USERSTREAM_FLUSH, sizeof(USERSTREAM_FLUSH)-1, 0);
-
- call_result = call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 0, NULL, 0, NULL TSRMLS_CC);
-
- if (call_result == SUCCESS && retval != NULL && zval_is_true(retval))
- call_result = 0;
- else
- call_result = -1;
-
- if (retval)
- zval_ptr_dtor(&retval);
-
- return call_result;
-}
-
-static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
-{
- zval func_name;
- zval *retval = NULL;
- int call_result, ret;
- php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
- zval **args[2];
- zval *zoffs, *zwhence;
-
- assert(us != NULL);
-
- ZVAL_STRINGL(&func_name, USERSTREAM_SEEK, sizeof(USERSTREAM_SEEK)-1, 0);
-
- MAKE_STD_ZVAL(zoffs);
- ZVAL_LONG(zoffs, offset);
- args[0] = &zoffs;
-
- MAKE_STD_ZVAL(zwhence);
- ZVAL_LONG(zwhence, whence);
- args[1] = &zwhence;
-
- call_result = call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 2, args,
- 0, NULL TSRMLS_CC);
-
- zval_ptr_dtor(&zoffs);
- zval_ptr_dtor(&zwhence);
-
- if (call_result == FAILURE) {
- /* stream_seek is not implemented, so disable seeks for this stream */
- stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
- /* there should be no retval to clean up */
-
- if (retval)
- zval_ptr_dtor(&retval);
-
- return -1;
- } else if (call_result == SUCCESS && retval != NULL && zval_is_true(retval)) {
- ret = 0;
- } else {
- ret = -1;
- }
-
- if (retval) {
- zval_ptr_dtor(&retval);
- retval = NULL;
- }
-
- /* now determine where we are */
- ZVAL_STRINGL(&func_name, USERSTREAM_TELL, sizeof(USERSTREAM_TELL)-1, 0);
-
- call_result = call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 0, NULL, 0, NULL TSRMLS_CC);
-
- if (call_result == SUCCESS && retval != NULL && Z_TYPE_P(retval) == IS_LONG)
- *newoffs = Z_LVAL_P(retval);
- else
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_TELL " is not implemented!",
- us->wrapper->classname);
-
- if (retval)
- zval_ptr_dtor(&retval);
-
- return 0;
-}
-
-
-/* parse the return value from one of the stat functions and store the
- * relevant fields into the statbuf provided */
-static int statbuf_from_array(zval *array, php_stream_statbuf *ssb TSRMLS_DC)
-{
- zval *elem;
-
-#define STAT_PROP_ENTRY(name) \
- if (SUCCESS == zend_hash_find(Z_ARRVAL_P(array), #name, sizeof(#name), (void**)&elem)) { \
- convert_to_long(elem); \
- ssb->sb.st_##name = Z_LVAL_P(elem); \
- }
-
- STAT_PROP_ENTRY(dev);
- STAT_PROP_ENTRY(ino);
- STAT_PROP_ENTRY(mode);
- STAT_PROP_ENTRY(nlink);
- STAT_PROP_ENTRY(uid);
- STAT_PROP_ENTRY(gid);
-#if HAVE_ST_RDEV
- STAT_PROP_ENTRY(rdev);
-#endif
- STAT_PROP_ENTRY(size);
-#if defined(NETWARE) && defined(CLIB_STAT_PATCH)
- STAT_PROP_ENTRY(atime.tv_sec);
- STAT_PROP_ENTRY(mtime.tv_sec);
- STAT_PROP_ENTRY(ctime.tv_sec);
-#else
- STAT_PROP_ENTRY(atime);
- STAT_PROP_ENTRY(mtime);
- STAT_PROP_ENTRY(ctime);
-#endif
-#ifdef HAVE_ST_BLKSIZE
- STAT_PROP_ENTRY(blksize);
-#endif
-#ifdef HAVE_ST_BLOCKS
- STAT_PROP_ENTRY(blocks);
-#endif
-
-#undef STAT_PROP_ENTRY
- return SUCCESS;
-}
-
-static int php_userstreamop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)
-{
- zval func_name;
- zval *retval = NULL;
- int call_result;
- php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
- int ret = -1;
-
- ZVAL_STRINGL(&func_name, USERSTREAM_STAT, sizeof(USERSTREAM_STAT)-1, 0);
-
- call_result = call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 0, NULL, 0, NULL TSRMLS_CC);
-
- if (call_result == SUCCESS && retval != NULL && Z_TYPE_P(retval) == IS_ARRAY) {
- if (SUCCESS == statbuf_from_array(retval, ssb TSRMLS_CC))
- ret = 0;
- } else {
- if (call_result == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_STAT " is not implemented!",
- us->wrapper->classname);
- }
- }
-
- if (retval)
- zval_ptr_dtor(&retval);
-
- return ret;
-}
-
-static int user_wrapper_stat_url(php_stream_wrapper *wrapper, char *url, php_stream_statbuf *ssb TSRMLS_DC)
-{
- struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract;
- zval *zfilename, *zfuncname, *zretval;
- zval **args[1];
- int call_result;
- zval *object;
- int ret = -1;
-
- /* create an instance of our class */
- ALLOC_ZVAL(object);
- object_init_ex(object, uwrap->ce);
- ZVAL_REFCOUNT(object) = 1;
- PZVAL_IS_REF(object) = 1;
-
- /* call the stat_url method */
-
- /* call it's stream_open method - set up params first */
- MAKE_STD_ZVAL(zfilename);
- ZVAL_STRING(zfilename, url, 1);
- args[0] = &zfilename;
-
- MAKE_STD_ZVAL(zfuncname);
- ZVAL_STRING(zfuncname, USERSTREAM_STATURL, 1);
-
- call_result = call_user_function_ex(NULL,
- &object,
- zfuncname,
- &zretval,
- 1, args,
- 0, NULL TSRMLS_CC);
-
- if (call_result == SUCCESS && zretval != NULL && Z_TYPE_P(zretval) == IS_ARRAY) {
- /* We got the info we needed */
- if (SUCCESS == statbuf_from_array(zretval, ssb TSRMLS_CC))
- ret = 0;
- } else {
- if (call_result == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_STATURL " is not implemented!",
- uwrap->classname);
- }
- }
-
- /* clean up */
- zval_ptr_dtor(&object);
- if (zretval)
- zval_ptr_dtor(&zretval);
-
- zval_ptr_dtor(&zfuncname);
- zval_ptr_dtor(&zfilename);
-
- return ret;
-
-}
-
-static size_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t count TSRMLS_DC)
-{
- zval func_name;
- zval *retval = NULL;
- int call_result;
- size_t didread = 0;
- php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
- php_stream_dirent *ent = (php_stream_dirent*)buf;
-
- /* avoid problems if someone mis-uses the stream */
- if (count != sizeof(php_stream_dirent))
- return 0;
-
- ZVAL_STRINGL(&func_name, USERSTREAM_DIR_READ, sizeof(USERSTREAM_DIR_READ)-1, 0);
-
- call_result = call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 0, NULL,
- 0, NULL TSRMLS_CC);
-
- if (call_result == SUCCESS && retval != NULL && Z_TYPE_P(retval) != IS_BOOL) {
- convert_to_string(retval);
- PHP_STRLCPY(ent->d_name, Z_STRVAL_P(retval), sizeof(ent->d_name), Z_STRLEN_P(retval));
-
- didread = sizeof(php_stream_dirent);
- } else if (call_result == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_DIR_READ " is not implemented!",
- us->wrapper->classname);
- }
-
- if (retval)
- zval_ptr_dtor(&retval);
-
- return didread;
-}
-
-static int php_userstreamop_closedir(php_stream *stream, int close_handle TSRMLS_DC)
-{
- zval func_name;
- zval *retval = NULL;
- php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
-
- assert(us != NULL);
-
- ZVAL_STRINGL(&func_name, USERSTREAM_DIR_CLOSE, sizeof(USERSTREAM_DIR_CLOSE)-1, 0);
-
- call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 0, NULL, 0, NULL TSRMLS_CC);
-
- if (retval)
- zval_ptr_dtor(&retval);
-
- zval_ptr_dtor(&us->object);
-
- efree(us);
-
- return 0;
-}
-
-static int php_userstreamop_rewinddir(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
-{
- zval func_name;
- zval *retval = NULL;
- php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
-
- ZVAL_STRINGL(&func_name, USERSTREAM_DIR_REWIND, sizeof(USERSTREAM_DIR_REWIND)-1, 0);
-
- call_user_function_ex(NULL,
- &us->object,
- &func_name,
- &retval,
- 0, NULL, 0, NULL TSRMLS_CC);
-
- if (retval)
- zval_ptr_dtor(&retval);
-
- return 0;
-
-}
-
-php_stream_ops php_stream_userspace_ops = {
- php_userstreamop_write, php_userstreamop_read,
- php_userstreamop_close, php_userstreamop_flush,
- "user-space",
- php_userstreamop_seek,
- NULL, /* cast */
- php_userstreamop_stat, /* stat */
- NULL /* set_option */
-};
-
-php_stream_ops php_stream_userspace_dir_ops = {
- NULL, /* write */
- php_userstreamop_readdir,
- php_userstreamop_closedir,
- NULL, /* flush */
- "user-space-dir",
- php_userstreamop_rewinddir,
- NULL, /* cast */
- NULL, /* stat */
- NULL /* set_option */
-};
-
-
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
deleted file mode 100644
index 01861701e8..0000000000
--- a/main/streams/xp_socket.c
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php.h"
-#include "ext/standard/file.h"
-#include "streams/php_streams_int.h"
-#include "php_network.h"
-
-#if defined(AF_UNIX)
-#include <sys/un.h>
-#endif
-
-
-static int php_tcp_sockop_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC);
-
-/* {{{ Generic socket stream operations */
-static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
-{
- php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- size_t didwrite;
-
- if (sock->socket == -1) {
- return 0;
- }
-
- didwrite = send(sock->socket, buf, count, 0);
-
- if (didwrite <= 0) {
- char *estr = php_socket_strerror(php_socket_errno(), NULL, 0);
-
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "send of %d bytes failed with errno=%d %s",
- count, php_socket_errno(), estr);
- efree(estr);
- }
-
- if (didwrite > 0) {
- php_stream_notify_progress_increment(stream->context, didwrite, 0);
- }
-
- return didwrite;
-}
-
-static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data_t *sock TSRMLS_DC)
-{
- fd_set fdr, tfdr;
- int retval;
- struct timeval timeout, *ptimeout;
-
- if (sock->socket == -1) {
- return;
- }
-
- FD_ZERO(&fdr);
- FD_SET(sock->socket, &fdr);
- sock->timeout_event = 0;
-
- if (sock->timeout.tv_sec == -1)
- ptimeout = NULL;
- else
- ptimeout = &timeout;
-
-
- while(1) {
- tfdr = fdr;
- timeout = sock->timeout;
-
- retval = select(sock->socket + 1, &tfdr, NULL, NULL, ptimeout);
-
- if (retval == 0)
- sock->timeout_event = 1;
-
- if (retval >= 0)
- break;
- }
-}
-
-static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
-{
- php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- int nr_bytes = 0;
-
- if (sock->socket == -1) {
- return 0;
- }
-
- if (sock->is_blocked) {
- php_sock_stream_wait_for_data(stream, sock TSRMLS_CC);
- if (sock->timeout_event)
- return 0;
- }
-
- nr_bytes = recv(sock->socket, buf, count, 0);
-
- if (nr_bytes == 0 || (nr_bytes == -1 && php_socket_errno() != EWOULDBLOCK)) {
- stream->eof = 1;
- }
-
- if (nr_bytes > 0)
- php_stream_notify_progress_increment(stream->context, nr_bytes, 0);
-
- return nr_bytes;
-}
-
-
-static int php_sockop_close(php_stream *stream, int close_handle TSRMLS_DC)
-{
- php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- fd_set wrfds, efds;
- int n;
- struct timeval timeout;
-
- if (close_handle) {
-
- if (sock->socket != -1) {
- /* prevent more data from coming in */
- shutdown(sock->socket, SHUT_RD);
-
- /* try to make sure that the OS sends all data before we close the connection.
- * Essentially, we are waiting for the socket to become writeable, which means
- * that all pending data has been sent.
- * We use a small timeout which should encourage the OS to send the data,
- * but at the same time avoid hanging indefintely.
- * */
- do {
- FD_ZERO(&wrfds);
- FD_SET(sock->socket, &wrfds);
- efds = wrfds;
-
- timeout.tv_sec = 0;
- timeout.tv_usec = 5000; /* arbitrary */
-
- n = select(sock->socket + 1, NULL, &wrfds, &efds, &timeout);
- } while (n == -1 && php_socket_errno() == EINTR);
-
- closesocket(sock->socket);
- sock->socket = -1;
- }
-
- }
-
- pefree(sock, php_stream_is_persistent(stream));
-
- return 0;
-}
-
-static int php_sockop_flush(php_stream *stream TSRMLS_DC)
-{
- php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- return fsync(sock->socket);
-}
-
-static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)
-{
- php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- return fstat(sock->socket, &ssb->sb);
-}
-
-static int php_sockop_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC)
-{
- int oldmode;
- php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- php_stream_xport_param *xparam;
-
- switch(option) {
- case PHP_STREAM_OPTION_BLOCKING:
-
- oldmode = sock->is_blocked;
-
- /* no need to change anything */
- if (value == oldmode)
- return oldmode;
-
- if (SUCCESS == php_set_sock_blocking(sock->socket, value TSRMLS_CC)) {
- sock->is_blocked = value;
- return oldmode;
- }
-
- return PHP_STREAM_OPTION_RETURN_ERR;
-
- case PHP_STREAM_OPTION_READ_TIMEOUT:
- sock->timeout = *(struct timeval*)ptrparam;
- sock->timeout_event = 0;
- return PHP_STREAM_OPTION_RETURN_OK;
-
- case PHP_STREAM_OPTION_XPORT_API:
- xparam = (php_stream_xport_param *)ptrparam;
-
- switch (xparam->op) {
- case STREAM_XPORT_OP_LISTEN:
- xparam->outputs.returncode = listen(sock->socket, 5);
- return PHP_STREAM_OPTION_RETURN_OK;
-
- default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
- }
-
- default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
- }
-}
-
-static int php_sockop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
-{
- php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
-
- switch(castas) {
- case PHP_STREAM_AS_STDIO:
- if (ret) {
- *ret = fdopen(sock->socket, stream->mode);
- if (*ret)
- return SUCCESS;
- return FAILURE;
- }
- return SUCCESS;
- case PHP_STREAM_AS_FD:
- case PHP_STREAM_AS_SOCKETD:
- if (ret)
- *ret = (void*)sock->socket;
- return SUCCESS;
- default:
- return FAILURE;
- }
-}
-/* }}} */
-
-/* These may look identical, but we need them this way so that
- * we can determine which type of socket we are dealing with
- * by inspecting stream->ops.
- * A "useful" side-effect is that the user's scripts can then
- * make similar decisions using stream_get_meta_data.
- * */
-php_stream_ops php_stream_generic_socket_ops = {
- php_sockop_write, php_sockop_read,
- php_sockop_close, php_sockop_flush,
- "generic_socket",
- NULL, /* seek */
- php_sockop_cast,
- php_sockop_stat,
- php_sockop_set_option,
-};
-
-
-php_stream_ops php_stream_socket_ops = {
- php_sockop_write, php_sockop_read,
- php_sockop_close, php_sockop_flush,
- "tcp_socket",
- NULL, /* seek */
- php_sockop_cast,
- php_sockop_stat,
- php_tcp_sockop_set_option,
-};
-
-php_stream_ops php_stream_udp_socket_ops = {
- php_sockop_write, php_sockop_read,
- php_sockop_close, php_sockop_flush,
- "udp_socket",
- NULL, /* seek */
- php_sockop_cast,
- php_sockop_stat,
- php_tcp_sockop_set_option,
-};
-
-#ifdef AF_UNIX
-php_stream_ops php_stream_unix_socket_ops = {
- php_sockop_write, php_sockop_read,
- php_sockop_close, php_sockop_flush,
- "unix_socket",
- NULL, /* seek */
- php_sockop_cast,
- php_sockop_stat,
- php_tcp_sockop_set_option,
-};
-php_stream_ops php_stream_unixdg_socket_ops = {
- php_sockop_write, php_sockop_read,
- php_sockop_close, php_sockop_flush,
- "udg_socket",
- NULL, /* seek */
- php_sockop_cast,
- php_sockop_stat,
- php_tcp_sockop_set_option,
-};
-#endif
-
-
-/* network socket operations */
-
-static inline int php_tcp_sockop_bind(php_stream *stream, php_netstream_data_t *sock,
- php_stream_xport_param *xparam TSRMLS_DC)
-{
-
- return -1;
-}
-
-static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_t *sock,
- php_stream_xport_param *xparam TSRMLS_DC)
-{
- char *colon;
- char *host = NULL;
- int portno, err;
- int ret;
-
-#ifdef AF_UNIX
- if (stream->ops == &php_stream_unix_socket_ops || stream->ops == &php_stream_unixdg_socket_ops) {
- struct sockaddr_un unix_addr;
-
- sock->socket = socket(PF_UNIX, stream->ops == &php_stream_unix_socket_ops ? SOCK_STREAM : SOCK_DGRAM, 0);
-
- if (sock->socket == SOCK_ERR) {
- if (xparam->want_errortext) {
- spprintf(&xparam->outputs.error_text, 0, "Failed to create unix socket");
- }
- return -1;
- }
-
- memset(&unix_addr, 0, sizeof(unix_addr));
- unix_addr.sun_family = AF_UNIX;
-
- /* we need to be binary safe on systems that support an abstract
- * namespace */
- if (xparam->inputs.namelen >= sizeof(unix_addr.sun_path)) {
- /* On linux, when the path begins with a NUL byte we are
- * referring to an abstract namespace. In theory we should
- * allow an extra byte below, since we don't need the NULL.
- * BUT, to get into this branch of code, the name is too long,
- * so we don't care. */
- xparam->inputs.namelen = sizeof(unix_addr.sun_path) - 1;
- }
-
- memcpy(unix_addr.sun_path, xparam->inputs.name, xparam->inputs.namelen);
-
- ret = php_network_connect_socket(sock->socket,
- (const struct sockaddr *)&unix_addr, sizeof(unix_addr),
- xparam->op == STREAM_XPORT_OP_CONNECT_ASYNC, xparam->inputs.timeout,
- xparam->want_errortext ? &xparam->outputs.error_text : NULL,
- &err);
-
- xparam->outputs.error_code = err;
-
- goto out;
- }
-#endif
-
- colon = memchr(xparam->inputs.name, ':', xparam->inputs.namelen);
- if (colon) {
- portno = atoi(colon + 1);
- host = estrndup(xparam->inputs.name, colon - xparam->inputs.name);
- } else {
- if (xparam->want_errortext) {
- spprintf(&xparam->outputs.error_text, 0, "Failed to parse address \"%s\"", xparam->inputs.name);
- }
- return -1;
- }
-
- /* Note: the test here for php_stream_udp_socket_ops is important, because we
- * want the default to be TCP sockets so that the openssl extension can
- * re-use this code. */
-
- sock->socket = php_network_connect_socket_to_host(host, portno,
- stream->ops == &php_stream_udp_socket_ops ? SOCK_DGRAM : SOCK_STREAM,
- xparam->op == STREAM_XPORT_OP_CONNECT_ASYNC,
- xparam->inputs.timeout, xparam->want_errortext ? &xparam->outputs.error_text : NULL,
- &err
- TSRMLS_CC);
-
- ret = sock->socket == -1 ? -1 : 0;
- xparam->outputs.error_code = err;
-
- if (host) {
- efree(host);
- }
-
-#ifdef AF_UNIX
-out:
-#endif
-
- if (ret >= 0 && xparam->op == STREAM_XPORT_OP_CONNECT_ASYNC && err == EINPROGRESS) {
- /* indicates pending connection */
- return 1;
- }
-
- return ret;
-}
-
-static inline int php_tcp_sockop_accept(php_stream *stream, php_netstream_data_t *sock,
- php_stream_xport_param *xparam TSRMLS_DC)
-{
- return -1;
-}
-
-static int php_tcp_sockop_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC)
-{
- php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- php_stream_xport_param *xparam;
-
- switch(option) {
- case PHP_STREAM_OPTION_XPORT_API:
- xparam = (php_stream_xport_param *)ptrparam;
-
- switch(xparam->op) {
- case STREAM_XPORT_OP_CONNECT:
- case STREAM_XPORT_OP_CONNECT_ASYNC:
- xparam->outputs.returncode = php_tcp_sockop_connect(stream, sock, xparam TSRMLS_CC);
- return PHP_STREAM_OPTION_RETURN_OK;
-
- case STREAM_XPORT_OP_BIND:
- xparam->outputs.returncode = php_tcp_sockop_bind(stream, sock, xparam TSRMLS_CC);
- return PHP_STREAM_OPTION_RETURN_OK;
-
-
- case STREAM_XPORT_OP_ACCEPT:
- xparam->outputs.returncode = php_tcp_sockop_accept(stream, sock, xparam TSRMLS_CC);
- return PHP_STREAM_OPTION_RETURN_OK;
- default:
- /* fall through */
- }
-
- /* fall through */
- default:
- return php_sockop_set_option(stream, option, value, ptrparam TSRMLS_CC);
- }
-}
-
-
-PHPAPI php_stream *php_stream_generic_socket_factory(const char *proto, long protolen,
- char *resourcename, long resourcenamelen,
- const char *persistent_id, int options, int flags,
- struct timeval *timeout,
- php_stream_context *context STREAMS_DC TSRMLS_DC)
-{
- php_stream *stream = NULL;
- php_netstream_data_t *sock;
- php_stream_ops *ops;
-
- /* which type of socket ? */
- if (strncmp(proto, "tcp", protolen) == 0) {
- ops = &php_stream_socket_ops;
- } else if (strncmp(proto, "udp", protolen) == 0) {
- ops = &php_stream_udp_socket_ops;
- }
-#ifdef AF_UNIX
- else if (strncmp(proto, "unix", protolen) == 0) {
- ops = &php_stream_unix_socket_ops;
- } else if (strncmp(proto, "udg", protolen) == 0) {
- ops = &php_stream_unixdg_socket_ops;
- }
-#endif
- else {
- /* should never happen */
- return NULL;
- }
-
- sock = pemalloc(sizeof(php_netstream_data_t), persistent_id ? 1 : 0);
- memset(sock, 0, sizeof(php_netstream_data_t));
-
- sock->is_blocked = 1;
- sock->timeout.tv_sec = FG(default_socket_timeout);
- sock->timeout.tv_usec = 0;
-
- /* we don't know the socket until we have determined if we are binding or
- * connecting */
- sock->socket = -1;
-
- stream = php_stream_alloc_rel(ops, sock, persistent_id, "r+");
-
- if (stream == NULL) {
- pefree(sock, persistent_id ? 1 : 0);
- return NULL;
- }
-
- if (flags == 0) {
- return stream;
- }
-
- return stream;
-}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/strlcat.c b/main/strlcat.c
deleted file mode 100644
index f3e8f70e3e..0000000000
--- a/main/strlcat.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/strlcpy.c b/main/strlcpy.c
deleted file mode 100644
index 89ff7ba505..0000000000
--- a/main/strlcpy.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#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 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/win95nt.h b/main/win95nt.h
deleted file mode 100644
index b6a0f9bd9f..0000000000
--- a/main/win95nt.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-/* 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
-#ifndef S_ISREG
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#endif
-#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 off_t _off_t
-typedef unsigned int uint;
-typedef unsigned long ulong;
-#if !NSAPI
-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 !defined(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