CVS update: php3/functions

From: Date: Sat, 19 Jun 1999 02:35:16 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-7138@lists.php.net to get a copy of this message
Date: Friday June 18, 1999 @ 22:35 Author: jim Update of /repository/php3/functions In directory php:/tmp/cvs-serv3441/functions Modified Files: basic_functions.c info.c info.h Log Message: Add extension_loaded function. Something similar should be added in PHP4, but with thread safety. Index: php3/functions/basic_functions.c diff -u php3/functions/basic_functions.c:1.265 php3/functions/basic_functions.c:1.266 --- php3/functions/basic_functions.c:1.265 Wed Jun 16 07:34:17 1999 +++ php3/functions/basic_functions.c Fri Jun 18 22:35:15 1999 @@ -28,7 +28,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.265 1999/06/16 11:34:17 ssb Exp $ */ +/* $Id: basic_functions.c,v 1.266 1999/06/19 02:35:15 jim Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif @@ -171,6 +171,7 @@ {"parse_str", php3_parsestr, NULL}, {"phpinfo", php3_info, NULL}, {"phpversion", php3_version, NULL}, + PHP_FE(extension_loaded, NULL) {"strlen", php3_strlen, NULL}, {"strcmp", php3_strcmp, NULL}, {"strspn", php3_strspn, NULL}, Index: php3/functions/info.c diff -u php3/functions/info.c:1.75 php3/functions/info.c:1.76 --- php3/functions/info.c:1.75 Tue May 18 22:06:06 1999 +++ php3/functions/info.c Fri Jun 18 22:35:16 1999 @@ -28,12 +28,13 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.c,v 1.75 1999/05/19 02:06:06 rasmus Exp $ */ +/* $Id: info.c,v 1.76 1999/06/19 02:35:16 jim Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif #include "php.h" +#include "internal_functions.h" #include "head.h" #include "info.h" #ifndef MSVC5 @@ -425,7 +426,45 @@ { TLS_VARS; - RETURN_STRING(PHP_VERSION,1); + RETURN_STRING(PHP_VERSION,1); +} +/* }}} */ + +static int extension_found; +static char *finding_extension; + +static int _find_extension(php3_module_entry *module) +{ + TLS_VARS; + + if (strcmp(finding_extension, module->name) == 0) { + extension_found = 1; + } + + return 0; +} + +/* {{{ proto bool extension_loaded(string) + Returns true if the specified extension is loaded. */ +PHP_FUNCTION(extension_loaded) +{ + pval *extension; + TLS_VARS; + + if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &extension) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_string(extension); + + /* What would be nice is if we could pass our own little chunk of data + to _php3_hash_apply to pass on to our function so we didn't rely + on static data. */ + finding_extension = extension->value.str.val; + extension_found = 0; + _php3_hash_apply(&GLOBAL(module_registry),(int (*)(void *))_find_extension); + finding_extension = NULL; + + RETURN_LONG(extension_found); } /* }}} */ Index: php3/functions/info.h diff -u php3/functions/info.h:1.6 php3/functions/info.h:1.7 --- php3/functions/info.h:1.6 Fri Jan 1 12:59:12 1999 +++ php3/functions/info.h Fri Jun 18 22:35:16 1999 @@ -27,13 +27,14 @@ | Zeev Suraski <bourbon@netvision.net.il> | +----------------------------------------------------------------------+ */ -/* $Id: info.h,v 1.6 1999/01/01 17:59:12 zeev Exp $ */ +/* $Id: info.h,v 1.7 1999/06/19 02:35:16 jim Exp $ */ #ifndef _INFO_H #define _INFO_H extern void php3_version(INTERNAL_FUNCTION_PARAMETERS); extern void php3_info(INTERNAL_FUNCTION_PARAMETERS); +extern PHP_FUNCTION(extension_loaded); extern void _php3_info(void);

« previous php.dev (#7138) next »