[PHP-CVS] cvs: php-src /ext/standard dl.c dl.h

2008-05-16 Thread Felipe Pena
felipe  Fri May 16 12:11:15 2008 UTC

  Modified files:  
/php-src/ext/standard   dl.c dl.h 
  Log:
  - Improved fix (used 's' in parameter parsing)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dl.c?r1=1.126r2=1.127diff_format=u
Index: php-src/ext/standard/dl.c
diff -u php-src/ext/standard/dl.c:1.126 php-src/ext/standard/dl.c:1.127
--- php-src/ext/standard/dl.c:1.126 Fri May 16 03:11:56 2008
+++ php-src/ext/standard/dl.c   Fri May 16 12:11:15 2008
@@ -18,7 +18,7 @@
+--+
 */
 
-/* $Id: dl.c,v 1.126 2008/05/16 03:11:56 felipe Exp $ */
+/* $Id: dl.c,v 1.127 2008/05/16 12:11:15 felipe Exp $ */
 
 #include php.h
 #include dl.h
@@ -54,15 +54,14 @@
Load a PHP extension at runtime */
 PHP_FUNCTION(dl)
 {
-   zval *filename;
+   char *filename;
+   int filename_len;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z/, filename) 
== FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, filename, 
filename_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv))) == FAILURE) {
return;
}
-   
-   convert_to_string(filename);
 
-   if (Z_STRLEN_P(filename) = MAXPATHLEN) {
+   if (filename_len = MAXPATHLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, File name exceeds 
the maximum allowed length of %d characters, MAXPATHLEN);
RETURN_FALSE;
}
@@ -72,10 +71,10 @@
(strncmp(sapi_module.name, embed, 5) != 0)
) {
 #ifdef ZTS
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Not supported in 
multithreaded Web servers - use extension=%s in your php.ini, 
Z_STRVAL_P(filename));
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Not supported in 
multithreaded Web servers - use extension=%s in your php.ini, filename);
RETURN_FALSE;
 #else
-   php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, dl() is 
deprecated - use extension=%s in your php.ini, Z_STRVAL_P(filename));
+   php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, dl() is 
deprecated - use extension=%s in your php.ini, filename);
 #endif
}
 
@@ -243,29 +242,14 @@
 
 /* {{{ php_dl
  */
-PHPAPI void php_dl(zval *file, int type, zval *return_value, int start_now 
TSRMLS_DC)
+PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now 
TSRMLS_DC)
 {
-   char *filename;
-   int filename_len;
-   
-   if (Z_TYPE_P(file) == IS_UNICODE) {
-   if (FAILURE == php_stream_path_encode(NULL, filename, 
filename_len, Z_USTRVAL_P(file), Z_USTRLEN_P(file), REPORT_ERRORS, 
FG(default_context))) {
-   return;
-   }
-   } else {
-   filename = Z_STRVAL_P(file);
-   }
-
/* Load extension */
-   if (php_load_extension(filename, type, start_now TSRMLS_CC) == FAILURE) 
{
+   if (php_load_extension(file, type, start_now TSRMLS_CC) == FAILURE) {
RETVAL_FALSE;
} else {
RETVAL_TRUE;
}
-
-   if (Z_TYPE_P(file) == IS_UNICODE) {
-   efree(filename);
-   }
 }
 /* }}} */
 
@@ -276,9 +260,9 @@
 
 #else
 
-PHPAPI void php_dl(zval *file, int type, zval *return_value, int start_now 
TSRMLS_DC)
+PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now 
TSRMLS_DC)
 {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot dynamically load %R 
- dynamic modules are not supported, Z_TYPE_P(file), Z_UNIVAL_P(file));
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot dynamically load %s 
- dynamic modules are not supported, file);
RETURN_FALSE;
 }
 
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dl.h?r1=1.28r2=1.29diff_format=u
Index: php-src/ext/standard/dl.h
diff -u php-src/ext/standard/dl.h:1.28 php-src/ext/standard/dl.h:1.29
--- php-src/ext/standard/dl.h:1.28  Mon Dec 31 07:12:15 2007
+++ php-src/ext/standard/dl.h   Fri May 16 12:11:15 2008
@@ -18,13 +18,13 @@
+--+
 */
 
-/* $Id: dl.h,v 1.28 2007/12/31 07:12:15 sebastian Exp $ */
+/* $Id: dl.h,v 1.29 2008/05/16 12:11:15 felipe Exp $ */
 
 #ifndef DL_H
 #define DL_H
 
 PHPAPI int php_load_extension(char *filename, int type, int start_now 
TSRMLS_DC);
-PHPAPI void php_dl(zval *file,int type, zval *return_value, int start_now 
TSRMLS_DC);
+PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now 
TSRMLS_DC);
 
 /* dynamic loading functions */
 PHPAPI PHP_FUNCTION(dl);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/standard dl.c dl.h /main php_ini.c

2007-11-09 Thread Jani Taskinen
janiFri Nov  9 16:26:55 2007 UTC

  Modified files:  
/php-src/ext/standard   dl.c dl.h 
/php-src/main   php_ini.c 
  Log:
  - Allow using full path to load modules using extension directive
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dl.c?r1=1.121r2=1.122diff_format=u
Index: php-src/ext/standard/dl.c
diff -u php-src/ext/standard/dl.c:1.121 php-src/ext/standard/dl.c:1.122
--- php-src/ext/standard/dl.c:1.121 Fri Nov  9 13:49:06 2007
+++ php-src/ext/standard/dl.c   Fri Nov  9 16:26:55 2007
@@ -18,7 +18,7 @@
+--+
 */
 
-/* $Id: dl.c,v 1.121 2007/11/09 13:49:06 jani Exp $ */
+/* $Id: dl.c,v 1.122 2007/11/09 16:26:55 jani Exp $ */
 
 #include php.h
 #include dl.h
@@ -80,7 +80,7 @@
 
 /* {{{ php_dl
  */
-void php_dl(zval *file, int type, zval *return_value, int start_now TSRMLS_DC)
+PHPAPI int php_load_extension(char *filename, int type, int start_now 
TSRMLS_DC) /* {{{ */
 {
void *handle;
char *libpath;
@@ -88,8 +88,6 @@
zend_module_entry *(*get_module)(void);
int error_type;
char *extension_dir;
-   char *filename;
-   int filename_len;
 
if (type == MODULE_PERSISTENT) {
extension_dir = INI_STR(extension_dir);
@@ -103,24 +101,16 @@
error_type = E_CORE_WARNING;
}
 
-   if (Z_TYPE_P(file) == IS_UNICODE) {
-   if (FAILURE == php_stream_path_encode(NULL, filename, 
filename_len, Z_USTRVAL_P(file), Z_USTRLEN_P(file), REPORT_ERRORS, 
FG(default_context))) {
-   return;
-   }
-   } else {
-   filename = Z_STRVAL_P(file);
-   filename_len = Z_STRLEN_P(file);
-   }
-
-   if (extension_dir  extension_dir[0]){
-   int extension_dir_len = strlen(extension_dir);
-
+   /* Check if passed filename contains directory separators */
+   if (strchr(filename, '/') != NULL || strchr(filename, DEFAULT_SLASH) != 
NULL) {
+   /* Passing modules with full path is not supported for 
dynamically loaded extensions */
if (type == MODULE_TEMPORARY) {
-   if (strchr(filename, '/') != NULL || strchr(filename, 
DEFAULT_SLASH) != NULL) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
Temporary module name should contain only filename);
-   RETURN_FALSE;
-   }
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Temporary 
module name should contain only filename);
+   return FAILURE;
}
+   libpath = estrdup(filename);
+   } else if (extension_dir  extension_dir[0]) {
+   int extension_dir_len = strlen(extension_dir);
 
if (IS_SLASH(extension_dir[extension_dir_len-1])) {
spprintf(libpath, 0, %s%s, extension_dir, filename); 
/* SAFE */
@@ -128,11 +118,7 @@
spprintf(libpath, 0, %s%c%s, extension_dir, 
DEFAULT_SLASH, filename); /* SAFE */
}
} else {
-   libpath = estrndup(filename, filename_len);
-   }
-
-   if (Z_TYPE_P(file) == IS_UNICODE) {
-   efree(filename);
+   return FAILURE; /* Not full path given or extension_dir is not 
set */
}
 
/* load dynamic symbol */
@@ -141,9 +127,8 @@
php_error_docref(NULL TSRMLS_CC, error_type, Unable to load 
dynamic library '%s' - %s, libpath, GET_DL_ERROR());
GET_DL_ERROR(); /* free the buffer storing the error */
efree(libpath);
-   RETURN_FALSE;
+   return FAILURE;
}
-
efree(libpath);
 
get_module = (zend_module_entry *(*)(void)) DL_FETCH_SYMBOL(handle, 
get_module);
@@ -158,8 +143,8 @@
 
if (!get_module) {
DL_UNLOAD(handle);
-   php_error_docref(NULL TSRMLS_CC, error_type, Invalid library 
(maybe not a PHP library) '%R', Z_TYPE_P(file), Z_UNIVAL_P(file));
-   RETURN_FALSE;
+   php_error_docref(NULL TSRMLS_CC, error_type, Invalid library 
(maybe not a PHP library) '%s', filename);
+   return FAILURE;
}
module_entry = get_module();
if ((module_entry-zend_debug != ZEND_DEBUG) ||
@@ -213,7 +198,7 @@
name, zend_api, zend_debug, zts,
ZEND_MODULE_API_NO, ZEND_DEBUG, 
USING_ZTS);
DL_UNLOAD(handle);
-   RETURN_FALSE;
+   return FAILURE;
}
module_entry-type = type;
module_entry-module_number = zend_next_free_module();
@@ -221,22 +206,50 @@
 
if ((module_entry = zend_register_module_ex(module_entry TSRMLS_CC)) == 
NULL) {
DL_UNLOAD(handle);
-   RETURN_FALSE;
+   

[PHP-CVS] cvs: php-src /ext/standard dl.c dl.h /main php_ini.c /sapi/cli php_cli.c

2005-08-08 Thread Jani Taskinen
sniper  Mon Aug  8 12:49:45 2005 EDT

  Modified files:  
/php-src/ext/standard   dl.c dl.h 
/php-src/main   php_ini.c 
/php-src/sapi/cli   php_cli.c 
  Log:
  - Fixed problem with -dextension=foobar.so not having it's MINIT run.
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/dl.c?r1=1.105r2=1.106ty=u
Index: php-src/ext/standard/dl.c
diff -u php-src/ext/standard/dl.c:1.105 php-src/ext/standard/dl.c:1.106
--- php-src/ext/standard/dl.c:1.105 Wed Aug  3 10:07:58 2005
+++ php-src/ext/standard/dl.c   Mon Aug  8 12:49:43 2005
@@ -18,7 +18,7 @@
+--+
 */
 
-/* $Id: dl.c,v 1.105 2005/08/03 14:07:58 sniper Exp $ */
+/* $Id: dl.c,v 1.106 2005/08/08 16:49:43 sniper Exp $ */
 
 #include php.h
 #include dl.h
@@ -84,7 +84,7 @@
 #endif
}
 
-   php_dl(*file, MODULE_TEMPORARY, return_value TSRMLS_CC);
+   php_dl(*file, MODULE_TEMPORARY, return_value, 0 TSRMLS_CC);
EG(full_tables_cleanup) = 1;
 }
 
@@ -101,7 +101,7 @@
 
 /* {{{ php_dl
  */
-void php_dl(zval *file, int type, zval *return_value TSRMLS_DC)
+void php_dl(zval *file, int type, zval *return_value, int start_now TSRMLS_DC)
 {
void *handle;
char *libpath;
@@ -223,12 +223,12 @@
RETURN_FALSE;
}
 
-   if (type == MODULE_TEMPORARY  zend_startup_module_ex(module_entry 
TSRMLS_CC) == FAILURE) {
+   if ((type == MODULE_TEMPORARY || start_now)  
zend_startup_module_ex(module_entry TSRMLS_CC) == FAILURE) {
DL_UNLOAD(handle);
RETURN_FALSE;
}
 
-   if ((type == MODULE_TEMPORARY)  module_entry-request_startup_func) {
+   if ((type == MODULE_TEMPORARY || start_now)  
module_entry-request_startup_func) {
if (module_entry-request_startup_func(type, 
module_entry-module_number TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, error_type, Unable to 
initialize module '%s', module_entry-name);
DL_UNLOAD(handle);
@@ -246,7 +246,7 @@
 
 #else
 
-void php_dl(zval *file, int type, zval *return_value TSRMLS_DC)
+void php_dl(zval *file, int type, zval *return_value, int start_now TSRMLS_DC)
 {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot dynamically load %s 
- dynamic modules are not supported, Z_STRVAL_P(file));
RETURN_FALSE;
http://cvs.php.net/diff.php/php-src/ext/standard/dl.h?r1=1.22r2=1.23ty=u
Index: php-src/ext/standard/dl.h
diff -u php-src/ext/standard/dl.h:1.22 php-src/ext/standard/dl.h:1.23
--- php-src/ext/standard/dl.h:1.22  Wed Aug  3 10:07:58 2005
+++ php-src/ext/standard/dl.h   Mon Aug  8 12:49:43 2005
@@ -18,12 +18,12 @@
+--+
 */
 
-/* $Id: dl.h,v 1.22 2005/08/03 14:07:58 sniper Exp $ */
+/* $Id: dl.h,v 1.23 2005/08/08 16:49:43 sniper Exp $ */
 
 #ifndef DL_H
 #define DL_H
 
-PHPAPI void php_dl(zval *file,int type, zval *return_value TSRMLS_DC);
+PHPAPI void php_dl(zval *file,int type, zval *return_value, int start_now 
TSRMLS_DC);
 
 /* dynamic loading functions */
 PHP_FUNCTION(dl);
http://cvs.php.net/diff.php/php-src/main/php_ini.c?r1=1.135r2=1.136ty=u
Index: php-src/main/php_ini.c
diff -u php-src/main/php_ini.c:1.135 php-src/main/php_ini.c:1.136
--- php-src/main/php_ini.c:1.135Wed Aug  3 10:08:34 2005
+++ php-src/main/php_ini.c  Mon Aug  8 12:49:43 2005
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_ini.c,v 1.135 2005/08/03 14:08:34 sniper Exp $ */
+/* $Id: php_ini.c,v 1.136 2005/08/08 16:49:43 sniper Exp $ */
 
 #include php.h
 #include ext/standard/info.h
@@ -242,7 +242,7 @@
zval *extension = (zval *) arg;
zval zval;
 
-   php_dl(extension, MODULE_PERSISTENT, zval TSRMLS_CC);
+   php_dl(extension, MODULE_PERSISTENT, zval, 0 TSRMLS_CC);
 }
 /* }}} */
 
http://cvs.php.net/diff.php/php-src/sapi/cli/php_cli.c?r1=1.128r2=1.129ty=u
Index: php-src/sapi/cli/php_cli.c
diff -u php-src/sapi/cli/php_cli.c:1.128 php-src/sapi/cli/php_cli.c:1.129
--- php-src/sapi/cli/php_cli.c:1.128Mon Aug  8 04:45:33 2005
+++ php-src/sapi/cli/php_cli.c  Mon Aug  8 12:49:44 2005
@@ -20,7 +20,7 @@
+--+
 */
 
-/* $Id: php_cli.c,v 1.128 2005/08/08 08:45:33 hholzgra Exp $ */
+/* $Id: php_cli.c,v 1.129 2005/08/08 16:49:44 sniper Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -438,7 +438,7 @@
if (!strcasecmp(name, extension)) { /* load function module */
zval extension, zval;
ZVAL_STRING(extension, value, 0);
-   php_dl(extension, MODULE_TEMPORARY, zval TSRMLS_CC);
+   php_dl(extension, MODULE_PERSISTENT, zval, 1 TSRMLS_CC);
} else {
zend_alter_ini_entry(name, strlen(name)+1, value, 
strlen(value), PHP_INI_SYSTEM,