diff options
Diffstat (limited to 'src/sp_sloppy.c')
| -rw-r--r-- | src/sp_sloppy.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/sp_sloppy.c b/src/sp_sloppy.c index 3276233..e7396fd 100644 --- a/src/sp_sloppy.c +++ b/src/sp_sloppy.c | |||
| @@ -36,7 +36,9 @@ ZEND_API zend_op_array* sp_compile_file(zend_file_handle* file_handle, | |||
| 36 | return opline; | 36 | return opline; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | PHP_FUNCTION(sp_in_array) { | 39 | static void array_handler(INTERNAL_FUNCTION_PARAMETERS, |
| 40 | const char *name, size_t size, | ||
| 41 | void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS)) { | ||
| 40 | void (*handler)(INTERNAL_FUNCTION_PARAMETERS); | 42 | void (*handler)(INTERNAL_FUNCTION_PARAMETERS); |
| 41 | zval func_name; | 43 | zval func_name; |
| 42 | zval params[3] = {{{0}}}; | 44 | zval params[3] = {{{0}}}; |
| @@ -48,18 +50,33 @@ PHP_FUNCTION(sp_in_array) { | |||
| 48 | ZVAL_COPY(¶ms[0], value); | 50 | ZVAL_COPY(¶ms[0], value); |
| 49 | ZVAL_COPY(¶ms[1], array); | 51 | ZVAL_COPY(¶ms[1], array); |
| 50 | ZVAL_BOOL(¶ms[2], 1); | 52 | ZVAL_BOOL(¶ms[2], 1); |
| 51 | ZVAL_STRING(&func_name, "in_array"); | 53 | ZVAL_STRING(&func_name, name); |
| 52 | 54 | ||
| 53 | handler = zend_hash_str_find_ptr( | 55 | handler = zend_hash_str_find_ptr( |
| 54 | SNUFFLEUPAGUS_G(sp_internal_functions_hook), "in_array", sizeof("in_array") - 1); | 56 | SNUFFLEUPAGUS_G(sp_internal_functions_hook), name, size); |
| 55 | zend_internal_function *func = zend_hash_str_find_ptr( | 57 | zend_internal_function *func = zend_hash_str_find_ptr( |
| 56 | CG(function_table), "in_array", sizeof("in_array") - 1); | 58 | CG(function_table), name, size); |
| 57 | func->handler = handler; | 59 | func->handler = handler; |
| 58 | 60 | ||
| 59 | call_user_function(CG(function_table), NULL, &func_name, return_value, 3, | 61 | call_user_function(CG(function_table), NULL, &func_name, |
| 60 | params); | 62 | return_value, 3, params); |
| 63 | |||
| 64 | func->handler = orig_handler; | ||
| 65 | } | ||
| 66 | |||
| 67 | PHP_FUNCTION(sp_in_array) { | ||
| 68 | array_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, "in_array", | ||
| 69 | sizeof("in_array") - 1, PHP_FN(sp_in_array)); | ||
| 70 | } | ||
| 71 | |||
| 72 | PHP_FUNCTION(sp_array_search) { | ||
| 73 | array_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, "array_search", | ||
| 74 | sizeof("array_search") - 1, PHP_FN(sp_array_search)); | ||
| 75 | } | ||
| 61 | 76 | ||
| 62 | func->handler = PHP_FN(sp_in_array); | 77 | PHP_FUNCTION(sp_array_keys) { |
| 78 | array_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, "array_keys", | ||
| 79 | sizeof("array_keys") - 1, PHP_FN(sp_array_keys)); | ||
| 63 | } | 80 | } |
| 64 | 81 | ||
| 65 | void hook_sloppy() { | 82 | void hook_sloppy() { |
| @@ -76,4 +93,6 @@ void hook_sloppy() { | |||
| 76 | } | 93 | } |
| 77 | 94 | ||
| 78 | HOOK_FUNCTION("in_array", sp_internal_functions_hook, PHP_FN(sp_in_array)); | 95 | HOOK_FUNCTION("in_array", sp_internal_functions_hook, PHP_FN(sp_in_array)); |
| 96 | HOOK_FUNCTION("array_search", sp_internal_functions_hook, PHP_FN(sp_array_search)); | ||
| 97 | HOOK_FUNCTION("array_keys", sp_internal_functions_hook, PHP_FN(sp_array_keys)); | ||
| 79 | } | 98 | } |
