cvs: pecl /newt newt.c

From: Date: Fri, 13 Aug 2004 20:20:00 +0000
Subject: cvs: pecl /newt newt.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-1647@lists.php.net to get a copy of this message
michael Fri Aug 13 16:20:00 2004 EDT Modified files: /pecl/newt newt.c Log: implemented newt_form_watch_fd through php_stream http://cvs.php.net/diff.php/pecl/newt/newt.c?r1=1.4&r2=1.5&ty=u Index: pecl/newt/newt.c diff -u pecl/newt/newt.c:1.4 pecl/newt/newt.c:1.5 --- pecl/newt/newt.c:1.4 Fri Aug 13 08:59:40 2004 +++ pecl/newt/newt.c Fri Aug 13 16:19:59 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: newt.c,v 1.4 2004/08/13 12:59:40 michael Exp $ */ +/* $Id: newt.c,v 1.5 2004/08/13 20:19:59 michael Exp $ */ #include <newt.h> @@ -28,6 +28,7 @@ #include "php_ini.h" #include "ext/standard/php_var.h" #include "ext/standard/info.h" +#include "php_network.h" #include "php_newt.h" /* True global resources - no need for thread safety here */ @@ -2313,9 +2314,37 @@ /* }}} */ /* {{{ + * proto newt_form_watch_fd (resource form, resource stream [, int flags]) */ PHP_FUNCTION(newt_form_watch_fd) { + zval * z_form; + newtComponent form; + zval * z_stream; + php_stream * stream; + php_socket_t fd; + int flags = 0; + + int argc = ZEND_NUM_ARGS(); + if (argc == 2) { + if (zend_parse_parameters (argc, "zz", &z_form, &z_stream) == FAILURE) { + return; + } + } else if (argc == 3) { + if (zend_parse_parameters (argc, "zzl", &z_form, &z_stream, &flags) == FAILURE) { + return; + } + } else { WRONG_PARAM_COUNT; } + + php_stream_from_zval_no_verify (stream, &z_stream); + + if (php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT, (void*)&fd, 1) == SUCCESS && fd >= 0) { + ZEND_FETCH_RESOURCE(form, newtComponent, &z_form, -1, le_newt_comp_name, le_newt_comp); + newtFormWatchFd (form, fd, flags); + } + else { + zend_error (E_WARNING, "Could not cast stream to a file descriptor"); + } } /* }}} */

« previous php.pecl.cvs (#1647) next »