summaryrefslogtreecommitdiff
path: root/README.NEW-OUTPUT-API
blob: 82e3f485b5e80ebbdb756acbf3193eae5330fbab (plain)
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
$Id: README.NEW-OUTPUT-API 219039 2006-08-30 07:39:09Z mike $


API adjustment to the old output control code:

	Everything now resides beneath the php_output namespace, 
	and there's an API call for every output handler op.

	Checking output control layers status:
		// Using OG()
		php_output_get_status(TSRMLS_C);

	Starting the default output handler:
		// php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
		php_output_start_default(TSRMLS_C);

	Starting an user handler by zval:
		// php_start_ob_buffer(zhandler, chunk_size, erase TSRMLS_CC);
		php_output_start_user(zhandler, chunk_size, flags TSRMLS_CC);

	Starting an internal handler whithout context:
		// php_ob_set_internal_handler(my_php_output_handler_func_t, buffer_size, "output handler name", erase TSRMLS_CC);
		php_output_start_internal(handler_name_zval, my_php_output_handler_func_t, chunk_size, flags TSRMLS_CC);

	Starting an internal handler with context:
		// not possible with old API
		php_output_handler *h;
		h = php_output_handler_create_internal(handler_name_zval, my_php_output_handler_context_func_t, chunk_size, flags TSRMLS_CC);
		php_output_handler_set_context(h, my_context, my_context_dtor);
		php_output_handler_start(h TSRMLS_CC);

	Testing whether a certain output handler has already been started:
		// php_ob_handler_used("output handler name" TSRMLS_CC);
		php_output_handler_started(handler_name_zval TSRMLS_CC);

	Flushing one output buffer:
		// php_ob_end_buffer(1, 1 TSRMLS_CC);
		php_output_flush(TSRMLS_C);

	Flushing all output buffers:
		// not possible with old API
		php_output_flush_all(TSRMLS_C);

	Cleaning one output buffer:
		// php_ob_end_buffer(0, 1 TSRMLS_CC);
		php_output_clean(TSRMLS_C);

	Cleaning all output buffers:
		// not possible with old API
		php_output_clean_all(TSRMLS_C);

	Discarding one output buffer:
		// php_ob_end_buffer(0, 0 TSRMLS_CC);
		php_output_discard(TSRMLS_C);

	Discarding all output buffers:
		// php_ob_end_buffers(0 TSRMLS_CC);
		php_output_discard_all(TSRMLS_C);

	Stopping (and dropping) one output buffer:
		// php_ob_end_buffer(1, 0 TSRMLS_CC)
		php_output_end(TSRMLS_C);

	Stopping (and dropping) all output buffers:
		// php_ob_end_buffers(1, 0 TSRMLS_CC);
		php_output_end_all(TSRMLS_C);

	Retrieving output buffers contents:
		// php_ob_get_buffer(zstring TSRMLS_CC);
		php_output_get_contents(zstring TSRMLS_CC);

	Retrieving output buffers length:
		// php_ob_get_length(zlength TSRMLS_CC);
		php_output_get_length(zlength TSRMLS_CC);

	Retrieving output buffering level:
		// OG(nesting_level);
		php_output_get_level(TSRMLS_C);

	Issue a warning because of an output handler conflict:
		// php_ob_init_conflict("to be started handler name", "to be tested if already started handler name" TSRMLS_CC);
		php_output_handler_conflict(new_handler_name_zval, set_handler_name_zval TSRMLS_CC);

	Registering a conflict checking function, which will be checked prior starting the handler:
		// not possible with old API, unless hardcoding into output.c
		php_output_handler_conflict_register(handler_name_zval, my_php_output_handler_conflict_check_t TSRMLS_CC);

	Registering a reverse conflict checking function, which will be checked prior starting the specified foreign handler:
		// not possible with old API
		php_output_handler_reverse_conflict_register(foreign_handler_name_zval, my_php_output_handler_conflict_check_t TSRMLS_CC);

	Facilitating a context from within an output handler callable with ob_start():
		// not possible with old API
		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ, (void *) &custom_ctx_ptr_ptr TSRMLS_CC);

	Disabling of the output handler by itself:
		//not possible with old API
		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE, NULL TSRMLS_CC);

	Marking an output handler immutable by itself because of irreversibility of its operation:
		// not possible with old API
		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);

	Restarting the output handler because of a CLEAN operation:
		// not possible with old API
		if (flags & PHP_OUTPUT_HANDLER_CLEAN) { ... }

	Recognizing by the output handler itself if it gets discarded:
		// not possible with old API
		if ((flags & PHP_OUTPUT_HANDLER_CLEAN) && (flags & PHP_OUTPUT_HANDLER_FINAL)) { ... }


Output handler hooks

	The output handler can change its abilities at runtime. Eg. the gz handler can
	remove the CLEANABLE and REMOVABLE bits when the first output has passed through it;
	or handlers implemented in C to be used with ob_start() can contain a non-global
	context:
		PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ
			pass a void*** pointer as second arg to receive the address of a pointer
			pointer to the opaque field of the output handler context
		PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS
			pass a int* pointer as second arg to receive the flags set for the output handler
		PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL
			pass a int* pointer as second arg to receive the level of this output handler
			(starts with 0)
		PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE
			the second arg is ignored; marks the output handler to be neither cleanable
			nor removable
		PHP_OUTPUT_HANDLER_HOOK_DISABLE
			the second arg is ignored; marks the output handler as disabled


Open questions

	Should the userland API be adjusted and unified?
	
	Many bits of the manual (and very first implementation) do not comply
	with the behaviour of the current (to be obsoleted) code, thus should
	the manual or the behaviour be adjusted?

END
$Id: README.NEW-OUTPUT-API 219039 2006-08-30 07:39:09Z mike $


API adjustment to the old output control code:

	Everything now resides beneath the php_output namespace, 
	and there's an API call for every output handler op.

	Checking output control layers status:
		// Using OG()
		php_output_get_status(TSRMLS_C);

	Starting the default output handler:
		// php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
		php_output_start_default(TSRMLS_C);

	Starting an user handler by zval:
		// php_start_ob_buffer(zhandler, chunk_size, erase TSRMLS_CC);
		php_output_start_user(zhandler, chunk_size, flags TSRMLS_CC);

	Starting an internal handler whithout context:
		// php_ob_set_internal_handler(my_php_output_handler_func_t, buffer_size, "output handler name", erase TSRMLS_CC);
		php_output_start_internal(handler_name_zval, my_php_output_handler_func_t, chunk_size, flags TSRMLS_CC);

	Starting an internal handler with context:
		// not possible with old API
		php_output_handler *h;
		h = php_output_handler_create_internal(handler_name_zval, my_php_output_handler_context_func_t, chunk_size, flags TSRMLS_CC);
		php_output_handler_set_context(h, my_context, my_context_dtor);
		php_output_handler_start(h TSRMLS_CC);

	Testing whether a certain output handler has already been started:
		// php_ob_handler_used("output handler name" TSRMLS_CC);
		php_output_handler_started(handler_name_zval TSRMLS_CC);

	Flushing one output buffer:
		// php_ob_end_buffer(1, 1 TSRMLS_CC);
		php_output_flush(TSRMLS_C);

	Flushing all output buffers:
		// not possible with old API
		php_output_flush_all(TSRMLS_C);

	Cleaning one output buffer:
		// php_ob_end_buffer(0, 1 TSRMLS_CC);
		php_output_clean(TSRMLS_C);

	Cleaning all output buffers:
		// not possible with old API
		php_output_clean_all(TSRMLS_C);

	Discarding one output buffer:
		// php_ob_end_buffer(0, 0 TSRMLS_CC);
		php_output_discard(TSRMLS_C);

	Discarding all output buffers:
		// php_ob_end_buffers(0 TSRMLS_CC);
		php_output_discard_all(TSRMLS_C);

	Stopping (and dropping) one output buffer:
		// php_ob_end_buffer(1, 0 TSRMLS_CC)
		php_output_end(TSRMLS_C);

	Stopping (and dropping) all output buffers:
		// php_ob_end_buffers(1, 0 TSRMLS_CC);
		php_output_end_all(TSRMLS_C);

	Retrieving output buffers contents:
		// php_ob_get_buffer(zstring TSRMLS_CC);
		php_output_get_contents(zstring TSRMLS_CC);

	Retrieving output buffers length:
		// php_ob_get_length(zlength TSRMLS_CC);
		php_output_get_length(zlength TSRMLS_CC);

	Retrieving output buffering level:
		// OG(nesting_level);
		php_output_get_level(TSRMLS_C);

	Issue a warning because of an output handler conflict:
		// php_ob_init_conflict("to be started handler name", "to be tested if already started handler name" TSRMLS_CC);
		php_output_handler_conflict(new_handler_name_zval, set_handler_name_zval TSRMLS_CC);

	Registering a conflict checking function, which will be checked prior starting the handler:
		// not possible with old API, unless hardcoding into output.c
		php_output_handler_conflict_register(handler_name_zval, my_php_output_handler_conflict_check_t TSRMLS_CC);

	Registering a reverse conflict checking function, which will be checked prior starting the specified foreign handler:
		// not possible with old API
		php_output_handler_reverse_conflict_register(foreign_handler_name_zval, my_php_output_handler_conflict_check_t TSRMLS_CC);

	Facilitating a context from within an output handler callable with ob_start():
		// not possible with old API
		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ, (void *) &custom_ctx_ptr_ptr TSRMLS_CC);

	Disabling of the output handler by itself:
		//not possible with old API
		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE, NULL TSRMLS_CC);

	Marking an output handler immutable by itself because of irreversibility of its operation:
		// not possible with old API
		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);

	Restarting the output handler because of a CLEAN operation:
		// not possible with old API
		if (flags & PHP_OUTPUT_HANDLER_CLEAN) { ... }

	Recognizing by the output handler itself if it gets discarded:
		// not possible with old API
		if ((flags & PHP_OUTPUT_HANDLER_CLEAN) && (flags & PHP_OUTPUT_HANDLER_FINAL)) { ... }


Output handler hooks

	The output handler can change its abilities at runtime. Eg. the gz handler can
	remove the CLEANABLE and REMOVABLE bits when the first output has passed through it;
	or handlers implemented in C to be used with ob_start() can contain a non-global
	context:
		PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ
			pass a void*** pointer as second arg to receive the address of a pointer
			pointer to the opaque field of the output handler context
		PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS
			pass a int* pointer as second arg to receive the flags set for the output handler
		PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL
			pass a int* pointer as second arg to receive the level of this output handler
			(starts with 0)
		PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE
			the second arg is ignored; marks the output handler to be neither cleanable
			nor removable
		PHP_OUTPUT_HANDLER_HOOK_DISABLE
			the second arg is ignored; marks the output handler as disabled


Open questions

	Should the userland API be adjusted and unified?
	
	Many bits of the manual (and very first implementation) do not comply
	with the behaviour of the current (to be obsoleted) code, thus should
	the manual or the behaviour be adjusted?

END
$Id: README.NEW-OUTPUT-API 219039 2006-08-30 07:39:09Z mike $


API adjustment to the old output control code:

	Everything now resides beneath the php_output namespace, 
	and there's an API call for every output handler op.

	Checking output control layers status:
		// Using OG()
		php_output_get_status(TSRMLS_C);

	Starting the default output handler:
		// php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
		php_output_start_default(TSRMLS_C);

	Starting an user handler by zval:
		// php_start_ob_buffer(zhandler, chunk_size, erase TSRMLS_CC);
		php_output_start_user(zhandler, chunk_size, flags TSRMLS_CC);

	Starting an internal handler whithout context:
		// php_ob_set_internal_handler(my_php_output_handler_func_t, buffer_size, "output handler name", erase TSRMLS_CC);
		php_output_start_internal(handler_name_zval, my_php_output_handler_func_t, chunk_size, flags TSRMLS_CC);

	Starting an internal handler with context:
		// not possible with old API
		php_output_handler *h;
		h = php_output_handler_create_internal(handler_name_zval, my_php_output_handler_context_func_t, chunk_size, flags TSRMLS_CC);
		php_output_handler_set_context(h, my_context, my_context_dtor);
		php_output_handler_start(h TSRMLS_CC);

	Testing whether a certain output handler has already been started:
		// php_ob_handler_used("output handler name" TSRMLS_CC);
		php_output_handler_started(handler_name_zval TSRMLS_CC);

	Flushing one output buffer:
		// php_ob_end_buffer(1, 1 TSRMLS_CC);
		php_output_flush(TSRMLS_C);

	Flushing all output buffers:
		// not possible with old API
		php_output_flush_all(TSRMLS_C);

	Cleaning one output buffer:
		// php_ob_end_buffer(0, 1 TSRMLS_CC);
		php_output_clean(TSRMLS_C);

	Cleaning all output buffers:
		// not possible with old API
		php_output_clean_all(TSRMLS_C);

	Discarding one output buffer:
		// php_ob_end_buffer(0, 0 TSRMLS_CC);
		php_output_discard(TSRMLS_C);

	Discarding all output buffers:
		// php_ob_end_buffers(0 TSRMLS_CC);
		php_output_discard_all(TSRMLS_C);

	Stopping (and dropping) one output buffer:
		// php_ob_end_buffer(1, 0 TSRMLS_CC)
		php_output_end(TSRMLS_C);

	Stopping (and dropping) all output buffers:
		// php_ob_end_buffers(1, 0 TSRMLS_CC);
		php_output_end_all(TSRMLS_C);

	Retrieving output buffers contents:
		// php_ob_get_buffer(zstring TSRMLS_CC);
		php_output_get_contents(zstring TSRMLS_CC);

	Retrieving output buffers length:
		// php_ob_get_length(zlength TSRMLS_CC);
		php_output_get_length(zlength TSRMLS_CC);

	Retrieving output buffering level:
		// OG(nesting_level);
		php_output_get_level(TSRMLS_C);

	Issue a warning because of an output handler conflict:
		// php_ob_init_conflict("to be started handler name", "to be tested if already started handler name" TSRMLS_CC);
		php_output_handler_conflict(new_handler_name_zval, set_handler_name_zval TSRMLS_CC);

	Registering a conflict checking function, which will be checked prior starting the handler:
		// not possible with old API, unless hardcoding into output.c
		php_output_handler_conflict_register(handler_name_zval, my_php_output_handler_conflict_check_t TSRMLS_CC);

	Registering a reverse conflict checking function, which will be checked prior starting the specified foreign handler:
		// not possible with old API
		php_output_handler_reverse_conflict_register(foreign_handler_name_zval, my_php_output_handler_conflict_check_t TSRMLS_CC);

	Facilitating a context from within an output handler callable with ob_start():
		// not possible with old API
		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ, (void *) &custom_ctx_ptr_ptr TSRMLS_CC);

	Disabling of the output handler by itself:
		//not possible with old API
		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE, NULL TSRMLS_CC);

	Marking an output handler immutable by itself because of irreversibility of its operation:
		// not possible with old API
		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);

	Restarting the output handler because of a CLEAN operation:
		// not possible with old API
		if (flags & PHP_OUTPUT_HANDLER_CLEAN) { ... }

	Recognizing by the output handler itself if it gets discarded:
		// not possible with old API
		if ((flags & PHP_OUTPUT_HANDLER_CLEAN) && (flags & PHP_OUTPUT_HANDLER_FINAL)) { ... }


Output handler hooks

	The output handler can change its abilities at runtime. Eg. the gz handler can
	remove the CLEANABLE and REMOVABLE bits when the first output has passed through it;
	or handlers implemented in C to be used with ob_start() can contain a non-global
	context:
		PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ
			pass a void*** pointer as second arg to receive the address of a pointer
			pointer to the opaque field of the output handler context
		PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS
			pass a int* pointer as second arg to receive the flags set for the output handler
		PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL
			pass a int* pointer as second arg to receive the level of this output handler
			(starts with 0)
		PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE
			the second arg is ignored; marks the output handler to be neither cleanable
			nor removable
		PHP_OUTPUT_HANDLER_HOOK_DISABLE
			the second arg is ignored; marks the output handler as disabled


Open questions

	Should the userland API be adjusted and unified?
	
	Many bits of the manual (and very first implementation) do not comply
	with the behaviour of the current (to be obsoleted) code, thus should
	the manual or the behaviour be adjusted?

END