]> granicus.if.org Git - php/commitdiff
Expose php_stream_copy_to_stream as stream_copy_to_stream(); a high
authorWez Furlong <wez@php.net>
Sat, 1 Mar 2003 01:27:50 +0000 (01:27 +0000)
committerWez Furlong <wez@php.net>
Sat, 1 Mar 2003 01:27:50 +0000 (01:27 +0000)
performance alternative to looping reads and writes.

ext/standard/basic_functions.c
ext/standard/streamsfuncs.c
ext/standard/streamsfuncs.h

index d9ef2ebb6c2b30a5e33b409d67c6e8b06c14bad5..d4f045464643855baaa038e64e054cf57853b460 100644 (file)
@@ -683,6 +683,7 @@ function_entry basic_functions[] = {
        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 4e46d7694a2b9723aaa658f7e7c017e7e1859f78..5e0c48b4911e58e7d839d7a7a3adda8cc507fded 100644 (file)
@@ -263,6 +263,25 @@ PHP_FUNCTION(stream_socket_get_name)
 }
 /* }}} */
 
+/* {{{ 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));
+}
+/* }}} */
+
 /* {{{ proto resource stream_get_meta_data(resource fp)
     Retrieves header/meta data from streams/file pointers */
 PHP_FUNCTION(stream_get_meta_data)
index 93b2f707a3655d274c4b86729d6fd48b6bdf8cf5..9da5f1f5af74e111aa4204f9cc912e798b3da94b 100644 (file)
@@ -27,6 +27,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_FUNCTION(stream_select);