xref: /PHP-5.3/main/php_output.h (revision a2045ff3)
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 
24 typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC);
25 
26 BEGIN_EXTERN_C()
27 PHPAPI void php_output_startup(void);
28 PHPAPI void php_output_activate(TSRMLS_D);
29 PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC);
30 PHPAPI void php_output_register_constants(TSRMLS_D);
31 PHPAPI int  php_default_output_func(const char *str, uint str_len TSRMLS_DC);
32 PHPAPI int  php_ub_body_write(const char *str, uint str_length TSRMLS_DC);
33 PHPAPI int  php_ub_body_write_no_header(const char *str, uint str_length TSRMLS_DC);
34 PHPAPI int  php_body_write(const char *str, uint str_length TSRMLS_DC);
35 PHPAPI int  php_header_write(const char *str, uint str_length TSRMLS_DC);
36 PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC);
37 PHPAPI int php_start_ob_buffer_named(const char *output_handler_name, uint chunk_size, zend_bool erase TSRMLS_DC);
38 PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS_DC);
39 PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC);
40 PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC);
41 PHPAPI int php_ob_get_length(zval *p TSRMLS_DC);
42 PHPAPI void php_start_implicit_flush(TSRMLS_D);
43 PHPAPI void php_end_implicit_flush(TSRMLS_D);
44 PHPAPI char *php_get_output_start_filename(TSRMLS_D);
45 PHPAPI int php_get_output_start_lineno(TSRMLS_D);
46 PHPAPI 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);
47 PHPAPI int php_ob_handler_used(char *handler_name TSRMLS_DC);
48 PHPAPI int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC);
49 PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC);
50 PHPAPI int php_ob_get_length(zval *p TSRMLS_DC);
51 END_EXTERN_C()
52 
53 PHP_FUNCTION(ob_start);
54 PHP_FUNCTION(ob_flush);
55 PHP_FUNCTION(ob_clean);
56 PHP_FUNCTION(ob_end_flush);
57 PHP_FUNCTION(ob_end_clean);
58 PHP_FUNCTION(ob_get_flush);
59 PHP_FUNCTION(ob_get_clean);
60 PHP_FUNCTION(ob_get_contents);
61 PHP_FUNCTION(ob_get_length);
62 PHP_FUNCTION(ob_get_level);
63 PHP_FUNCTION(ob_get_status);
64 PHP_FUNCTION(ob_implicit_flush);
65 PHP_FUNCTION(ob_list_handlers);
66 
67 typedef 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 
82 typedef 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)
97 ZEND_API extern int output_globals_id;
98 #else
99 #define OG(v) (output_globals.v)
100 ZEND_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 
110 PHP_FUNCTION(output_add_rewrite_var);
111 PHP_FUNCTION(output_reset_rewrite_vars);
112 
113 
114 #endif /* PHP_OUTPUT_H */
115