cvs: php4 /ext/exif exif.c /ext/ftp php_ftp.c /ext/gd gd.c /ext/mailparse mailparse.c /ext/ming ming.c /ext/pgsql pgsql.c /ext/standard
basic_functions.c ftp_fopen_wrapper.c http_fopen_wrapper.c image.c php_fopen_wrapper.c php_fopen_wrappers.h /ext/zlib php_zlib.h zlib.c
zlib_fopen_wrapper.c /main main.c network.c php_network.h php_streams.h streams.c

From: Date: Sun, 17 Mar 2002 22:50:59 +0000
Subject: cvs: php4 /ext/exif exif.c /ext/ftp php_ftp.c /ext/gd gd.c /ext/mailparse mailparse.c /ext/ming ming.c /ext/pgsql pgsql.c /ext/standard
basic_functions.c ftp_fopen_wrapper.c http_fopen_wrapper.c image.c php_fopen_wrapper.c php_fopen_wrappers.h /ext/zlib php_zlib.h zlib.c
zlib_fopen_wrapper.c /main main.c network.c php_network.h php_streams.h streams.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10306@lists.php.net to get a copy of this message
wez Sun Mar 17 17:50:59 2002 EDT Modified files: /php4/ext/exif exif.c /php4/ext/ftp php_ftp.c /php4/ext/gd gd.c /php4/ext/mailparse mailparse.c /php4/ext/ming ming.c /php4/ext/pgsql pgsql.c /php4/ext/standard basic_functions.c ftp_fopen_wrapper.c http_fopen_wrapper.c image.c php_fopen_wrapper.c php_fopen_wrappers.h /php4/ext/zlib php_zlib.h zlib.c zlib_fopen_wrapper.c /php4/main main.c network.c php_network.h php_streams.h streams.c Log: Streams now make more use of the memory manager, so tracking down leaking streams should be easier. # I hate these big commits

Index: php4/ext/exif/exif.c diff -u php4/ext/exif/exif.c:1.66 php4/ext/exif/exif.c:1.67 --- php4/ext/exif/exif.c:1.66 Sun Mar 17 07:16:29 2002 +++ php4/ext/exif/exif.c Sun Mar 17 17:50:54 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: exif.c,v 1.66 2002/03/17 12:16:29 helly Exp $ */ +/* $Id: exif.c,v 1.67 2002/03/17 22:50:54 wez Exp $ */ /* ToDos * @@ -113,7 +113,7 @@ }; /* }}} */ -#define EXIF_VERSION "1.3 $Id: exif.c,v 1.66 2002/03/17 12:16:29 helly Exp $" +#define EXIF_VERSION "1.3 $Id: exif.c,v 1.67 2002/03/17 22:50:54 wez Exp $" PHP_MINFO_FUNCTION(exif); @@ -2960,7 +2960,7 @@ ImageInfo->motorola_intel = 0; #ifdef HAVE_PHP_STREAM - ImageInfo->infile = php_stream_open_wrapper(FileName, "rb", IGNORE_PATH|ENFORCE_SAFE_MODE, NULL TSRMLS_CC); + ImageInfo->infile = php_stream_open_wrapper(FileName, "rb", IGNORE_PATH|ENFORCE_SAFE_MODE, NULL); #else ImageInfo->infile = VCWD_FOPEN(FileName, "rb"); /* Unix ignores 'b', windows needs it. */ #endif @@ -3264,7 +3264,7 @@ if (zend_get_parameters_ex(1, &arg1) == FAILURE) WRONG_PARAM_COUNT; - stream = php_stream_open_wrapper(Z_STRVAL_PP(arg1), "rb", IGNORE_PATH|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL TSRMLS_CC); + stream = php_stream_open_wrapper(Z_STRVAL_PP(arg1), "rb", IGNORE_PATH|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL); if (stream == NULL) { RETURN_FALSE; Index: php4/ext/ftp/php_ftp.c diff -u php4/ext/ftp/php_ftp.c:1.56 php4/ext/ftp/php_ftp.c:1.57 --- php4/ext/ftp/php_ftp.c:1.56 Fri Mar 15 21:48:35 2002 +++ php4/ext/ftp/php_ftp.c Sun Mar 17 17:50:55 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ftp.c,v 1.56 2002/03/16 02:48:35 wez Exp $ */ +/* $Id: php_ftp.c,v 1.57 2002/03/17 22:50:55 wez Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -480,7 +480,7 @@ RETURN_FALSE; } - outstream = php_stream_fopen(local, "wb", NULL TSRMLS_CC); + outstream = php_stream_fopen(local, "wb", NULL); if (outstream == NULL) { php_stream_close(tmpstream); @@ -547,7 +547,7 @@ ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); XTYPE(xtype, mode); - instream = php_stream_fopen(local, "rb", NULL TSRMLS_CC); + instream = php_stream_fopen(local, "rb", NULL); if (instream == NULL) { RETURN_FALSE; Index: php4/ext/gd/gd.c diff -u php4/ext/gd/gd.c:1.182 php4/ext/gd/gd.c:1.183 --- php4/ext/gd/gd.c:1.182 Sat Mar 16 08:48:57 2002 +++ php4/ext/gd/gd.c Sun Mar 17 17:50:55 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd.c,v 1.182 2002/03/16 13:48:57 wez Exp $ */ +/* $Id: gd.c,v 1.183 2002/03/17 22:50:55 wez Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -449,7 +449,7 @@ convert_to_string_ex(file); - stream = php_stream_open_wrapper(Z_STRVAL_PP(file), "rb", IGNORE_PATH|IGNORE_URL_WIN|REPORT_ERRORS, NULL TSRMLS_CC); + stream = php_stream_open_wrapper(Z_STRVAL_PP(file), "rb", IGNORE_PATH|IGNORE_URL_WIN|REPORT_ERRORS, NULL); if (stream == NULL) { RETURN_FALSE; } @@ -1150,7 +1150,7 @@ fn = Z_STRVAL_PP(file); - stream = php_stream_open_wrapper(fn, "rb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL TSRMLS_CC); + stream = php_stream_open_wrapper(fn, "rb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL); if (stream == NULL) { RETURN_FALSE; } Index: php4/ext/mailparse/mailparse.c diff -u php4/ext/mailparse/mailparse.c:1.21 php4/ext/mailparse/mailparse.c:1.22 --- php4/ext/mailparse/mailparse.c:1.21 Sat Mar 16 17:19:09 2002 +++ php4/ext/mailparse/mailparse.c Sun Mar 17 17:50:55 2002 @@ -17,7 +17,7 @@ | the support routines for this extension were based upon. | +----------------------------------------------------------------------+ */ -/* $Id: mailparse.c,v 1.21 2002/03/16 22:19:09 mfischer Exp $ */ +/* $Id: mailparse.c,v 1.22 2002/03/17 22:50:55 wez Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -193,7 +193,7 @@ instream = (php_stream*)zend_fetch_resource(&file TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream()); ZEND_VERIFY_RESOURCE(instream); - outstream = php_stream_fopen_temporary_file(NULL, "mailparse", &outpath TSRMLS_CC); + outstream = php_stream_fopen_temporary_file(NULL, "mailparse", &outpath); if (outstream == NULL) { zend_error(E_WARNING, "%s(): unable to open temp file", get_active_function_name(TSRMLS_C)); RETURN_FALSE; @@ -232,7 +232,7 @@ add_assoc_string(item, "origfilename", origfilename, 1); /* create a temp file for the data */ - partstream = php_stream_fopen_temporary_file(NULL, "mailparse", &outpath TSRMLS_CC); + partstream = php_stream_fopen_temporary_file(NULL, "mailparse", &outpath); if (partstream) { nparts++; add_assoc_string(item, "filename", outpath, 0); Index: php4/ext/ming/ming.c diff -u php4/ext/ming/ming.c:1.31 php4/ext/ming/ming.c:1.32 --- php4/ext/ming/ming.c:1.31 Sat Mar 16 20:58:41 2002 +++ php4/ext/ming/ming.c Sun Mar 17 17:50:55 2002 @@ -1157,7 +1157,7 @@ php_stream * stream; FILE * file; - stream = php_stream_open_wrapper(Z_STRVAL_PP(zfile), "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL TSRMLS_CC); + stream = php_stream_open_wrapper(Z_STRVAL_PP(zfile), "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); if(stream == NULL) { RETURN_FALSE; @@ -1602,7 +1602,7 @@ convert_to_string_ex(x); - stream = php_stream_open_wrapper(Z_STRVAL_PP(x), "wb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL TSRMLS_CC); + stream = php_stream_open_wrapper(Z_STRVAL_PP(x), "wb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); if (stream == NULL) RETURN_FALSE; Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.157 php4/ext/pgsql/pgsql.c:1.158 --- php4/ext/pgsql/pgsql.c:1.157 Fri Mar 15 20:27:45 2002 +++ php4/ext/pgsql/pgsql.c Sun Mar 17 17:50:56 2002 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.157 2002/03/16 01:27:45 wez Exp $ */ +/* $Id: pgsql.c,v 1.158 2002/03/17 22:50:56 wez Exp $ */ #include <stdlib.h> @@ -1468,7 +1468,7 @@ ZEND_FETCH_RESOURCE2(pgsql, PGconn *, z_pgsql_link, id, "PostgreSQL link", le_link, le_plink); convert_to_string_ex(z_filename); - stream = php_stream_open_wrapper(Z_STRVAL_PP(z_filename), mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL TSRMLS_CC); + stream = php_stream_open_wrapper(Z_STRVAL_PP(z_filename), mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL); if (!stream) { RETURN_FALSE; Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.453 php4/ext/standard/basic_functions.c:1.454 --- php4/ext/standard/basic_functions.c:1.453 Sun Mar 17 15:56:20 2002 +++ php4/ext/standard/basic_functions.c Sun Mar 17 17:50:56 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.453 2002/03/17 20:56:20 sesser Exp $ */ +/* $Id: basic_functions.c,v 1.454 2002/03/17 22:50:56 wez Exp $ */ #include "php.h" #include "php_streams.h" @@ -1005,14 +1005,14 @@ if (PG(allow_url_fopen)) { - if (FAILURE == php_register_url_stream_wrapper("http", &php_stream_http_wrapper TSRMLS_CC)) + if (FAILURE == php_register_url_stream_wrapper("http", &php_stream_http_wrapper)) return FAILURE; - if (FAILURE == php_register_url_stream_wrapper("php", &php_stream_php_wrapper TSRMLS_CC)) + if (FAILURE == php_register_url_stream_wrapper("php", &php_stream_php_wrapper)) return FAILURE; - if (FAILURE == php_register_url_stream_wrapper("ftp", &php_stream_ftp_wrapper TSRMLS_CC)) + if (FAILURE == php_register_url_stream_wrapper("ftp", &php_stream_ftp_wrapper)) return FAILURE; # if HAVE_OPENSSL_EXT - if (FAILURE == php_register_url_stream_wrapper("https", &php_stream_http_wrapper TSRMLS_CC)) + if (FAILURE == php_register_url_stream_wrapper("https", &php_stream_http_wrapper)) return FAILURE; # endif } @@ -1030,11 +1030,11 @@ #endif if (PG(allow_url_fopen)) { - php_unregister_url_stream_wrapper("http" TSRMLS_CC); - php_unregister_url_stream_wrapper("ftp" TSRMLS_CC); - php_unregister_url_stream_wrapper("php" TSRMLS_CC); + php_unregister_url_stream_wrapper("http"); + php_unregister_url_stream_wrapper("ftp"); + php_unregister_url_stream_wrapper("php"); # if HAVE_OPENSSL_EXT - php_unregister_url_stream_wrapper("https" TSRMLS_CC); + php_unregister_url_stream_wrapper("https"); # endif } @@ -1532,7 +1532,7 @@ break; case 3: /*save to a file */ - stream = php_stream_open_wrapper(opt, "a", IGNORE_URL | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL TSRMLS_CC); + stream = php_stream_open_wrapper(opt, "a", IGNORE_URL | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); if (!stream) return FAILURE; php_stream_write(stream, message, strlen(message)); Index: php4/ext/standard/ftp_fopen_wrapper.c diff -u php4/ext/standard/ftp_fopen_wrapper.c:1.16 php4/ext/standard/ftp_fopen_wrapper.c:1.17 --- php4/ext/standard/ftp_fopen_wrapper.c:1.16 Fri Mar 15 20:34:52 2002 +++ php4/ext/standard/ftp_fopen_wrapper.c Sun Mar 17 17:50:57 2002 @@ -17,7 +17,7 @@ | Hartmut Holzgraefe <hholzgra@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.16 2002/03/16 01:34:52 wez Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.17 2002/03/17 22:50:57 wez Exp $ */ #include "php.h" #include "php_globals.h" @@ -85,7 +85,7 @@ /* {{{ php_fopen_url_wrap_ftp */ -php_stream * php_stream_url_wrap_ftp(char *path, char *mode, int options, char **opened_path TSRMLS_DC) +php_stream * php_stream_url_wrap_ftp(char *path, char *mode, int options, char **opened_path STREAMS_DC) { php_stream *stream=NULL; php_url *resource=NULL; Index: php4/ext/standard/http_fopen_wrapper.c diff -u php4/ext/standard/http_fopen_wrapper.c:1.25 php4/ext/standard/http_fopen_wrapper.c:1.26 --- php4/ext/standard/http_fopen_wrapper.c:1.25 Fri Mar 15 20:34:52 2002 +++ php4/ext/standard/http_fopen_wrapper.c Sun Mar 17 17:50:57 2002 @@ -18,7 +18,7 @@ | Wez Furlong <wez@thebrainroom.com> | +----------------------------------------------------------------------+ */ -/* $Id: http_fopen_wrapper.c,v 1.25 2002/03/16 01:34:52 wez Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.26 2002/03/17 22:50:57 wez Exp $ */ #include "php.h" #include "php_globals.h" @@ -71,7 +71,7 @@ #define HTTP_HEADER_BLOCK_SIZE 1024 -php_stream *php_stream_url_wrap_http(char *path, char *mode, int options, char **opened_path TSRMLS_DC) +php_stream *php_stream_url_wrap_http(char *path, char *mode, int options, char **opened_path STREAMS_DC) { php_stream *stream = NULL; php_url *resource = NULL; @@ -268,7 +268,7 @@ else { strlcpy(new_path, location, sizeof(new_path)); } - stream = php_stream_url_wrap_http(new_path, mode, options, opened_path TSRMLS_CC); + stream = php_stream_url_wrap_http(new_path, mode, options, opened_path STREAMS_CC); if (stream->wrapperdata) { entryp = &entry; MAKE_STD_ZVAL(entry); Index: php4/ext/standard/image.c diff -u php4/ext/standard/image.c:1.50 php4/ext/standard/image.c:1.51 --- php4/ext/standard/image.c:1.50 Sat Mar 16 15:12:58 2002 +++ php4/ext/standard/image.c Sun Mar 17 17:50:57 2002 @@ -16,7 +16,7 @@ | Marcus Boerger <helly@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: image.c,v 1.50 2002/03/16 20:12:58 helly Exp $ */ +/* $Id: image.c,v 1.51 2002/03/17 22:50:57 wez Exp $ */ /* * Based on Daniel Schmitt's imageinfo.c which carried the following * Copyright notice. @@ -717,7 +717,7 @@ break; } - stream = php_stream_open_wrapper(Z_STRVAL_PP(arg1), "rb", REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL TSRMLS_CC); + stream = php_stream_open_wrapper(Z_STRVAL_PP(arg1), "rb", REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL); if (!stream) { RETURN_FALSE; Index: php4/ext/standard/php_fopen_wrapper.c diff -u php4/ext/standard/php_fopen_wrapper.c:1.12 php4/ext/standard/php_fopen_wrapper.c:1.13 --- php4/ext/standard/php_fopen_wrapper.c:1.12 Fri Mar 15 16:03:05 2002 +++ php4/ext/standard/php_fopen_wrapper.c Sun Mar 17 17:50:57 2002 @@ -17,7 +17,7 @@ | Hartmut Holzgraefe <hholzgra@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: php_fopen_wrapper.c,v 1.12 2002/03/15 21:03:05 wez Exp $ */ +/* $Id: php_fopen_wrapper.c,v 1.13 2002/03/17 22:50:57 wez Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -30,7 +30,7 @@ #include "php_standard.h" #include "php_fopen_wrappers.h" -php_stream * php_stream_url_wrap_php(char * path, char * mode, int options, char ** opened_path TSRMLS_DC) +php_stream * php_stream_url_wrap_php(char * path, char * mode, int options, char ** opened_path STREAMS_DC) { FILE * fp = NULL; php_stream * stream = NULL; Index: php4/ext/standard/php_fopen_wrappers.h diff -u php4/ext/standard/php_fopen_wrappers.h:1.8 php4/ext/standard/php_fopen_wrappers.h:1.9 --- php4/ext/standard/php_fopen_wrappers.h:1.8 Fri Mar 15 20:34:52 2002 +++ php4/ext/standard/php_fopen_wrappers.h Sun Mar 17 17:50:57 2002 @@ -18,13 +18,13 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_fopen_wrappers.h,v 1.8 2002/03/16 01:34:52 wez Exp $ */ +/* $Id: php_fopen_wrappers.h,v 1.9 2002/03/17 22:50:57 wez Exp $ */ #ifndef PHP_FOPEN_WRAPPERS_H #define PHP_FOPEN_WRAPPERS_H -php_stream *php_stream_url_wrap_http(char *path, char *mode, int options, char **opened_path TSRMLS_DC); -php_stream *php_stream_url_wrap_ftp(char *path, char *mode, int options, char **opened_path TSRMLS_DC); +php_stream *php_stream_url_wrap_http(char *path, char *mode, int options, char **opened_path STREAMS_DC); +php_stream *php_stream_url_wrap_ftp(char *path, char *mode, int options, char **opened_path STREAMS_DC); php_stream_wrapper php_stream_http_wrapper; php_stream_wrapper php_stream_ftp_wrapper; php_stream_wrapper php_stream_php_wrapper; Index: php4/ext/zlib/php_zlib.h diff -u php4/ext/zlib/php_zlib.h:1.23 php4/ext/zlib/php_zlib.h:1.24 --- php4/ext/zlib/php_zlib.h:1.23 Fri Mar 15 20:37:24 2002 +++ php4/ext/zlib/php_zlib.h Sun Mar 17 17:50:58 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_zlib.h,v 1.23 2002/03/16 01:37:24 wez Exp $ */ +/* $Id: php_zlib.h,v 1.24 2002/03/17 22:50:58 wez Exp $ */ #ifndef PHP_ZLIB_H #define PHP_ZLIB_H @@ -64,10 +64,9 @@ PHP_FUNCTION(gzencode); PHP_FUNCTION(ob_gzhandler); -FILE *zlib_fopen_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path TSRMLS_DC); int php_enable_output_compression(int buffer_size TSRMLS_DC); -php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened_path TSRMLS_DC); +php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened_path STREAMS_DC); extern php_stream_ops php_stream_gzio_ops; extern php_stream_wrapper php_stream_gzip_wrapper; Index: php4/ext/zlib/zlib.c diff -u php4/ext/zlib/zlib.c:1.111 php4/ext/zlib/zlib.c:1.112 --- php4/ext/zlib/zlib.c:1.111 Sat Mar 16 13:42:41 2002 +++ php4/ext/zlib/zlib.c Sun Mar 17 17:50:58 2002 @@ -18,7 +18,7 @@ | Jade Nicoletti <nicoletti@nns.ch> | +----------------------------------------------------------------------+ */ -/* $Id: zlib.c,v 1.111 2002/03/16 18:42:41 wez Exp $ */ +/* $Id: zlib.c,v 1.112 2002/03/17 22:50:58 wez Exp $ */ #define IS_EXT_MODULE #ifdef HAVE_CONFIG_H @@ -188,7 +188,7 @@ le_zp = zend_register_list_destructors_ex(phpi_destructor_gzclose, NULL, "zlib", module_number); if(PG(allow_url_fopen)) { - php_register_url_stream_wrapper("zlib", &php_stream_gzip_wrapper TSRMLS_CC); + php_register_url_stream_wrapper("zlib", &php_stream_gzip_wrapper); } REGISTER_LONG_CONSTANT("FORCE_GZIP", CODING_GZIP, CONST_CS | CONST_PERSISTENT); @@ -255,7 +255,7 @@ php_stream *stream = NULL; int fd; - stream = php_stream_open_wrapper(path, mode, options | REPORT_ERRORS, NULL TSRMLS_CC); + stream = php_stream_open_wrapper(path, mode, options | REPORT_ERRORS, NULL); if (stream) { if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD|PHP_STREAM_CAST_TRY_HARD, (void**)&fd, 1)) { @@ -302,7 +302,7 @@ convert_to_string_ex(filename); /* using a stream here is a bit more efficient (resource wise) than php_gzopen_wrapper */ - stream = php_stream_gzopen(Z_STRVAL_PP(filename), "rb", use_include_path|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL TSRMLS_CC); + stream = php_stream_gzopen(Z_STRVAL_PP(filename), "rb", use_include_path|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL STREAMS_CC); if (stream == NULL) { php_error(E_WARNING,"gzFile(\"%s\") - %s",Z_STRVAL_PP(filename),strerror(errno)); RETURN_FALSE; Index: php4/ext/zlib/zlib_fopen_wrapper.c diff -u php4/ext/zlib/zlib_fopen_wrapper.c:1.13 php4/ext/zlib/zlib_fopen_wrapper.c:1.14 --- php4/ext/zlib/zlib_fopen_wrapper.c:1.13 Sat Mar 16 13:42:42 2002 +++ php4/ext/zlib/zlib_fopen_wrapper.c Sun Mar 17 17:50:58 2002 @@ -15,7 +15,7 @@ | Author: Hartmut Holzgraefe <hartmut@six.de> | +----------------------------------------------------------------------+ */ -/* $Id: zlib_fopen_wrapper.c,v 1.13 2002/03/16 18:42:42 wez Exp $ */ +/* $Id: zlib_fopen_wrapper.c,v 1.14 2002/03/17 22:50:58 wez Exp $ */ #define IS_EXT_MODULE #define _GNU_SOURCE @@ -80,7 +80,7 @@ NULL, "ZLIB" }; -php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened_path TSRMLS_DC) +php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened_path STREAMS_DC) { struct php_gz_stream_data_t *self; php_stream *stream = NULL; @@ -90,7 +90,7 @@ if (strncmp("zlib:", path, 5) == 0) path += 5; - self->stream = php_stream_open_wrapper(path, mode, options, opened_path TSRMLS_CC); + self->stream = php_stream_open_wrapper(path, mode, options, opened_path); if (self->stream) { int fd; Index: php4/main/main.c diff -u php4/main/main.c:1.435 php4/main/main.c:1.436 --- php4/main/main.c:1.435 Sat Mar 16 09:39:51 2002 +++ php4/main/main.c Sun Mar 17 17:50:58 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.435 2002/03/16 14:39:51 wez Exp $ */ +/* $Id: main.c,v 1.436 2002/03/17 22:50:58 wez Exp $ */ /* {{{ includes */ @@ -565,9 +565,8 @@ { FILE *retval = NULL; php_stream *stream; - TSRMLS_FETCH(); - stream = php_stream_open_wrapper((char *)filename, "rb", USE_PATH|IGNORE_URL_WIN|REPORT_ERRORS, opened_path TSRMLS_CC); + stream = php_stream_open_wrapper((char *)filename, "rb", USE_PATH|IGNORE_URL_WIN|REPORT_ERRORS, opened_path); if (stream) { /* no need for us to check the stream type here */ php_stream_sock_set_chunk_size(stream, 1); @@ -952,7 +951,7 @@ /* initialize stream wrappers registry * (this uses configuration parameters from php.ini) */ - if (php_init_stream_wrappers(TSRMLS_C) == FAILURE) { + if (php_init_stream_wrappers() == FAILURE) { php_printf("PHP: Unable to initialize stream url wrappers.\n"); return FAILURE; } @@ -1057,7 +1056,7 @@ zend_shutdown(TSRMLS_C); - php_shutdown_stream_wrappers(TSRMLS_C); + php_shutdown_stream_wrappers(); php_shutdown_info_logos(); UNREGISTER_INI_ENTRIES(); Index: php4/main/network.c diff -u php4/main/network.c:1.37 php4/main/network.c:1.38 --- php4/main/network.c:1.37 Sun Mar 17 08:19:27 2002 +++ php4/main/network.c Sun Mar 17 17:50:59 2002 @@ -15,7 +15,7 @@ | Author: Stig Venaas <venaas@uninett.no> | +----------------------------------------------------------------------+ */ -/* $Id: network.c,v 1.37 2002/03/17 13:19:27 wez Exp $ */ +/* $Id: network.c,v 1.38 2002/03/17 22:50:59 wez Exp $ */ #define PHP_SOCK_CHUNK_SIZE 8192 #define MAX_CHUNKS_PER_READ 10 @@ -413,7 +413,7 @@ } /* }}} */ -PHPAPI php_stream *php_stream_sock_open_from_socket(int socket, int persistent) +PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, int persistent STREAMS_DC) { php_stream *stream; php_netstream_data_t *sock; @@ -426,7 +426,7 @@ sock->timeout.tv_sec = -1; sock->socket = socket; - stream = php_stream_alloc(&php_stream_socket_ops, sock, persistent, "r+"); + stream = php_stream_alloc_rel(&php_stream_socket_ops, sock, persistent, "r+"); if (stream == NULL) pefree(sock, persistent); @@ -434,8 +434,8 @@ return stream; } -PHPAPI php_stream *php_stream_sock_open_host(const char *host, unsigned short port, - int socktype, int timeout, int persistent) +PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short port, + int socktype, int timeout, int persistent STREAMS_DC) { int socket; @@ -444,10 +444,11 @@ if (socket == -1) return NULL; - return php_stream_sock_open_from_socket(socket, persistent); + return php_stream_sock_open_from_socket_rel(socket, persistent); } -PHPAPI php_stream *php_stream_sock_open_unix(const char *path, int pathlen, int persistent, struct timeval *timeout) +PHPAPI php_stream *_php_stream_sock_open_unix(const char *path, int pathlen, int persistent, + struct timeval *timeout STREAMS_DC) { #if defined(AF_UNIX) int socketd; @@ -476,7 +477,7 @@ if (php_connect_nonb(socketd, (struct sockaddr *) &unix_addr, sizeof(unix_addr), timeout) == SOCK_CONN_ERR) return NULL; - return php_stream_sock_open_from_socket(socketd, persistent); + return php_stream_sock_open_from_socket_rel(socketd, persistent); #else return NULL; #endif Index: php4/main/php_network.h diff -u php4/main/php_network.h:1.17 php4/main/php_network.h:1.18 --- php4/main/php_network.h:1.17 Sun Mar 17 08:29:44 2002 +++ php4/main/php_network.h Sun Mar 17 17:50:59 2002 @@ -15,7 +15,7 @@ | Author: Stig Venaas <venaas@uninett.no> | +----------------------------------------------------------------------+ */ -/* $Id: php_network.h,v 1.17 2002/03/17 13:29:44 wez Exp $ */ +/* $Id: php_network.h,v 1.18 2002/03/17 22:50:59 wez Exp $ */ #ifndef _PHP_NETWORK_H #define _PHP_NETWORK_H @@ -112,11 +112,23 @@ extern php_stream_ops php_stream_socket_ops; #define PHP_STREAM_IS_SOCKET (&php_stream_socket_ops) -PHPAPI php_stream *php_stream_sock_open_from_socket(int socket, int persistent); +PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, int persistent STREAMS_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, int timeout, int persistent); -PHPAPI php_stream *php_stream_sock_open_unix(const char *path, int pathlen, int persistent, struct timeval *timeout); +PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short port, + int socktype, int timeout, int persistent STREAMS_DC); +PHPAPI php_stream *_php_stream_sock_open_unix(const char *path, int pathlen, int persistent, + struct timeval *timeout STREAMS_DC); + +#define php_stream_sock_open_from_socket(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_CC) +#define php_stream_sock_open_host(host, port, socktype, timeout, persistent) _php_stream_sock_open_host((host), (port), (socktype), (timeout), (persistent) STREAMS_CC) +#define php_stream_sock_open_unix(path, pathlen, persistent, timeval) _php_stream_sock_open_unix((path), (pathlen), (persistent), (timeval) STREAMS_CC) + +/* {{{ memory debug */ +#define php_stream_sock_open_from_socket_rel(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_REL_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) +#define php_stream_sock_open_unix_rel(path, pathlen, persistent, timeval) _php_stream_sock_open_unix((path), (pathlen), (persistent), (timeval) STREAMS_REL_CC) + +/* }}} */ PHPAPI void php_stream_sock_set_timeout(php_stream *stream, struct timeval *timeout); PHPAPI int php_stream_sock_set_blocking(php_stream *stream, int mode); Index: php4/main/php_streams.h diff -u php4/main/php_streams.h:1.14 php4/main/php_streams.h:1.15 --- php4/main/php_streams.h:1.14 Sun Mar 17 09:21:01 2002 +++ php4/main/php_streams.h Sun Mar 17 17:50:59 2002 @@ -25,6 +25,54 @@ /* See README.STREAMS in php4 root dir for more info about this stuff */ +/* {{{ 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 TSRMLS_DC +# define STREAMS_C 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_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 \ + TSRMLS_CC + +# define STREAMS_DC , STREAMS_D +# define STREAMS_CC , STREAMS_C +# define STREAMS_REL_CC , STREAMS_REL_C +#else +# define STREAMS_D TSRMLS_D +# define STREAMS_C TSRMLS_C +# define STREAMS_REL_C TSRMLS_C +# define STREAMS_DC TSRMLS_DC +# define STREAMS_CC TSRMLS_CC +# define STREAMS_REL_CC TSRMLS_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) + +#define php_stream_copy_to_mem_rel(src, buf, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_REL_CC) + +#define php_stream_fopen_rel(filename, mode, opened) _php_stream_fopen((filename), (mode), (opened) STREAMS_REL_CC) + +#define php_stream_fopen_with_path_rel(filename, mode, path, opened) _php_stream_fopen_with_path((filename), (mode), (path), (opened) STREAMS_REL_CC) + +#define php_stream_fopen_from_file_rel(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_REL_CC) + +#define php_stream_fopen_from_pipe_rel(file, mode) _php_stream_fopen_from_pipe((file), (mode) STREAMS_REL_CC) + +#define php_stream_fopen_tmpfile_rel() _php_stream_fopen_tmpfile(STREAMS_REL_C) + +#define php_stream_fopen_temporary_file_rel(dir, pfx, opened_path) _php_stream_fopen_temporary_file((dir), (pfx), (opened_path) STREAMS_REL_CC) + +#define php_stream_open_wrapper_rel(path, mode, options, opened) _php_stream_open_wrapper((path), (mode), (options), (opened) STREAMS_REL_CC) + +#define php_stream_make_seekable_rel(origstream, newstream) _php_stream_make_seekable(origstream, newstream STREAMS_REL_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, @@ -53,7 +101,7 @@ } php_stream_ops; /* options uses the IGNORE_URL family of defines from fopen_wrappers.h */ -typedef php_stream *(*php_stream_factory_func_t)(char *filename, char *mode, int options, char **opened_path TSRMLS_DC); +typedef php_stream *(*php_stream_factory_func_t)(char *filename, char *mode, int options, char **opened_path STREAMS_DC); typedef void (*php_stream_wrapper_dtor_func_t)(php_stream *stream); typedef struct _php_stream_wrapper { @@ -83,7 +131,9 @@ /* allocate a new stream for a particular ops */ -PHPAPI php_stream *php_stream_alloc(php_stream_ops *ops, void *abstract, int persistent, const char *mode); +PHPAPI php_stream *_php_stream_alloc(php_stream_ops *ops, void *abstract, + int persistent, const char *mode STREAMS_DC); +#define php_stream_alloc(ops, thisptr, persistent, mode) _php_stream_alloc((ops), (thisptr), (persistent), (mode) STREAMS_CC) PHPAPI int php_stream_free(php_stream *stream, int call_dtor); #define php_stream_close(stream) php_stream_free(stream, 1) @@ -107,7 +157,10 @@ PHPAPI size_t php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen); /* 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); +PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen, + int persistent STREAMS_DC); +#define php_stream_copy_to_mem(src, buf, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_CC) + /* maybe implement someday */ #define php_stream_error(stream) (0) @@ -115,12 +168,23 @@ /* operations for a stdio FILE; use the php_stream_fopen_XXX funcs below */ 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 TSRMLS_DC); -PHPAPI php_stream *php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path TSRMLS_DC); -PHPAPI php_stream *php_stream_fopen_from_file(FILE *file, const char *mode); -PHPAPI php_stream *php_stream_fopen_from_pipe(FILE *file, const char *mode); -PHPAPI php_stream *php_stream_fopen_tmpfile(void); -PHPAPI php_stream *php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path TSRMLS_DC); +PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, char **opened_path STREAMS_DC); +#define php_stream_fopen(filename, mode, opened) _php_stream_fopen((filename), (mode), (opened) STREAMS_CC) + +PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path STREAMS_DC); +#define php_stream_fopen_with_path(filename, mode, path, opened) _php_stream_fopen_with_path((filename), (mode), (path), (opened) STREAMS_CC) + +PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC); +#define php_stream_fopen_from_file(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_CC) + +PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STREAMS_DC); +#define php_stream_fopen_from_pipe(file, mode) _php_stream_fopen_from_pipe((file), (mode) STREAMS_CC) + +PHPAPI php_stream *_php_stream_fopen_tmpfile(STREAMS_D); +#define php_stream_fopen_tmpfile() _php_stream_fopen_tmpfile(STREAMS_C) + +PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path STREAMS_DC); +#define php_stream_fopen_temporary_file(dir, pfx, opened_path) _php_stream_fopen_temporary_file((dir), (pfx), (opened_path) STREAMS_CC) /* coerce the stream into some other form */ /* cast as a stdio FILE * */ @@ -163,18 +227,20 @@ # define IGNORE_URL_WIN 0 #endif -int php_init_stream_wrappers(TSRMLS_D); -int php_shutdown_stream_wrappers(TSRMLS_D); -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(char *path, char *mode, int options, char **opened_path TSRMLS_DC); +int php_init_stream_wrappers(void); +int php_shutdown_stream_wrappers(void); +PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper); +PHPAPI int php_unregister_url_stream_wrapper(char *protocol); +PHPAPI php_stream *_php_stream_open_wrapper(char *path, char *mode, int options, char **opened_path STREAMS_DC); +#define php_stream_open_wrapper(path, mode, options, opened) _php_stream_open_wrapper((path), (mode), (options), (opened) STREAMS_CC) #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 */ /* DO NOT call this on streams that are referenced by resources! */ -PHPAPI int php_stream_make_seekable(php_stream *origstream, php_stream **newstream); +PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream STREAMS_DC); +#define php_stream_make_seekable(origstream, newstream) _php_stream_make_seekable(origstream, newstream STREAMS_CC) #endif Index: php4/main/streams.c diff -u php4/main/streams.c:1.26 php4/main/streams.c:1.27 --- php4/main/streams.c:1.26 Sun Mar 17 09:21:01 2002 +++ php4/main/streams.c Sun Mar 17 17:50:59 2002 @@ -42,14 +42,35 @@ #include "build-defs.h" #endif +#if ZEND_DEBUG +/* some macros to help track leaks */ +#define emalloc_rel_orig(size) \ + ( __php_stream_call_depth == 0 \ + ? _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_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_ORIG_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 + static HashTable url_stream_wrappers_hash; /* allocate a new stream for a particular ops */ -PHPAPI php_stream *php_stream_alloc(php_stream_ops *ops, void *abstract, int persistent, const char *mode) /* {{{ */ +PHPAPI php_stream *_php_stream_alloc(php_stream_ops *ops, void *abstract, int persistent, const char *mode STREAMS_DC) /* {{{ */ { php_stream *ret; - - ret = (php_stream*) pemalloc(sizeof(php_stream), persistent); + + ret = (php_stream*) pemalloc_rel_orig(sizeof(php_stream), persistent); memset(ret, 0, sizeof(php_stream)); @@ -232,7 +253,7 @@ return -1; } -PHPAPI size_t php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen, int persistent) +PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen, int persistent STREAMS_DC) { size_t ret = 0; char *ptr; @@ -272,7 +293,7 @@ srcfile = mmap(NULL, maxlen, PROT_READ, MAP_SHARED, srcfd, 0); if (srcfile != (void*)MAP_FAILED) { - *buf = pemalloc(persistent, maxlen); + *buf = pemalloc_rel_orig(persistent, maxlen); if (*buf) { memcpy(*buf, srcfile, maxlen); @@ -287,19 +308,19 @@ } #endif - ptr = *buf = pemalloc(persistent, step); + ptr = *buf = pemalloc_rel_orig(persistent, step); max_len = step; while((ret = php_stream_read(src, ptr, max_len - len))) { len += ret; if (len + min_room >= max_len) { - *buf = perealloc(*buf, max_len + step, persistent); + *buf = perealloc_rel_orig(*buf, max_len + step, persistent); max_len += step; ptr = *buf + len; } } if (len) { - *buf = perealloc(*buf, len, persistent); + *buf = perealloc_rel_orig(*buf, len, persistent); } else { pefree(*buf, persistent); *buf = NULL; @@ -406,12 +427,12 @@ #endif } php_stdio_stream_data; -PHPAPI php_stream *php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path TSRMLS_DC) +PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path STREAMS_DC) { FILE *fp = php_open_temporary_file(dir, pfx, opened_path TSRMLS_CC); if (fp) { - php_stream *stream = php_stream_fopen_from_file(fp, "wb"); + php_stream *stream = php_stream_fopen_from_file_rel(fp, "wb"); if (stream) { return stream; } @@ -424,7 +445,7 @@ return NULL; } -PHPAPI php_stream *php_stream_fopen_tmpfile(void) +PHPAPI php_stream *_php_stream_fopen_tmpfile(STREAMS_D) { FILE *fp; php_stream *stream; @@ -434,7 +455,7 @@ zend_error(E_WARNING, "tmpfile(): %s", strerror(errno)); return NULL; } - stream = php_stream_fopen_from_file(fp, "r+"); + stream = php_stream_fopen_from_file_rel(fp, "r+"); if (stream == NULL) { zend_error(E_WARNING, "tmpfile(): %s", strerror(errno)); fclose(fp); @@ -445,24 +466,24 @@ -PHPAPI php_stream *php_stream_fopen_from_file(FILE *file, const char *mode) +PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC) { php_stdio_stream_data *self; - self = emalloc(sizeof(*self)); + self = emalloc_rel_orig(sizeof(*self)); self->file = file; self->is_pipe = 0; - return php_stream_alloc(&php_stream_stdio_ops, self, 0, mode); + return php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode); } -PHPAPI php_stream *php_stream_fopen_from_pipe(FILE *file, const char *mode) +PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STREAMS_DC) { php_stdio_stream_data *self; - self = emalloc(sizeof(*self)); + self = emalloc_rel_orig(sizeof(*self)); self->file = file; self->is_pipe = 1; - return php_stream_alloc(&php_stream_stdio_ops, self, 0, mode); + return php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode); } static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count) { @@ -595,7 +616,7 @@ "STDIO" }; -PHPAPI php_stream *php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path TSRMLS_DC) /* {{{ */ +PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path STREAMS_DC) /* {{{ */ { /* code ripped off from fopen_wrappers.c */ char *pathbuf, *ptr, *end; @@ -622,7 +643,7 @@ if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) { return NULL; } - return php_stream_fopen(filename, mode, opened_path TSRMLS_CC); + return php_stream_fopen_rel(filename, mode, opened_path TSRMLS_CC); } /* @@ -634,19 +655,19 @@ 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_stream_fopen(filename, mode, opened_path TSRMLS_CC); + return php_stream_fopen_rel(filename, mode, opened_path); if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) return NULL; - return php_stream_fopen(filename, mode, opened_path TSRMLS_CC); + return php_stream_fopen_rel(filename, mode, opened_path); } if (!path || (path && !*path)) { if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) { return NULL; } - return php_stream_fopen(filename, mode, opened_path TSRMLS_CC); + return php_stream_fopen_rel(filename, mode, opened_path); } /* check in provided path */ @@ -689,7 +710,7 @@ 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(trypath, mode, opened_path TSRMLS_CC); + stream = php_stream_fopen_rel(trypath, mode, opened_path); } else { stream = NULL; } @@ -698,7 +719,7 @@ return stream; } } - stream = php_stream_fopen(trypath, mode, opened_path TSRMLS_CC); + stream = php_stream_fopen_rel(trypath, mode, opened_path); if (stream) { efree(pathbuf); return stream; @@ -712,7 +733,7 @@ } /* }}} */ -PHPAPI php_stream *php_stream_fopen(const char *filename, const char *mode, char **opened_path TSRMLS_DC) +PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, char **opened_path STREAMS_DC) { FILE *fp; char *realpath = NULL; @@ -722,7 +743,7 @@ fp = fopen(realpath, mode); if (fp) { - php_stream *ret = php_stream_fopen_from_file(fp, mode); + php_stream *ret = php_stream_fopen_from_file_rel(fp, mode); if (ret) { if (opened_path) { @@ -860,34 +881,34 @@ } /* }}} */ -int php_init_stream_wrappers(TSRMLS_D) +int php_init_stream_wrappers(void) { if (PG(allow_url_fopen)) return zend_hash_init(&url_stream_wrappers_hash, 0, NULL, NULL, 1); return SUCCESS; } -int php_shutdown_stream_wrappers(TSRMLS_D) +int php_shutdown_stream_wrappers(void) { if (PG(allow_url_fopen)) zend_hash_destroy(&url_stream_wrappers_hash); return SUCCESS; } -PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC) +PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper) { if (PG(allow_url_fopen)) return zend_hash_add(&url_stream_wrappers_hash, protocol, strlen(protocol), wrapper, sizeof(*wrapper), NULL); return FAILURE; } -PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC) +PHPAPI int php_unregister_url_stream_wrapper(char *protocol) { if (PG(allow_url_fopen)) return zend_hash_del(&url_stream_wrappers_hash, protocol, strlen(protocol)); return SUCCESS; } -static php_stream *php_stream_open_url(char *path, char *mode, int options, char **opened_path TSRMLS_DC) +static php_stream *php_stream_open_url(char *path, char *mode, int options, char **opened_path STREAMS_DC) { php_stream_wrapper *wrapper; const char *p, *protocol = NULL; @@ -907,7 +928,7 @@ protocol = NULL; } if (wrapper) { - php_stream *stream = wrapper->create(path, mode, options, opened_path TSRMLS_CC); + php_stream *stream = wrapper->create(path, mode, options, opened_path STREAMS_REL_CC); if (stream) stream->wrapper = wrapper; return stream; @@ -923,15 +944,16 @@ path += n + 1; /* fall back on regular file access */ - return php_stream_open_wrapper(path, mode, (options & ~REPORT_ERRORS) | IGNORE_URL, - opened_path TSRMLS_CC); + return php_stream_open_wrapper_rel(path, mode, (options & ~REPORT_ERRORS) | IGNORE_URL, + opened_path); } return NULL; } -PHPAPI php_stream *php_stream_open_wrapper(char *path, char *mode, int options, char **opened_path TSRMLS_DC) +PHPAPI php_stream *_php_stream_open_wrapper(char *path, char *mode, int options, char **opened_path STREAMS_DC) { php_stream *stream = NULL; + TSRMLS_FETCH(); if (opened_path) *opened_path = NULL; @@ -940,24 +962,24 @@ return NULL; if (PG(allow_url_fopen) && !(options & IGNORE_URL)) { - stream = php_stream_open_url(path, mode, options, opened_path TSRMLS_CC); + stream = php_stream_open_url(path, mode, options, opened_path STREAMS_REL_CC); goto out; } if ((options & USE_PATH) && PG(include_path) != NULL) { - stream = php_stream_fopen_with_path(path, mode, PG(include_path), opened_path TSRMLS_CC); + stream = php_stream_fopen_with_path_rel(path, mode, PG(include_path), opened_path); goto out; } if ((options & ENFORCE_SAFE_MODE) && PG(safe_mode) && (!php_checkuid(path, mode, CHECKUID_CHECK_MODE_PARAM))) return NULL; - stream = php_stream_fopen(path, mode, opened_path TSRMLS_CC); + stream = php_stream_fopen_rel(path, mode, opened_path); out: if (stream != NULL && (options & STREAM_MUST_SEEK)) { php_stream *newstream; - switch(php_stream_make_seekable(stream, &newstream)) { + switch(php_stream_make_seekable_rel(stream, &newstream)) { case PHP_STREAM_UNCHANGED: return stream; case PHP_STREAM_RELEASED: @@ -985,7 +1007,7 @@ return stream; } -PHPAPI int php_stream_make_seekable(php_stream *origstream, php_stream **newstream) +PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream STREAMS_DC) { assert(newstream != NULL);
« previous php.cvs (#10306) next »