diff options
author | Rui Hirokawa <hirokawa@php.net> | 2001-12-16 22:58:24 +0000 |
---|---|---|
committer | Rui Hirokawa <hirokawa@php.net> | 2001-12-16 22:58:24 +0000 |
commit | 26e30dc606b06e05c59d0c62275aa4e08672045d (patch) | |
tree | ff11879c95c106d8359025b4118ae0dbae592ad6 | |
parent | 8e5e7efc5b96ecadf094d011a1fabcc6d642313d (diff) | |
download | php-git-26e30dc606b06e05c59d0c62275aa4e08672045d.tar.gz |
added an option mbstring.func_overload to overload some function by multibyte enabled version of function in mbstring.
-rw-r--r-- | ext/mbstring/mbstring.c | 25 | ||||
-rw-r--r-- | ext/mbstring/mbstring.h | 4 |
2 files changed, 24 insertions, 5 deletions
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index cfca15cd41..7c35478761 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -373,11 +373,12 @@ static PHP_INI_MH(OnUpdate_mbstring_substitute_character) /* php.ini directive registration */ PHP_INI_BEGIN() - PHP_INI_ENTRY("mbstring.detect_order", NULL, PHP_INI_ALL, OnUpdate_mbstring_detect_order) - PHP_INI_ENTRY("mbstring.http_input", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_input) - PHP_INI_ENTRY("mbstring.http_output", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_output) - PHP_INI_ENTRY("mbstring.internal_encoding", NULL, PHP_INI_ALL, OnUpdate_mbstring_internal_encoding) - PHP_INI_ENTRY("mbstring.substitute_character", NULL, PHP_INI_ALL, OnUpdate_mbstring_substitute_character) + PHP_INI_ENTRY("mbstring.detect_order", NULL, PHP_INI_ALL, OnUpdate_mbstring_detect_order) + PHP_INI_ENTRY("mbstring.http_input", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_input) + PHP_INI_ENTRY("mbstring.http_output", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_output) + PHP_INI_ENTRY("mbstring.internal_encoding", NULL, PHP_INI_ALL, OnUpdate_mbstring_internal_encoding) + PHP_INI_ENTRY("mbstring.substitute_character", NULL, PHP_INI_ALL, OnUpdate_mbstring_substitute_character) + STD_PHP_INI_ENTRY("mbstring.func_overload", "0", PHP_INI_SYSTEM, OnUpdateInt, func_overload, zend_mbstring_globals, mbstring_globals) PHP_INI_END() @@ -406,6 +407,8 @@ php_mbstring_init_globals(zend_mbstring_globals *pglobals) pglobals->filter_illegal_substchar = 0x3f; /* '?' */ pglobals->current_filter_illegal_mode = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR; pglobals->current_filter_illegal_substchar = 0x3f; /* '?' */ + pglobals->func_overload = 0; + pglobals->orig_mail = (zend_function *)NULL; pglobals->outconv = NULL; } @@ -467,6 +470,18 @@ PHP_RINIT_FUNCTION(mbstring) } } + /* override original mail() function with mb_send_mail(). */ + if ((MBSTRG(func_overload) & MB_OVERLOAD_MAIL) == MB_OVERLOAD_MAIL && + !MBSTRG(orig_mail)){ + zend_hash_find(EG(function_table), "mb_send_mail", sizeof("mb_send_mail"), (void **)&func); + zend_hash_find(EG(function_table), "mail", sizeof("mail"), (void **)&MBSTRG(orig_mail)); + if (zend_hash_del(EG(function_table), "mail",sizeof("mail")) != FAILURE) { + zend_hash_add(EG(function_table), "mail",sizeof("mail"),func, sizeof(zend_function), NULL); + } else { + zend_error(E_ERROR, "mbtring couldn't replace mail()."); + } + } + return SUCCESS; } diff --git a/ext/mbstring/mbstring.h b/ext/mbstring/mbstring.h index 2632111740..56cc557d9d 100644 --- a/ext/mbstring/mbstring.h +++ b/ext/mbstring/mbstring.h @@ -55,6 +55,8 @@ #include "mbfilter.h" +#define MB_OVERLOAD_MAIL 1 + extern zend_module_entry mbstring_module_entry; #define mbstring_module_ptr &mbstring_module_entry @@ -113,6 +115,8 @@ ZEND_BEGIN_MODULE_GLOBALS(mbstring) int filter_illegal_substchar; int current_filter_illegal_mode; int current_filter_illegal_substchar; + int func_overload; + zend_function *orig_mail; mbfl_buffer_converter *outconv; ZEND_END_MODULE_GLOBALS(mbstring); |