From dfbed2aa24a6711fec37ed080e722f5035481b76 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Fri, 15 Aug 2003 16:13:51 +0000 Subject: [PATCH] Added ibase_free_event_handler() --- ext/interbase/interbase.c | 28 ++++++++++++++++++++++------ ext/interbase/php_interbase.h | 2 ++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c index c110c5d6f17..f0e28cdb55b 100644 --- a/ext/interbase/interbase.c +++ b/ext/interbase/interbase.c @@ -14,6 +14,7 @@ +----------------------------------------------------------------------+ | Authors: Jouni Ahto | | Andrew Avdeev | + | Ard Biesheuvel | +----------------------------------------------------------------------+ */ @@ -137,6 +138,7 @@ function_entry ibase_functions[] = { #endif PHP_FE(ibase_wait_event, NULL) PHP_FE(ibase_set_event_handler, NULL) + PHP_FE(ibase_free_event_handler, NULL) {NULL, NULL, NULL} }; @@ -3965,16 +3967,13 @@ static isc_callback _php_ibase_callback(ibase_event *event, unsigned short buffe } } - Z_TYPE(return_value) = IS_BOOL; - Z_BVAL(return_value) = 1; - /* call the callback provided by the user */ if (SUCCESS != call_user_function(EG(function_table), NULL, event->callback, &return_value, 2, args TSRMLS_CC)) { _php_ibase_module_error("Error calling callback %s", Z_STRVAL_P(event->callback)); return 0; } - if (! Z_BVAL(return_value)) { + if (Z_TYPE(return_value) == IS_BOOL && !Z_BVAL(return_value)) { return 0; } } @@ -4042,7 +4041,7 @@ PHP_FUNCTION(ibase_set_event_handler) } /* get the callback */ - if (!zend_is_callable(*args[i-1], 0, &callback_name)) { + if (!zend_is_callable(*cb_arg, 0, &callback_name)) { _php_ibase_module_error("Callback argument %s is not a callable function", callback_name); efree(callback_name); efree(args); @@ -4088,7 +4087,24 @@ PHP_FUNCTION(ibase_set_event_handler) ZEND_REGISTER_RESOURCE(return_value, event, le_event); zend_list_addref(Z_LVAL_P(return_value)); } - + +/* {{{ proto bool ibase_free_vevent_handler(resource event) + Frees the event handler set by ibase_set_event_handler() */ +PHP_FUNCTION(ibase_free_event_handler) +{ + zval **event_arg; + ibase_event *event; + + RESET_ERRMSG; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &event_arg) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(event, ibase_event *, event_arg, -1, "Interbase event", le_event); + zend_list_delete(Z_LVAL_PP(event_arg)); + RETURN_TRUE; +} /* }}} */ #endif /* HAVE_IBASE */ diff --git a/ext/interbase/php_interbase.h b/ext/interbase/php_interbase.h index 6070bf47145..6185defa12c 100644 --- a/ext/interbase/php_interbase.h +++ b/ext/interbase/php_interbase.h @@ -14,6 +14,7 @@ +----------------------------------------------------------------------+ | Authors: Jouni Ahto | | Andrew Avdeev | + | Ard Biesheuvel | +----------------------------------------------------------------------+ */ @@ -92,6 +93,7 @@ PHP_FUNCTION(ibase_errcode); PHP_FUNCTION(ibase_wait_event); PHP_FUNCTION(ibase_set_event_handler); +PHP_FUNCTION(ibase_free_event_handler); #define IBASE_MSGSIZE 256 #define MAX_ERRMSG (IBASE_MSGSIZE*2)