pollita         Mon Oct  9 02:48:06 2006 UTC

  Modified files:              
    /php-src/ext/standard       basic_functions.c streamsfuncs.c 
                                streamsfuncs.h 
    /php-src    NEWS 
  Log:
  Add stream_resolve_include_path()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.810&r2=1.811&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.810 
php-src/ext/standard/basic_functions.c:1.811
--- php-src/ext/standard/basic_functions.c:1.810        Sun Oct  8 13:34:23 2006
+++ php-src/ext/standard/basic_functions.c      Mon Oct  9 02:48:06 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.810 2006/10/08 13:34:23 bjori Exp $ */
+/* $Id: basic_functions.c,v 1.811 2006/10/09 02:48:06 pollita Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -2443,6 +2443,12 @@
        ZEND_ARG_INFO(0, stream)
        ZEND_ARG_INFO(0, encoding)
 ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_resolve_include_path, 0, 0, 1)
+       ZEND_ARG_INFO(0, filename)
+       ZEND_ARG_INFO(0, context)
+ZEND_END_ARG_INFO()
 /* }}} */
 /* {{{ string.c */
 static
@@ -3553,6 +3559,7 @@
 #endif
        PHP_FE(stream_copy_to_stream,                                           
                                        arginfo_stream_copy_to_stream)
        PHP_FE(stream_get_contents,                                             
                                                arginfo_stream_get_contents)
+       PHP_FE(stream_resolve_include_path,                                     
                                        arginfo_stream_resolve_include_path)
        PHP_FE(fgetcsv,                                                         
                                                        arginfo_fgetcsv)
        PHP_FE(fputcsv,                                                         
                                                        arginfo_fputcsv)
        PHP_FE(flock,                                                           
                                                        arginfo_flock)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.94&r2=1.95&diff_format=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.94 
php-src/ext/standard/streamsfuncs.c:1.95
--- php-src/ext/standard/streamsfuncs.c:1.94    Sun Oct  8 13:34:23 2006
+++ php-src/ext/standard/streamsfuncs.c Mon Oct  9 02:48:06 2006
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.c,v 1.94 2006/10/08 13:34:23 bjori Exp $ */
+/* $Id: streamsfuncs.c,v 1.95 2006/10/09 02:48:06 pollita Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -1579,6 +1579,72 @@
 }
 /* }}} */
 
+/* {{{ proto string stream_resolve_include_path(string filename[, resource 
context]) U
+Determine what file will be opened by calls to fopen() with a relative path */
+PHP_FUNCTION(stream_resolve_include_path)
+{
+       zval **ppfilename, *zcontext = NULL;
+       char *filename, *ptr = PG(include_path), *end = ptr + (ptr ? 
strlen(ptr) : 0), buffer[MAXPATHLEN];
+       int filename_len;
+       php_stream_context *context = NULL;
+       struct stat sb;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|r", 
&ppfilename, &zcontext) == FAILURE ||
+               php_stream_path_param_encode(ppfilename, &filename, 
&filename_len, REPORT_ERRORS, context = php_stream_context_from_zval(zcontext, 
0)) == FAILURE) {
+               return;
+       }
+
+       while (ptr < end) {
+               char *s = strchr(ptr, DEFAULT_DIR_SEPARATOR);
+
+               if (!s) {
+                       s = end;
+               }
+
+               if (s == ptr) {
+                       ptr++;
+                       continue;
+               }
+
+               if ((s - ptr) + 1 + filename_len >= MAXPATHLEN) {
+                       /* Too long to try */
+                       ptr = s + 1;
+                       continue;
+               }
+
+               memcpy(buffer, ptr, s - ptr);
+               buffer[s - ptr] = '/';
+               memcpy(buffer + (s - ptr) + 1, filename, filename_len + 1);
+
+               if (php_check_open_basedir_ex(buffer, 0 TSRMLS_CC)) {
+                       ptr = s + 1;
+                       continue;
+               }
+
+               if (VCWD_STAT(buffer, &sb)) {
+                       ptr = s + 1;
+                       continue;
+               }
+
+               if (UG(unicode)) {
+                       UChar *upath;
+                       int upath_len;
+
+                       if (SUCCESS == php_stream_path_decode(NULL, &upath, 
&upath_len, buffer, (s - ptr) + 1 + filename_len, REPORT_ERRORS, context)) {
+                               RETURN_UNICODEL(upath, upath_len, 0);
+                       } else {
+                               /* Fallback */
+                               RETURN_STRINGL(buffer, (s - ptr) + 1 + 
filename_len, 1);
+                       }
+               } else {
+                       RETURN_STRINGL(buffer, (s - ptr) + 1 + filename_len, 1);
+               }
+       }
+
+       RETURN_FALSE;
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.h?r1=1.16&r2=1.17&diff_format=u
Index: php-src/ext/standard/streamsfuncs.h
diff -u php-src/ext/standard/streamsfuncs.h:1.16 
php-src/ext/standard/streamsfuncs.h:1.17
--- php-src/ext/standard/streamsfuncs.h:1.16    Mon Jun 26 11:31:19 2006
+++ php-src/ext/standard/streamsfuncs.h Mon Oct  9 02:48:06 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.h,v 1.16 2006/06/26 11:31:19 bjori Exp $ */
+/* $Id: streamsfuncs.h,v 1.17 2006/10/09 02:48:06 pollita Exp $ */
 
 /* Flags for stream_socket_client */
 #define PHP_STREAM_CLIENT_PERSISTENT   1
@@ -55,6 +55,7 @@
 PHP_FUNCTION(stream_encoding);
 PHP_FUNCTION(stream_socket_enable_crypto);
 PHP_FUNCTION(stream_socket_pair);
+PHP_FUNCTION(stream_resolve_include_path);
 
 /*
  * Local variables:
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2127&r2=1.2128&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2127 php-src/NEWS:1.2128
--- php-src/NEWS:1.2127 Wed Oct  4 12:58:02 2006
+++ php-src/NEWS        Mon Oct  9 02:48:06 2006
@@ -55,6 +55,7 @@
   . sys_get_temp_dir() function that returns the default directory
     for temporary files (as requested in bug #35380). (Hartmut)
   . "context" and "binary_pipes" params in "other_options" arg. (Sara)
+  . stream_resolve_include_path(). (Sara)
 
 - Fixed bug #36630 (umask not reset at the end of the request). (Ilia)
 - Fixed bug #34286 (__toString() behavior is inconsistent). (Marcus)

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

Reply via email to