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

index 0768c7ef684743dc204cdb40e4651c21909002e8..470c2bbead46ec2103a17d6d3931e19632ba81e1 100644 (file)
@@ -2380,6 +2380,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) */
@@ -3553,6 +3558,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 3d68bd5a39e21135b6e49a0a263de39e6b0522aa..2e580f83e52cb351165d6379698ab055548750a4 100644 (file)
@@ -1158,6 +1158,28 @@ PHP_FUNCTION(stream_context_get_default)
 }
 /* }}} */
 
+/* {{{ proto resource stream_context_set_default(array options) U
+   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]]) U
    Create a file context and optionally set parameters */
 PHP_FUNCTION(stream_context_create)
index f27cc31e1ee4bff883ca00cc17969e4b7ced580d..4963614bcf316e4f0f32fabcd61a9b2f1370d1b7 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);