|
14 | 14 | +----------------------------------------------------------------------+ |
15 | 15 | | Authors: Jouni Ahto <jouni.ahto@exdec.fi> | |
16 | 16 | | Andrew Avdeev <andy@rsc.mv.ru> | |
| 17 | + | Ard Biesheuvel <a.k.biesheuvel@its.tudelft.nl> | |
17 | 18 | +----------------------------------------------------------------------+ |
18 | 19 | */ |
19 | 20 |
|
@@ -137,6 +138,7 @@ function_entry ibase_functions[] = { |
137 | 138 | #endif |
138 | 139 | PHP_FE(ibase_wait_event, NULL) |
139 | 140 | PHP_FE(ibase_set_event_handler, NULL) |
| 141 | + PHP_FE(ibase_free_event_handler, NULL) |
140 | 142 | {NULL, NULL, NULL} |
141 | 143 | }; |
142 | 144 |
|
@@ -3965,16 +3967,13 @@ static isc_callback _php_ibase_callback(ibase_event *event, unsigned short buffe |
3965 | 3967 | } |
3966 | 3968 | } |
3967 | 3969 |
|
3968 | | - Z_TYPE(return_value) = IS_BOOL; |
3969 | | - Z_BVAL(return_value) = 1; |
3970 | | - |
3971 | 3970 | /* call the callback provided by the user */ |
3972 | 3971 | if (SUCCESS != call_user_function(EG(function_table), NULL, event->callback, &return_value, 2, args TSRMLS_CC)) { |
3973 | 3972 | _php_ibase_module_error("Error calling callback %s", Z_STRVAL_P(event->callback)); |
3974 | 3973 | return 0; |
3975 | 3974 | } |
3976 | 3975 |
|
3977 | | - if (! Z_BVAL(return_value)) { |
| 3976 | + if (Z_TYPE(return_value) == IS_BOOL && !Z_BVAL(return_value)) { |
3978 | 3977 | return 0; |
3979 | 3978 | } |
3980 | 3979 | } |
@@ -4042,7 +4041,7 @@ PHP_FUNCTION(ibase_set_event_handler) |
4042 | 4041 | } |
4043 | 4042 |
|
4044 | 4043 | /* get the callback */ |
4045 | | - if (!zend_is_callable(*args[i-1], 0, &callback_name)) { |
| 4044 | + if (!zend_is_callable(*cb_arg, 0, &callback_name)) { |
4046 | 4045 | _php_ibase_module_error("Callback argument %s is not a callable function", callback_name); |
4047 | 4046 | efree(callback_name); |
4048 | 4047 | efree(args); |
@@ -4088,7 +4087,24 @@ PHP_FUNCTION(ibase_set_event_handler) |
4088 | 4087 | ZEND_REGISTER_RESOURCE(return_value, event, le_event); |
4089 | 4088 | zend_list_addref(Z_LVAL_P(return_value)); |
4090 | 4089 | } |
4091 | | - |
| 4090 | + |
| 4091 | +/* {{{ proto bool ibase_free_vevent_handler(resource event) |
| 4092 | + Frees the event handler set by ibase_set_event_handler() */ |
| 4093 | +PHP_FUNCTION(ibase_free_event_handler) |
| 4094 | +{ |
| 4095 | + zval **event_arg; |
| 4096 | + ibase_event *event; |
| 4097 | + |
| 4098 | + RESET_ERRMSG; |
| 4099 | + |
| 4100 | + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &event_arg) == FAILURE) { |
| 4101 | + WRONG_PARAM_COUNT; |
| 4102 | + } |
| 4103 | + |
| 4104 | + ZEND_FETCH_RESOURCE(event, ibase_event *, event_arg, -1, "Interbase event", le_event); |
| 4105 | + zend_list_delete(Z_LVAL_PP(event_arg)); |
| 4106 | + RETURN_TRUE; |
| 4107 | +} |
4092 | 4108 | /* }}} */ |
4093 | 4109 |
|
4094 | 4110 | #endif /* HAVE_IBASE */ |
|
0 commit comments