]> granicus.if.org Git - php/commitdiff
MFH: [DOC] Added stream_context_set_default() function. (Davey Shafik)
authorHannes Magnusson <bjori@php.net>
Sat, 16 Aug 2008 10:57:56 +0000 (10:57 +0000)
committerHannes Magnusson <bjori@php.net>
Sat, 16 Aug 2008 10:57:56 +0000 (10:57 +0000)
NEWS
ext/standard/basic_functions.c
ext/standard/streamsfuncs.c
ext/standard/streamsfuncs.h

diff --git a/NEWS b/NEWS
index 796c63e35bfbdcba3e0f4c1d904cd8a6530becee..74a2f92164132ffe42034363a629500af7da06b1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
 
index 4145ed64e1a4db2c9edc20af0f6982d38738cad0..9d732090da78b4ee4ca66b2227ff245d09679674 100644 (file)
@@ -2395,6 +2395,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_context_get_default, 0, 0, 0)
        ZEND_ARG_INFO(0, options) /* ARRAY_INFO(0, options, 1) */
 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) */
@@ -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)
index 459c8389ed21e308b7b5d891586aa21f507cdd88..d836db7f491ee36e9be69e904960eb5500e0ae33 100644 (file)
@@ -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)
index 244737835e88f165517a8a47151442f9d725feba..90105919c624d0bad048c7515fd38673a0f9337f 100644 (file)
@@ -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);