cvs: php-gtk /ext/gtk+ gtk.overrides
| From: | Andrei Zmievski | Date: | Wed, 03 Apr 2002 19:13:35 +0000 |
| Subject: | cvs: php-gtk /ext/gtk+ gtk.overrides | ||
| Groups: | php.gtk.cvs | ||
| Request: | Send a blank email to php-gtk-cvs+get-498@lists.php.net to get a copy of this message | ||
andrei Wed Apr 3 14:13:35 2002 EDT
Modified files:
/php-gtk/ext/gtk+ gtk.overrides
Log:
Make gtk::input_add() work with PHP streams.
Index: php-gtk/ext/gtk+/gtk.overrides
diff -u php-gtk/ext/gtk+/gtk.overrides:1.48 php-gtk/ext/gtk+/gtk.overrides:1.49
--- php-gtk/ext/gtk+/gtk.overrides:1.48 Tue Jan 29 15:34:08 2002
+++ php-gtk/ext/gtk+/gtk.overrides Wed Apr 3 14:13:35 2002
@@ -267,8 +267,8 @@
PHP_FUNCTION(gtk_input_add_full)
{
zval *source_rsrc;
+ int source;
int rsrc_type;
- int *source;
GdkInputCondition condition;
zval *callback = NULL;
zval *extra, *data;
@@ -284,17 +284,43 @@
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_fopen()) {
- php_error(E_WARNING, "%s() expects argument 1 to be a valid filehandle resource",
get_active_function_name(TSRMLS_C));
- return;
+#ifdef PHP_HAVE_STREAMS
+ {
+ php_stream *stream;
+ stream = zend_list_find(Z_LVAL_P(source_rsrc), &rsrc_type);
+ if (!stream || rsrc_type != php_file_le_stream()) {
+ php_error(E_WARNING, "%s() expects argument 1 to be a valid stream resource",
get_active_function_name(TSRMLS_C));
+ return;
+ }
+ if (php_stream_can_cast(stream, PHP_STREAM_AS_SOCKETD) == SUCCESS) {
+ php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void*)&source, 0);
+ } else if (php_stream_can_cast(stream, PHP_STREAM_AS_FD) == SUCCESS) {
+ php_stream_cast(stream, PHP_STREAM_AS_FD, (void*)&source, 0);
+ } else {
+ php_error(E_WARNING, "%s() could not use stream of type '%s'",
+ get_active_function_name(), stream->ops->label);
+ return;
+ }
+ }
+#else
+ {
+ int *source_ptr;
+
+ source_ptr = zend_list_find(Z_LVAL_P(source_rsrc), &rsrc_type);
+ if (!source_ptr ||
+ (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;
+ }
+ source = *source_ptr;
}
+#endif
callback_filename = zend_get_executed_filename(TSRMLS_C);
callback_lineno = zend_get_executed_lineno(TSRMLS_C);
extra = php_gtk_func_args_as_hash(ZEND_NUM_ARGS(), 3, ZEND_NUM_ARGS());
data = php_gtk_build_value("(VNsi)", callback, extra, callback_filename,
callback_lineno);
- RETURN_LONG(gtk_input_add_full(*source, condition, NULL,
+ RETURN_LONG(gtk_input_add_full(source, condition, NULL,
(GtkCallbackMarshal)php_gtk_input_marshal,
data, php_gtk_destroy_notify));
}