Probably worth continuing on php-gtk-dev only...

I was getting a bit further with
        MAKE_STD_ZVAL(myresource);
        ZVAL_RESOURCE(myresource, gs) ;
        /*ZEND_REGISTER_RESOURCE(myresource, gs, le_gtkhtmlstream); */
  now the function does not segfault, but does not appear to pass resource around..

then function below is called when the browser is loading a webpage, and wants an 
image, 
it emits a signal 'url_requested', which I have added a method of html 
connect_url_request.

this builds the callback data array in data, and calls this function.. - with a new 
stream.

- theoretically, when you load the web page, you would get  a number of these call for 
each of the images. the callback routine would then either get from the cache or open 
a non-blocking socket to get the file/image..

in theory a number of these streams could be open at one time (assuming the program 
can be taught to multi task well...)


on the php side..
it is supposed to work like this...

$string = implode('',file("http://www.php.net";));
$gtkhtml = &new gtkhtml();
$gtkhtml->connect_url_request("my_url_callback");
$gtkhtml->load_from_string($string);


function my_url_callback($url,$stream) {
  global $gtkhtml;
  $string = implode('',file("http://www.php.net".$url));
  $gtkhtml->write($stream,$string);
}

the code below just segfaults when url_requested is emitted.

with the modification above, $stream does not appear to be a resource... (although Im 
still testing..)

thx
regards
alan





>----- Original Message -----
> From: Markus Fischer <[EMAIL PROTECTED]>
> To: Alan Knowles <[EMAIL PROTECTED]>
> Sent: Thu, 18 Oct 2001 18:30:57 +0200
> Subject: [PHP-DEV] Re: [PHP-GTK-DEV] Help - Merging Resource into a call_function 
>array
> 
> Is gs really a newly allocated resource so you have to register
> it? Or is it arleady an existing one? If it does already exist
> (what I assume) you should fetch it from the resource lirst (quick
> look , could be wrong).
> 
> Btw, it would help telling what exactly does not work.
> 
> And, with the extra arguments, ... you really want to 'merge'
> this? I think it should be added to the args, no?
> 
> 
> On Thu, Oct 18, 2001 at 04:17:31PM -0000, Alan Knowles wrote : 
> > 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(&params);
> > 
> > }
> > 
> > -- 
> > PHP-GTK Development Mailing List (http://gtk.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> -- 
> Markus Fischer,  http://guru.josefine.at/~mfischer/
> EMail:         [EMAIL PROTECTED]
> PGP Public  Key: http://guru.josefine.at/~mfischer/C2272BD0.asc
> PGP Fingerprint: D3B0 DD4F E12B F911 3CE1  C2B5 D674 B445 C227 2BD0
>               -All your scripts are belong to Zend-
> 
> -- 
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 
> 



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to