Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* implement new output API, fixing some bugs and implementing some fe…

…ature

  requests--let's see what I can dig out of the bugtracker for NEWS--
  and while crossing the road:
   * implemented new zlib API
   * fixed up ext/tidy (what was "s&" in zend_parse_parameters() supposed to do?)

Thanks to Jani and Felipe for pioneering.
  • Loading branch information...
commit 11d24c1593d6617f73d3f290617bd8994182f4dc 1 parent 27299b7
@m6w6 m6w6 authored
Showing with 3,410 additions and 2,550 deletions.
  1. +426 −0 README.NEW-OUTPUT-API
  2. +67 −62 ext/iconv/iconv.c
  3. +4 −4 ext/session/session.c
  4. +26 −76 ext/soap/soap.c
  5. +21 −29 ext/standard/basic_functions.c
  6. +3 −1 ext/standard/exec.c
  7. +2 −2 ext/standard/head.c
  8. +242 −357 ext/standard/info.c
  9. +2 −0  ext/standard/tests/general_functions/ob_get_flush_error.phpt
  10. +4 −4 ext/standard/url_scanner_ex.c
  11. +3 −3 ext/standard/url_scanner_ex.re
  12. +3 −3 ext/standard/var.c
  13. +1 −0  ext/tidy/php_tidy.h
  14. +149 −105 ext/tidy/tidy.c
  15. +1 −1  ext/zlib/CREDITS
  16. +8 −1 ext/zlib/config0.m4
  17. +29 −17 ext/zlib/php_zlib.h
  18. +2 −0  ext/zlib/tests/006.phpt
  19. +8 −8 ext/zlib/tests/007.phpt
  20. +3 −3 ext/zlib/tests/gzcompress_basic1.phpt
  21. +17 −11 ext/zlib/tests/gzcompress_error1.phpt
  22. +2 −4 ext/zlib/tests/gzcompress_variation1.phpt
  23. +1 −1  ext/zlib/tests/gzdeflate_basic1.phpt
  24. +14 −4 ext/zlib/tests/gzdeflate_error1.phpt
  25. +20 −7 ext/zlib/tests/gzencode_basic1.phpt
  26. +4 −4 ext/zlib/tests/gzencode_error1.phpt
  27. +5 −1 ext/zlib/tests/gzencode_variation1.phpt
  28. +42 −0 ext/zlib/tests/gzencode_variation2-win32.phpt
  29. +7 −1 ext/zlib/tests/gzencode_variation2.phpt
  30. +7 −4 ext/zlib/tests/gzinflate-bug42663.phpt
  31. +1 −1  ext/zlib/tests/gzinflate_length.phpt
  32. +7 −2 ext/zlib/tests/gzreadgzwrite.phpt
  33. +12 −3 ext/zlib/tests/gzreadgzwriteplain.phpt
  34. +2 −6 ext/zlib/tests/gzuncompress_error1.phpt
  35. +1 −1  ext/zlib/tests/gzwrite_variation1.phpt
  36. +20 −0 ext/zlib/tests/ob_001.phpt
  37. +18 −0 ext/zlib/tests/ob_002.phpt
  38. +25 −0 ext/zlib/tests/ob_003.phpt
  39. +25 −0 ext/zlib/tests/ob_004.phpt
  40. +21 −0 ext/zlib/tests/ob_005.phpt
  41. +1 −1  ext/zlib/tests/readgzfile_variation14.phpt
  42. +9 −0 ext/zlib/tests/readgzfile_variation4.phpt
  43. +8 −1 ext/zlib/tests/readgzfile_variation5.phpt
  44. +1 −0  ext/zlib/tests/readgzfile_variation6.phpt
  45. +7 −0 ext/zlib/tests/readgzfile_variation7.phpt
  46. +2 −2 ext/zlib/tests/zlib_filter_inflate2.phpt
  47. +632 −891 ext/zlib/zlib.c
  48. +16 −9 ext/zlib/zlib_filter.c
  49. +1 −1  ext/zlib/zlib_fopen_wrapper.c
  50. +2 −2 main/SAPI.c
  51. +33 −27 main/main.c
  52. +1,060 −664 main/output.c
  53. +1 −14 main/php.h
  54. +1 −1  main/php_logos.c
  55. +227 −67 main/php_output.h
  56. +1 −1  sapi/apache/mod_php5.c
  57. +1 −1  sapi/apache/php_apache.c
  58. +1 −1  sapi/apache2handler/php_functions.c
  59. +1 −1  sapi/apache_hooks/mod_php5.c
  60. +1 −1  sapi/apache_hooks/php_apache.c
  61. +5 −8 sapi/cgi/cgi_main.c
  62. +4 −4 sapi/cli/php_cli.c
  63. +5 −7 sapi/milter/php_milter.c
  64. +1 −1  sapi/nsapi/nsapi.c
  65. +2 −2 tests/output/bug46897.phpt
  66. +0 −2  tests/output/ob_011.phpt
  67. +37 −35 tests/output/ob_013.phpt
  68. +6 −6 tests/output/ob_017.phpt
  69. +2 −2 tests/output/ob_clean_basic_001.phpt
  70. +2 −2 tests/output/ob_end_clean_basic_001.phpt
  71. +3 −3 tests/output/ob_end_flush_basic_001.phpt
  72. +2 −2 tests/output/ob_flush_basic_001.phpt
  73. +1 −0  tests/output/ob_get_clean_basic_001.phpt
  74. +2 −2 tests/output/ob_get_level_basic_001.phpt
  75. +11 −12 tests/output/ob_get_status.phpt
  76. +14 −4 tests/output/ob_start_basic_004.phpt
  77. +16 −27 tests/output/ob_start_basic_006.phpt
  78. +3 −3 tests/output/ob_start_basic_unerasable_002.phpt
  79. +5 −4 tests/output/ob_start_basic_unerasable_003.phpt
  80. +5 −4 tests/output/ob_start_basic_unerasable_004.phpt
  81. +2 −2 tests/output/ob_start_basic_unerasable_005.phpt
  82. +8 −5 tests/output/ob_start_error_001.phpt
  83. +7 −0 tests/output/ob_start_error_002.phpt
  84. +3 −1 tests/output/ob_start_error_003.phpt
  85. +3 −1 tests/output/ob_start_error_004.phpt
View
426 README.NEW-OUTPUT-API
@@ -0,0 +1,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
View
129 ext/iconv/iconv.c
@@ -112,11 +112,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_iconv, 0)
ZEND_ARG_INFO(0, str)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO(arginfo_ob_iconv_handler, 0)
- ZEND_ARG_INFO(0, contents)
- ZEND_ARG_INFO(0, status)
-ZEND_END_ARG_INFO()
-
ZEND_BEGIN_ARG_INFO(arginfo_iconv_set_encoding, 0)
ZEND_ARG_INFO(0, type)
ZEND_ARG_INFO(0, charset)
@@ -132,7 +127,6 @@ ZEND_END_ARG_INFO()
*/
const zend_function_entry iconv_functions[] = {
PHP_RAW_NAMED_FE(iconv,php_if_iconv, arginfo_iconv)
- PHP_FE(ob_iconv_handler, arginfo_ob_iconv_handler)
PHP_FE(iconv_get_encoding, arginfo_iconv_get_encoding)
PHP_FE(iconv_set_encoding, arginfo_iconv_set_encoding)
PHP_FE(iconv_strlen, arginfo_iconv_strlen)
@@ -214,6 +208,10 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
static php_iconv_err_t php_iconv_stream_filter_register_factory(TSRMLS_D);
static php_iconv_err_t php_iconv_stream_filter_unregister_factory(TSRMLS_D);
+
+static int php_iconv_output_conflict(const char *handler_name, size_t handler_name_len TSRMLS_DC);
+static php_output_handler *php_iconv_output_handler_init(const char *name, size_t name_len, size_t chunk_size, int flags TSRMLS_DC);
+static int php_iconv_output_handler(void **nothing, php_output_context *output_context);
/* }}} */
/* {{{ static globals */
@@ -278,6 +276,9 @@ PHP_MINIT_FUNCTION(miconv)
return FAILURE;
}
+ php_output_handler_alias_register(ZEND_STRL("ob_iconv_handler"), php_iconv_output_handler_init TSRMLS_CC);
+ php_output_handler_conflict_register(ZEND_STRL("ob_iconv_handler"), php_iconv_output_conflict TSRMLS_CC);
+
return SUCCESS;
}
/* }}} */
@@ -312,6 +313,62 @@ PHP_MINFO_FUNCTION(miconv)
}
/* }}} */
+static int php_iconv_output_conflict(const char *handler_name, size_t handler_name_len TSRMLS_DC)
+{
+ if (php_output_get_level(TSRMLS_C)) {
+ if (php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL("ob_iconv_handler") TSRMLS_CC)
+ || php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL("mb_output_handler") TSRMLS_CC)) {
+ return FAILURE;
+ }
+ }
+ return SUCCESS;
+}
+
+static php_output_handler *php_iconv_output_handler_init(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags TSRMLS_DC)
+{
+ return php_output_handler_create_internal(handler_name, handler_name_len, php_iconv_output_handler, chunk_size, flags TSRMLS_CC);
+}
+
+static int php_iconv_output_handler(void **nothing, php_output_context *output_context)
+{
+ char *s, *content_type, *mimetype = NULL;
+ int output_status, mimetype_len = 0;
+ PHP_OUTPUT_TSRMLS(output_context);
+
+ if (output_context->op & PHP_OUTPUT_HANDLER_START) {
+ output_status = php_output_get_status(TSRMLS_C);
+ if (output_status & PHP_OUTPUT_SENT) {
+ return FAILURE;
+ }
+
+ if (SG(sapi_headers).mimetype && !strncasecmp(SG(sapi_headers).mimetype, "text/", 5)) {
+ if ((s = strchr(SG(sapi_headers).mimetype,';')) == NULL){
+ mimetype = SG(sapi_headers).mimetype;
+ } else {
+ mimetype = SG(sapi_headers).mimetype;
+ mimetype_len = s - SG(sapi_headers).mimetype;
+ }
+ } else if (SG(sapi_headers).send_default_content_type) {
+ mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE;
+ }
+
+ if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {
+ int len = spprintf(&content_type, 0, "Content-Type: %.*s; charset=%s", mimetype_len?mimetype_len:strlen(mimetype), mimetype, ICONVG(output_encoding));
+ if (content_type && SUCCESS == sapi_add_header(content_type, len, 0)) {
+ SG(sapi_headers).send_default_content_type = 0;
+ php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
+ }
+ }
+ }
+
+ if (output_context->in.used) {
+ output_context->out.free = 1;
+ _php_iconv_show_error(php_iconv_string(output_context->in.data, output_context->in.used, &output_context->out.data, &output_context->out.used, ICONVG(output_encoding), ICONVG(internal_encoding)), ICONVG(output_encoding), ICONVG(internal_encoding) TSRMLS_CC);
+ }
+
+ return SUCCESS;
+}
+
/* {{{ _php_iconv_appendl() */
static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, iconv_t cd)
{
@@ -1131,7 +1188,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn
goto out;
}
break;
-
+
default:
err = PHP_ICONV_ERR_UNKNOWN;
goto out;
@@ -1725,7 +1782,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
break;
case '\n':
- scan_stat = 8;
+ scan_stat = 8;
break;
case '=': /* first letter of an encoded chunk */
@@ -2308,58 +2365,6 @@ PHP_NAMED_FUNCTION(php_if_iconv)
}
/* }}} */
-/* {{{ proto string ob_iconv_handler(string contents, int status)
- Returns str in output buffer converted to the iconv.output_encoding character set */
-PHP_FUNCTION(ob_iconv_handler)
-{
- char *out_buffer, *content_type, *mimetype = NULL, *s;
- zval *zv_string;
- size_t out_len;
- int mimetype_alloced = 0;
- long status;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &zv_string, &status) == FAILURE)
- return;
-
- convert_to_string(zv_string);
-
- if (SG(sapi_headers).mimetype &&
- strncasecmp(SG(sapi_headers).mimetype, "text/", 5) == 0) {
- if ((s = strchr(SG(sapi_headers).mimetype,';')) == NULL){
- mimetype = SG(sapi_headers).mimetype;
- } else {
- mimetype = estrndup(SG(sapi_headers).mimetype, s-SG(sapi_headers).mimetype);
- mimetype_alloced = 1;
- }
- } else if (SG(sapi_headers).send_default_content_type) {
- mimetype =(SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE);
- }
- if (mimetype != NULL) {
- php_iconv_err_t err = php_iconv_string(Z_STRVAL_P(zv_string),
- Z_STRLEN_P(zv_string), &out_buffer, &out_len,
- ICONVG(output_encoding), ICONVG(internal_encoding));
- _php_iconv_show_error(err, ICONVG(output_encoding), ICONVG(internal_encoding) TSRMLS_CC);
- if (out_buffer != NULL) {
- int len = spprintf(&content_type, 0, "Content-Type:%s; charset=%s", mimetype, ICONVG(output_encoding));
- if (content_type && sapi_add_header(content_type, len, 0) != FAILURE) {
- SG(sapi_headers).send_default_content_type = 0;
- }
- if (mimetype_alloced) {
- efree(mimetype);
- }
- RETURN_STRINGL(out_buffer, out_len, 0);
- }
- if (mimetype_alloced) {
- efree(mimetype);
- }
- }
-
- zval_dtor(return_value);
- *return_value = *zv_string;
- zval_copy_ctor(return_value);
-}
-/* }}} */
-
/* {{{ proto bool iconv_set_encoding(string type, string charset)
Sets internal encoding and output encoding for ob_iconv_handler() */
PHP_FUNCTION(iconv_set_encoding)
@@ -2488,7 +2493,7 @@ static int php_iconv_stream_filter_append_bucket(
char *pd, *pt;
size_t ocnt, prev_ocnt, icnt, tcnt;
size_t initial_out_buf_size;
-
+
if (ps == NULL) {
initial_out_buf_size = 64;
icnt = 1;
@@ -2784,7 +2789,7 @@ static php_stream_filter *php_iconv_stream_filter_factory_create(const char *nam
pefree(inst, persistent);
}
- return retval;
+ return retval;
}
/* }}} */
View
8 ext/session/session.c
@@ -1093,8 +1093,8 @@ static int php_session_cache_limiter(TSRMLS_D) /* {{{ */
if (PS(cache_limiter)[0] == '\0') return 0;
if (SG(headers_sent)) {
- char *output_start_filename = php_get_output_start_filename(TSRMLS_C);
- int output_start_lineno = php_get_output_start_lineno(TSRMLS_C);
+ char *output_start_filename = php_output_get_start_filename(TSRMLS_C);
+ int output_start_lineno = php_output_get_start_lineno(TSRMLS_C);
if (output_start_filename) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot send session cache limiter - headers already sent (output started at %s:%d)", output_start_filename, output_start_lineno);
@@ -1133,8 +1133,8 @@ static void php_session_send_cookie(TSRMLS_D) /* {{{ */
char *e_session_name, *e_id;
if (SG(headers_sent)) {
- char *output_start_filename = php_get_output_start_filename(TSRMLS_C);
- int output_start_lineno = php_get_output_start_lineno(TSRMLS_C);
+ char *output_start_filename = php_output_get_start_filename(TSRMLS_C);
+ int output_start_lineno = php_output_get_start_lineno(TSRMLS_C);
if (output_start_filename) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot send session cookie - headers already sent by (output started at %s:%d)", output_start_filename, output_start_lineno);
View
102 ext/soap/soap.c
@@ -1650,7 +1650,7 @@ PHP_METHOD(SoapServer, handle)
ALLOC_INIT_ZVAL(retval);
- if (php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC) != SUCCESS) {
+ if (php_output_start_default(TSRMLS_C) != SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_ERROR,"ob_start failed");
}
@@ -1738,7 +1738,7 @@ PHP_METHOD(SoapServer, handle)
#ifdef ZEND_ENGINE_2
if (EG(exception)) {
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
@@ -1792,7 +1792,7 @@ PHP_METHOD(SoapServer, handle)
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");
}
if (EG(exception)) {
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
@@ -1824,7 +1824,7 @@ PHP_METHOD(SoapServer, handle)
}
#ifdef ZEND_ENGINE_2
if (EG(exception)) {
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
@@ -1904,14 +1904,14 @@ PHP_METHOD(SoapServer, handle)
Z_TYPE_PP(tmp) != IS_NULL) {
headerfault = *tmp;
}
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
soap_server_fault_ex(function, &h->retval, h TSRMLS_CC);
efree(fn_name);
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(&soap_obj);}
goto fail;
#ifdef ZEND_ENGINE_2
} else if (EG(exception)) {
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
zval *headerfault = NULL, **tmp;
@@ -1961,7 +1961,7 @@ PHP_METHOD(SoapServer, handle)
#ifdef ZEND_ENGINE_2
if (EG(exception)) {
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
@@ -1983,7 +1983,7 @@ PHP_METHOD(SoapServer, handle)
if (Z_TYPE_P(retval) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(retval), soap_fault_class_entry TSRMLS_CC)) {
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
soap_server_fault_ex(function, retval, NULL TSRMLS_CC);
goto fail;
}
@@ -2004,7 +2004,7 @@ PHP_METHOD(SoapServer, handle)
#ifdef ZEND_ENGINE_2
if (EG(exception)) {
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
@@ -2023,7 +2023,7 @@ PHP_METHOD(SoapServer, handle)
#endif
/* Flush buffer */
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
if (doc_return) {
/* xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); */
@@ -2041,39 +2041,14 @@ PHP_METHOD(SoapServer, handle)
xmlFreeDoc(doc_return);
- if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0) &&
- zend_hash_exists(EG(function_table), "ob_gzhandler", sizeof("ob_gzhandler"))) {
- zval nm_ob_gzhandler;
- zval str;
- zval mode;
- zval result;
- zval *params[2];
-
- INIT_ZVAL(result);
- ZVAL_STRINGL(&nm_ob_gzhandler, "ob_gzhandler", sizeof("ob_gzhandler") - 1, 0);
- INIT_PZVAL(&str);
- ZVAL_STRINGL(&str, (char*)buf, size, 0);
- params[0] = &str;
- INIT_PZVAL(&mode);
- ZVAL_LONG(&mode, PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END);
- params[1] = &mode;
- if (call_user_function(CG(function_table), NULL, &nm_ob_gzhandler, &result, 2, params TSRMLS_CC) != FAILURE &&
- Z_TYPE(result) == IS_STRING &&
- zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == SUCCESS) {
- xmlFree(buf);
- buf = NULL;
- snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", Z_STRLEN(result));
- sapi_add_header(cont_len, strlen(cont_len), 1);
- php_write(Z_STRVAL(result), Z_STRLEN(result) TSRMLS_CC);
- }
- zval_dtor(&result);
- }
- if (buf) {
+ if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
+ sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
+ } else {
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
sapi_add_header(cont_len, strlen(cont_len), 1);
- php_write(buf, size TSRMLS_CC);
- xmlFree(buf);
}
+ php_write(buf, size TSRMLS_CC);
+ xmlFree(buf);
} else {
sapi_add_header("HTTP/1.1 202 Accepted", sizeof("HTTP/1.1 202 Accepted")-1, 1);
sapi_add_header("Content-Length: 0", sizeof("Content-Length: 0")-1, 1);
@@ -2212,47 +2187,22 @@ static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeade
if (use_http_error_status) {
sapi_add_header("HTTP/1.1 500 Internal Service Error", sizeof("HTTP/1.1 500 Internal Service Error")-1, 1);
}
+ if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
+ sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
+ } else {
+ snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
+ sapi_add_header(cont_len, strlen(cont_len), 1);
+ }
if (soap_version == SOAP_1_2) {
sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);
} else {
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
}
- if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0) &&
- zend_hash_exists(EG(function_table), "ob_gzhandler", sizeof("ob_gzhandler"))) {
- zval nm_ob_gzhandler;
- zval str;
- zval mode;
- zval result;
- zval *params[2];
-
- INIT_ZVAL(result);
- ZVAL_STRINGL(&nm_ob_gzhandler, "ob_gzhandler", sizeof("ob_gzhandler") - 1, 0);
- INIT_PZVAL(&str);
- ZVAL_STRINGL(&str, (char*)buf, size, 0);
- params[0] = &str;
- INIT_PZVAL(&mode);
- ZVAL_LONG(&mode, PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END);
- params[1] = &mode;
- if (call_user_function(CG(function_table), NULL, &nm_ob_gzhandler, &result, 2, params TSRMLS_CC) != FAILURE &&
- Z_TYPE(result) == IS_STRING &&
- zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == SUCCESS) {
- xmlFree(buf);
- buf = NULL;
- snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", Z_STRLEN(result));
- sapi_add_header(cont_len, strlen(cont_len), 1);
- php_write(Z_STRVAL(result), Z_STRLEN(result) TSRMLS_CC);
- }
- zval_dtor(&result);
- }
- if (buf) {
- snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
- sapi_add_header(cont_len, strlen(cont_len), 1);
- php_write(buf, size TSRMLS_CC);
- xmlFree(buf);
- }
+ php_write(buf, size TSRMLS_CC);
xmlFreeDoc(doc_return);
+ xmlFree(buf);
zend_clear_exception(TSRMLS_C);
}
@@ -2415,11 +2365,11 @@ static void soap_error_handler(int error_num, const char *error_filename, const
}
/* Get output buffer and send as fault detials */
- if (php_ob_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0) {
+ if (php_output_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0) {
ALLOC_INIT_ZVAL(outbuf);
- php_ob_get_buffer(outbuf TSRMLS_CC);
+ php_output_get_contents(outbuf TSRMLS_CC);
}
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
}
INIT_ZVAL(fault_obj);
View
50 ext/standard/basic_functions.c
@@ -5055,7 +5055,7 @@ ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highl
PHP_FUNCTION(highlight_file)
{
char *filename;
- int filename_len;
+ int filename_len, ret;
zend_syntax_highlighter_ini syntax_highlighter_ini;
zend_bool i = 0;
@@ -5068,32 +5068,23 @@ PHP_FUNCTION(highlight_file)
}
if (i) {
- php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
+ php_output_start_default(TSRMLS_C);
}
php_get_highlight_struct(&syntax_highlighter_ini);
- if (highlight_file(filename, &syntax_highlighter_ini TSRMLS_CC) == FAILURE) {
- if (i) {
- int res = php_ob_get_buffer(return_value TSRMLS_CC);
+ ret = highlight_file(filename, &syntax_highlighter_ini TSRMLS_CC);
- /* flush the buffer only if there is something to flush */
- if (res == SUCCESS && Z_STRLEN_P(return_value) > 0) {
- php_end_ob_buffer (1, 0 TSRMLS_CC);
- zval_dtor(return_value);
- } else {
- php_end_ob_buffer (0, 0 TSRMLS_CC);
- if (res == SUCCESS) {
- zval_dtor(return_value);
- }
- }
+ if (ret == FAILURE) {
+ if (i) {
+ php_output_end(TSRMLS_C);
}
RETURN_FALSE;
}
if (i) {
- php_ob_get_buffer (return_value TSRMLS_CC);
- php_end_ob_buffer (0, 0 TSRMLS_CC);
+ php_output_get_contents(return_value TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
} else {
RETURN_TRUE;
}
@@ -5113,25 +5104,26 @@ PHP_FUNCTION(php_strip_whitespace)
RETURN_FALSE;
}
+ php_output_start_default(TSRMLS_C);
+
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = filename;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
zend_save_lexical_state(&original_lex_state TSRMLS_CC);
- if (open_file_for_scanning(&file_handle TSRMLS_CC)==FAILURE) {
+ if (open_file_for_scanning(&file_handle TSRMLS_CC) == FAILURE) {
zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
+ php_output_end(TSRMLS_C);
RETURN_EMPTY_STRING();
}
- php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
-
zend_strip(TSRMLS_C);
zend_destroy_file_handle(&file_handle TSRMLS_CC);
zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
- php_ob_get_buffer(return_value TSRMLS_CC);
- php_end_ob_buffer(0, 0 TSRMLS_CC);
+ php_output_get_contents(return_value TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
}
/* }}} */
@@ -5151,7 +5143,7 @@ PHP_FUNCTION(highlight_string)
convert_to_string_ex(expr);
if (i) {
- php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
+ php_output_start_default(TSRMLS_C);
}
EG(error_reporting) = E_ERROR;
@@ -5164,7 +5156,7 @@ PHP_FUNCTION(highlight_string)
efree(hicompiled_string_description);
EG(error_reporting) = old_error_reporting;
if (i) {
- php_end_ob_buffer (1, 0 TSRMLS_CC);
+ php_output_end(TSRMLS_C);
}
RETURN_FALSE;
}
@@ -5173,8 +5165,8 @@ PHP_FUNCTION(highlight_string)
EG(error_reporting) = old_error_reporting;
if (i) {
- php_ob_get_buffer (return_value TSRMLS_CC);
- php_end_ob_buffer (0, 0 TSRMLS_CC);
+ php_output_get_contents(return_value TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
} else {
RETURN_TRUE;
}
@@ -5416,14 +5408,14 @@ PHP_FUNCTION(print_r)
}
if (do_return) {
- php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
+ php_output_start_default(TSRMLS_C);
}
zend_print_zval_r(var, 0 TSRMLS_CC);
if (do_return) {
- php_ob_get_buffer (return_value TSRMLS_CC);
- php_end_ob_buffer (0, 0 TSRMLS_CC);
+ php_output_get_contents(return_value TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
} else {
RETURN_TRUE;
}
View
4 ext/standard/exec.c
@@ -108,8 +108,10 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
}
if (type == 1) {
+ int ob_level;
+
PHPWRITE(buf, bufl);
- if (OG(ob_nesting_level) < 1) {
+ if (php_output_get_level(TSRMLS_C) < 1) {
sapi_flush(TSRMLS_C);
}
} else if (type == 2) {
View
4 ext/standard/head.c
@@ -228,8 +228,8 @@ PHP_FUNCTION(headers_sent)
return;
if (SG(headers_sent)) {
- line = php_get_output_start_lineno(TSRMLS_C);
- file = php_get_output_start_filename(TSRMLS_C);
+ line = php_output_get_start_lineno(TSRMLS_C);
+ file = php_output_get_start_filename(TSRMLS_C);
}
switch(ZEND_NUM_ARGS()) {
View
599 ext/standard/info.c
@@ -38,16 +38,15 @@
#include <sys/utsname.h>
#endif
+
#ifdef PHP_WIN32
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
-
# include "winver.h"
-#if _MSC_VER < 1300
-# define OSVERSIONINFOEX php_win_OSVERSIONINFOEX
-#endif
-
+# if _MSC_VER < 1300
+# define OSVERSIONINFOEX php_win_OSVERSIONINFOEX
+# endif
#endif
#if HAVE_MBSTRING
@@ -61,7 +60,7 @@ ZEND_EXTERN_MODULE_GLOBALS(iconv)
#endif
#define SECTION(name) if (!sapi_module.phpinfo_as_text) { \
- PUTS("<h2>" name "</h2>\n"); \
+ php_info_print("<h2>" name "</h2>\n"); \
} else { \
php_info_print_table_start(); \
php_info_print_table_header(1, name); \
@@ -71,29 +70,99 @@ ZEND_EXTERN_MODULE_GLOBALS(iconv)
PHPAPI extern char *php_ini_opened_path;
PHPAPI extern char *php_ini_scanned_path;
PHPAPI extern char *php_ini_scanned_files;
-
-static int php_info_write_wrapper(const char *str, uint str_length)
+
+static int php_info_print_html_esc(const char *str, int len) /* {{{ */
{
int new_len, written;
- char *elem_esc;
+ char *new_str;
+ TSRMLS_FETCH();
+
+ new_str = php_escape_html_entities((char *) str, len, &new_len, 0, ENT_QUOTES, "utf-8" TSRMLS_CC);
+ written = php_output_write(new_str, new_len TSRMLS_CC);
+ efree(new_str);
+ return written;
+}
+/* }}} */
+static int php_info_printf(const char *fmt, ...) /* {{{ */
+{
+ char *buf;
+ int len, written;
+ va_list argv;
TSRMLS_FETCH();
+
+ va_start(argv, fmt);
+ len = vspprintf(&buf, 0, fmt, argv);
+ va_end(argv);
+
+ written = php_output_write(buf, len TSRMLS_CC);
+ efree(buf);
+ return written;
+}
+/* }}} */
- elem_esc = php_escape_html_entities((unsigned char *)str, str_length, &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
+static void php_info_print_request_uri(TSRMLS_D) /* {{{ */
+{
+ if (SG(request_info).request_uri) {
+ php_info_print_html_esc(SG(request_info).request_uri, strlen(SG(request_info).request_uri));
+ }
+}
+/* }}} */
- written = php_body_write(elem_esc, new_len TSRMLS_CC);
+static int php_info_print(const char *str) /* {{{ */
+{
+ TSRMLS_FETCH();
+ return php_output_write(str, strlen(str) TSRMLS_CC);
+}
+/* }}} */
- efree(elem_esc);
+static void php_info_print_stream_hash(const char *name, HashTable *ht TSRMLS_DC) /* {{{ */
+{
+ char *key;
+ uint len;
+ int type;
+
+ if (ht) {
+ if (zend_hash_num_elements(ht)) {
+ HashPosition pos;
- return written;
+ if (!sapi_module.phpinfo_as_text) {
+ php_info_printf("<tr class=\"v\"><td>Registered %s</td><td>", name);
+ } else {
+ php_info_printf("\nRegistered %s => ", name);
+ }
+
+ zend_hash_internal_pointer_reset_ex(ht, &pos);
+ while (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING)
+ {
+ php_info_print(key);
+ zend_hash_move_forward_ex(ht, &pos);
+ if (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
+ php_info_print(", ");
+ } else {
+ break;
+ }
+ }
+
+ if (!sapi_module.phpinfo_as_text) {
+ php_info_print("</td></tr>\n");
+ }
+ } else {
+ char reg_name[128];
+ snprintf(reg_name, sizeof(reg_name), "Registered %s", name);
+ php_info_print_table_row(2, reg_name, "none registered");
+ }
+ } else {
+ php_info_print_table_row(2, name, "disabled");
+ }
}
-
+/* }}} */
PHPAPI void php_info_print_module(zend_module_entry *zend_module TSRMLS_DC) /* {{{ */
{
if (zend_module->info_func || zend_module->version) {
if (!sapi_module.phpinfo_as_text) {
- php_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", zend_module->name, zend_module->name);
+ php_info_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", zend_module->name, zend_module->name);
} else {
php_info_print_table_start();
php_info_print_table_header(1, zend_module->name);
@@ -109,9 +178,9 @@ PHPAPI void php_info_print_module(zend_module_entry *zend_module TSRMLS_DC) /* {
}
} else {
if (!sapi_module.phpinfo_as_text) {
- php_printf("<tr><td>%s</td></tr>\n", zend_module->name);
+ php_info_printf("<tr><td>%s</td></tr>\n", zend_module->name);
} else {
- php_printf("%s\n", zend_module->name);
+ php_info_printf("%s\n", zend_module->name);
}
}
}
@@ -151,70 +220,66 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data));
while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) {
if (!sapi_module.phpinfo_as_text) {
- PUTS("<tr>");
- PUTS("<td class=\"e\">");
-
+ php_info_print("<tr>");
+ php_info_print("<td class=\"e\">");
}
- PUTS(name);
- PUTS("[\"");
+ php_info_print(name);
+ php_info_print("[\"");
switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) {
case HASH_KEY_IS_STRING:
if (!sapi_module.phpinfo_as_text) {
- php_info_html_esc_write(string_key, string_len - 1 TSRMLS_CC);
+ php_info_print_html_esc(string_key, string_len-1);
} else {
- PHPWRITE(string_key, string_len - 1);
- }
+ php_info_print(string_key);
+ }
break;
case HASH_KEY_IS_LONG:
- php_printf("%ld", num_key);
+ php_info_printf("%ld", num_key);
break;
}
- PUTS("\"]");
+ php_info_print("\"]");
if (!sapi_module.phpinfo_as_text) {
- PUTS("</td><td class=\"v\">");
+ php_info_print("</td><td class=\"v\">");
} else {
- PUTS(" => ");
+ php_info_print(" => ");
}
if (Z_TYPE_PP(tmp) == IS_ARRAY) {
if (!sapi_module.phpinfo_as_text) {
- PUTS("<pre>");
- zend_print_zval_r_ex((zend_write_func_t) php_info_write_wrapper, *tmp, 0 TSRMLS_CC);
- PUTS("</pre>");
+ php_info_print("<pre>");
+ zend_print_zval_r_ex((zend_write_func_t) php_info_print_html_esc, *tmp, 0 TSRMLS_CC);
+ php_info_print("</pre>");
} else {
zend_print_zval_r(*tmp, 0 TSRMLS_CC);
}
- } else if (Z_TYPE_PP(tmp) != IS_STRING) {
- tmp2 = **tmp;
- zval_copy_ctor(&tmp2);
- convert_to_string(&tmp2);
- if (!sapi_module.phpinfo_as_text) {
- if (Z_STRLEN(tmp2) == 0) {
- PUTS("<i>no value</i>");
- } else {
- php_info_html_esc_write(Z_STRVAL(tmp2), Z_STRLEN(tmp2) TSRMLS_CC);
- }
- } else {
- PHPWRITE(Z_STRVAL(tmp2), Z_STRLEN(tmp2));
- }
- zval_dtor(&tmp2);
} else {
- if (!sapi_module.phpinfo_as_text) {
- if (Z_STRLEN_PP(tmp) == 0) {
- PUTS("<i>no value</i>");
- } else {
- php_info_html_esc_write(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp) TSRMLS_CC);
- }
- } else {
- PHPWRITE(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
- }
+ tmp2 = **tmp;
+ switch (Z_TYPE_PP(tmp)) {
+ default:
+ tmp = NULL;
+ zval_copy_ctor(&tmp2);
+ convert_to_string(&tmp2);
+ case IS_STRING:
+ if (!sapi_module.phpinfo_as_text) {
+ if (Z_STRLEN(tmp2) == 0) {
+ php_info_print("<i>no value</i>");
+ } else {
+ php_info_print_html_esc(Z_STRVAL(tmp2), Z_STRLEN(tmp2));
+ }
+ } else {
+ php_info_print(Z_STRVAL(tmp2));
+ }
+ }
+ if (!tmp) {
+ zval_dtor(&tmp2);
+ }
}
if (!sapi_module.phpinfo_as_text) {
- PUTS("</td></tr>\n");
+ php_info_print("</td></tr>\n");
} else {
- PUTS("\n");
- }
+ php_info_print("\n");
+ }
zend_hash_move_forward(Z_ARRVAL_PP(data));
}
}
@@ -225,21 +290,9 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
*/
void php_info_print_style(TSRMLS_D)
{
- php_printf("<style type=\"text/css\">\n");
+ php_info_printf("<style type=\"text/css\">\n");
php_info_print_css(TSRMLS_C);
- php_printf("</style>\n");
-}
-/* }}} */
-
-/* {{{ php_info_html_esc_write
- */
-PHPAPI void php_info_html_esc_write(char *string, int str_len TSRMLS_DC)
-{
- int new_len;
- char *ret = php_escape_html_entities((unsigned char *)string, str_len, &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
-
- PHPWRITE(ret, new_len);
- efree(ret);
+ php_info_printf("</style>\n");
}
/* }}} */
@@ -248,13 +301,13 @@ PHPAPI void php_info_html_esc_write(char *string, int str_len TSRMLS_DC)
PHPAPI char *php_info_html_esc(char *string TSRMLS_DC)
{
int new_len;
- return php_escape_html_entities((unsigned char *)string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
+ return php_escape_html_entities(string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
}
/* }}} */
-
#ifdef PHP_WIN32
/* {{{ */
+
char* php_get_windows_name()
{
OSVERSIONINFOEX osvi;
@@ -360,9 +413,9 @@ char* php_get_windows_name()
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) {
if (GetSystemMetrics(SM_SERVERR2))
major = "Windows Server 2003 R2";
- else if (osvi.wSuiteMask == VER_SUITE_STORAGE_SERVER)
+ else if (osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER)
major = "Windows Storage Server 2003";
- else if (osvi.wSuiteMask == VER_SUITE_WH_SERVER)
+ else if (osvi.wSuiteMask==VER_SUITE_WH_SERVER)
major = "Windows Home Server";
else if (osvi.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) {
@@ -588,54 +641,18 @@ PHPAPI char *php_get_uname(char mode)
}
/* }}} */
-
/* {{{ php_print_info_htmlhead
*/
PHPAPI void php_print_info_htmlhead(TSRMLS_D)
{
-
-/*** none of this is needed now ***
-
- const char *charset = NULL;
-
- if (SG(default_charset)) {
- charset = SG(default_charset);
- }
-
-#if HAVE_MBSTRING
- if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) {
- if (MBSTRG(current_http_output_encoding) == mbfl_no_encoding_pass) {
- charset = "US-ASCII";
- } else {
- charset = mbfl_no2preferred_mime_name(MBSTRG(current_http_output_encoding));
- }
- }
-#endif
-
-#if HAVE_ICONV
- if (php_ob_handler_used("ob_iconv_handler" TSRMLS_CC)) {
- charset = ICONVG(output_encoding);
- }
-#endif
-
- if (!charset || !charset[0]) {
- charset = "US-ASCII";
- }
-
-*** none of that is needed now ***/
-
-
- PUTS("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n");
- PUTS("<html>");
- PUTS("<head>\n");
+ php_info_print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n");
+ php_info_print("<html>");
+ php_info_print("<head>\n");
php_info_print_style(TSRMLS_C);
- PUTS("<title>phpinfo()</title>");
- PUTS("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />");
-/*
- php_printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />\n", charset);
-*/
- PUTS("</head>\n");
- PUTS("<body><div class=\"center\">\n");
+ php_info_print("<title>phpinfo()</title>");
+ php_info_print("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />");
+ php_info_print("</head>\n");
+ php_info_print("<body><div class=\"center\">\n");
}
/* }}} */
@@ -661,8 +678,8 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
if (!sapi_module.phpinfo_as_text) {
php_print_info_htmlhead(TSRMLS_C);
} else {
- PUTS("phpinfo()\n");
- }
+ php_info_print("phpinfo()\n");
+ }
if (flag & PHP_INFO_GENERAL) {
char *zend_version = get_zend_version();
@@ -676,21 +693,17 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
}
if (expose_php && !sapi_module.phpinfo_as_text) {
- PUTS("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
- if (SG(request_info).request_uri) {
- char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
- PUTS(elem_esc);
- efree(elem_esc);
- }
- PUTS("?=");
+ php_info_print("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
+ php_info_print_request_uri(TSRMLS_C);
+ php_info_print("?=");
logo_guid = php_logo_guid();
- PUTS(logo_guid);
+ php_info_print(logo_guid);
efree(logo_guid);
- PUTS("\" alt=\"PHP Logo\" /></a>");
+ php_info_print("\" alt=\"PHP Logo\" /></a>");
}
if (!sapi_module.phpinfo_as_text) {
- php_printf("<h1 class=\"p\">PHP Version %s</h1>\n", PHP_VERSION);
+ php_info_printf("<h1 class=\"p\">PHP Version %s</h1>\n", PHP_VERSION);
} else {
php_info_print_table_row(2, "PHP Version", PHP_VERSION);
}
@@ -766,139 +779,24 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
#else
php_info_print_table_row(2, "DTrace Support", "disabled" );
#endif
- {
- HashTable *url_stream_wrappers_hash;
- char *stream_protocol, *stream_protocols_buf = NULL;
- int stream_protocol_len, stream_protocols_buf_len = 0;
- ulong num_key;
-
- if ((url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash())) {
- HashPosition pos;
- for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos);
- zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, (uint *)&stream_protocol_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING;
- zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) {
- stream_protocols_buf = erealloc(stream_protocols_buf, stream_protocols_buf_len + stream_protocol_len + 2 + 1);
- memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len - 1);
- stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len - 1] = ',';
- stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len] = ' ';
- stream_protocols_buf_len += stream_protocol_len + 1;
- }
- if (stream_protocols_buf) {
- stream_protocols_buf[stream_protocols_buf_len - 2] = ' ';
- stream_protocols_buf[stream_protocols_buf_len] = 0;
- php_info_print_table_row(2, "Registered PHP Streams", stream_protocols_buf);
- efree(stream_protocols_buf);
- } else {
- /* Any chances we will ever hit this? */
- php_info_print_table_row(2, "Registered PHP Streams", "no streams registered");
- }
- } else {
- /* Any chances we will ever hit this? */
- php_info_print_table_row(2, "PHP Streams", "disabled"); /* ?? */
- }
- }
-
- {
- HashTable *stream_xport_hash;
- char *xport_name, *xport_buf = NULL;
- int xport_name_len, xport_buf_len = 0, xport_buf_size = 0;
- ulong num_key;
-
- if ((stream_xport_hash = php_stream_xport_get_hash())) {
- HashPosition pos;
- for(zend_hash_internal_pointer_reset_ex(stream_xport_hash, &pos);
- zend_hash_get_current_key_ex(stream_xport_hash, &xport_name, (uint *)&xport_name_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING;
- zend_hash_move_forward_ex(stream_xport_hash, &pos)) {
- if (xport_buf_len + xport_name_len + 2 > xport_buf_size) {
- while (xport_buf_len + xport_name_len + 2 > xport_buf_size) {
- xport_buf_size += 256;
- }
- if (xport_buf) {
- xport_buf = erealloc(xport_buf, xport_buf_size);
- } else {
- xport_buf = emalloc(xport_buf_size);
- }
- }
- if (xport_buf_len > 0) {
- xport_buf[xport_buf_len++] = ',';
- xport_buf[xport_buf_len++] = ' ';
- }
- memcpy(xport_buf + xport_buf_len, xport_name, xport_name_len - 1);
- xport_buf_len += xport_name_len - 1;
- xport_buf[xport_buf_len] = '\0';
- }
- if (xport_buf) {
- php_info_print_table_row(2, "Registered Stream Socket Transports", xport_buf);
- efree(xport_buf);
- } else {
- /* Any chances we will ever hit this? */
- php_info_print_table_row(2, "Registered Stream Socket Transports", "no transports registered");
- }
- } else {
- /* Any chances we will ever hit this? */
- php_info_print_table_row(2, "Stream Socket Transports", "disabled"); /* ?? */
- }
- }
-
- {
- HashTable *stream_filter_hash;
- char *filter_name, *filter_buf = NULL;
- int filter_name_len, filter_buf_len = 0, filter_buf_size = 0;
- ulong num_key;
-
- if ((stream_filter_hash = php_get_stream_filters_hash())) {
- HashPosition pos;
- for(zend_hash_internal_pointer_reset_ex(stream_filter_hash, &pos);
- zend_hash_get_current_key_ex(stream_filter_hash, &filter_name, (uint *)&filter_name_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING;
- zend_hash_move_forward_ex(stream_filter_hash, &pos)) {
- if (filter_buf_len + filter_name_len + 2 > filter_buf_size) {
- while (filter_buf_len + filter_name_len + 2 > filter_buf_size) {
- filter_buf_size += 256;
- }
- if (filter_buf) {
- filter_buf = erealloc(filter_buf, filter_buf_size);
- } else {
- filter_buf = emalloc(filter_buf_size);
- }
- }
- if (filter_buf_len > 0) {
- filter_buf[filter_buf_len++] = ',';
- filter_buf[filter_buf_len++] = ' ';
- }
- memcpy(filter_buf + filter_buf_len, filter_name, filter_name_len - 1);
- filter_buf_len += filter_name_len - 1;
- filter_buf[filter_buf_len] = '\0';
- }
- if (filter_buf) {
- php_info_print_table_row(2, "Registered Stream Filters", filter_buf);
- efree(filter_buf);
- } else {
- /* Any chances we will ever hit this? */
- php_info_print_table_row(2, "Registered Stream Filters", "no filters registered");
- }
- } else {
- /* Any chances we will ever hit this? */
- php_info_print_table_row(2, "Stream Filters", "disabled"); /* ?? */
- }
- }
+ php_info_print_stream_hash("PHP Streams", php_stream_get_url_stream_wrappers_hash() TSRMLS_CC);
+ php_info_print_stream_hash("Stream Socket Transports", php_stream_xport_get_hash() TSRMLS_CC);
+ php_info_print_stream_hash("Stream Filters", php_get_stream_filters_hash() TSRMLS_CC);
+
php_info_print_table_end();
/* Zend Engine */
php_info_print_box_start(0);
if (expose_php && !sapi_module.phpinfo_as_text) {
- PUTS("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
- if (SG(request_info).request_uri) {
- char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
- PUTS(elem_esc);
- efree(elem_esc);
- }
- PUTS("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n");
+ php_info_print("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
+ php_info_print_request_uri(TSRMLS_C);
+ php_info_print("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n");
}
- PUTS("This program makes use of the Zend Scripting Language Engine:");
- PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
+ php_info_print("This program makes use of the Zend Scripting Language Engine:");
+ php_info_print(!sapi_module.phpinfo_as_text?"<br />":"\n");
if (sapi_module.phpinfo_as_text) {
- PUTS(zend_version);
+ php_info_print(zend_version);
} else {
zend_html_puts(zend_version, strlen(zend_version) TSRMLS_CC);
}
@@ -908,15 +806,11 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
if ((flag & PHP_INFO_CREDITS) && expose_php && !sapi_module.phpinfo_as_text) {
php_info_print_hr();
- PUTS("<h1><a href=\"");
- if (SG(request_info).request_uri) {
- char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
- PUTS(elem_esc);
- efree(elem_esc);
- }
- PUTS("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">");
- PUTS("PHP Credits");
- PUTS("</a></h1>\n");
+ php_info_print("<h1><a href=\"");
+ php_info_print_request_uri(TSRMLS_C);
+ php_info_print("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">");
+ php_info_print("PHP Credits");
+ php_info_print("</a></h1>\n");
}
zend_ini_sort_entries(TSRMLS_C);
@@ -924,7 +818,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
if (flag & PHP_INFO_CONFIGURATION) {
php_info_print_hr();
if (!sapi_module.phpinfo_as_text) {
- PUTS("<h1>Configuration</h1>\n");
+ php_info_print("<h1>Configuration</h1>\n");
} else {
SECTION("Configuration");
}
@@ -1004,103 +898,108 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
if (!sapi_module.phpinfo_as_text) {
SECTION("PHP License");
php_info_print_box_start(0);
- PUTS("<p>\n");
- PUTS("This program is free software; you can redistribute it and/or modify ");
- PUTS("it under the terms of the PHP License as published by the PHP Group ");
- PUTS("and included in the distribution in the file: LICENSE\n");
- PUTS("</p>\n");
- PUTS("<p>");
- PUTS("This program is distributed in the hope that it will be useful, ");
- PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of ");
- PUTS("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
- PUTS("</p>\n");
- PUTS("<p>");
- PUTS("If you did not receive a copy of the PHP license, or have any questions about ");
- PUTS("PHP licensing, please contact license@php.net.\n");
- PUTS("</p>\n");
+ php_info_print("<p>\n");
+ php_info_print("This program is free software; you can redistribute it and/or modify ");
+ php_info_print("it under the terms of the PHP License as published by the PHP Group ");
+ php_info_print("and included in the distribution in the file: LICENSE\n");
+ php_info_print("</p>\n");
+ php_info_print("<p>");
+ php_info_print("This program is distributed in the hope that it will be useful, ");
+ php_info_print("but WITHOUT ANY WARRANTY; without even the implied warranty of ");
+ php_info_print("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
+ php_info_print("</p>\n");
+ php_info_print("<p>");
+ php_info_print("If you did not receive a copy of the PHP license, or have any questions about ");
+ php_info_print("PHP licensing, please contact license@php.net.\n");
+ php_info_print("</p>\n");
php_info_print_box_end();
} else {
- PUTS("\nPHP License\n");
- PUTS("This program is free software; you can redistribute it and/or modify\n");
- PUTS("it under the terms of the PHP License as published by the PHP Group\n");
- PUTS("and included in the distribution in the file: LICENSE\n");
- PUTS("\n");
- PUTS("This program is distributed in the hope that it will be useful,\n");
- PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
- PUTS("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
- PUTS("\n");
- PUTS("If you did not receive a copy of the PHP license, or have any\n");
- PUTS("questions about PHP licensing, please contact license@php.net.\n");
+ php_info_print("\nPHP License\n");
+ php_info_print("This program is free software; you can redistribute it and/or modify\n");
+ php_info_print("it under the terms of the PHP License as published by the PHP Group\n");
+ php_info_print("and included in the distribution in the file: LICENSE\n");
+ php_info_print("\n");
+ php_info_print("This program is distributed in the hope that it will be useful,\n");
+ php_info_print("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
+ php_info_print("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
+ php_info_print("\n");
+ php_info_print("If you did not receive a copy of the PHP license, or have any\n");
+ php_info_print("questions about PHP licensing, please contact license@php.net.\n");
}
}
if (!sapi_module.phpinfo_as_text) {
- PUTS("</div></body></html>");
+ php_info_print("</div></body></html>");
}
}
/* }}} */
-
-PHPAPI void php_info_print_table_start(void)
+PHPAPI void php_info_print_table_start(void) /* {{{ */
{
if (!sapi_module.phpinfo_as_text) {
- php_printf("<table border=\"0\" cellpadding=\"3\" width=\"600\">\n");
+ php_info_print("<table border=\"0\" cellpadding=\"3\" width=\"600\">\n");
} else {
- php_printf("\n");
+ php_info_print("\n");
}
}
+/* }}} */
-PHPAPI void php_info_print_table_end(void)
+PHPAPI void php_info_print_table_end(void) /* {{{ */
{
if (!sapi_module.phpinfo_as_text) {
- php_printf("</table><br />\n");
+ php_info_print("</table><br />\n");
}
}
+/* }}} */
-PHPAPI void php_info_print_box_start(int flag)
+PHPAPI void php_info_print_box_start(int flag) /* {{{ */
{
php_info_print_table_start();
if (flag) {
if (!sapi_module.phpinfo_as_text) {
- php_printf("<tr class=\"h\"><td>\n");
+ php_info_print("<tr class=\"h\"><td>\n");
}
} else {
if (!sapi_module.phpinfo_as_text) {
- php_printf("<tr class=\"v\"><td>\n");
+ php_info_print("<tr class=\"v\"><td>\n");
} else {
- php_printf("\n");
+ php_info_print("\n");
}
}
}
+/* }}} */
-PHPAPI void php_info_print_box_end(void)
+PHPAPI void php_info_print_box_end(void) /* {{{ */
{
if (!sapi_module.phpinfo_as_text) {
- php_printf("</td></tr>\n");
+ php_info_print("</td></tr>\n");
}
php_info_print_table_end();
}
+/* }}} */
-PHPAPI void php_info_print_hr(void)
+PHPAPI void php_info_print_hr(void) /* {{{ */
{
if (!sapi_module.phpinfo_as_text) {
- php_printf("<hr />\n");
+ php_info_print("<hr />\n");
} else {
- php_printf("\n\n _______________________________________________________________________\n\n");
+ php_info_print("\n\n _______________________________________________________________________\n\n");
}
}
+/* }}} */
-PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header)
+PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header) /* {{{ */
{
int spaces;
if (!sapi_module.phpinfo_as_text) {
- php_printf("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\n", num_cols, header );
+ php_info_printf("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\n", num_cols, header );
} else {
spaces = (74 - strlen(header));
- php_printf("%*s%s%*s\n", (int)(spaces/2), " ", header, (int)(spaces/2), " ");
+ php_info_printf("%*s%s%*s\n", (int)(spaces/2), " ", header, (int)(spaces/2), " ");
}
}
+/* }}} */
/* {{{ php_info_print_table_header
*/
@@ -1110,11 +1009,9 @@ PHPAPI void php_info_print_table_header(int num_cols, ...)
va_list row_elements;
char *row_element;
- TSRMLS_FETCH();
-
va_start(row_elements, num_cols);
if (!sapi_module.phpinfo_as_text) {
- php_printf("<tr class=\"h\">");
+ php_info_print("<tr class=\"h\">");
}
for (i=0; i<num_cols; i++) {
row_element = va_arg(row_elements, char *);
@@ -1122,21 +1019,21 @@ PHPAPI void php_info_print_table_header(int num_cols, ...)
row_element = " ";
}
if (!sapi_module.phpinfo_as_text) {
- PUTS("<th>");
- PUTS(row_element);
- PUTS("</th>");
+ php_info_print("<th>");
+ php_info_print(row_element);
+ php_info_print("</th>");
} else {
- PUTS(row_element);
+ php_info_print(row_element);
if (i < num_cols-1) {
- PUTS(" => ");
+ php_info_print(" => ");
} else {
- PUTS("\n");
- }
- }
+ php_info_print("\n");
+ }
+ }
}
if (!sapi_module.phpinfo_as_text) {
- php_printf("</tr>\n");
- }
+ php_info_print("</tr>\n");
+ }
va_end(row_elements);
}
@@ -1149,49 +1046,41 @@ static void php_info_print_table_row_internal(int num_cols,
{
int i;
char *row_element;
- char *elem_esc = NULL;
-/*
- int elem_esc_len;
-*/
-
- TSRMLS_FETCH();
if (!sapi_module.phpinfo_as_text) {
- php_printf("<tr>");
+ php_info_print("<tr>");
}
for (i=0; i<num_cols; i++) {
if (!sapi_module.phpinfo_as_text) {
- php_printf("<td class=\"%s\">",
+ php_info_printf("<td class=\"%s\">",
(i==0 ? "e" : value_class )
);
}
row_element = va_arg(row_elements, char *);
if (!row_element || !*row_element) {
if (!sapi_module.phpinfo_as_text) {
- PUTS( "<i>no value</i>" );
+ php_info_print( "<i>no value</i>" );
} else {
- PUTS( " " );
+ php_info_print( " " );
}
} else {
if (!sapi_module.phpinfo_as_text) {
- elem_esc = php_info_html_esc(row_element TSRMLS_CC);
- PUTS(elem_esc);
- efree(elem_esc);
+ php_info_print_html_esc(row_element, strlen(row_element));
} else {
- PUTS(row_element);
+ php_info_print(row_element);
if (i < num_cols-1) {
- PUTS(" => ");
+ php_info_print(" => ");
}
}
}
if (!sapi_module.phpinfo_as_text) {
- php_printf(" </td>");
+ php_info_print(" </td>");
} else if (i == (num_cols - 1)) {
- PUTS("\n");
+ php_info_print("\n");
}
}
if (!sapi_module.phpinfo_as_text) {
- php_printf("</tr>\n");
+ php_info_print("</tr>\n");
}
}
/* }}} */
@@ -1255,9 +1144,9 @@ PHP_FUNCTION(phpinfo)
}
/* Andale! Andale! Yee-Hah! */
- php_start_ob_buffer(NULL, 4096, 0 TSRMLS_CC);
+ php_output_start_default(TSRMLS_C);
php_print_info(flag TSRMLS_CC);
- php_end_ob_buffer(1, 0 TSRMLS_CC);
+ php_output_end(TSRMLS_C);
RETURN_TRUE;
}
@@ -1268,20 +1157,18 @@ PHP_FUNCTION(phpinfo)
Return the current PHP version */
PHP_FUNCTION(phpversion)
{
- zval **arg;
- const char *version;
- int argc = ZEND_NUM_ARGS();
+ char *ext_name = NULL;
+ int ext_name_len = 0;
- if (argc == 0) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &ext_name, &ext_name_len) == FAILURE) {
+ return;
+ }
+
+ if (!ext_name) {
RETURN_STRING(PHP_VERSION, 1);
} else {
- if (zend_parse_parameters(argc TSRMLS_CC, "Z", &arg) == FAILURE) {
- return;
- }
-
- convert_to_string_ex(arg);
- version = zend_get_module_version(Z_STRVAL_PP(arg));
-
+ const char *version;
+ version = zend_get_module_version(ext_name);
if (version == NULL) {
RETURN_FALSE;
}
@@ -1305,7 +1192,6 @@ PHP_FUNCTION(phpcredits)
}
/* }}} */
-
/* {{{ php_logo_guid
*/
PHPAPI char *php_logo_guid(void)
@@ -1333,7 +1219,6 @@ PHPAPI char *php_logo_guid(void)
Return the special ID used to request the PHP logo in phpinfo screens*/
PHP_FUNCTION(php_logo_guid)
{
-
if (zend_parse_parameters_none() == FAILURE) {
return;
}
@@ -1346,7 +1231,6 @@ PHP_FUNCTION(php_logo_guid)
Return the special ID used to request the PHP logo in phpinfo screens*/
PHP_FUNCTION(php_real_logo_guid)
{
-
if (zend_parse_parameters_none() == FAILURE) {
return;
}
@@ -1402,6 +1286,7 @@ PHP_FUNCTION(php_uname)
{
char *mode = "a";
int modelen = sizeof("a")-1;
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) {
return;
}
View
2  ext/standard/tests/general_functions/ob_get_flush_error.phpt
@@ -26,5 +26,7 @@ var_dump( ob_get_flush() );
Warning: ob_get_flush() expects exactly 0 parameters, 1 given in %s on line %d
NULL
+
+Notice: ob_get_flush(): failed to delete and flush buffer. No buffer to delete or flush in %s on line %d
bool(false)
===DONE===
View
8 ext/standard/url_scanner_ex.c
@@ -1,8 +1,8 @@
-/* Generated by re2c 0.13.5 on Mon Jul 27 02:20:40 2009 */
+/* Generated by re2c 0.13.5 on Mon May 31 11:07:50 2010 */
#line 1 "ext/standard/url_scanner_ex.re"
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 6 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
@@ -993,7 +993,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char *
size_t len;
if (BG(url_adapt_state_ex).url_app.len != 0) {
- *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT) ? 1 : 0) TSRMLS_CC);
+ *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0) TSRMLS_CC);
if (sizeof(uint) < sizeof(size_t)) {
if (len > UINT_MAX)
len = UINT_MAX;
@@ -1027,7 +1027,7 @@ PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int va
if (! BG(url_adapt_state_ex).active) {
php_url_scanner_ex_activate(TSRMLS_C);
- php_ob_set_internal_handler(php_url_scanner_output_handler, 0, "URL-Rewriter", 1 TSRMLS_CC);
+ php_output_start_internal(ZEND_STRL("URL-Rewriter"), php_url_scanner_output_handler, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC);
BG(url_adapt_state_ex).active = 1;
}
View
6 ext/standard/url_scanner_ex.re
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 6 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
@@ -431,7 +431,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char *
size_t len;
if (BG(url_adapt_state_ex).url_app.len != 0) {
- *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT) ? 1 : 0) TSRMLS_CC);
+ *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0) TSRMLS_CC);
if (sizeof(uint) < sizeof(size_t)) {
if (len > UINT_MAX)
len = UINT_MAX;
@@ -465,7 +465,7 @@ PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int va
if (! BG(url_adapt_state_ex).active) {
php_url_scanner_ex_activate(TSRMLS_C);
- php_ob_set_internal_handler(php_url_scanner_output_handler, 0, "URL-Rewriter", 1 TSRMLS_CC);
+ php_output_start_internal(ZEND_STRL("URL-Rewriter"), php_url_scanner_output_handler, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC);
BG(url_adapt_state_ex).active = 1;
}
View
6 ext/standard/var.c
@@ -456,14 +456,14 @@ PHP_FUNCTION(var_export)
}
if (return_output) {
- php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
+ php_output_start_default(TSRMLS_C);
}
php_var_export(&var, 1 TSRMLS_CC);
if (return_output) {
- php_ob_get_buffer (return_value TSRMLS_CC);
- php_end_ob_buffer (0, 0 TSRMLS_CC);
+ php_output_get_contents(return_value TSRMLS_CC);
+ php_output_discard(TSRMLS_C);
}
}
/* }}} */
View
1  ext/tidy/php_tidy.h
@@ -36,6 +36,7 @@ extern zend_module_entry tidy_module_entry;
ZEND_BEGIN_MODULE_GLOBALS(tidy)
char *default_config;
+ zend_bool clean_output;
ZEND_END_MODULE_GLOBALS(tidy)
#ifdef ZTS
View
254 ext/tidy/tidy.c
@@ -42,6 +42,8 @@
/* {{{ ext/tidy macros
*/
+#define FIX_BUFFER(bptr) do { if ((bptr)->size) { (bptr)->bp[(bptr)->size-1] = '\0'; } } while(0)
+
#define TIDY_SET_CONTEXT \
zval *object = getThis();
@@ -186,16 +188,16 @@ typedef enum {
} tidy_base_nodetypes;
struct _PHPTidyDoc {
- TidyDoc doc;
- TidyBuffer *errbuf;
- unsigned int ref_count;
+ TidyDoc doc;
+ TidyBuffer *errbuf;
+ unsigned int ref_count;
};
struct _PHPTidyObj {
- zend_object std;
- TidyNode node;
- tidy_obj_type type;
- PHPTidyDoc *ptdoc;
+ zend_object std;
+ TidyNode node;
+ tidy_obj_type type;
+ PHPTidyDoc *ptdoc;
};
/* }}} */
@@ -216,6 +218,10 @@ static int _php_tidy_set_tidy_opt(TidyDoc, char *, zval * TSRMLS_DC);
static int _php_tidy_apply_config_array(TidyDoc doc, HashTable *ht_options TSRMLS_DC);
static void _php_tidy_register_nodetypes(INIT_FUNC_ARGS);
static void _php_tidy_register_tags(INIT_FUNC_ARGS);
+static PHP_INI_MH(php_tidy_set_clean_output);
+static void php_tidy_clean_output_start(const char *name, size_t name_len TSRMLS_DC);
+static php_output_handler *php_tidy_output_handler_init(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags TSRMLS_DC);
+static int php_tidy_output_handler(void **nothing, php_output_context *output_context);
static PHP_MINIT_FUNCTION(tidy);
static PHP_MSHUTDOWN_FUNCTION(tidy);
@@ -245,8 +251,6 @@ static PHP_FUNCTION(tidy_warning_count);
static PHP_FUNCTION(tidy_access_count);
static PHP_FUNCTION(tidy_config_count);
-static PHP_FUNCTION(ob_tidyhandler);
-
static PHP_FUNCTION(tidy_get_root);
static PHP_FUNCTION(tidy_get_html);
static PHP_FUNCTION(tidy_get_head);
@@ -271,8 +275,8 @@ static TIDY_NODE_METHOD(__construct);
ZEND_DECLARE_MODULE_GLOBALS(tidy)
PHP_INI_BEGIN()