]> granicus.if.org Git - php/commitdiff
Rename streams functions to fit with naming conventions, adding aliases
authorWez Furlong <wez@php.net>
Sat, 28 Sep 2002 22:14:21 +0000 (22:14 +0000)
committerWez Furlong <wez@php.net>
Sat, 28 Sep 2002 22:14:21 +0000 (22:14 +0000)
for old functions where required.
Make use of recent changes to chunk size and timeout setting code.

ext/standard/basic_functions.c
ext/standard/file.c
ext/standard/file.h
ext/standard/http_fopen_wrapper.c
ext/standard/tests/file/userstreams.phpt
main/user_streams.c

index 765b9300e171f0f96e7a142e3aa1c279239f1151..6fd30daf195b941ef8b6ad4206679c3fa2e3456a 100644 (file)
@@ -630,20 +630,22 @@ function_entry basic_functions[] = {
        PHP_FE(fgetcsv,                                                                                                                 NULL)
        PHP_FE(flock,                                                                                                                   NULL)
        PHP_FE(get_meta_tags,                                                                                                   NULL)
-       PHP_FE(set_file_buffer,                                                                                                 NULL)
+       PHP_FE(stream_set_write_buffer,                                                                                 NULL)
+       PHP_FALIAS(set_file_buffer, stream_set_write_buffer,                                    NULL)
 
        PHP_FE(set_socket_blocking,                                                                                             NULL)
        PHP_FE(stream_set_blocking,                                                                                             NULL)
        PHP_FALIAS(socket_set_blocking, stream_set_blocking,                                    NULL)
 
-       PHP_FE(file_get_meta_data,                                                                                              NULL)
-       PHP_FE(file_register_wrapper,                                                                                   NULL)
+       PHP_FE(stream_get_meta_data,                                                                                    NULL)
+       PHP_FE(stream_register_wrapper,                                                                                 NULL)
 
 #if HAVE_SYS_TIME_H || defined(PHP_WIN32)
-       PHP_FE(socket_set_timeout,                                                                                              NULL)
+       PHP_FE(stream_set_timeout,                                                                                              NULL)
+       PHP_FALIAS(socket_set_timeout, stream_set_timeout,                                              NULL)
 #endif
 
-       PHP_FALIAS(socket_get_status, file_get_meta_data,                                               NULL)
+       PHP_FALIAS(socket_get_status, stream_get_meta_data,                                             NULL)
 
 #if (!defined(PHP_WIN32) && !defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) || defined(ZTS)
        PHP_FE(realpath,                                                                                                                NULL)
index f7d8ef590229d58248767870ae649a3f5b016d01..83574582148645b35d830b884dd0460c95f2adc6 100644 (file)
@@ -582,9 +582,9 @@ PHP_NAMED_FUNCTION(php_if_tmpfile)
 }
 /* }}} */
 
-/* {{{ proto resource file_get_meta_data(resource fp)
+/* {{{ proto resource stream_get_meta_data(resource fp)
     Retrieves header/meta data from streams/file pointers */
-PHP_FUNCTION(file_get_meta_data)
+PHP_FUNCTION(stream_get_meta_data)
 {
        zval **arg1;
        php_stream *stream;
@@ -639,6 +639,7 @@ PHP_FUNCTION(file_get_meta_data)
 }
 /* }}} */
 
+/* {{{ stream_select related functions */
 static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, int *max_fd TSRMLS_DC)
 {
        zval **elem;
@@ -664,9 +665,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, int *max_fd T
                        }
                }
        }
-
        return 1;
-
 }
 
 static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
@@ -708,9 +707,8 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
        Z_ARRVAL_P(stream_array) = new_hash;
        
        return 1;
-
 }
-
+/* }}} */
 
 /* {{{ proto int stream_select(array &read_streams, array &write_streams, array &except_streams, int tv_sec[, int tv_usec])
    Runs the select() system call on the sets of streams with a timeout specified by tv_sec and tv_usec */
@@ -763,7 +761,6 @@ PHP_FUNCTION(stream_select)
 }
 /* }}} */
 
-
 /* {{{ stream_context related functions */
 static void user_space_stream_notifier(php_stream_context *context, int notifycode, int severity,
                char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void * ptr TSRMLS_DC)
@@ -1205,10 +1202,10 @@ PHP_FUNCTION(set_socket_blocking)
 }
 /* }}} */
 
-/* {{{ proto bool socket_set_timeout(int socket_descriptor, int seconds, int microseconds)
-   Set timeout on socket read to seconds + microseonds */
+/* {{{ proto bool stream_set_timeout(resource stream, int seconds, int microseconds)
+   Set timeout on stream read to seconds + microseonds */
 #if HAVE_SYS_TIME_H || defined(PHP_WIN32)
-PHP_FUNCTION(socket_set_timeout)
+PHP_FUNCTION(stream_set_timeout)
 {
        zval **socket, **seconds, **microseconds;
        struct timeval t;
@@ -1232,8 +1229,7 @@ PHP_FUNCTION(socket_set_timeout)
        else
                t.tv_usec = 0;
 
-       if (php_stream_is(stream, PHP_STREAM_IS_SOCKET))        {
-               php_stream_sock_set_timeout(stream, &t TSRMLS_CC);
+       if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &t)) {
                RETURN_TRUE;
        }
 
@@ -1513,9 +1509,9 @@ PHPAPI PHP_FUNCTION(fflush)
 }
 /* }}} */
 
-/* {{{ proto int set_file_buffer(resource fp, int buffer)
+/* {{{ proto int stream_set_write_buffer(resource fp, int buffer)
    Set file write buffer */
-PHP_FUNCTION(set_file_buffer)
+PHP_FUNCTION(stream_set_write_buffer)
 {
        zval **arg1, **arg2;
        int ret;
@@ -1541,12 +1537,12 @@ PHP_FUNCTION(set_file_buffer)
 
        /* if buff is 0 then set to non-buffered */
        if (buff == 0) {
-               ret = php_stream_set_option(stream, PHP_STREAM_OPTION_BUFFER, PHP_STREAM_BUFFER_NONE, NULL);
+               ret = php_stream_set_option(stream, PHP_STREAM_OPTION_WRITE_BUFFER, PHP_STREAM_BUFFER_NONE, NULL);
        } else {
-               ret = php_stream_set_option(stream, PHP_STREAM_OPTION_BUFFER, PHP_STREAM_BUFFER_FULL, &buff);
+               ret = php_stream_set_option(stream, PHP_STREAM_OPTION_WRITE_BUFFER, PHP_STREAM_BUFFER_FULL, &buff);
        }
 
-       RETURN_LONG(ret);
+       RETURN_LONG(ret == 0 ? 0 : EOF);
 }
 /* }}} */
 
@@ -1717,7 +1713,6 @@ PHP_FUNCTION(readfile)
 }
 /* }}} */
 
-
 /* {{{ proto int umask([int mask])
    Return or change the umask */
 PHP_FUNCTION(umask)
@@ -1745,7 +1740,6 @@ PHP_FUNCTION(umask)
 
 /* }}} */
 
-
 /* {{{ proto int fpassthru(resource fp)
    Output all remaining data from a file pointer */
 
index d8eb1aa301cb4629978ba0cfdf967f0885e71f42..fd2835d4a6583ae1cacdae5dc12572a7d1a18657 100644 (file)
@@ -57,13 +57,12 @@ PHP_FUNCTION(file_get_contents);
 PHP_FUNCTION(set_socket_blocking); /* deprecated */
 PHP_FUNCTION(stream_set_blocking);
 PHP_FUNCTION(stream_select);
-PHP_FUNCTION(socket_set_timeout);
-PHP_FUNCTION(set_file_buffer);
+PHP_FUNCTION(stream_set_timeout);
+PHP_FUNCTION(stream_set_write_buffer);
 PHP_FUNCTION(get_meta_tags);
 PHP_FUNCTION(flock);
 PHP_FUNCTION(fd_set);
 PHP_FUNCTION(fd_isset);
-PHP_FUNCTION(select);
 #if (!defined(PHP_WIN32) && !defined(__BEOS__) && HAVE_REALPATH) || defined(ZTS)
 PHP_FUNCTION(realpath);
 PHP_FUNCTION(fnmatch);
@@ -71,8 +70,8 @@ PHP_FUNCTION(fnmatch);
 PHP_NAMED_FUNCTION(php_if_ftruncate);
 PHP_NAMED_FUNCTION(php_if_fstat);
 
-PHP_FUNCTION(file_get_meta_data);
-PHP_FUNCTION(file_register_wrapper);
+PHP_FUNCTION(stream_get_meta_data);
+PHP_FUNCTION(stream_register_wrapper);
 PHP_FUNCTION(stream_context_create);
 PHP_FUNCTION(stream_context_set_params);
 PHP_FUNCTION(stream_context_set_option);
index ba1858696f7428a7943ed1bea5328819ca22906c..20e6b23ec2e5c4cb9a25554adb479bced4aa7940 100644 (file)
@@ -124,7 +124,7 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
 
        /* avoid buffering issues while reading header */
        if (options & STREAM_WILL_CAST)
-               chunk_size = php_stream_sock_set_chunk_size(stream, 1 TSRMLS_CC);
+               chunk_size = php_stream_set_chunk_size(stream, 1);
        
        php_stream_context_set(stream, context);
 
@@ -389,7 +389,7 @@ out:
                stream->wrapperdata = response_header;
                php_stream_notify_progress_init(context, 0, file_size);
                if (options & STREAM_WILL_CAST)
-                       php_stream_sock_set_chunk_size(stream, chunk_size TSRMLS_CC);
+                       php_stream_set_chunk_size(stream, chunk_size);
                /* as far as streams are concerned, we are now at the start of
                 * the stream */
                stream->position = 0;
index 93b5199d5bbbe4b7be5a11b902b6fafa0bfb6365..6fc7da5faa0a54d318f3bc3ec013cea95ebb6aaf 100644 (file)
@@ -151,12 +151,12 @@ class mystream {
 
 }
 
-if (@file_register_wrapper("bogus", "class_not_exist"))
+if (@stream_register_wrapper("bogus", "class_not_exist"))
        die("Registered a non-existant class!!!???");
 
-if (!file_register_wrapper("test", "mystream"))
+if (!stream_register_wrapper("test", "mystream"))
        die("test wrapper registration failed");
-if (!file_register_wrapper("bogon", "uselessstream"))
+if (!stream_register_wrapper("bogon", "uselessstream"))
        die("bogon wrapper registration failed");
 
 echo "Registered\n";
@@ -248,7 +248,7 @@ foreach($line_lengths as $line_length) {
 
                if ($rr != $ur || $rline != $uline || $rpa != $position || $upa != $position) {
                        $fail_count++;
-                       $dat = file_get_wrapper_data($fp);
+                       $dat = stream_get_meta_data($fp);
                        var_dump($dat);
                        break;
                }
index b74715ce9219a39ec888862e2419089070e3fd9c..0688fbd596106d7f318739f2d444f388bc0bd0bb 100644 (file)
@@ -335,9 +335,9 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, char *filen
 }
 
 
-/* {{{ proto bool file_register_wrapper(string protocol, string classname)
+/* {{{ proto bool stream_register_wrapper(string protocol, string classname)
    Registers a custom URL protocol handler class */
-PHP_FUNCTION(file_register_wrapper)
+PHP_FUNCTION(stream_register_wrapper)
 {
        char *protocol, *classname;
        int protocol_len, classname_len;