cvs: php4 /ext/mbstring mbstring.c mbstring.h

From: Date: Mon, 07 Jan 2002 02:40:54 +0000
Subject: cvs: php4 /ext/mbstring mbstring.c mbstring.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8968@lists.php.net to get a copy of this message
hirokawa Sun Jan 6 21:40:54 2002 EDT Modified files: /php4/ext/mbstring mbstring.c mbstring.h Log: @added mb_get_info() to get internal settings of mbstring. Index: php4/ext/mbstring/mbstring.c diff -u php4/ext/mbstring/mbstring.c:1.39 php4/ext/mbstring/mbstring.c:1.40 --- php4/ext/mbstring/mbstring.c:1.39 Wed Dec 26 10:21:13 2001 +++ php4/ext/mbstring/mbstring.c Sun Jan 6 21:40:54 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.39 2001/12/26 15:21:13 hirokawa Exp $ */ +/* $Id: mbstring.c,v 1.40 2002/01/07 02:40:54 hirokawa Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -124,6 +124,7 @@ PHP_FE(mb_encode_numericentity, NULL) PHP_FE(mb_decode_numericentity, NULL) PHP_FE(mb_send_mail, NULL) + PHP_FE(mb_get_info, NULL) PHP_FALIAS(mbstrlen, mb_strlen, NULL) PHP_FALIAS(mbstrpos, mb_strpos, NULL) PHP_FALIAS(mbstrrpos, mb_strrpos, NULL) @@ -430,6 +431,9 @@ sapi_register_post_entries(mbstr_post_entries); #endif + REGISTER_LONG_CONSTANT("MB_OVERLOAD_MAIL", MB_OVERLOAD_MAIL, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MB_OVERLOAD_STRING", MB_OVERLOAD_STRING, CONST_CS | CONST_PERSISTENT); + return SUCCESS; } @@ -2685,6 +2689,66 @@ } #endif /* HAVE_SENDMAIL */ + +/* {{{ proto string mb_get_info([string type]) + Returns the current settings of mbstring. */ +PHP_FUNCTION(mb_get_info) +{ + zval **type; + char *name; + int argc = ZEND_NUM_ARGS(); + + if (argc < 0 || argc > 1 || zend_get_parameters_ex(1, &type) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_string_ex(type); + + if (argc == 0 || !strcasecmp("all", Z_STRVAL_PP(type))) { + if (array_init(return_value) == FAILURE) { + RETURN_FALSE; + } + if ((name = (char *)mbfl_no_encoding2name(MBSTRG(current_internal_encoding))) + != NULL) { + add_assoc_string(return_value, "internal_encoding", name, 1); + } + if ((name = (char *)mbfl_no_encoding2name(MBSTRG(http_input_identify))) + != NULL) { + add_assoc_string(return_value, "http_input", name, 1); + } + if ((name = (char *)mbfl_no_encoding2name(MBSTRG(current_http_output_encoding))) + != NULL) { + add_assoc_string(return_value, "http_output", name, 1); + } + if ((name = (char *)mbfl_no_encoding2name(MBSTRG(func_overload))) + != NULL) { + add_assoc_string(return_value, "func_overload", name, 1); + } + } else if (!strcasecmp("internal_encoding", Z_STRVAL_PP(type))) { + if ((name = (char *)mbfl_no_encoding2name(MBSTRG(current_internal_encoding))) + != NULL) { + RETVAL_STRING(name, 1); + } + } else if (!strcasecmp("http_input", Z_STRVAL_PP(type))) { + if ((name = (char *)mbfl_no_encoding2name(MBSTRG(http_input_identify))) + != NULL) { + RETVAL_STRING(name, 1); + } + } else if (!strcasecmp("http_output", Z_STRVAL_PP(type))) { + if ((name = (char *)mbfl_no_encoding2name(MBSTRG(current_http_output_encoding))) + != NULL) { + RETVAL_STRING(name, 1); + } + } else if (!strcasecmp("func_overload", Z_STRVAL_PP(type))) { + if ((name = (char *)mbfl_no_encoding2name(MBSTRG(func_overload))) + != NULL) { + RETVAL_STRING(name, 1); + } + } else { + RETURN_FALSE; + } +} +/* }}} */ #endif /* HAVE_MBSTRING */ Index: php4/ext/mbstring/mbstring.h diff -u php4/ext/mbstring/mbstring.h:1.11 php4/ext/mbstring/mbstring.h:1.12 --- php4/ext/mbstring/mbstring.h:1.11 Wed Dec 26 10:21:13 2001 +++ php4/ext/mbstring/mbstring.h Sun Jan 6 21:40:54 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.h,v 1.11 2001/12/26 15:21:13 hirokawa Exp $ */ +/* $Id: mbstring.h,v 1.12 2002/01/07 02:40:54 hirokawa Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -90,6 +90,7 @@ PHP_FUNCTION(mb_encode_numericentity); PHP_FUNCTION(mb_decode_numericentity); PHP_FUNCTION(mb_send_mail); +PHP_FUNCTION(mb_get_info); ZEND_BEGIN_MODULE_GLOBALS(mbstring) int language;

« previous php.cvs (#8968) next »