From 34c493ea0719652aa6bd539144f93121ed38ccf7 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 17 Mar 2006 13:45:43 +0000 Subject: [PATCH] Unicode support for dl() patch. --- main/SAPI.h | 1 + main/main.c | 32 +++++++++++--------------------- main/php_main.h | 3 --- sapi/cgi/cgi_main.c | 12 ++++++++---- sapi/cli/php_cli.c | 12 ++++++++---- sapi/embed/php_embed.c | 9 +++++++-- 6 files changed, 35 insertions(+), 34 deletions(-) diff --git a/main/SAPI.h b/main/SAPI.h index 9abf29b0fc..6fa66db6fd 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -260,6 +260,7 @@ struct _sapi_module_struct { int phpinfo_as_text; char *ini_entries; + zend_function_entry *additional_functions; }; diff --git a/main/main.c b/main/main.c index b0c6246815..0ea62ffffe 100644 --- a/main/main.c +++ b/main/main.c @@ -1680,6 +1680,17 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod /* start Zend extensions */ zend_startup_extensions(); + /* register additional functions */ + if (sapi_module.additional_functions) { + zend_module_entry *module; + + if (zend_hash_find(&module_registry, "standard", sizeof("standard"), (void**)&module)==SUCCESS) { + EG(current_module) = module; + zend_register_functions(NULL, sapi_module.additional_functions, NULL, MODULE_PERSISTENT TSRMLS_CC); + EG(current_module) = NULL; + } + } + UG(unicode) = orig_unicode; zend_post_startup(TSRMLS_C); @@ -1692,27 +1703,6 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod } /* }}} */ -/* {{{ php_enable_dl - */ -int php_enable_dl() -{ - zend_module_entry *module; - static zend_function_entry dl_functions[] = { - ZEND_FE(dl, NULL) - { NULL, NULL, NULL } - }; - int ret = FAILURE; - TSRMLS_FETCH(); - - if (zend_hash_find(&module_registry, "standard", sizeof("standard"), (void**)&module)==SUCCESS) { - EG(current_module) = module; - ret = zend_register_functions(NULL, dl_functions, NULL, MODULE_PERSISTENT TSRMLS_CC); - EG(current_module) = NULL; - } - return ret; -} -/* }}} */ - void php_module_shutdown_for_exec() { /* used to close fd's in the range 3.255 here, but it's problematic */ diff --git a/main/php_main.h b/main/php_main.h index 3560f91941..27b725133e 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -55,9 +55,6 @@ extern void php_free_shutdown_functions(TSRMLS_D); extern int php_init_environ(void); extern int php_shutdown_environ(void); -/* dl() support */ -PHPAPI int php_enable_dl(void); - END_EXTERN_C() #endif diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index d9ac678686..b8633c751c 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -468,8 +468,7 @@ static int sapi_cgi_deactivate(TSRMLS_D) static int php_cgi_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module, NULL, 0) == FAILURE || - php_enable_dl() == FAILURE) { + if (php_module_startup(sapi_module, NULL, 0) == FAILURE) { return FAILURE; } return SUCCESS; @@ -510,6 +509,11 @@ static sapi_module_struct cgi_sapi_module = { }; /* }}} */ +static zend_function_entry additional_functions[] = { + ZEND_FE(dl, NULL) + {NULL, NULL, NULL} +}; + /* {{{ php_cgi_usage */ static void php_cgi_usage(char *argv0) @@ -1003,10 +1007,10 @@ int main(int argc, char *argv[]) #endif cgi_sapi_module.executable_location = argv[0]; + cgi_sapi_module.additional_functions = additional_functions; /* startup after we get the above ini override se we get things right */ - if (php_module_startup(&cgi_sapi_module, NULL, 0) == FAILURE || - php_enable_dl() == FAILURE) { + if (php_module_startup(&cgi_sapi_module, NULL, 0) == FAILURE) { #ifdef ZTS tsrm_shutdown(); #endif diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 2248e3d776..864975414c 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -328,8 +328,7 @@ static void sapi_cli_send_header(sapi_header_struct *sapi_header, void *server_c static int php_cli_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module, NULL, 0)==FAILURE || - php_enable_dl()==FAILURE) { + if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { return FAILURE; } return SUCCESS; @@ -391,6 +390,11 @@ static sapi_module_struct cli_sapi_module = { }; /* }}} */ +static zend_function_entry additional_functions[] = { + ZEND_FE(dl, NULL) + {NULL, NULL, NULL} +}; + /* {{{ php_cli_usage */ static void php_cli_usage(char *argv0) @@ -672,6 +676,7 @@ int main(int argc, char *argv[]) php_optarg = orig_optarg; cli_sapi_module.executable_location = argv[0]; + cli_sapi_module.additional_functions = additional_functions; #ifdef ZTS compiler_globals = ts_resource(compiler_globals_id); @@ -682,8 +687,7 @@ int main(int argc, char *argv[]) #endif /* startup after we get the above ini override se we get things right */ - if (php_module_startup(&cli_sapi_module, NULL, 0)==FAILURE || - php_enable_dl()==FAILURE) { + if (php_module_startup(&cli_sapi_module, NULL, 0)==FAILURE) { /* there is no way to see if we must call zend_ini_deactivate() * since we cannot check if EG(ini_directives) has been initialised * because the executor's constructor does not set initialize it. diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c index ec9476e6e9..9ed446b840 100644 --- a/sapi/embed/php_embed.c +++ b/sapi/embed/php_embed.c @@ -93,8 +93,7 @@ static void php_embed_register_variables(zval *track_vars_array TSRMLS_DC) static int php_embed_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module, NULL, 0)==FAILURE || - php_enable_dl()==FAILURE) { + if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { return FAILURE; } return SUCCESS; @@ -132,6 +131,11 @@ sapi_module_struct php_embed_module = { }; /* }}} */ +static zend_function_entry additional_functions[] = { + ZEND_FE(dl, NULL) + {NULL, NULL, NULL} +}; + int php_embed_init(int argc, char **argv PTSRMLS_DC) { zend_llist global_vars; @@ -174,6 +178,7 @@ int php_embed_init(int argc, char **argv PTSRMLS_DC) *ptsrm_ls = tsrm_ls; #endif + php_embed_module.additional_functions = additional_functions; sapi_startup(&php_embed_module); if (php_embed_module.startup(&php_embed_module)==FAILURE) { -- 2.50.1