summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2002-09-28 22:14:21 +0000
committerWez Furlong <wez@php.net>2002-09-28 22:14:21 +0000
commit76947703049259678c391dd69d072d0df56f5977 (patch)
tree713490ede3352a0f10182254cbe13d7c96d6e85d /ext/standard
parent9509c209417af7726813c19a99adca37d4158662 (diff)
downloadphp-git-76947703049259678c391dd69d072d0df56f5977.tar.gz
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.
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/basic_functions.c12
-rw-r--r--ext/standard/file.c32
-rw-r--r--ext/standard/file.h9
-rw-r--r--ext/standard/http_fopen_wrapper.c4
-rw-r--r--ext/standard/tests/file/userstreams.phpt8
5 files changed, 30 insertions, 35 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 765b9300e1..6fd30daf19 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -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)
diff --git a/ext/standard/file.c b/ext/standard/file.c
index f7d8ef5902..8357458214 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -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 */
diff --git a/ext/standard/file.h b/ext/standard/file.h
index d8eb1aa301..fd2835d4a6 100644
--- a/ext/standard/file.h
+++ b/ext/standard/file.h
@@ -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);
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index ba1858696f..20e6b23ec2 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -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;
diff --git a/ext/standard/tests/file/userstreams.phpt b/ext/standard/tests/file/userstreams.phpt
index 93b5199d5b..6fc7da5faa 100644
--- a/ext/standard/tests/file/userstreams.phpt
+++ b/ext/standard/tests/file/userstreams.phpt
@@ -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;
}