1 /*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Derick Rethans <derick@php.net> |
14 +----------------------------------------------------------------------+
15 */
16
17 #include "php_filter.h"
18
php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL)19 void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL)
20 {
21 zval retval;
22 zval args[1];
23 int status;
24
25 if (!option_array || !zend_is_callable(option_array, 0, NULL)) {
26 zend_type_error("%s(): Option must be a valid callback", get_active_function_name());
27 zval_ptr_dtor(value);
28 ZVAL_NULL(value);
29 return;
30 }
31
32 ZVAL_COPY(&args[0], value);
33 status = call_user_function(NULL, NULL, option_array, &retval, 1, args);
34
35 if (status == SUCCESS && !Z_ISUNDEF(retval)) {
36 zval_ptr_dtor(value);
37 ZVAL_COPY_VALUE(value, &retval);
38 } else {
39 zval_ptr_dtor(value);
40 ZVAL_NULL(value);
41 }
42
43 zval_ptr_dtor(&args[0]);
44 }
45