[PHP-CVS] cvs: php-src / NEWS /ext/standard basic_functions.c streamsfuncs.c streamsfuncs.h

2006-10-08 Thread Sara Golemon
pollita Mon Oct  9 02:48:06 2006 UTC

  Modified files:  
/php-src/ext/standard   basic_functions.c streamsfuncs.c 
streamsfuncs.h 
/php-srcNEWS 
  Log:
  Add stream_resolve_include_path()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.810r2=1.811diff_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.810Sun 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.94r2=1.95diff_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.94Sun 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 {
+ 

[PHP-CVS] cvs: php-src / NEWS /ext/standard basic_functions.c streamsfuncs.c streamsfuncs.h /main php_streams.h /main/streams filter.c php_stream_filter_api.h streams.c

2004-09-13 Thread Sara Golemon
pollita Mon Sep 13 23:48:17 2004 EDT

  Modified files:  
/php-src/ext/standard   basic_functions.c streamsfuncs.c 
streamsfuncs.h 
/php-src/main   php_streams.h 
/php-src/main/streams   filter.c php_stream_filter_api.h streams.c 
/php-srcNEWS 
  Log:
  Added stream_filter_remove() to cancel a stream filter.
  
  Register filters as resources when
  instantiated by stream_filter_(ap|pre)pend().
  
  Export php_stream_filter_flush() internal function to wind buffered data
  out of a particular filter until consumed by a later filter or sent to
  stream-readbuffer or stream-ops-write()
  
  http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.686r2=1.687ty=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.686 
php-src/ext/standard/basic_functions.c:1.687
--- php-src/ext/standard/basic_functions.c:1.686Fri Sep 10 16:45:33 2004
+++ php-src/ext/standard/basic_functions.c  Mon Sep 13 23:48:16 2004
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.686 2004/09/10 20:45:33 pollita Exp $ */
+/* $Id: basic_functions.c,v 1.687 2004/09/14 03:48:16 pollita Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -600,6 +600,7 @@
PHP_FE(stream_context_get_default, 
 NULL)
PHP_FE(stream_filter_prepend,  
 NULL)
PHP_FE(stream_filter_append,   
 NULL)
+   PHP_FE(stream_filter_remove,   
 NULL)
PHP_FE(stream_socket_client, 
second_and_third_args_force_ref)
PHP_FE(stream_socket_server, 
second_and_third_args_force_ref)
PHP_FE(stream_socket_accept,   
third_arg_force_ref)
http://cvs.php.net/diff.php/php-src/ext/standard/streamsfuncs.c?r1=1.40r2=1.41ty=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.40 
php-src/ext/standard/streamsfuncs.c:1.41
--- php-src/ext/standard/streamsfuncs.c:1.40Fri Aug  6 10:08:17 2004
+++ php-src/ext/standard/streamsfuncs.c Mon Sep 13 23:48:16 2004
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: streamsfuncs.c,v 1.40 2004/08/06 14:08:17 wez Exp $ */
+/* $Id: streamsfuncs.c,v 1.41 2004/09/14 03:48:16 pollita Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -987,7 +987,7 @@
int filternamelen;
long read_write = 0;
zval *filterparams = NULL;
-   php_stream_filter *filter;
+   php_stream_filter *filter = NULL;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rs|lz, zstream,
filtername, filternamelen, read_write, 
filterparams) == FAILURE) {
@@ -1036,10 +1036,14 @@
}
}
 
-   RETURN_TRUE;
+   if (filter) {
+   RETURN_RESOURCE(ZEND_REGISTER_RESOURCE(NULL, filter, 
php_file_le_stream_filter()));
+   } else {
+   RETURN_FALSE;
+   }
 }
 
-/* {{{ proto bool stream_filter_prepend(resource stream, string filtername[, int 
read_write[, string filterparams]])
+/* {{{ proto resource stream_filter_prepend(resource stream, string filtername[, int 
read_write[, string filterparams]])
Prepend a filter to a stream */
 PHP_FUNCTION(stream_filter_prepend)
 {
@@ -1047,7 +1051,7 @@
 }
 /* }}} */
 
-/* {{{ proto bool stream_filter_append(resource stream, string filtername[, int 
read_write[, string filterparams]])
+/* {{{ proto resource stream_filter_append(resource stream, string filtername[, int 
read_write[, string filterparams]])
Append a filter to a stream */
 PHP_FUNCTION(stream_filter_append)
 {
@@ -1055,6 +1059,36 @@
 }
 /* }}} */
 
+/* {{{ proto bool stream_filter_remove(resource stream_filter)
+   Flushes any data in the filter's internal buffer, removes it from the chain, 
and frees the resource */
+PHP_FUNCTION(stream_filter_remove)
+{
+   zval *zfilter;
+   php_stream_filter *filter;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, zfilter) == 
FAILURE) {
+   RETURN_FALSE;
+   }
+
+   filter = zend_fetch_resource(zfilter TSRMLS_CC, -1, NULL, NULL, 1, 
php_file_le_stream_filter());
+   if (!filter) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid resource given, 
not a stream filter);
+   RETURN_FALSE;
+   }
+
+   if (php_stream_filter_flush(filter, 1) == FAILURE) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to flush filter, 
not removing);
+