]> granicus.if.org Git - php/commitdiff
- Always store the URI path in the streams structure, and expose it with
authorDerick Rethans <derick@php.net>
Mon, 3 Nov 2003 14:12:46 +0000 (14:12 +0000)
committerDerick Rethans <derick@php.net>
Mon, 3 Nov 2003 14:12:46 +0000 (14:12 +0000)
  stream_get_meta_data().

ext/standard/streamsfuncs.c
main/php.h
main/php_streams.h
main/streams/streams.c

index c0af60d8955efd4c0fe8a840b359d0f9e6e32065..ae9ed56184b3f2335d5861b835cdf72cc4340c5f 100644 (file)
@@ -364,6 +364,7 @@ PHP_FUNCTION(stream_get_meta_data)
        add_assoc_long(return_value, "unread_bytes", stream->writepos - stream->readpos);
 
        add_assoc_bool(return_value, "seekable", (stream->ops->seek) && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0);
+       add_assoc_string(return_value, "uri", stream->orig_path, 1);
 
        if (!php_stream_populate_meta_data(stream, return_value)) {
                add_assoc_bool(return_value, "timed_out", 0);
index 16d9ec03eef00885f44a1a768403390d5a3ca515..5b33180a1e8732d8f7c12966d9e7c143081badb4 100644 (file)
@@ -26,7 +26,7 @@
 #include <dmalloc.h>
 #endif
 
-#define PHP_API_VERSION 20030820
+#define PHP_API_VERSION 20031103
 #define PHP_HAVE_STREAMS
 #define YYDEBUG 0
 
index 69c75960176ab875eaa185256e61546f07dfe733..793878a488fd1d761b635b677febdbd7387364a2 100755 (executable)
@@ -194,8 +194,8 @@ struct _php_stream  {
        FILE *stdiocast;    /* cache this, otherwise we might leak! */
 #if ZEND_DEBUG
        int __exposed;  /* non-zero if exposed as a zval somewhere */
-       char *__orig_path; /* it really helps when debugging "unclosed" streams */
 #endif
+       char *orig_path;
 
        php_stream_context *context;
        int flags;      /* PHP_STREAM_FLAG_XXX */
index d7579378c1b9b48cfe02d60c98ff61e95d1bd8de..697d72f34db4eeaac31ac7cbf1c01ca1fe30b262 100755 (executable)
@@ -265,7 +265,7 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC) /*
        int release_cast = 1;
 
 #if STREAM_DEBUG
-fprintf(stderr, "stream_free: %s:%p[%s] in_free=%d opts=%08x\n", stream->ops->label, stream, stream->__orig_path, stream->in_free, close_options);
+fprintf(stderr, "stream_free: %s:%p[%s] in_free=%d opts=%08x\n", stream->ops->label, stream, stream->orig_path, stream->in_free, close_options);
 #endif
 
        /* recursion protection */
@@ -295,7 +295,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] in_free=%d opts=%08x\n", stream->ops->la
 
 #if STREAM_DEBUG
 fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remove_rsrc=%d\n",
-               stream->ops->label, stream, stream->__orig_path, preserve_handle, release_cast, remove_rsrc);
+               stream->ops->label, stream, stream->orig_path, preserve_handle, release_cast, remove_rsrc);
 #endif
 
        /* make sure everything is saved */
@@ -368,11 +368,11 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
                         * as leaked; it will log a warning, but lets help it out and display what kind
                         * of stream it was. */
                        char *leakinfo;
-                       spprintf(&leakinfo, 0, __FILE__ "(%d) : Stream of type '%s' %p (path:%s) was not closed\n", __LINE__, stream->ops->label, stream, stream->__orig_path);
+                       spprintf(&leakinfo, 0, __FILE__ "(%d) : Stream of type '%s' %p (path:%s) was not closed\n", __LINE__, stream->ops->label, stream, stream->orig_path);
 
-                       if (stream->__orig_path) {
-                               pefree(stream->__orig_path, stream->is_persistent);
-                               stream->__orig_path = NULL;
+                       if (stream->orig_path) {
+                               pefree(stream->orig_path, stream->is_persistent);
+                               stream->orig_path = NULL;
                        }
                        
 # if defined(PHP_WIN32)
@@ -382,14 +382,19 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
 # endif
                        efree(leakinfo);
                } else {
-                       if (stream->__orig_path) {
-                               pefree(stream->__orig_path, stream->is_persistent);
-                               stream->__orig_path = NULL;
+                       if (stream->orig_path) {
+                               pefree(stream->orig_path, stream->is_persistent);
+                               stream->orig_path = NULL;
                        }
 
                        pefree(stream, stream->is_persistent);
                }
 #else
+               if (stream->orig_path) {
+                       pefree(stream->orig_path, stream->is_persistent);
+                       stream->orig_path = NULL;
+               }
+
                pefree(stream, stream->is_persistent);
 #endif
        }
@@ -1516,10 +1521,8 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio
        php_stream *stream = NULL;
        php_stream_wrapper *wrapper = NULL;
        char *path_to_open;
-#if ZEND_DEBUG
        int persistent = options & STREAM_OPEN_PERSISTENT;
        char *copy_of_path = NULL;
-#endif
 
        
        if (opened_path) {
@@ -1558,12 +1561,10 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio
                }
        }
 
-#if ZEND_DEBUG
        if (stream) {
                copy_of_path = pestrdup(path, persistent);
-               stream->__orig_path = copy_of_path;
+               stream->orig_path = copy_of_path;
        }
-#endif
 
        if (stream != NULL && (options & STREAM_MUST_SEEK)) {
                php_stream *newstream;
@@ -1574,9 +1575,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio
                        case PHP_STREAM_UNCHANGED:
                                return stream;
                        case PHP_STREAM_RELEASED:
-#if ZEND_DEBUG
-                               newstream->__orig_path = pestrdup(path, persistent);
-#endif
+                               newstream->orig_path = pestrdup(path, persistent);
                                return newstream;
                        default:
                                php_stream_close(stream);