Help - Merging Resource into a call_function array
| From: | Alan Knowles | Date: | Thu, 18 Oct 2001 16:17:31 +0000 |
| Subject: | Help - Merging Resource into a call_function array | ||
| Groups: | php.dev php.gtk.dev | ||
| Request: | Send a blank email to php-dev+get-68253@lists.php.net to get a copy of this message | ||
Can someone help me out with this one, - I'm sure that I've not acheived what I was aiming
at - adding the Resource, myresource to the array prior to calling the callback function....
the code below is from the url_request callback wrapper for gtkhtml - if this works - you can build
a working web browser/editor in php..
regards
alan
static void php_gtk_html_url_request_callback (GtkHTML *html, const char *url, GtkHTMLStream *gs,
zval* callback_data)
{
zval *myresource = NULL;
zval *retval = NULL;
zval **callback = NULL, **extra = NULL;
zval **callback_filename = NULL, **callback_lineno = NULL;
zval ***args, *params;
char *callback_name;
TSRMLS_FETCH();
zend_hash_index_find(Z_ARRVAL_P(callback_data), 0, (void **)&callback);
zend_hash_index_find(Z_ARRVAL_P(callback_data), 1, (void **)&extra);
zend_hash_index_find(Z_ARRVAL_P(callback_data), 2, (void **)&callback_filename);
zend_hash_index_find(Z_ARRVAL_P(callback_data), 3, (void **)&callback_lineno);
if (!php_gtk_is_callable(*callback, 0, &callback_name)) {
php_error(E_WARNING, "Unable to call ctree callback '%s' specified in %s on line
%d", callback_name, Z_STRVAL_PP(callback_filename), Z_LVAL_PP(callback_lineno));
efree(callback_name);
return;
}
params = php_gtk_build_value("(s)", url);
ZEND_REGISTER_RESOURCE(myresource, gs, le_gtkhtmlstream);
zend_hash_next_index_insert(Z_ARRVAL_P(params), (zval *) &myresource, sizeof(zval *), NULL);
if (extra)
php_array_merge(Z_ARRVAL_P(params), Z_ARRVAL_PP(extra), 0);
args = php_gtk_hash_as_array(params);
call_user_function_ex(EG(function_table), NULL, *callback, &retval,
zend_hash_num_elements(Z_ARRVAL_P(params)), args, 0, NULL TSRMLS_CC);
if (retval)
zval_ptr_dtor(&retval);
efree(args);
zval_ptr_dtor(¶ms);
}