cvs: php4 /ext/standard file.c
| From: | Sara Golemon | Date: | Tue, 08 Apr 2003 00:02:47 +0000 |
| Subject: | cvs: php4 /ext/standard file.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-20157@lists.php.net to get a copy of this message | ||
pollita Mon Apr 7 20:02:47 2003 EDT
Modified files:
/php4/ext/standard file.c
Log:
Add context support to file_get_contents
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.329 php4/ext/standard/file.c:1.330
--- php4/ext/standard/file.c:1.329 Fri Mar 28 09:31:31 2003
+++ php4/ext/standard/file.c Mon Apr 7 20:02:47 2003
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.329 2003/03/28 14:31:31 iliaa Exp $ */
+/* $Id: file.c,v 1.330 2003/04/08 00:02:47 pollita Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -417,7 +417,7 @@
/* }}} */
-/* {{{ proto string file_get_contents(string filename [, bool use_include_path])
+/* {{{ proto string file_get_contents(string filename [[, bool use_include_path], resource
context])
Read the entire file into a string */
PHP_FUNCTION(file_get_contents)
{
@@ -427,16 +427,22 @@
zend_bool use_include_path = 0;
php_stream *stream;
int len, newlen;
+ zval *zcontext = NULL;
+ php_stream_context *context = NULL;
/* Parse arguments */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b",
- &filename, &filename_len, &use_include_path) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|br!",
+ &filename, &filename_len, &use_include_path, &zcontext) == FAILURE) {
return;
}
- 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;
}