ZEND_ARG_INFO(0, options) /* ARRAY_INFO(0, options, 1) */
ZEND_END_ARG_INFO()
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_context_get_params, 0, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, stream_or_context)
+ZEND_END_ARG_INFO()
+
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_context_get_default, 0, 0, 0)
ZEND_ARG_INFO(0, options) /* ARRAY_INFO(0, options, 1) */
PHP_FE(stream_select, arginfo_stream_select)
PHP_FE(stream_context_create, arginfo_stream_context_create)
PHP_FE(stream_context_set_params, arginfo_stream_context_set_params)
+ PHP_FE(stream_context_get_params, arginfo_stream_context_get_params)
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)
}
/* }}} */
+/* {{{ proto bool stream_context_get_params(resource context|resource stream) U
+ Get parameters of a file context */
+PHP_FUNCTION(stream_context_get_params)
+{
+ zval *zcontext, *options;
+ php_stream_context *context;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zcontext) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ context = decode_context_param(zcontext TSRMLS_CC);
+ if (!context) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter");
+ RETURN_FALSE;
+ }
+
+ array_init(return_value);
+ if (context->notifier && context->notifier->ptr && context->notifier->func == user_space_stream_notifier) {
+ add_ascii_assoc_zval_ex(return_value, ZEND_STRS("notification"), context->notifier->ptr);
+ Z_ADDREF_P(context->notifier->ptr);
+ }
+ ALLOC_INIT_ZVAL(options);
+ ZVAL_ZVAL(options, context->options, 1, 0);
+ add_ascii_assoc_zval_ex(return_value, ZEND_STRS("options"), options);
+}
+/* }}} */
+
+
/* {{{ proto resource stream_context_get_default([array options]) U
Get a handle on the default file/stream context and optionally set parameters */
PHP_FUNCTION(stream_context_get_default)
PHP_FUNCTION(stream_wrapper_restore);
PHP_FUNCTION(stream_context_create);
PHP_FUNCTION(stream_context_set_params);
+PHP_FUNCTION(stream_context_get_params);
PHP_FUNCTION(stream_context_set_option);
PHP_FUNCTION(stream_context_get_options);
PHP_FUNCTION(stream_context_get_default);
--- /dev/null
+--TEST--
+stream_context_get_params()
+--FILE--
+<?php
+
+$ctx = stream_context_create();
+var_dump($ctx);
+var_dump(stream_context_get_params($ctx));
+
+var_dump(stream_context_set_option($ctx, "foo","bar","baz"));
+var_dump(stream_context_get_params($ctx));
+
+var_dump(stream_context_set_params($ctx, array("notification" => "stream_notification_callback")));
+var_dump(stream_context_get_params($ctx));
+
+var_dump(stream_context_set_params($ctx, array("notification" => array("stream","notification_callback"))));
+var_dump(stream_context_get_params($ctx));
+
+var_dump(stream_context_get_params($ctx));
+var_dump(stream_context_get_options($ctx));
+var_dump(stream_context_get_params($ctx));
+var_dump(stream_context_get_options($ctx));
+
+?>
+--EXPECTF--
+resource(%d) of type (stream-context)
+array(1) {
+ [%u|b%"options"]=>
+ array(0) {
+ }
+}
+bool(true)
+array(1) {
+ [%u|b%"options"]=>
+ array(1) {
+ [%u|b%"foo"]=>
+ array(1) {
+ [%u|b%"bar"]=>
+ %unicode|string%(3) "baz"
+ }
+ }
+}
+bool(true)
+array(2) {
+ [%u|b%"notification"]=>
+ %unicode|string%(28) "stream_notification_callback"
+ [%u|b%"options"]=>
+ array(1) {
+ [%u|b%"foo"]=>
+ array(1) {
+ [%u|b%"bar"]=>
+ %unicode|string%(3) "baz"
+ }
+ }
+}
+bool(true)
+array(2) {
+ [%u|b%"notification"]=>
+ array(2) {
+ [0]=>
+ %unicode|string%(6) "stream"
+ [1]=>
+ %unicode|string%(21) "notification_callback"
+ }
+ [%u|b%"options"]=>
+ array(1) {
+ [%u|b%"foo"]=>
+ array(1) {
+ [%u|b%"bar"]=>
+ %unicode|string%(3) "baz"
+ }
+ }
+}
+array(2) {
+ [%u|b%"notification"]=>
+ array(2) {
+ [0]=>
+ %unicode|string%(6) "stream"
+ [1]=>
+ %unicode|string%(21) "notification_callback"
+ }
+ [%u|b%"options"]=>
+ array(1) {
+ [%u|b%"foo"]=>
+ array(1) {
+ [%u|b%"bar"]=>
+ %unicode|string%(3) "baz"
+ }
+ }
+}
+array(1) {
+ [%u|b%"foo"]=>
+ array(1) {
+ [%u|b%"bar"]=>
+ %unicode|string%(3) "baz"
+ }
+}
+array(2) {
+ [%u|b%"notification"]=>
+ array(2) {
+ [0]=>
+ %unicode|string%(6) "stream"
+ [1]=>
+ %unicode|string%(21) "notification_callback"
+ }
+ [%u|b%"options"]=>
+ array(1) {
+ [%u|b%"foo"]=>
+ array(1) {
+ [%u|b%"bar"]=>
+ %unicode|string%(3) "baz"
+ }
+ }
+}
+array(1) {
+ [%u|b%"foo"]=>
+ array(1) {
+ [%u|b%"bar"]=>
+ %unicode|string%(3) "baz"
+ }
+}