1/*
2   +----------------------------------------------------------------------+
3   | PHP Version 5                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2013 The PHP Group                                |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author: Zeev Suraski <zeev@zend.com>                                 |
16   +----------------------------------------------------------------------+
17*/
18
19/* $Id$ */
20
21#ifndef PHP_OUTPUT_H
22#define PHP_OUTPUT_H
23
24typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC);
25
26BEGIN_EXTERN_C()
27PHPAPI void php_output_startup(void);
28PHPAPI void php_output_activate(TSRMLS_D);
29PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC);
30PHPAPI void php_output_register_constants(TSRMLS_D);
31PHPAPI int  php_default_output_func(const char *str, uint str_len TSRMLS_DC);
32PHPAPI int  php_ub_body_write(const char *str, uint str_length TSRMLS_DC);
33PHPAPI int  php_ub_body_write_no_header(const char *str, uint str_length TSRMLS_DC);
34PHPAPI int  php_body_write(const char *str, uint str_length TSRMLS_DC);
35PHPAPI int  php_header_write(const char *str, uint str_length TSRMLS_DC);
36PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC);
37PHPAPI int php_start_ob_buffer_named(const char *output_handler_name, uint chunk_size, zend_bool erase TSRMLS_DC);
38PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS_DC);
39PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC);
40PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC);
41PHPAPI int php_ob_get_length(zval *p TSRMLS_DC);
42PHPAPI void php_start_implicit_flush(TSRMLS_D);
43PHPAPI void php_end_implicit_flush(TSRMLS_D);
44PHPAPI char *php_get_output_start_filename(TSRMLS_D);
45PHPAPI int php_get_output_start_lineno(TSRMLS_D);
46PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t internal_output_handler, uint buffer_size, char *handler_name, zend_bool erase TSRMLS_DC);
47PHPAPI int php_ob_handler_used(char *handler_name TSRMLS_DC);
48PHPAPI int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC);
49PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC);
50PHPAPI int php_ob_get_length(zval *p TSRMLS_DC);
51END_EXTERN_C()
52
53PHP_FUNCTION(ob_start);
54PHP_FUNCTION(ob_flush);
55PHP_FUNCTION(ob_clean);
56PHP_FUNCTION(ob_end_flush);
57PHP_FUNCTION(ob_end_clean);
58PHP_FUNCTION(ob_get_flush);
59PHP_FUNCTION(ob_get_clean);
60PHP_FUNCTION(ob_get_contents);
61PHP_FUNCTION(ob_get_length);
62PHP_FUNCTION(ob_get_level);
63PHP_FUNCTION(ob_get_status);
64PHP_FUNCTION(ob_implicit_flush);
65PHP_FUNCTION(ob_list_handlers);
66
67typedef struct _php_ob_buffer {
68    char *buffer;
69    uint size;
70    uint text_length;
71    int block_size;
72    uint chunk_size;
73    int status;
74    zval *output_handler;
75    php_output_handler_func_t internal_output_handler;
76    char *internal_output_handler_buffer;
77    uint internal_output_handler_buffer_size;
78    char *handler_name;
79    zend_bool erase;
80} php_ob_buffer;
81
82typedef struct _php_output_globals {
83    int (*php_body_write)(const char *str, uint str_length TSRMLS_DC);      /* string output */
84    int (*php_header_write)(const char *str, uint str_length TSRMLS_DC);    /* unbuffer string output */
85    php_ob_buffer active_ob_buffer;
86    unsigned char implicit_flush;
87    char *output_start_filename;
88    int output_start_lineno;
89    zend_stack ob_buffers;
90    int ob_nesting_level;
91    zend_bool ob_lock;
92    zend_bool disable_output;
93} php_output_globals;
94
95#ifdef ZTS
96#define OG(v) TSRMG(output_globals_id, php_output_globals *, v)
97ZEND_API extern int output_globals_id;
98#else
99#define OG(v) (output_globals.v)
100ZEND_API extern php_output_globals output_globals;
101#endif
102
103#define PHP_OUTPUT_HANDLER_START        (1<<0)
104#define PHP_OUTPUT_HANDLER_CONT         (1<<1)
105#define PHP_OUTPUT_HANDLER_END          (1<<2)
106
107#define PHP_OUTPUT_HANDLER_INTERNAL     0
108#define PHP_OUTPUT_HANDLER_USER        1
109
110PHP_FUNCTION(output_add_rewrite_var);
111PHP_FUNCTION(output_reset_rewrite_vars);
112
113
114#endif /* PHP_OUTPUT_H */
115