cvs: php4 /ext/standard file.c

From: Date: Tue, 08 Apr 2003 21:00:07 +0000
Subject: cvs: php4 /ext/standard file.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-20178@lists.php.net to get a copy of this message
pollita Tue Apr 8 17:00:07 2003 EDT Modified files: /php4/ext/standard file.c Log: Added context support to file() Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.331 php4/ext/standard/file.c:1.332 --- php4/ext/standard/file.c:1.331 Tue Apr 8 10:12:52 2003 +++ php4/ext/standard/file.c Tue Apr 8 17:00:07 2003 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.331 2003/04/08 14:12:52 sniper Exp $ */ +/* $Id: file.c,v 1.332 2003/04/08 21:00:07 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -498,7 +498,7 @@ } /* }}} */ -/* {{{ proto array file(string filename [, int flags]) +/* {{{ proto array file(string filename [, int flags[, resource context]]) Read entire file into an array */ #define PHP_FILE_BUF_SIZE 80 @@ -516,9 +516,11 @@ zend_bool include_new_line; zend_bool skip_blank_lines; php_stream *stream; + zval *zcontext = NULL; + php_stream_context *context = NULL; /* Parse arguments */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, &filename_len, &flags) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lr!", &filename, &filename_len, &flags, &zcontext) == FAILURE) { return; } if (flags < 0 || flags > (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES)) { @@ -530,7 +532,11 @@ include_new_line = !(flags & PHP_FILE_IGNORE_NEW_LINES); skip_blank_lines = flags & PHP_FILE_SKIP_EMPTY_LINES; - stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); + if (zcontext) { + context = zend_fetch_resource(&zcontext TSRMLS_CC, -1, "Stream-Context", NULL, 1, php_le_stream_context()); + } + + stream = php_stream_open_wrapper_ex(filename, "rb", (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context); if (!stream) { RETURN_FALSE; }

« previous php.cvs (#20178) next »