wez Fri Feb 28 20:27:50 2003 EDT Modified files: /php4/ext/standard basic_functions.c streamsfuncs.c streamsfuncs.h Log: Expose php_stream_copy_to_stream as stream_copy_to_stream(); a high performance alternative to looping reads and writes. Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.592 php4/ext/standard/basic_functions.c:1.593 --- php4/ext/standard/basic_functions.c:1.592 Fri Feb 28 14:53:20 2003 +++ php4/ext/standard/basic_functions.c Fri Feb 28 20:27:50 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.592 2003/02/28 19:53:20 wez Exp $ */ +/* $Id: basic_functions.c,v 1.593 2003/03/01 01:27:50 wez Exp $ */ #include "php.h" #include "php_streams.h" @@ -683,6 +683,7 @@ PHP_FE(stream_socket_server, second_and_third_args_force_ref) PHP_FE(stream_socket_accept, third_arg_force_ref) PHP_FE(stream_socket_get_name, NULL) + PHP_FE(stream_copy_to_stream, NULL) PHP_FE(fgetcsv, NULL) PHP_FE(flock, NULL) PHP_FE(get_meta_tags, NULL) Index: php4/ext/standard/streamsfuncs.c diff -u php4/ext/standard/streamsfuncs.c:1.3 php4/ext/standard/streamsfuncs.c:1.4 --- php4/ext/standard/streamsfuncs.c:1.3 Fri Feb 28 16:03:35 2003 +++ php4/ext/standard/streamsfuncs.c Fri Feb 28 20:27:50 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streamsfuncs.c,v 1.3 2003/02/28 21:03:35 wez Exp $ */ +/* $Id: streamsfuncs.c,v 1.4 2003/03/01 01:27:50 wez Exp $ */ #include "php.h" #include "php_globals.h" @@ -260,6 +260,25 @@ TSRMLS_CC)) { RETURN_FALSE; } +} +/* }}} */ + +/* {{{ proto long stream_copy_to_stream(resource source, resource dest [, long maxlen ]) + Reads up to maxlen bytes from source stream and writes them to dest stream. */ +PHP_FUNCTION(stream_copy_to_stream) +{ + php_stream *src, *dest; + zval *zsrc, *zdest; + long maxlen = PHP_STREAM_COPY_ALL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &zsrc, &zdest, &maxlen) == FAILURE) { + RETURN_FALSE; + } + + php_stream_from_zval(src, &zsrc); + php_stream_from_zval(dest, &zdest); + + RETURN_LONG(php_stream_copy_to_stream(src, dest, maxlen)); } /* }}} */ Index: php4/ext/standard/streamsfuncs.h diff -u php4/ext/standard/streamsfuncs.h:1.1 php4/ext/standard/streamsfuncs.h:1.2 --- php4/ext/standard/streamsfuncs.h:1.1 Fri Feb 28 15:06:05 2003 +++ php4/ext/standard/streamsfuncs.h Fri Feb 28 20:27:50 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streamsfuncs.h,v 1.1 2003/02/28 20:06:05 wez Exp $ */ +/* $Id: streamsfuncs.h,v 1.2 2003/03/01 01:27:50 wez Exp $ */ /* Flags for stream_socket_client */ #define PHP_STREAM_CLIENT_PERSISTENT 1 @@ -26,6 +26,8 @@ PHP_FUNCTION(stream_socket_server); PHP_FUNCTION(stream_socket_accept); PHP_FUNCTION(stream_socket_get_name); + +PHP_FUNCTION(stream_copy_to_stream); PHP_FUNCTION(set_socket_blocking); /* deprecated */ PHP_FUNCTION(stream_set_blocking);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php