From 633d18de0f34da5fcc40962b4e40291314faae95 Mon Sep 17 00:00:00 2001 From: Evan Klinger Date: Wed, 24 Nov 1999 03:47:58 +0000 Subject: [PATCH] Can't forget fd_isset() --- ext/standard/file.c | 27 ++++++++++++++++++++++++++- ext/standard/file.h | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ext/standard/file.c b/ext/standard/file.c index 8f0c1a2ddd..f9384b1768 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -245,6 +245,7 @@ function_entry file_functions[] = { PHP_FE(set_socket_timeout, NULL) #endif PHP_FE(fd_set, NULL) + PHP_FE(fd_isset, NULL) PHP_FE(select, NULL) {NULL, NULL, NULL} }; @@ -1681,7 +1682,7 @@ PHP_FUNCTION(fd_set) if(getParametersEx(1, &arg) == FAILURE) { WRONG_PARAM_COUNT; } - what = zend_fetch_resource(arg,-1,"Select",&type,3,le_fopen,le_socket,le_popen); + what = zend_fetch_resource(arg,-1,"select",&type,3,le_fopen,le_socket,le_popen); ZEND_VERIFY_RESOURCE(what); if(type == le_socket) { fd = *(int *)what; @@ -1733,3 +1734,27 @@ PHP_FUNCTION(select) RETURN_LONG(select(max_fd + 1,&readfd,NULL,NULL,((*timeout)->value.lval <= 0) ? NULL : &tv)); } +PHP_FUNCTION(fd_isset) +{ + pval **fdarg; + void *what; + int type, fd; + + if(ARG_COUNT(ht) != 1 || getParametersEx(1, &fdarg) == FAILURE) { + WRONG_PARAM_COUNT; + } + + what = zend_fetch_resource(fdarg,-1,"select",&type,3,le_fopen,le_socket,le_popen); + ZEND_VERIFY_RESOURCE(what); + + if(type == le_socket) { + fd = *(int *)what; + } else { + fd = fileno((FILE *)what); + } + + if(FD_ISSET(fd,&readfd)) { + RETURN_TRUE; + } + RETURN_FALSE; +} diff --git a/ext/standard/file.h b/ext/standard/file.h index 0f4b521a5b..30e48a4467 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -69,6 +69,7 @@ PHP_FUNCTION(set_file_buffer); PHP_FUNCTION(get_meta_tags); PHP_FUNCTION(flock); PHP_FUNCTION(fd_set); +PHP_FUNCTION(fd_isset); PHP_FUNCTION(select); PHPAPI int _php3_set_sock_blocking(int socketd, int block); -- 2.40.0