wez Sat Sep 28 18:10:47 2002 EDT Modified files: /php4/main streams.c php_streams.h Log: Differentiate between write buffer and streams read buffer sizes. Add options for timeout and chunk size; previously these were only set-able for socket streams. Index: php4/main/streams.c diff -u php4/main/streams.c:1.85 php4/main/streams.c:1.86 --- php4/main/streams.c:1.85 Sat Sep 28 09:05:47 2002 +++ php4/main/streams.c Sat Sep 28 18:10:46 2002 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.85 2002/09/28 13:05:47 wez Exp $ */ +/* $Id: streams.c,v 1.86 2002/09/28 22:10:46 wez Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -799,7 +799,12 @@ if (ret == PHP_STREAM_OPTION_RETURN_NOTIMPL) { switch(option) { - case PHP_STREAM_OPTION_BUFFER: + case PHP_STREAM_OPTION_SET_CHUNK_SIZE: + ret = stream->chunk_size; + stream->chunk_size = value; + return ret; + + case PHP_STREAM_OPTION_READ_BUFFER: /* try to match the buffer mode as best we can */ if (value == PHP_STREAM_BUFFER_NONE) { stream->flags |= PHP_STREAM_FLAG_NO_BUFFER; @@ -1291,7 +1296,7 @@ return -1; /* not yet implemented */ #endif - case PHP_STREAM_OPTION_BUFFER: + case PHP_STREAM_OPTION_WRITE_BUFFER: if (ptrparam) size = *(size_t *)ptrparam; else Index: php4/main/php_streams.h diff -u php4/main/php_streams.h:1.50 php4/main/php_streams.h:1.51 --- php4/main/php_streams.h:1.50 Sat Sep 28 09:05:47 2002 +++ php4/main/php_streams.h Sat Sep 28 18:10:47 2002 @@ -374,16 +374,23 @@ PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC); #define php_stream_set_option(stream, option, value, ptrvalue) _php_stream_set_option((stream), (option), (value), (ptrvalue) TSRMLS_CC) +#define php_stream_set_chunk_size(stream, size) php_stream_set_option((stream), +PHP_STREAM_OPTION_SET_CHUNK_SIZE, (size), NULL TSRMLS_CC) + /* change the blocking mode of stream: value == 1 => blocking, value == 0 => non-blocking. */ #define PHP_STREAM_OPTION_BLOCKING 1 /* change the buffering mode of stream. value is a PHP_STREAM_BUFFER_XXXX value, ptrparam is a ptr to a size_t holding * the required buffer size */ -#define PHP_STREAM_OPTION_BUFFER 2 +#define PHP_STREAM_OPTION_READ_BUFFER 2 +#define PHP_STREAM_OPTION_WRITE_BUFFER 3 #define PHP_STREAM_BUFFER_NONE 0 /* unbuffered */ #define PHP_STREAM_BUFFER_LINE 1 /* line buffered */ #define PHP_STREAM_BUFFER_FULL 2 /* fully buffered */ + +/* set the timeout duration for reads on the stream. ptrparam is a pointer to a +struct timeval * */ +#define PHP_STREAM_OPTION_READ_TIMEOUT 4 +#define PHP_STREAM_OPTION_SET_CHUNK_SIZE 5 #define PHP_STREAM_OPTION_RETURN_OK 0 /* option set OK */ #define PHP_STREAM_OPTION_RETURN_ERR -1 /* problem setting option */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php