helly           Tue Nov  6 11:02:36 2007 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/main       php_streams.h 
    /php-src/main/streams       cast.c streams.c 
    /php-src/ext/standard/tests/file    include_userstream_002.phpt 
                                        stream_001.phpt 
  Log:
  MFH streams stuff
  
http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.103.2.1.2.4&r2=1.103.2.1.2.4.2.1&diff_format=u
Index: php-src/main/php_streams.h
diff -u php-src/main/php_streams.h:1.103.2.1.2.4 
php-src/main/php_streams.h:1.103.2.1.2.4.2.1
--- php-src/main/php_streams.h:1.103.2.1.2.4    Sat Jul 21 01:43:33 2007
+++ php-src/main/php_streams.h  Tue Nov  6 11:02:36 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_streams.h,v 1.103.2.1.2.4 2007/07/21 01:43:33 jani Exp $ */
+/* $Id: php_streams.h,v 1.103.2.1.2.4.2.1 2007/11/06 11:02:36 helly Exp $ */
 
 #ifndef PHP_STREAMS_H
 #define PHP_STREAMS_H
@@ -220,7 +220,12 @@
 
        int eof;
 
+#if ZEND_DEBUG
+       char *open_filename;
+       uint open_lineno;
+#endif
 }; /* php_stream */
+
 /* state definitions when closing down; these are private to streams.c */
 #define PHP_STREAM_FCLOSE_NONE 0
 #define PHP_STREAM_FCLOSE_FDOPEN       1
@@ -233,7 +238,6 @@
 END_EXTERN_C()
 #define php_stream_alloc(ops, thisptr, persistent_id, mode)    
_php_stream_alloc((ops), (thisptr), (persistent_id), (mode) STREAMS_CC 
TSRMLS_CC)
 
-
 #define php_stream_get_resource_id(stream)             (stream)->rsrc_id
 #if ZEND_DEBUG
 /* use this to tell the stream that it is OK if we don't explicitly close it */
@@ -430,6 +434,7 @@
 
 #include "streams/php_stream_transport.h"
 #include "streams/php_stream_plain_wrapper.h"
+#include "streams/php_stream_glob_wrapper.h"
 #include "streams/php_stream_userspace.h"
 #include "streams/php_stream_mmap.h"
 
@@ -464,14 +469,15 @@
 
 /* Wrappers support */
 
-#define IGNORE_PATH                    0
-#define USE_PATH                       1
-#define IGNORE_URL                     2
-#define ENFORCE_SAFE_MODE      4
-#define REPORT_ERRORS          8
+#define IGNORE_PATH                     0x00000000
+#define USE_PATH                        0x00000001
+#define IGNORE_URL                      0x00000002
+#define ENFORCE_SAFE_MODE               0x00000004
+#define REPORT_ERRORS                   0x00000008
+
 /* If you don't need to write to the stream, but really need to
  * be able to seek, use this flag in your options. */
-#define STREAM_MUST_SEEK       16
+#define STREAM_MUST_SEEK                0x00000010
 /* If you are going to end up casting the stream into a FILE* or
  * a socket, pass this flag and the streams/wrappers will not use
  * buffering mechanisms while reading the headers, so that HTTP
@@ -479,25 +485,28 @@
  * If you omit this flag, streams will use buffering and should end 
  * up working more optimally.
  * */
-#define STREAM_WILL_CAST       32
+#define STREAM_WILL_CAST                0x00000020
 
 /* this flag applies to php_stream_locate_url_wrapper */
-#define STREAM_LOCATE_WRAPPERS_ONLY    64
+#define STREAM_LOCATE_WRAPPERS_ONLY     0x00000040
 
 /* this flag is only used by include/require functions */
-#define STREAM_OPEN_FOR_INCLUDE                128
+#define STREAM_OPEN_FOR_INCLUDE         0x00000080
 
 /* this flag tells streams to ONLY open urls */
-#define STREAM_USE_URL                 256
+#define STREAM_USE_URL                  0x00000100
 
 /* this flag is used when only the headers from HTTP request are to be fetched 
*/
-#define STREAM_ONLY_GET_HEADERS                512
+#define STREAM_ONLY_GET_HEADERS         0x00000200
 
 /* don't apply open_basedir checks */
-#define STREAM_DISABLE_OPEN_BASEDIR    1024
+#define STREAM_DISABLE_OPEN_BASEDIR     0x00000400
 
 /* get (or create) a persistent version of the stream */
-#define STREAM_OPEN_PERSISTENT 2048
+#define STREAM_OPEN_PERSISTENT          0x00000800
+
+/* use glob stream for directory open in plain files stream */
+#define STREAM_USE_GLOB_DIR_OPEN        0x00001000
 
 /* don't check allow_url_fopen and allow_url_include */
 #define STREAM_DISABLE_URL_PROTECTION   0x00002000
@@ -550,12 +559,12 @@
 PHPAPI HashTable *_php_get_stream_filters_hash(TSRMLS_D);
 #define php_get_stream_filters_hash()  _php_get_stream_filters_hash(TSRMLS_C)
 PHPAPI HashTable *php_get_stream_filters_hash_global(void);
+extern php_stream_wrapper_ops *php_stream_user_wrapper_ops;
 END_EXTERN_C()
 #endif
 
 /* Definitions for user streams */
 #define PHP_STREAM_IS_URL              1
-
 /*
  * Local variables:
  * tab-width: 4
http://cvs.php.net/viewvc.cgi/php-src/main/streams/cast.c?r1=1.12.2.1.2.1&r2=1.12.2.1.2.1.2.1&diff_format=u
Index: php-src/main/streams/cast.c
diff -u php-src/main/streams/cast.c:1.12.2.1.2.1 
php-src/main/streams/cast.c:1.12.2.1.2.1.2.1
--- php-src/main/streams/cast.c:1.12.2.1.2.1    Mon Jan  1 09:36:11 2007
+++ php-src/main/streams/cast.c Tue Nov  6 11:02:36 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: cast.c,v 1.12.2.1.2.1 2007/01/01 09:36:11 sebastian Exp $ */
+/* $Id: cast.c,v 1.12.2.1.2.1.2.1 2007/11/06 11:02:36 helly Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -327,6 +327,11 @@
        if (*newstream == NULL)
                return PHP_STREAM_FAILED;
 
+#if ZEND_DEBUG
+       (*newstream)->open_filename = origstream->open_filename;
+       (*newstream)->open_lineno = origstream->open_lineno;
+#endif
+
        if (php_stream_copy_to_stream(origstream, *newstream, 
PHP_STREAM_COPY_ALL) == 0) {
                php_stream_close(*newstream);
                *newstream = NULL;
http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18&r2=1.82.2.6.2.18.2.1&diff_format=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.82.2.6.2.18 
php-src/main/streams/streams.c:1.82.2.6.2.18.2.1
--- php-src/main/streams/streams.c:1.82.2.6.2.18        Wed Aug  8 07:01:49 2007
+++ php-src/main/streams/streams.c      Tue Nov  6 11:02:36 2007
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c,v 1.82.2.6.2.18 2007/08/08 07:01:49 jani Exp $ */
+/* $Id: streams.c,v 1.82.2.6.2.18.2.1 2007/11/06 11:02:36 helly Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -240,6 +240,11 @@
        ret->is_persistent = persistent_id ? 1 : 0;
        ret->chunk_size = FG(def_chunk_size);
 
+#if ZEND_DEBUG
+       ret->open_filename = __zend_orig_filename ? __zend_orig_filename : 
__zend_filename;
+       ret->open_lineno = __zend_orig_lineno ? __zend_orig_lineno : 
__zend_lineno;
+#endif
+
        if (FG(auto_detect_line_endings)) {
                ret->flags |= PHP_STREAM_FLAG_DETECT_EOL;
        }
@@ -490,11 +495,10 @@
                                                }
                                                memcpy(stream->readbuf + 
stream->writepos, bucket->buf, bucket->buflen);
                                                stream->writepos += 
bucket->buflen;
-                                               
+
                                                php_stream_bucket_unlink(bucket 
TSRMLS_CC);
                                                php_stream_bucket_delref(bucket 
TSRMLS_CC);
                                        }
-
                                        break;
 
                                case PSFS_FEED_ME:
@@ -1324,8 +1328,9 @@
        while(1) {
                readchunk = sizeof(buf);
 
-               if (maxlen && (maxlen - haveread) < readchunk)
+               if (maxlen && (maxlen - haveread) < readchunk) {
                        readchunk = maxlen - haveread;
+               }
 
                didread = php_stream_read(src, buf, readchunk);
 
@@ -1355,8 +1360,8 @@
                        break;
                }
        }
-       return haveread;
 
+       return haveread;
 }
 /* }}} */
 
@@ -1522,7 +1527,7 @@
                /* BC with older php scripts and zlib wrapper */
                protocol = "compress.zlib";
                n = 13;
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Use of \"zlib:\" 
wrapper is deprecated; please use \"compress.zlib://\" instead.");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Use of \"zlib:\" 
wrapper is deprecated; please use \"compress.zlib://\" instead");
        }
 
        if (protocol) {
@@ -1547,6 +1552,9 @@
        }
        /* TODO: curl based streams probably support file:// properly */
        if (!protocol || !strncasecmp(protocol, "file", n))     {
+               /* fall back on regular file access */
+               php_stream_wrapper *plain_files_wrapper = 
&php_plain_files_wrapper;
+
                if (protocol) {
                        int localhost = 0;
 
@@ -1597,13 +1605,12 @@
                        }
 
                        if (options & REPORT_ERRORS) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Plainfiles wrapper disabled");
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"file:// wrapper is disabled in the server configuration");
                        }
                        return NULL;
                }
-
-               /* fall back on regular file access */          
-               return &php_plain_files_wrapper;
+               
+               return plain_files_wrapper;
        }
 
        if (wrapperpp && (*wrapperpp)->is_url &&            
@@ -1612,7 +1619,10 @@
             (((options & STREAM_OPEN_FOR_INCLUDE) ||
               PG(in_user_include)) && !PG(allow_url_include)))) {
                if (options & REPORT_ERRORS) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL 
file-access is disabled in the server configuration");
+                       /* protocol[n] probably isn't '\0' */
+                       char *protocol_dup = estrndup(protocol, n);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s:// 
wrapper is disabled in the server configuration", protocol_dup);
+                       efree(protocol_dup);
                }
                return NULL;
        }
@@ -1768,7 +1778,7 @@
 
        wrapper = php_stream_locate_url_wrapper(path, &path_to_open, options 
TSRMLS_CC);
        if (options & STREAM_USE_URL && (!wrapper || !wrapper->is_url)) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function may 
only be used against URLs.");
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function may 
only be used against URLs");
                return NULL;
        }
 
@@ -1802,6 +1812,10 @@
                }
                copy_of_path = pestrdup(path, persistent);
                stream->orig_path = copy_of_path;
+#if ZEND_DEBUG
+               stream->open_filename = __zend_orig_filename ? 
__zend_orig_filename : __zend_filename;
+               stream->open_lineno = __zend_orig_lineno ? __zend_orig_lineno : 
__zend_lineno;
+#endif
        }
 
        if (stream != NULL && (options & STREAM_MUST_SEEK)) {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/include_userstream_002.phpt?r1=1.1.2.2&r2=1.1.2.2.2.1&diff_format=u
Index: php-src/ext/standard/tests/file/include_userstream_002.phpt
diff -u php-src/ext/standard/tests/file/include_userstream_002.phpt:1.1.2.2 
php-src/ext/standard/tests/file/include_userstream_002.phpt:1.1.2.2.2.1
--- php-src/ext/standard/tests/file/include_userstream_002.phpt:1.1.2.2 Mon Jul 
 9 17:27:24 2007
+++ php-src/ext/standard/tests/file/include_userstream_002.phpt Tue Nov  6 
11:02:36 2007
@@ -97,7 +97,7 @@
 <?php echo "Hello World\n";?>
 <?php echo "Hello World\n";?>
 
-Warning: fopen(): URL file-access is disabled in the server configuration in 
%sinclude_userstream_002.php on line 10
+Warning: fopen(): test1:// wrapper is disabled in the server configuration in 
%sinclude_userstream_002.php on line 10
 
 Warning: fopen(test1://hello): failed to open stream: no suitable wrapper 
could be found in %sinclude_userstream_002.php on line 10
 
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/stream_001.phpt?r1=1.1.2.3&r2=1.1.2.3.2.1&diff_format=u
Index: php-src/ext/standard/tests/file/stream_001.phpt
diff -u php-src/ext/standard/tests/file/stream_001.phpt:1.1.2.3 
php-src/ext/standard/tests/file/stream_001.phpt:1.1.2.3.2.1
--- php-src/ext/standard/tests/file/stream_001.phpt:1.1.2.3     Wed Apr 18 
14:51:29 2007
+++ php-src/ext/standard/tests/file/stream_001.phpt     Tue Nov  6 11:02:36 2007
@@ -15,7 +15,7 @@
 
 Notice: fopen(): Unable to find the wrapper "file" - did you forget to enable 
it when you configured PHP? in %s on line %d
 
-Warning: fopen(): Plainfiles wrapper disabled in %s on line %d
+Warning: fopen(): file:// wrapper is disabled in the server configuration in 
%s on line %d
 
 Warning: fopen(file://%s): failed to open stream: no suitable wrapper could be 
found in %s on line %d
 bool(false)

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

Reply via email to