diff options
author | Hannes Magnusson <bjori@php.net> | 2008-08-16 10:57:56 +0000 |
---|---|---|
committer | Hannes Magnusson <bjori@php.net> | 2008-08-16 10:57:56 +0000 |
commit | eea3226d58c8bca06b8b20217d8a7f41dfce81fa (patch) | |
tree | 25cd80d0b3b6a137c506ff5d5780dd640b82e069 | |
parent | bb4eacb77319b8bb06a3fa1d9b6d0227fb3a069d (diff) | |
download | php-git-eea3226d58c8bca06b8b20217d8a7f41dfce81fa.tar.gz |
MFH: [DOC] Added stream_context_set_default() function. (Davey Shafik)
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/standard/basic_functions.c | 6 | ||||
-rw-r--r-- | ext/standard/streamsfuncs.c | 22 | ||||
-rw-r--r-- | ext/standard/streamsfuncs.h | 1 |
4 files changed, 30 insertions, 0 deletions
@@ -12,6 +12,7 @@ PHP NEWS - Added litespeed SAPI module. (George Wang) - Added ext/hash support to ext/session's ID generator. (Sara) - Added quoted_printable_encode() function. (Tony) +- Added stream_context_set_default() function. (Davey Shafik) - Added optional "is_xhtml" parameter to nl2br() which makes the function output <br> when false and <br /> when true (FR #34381). (Kalle) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 4145ed64e1..9d732090da 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2396,6 +2396,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_context_get_default, 0, 0, 0) ZEND_END_ARG_INFO() static +ZEND_BEGIN_ARG_INFO(arginfo_stream_context_set_default, 0) + ZEND_ARG_INFO(0, options) +ZEND_END_ARG_INFO() + +static ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_context_create, 0, 0, 0) ZEND_ARG_INFO(0, options) /* ARRAY_INFO(0, options, 1) */ ZEND_END_ARG_INFO() @@ -3520,6 +3525,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(stream_context_set_option, arginfo_stream_context_set_option) PHP_FE(stream_context_get_options, arginfo_stream_context_get_options) PHP_FE(stream_context_get_default, arginfo_stream_context_get_default) + PHP_FE(stream_context_set_default, arginfo_stream_context_set_default) PHP_FE(stream_filter_prepend, arginfo_stream_filter_prepend) PHP_FE(stream_filter_append, arginfo_stream_filter_append) PHP_FE(stream_filter_remove, arginfo_stream_filter_remove) diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 459c8389ed..d836db7f49 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -1047,6 +1047,28 @@ PHP_FUNCTION(stream_context_get_default) } /* }}} */ +/* {{{ proto resource stream_context_set_default(array options) + Set default file/stream context, returns the context as a resource */ +PHP_FUNCTION(stream_context_set_default) +{ + zval *options = NULL; + php_stream_context *context; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &options) == FAILURE) { + return; + } + + if (FG(default_context) == NULL) { + FG(default_context) = php_stream_context_alloc(); + } + context = FG(default_context); + + parse_context_options(context, options TSRMLS_CC); + + php_stream_context_to_zval(context, return_value); +} +/* }}} */ + /* {{{ proto resource stream_context_create([array options[, array params]]) Create a file context and optionally set parameters */ PHP_FUNCTION(stream_context_create) diff --git a/ext/standard/streamsfuncs.h b/ext/standard/streamsfuncs.h index 244737835e..90105919c6 100644 --- a/ext/standard/streamsfuncs.h +++ b/ext/standard/streamsfuncs.h @@ -49,6 +49,7 @@ PHP_FUNCTION(stream_context_set_params); PHP_FUNCTION(stream_context_set_option); PHP_FUNCTION(stream_context_get_options); PHP_FUNCTION(stream_context_get_default); +PHP_FUNCTION(stream_context_set_default); PHP_FUNCTION(stream_filter_prepend); PHP_FUNCTION(stream_filter_append); PHP_FUNCTION(stream_filter_remove); |