From: Sara Golemon Date: Mon, 16 Jun 2003 19:13:39 +0000 (+0000) Subject: Add context property to userspace streams object. X-Git-Tag: RELEASE_1_0_2~178 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=730ce7b06f2fca9cda374556a9aa43568f4653cb;p=php Add context property to userspace streams object. --- diff --git a/NEWS b/NEWS index a5f496e2b8..2f60f090aa 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ PHP NEWS . "mail.force_extra_paramaters". (Derick) - Improved streams support: (Wez) + . Added context property to userspace streams object. (sara) . stream_socket_client() - similar to fsockopen(), but more powerful. . stream_socket_server() - Creates a server socket. . stream_socket_accept() - Accept a client connection. diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 9b1f9418c8..7ef9a0bcac 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -185,6 +185,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena zval **args[4]; int call_result; php_stream *stream = NULL; + zval *zcontext = NULL; /* Try to catch bad usage without preventing flexibility */ if (FG(user_stream_current_filename) != NULL && strcmp(filename, FG(user_stream_current_filename)) == 0) { @@ -201,6 +202,17 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena object_init_ex(us->object, uwrap->ce); ZVAL_REFCOUNT(us->object) = 1; PZVAL_IS_REF(us->object) = 1; + + if (context) { + MAKE_STD_ZVAL(zcontext); + php_stream_context_to_zval(context, zcontext); + add_property_zval(us->object, "context", zcontext); + /* The object property should be the only reference, + 'get rid' of our local reference. */ + zval_ptr_dtor(&zcontext); + } else { + add_property_null(us->object, "context"); + } /* call it's stream_open method - set up params first */ MAKE_STD_ZVAL(zfilename);