Back to index

php5  5.3.10
callback_filter.c
Go to the documentation of this file.
00001 /*
00002   +----------------------------------------------------------------------+
00003   | PHP Version 5                                                        |
00004   +----------------------------------------------------------------------+
00005   | Copyright (c) 1997-2012 The PHP Group                                |
00006   +----------------------------------------------------------------------+
00007   | This source file is subject to version 3.01 of the PHP license,      |
00008   | that is bundled with this package in the file LICENSE, and is        |
00009   | available through the world-wide-web at the following url:           |
00010   | http://www.php.net/license/3_01.txt                                  |
00011   | If you did not receive a copy of the PHP license and are unable to   |
00012   | obtain it through the world-wide-web, please send a note to          |
00013   | license@php.net so we can mail you a copy immediately.               |
00014   +----------------------------------------------------------------------+
00015   | Authors: Derick Rethans <derick@php.net>                             |
00016   +----------------------------------------------------------------------+
00017 */
00018 
00019 /* $Id: callback_filter.c 321634 2012-01-01 13:15:04Z felipe $ */
00020 
00021 #include "php_filter.h"
00022 
00023 void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL)
00024 {
00025        zval *retval_ptr;
00026        zval ***args;
00027        int status;
00028 
00029        if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_CHECK_NO_ACCESS, NULL TSRMLS_CC)) {
00030               php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is expected to be a valid callback");
00031               zval_dtor(value);
00032               Z_TYPE_P(value) = IS_NULL;
00033               return;
00034        }
00035 
00036        args = safe_emalloc(sizeof(zval **), 1, 0);
00037        args[0] = &value;
00038        
00039        status = call_user_function_ex(EG(function_table), NULL, option_array, &retval_ptr, 1, args, 0, NULL TSRMLS_CC);
00040 
00041        if (status == SUCCESS && retval_ptr != NULL) {
00042               if (retval_ptr != value) {
00043                      zval_dtor(value);
00044                      COPY_PZVAL_TO_ZVAL(*value, retval_ptr);
00045               } else {
00046                      zval_ptr_dtor(&retval_ptr);
00047               }
00048        } else {
00049               zval_dtor(value);
00050               Z_TYPE_P(value) = IS_NULL;
00051        }
00052 
00053        efree(args);
00054 }
00055 
00056 /*
00057  * Local variables:
00058  * tab-width: 4
00059  * c-basic-offset: 4
00060  * End:
00061  * vim600: noet sw=4 ts=4 fdm=marker
00062  * vim<600: noet sw=4 ts=4
00063  */