for old functions where required.
Make use of recent changes to chunk size and timeout setting code.
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)
}
/* }}} */
-/* {{{ 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;
}
/* }}} */
+/* {{{ stream_select related functions */
static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, int *max_fd TSRMLS_DC)
{
zval **elem;
}
}
}
-
return 1;
-
}
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 */
}
/* }}} */
-
/* {{{ 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)
}
/* }}} */
-/* {{{ 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;
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;
}
}
/* }}} */
-/* {{{ 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;
/* 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);
}
/* }}} */
}
/* }}} */
-
/* {{{ proto int umask([int mask])
Return or change the umask */
PHP_FUNCTION(umask)
/* }}} */
-
/* {{{ proto int fpassthru(resource fp)
Output all remaining data from a file pointer */
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);
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);
/* 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);
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;
}
-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";
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;
}
}
-/* {{{ 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;