This repository has been archived by the owner on Nov 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.c
118 lines (103 loc) · 3.2 KB
/
output.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
+------------------------------------------------------------------------+
| Zephir Language |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to [email protected] so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <[email protected]> |
| Eduar Carvajal <[email protected]> |
| Vladimir Kolesnikov <[email protected]> |
+------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ext.h"
#include "kernel/memory.h"
#include "kernel/output.h"
#include <Zend/zend_API.h>
#include <main/php_output.h>
void zephir_ob_start(TSRMLS_D)
{
#if PHP_VERSION_ID < 50400
php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
#else
php_output_start_default(TSRMLS_C);
#endif
}
void zephir_ob_get_contents(zval *result TSRMLS_DC)
{
#if PHP_VERSION_ID < 50400
php_ob_get_buffer(result TSRMLS_CC);
#else
php_output_get_contents(result TSRMLS_CC);
#endif
}
int zephir_ob_end_flush(TSRMLS_D)
{
if (zephir_ob_get_level(TSRMLS_C) < 1) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to flush");
return FAILURE;
}
#if PHP_VERSION_ID < 50400
php_end_ob_buffer(1, 0 TSRMLS_CC);
return SUCCESS;
#else
return php_output_end(TSRMLS_C);
#endif
}
int zephir_ob_end_clean(TSRMLS_D)
{
if (zephir_ob_get_level(TSRMLS_C) < 1) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete");
return FAILURE;
}
#if PHP_VERSION_ID < 50400
php_end_ob_buffer(0, 0 TSRMLS_CC);
return SUCCESS;
#else
return php_output_discard(TSRMLS_C);
#endif
}
int zephir_ob_flush(TSRMLS_D)
{
if (zephir_ob_get_level(TSRMLS_C) < 1) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer. No buffer to flush");
return FAILURE;
}
#if PHP_VERSION_ID < 50400
php_end_ob_buffer(1, 1 TSRMLS_CC);
return SUCCESS;
#else
return php_output_flush(TSRMLS_C);
#endif
}
int zephir_ob_clean(TSRMLS_D)
{
if (zephir_ob_get_level(TSRMLS_C) < 1) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete");
return FAILURE;
}
#if PHP_VERSION_ID < 50400
php_end_ob_buffer(0, 1 TSRMLS_CC);
return SUCCESS;
#else
return php_output_clean(TSRMLS_C);
#endif
}
int zephir_ob_get_level(TSRMLS_D)
{
#if PHP_VERSION_ID < 50400
return OG(ob_nesting_level);
#else
return php_output_get_level(TSRMLS_C);
#endif
}