wez             Sat Sep 28 18:14:21 2002 EDT

  Modified files:              
    /php4/ext/standard  basic_functions.c file.c file.h 
                        http_fopen_wrapper.c 
    /php4/ext/standard/tests/file       userstreams.phpt 
    /php4/main  user_streams.c 
  Log:
  Rename streams functions to fit with naming conventions, adding aliases
  for old functions where required.
  Make use of recent changes to chunk size and timeout setting code.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.514 
php4/ext/standard/basic_functions.c:1.515
--- php4/ext/standard/basic_functions.c:1.514   Fri Sep 27 19:42:38 2002
+++ php4/ext/standard/basic_functions.c Sat Sep 28 18:14:20 2002
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.514 2002/09/27 23:42:38 wez Exp $ */
+/* $Id: basic_functions.c,v 1.515 2002/09/28 22:14:20 wez Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -630,20 +630,22 @@
        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: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.265 php4/ext/standard/file.c:1.266
--- php4/ext/standard/file.c:1.265      Sat Sep 28 09:04:47 2002
+++ php4/ext/standard/file.c    Sat Sep 28 18:14:21 2002
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: file.c,v 1.265 2002/09/28 13:04:47 wez Exp $ */
+/* $Id: file.c,v 1.266 2002/09/28 22:14:21 wez Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -582,9 +582,9 @@
 }
 /* }}} */
 
-/* {{{ 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 @@
 }
 /* }}} */
 
+/* {{{ 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 @@
                        }
                }
        }
-
        return 1;
-
 }
 
 static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
@@ -708,9 +707,8 @@
        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 @@
 }
 /* }}} */
 
-
 /* {{{ 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 @@
 }
 /* }}} */
 
-/* {{{ 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 @@
        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 @@
 }
 /* }}} */
 
-/* {{{ 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 @@
 
        /* 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 @@
 }
 /* }}} */
 
-
 /* {{{ proto int umask([int mask])
    Return or change the umask */
 PHP_FUNCTION(umask)
@@ -1744,7 +1739,6 @@
 }
 
 /* }}} */
-
 
 /* {{{ proto int fpassthru(resource fp)
    Output all remaining data from a file pointer */
Index: php4/ext/standard/file.h
diff -u php4/ext/standard/file.h:1.69 php4/ext/standard/file.h:1.70
--- php4/ext/standard/file.h:1.69       Fri Sep 27 19:42:38 2002
+++ php4/ext/standard/file.h    Sat Sep 28 18:14:21 2002
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: file.h,v 1.69 2002/09/27 23:42:38 wez Exp $ */
+/* $Id: file.h,v 1.70 2002/09/28 22:14:21 wez Exp $ */
 
 /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */
 
@@ -57,13 +57,12 @@
 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_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: php4/ext/standard/http_fopen_wrapper.c
diff -u php4/ext/standard/http_fopen_wrapper.c:1.51 
php4/ext/standard/http_fopen_wrapper.c:1.52
--- php4/ext/standard/http_fopen_wrapper.c:1.51 Thu Sep 26 06:17:41 2002
+++ php4/ext/standard/http_fopen_wrapper.c      Sat Sep 28 18:14:21 2002
@@ -18,7 +18,7 @@
    |          Wez Furlong <[EMAIL PROTECTED]>                          |
    +----------------------------------------------------------------------+
  */
-/* $Id: http_fopen_wrapper.c,v 1.51 2002/09/26 10:17:41 wez Exp $ */ 
+/* $Id: http_fopen_wrapper.c,v 1.52 2002/09/28 22:14:21 wez Exp $ */ 
 
 #include "php.h"
 #include "php_globals.h"
@@ -124,7 +124,7 @@
 
        /* 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 @@
                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: php4/ext/standard/tests/file/userstreams.phpt
diff -u php4/ext/standard/tests/file/userstreams.phpt:1.2 
php4/ext/standard/tests/file/userstreams.phpt:1.3
--- php4/ext/standard/tests/file/userstreams.phpt:1.2   Mon Sep 23 09:22:10 2002
+++ php4/ext/standard/tests/file/userstreams.phpt       Sat Sep 28 18:14:21 2002
@@ -151,12 +151,12 @@
 
 }
 
-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 @@
 
                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: php4/main/user_streams.c
diff -u php4/main/user_streams.c:1.24 php4/main/user_streams.c:1.25
--- php4/main/user_streams.c:1.24       Sat Sep 28 09:05:47 2002
+++ php4/main/user_streams.c    Sat Sep 28 18:14:21 2002
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: user_streams.c,v 1.24 2002/09/28 13:05:47 wez Exp $ */
+/* $Id: user_streams.c,v 1.25 2002/09/28 22:14:21 wez Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -335,9 +335,9 @@
 }
 
 
-/* {{{ 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;

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

Reply via email to