cvs: php-src /ext/standard dl.c

From: Date: Fri, 08 Dec 2006 19:13:51 +0000
Subject: cvs: php-src /ext/standard dl.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-41993@lists.php.net to get a copy of this message
andrei Fri Dec 8 19:13:51 2006 UTC Modified files: /php-src/ext/standard dl.c Log: Unicode filename support in dl(). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dl.c?r1=1.110&r2=1.111&diff_format=u Index: php-src/ext/standard/dl.c diff -u php-src/ext/standard/dl.c:1.110 php-src/ext/standard/dl.c:1.111 --- php-src/ext/standard/dl.c:1.110 Sun Oct 8 13:34:23 2006 +++ php-src/ext/standard/dl.c Fri Dec 8 19:13:51 2006 @@ -18,13 +18,14 @@ +----------------------------------------------------------------------+ */ -/* $Id: dl.c,v 1.110 2006/10/08 13:34:23 bjori Exp $ */ +/* $Id: dl.c,v 1.111 2006/12/08 19:13:51 andrei Exp $ */ #include "php.h" #include "dl.h" #include "php_globals.h" #include "php_ini.h" #include "ext/standard/info.h" +#include "ext/standard/file.h" #include "SAPI.h" @@ -52,20 +53,17 @@ #endif /* defined(HAVE_LIBDL) || HAVE_MACH_O_DYLD_H */ -/* {{{ proto int dl(string extension_filename) +/* {{{ proto int dl(string extension_filename) U Load a PHP extension at runtime */ PHP_FUNCTION(dl) { - zval **file; + zval *filename; - /* obtain arguments */ - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &file) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &filename) == FAILURE) { + return; } - convert_to_string_ex(file); - - php_dl(*file, MODULE_TEMPORARY, return_value, 0 TSRMLS_CC); + php_dl(filename, MODULE_TEMPORARY, return_value, 0 TSRMLS_CC); EG(full_tables_cleanup) = 1; } @@ -90,6 +88,8 @@ 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,18 +103,31 @@ 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); - libpath = emalloc(extension_dir_len+Z_STRLEN_P(file)+2); + libpath = emalloc(extension_dir_len+filename_len+2); if (IS_SLASH(extension_dir[extension_dir_len-1])) { - sprintf(libpath, "%s%s", extension_dir, Z_STRVAL_P(file)); /* SAFE */ + sprintf(libpath, "%s%s", extension_dir, filename); /* SAFE */ } else { - sprintf(libpath, "%s%c%s", extension_dir, DEFAULT_SLASH, Z_STRVAL_P(file)); /* SAFE */ + sprintf(libpath, "%s%c%s", extension_dir, DEFAULT_SLASH, filename); /* SAFE */ } } else { - libpath = estrndup(Z_STRVAL_P(file), Z_STRLEN_P(file)); + libpath = estrndup(filename, filename_len); + } + + if (Z_TYPE_P(file) == IS_UNICODE) { + efree(filename); } /* load dynamic symbol */ @@ -141,7 +154,7 @@ if (!get_module) { DL_UNLOAD(handle); - php_error_docref(NULL TSRMLS_CC, error_type, "Invalid library (maybe not a PHP library) '%s'", Z_STRVAL_P(file)); + 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; } module_entry = get_module(); @@ -229,7 +242,7 @@ 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)); + 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)); RETURN_FALSE; }

« previous php.cvs (#41993) next »