summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2003-04-08 21:00:07 +0000
committerSara Golemon <pollita@php.net>2003-04-08 21:00:07 +0000
commit1e853b74a366e2ee691d69304a256e9dccc6f2a5 (patch)
tree68ed2f3e91f5d6a676805ae002a00fc5ad35a56d
parent7467ad8c4739234796aea7994b44d24aa23e0dda (diff)
downloadphp-git-1e853b74a366e2ee691d69304a256e9dccc6f2a5.tar.gz
Added context support to file()
-rw-r--r--ext/standard/file.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 912a1c4fe8..9e7ef7f1c4 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -498,7 +498,7 @@ PHP_FUNCTION(file_put_contents)
}
/* }}} */
-/* {{{ 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 @@ PHP_FUNCTION(file)
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 @@ PHP_FUNCTION(file)
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;
}