]> granicus.if.org Git - php/commitdiff
- [doc] add stream_set_read_buffer, equivalent of stream_set_write_buffer for read...
authorPierre Joye <pajoye@php.net>
Mon, 12 Apr 2010 08:25:50 +0000 (08:25 +0000)
committerPierre Joye <pajoye@php.net>
Mon, 12 Apr 2010 08:25:50 +0000 (08:25 +0000)
ext/standard/basic_functions.c
ext/standard/streamsfuncs.c
ext/standard/streamsfuncs.h
ext/standard/var_unserializer.c

index b3e8c70bbb1ebcfe5d55cb82ac64e5ef43e7a244..b9feaf0bef37313a4aa5c81e56836b81196b28a2 100644 (file)
@@ -2100,6 +2100,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_stream_set_timeout, 0)
 ZEND_END_ARG_INFO()
 #endif
 
+ZEND_BEGIN_ARG_INFO(arginfo_stream_set_read_buffer, 0)
+       ZEND_ARG_INFO(0, fp)
+       ZEND_ARG_INFO(0, buffer)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO(arginfo_stream_set_write_buffer, 0)
        ZEND_ARG_INFO(0, fp)
        ZEND_ARG_INFO(0, buffer)
@@ -3101,6 +3106,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */
        PHP_FE(fputcsv,                                                                                                                 arginfo_fputcsv)
        PHP_FE(flock,                                                                                                                   arginfo_flock)
        PHP_FE(get_meta_tags,                                                                                                   arginfo_get_meta_tags)
+       PHP_FE(stream_set_read_buffer,                                                                                  arginfo_stream_set_read_buffer)
        PHP_FE(stream_set_write_buffer,                                                                                 arginfo_stream_set_write_buffer)
        PHP_FALIAS(set_file_buffer, stream_set_write_buffer,                                    arginfo_stream_set_write_buffer)
 
index 6bc2e0598b0d72cd92b3e46d9f5a70d2c849f662..94c521508f1b0369408c521120a854254f8a4063 100644 (file)
@@ -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)
index 268be381b434b4f7ae3c7f6e89de4e2adfa06126..5eb9385e0d901c6d770a05a32303bd937fbcfb62 100644 (file)
@@ -36,6 +36,7 @@ PHP_FUNCTION(stream_get_contents);
 PHP_FUNCTION(stream_set_blocking);
 PHP_FUNCTION(stream_select);
 PHP_FUNCTION(stream_set_timeout);
+PHP_FUNCTION(stream_set_read_buffer);
 PHP_FUNCTION(stream_set_write_buffer);
 PHP_FUNCTION(stream_get_transports);
 PHP_FUNCTION(stream_get_wrappers);
index a497224ea913149eba881f452d5a3907b4f3d5aa..1ed2710f1f729a2cc1dec1f3d7d5232db3750d69 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Mon Jan 11 14:20:08 2010 */
+/* Generated by re2c 0.13.5 on Mon Apr 12 10:11:22 2010 */
 #line 1 "ext/standard/var_unserializer.re"
 /*
   +----------------------------------------------------------------------+