Re: Gtk::input_add() for a popen() filehandle?
| From: | Andrei Zmievski | Date: | Mon, 01 Apr 2002 16:39:42 +0000 |
| Subject: | Re: Gtk::input_add() for a popen() filehandle? | ||
| References: | 1 2 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-1691@lists.php.net to get a copy of this message | ||
Try this diff and let me know if it works:
--- ext/gtk+/gtk.overrides 29 Jan 2002 20:34:08 -0000 1.48
+++ ext/gtk+/gtk.overrides 1 Apr 2002 16:39:12 -0000
@@ -286,6 +286,7 @@
source = zend_list_find(Z_LVAL_P(source_rsrc), &rsrc_type);
- if (!source || rsrc_type != php_file_le_fopen()) {
- php_error(E_WARNING, "%s() expects argument 1 to be a valid filehandle resource",
get_active_function_name(TSRMLS_C));
+ if (!source ||
+ (rsrc_type != php_file_le_fopen() && rsrc_type != php_file_le_popen())) {
+ php_error(E_WARNING, "%s() expects argument 1 to be a valid filehandle or pipe
resource", get_active_function_name(TSRMLS_C));
return;
}
On Sun, 31 Mar 2002, Alan Knowles wrote:
> Having had a quick hunt through the code for this, it appears that if
> you replaced the call with the le_popen check, the value in *source
> should be the return value from the popen call - so if this worked in C
> - it should be possible in gtk.
>
> you could try doing a couple of sprintf's in the php4/ext/file.c and/or
> php4/TSRM/tsrm_virtual_cmd.c and gtk.overides to find out the exact
> values that are getting sent back and forth, and compare this with the C
> version.
>
> eg.
>
> if (!php_gtk_parse_args(3, "riV", &source_rsrc, &condition, &callback))
> return;
>
> source = zend_list_find(Z_LVAL_P(source_rsrc), &rsrc_type);
> if (!source || rsrc_type != php_file_le_popen()) {
> php_error(E_WARNING, "%s() expects argument 1 to be a valid
> filehandle resource", get_active_function_name(TSRMLS_C));
> return;
> }
> php_error(E_WARNING, "Debugging input_add : %x %d", source,source);
>
> etc.
>
> I wasnt aware of this function - it would be amazingly usefull if it
> could work....
>
> regards
> alan
>
> James Cameron wrote:
>
> >G'day,
> >
> >I'm trying to write an application using PHP-GTK that will run rsync
> >over ssh in a pipe, so that I can update the GUI according to the
> >progress (or failure) of the rsync.
> >
> >If I were using C, then I would use popen(), obtain the file descriptor
> >for the pipe, and then hand it to gtk_input_add_full() so that I can
> >return control to the GTK+ event loop, and be informed when input
> >arrives. I've done this successfully in C before.
> >
> >However, the PHP-GTK function Gtk::input_add() only accepts an fopen()
> >filehandle. The check is in ext/gtk+/gtk.overrides:288 (rev 1.48) and
> >changing it to allow popen() filehandles doesn't seem to work. The
> >callback is not called. I presume the filehandle types are different.
> >
> >Can anyone suggest how to fix this?
> >
>
>
-Andrei
* We are not a clone. *