pollita         Tue Dec  2 14:14:32 2003 EDT

  Modified files:              
    /php-src/main/streams       userspace.c 
  Log:
  Populate userstream objects with context property
  
Index: php-src/main/streams/userspace.c
diff -u php-src/main/streams/userspace.c:1.11 php-src/main/streams/userspace.c:1.12
--- php-src/main/streams/userspace.c:1.11       Tue Dec  2 13:52:58 2003
+++ php-src/main/streams/userspace.c    Tue Dec  2 14:14:31 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: userspace.c,v 1.11 2003/12/02 18:52:58 pollita Exp $ */
+/* $Id: userspace.c,v 1.12 2003/12/02 19:14:31 pollita Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -284,7 +284,7 @@
 {
        struct php_user_stream_wrapper *uwrap = (struct 
php_user_stream_wrapper*)wrapper->abstract;
        php_userstream_data_t *us;
-       zval *zfilename, *zoptions, *zretval = NULL, *zfuncname;
+       zval *zfilename, *zoptions, *zretval = NULL, *zfuncname, *zcontext;
        zval **args[2]; 
        int call_result;
        php_stream *stream = NULL;
@@ -304,6 +304,17 @@
        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 dir_open method - set up params first */
        MAKE_STD_ZVAL(zfilename);
@@ -722,7 +733,7 @@
 static int user_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, 
php_stream_context *context TSRMLS_DC)
 {
        struct php_user_stream_wrapper *uwrap = (struct 
php_user_stream_wrapper*)wrapper->abstract;
-       zval *zfilename, *zfuncname, *zretval;
+       zval *zfilename, *zfuncname, *zretval, *zcontext;
        zval **args[1];
        int call_result;
        zval *object;
@@ -734,6 +745,17 @@
        ZVAL_REFCOUNT(object) = 1;
        PZVAL_IS_REF(object) = 1;
 
+       if (context) {
+               MAKE_STD_ZVAL(zcontext);
+               php_stream_context_to_zval(context, zcontext);
+               add_property_zval(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(object, "context");
+       }
+
        /* call the unlink method */
        MAKE_STD_ZVAL(zfilename);
        ZVAL_STRING(zfilename, url, 1);
@@ -769,7 +791,7 @@
 static int user_wrapper_stat_url(php_stream_wrapper *wrapper, char *url, int flags, 
php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC)
 {
        struct php_user_stream_wrapper *uwrap = (struct 
php_user_stream_wrapper*)wrapper->abstract;
-       zval *zfilename, *zfuncname, *zretval, *zflags;
+       zval *zfilename, *zfuncname, *zretval, *zflags, *zcontext;
        zval **args[2]; 
        int call_result;
        zval *object;
@@ -781,6 +803,17 @@
        ZVAL_REFCOUNT(object) = 1;
        PZVAL_IS_REF(object) = 1;
 
+       if (context) {
+               MAKE_STD_ZVAL(zcontext);
+               php_stream_context_to_zval(context, zcontext);
+               add_property_zval(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(object, "context");
+       }
+
        /* call the stat_url method */
        
        /* call it's stream_open method - set up params first */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to