return FAILURE;
}
if (chunk_size) {
- if (chunk_size==1)
+ if (chunk_size==1) {
chunk_size = 4096;
+ }
initial_size = (chunk_size*3/2);
block_size = chunk_size/2;
} else {
OG(active_ob_buffer).internal_output_handler = internal_output_handler;
OG(active_ob_buffer).internal_output_handler_buffer = (char *) emalloc(buffer_size);
OG(active_ob_buffer).internal_output_handler_buffer_size = buffer_size;
- if (OG(active_ob_buffer).handler_name)
+ if (OG(active_ob_buffer).handler_name) {
efree(OG(active_ob_buffer).handler_name);
+ }
OG(active_ob_buffer).handler_name = estrdup(handler_name);
OG(active_ob_buffer).erase = erase;
}
*/
PHPAPI int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC)
{
- if (php_ob_handler_used(handler_set TSRMLS_CC))
- {
+ if (php_ob_handler_used(handler_set TSRMLS_CC)) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler '%s' conflicts with '%s'", handler_new, handler_set);
return 1;
}
FREE_ZVAL(handler_zval);
}
result = result ? SUCCESS : FAILURE;
- }
- else if (output_handler && output_handler->type == IS_ARRAY) {
+ } else if (output_handler && output_handler->type == IS_ARRAY) {
result = 0;
/* do we have array(object,method) */
if (zend_is_callable(output_handler, 1, &handler_name)) {
}
}
result = result ? SUCCESS : FAILURE;
- }
- else if (output_handler && output_handler->type == IS_OBJECT) {
+ } else if (output_handler && output_handler->type == IS_OBJECT) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "No method name given: use ob_start(array($object,'method')) to specify instance $object and the name of a method of class %s to use as output handler", Z_OBJCE_P(output_handler)->name);
result = FAILURE;
- }
- else {
+ } else {
if (output_handler) {
SEPARATE_ZVAL(&output_handler);
output_handler->refcount++;
PHP_FUNCTION(ob_list_handlers)
{
if (ZEND_NUM_ARGS()!=0) {
- WRONG_PARAM_COUNT;
+ ZEND_WRONG_PARAM_COUNT();
RETURN_FALSE;
}
*/
static int php_ob_handler_used_each(php_ob_buffer *ob_buffer, char **handler_name)
{
- if (!strcmp(ob_buffer->handler_name, *handler_name))
- {
+ if (!strcmp(ob_buffer->handler_name, *handler_name)) {
*handler_name = NULL;
return 1;
}
zend_bool erase=1;
int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argc TSRMLS_CC, "|zlb", &output_handler,
- &chunk_size, &erase) == FAILURE)
+ if (zend_parse_parameters(argc TSRMLS_CC, "|zlb", &output_handler, &chunk_size, &erase) == FAILURE) {
RETURN_FALSE;
+ }
if (php_start_ob_buffer(output_handler, chunk_size, erase TSRMLS_CC)==FAILURE) {
RETURN_FALSE;
Flush (send) contents of the output buffer. The last buffer content is sent to next buffer */
PHP_FUNCTION(ob_flush)
{
- if (ZEND_NUM_ARGS() != 0)
- WRONG_PARAM_COUNT;
+ if (ZEND_NUM_ARGS() != 0) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
if (!OG(ob_nesting_level)) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer. No buffer to flush.");
Clean (delete) the current output buffer */
PHP_FUNCTION(ob_clean)
{
- if (ZEND_NUM_ARGS() != 0)
- WRONG_PARAM_COUNT;
-
+ if (ZEND_NUM_ARGS() != 0) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
if (!OG(ob_nesting_level)) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete.");
RETURN_FALSE;
}
+
if (!OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
RETURN_FALSE;
Flush (send) the output buffer, and delete current output buffer */
PHP_FUNCTION(ob_end_flush)
{
- if (ZEND_NUM_ARGS() != 0)
- WRONG_PARAM_COUNT;
+ if (ZEND_NUM_ARGS() != 0) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
if (!OG(ob_nesting_level)) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush.");
Clean the output buffer, and delete current output buffer */
PHP_FUNCTION(ob_end_clean)
{
- if (ZEND_NUM_ARGS() != 0)
- WRONG_PARAM_COUNT;
+ if (ZEND_NUM_ARGS() != 0) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
if (!OG(ob_nesting_level)) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete.");
Get current buffer contents, flush (send) the output buffer, and delete current output buffer */
PHP_FUNCTION(ob_get_flush)
{
- if (ZEND_NUM_ARGS() != 0)
- WRONG_PARAM_COUNT;
+ if (ZEND_NUM_ARGS() != 0) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
/* get contents */
if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
PHP_FUNCTION(ob_get_clean)
{
if (ZEND_NUM_ARGS() != 0)
- WRONG_PARAM_COUNT;
+ ZEND_WRONG_PARAM_COUNT();
/* get contents */
if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
Return the contents of the output buffer */
PHP_FUNCTION(ob_get_contents)
{
- if (ZEND_NUM_ARGS() != 0)
- WRONG_PARAM_COUNT;
+ if (ZEND_NUM_ARGS() != 0) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
RETURN_FALSE;
Return the nesting level of the output buffer */
PHP_FUNCTION(ob_get_level)
{
- if (ZEND_NUM_ARGS() != 0)
- WRONG_PARAM_COUNT;
+ if (ZEND_NUM_ARGS() != 0) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
RETURN_LONG (OG(ob_nesting_level));
}
Return the length of the output buffer */
PHP_FUNCTION(ob_get_length)
{
- if (ZEND_NUM_ARGS() != 0)
- WRONG_PARAM_COUNT;
+ if (ZEND_NUM_ARGS() != 0) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
if (php_ob_get_length(return_value TSRMLS_CC)==FAILURE) {
RETURN_FALSE;
if (OG(ob_nesting_level)>0 && php_ob_buffer_status(&OG(active_ob_buffer), return_value)==FAILURE) {
RETURN_FALSE;
}
- }
- else if (OG(ob_nesting_level)>0) {
+ } else if (OG(ob_nesting_level)>0) {
add_assoc_long(return_value, "level", OG(ob_nesting_level));
if (OG(active_ob_buffer).internal_output_handler) {
add_assoc_long(return_value, "type", PHP_OUTPUT_HANDLER_INTERNAL);
- }
- else {
+ } else {
add_assoc_long(return_value, "type", PHP_OUTPUT_HANDLER_USER);
}
add_assoc_long(return_value, "status", OG(active_ob_buffer).status);
flag = Z_LVAL_PP(zv_flag);
break;
default:
- WRONG_PARAM_COUNT;
+ ZEND_WRONG_PARAM_COUNT();
break;
}
if (flag) {