summaryrefslogtreecommitdiff
path: root/main/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/output.c')
-rw-r--r--main/output.c109
1 files changed, 46 insertions, 63 deletions
diff --git a/main/output.c b/main/output.c
index 7751586dbc..aab080ba01 100644
--- a/main/output.c
+++ b/main/output.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -33,7 +31,7 @@
#include "zend_stack.h"
#include "php_output.h"
-PHPAPI ZEND_DECLARE_MODULE_GLOBALS(output);
+PHPAPI ZEND_DECLARE_MODULE_GLOBALS(output)
const char php_output_default_handler_name[sizeof("default output handler")] = "default output handler";
const char php_output_devnull_handler_name[sizeof("null output handler")] = "null output handler";
@@ -592,9 +590,9 @@ PHPAPI int php_output_handler_conflict(const char *handler_new, size_t handler_n
{
if (php_output_handler_started(handler_set, handler_set_len)) {
if (handler_new_len != handler_set_len || memcmp(handler_new, handler_set, handler_set_len)) {
- php_error_docref("ref.outcontrol", E_WARNING, "output handler '%s' conflicts with '%s'", handler_new, handler_set);
+ php_error_docref("ref.outcontrol", E_WARNING, "Output handler '%s' conflicts with '%s'", handler_new, handler_set);
} else {
- php_error_docref("ref.outcontrol", E_WARNING, "output handler '%s' cannot be used twice", handler_new);
+ php_error_docref("ref.outcontrol", E_WARNING, "Output handler '%s' cannot be used twice", handler_new);
}
return 1;
}
@@ -1199,12 +1197,12 @@ static int php_output_stack_pop(int flags)
if (!orphan) {
if (!(flags & PHP_OUTPUT_POP_SILENT)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to %s buffer. No buffer to %s", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to %s buffer. No buffer to %s", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send");
}
return 0;
} else if (!(flags & PHP_OUTPUT_POP_FORCE) && !(orphan->flags & PHP_OUTPUT_HANDLER_REMOVABLE)) {
if (!(flags & PHP_OUTPUT_POP_SILENT)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to %s buffer of %s (%d)", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", ZSTR_VAL(orphan->name), orphan->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to %s buffer of %s (%d)", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", ZSTR_VAL(orphan->name), orphan->level);
}
return 0;
} else {
@@ -1292,8 +1290,7 @@ static int php_output_handler_devnull_func(void **handler_context, php_output_co
* USERLAND (nearly 1:1 of old output.c)
*/
-/* {{{ proto bool ob_start([string|array user_function [, int chunk_size [, int flags]]])
- Turn on Output Buffering (specifying an optional output handler). */
+/* {{{ Turn on Output Buffering (specifying an optional output handler). */
PHP_FUNCTION(ob_start)
{
zval *output_handler = NULL;
@@ -1301,7 +1298,7 @@ PHP_FUNCTION(ob_start)
zend_long flags = PHP_OUTPUT_HANDLER_STDFLAGS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zll", &output_handler, &chunk_size, &flags) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (chunk_size < 0) {
@@ -1309,65 +1306,62 @@ PHP_FUNCTION(ob_start)
}
if (php_output_start_user(output_handler, chunk_size, flags) == FAILURE) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to create buffer");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to create buffer");
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
-/* {{{ proto bool ob_flush(void)
- Flush (send) contents of the output buffer. The last buffer content is sent to next buffer */
+/* {{{ Flush (send) contents of the output buffer. The last buffer content is sent to next buffer */
PHP_FUNCTION(ob_flush)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to flush buffer. No buffer to flush");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to flush buffer. No buffer to flush");
RETURN_FALSE;
}
if (SUCCESS != php_output_flush()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to flush buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to flush buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
-/* {{{ proto bool ob_clean(void)
- Clean (delete) the current output buffer */
+/* {{{ Clean (delete) the current output buffer */
PHP_FUNCTION(ob_clean)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer. No buffer to delete");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer. No buffer to delete");
RETURN_FALSE;
}
if (SUCCESS != php_output_clean()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
-/* {{{ proto bool ob_end_flush(void)
- Flush (send) the output buffer, and delete current output buffer */
+/* {{{ Flush (send) the output buffer, and delete current output buffer */
PHP_FUNCTION(ob_end_flush)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete and flush buffer. No buffer to delete or flush");
RETURN_FALSE;
}
@@ -1375,16 +1369,15 @@ PHP_FUNCTION(ob_end_flush)
}
/* }}} */
-/* {{{ proto bool ob_end_clean(void)
- Clean the output buffer, and delete current output buffer */
+/* {{{ Clean the output buffer, and delete current output buffer */
PHP_FUNCTION(ob_end_clean)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer. No buffer to delete");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer. No buffer to delete");
RETURN_FALSE;
}
@@ -1392,31 +1385,29 @@ PHP_FUNCTION(ob_end_clean)
}
/* }}} */
-/* {{{ proto bool ob_get_flush(void)
- Get current buffer contents, flush (send) the output buffer, and delete current output buffer */
+/* {{{ Get current buffer contents, flush (send) the output buffer, and delete current output buffer */
PHP_FUNCTION(ob_get_flush)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_output_get_contents(return_value) == FAILURE) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete and flush buffer. No buffer to delete or flush");
RETURN_FALSE;
}
if (SUCCESS != php_output_end()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
}
}
/* }}} */
-/* {{{ proto bool ob_get_clean(void)
- Get current buffer contents and delete current output buffer */
+/* {{{ Get current buffer contents and delete current output buffer */
PHP_FUNCTION(ob_get_clean)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if(!OG(active)) {
@@ -1424,22 +1415,21 @@ PHP_FUNCTION(ob_get_clean)
}
if (php_output_get_contents(return_value) == FAILURE) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer. No buffer to delete");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer. No buffer to delete");
RETURN_FALSE;
}
if (SUCCESS != php_output_discard()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
}
}
/* }}} */
-/* {{{ proto string ob_get_contents(void)
- Return the contents of the output buffer */
+/* {{{ Return the contents of the output buffer */
PHP_FUNCTION(ob_get_contents)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_output_get_contents(return_value) == FAILURE) {
@@ -1448,24 +1438,22 @@ PHP_FUNCTION(ob_get_contents)
}
/* }}} */
-/* {{{ proto int ob_get_level(void)
- Return the nesting level of the output buffer */
+/* {{{ Return the nesting level of the output buffer */
PHP_FUNCTION(ob_get_level)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
RETURN_LONG(php_output_get_level());
}
/* }}} */
-/* {{{ proto int ob_get_length(void)
- Return the length of the output buffer */
+/* {{{ Return the length of the output buffer */
PHP_FUNCTION(ob_get_length)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_output_get_length(return_value) == FAILURE) {
@@ -1474,12 +1462,11 @@ PHP_FUNCTION(ob_get_length)
}
/* }}} */
-/* {{{ proto false|array ob_list_handlers()
- List all output_buffers in an array */
+/* {{{ List all output_buffers in an array */
PHP_FUNCTION(ob_list_handlers)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
array_init(return_value);
@@ -1492,14 +1479,13 @@ PHP_FUNCTION(ob_list_handlers)
}
/* }}} */
-/* {{{ proto false|array ob_get_status([bool full_status])
- Return the status of the active or all output buffers */
+/* {{{ Return the status of the active or all output buffers */
PHP_FUNCTION(ob_get_status)
{
zend_bool full_status = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &full_status) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
@@ -1516,26 +1502,24 @@ PHP_FUNCTION(ob_get_status)
}
/* }}} */
-/* {{{ proto void ob_implicit_flush([int flag])
- Turn implicit flush on/off and is equivalent to calling flush() after every output call */
+/* {{{ Turn implicit flush on/off and is equivalent to calling flush() after every output call */
PHP_FUNCTION(ob_implicit_flush)
{
zend_long flag = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
- return;
+ RETURN_THROWS();
}
php_output_set_implicit_flush(flag);
}
/* }}} */
-/* {{{ proto bool output_reset_rewrite_vars(void)
- Reset(clear) URL rewriter values */
+/* {{{ Reset(clear) URL rewriter values */
PHP_FUNCTION(output_reset_rewrite_vars)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_url_scanner_reset_vars() == SUCCESS) {
@@ -1546,15 +1530,14 @@ PHP_FUNCTION(output_reset_rewrite_vars)
}
/* }}} */
-/* {{{ proto bool output_add_rewrite_var(string name, string value)
- Add URL rewriter values */
+/* {{{ Add URL rewriter values */
PHP_FUNCTION(output_add_rewrite_var)
{
char *name, *value;
size_t name_len, value_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &value, &value_len) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_url_scanner_add_var(name, name_len, value, value_len, 1) == SUCCESS) {