diff options
| author | Pierre Joye <pajoye@php.net> | 2010-04-12 08:25:50 +0000 | 
|---|---|---|
| committer | Pierre Joye <pajoye@php.net> | 2010-04-12 08:25:50 +0000 | 
| commit | 95fcd75af2ef334894aed50ef065352cb4ba61c7 (patch) | |
| tree | 885b13a75cdaa33e782587260fd066659dcda96c /ext/standard/streamsfuncs.c | |
| parent | 4e7b11cccedddcdaa57c694d13d9276c8997d413 (diff) | |
| download | php-git-95fcd75af2ef334894aed50ef065352cb4ba61c7.tar.gz | |
- [doc] add stream_set_read_buffer, equivalent of stream_set_write_buffer for read operations. Fixing possible bad effects while reading devices. full context support is under work.
Diffstat (limited to 'ext/standard/streamsfuncs.c')
| -rw-r--r-- | ext/standard/streamsfuncs.c | 41 | 
1 files changed, 31 insertions, 10 deletions
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 6bc2e0598b..94c521508f 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -1372,16 +1372,8 @@ PHP_FUNCTION(stream_set_write_buffer)  	size_t buff;  	php_stream *stream; -	switch (ZEND_NUM_ARGS()) { -	case 2: -		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &arg2) == FAILURE) { -			RETURN_FALSE; -		} -		break; -	default: -		WRONG_PARAM_COUNT; -		/* NOTREACHED */ -		break; +	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &arg2) == FAILURE) { +		RETURN_FALSE;  	}  	php_stream_from_zval(stream, &arg1); @@ -1399,6 +1391,35 @@ PHP_FUNCTION(stream_set_write_buffer)  }  /* }}} */ +/* {{{ proto int stream_set_read_buffer(resource fp, int buffer) +   Set file write buffer */ +PHP_FUNCTION(stream_set_read_buffer) +{ +	zval *arg1; +	int ret; +	long arg2; +	size_t buff; +	php_stream *stream; + +	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &arg2) == FAILURE) { +		RETURN_FALSE; +	} + +	php_stream_from_zval(stream, &arg1); + +	buff = arg2; + +	/* if buff is 0 then set to non-buffered */ +	if (buff == 0) { +		ret = php_stream_set_option(stream, PHP_STREAM_OPTION_READ_BUFFER, PHP_STREAM_BUFFER_NONE, NULL); +	} else { +		ret = php_stream_set_option(stream, PHP_STREAM_OPTION_READ_BUFFER, PHP_STREAM_BUFFER_FULL, &buff); +	} + +	RETURN_LONG(ret == 0 ? 0 : EOF); +} +/* }}} */ +  /* {{{ proto int stream_socket_enable_crypto(resource stream, bool enable [, int cryptokind [, resource sessionstream]])     Enable or disable a specific kind of crypto on the stream */  PHP_FUNCTION(stream_socket_enable_crypto)  | 
