CVS update: php31/ext/standard
| From: | shane | Date: | Thu, 27 Aug 1998 22:16:16 +0000 |
| Subject: | CVS update: php31/ext/standard | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-627@lists.php.net to get a copy of this message | ||
Date: Thursday August 27, 1998 @ 18:16
Author: shane
Update of /repository/php31/ext/standard
In directory asf:/u2/tmp/cvs-serv2413/ext/standard
Modified Files:
dl.c dl.h
Log Message:
more dl optimization.
Index: php31/ext/standard/dl.c
diff -c php31/ext/standard/dl.c:2.3 php31/ext/standard/dl.c:2.4
*** php31/ext/standard/dl.c:2.3 Thu Aug 27 17:42:31 1998
--- php31/ext/standard/dl.c Thu Aug 27 18:16:16 1998
***************
*** 57,62 ****
--- 57,63 ----
#define DL_EXT ".so"
#endif
+
#ifdef THREAD_SAFE
/* FIXME this stuff is only necessary for windows
cross-thread handling of dl's loading from ini file,
***************
*** 66,72 ****
#endif
function_entry dl_functions[] = {
! {"dl", dl, NULL},
{NULL, NULL, NULL}
};
--- 67,73 ----
#endif
function_entry dl_functions[] = {
! {"dl", php3_dl, NULL},
{NULL, NULL, NULL}
};
***************
*** 79,126 ****
int _php3_load_module(php3_module_entry *module_entry, void *handle);
! void dl(INTERNAL_FUNCTION_PARAMETERS)
{
pval *file;
TLS_VARS;
- /* obtain arguments */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
if (!GLOBAL(php3_ini)->enable_dl) {
php3_error(E_ERROR, "Dynamically loaded extentions aren't enabled.");
- } else if (GLOBAL(php3_ini)->safe_mode) {
- php3_error(E_ERROR, "Dynamically loaded extensions aren't allowed when running in SAFE
MODE.");
} else {
convert_to_string(file);
! php3_dl(file->value.str.val,MODULE_TEMPORARY,return_value);
}
}
- #if HAVE_LIBDL
! void php3_dl(char *file,int type,pval *return_value)
{
void *handle;
char filename[MAXPATHLEN + 1];
char libpath[MAXPATHLEN + 1];
php3_module_entry *module_entry;
php3_module_entry *(*get_module)(void);
! TLS_VARS;
! if (cfg_get_string("extension_dir",&GLOBAL(php3_ini)->extension_dir)==SUCCESS
&& GLOBAL(php3_ini)->extension_dir){
int extension_dir_len = strlen(GLOBAL(php3_ini)->extension_dir);
- if (!strstr(file,DL_EXT)){
- /*add the extension on*/
- snprintf(filename,MAXPATHLEN + 1,"%s%s",file,DL_EXT);
- }else{
- snprintf(filename,MAXPATHLEN + 1,"%s",file);
- }
-
if (GLOBAL(php3_ini)->extension_dir[extension_dir_len-1]=='/' ||
GLOBAL(php3_ini)->extension_dir[extension_dir_len-1]=='\\') {
snprintf(libpath,MAXPATHLEN + 1,"%s%s",GLOBAL(php3_ini)->extension_dir,filename);
/* SAFE */
} else {
--- 80,141 ----
int _php3_load_module(php3_module_entry *module_entry, void *handle);
! #if HAVE_LIBDL
! void php3_dl(INTERNAL_FUNCTION_PARAMETERS)
{
pval *file;
TLS_VARS;
if (!GLOBAL(php3_ini)->enable_dl) {
php3_error(E_ERROR, "Dynamically loaded extentions aren't enabled.");
} else {
+ /* obtain arguments */
+ if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
convert_to_string(file);
!
! /* FIXME HELPME we need to have some way to check if the dl is already
! loaded before going through all this stuff. */
!
! _php3_dl(file->value.str.val,MODULE_TEMPORARY,return_value _INLINE_TLS);
}
}
! void _php3_dl(char *file,int type,pval *return_value INLINE_TLS)
{
void *handle;
char filename[MAXPATHLEN + 1];
char libpath[MAXPATHLEN + 1];
php3_module_entry *module_entry;
php3_module_entry *(*get_module)(void);
!
! if (!GLOBAL(php3_ini)->extension_dir && GLOBAL(php3_ini)->safe_mode) {
! /*allowing dl's to be loaded from extension_dir if safe_mode is enabled
! because an isp can shut them off completely with enable_dl*/
! php3_error(E_ERROR, "Dynamically loaded extensions aren't allowed when running in SAFE
MODE.");
! RETURN_FALSE;
! }
! /*verify not using ../ or ./ in path*/
! if (strstr(file,"./")){
! php3_error(E_ERROR, "Invalid Path loading Dynamic Module!");
! RETURN_FALSE;
! }
!
! if (!strstr(file,DL_EXT)){
! /*add the extension on*/
! snprintf(filename,MAXPATHLEN + 1,"%s%s",file,DL_EXT);
! }else{
! snprintf(filename,MAXPATHLEN + 1,"%s",file);
! }
!
! if (GLOBAL(php3_ini)->extension_dir){
int extension_dir_len = strlen(GLOBAL(php3_ini)->extension_dir);
if (GLOBAL(php3_ini)->extension_dir[extension_dir_len-1]=='/' ||
GLOBAL(php3_ini)->extension_dir[extension_dir_len-1]=='\\') {
snprintf(libpath,MAXPATHLEN + 1,"%s%s",GLOBAL(php3_ini)->extension_dir,filename);
/* SAFE */
} else {
***************
*** 130,135 ****
--- 145,151 ----
snprintf(libpath,MAXPATHLEN + 1,"%s",filename); /* SAFE */
}
+
/* load dynamic symbol */
handle = dlopen(libpath, RTLD_LAZY);
if (!handle) {
***************
*** 202,215 ****
\*************************************************/
/* this should be called in every module startup */
! void php3_dlload(){
dl_plist *ins;
pval dummy;
if(dllist){
ins=dllist->next;
do{
! php3_dl(ins->dlname,MODULE_PERSISTENT,&dummy);
ins=ins->next;
}while(ins!=dllist->next);
}
--- 218,231 ----
\*************************************************/
/* this should be called in every module startup */
! void php3_dlload(INLINE_TLS_VOID){
dl_plist *ins;
pval dummy;
if(dllist){
ins=dllist->next;
do{
! _php3_dl(ins->dlname,MODULE_PERSISTENT,&dummy _INLINE_TLS);
ins=ins->next;
}while(ins!=dllist->next);
}
***************
*** 251,257 ****
#endif
#else
! void php3_dl(pval *file,int type,pval *return_value)
{
php3_error(E_WARNING,"Cannot dynamically load %s - dynamic modules are not
supported",file->value.str.val);
RETURN_FALSE;
--- 267,273 ----
#endif
#else
! void php3_dl(INTERNAL_FUNCTION_PARAMETERS)
{
php3_error(E_WARNING,"Cannot dynamically load %s - dynamic modules are not
supported",file->value.str.val);
RETURN_FALSE;
Index: php31/ext/standard/dl.h
diff -c php31/ext/standard/dl.h:2.0 php31/ext/standard/dl.h:2.1
*** php31/ext/standard/dl.h:2.0 Fri Jul 3 09:14:21 1998
--- php31/ext/standard/dl.h Thu Aug 27 18:16:16 1998
***************
*** 30,42 ****
*/
! /* $Id: dl.h,v 2.0 1998/07/03 13:14:21 rasmus Exp $ */
#ifndef _DL_H
#define _DL_H
! extern void php3_dl(char *file,int type,pval *return_value);
! extern void php3_dlload(void);
extern void php3_dladd(char *dlname);
extern void php3_dllist_clear(void);
--- 30,42 ----
*/
! /* $Id: dl.h,v 2.1 1998/08/27 22:16:16 shane Exp $ */
#ifndef _DL_H
#define _DL_H
! extern void _php3_dl(char *file,int type,pval *return_value INLINE_TLS);
! extern void php3_dlload(INLINE_TLS_VOID);
extern void php3_dladd(char *dlname);
extern void php3_dllist_clear(void);
***************
*** 55,61 ****
#endif
/* dynamic loading functions */
! extern void dl(INTERNAL_FUNCTION_PARAMETERS);
extern int php3_minit_dl(INIT_FUNC_ARGS);
extern int php3_mshutdown_dl(void);
extern int php3_rshutdown_dl(void);
--- 55,61 ----
#endif
/* dynamic loading functions */
! extern void php3_dl(INTERNAL_FUNCTION_PARAMETERS);
extern int php3_minit_dl(INIT_FUNC_ARGS);
extern int php3_mshutdown_dl(void);
extern int php3_rshutdown_dl(void);
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net