php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_output.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Michael Wallner <mike@php.net> |
14 +----------------------------------------------------------------------+
15*/
16
17#ifndef PHP_OUTPUT_H
18#define PHP_OUTPUT_H
19
20#define PHP_OUTPUT_NEWAPI 1
21
22/* handler ops */
23#define PHP_OUTPUT_HANDLER_WRITE 0x00 /* standard passthru */
24#define PHP_OUTPUT_HANDLER_START 0x01 /* start */
25#define PHP_OUTPUT_HANDLER_CLEAN 0x02 /* restart */
26#define PHP_OUTPUT_HANDLER_FLUSH 0x04 /* pass along as much as possible */
27#define PHP_OUTPUT_HANDLER_FINAL 0x08 /* finalize */
28#define PHP_OUTPUT_HANDLER_CONT PHP_OUTPUT_HANDLER_WRITE
29#define PHP_OUTPUT_HANDLER_END PHP_OUTPUT_HANDLER_FINAL
30
31/* handler types */
32#define PHP_OUTPUT_HANDLER_INTERNAL 0x0000
33#define PHP_OUTPUT_HANDLER_USER 0x0001
34
35/* handler ability flags */
36#define PHP_OUTPUT_HANDLER_CLEANABLE 0x0010
37#define PHP_OUTPUT_HANDLER_FLUSHABLE 0x0020
38#define PHP_OUTPUT_HANDLER_REMOVABLE 0x0040
39#define PHP_OUTPUT_HANDLER_STDFLAGS 0x0070
40
41/* handler status flags */
42#define PHP_OUTPUT_HANDLER_STARTED 0x1000
43#define PHP_OUTPUT_HANDLER_DISABLED 0x2000
44#define PHP_OUTPUT_HANDLER_PROCESSED 0x4000
45
46#define PHP_OUTPUT_HANDLER_ABILITY_FLAGS(bitmask) ((bitmask) & ~0xf00f)
47
48/* handler op return values */
54
55/* php_output_stack_pop() flags */
56#define PHP_OUTPUT_POP_TRY 0x000
57#define PHP_OUTPUT_POP_FORCE 0x001
58#define PHP_OUTPUT_POP_DISCARD 0x010
59#define PHP_OUTPUT_POP_SILENT 0x100
60
61/* real global flags */
62#define PHP_OUTPUT_IMPLICITFLUSH 0x01
63#define PHP_OUTPUT_DISABLED 0x02
64#define PHP_OUTPUT_WRITTEN 0x04
65#define PHP_OUTPUT_SENT 0x08
66/* supplementary flags for php_output_get_status() */
67#define PHP_OUTPUT_ACTIVE 0x10
68#define PHP_OUTPUT_LOCKED 0x20
69/* output layer is ready to use */
70#define PHP_OUTPUT_ACTIVATED 0x100000
71
72/* handler hooks */
82
83#define PHP_OUTPUT_HANDLER_INITBUF_SIZE(s) \
84( ((s) > 1) ? \
85 (s) + PHP_OUTPUT_HANDLER_ALIGNTO_SIZE - ((s) % (PHP_OUTPUT_HANDLER_ALIGNTO_SIZE)) : \
86 PHP_OUTPUT_HANDLER_DEFAULT_SIZE \
87)
88#define PHP_OUTPUT_HANDLER_ALIGNTO_SIZE 0x1000
89#define PHP_OUTPUT_HANDLER_DEFAULT_SIZE 0x4000
90
91typedef struct _php_output_buffer {
92 char *data;
93 size_t size;
94 size_t used;
95 uint32_t free:1;
96 uint32_t _reserved:31;
98
104
105/* old-style, stateless callback */
106typedef void (*php_output_handler_func_t)(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode);
107/* new-style, opaque context callback */
108typedef zend_result (*php_output_handler_context_func_t)(void **handler_context, php_output_context *output_context);
109/* output handler context dtor */
111/* conflict check callback */
112typedef zend_result (*php_output_handler_conflict_check_t)(const char *handler_name, size_t handler_name_len);
113/* ctor for aliases */
114typedef struct _php_output_handler *(*php_output_handler_alias_ctor_t)(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags);
115
121
137
144 int flags;
146
148
149/* there should not be a need to use OG() from outside of output.c */
150#ifdef ZTS
151# define OG(v) ZEND_TSRMG(output_globals_id, zend_output_globals *, v)
152#else
153# define OG(v) (output_globals.v)
154#endif
155
156/* convenience macros */
157#define PHPWRITE(str, str_len) php_output_write((str), (str_len))
158#define PHPWRITE_H(str, str_len) php_output_write_unbuffered((str), (str_len))
159
160#define PUTC(c) php_output_write((const char *) &(c), 1)
161#define PUTC_H(c) php_output_write_unbuffered((const char *) &(c), 1)
162
163#define PUTS(str) do { \
164 const char *__str = (str); \
165 php_output_write(__str, strlen(__str)); \
166} while (0)
167#define PUTS_H(str) do { \
168 const char *__str = (str); \
169 php_output_write_unbuffered(__str, strlen(__str)); \
170} while (0)
171
172
174
175extern const char php_output_default_handler_name[sizeof("default output handler")];
176extern const char php_output_devnull_handler_name[sizeof("null output handler")];
177
178#define php_output_tearup() \
179 php_output_startup(); \
180 php_output_activate()
181#define php_output_teardown() \
182 php_output_end_all(); \
183 php_output_deactivate(); \
184 php_output_shutdown()
185
186/* MINIT */
187PHPAPI void php_output_startup(void);
188/* MSHUTDOWN */
189PHPAPI void php_output_shutdown(void);
190
191/* RINIT */
193/* RSHUTDOWN */
195
199PHPAPI const char *php_output_get_start_filename(void);
201
202PHPAPI size_t php_output_write_unbuffered(const char *str, size_t len);
203PHPAPI size_t php_output_write(const char *str, size_t len);
204
210PHPAPI void php_output_end_all(void);
213
218
221
223PHPAPI zend_result php_output_start_internal(const char *name, size_t name_len, php_output_handler_func_t output_handler, size_t chunk_size, int flags);
224
227
228PHPAPI void php_output_handler_set_context(php_output_handler *handler, void *opaq, void (*dtor)(void*));
230PHPAPI bool php_output_handler_started(const char *name, size_t name_len);
234
235PHPAPI bool php_output_handler_conflict(const char *handler_new, size_t handler_new_len, const char *handler_set, size_t handler_set_len);
236PHPAPI zend_result php_output_handler_conflict_register(const char *handler_name, size_t handler_name_len, php_output_handler_conflict_check_t check_func);
237PHPAPI zend_result php_output_handler_reverse_conflict_register(const char *handler_name, size_t handler_name_len, php_output_handler_conflict_check_t check_func);
238
239PHPAPI php_output_handler_alias_ctor_t php_output_handler_alias(const char *handler_name, size_t handler_name_len);
240PHPAPI zend_result php_output_handler_alias_register(const char *handler_name, size_t handler_name_len, php_output_handler_alias_ctor_t func);
241
243
244#endif
size_t len
Definition apprentice.c:174
sizeof(Countable|array $value, int $mode=COUNT_NORMAL)
DNS_STATUS status
Definition dns_win32.c:49
zend_ffi_type * type
Definition ffi.c:3812
zval * arg
Definition ffi.c:3975
char * mode
#define PHPAPI
Definition php.h:71
php_output_handler * active
Definition php_output.h:140
PHPAPI zend_result php_output_handler_hook(php_output_handler_hook_t type, void *arg)
Definition output.c:669
PHPAPI php_output_handler * php_output_handler_create_internal(const char *name, size_t name_len, php_output_handler_context_func_t handler, size_t chunk_size, int flags)
Definition output.c:505
PHPAPI void php_output_handler_dtor(php_output_handler *handler)
Definition output.c:698
_php_output_handler_status_t
Definition php_output.h:49
@ PHP_OUTPUT_HANDLER_FAILURE
Definition php_output.h:50
@ PHP_OUTPUT_HANDLER_SUCCESS
Definition php_output.h:51
@ PHP_OUTPUT_HANDLER_NO_DATA
Definition php_output.h:52
enum _php_output_handler_status_t php_output_handler_status_t
PHPAPI void php_output_end_all(void)
Definition output.c:322
PHPAPI bool php_output_handler_conflict(const char *handler_new, size_t handler_new_len, const char *handler_set, size_t handler_set_len)
Definition output.c:582
PHPAPI int php_output_activate(void)
Definition output.c:159
PHPAPI zend_result php_output_start_devnull(void)
Definition output.c:413
zend_string * output_start_filename
Definition php_output.h:142
PHPAPI bool php_output_handler_started(const char *name, size_t name_len)
Definition output.c:561
PHPAPI zend_result php_output_handler_reverse_conflict_register(const char *handler_name, size_t handler_name_len, php_output_handler_conflict_check_t check_func)
Definition output.c:615
PHPAPI void php_output_flush_all(void)
Definition output.c:273
PHPAPI void php_output_set_status(int status)
Definition output.c:206
struct _php_output_handler php_output_handler
php_output_handler * running
Definition php_output.h:141
enum _php_output_handler_hook_t php_output_handler_hook_t
PHPAPI zend_result php_output_start_user(zval *output_handler, size_t chunk_size, int flags)
Definition output.c:428
PHPAPI zend_result php_output_get_length(zval *p)
Definition output.c:376
PHPAPI void php_output_discard_all(void)
Definition output.c:341
const char php_output_devnull_handler_name[sizeof("null output handler")]
PHPAPI const char * php_output_get_start_filename(void)
Definition output.c:743
PHPAPI size_t php_output_write_unbuffered(const char *str, size_t len)
Definition output.c:226
_php_output_handler_hook_t
Definition php_output.h:73
@ PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL
Definition php_output.h:76
@ PHP_OUTPUT_HANDLER_HOOK_DISABLE
Definition php_output.h:78
@ PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS
Definition php_output.h:75
@ PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ
Definition php_output.h:74
@ PHP_OUTPUT_HANDLER_HOOK_LAST
Definition php_output.h:80
@ PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE
Definition php_output.h:77
PHPAPI zend_result php_output_handler_conflict_register(const char *handler_name, size_t handler_name_len, php_output_handler_conflict_check_t check_func)
Definition output.c:598
PHPAPI php_output_handler_alias_ctor_t php_output_handler_alias(const char *handler_name, size_t handler_name_len)
Definition output.c:644
PHPAPI void php_output_shutdown(void)
Definition output.c:148
PHPAPI zend_result php_output_discard(void)
Definition output.c:330
PHPAPI size_t php_output_write(const char *str, size_t len)
Definition output.c:237
struct _php_output_buffer php_output_buffer
void(* php_output_handler_context_dtor_t)(void *opaq)
Definition php_output.h:110
PHPAPI void php_output_set_implicit_flush(int flush)
Definition output.c:731
int output_start_lineno
Definition php_output.h:143
PHPAPI void php_output_handler_free(php_output_handler **handler)
Definition output.c:719
PHPAPI zend_result php_output_end(void)
Definition output.c:311
zend_stack handlers
Definition php_output.h:139
PHPAPI php_output_handler * php_output_get_active_handler(void)
Definition output.c:390
struct _php_output_handler_user_func_t php_output_handler_user_func_t
PHPAPI int php_output_get_level(void)
Definition output.c:351
struct _php_output_context php_output_context
zend_result(* php_output_handler_context_func_t)(void **handler_context, php_output_context *output_context)
Definition php_output.h:108
PHPAPI zend_result php_output_start_internal(const char *name, size_t name_len, php_output_handler_func_t output_handler, size_t chunk_size, int flags)
Definition output.c:447
PHPAPI zend_result php_output_clean(void)
Definition output.c:283
PHPAPI zend_result php_output_start_default(void)
Definition output.c:398
struct _php_output_handler *(* php_output_handler_alias_ctor_t)(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags)
Definition php_output.h:114
PHPAPI void php_output_clean_all(void)
Definition output.c:299
PHPAPI zend_result php_output_handler_start(php_output_handler *handler)
Definition output.c:532
PHPAPI zend_result php_output_handler_alias_register(const char *handler_name, size_t handler_name_len, php_output_handler_alias_ctor_t func)
Definition output.c:652
PHPAPI int php_output_get_start_lineno(void)
Definition output.c:751
PHPAPI int php_output_get_status(void)
Definition output.c:214
PHPAPI void php_output_startup(void)
Definition output.c:136
zend_result(* php_output_handler_conflict_check_t)(const char *handler_name, size_t handler_name_len)
Definition php_output.h:112
PHPAPI void php_output_handler_set_context(php_output_handler *handler, void *opaq, void(*dtor)(void *))
Definition output.c:520
PHPAPI zend_result php_output_get_contents(zval *p)
Definition output.c:359
void(* php_output_handler_func_t)(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode)
Definition php_output.h:106
PHPAPI zend_result php_output_flush(void)
Definition output.c:252
PHPAPI php_output_handler * php_output_handler_create_user(zval *handler, size_t chunk_size, int flags)
Definition output.c:463
PHPAPI void php_output_deactivate(void)
Definition output.c:176
char * output_handler
Definition php_zlib.h:57
p
Definition session.c:1105
php_output_buffer in
Definition php_output.h:101
php_output_buffer out
Definition php_output.h:102
zend_fcall_info_cache fcc
Definition php_output.h:118
void(* dtor)(void *opaq)
Definition php_output.h:130
php_output_buffer buffer
Definition php_output.h:127
php_output_handler_user_func_t * user
Definition php_output.h:133
zend_string * name
Definition php_output.h:123
php_output_handler_context_func_t internal
Definition php_output.h:134
struct _zend_fcall_info_cache zend_fcall_info_cache
#define ZEND_END_MODULE_GLOBALS(module_name)
Definition zend_API.h:248
struct _zend_fcall_info zend_fcall_info
#define ZEND_EXTERN_MODULE_GLOBALS(module_name)
Definition zend_API.h:270
#define ZEND_BEGIN_MODULE_GLOBALS(module_name)
Definition zend_API.h:246
struct _zval_struct zval
execute_data func
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
struct _zend_string zend_string
#define END_EXTERN_C()
#define BEGIN_EXTERN_C()
struct _zend_stack zend_stack
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
zend_string * name
fbc internal_function handler(call, ret)