README.NEW-OUTPUT-API 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. $Id: README.NEW-OUTPUT-API 219039 2006-08-30 07:39:09Z mike $
  2. API adjustment to the old output control code:
  3. Everything now resides beneath the php_output namespace,
  4. and there's an API call for every output handler op.
  5. Checking output control layers status:
  6. // Using OG()
  7. php_output_get_status(TSRMLS_C);
  8. Starting the default output handler:
  9. // php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
  10. php_output_start_default(TSRMLS_C);
  11. Starting an user handler by zval:
  12. // php_start_ob_buffer(zhandler, chunk_size, erase TSRMLS_CC);
  13. php_output_start_user(zhandler, chunk_size, flags TSRMLS_CC);
  14. Starting an internal handler whithout context:
  15. // php_ob_set_internal_handler(my_php_output_handler_func_t, buffer_size, "output handler name", erase TSRMLS_CC);
  16. php_output_start_internal(handler_name, handler_name_len, my_php_output_handler_func_t, chunk_size, flags TSRMLS_CC);
  17. Starting an internal handler with context:
  18. // not possible with old API
  19. php_output_handler *h;
  20. h = php_output_handler_create_internal(handler_name, handler_name_len, my_php_output_handler_context_func_t, chunk_size, flags TSRMLS_CC);
  21. php_output_handler_set_context(h, my_context, my_context_dtor);
  22. php_output_handler_start(h TSRMLS_CC);
  23. Testing whether a certain output handler has already been started:
  24. // php_ob_handler_used("output handler name" TSRMLS_CC);
  25. php_output_handler_started(handler_name, handler_name_len TSRMLS_CC);
  26. Flushing one output buffer:
  27. // php_ob_end_buffer(1, 1 TSRMLS_CC);
  28. php_output_flush(TSRMLS_C);
  29. Flushing all output buffers:
  30. // not possible with old API
  31. php_output_flush_all(TSRMLS_C);
  32. Cleaning one output buffer:
  33. // php_ob_end_buffer(0, 1 TSRMLS_CC);
  34. php_output_clean(TSRMLS_C);
  35. Cleaning all output buffers:
  36. // not possible with old API
  37. php_output_clean_all(TSRMLS_C);
  38. Discarding one output buffer:
  39. // php_ob_end_buffer(0, 0 TSRMLS_CC);
  40. php_output_discard(TSRMLS_C);
  41. Discarding all output buffers:
  42. // php_ob_end_buffers(0 TSRMLS_CC);
  43. php_output_discard_all(TSRMLS_C);
  44. Stopping (and dropping) one output buffer:
  45. // php_ob_end_buffer(1, 0 TSRMLS_CC)
  46. php_output_end(TSRMLS_C);
  47. Stopping (and dropping) all output buffers:
  48. // php_ob_end_buffers(1, 0 TSRMLS_CC);
  49. php_output_end_all(TSRMLS_C);
  50. Retrieving output buffers contents:
  51. // php_ob_get_buffer(zstring TSRMLS_CC);
  52. php_output_get_contents(zstring TSRMLS_CC);
  53. Retrieving output buffers length:
  54. // php_ob_get_length(zlength TSRMLS_CC);
  55. php_output_get_length(zlength TSRMLS_CC);
  56. Retrieving output buffering level:
  57. // OG(nesting_level);
  58. php_output_get_level(TSRMLS_C);
  59. Issue a warning because of an output handler conflict:
  60. // php_ob_init_conflict("to be started handler name", "to be tested if already started handler name" TSRMLS_CC);
  61. php_output_handler_conflict(new_handler_name, new_handler_name_len, set_handler_name, set_handler_name_len TSRMLS_CC);
  62. Registering a conflict checking function, which will be checked prior starting the handler:
  63. // not possible with old API, unless hardcoding into output.c
  64. php_output_handler_conflict_register(handler_name, handler_name_len, my_php_output_handler_conflict_check_t TSRMLS_CC);
  65. Registering a reverse conflict checking function, which will be checked prior starting the specified foreign handler:
  66. // not possible with old API
  67. php_output_handler_reverse_conflict_register(foreign_handler_name, foreign_handler_name_len, my_php_output_handler_conflict_check_t TSRMLS_CC);
  68. Facilitating a context from within an output handler callable with ob_start():
  69. // not possible with old API
  70. php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ, (void *) &custom_ctx_ptr_ptr TSRMLS_CC);
  71. Disabling of the output handler by itself:
  72. //not possible with old API
  73. php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE, NULL TSRMLS_CC);
  74. Marking an output handler immutable by itself because of irreversibility of its operation:
  75. // not possible with old API
  76. php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
  77. Restarting the output handler because of a CLEAN operation:
  78. // not possible with old API
  79. if (flags & PHP_OUTPUT_HANDLER_CLEAN) { ... }
  80. Recognizing by the output handler itself if it gets discarded:
  81. // not possible with old API
  82. if ((flags & PHP_OUTPUT_HANDLER_CLEAN) && (flags & PHP_OUTPUT_HANDLER_FINAL)) { ... }
  83. Output handler hooks
  84. The output handler can change its abilities at runtime. Eg. the gz handler can
  85. remove the CLEANABLE and REMOVABLE bits when the first output has passed through it;
  86. or handlers implemented in C to be used with ob_start() can contain a non-global
  87. context:
  88. PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ
  89. pass a void*** pointer as second arg to receive the address of a pointer
  90. pointer to the opaque field of the output handler context
  91. PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS
  92. pass a int* pointer as second arg to receive the flags set for the output handler
  93. PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL
  94. pass a int* pointer as second arg to receive the level of this output handler
  95. (starts with 0)
  96. PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE
  97. the second arg is ignored; marks the output handler to be neither cleanable
  98. nor removable
  99. PHP_OUTPUT_HANDLER_HOOK_DISABLE
  100. the second arg is ignored; marks the output handler as disabled
  101. Open questions
  102. Should the userland API be adjusted and unified?
  103. Many bits of the manual (and very first implementation) do not comply
  104. with the behaviour of the current (to be obsoleted) code, thus should
  105. the manual or the behaviour be adjusted?
  106. END