wez Sat Jun 28 07:24:47 2003 EDT Modified files: /php-src/ext/standard streamsfuncs.c /php-src/main php_streams.h /php-src/main/streams cast.c plain_wrapper.c xp_socket.c Log: Merge selectable descriptor casting from PHP_4_3 branch. Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.23 php-src/ext/standard/streamsfuncs.c:1.24 --- php-src/ext/standard/streamsfuncs.c:1.23 Fri Jun 27 12:23:57 2003 +++ php-src/ext/standard/streamsfuncs.c Sat Jun 28 07:24:46 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streamsfuncs.c,v 1.23 2003/06/27 16:23:57 pollita Exp $ */ +/* $Id: streamsfuncs.c,v 1.24 2003/06/28 11:24:46 wez Exp $ */ #include "php.h" #include "php_globals.h" @@ -422,7 +422,7 @@ * when casting. It is only used here so that the buffered data warning * is not displayed. * */ - if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1)) { + if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1)) { FD_SET(this_fd, fds); if (this_fd > *max_fd) { *max_fd = this_fd; @@ -458,7 +458,7 @@ * when casting. It is only used here so that the buffered data warning * is not displayed. */ - if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1)) { + if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1)) { if (FD_ISSET(this_fd, fds)) { zend_hash_next_index_insert(new_hash, (void *)elem, sizeof(zval *), (void **)&dest_elem); if (dest_elem) { Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.81 php-src/main/php_streams.h:1.82 --- php-src/main/php_streams.h:1.81 Tue Jun 10 16:03:42 2003 +++ php-src/main/php_streams.h Sat Jun 28 07:24:47 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_streams.h,v 1.81 2003/06/10 20:03:42 imajes Exp $ */ +/* $Id: php_streams.h,v 1.82 2003/06/28 11:24:47 wez Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -388,6 +388,8 @@ #define PHP_STREAM_AS_FD 1 /* cast as a socketd */ #define PHP_STREAM_AS_SOCKETD 2 +/* cast as fd/socket for select purposes */ +#define PHP_STREAM_AS_FD_FOR_SELECT 3 /* try really, really hard to make sure the cast happens (avoid using this flag if possible) */ #define PHP_STREAM_CAST_TRY_HARD 0x80000000 Index: php-src/main/streams/cast.c diff -u php-src/main/streams/cast.c:1.7 php-src/main/streams/cast.c:1.8 --- php-src/main/streams/cast.c:1.7 Tue Jun 10 16:03:42 2003 +++ php-src/main/streams/cast.c Sat Jun 28 07:24:47 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cast.c,v 1.7 2003/06/10 20:03:42 imajes Exp $ */ +/* $Id: cast.c,v 1.8 2003/06/28 11:24:47 wez Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -137,10 +137,6 @@ #endif /* }}} */ - - - - /* {{{ php_stream_cast */ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err TSRMLS_DC) { @@ -148,7 +144,7 @@ castas &= ~PHP_STREAM_CAST_MASK; /* synchronize our buffer (if possible) */ - if (ret) { + if (ret && castas != PHP_STREAM_AS_FD_FOR_SELECT) { php_stream_flush(stream); if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) { off_t dummy; @@ -248,8 +244,8 @@ if (show_err) { /* these names depend on the values of the PHP_STREAM_AS_XXX defines in php_streams.h */ - static const char *cast_names[3] = { - "STDIO FILE*", "File Descriptor", "Socket Descriptor" + static const char *cast_names[4] = { + "STDIO FILE*", "File Descriptor", "Socket Descriptor", "select()able descriptor" }; php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot represent a stream of type %s as a %s", Index: php-src/main/streams/plain_wrapper.c diff -u php-src/main/streams/plain_wrapper.c:1.18 php-src/main/streams/plain_wrapper.c:1.19 --- php-src/main/streams/plain_wrapper.c:1.18 Tue Jun 10 16:03:42 2003 +++ php-src/main/streams/plain_wrapper.c Sat Jun 28 07:24:47 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: plain_wrapper.c,v 1.18 2003/06/10 20:03:42 imajes Exp $ */ +/* $Id: plain_wrapper.c,v 1.19 2003/06/28 11:24:47 wez Exp $ */ #include "php.h" #include "php_globals.h" @@ -520,6 +520,16 @@ *(FILE**)ret = data->file; data->fd = -1; + } + return SUCCESS; + + case PHP_STREAM_AS_FD_FOR_SELECT: + PHP_STDIOP_GET_FD(fd, data); + if (fd < 0) { + return FAILURE; + } + if (ret) { + *(int*)ret = fd; } return SUCCESS; Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.13 php-src/main/streams/xp_socket.c:1.14 --- php-src/main/streams/xp_socket.c:1.13 Sun Jun 15 19:34:45 2003 +++ php-src/main/streams/xp_socket.c Sat Jun 28 07:24:47 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xp_socket.c,v 1.13 2003/06/15 23:34:45 edink Exp $ */ +/* $Id: xp_socket.c,v 1.14 2003/06/28 11:24:47 wez Exp $ */ #include "php.h" #include "ext/standard/file.h" @@ -282,6 +282,7 @@ return FAILURE; } return SUCCESS; + case PHP_STREAM_AS_FD_FOR_SELECT: case PHP_STREAM_AS_FD: case PHP_STREAM_AS_SOCKETD: if (ret)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php