Skip to content

Commit dfbed2a

Browse files
author
Ard Biesheuvel
committed
Added ibase_free_event_handler()
1 parent a2e91e3 commit dfbed2a

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

‎ext/interbase/interbase.c‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
+----------------------------------------------------------------------+
1515
| Authors: Jouni Ahto <jouni.ahto@exdec.fi> |
1616
| Andrew Avdeev <andy@rsc.mv.ru> |
17+
| Ard Biesheuvel <a.k.biesheuvel@its.tudelft.nl> |
1718
+----------------------------------------------------------------------+
1819
*/
1920

@@ -137,6 +138,7 @@ function_entry ibase_functions[] = {
137138
#endif
138139
PHP_FE(ibase_wait_event, NULL)
139140
PHP_FE(ibase_set_event_handler, NULL)
141+
PHP_FE(ibase_free_event_handler, NULL)
140142
{NULL, NULL, NULL}
141143
};
142144

@@ -3965,16 +3967,13 @@ static isc_callback _php_ibase_callback(ibase_event *event, unsigned short buffe
39653967
}
39663968
}
39673969

3968-
Z_TYPE(return_value) = IS_BOOL;
3969-
Z_BVAL(return_value) = 1;
3970-
39713970
/* call the callback provided by the user */
39723971
if (SUCCESS != call_user_function(EG(function_table), NULL, event->callback, &return_value, 2, args TSRMLS_CC)) {
39733972
_php_ibase_module_error("Error calling callback %s", Z_STRVAL_P(event->callback));
39743973
return 0;
39753974
}
39763975

3977-
if (! Z_BVAL(return_value)) {
3976+
if (Z_TYPE(return_value) == IS_BOOL && !Z_BVAL(return_value)) {
39783977
return 0;
39793978
}
39803979
}
@@ -4042,7 +4041,7 @@ PHP_FUNCTION(ibase_set_event_handler)
40424041
}
40434042

40444043
/* get the callback */
4045-
if (!zend_is_callable(*args[i-1], 0, &callback_name)) {
4044+
if (!zend_is_callable(*cb_arg, 0, &callback_name)) {
40464045
_php_ibase_module_error("Callback argument %s is not a callable function", callback_name);
40474046
efree(callback_name);
40484047
efree(args);
@@ -4088,7 +4087,24 @@ PHP_FUNCTION(ibase_set_event_handler)
40884087
ZEND_REGISTER_RESOURCE(return_value, event, le_event);
40894088
zend_list_addref(Z_LVAL_P(return_value));
40904089
}
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+
}
40924108
/* }}} */
40934109

40944110
#endif /* HAVE_IBASE */

‎ext/interbase/php_interbase.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
+----------------------------------------------------------------------+
1515
| Authors: Jouni Ahto <jouni.ahto@exdec.fi> |
1616
| Andrew Avdeev <andy@simgts.mv.ru> |
17+
| Ard Biesheuvel <a.k.biesheuvel@its.tudelft.nl> |
1718
+----------------------------------------------------------------------+
1819
*/
1920

@@ -92,6 +93,7 @@ PHP_FUNCTION(ibase_errcode);
9293

9394
PHP_FUNCTION(ibase_wait_event);
9495
PHP_FUNCTION(ibase_set_event_handler);
96+
PHP_FUNCTION(ibase_free_event_handler);
9597

9698
#define IBASE_MSGSIZE 256
9799
#define MAX_ERRMSG (IBASE_MSGSIZE*2)

0 commit comments

Comments
 (0)