derick Mon Nov 3 09:12:47 2003 EDT
Modified files:
/php-src/ext/standard streamsfuncs.c
/php-src/main php.h php_streams.h
/php-src/main/streams streams.c
Log:
- Always store the URI path in the streams structure, and expose it with
stream_get_meta_data().
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.26
php-src/ext/standard/streamsfuncs.c:1.27
--- php-src/ext/standard/streamsfuncs.c:1.26 Wed Oct 8 06:07:25 2003
+++ php-src/ext/standard/streamsfuncs.c Mon Nov 3 09:12:44 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streamsfuncs.c,v 1.26 2003/10/08 10:07:25 wez Exp $ */
+/* $Id: streamsfuncs.c,v 1.27 2003/11/03 14:12:44 derick Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -364,6 +364,7 @@
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: php-src/main/php.h
diff -u php-src/main/php.h:1.199 php-src/main/php.h:1.200
--- php-src/main/php.h:1.199 Wed Sep 24 19:20:48 2003
+++ php-src/main/php.h Mon Nov 3 09:12:45 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php.h,v 1.199 2003/09/24 23:20:48 iliaa Exp $ */
+/* $Id: php.h,v 1.200 2003/11/03 14:12:45 derick Exp $ */
#ifndef PHP_H
#define PHP_H
@@ -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: php-src/main/php_streams.h
diff -u php-src/main/php_streams.h:1.83 php-src/main/php_streams.h:1.84
--- php-src/main/php_streams.h:1.83 Tue Jul 29 14:26:34 2003
+++ php-src/main/php_streams.h Mon Nov 3 09:12:45 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_streams.h,v 1.83 2003/07/29 18:26:34 iliaa Exp $ */
+/* $Id: php_streams.h,v 1.84 2003/11/03 14:12:45 derick Exp $ */
#ifndef PHP_STREAMS_H
#define PHP_STREAMS_H
@@ -194,8 +194,8 @@
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: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.38 php-src/main/streams/streams.c:1.39
--- php-src/main/streams/streams.c:1.38 Sun Oct 19 16:59:12 2003
+++ php-src/main/streams/streams.c Mon Nov 3 09:12:46 2003
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.38 2003/10/19 20:59:12 shane Exp $ */
+/* $Id: streams.c,v 1.39 2003/11/03 14:12:46 derick Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -265,7 +265,7 @@
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 @@
#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 @@
* 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 @@
# 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 @@
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 @@
}
}
-#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 @@
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);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php