1 2 /* 3 +------------------------------------------------------------------------+ 4 | Zephir Language | 5 +------------------------------------------------------------------------+ 6 | Copyright (c) 2011-2017 Zephir Team (http://www.zephir-lang.com) | 7 +------------------------------------------------------------------------+ 8 | This source file is subject to the New BSD License that is bundled | 9 | with this package in the file docs/LICENSE.txt. | 10 | | 11 | If you did not receive a copy of the license and are unable to | 12 | obtain it through the world-wide-web, please send an email | 13 | to license@zephir-lang.com so we can send you a copy immediately. | 14 +------------------------------------------------------------------------+ 15 | Authors: Andres Gutierrez <andres@zephir-lang.com> | 16 | Eduar Carvajal <eduar@zephir-lang.com> | 17 | Vladimir Kolesnikov <vladimir@extrememember.com> | 18 +------------------------------------------------------------------------+ 19 */ 20 21 #ifdef HAVE_CONFIG_H 22 #include "config.h" 23 #endif 24 25 #include "php.h" 26 #include "php_ext.h" 27 #include "kernel/memory.h" 28 #include "kernel/output.h" 29 30 #include <Zend/zend_API.h> 31 #include <main/php_output.h> 32 zephir_ob_start(TSRMLS_D)33void zephir_ob_start(TSRMLS_D) 34 { 35 php_output_start_default(TSRMLS_C); 36 } 37 zephir_ob_get_contents(zval * result TSRMLS_DC)38void zephir_ob_get_contents(zval *result TSRMLS_DC) 39 { 40 php_output_get_contents(result TSRMLS_CC); 41 } 42 zephir_ob_end_flush(TSRMLS_D)43int zephir_ob_end_flush(TSRMLS_D) 44 { 45 if (zephir_ob_get_level(TSRMLS_C) < 1) { 46 php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to flush"); 47 return FAILURE; 48 } 49 50 return php_output_end(TSRMLS_C); 51 } 52 zephir_ob_end_clean(TSRMLS_D)53int zephir_ob_end_clean(TSRMLS_D) 54 { 55 if (zephir_ob_get_level(TSRMLS_C) < 1) { 56 php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete"); 57 return FAILURE; 58 } 59 60 return php_output_discard(TSRMLS_C); 61 } 62 zephir_ob_flush(TSRMLS_D)63int zephir_ob_flush(TSRMLS_D) 64 { 65 if (zephir_ob_get_level(TSRMLS_C) < 1) { 66 php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer. No buffer to flush"); 67 return FAILURE; 68 } 69 70 return php_output_flush(TSRMLS_C); 71 } 72 zephir_ob_clean(TSRMLS_D)73int zephir_ob_clean(TSRMLS_D) 74 { 75 if (zephir_ob_get_level(TSRMLS_C) < 1) { 76 php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete"); 77 return FAILURE; 78 } 79 80 return php_output_clean(TSRMLS_C); 81 } 82 zephir_ob_get_level(TSRMLS_D)83int zephir_ob_get_level(TSRMLS_D) 84 { 85 return php_output_get_level(TSRMLS_C); 86 } 87