⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mbstring.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	if (MBSTRG(encoding_translation)) {		sapi_unregister_post_entry(mbstr_post_entries);		sapi_register_post_entries(mbstr_post_entries);		sapi_register_treat_data(mbstr_treat_data);	}	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);	REGISTER_LONG_CONSTANT("MB_OVERLOAD_REGEX", MB_OVERLOAD_REGEX, CONST_CS | CONST_PERSISTENT);	REGISTER_LONG_CONSTANT("MB_CASE_UPPER", PHP_UNICODE_CASE_UPPER, CONST_CS | CONST_PERSISTENT);	REGISTER_LONG_CONSTANT("MB_CASE_LOWER", PHP_UNICODE_CASE_LOWER, CONST_CS | CONST_PERSISTENT);	REGISTER_LONG_CONSTANT("MB_CASE_TITLE", PHP_UNICODE_CASE_TITLE, CONST_CS | CONST_PERSISTENT);#if HAVE_MBREGEX# ifdef ZTS	mbregex_locale_mutex = tsrm_mutex_alloc();# endif#endif	return SUCCESS;}/* }}} *//* {{{ PHP_MSHUTDOWN_FUNCTION(mbstring) */PHP_MSHUTDOWN_FUNCTION(mbstring){	UNREGISTER_INI_ENTRIES();		if (MBSTRG(http_input_list)) {		free(MBSTRG(http_input_list));	}#ifdef ZEND_MULTIBYTE	if (MBSTRG(script_encoding_list)) {		free(MBSTRG(script_encoding_list));	}#endif /* ZEND_MULTIBYTE */	if (MBSTRG(detect_order_list)) {		free(MBSTRG(detect_order_list));	}	if (MBSTRG(encoding_translation)) {		sapi_unregister_post_entry(mbstr_post_entries);		sapi_register_post_entries(php_post_entries);		sapi_register_treat_data(php_default_treat_data);	}#if HAVE_MBREGEX# ifdef ZTS	if (mbregex_locale_mutex != NULL) {		tsrm_mutex_free(mbregex_locale_mutex);	}# endif#endif#ifdef ZTS	ts_free_id(mbstring_globals_id);#else	mbstring_globals_dtor(&mbstring_globals TSRMLS_CC);#endif	return SUCCESS;}/* }}} *//* {{{ PHP_RINIT_FUNCTION(mbstring) */PHP_RINIT_FUNCTION(mbstring){	int n;	enum mbfl_no_encoding *list=NULL, *entry;	zend_function *func, *orig;	const struct mb_overload_def *p;	MBSTRG(current_language) = MBSTRG(language);	if (MBSTRG(internal_encoding) == mbfl_no_encoding_invalid) {		char *default_enc = NULL;		switch (MBSTRG(current_language)) {			case mbfl_no_language_uni:				default_enc = "UTF-8";				break;			case mbfl_no_language_japanese:				default_enc = "EUC-JP";				break;			case mbfl_no_language_korean:				default_enc = "EUC-KR";				break;			case mbfl_no_language_simplified_chinese:				default_enc = "EUC-CN";				break;			case mbfl_no_language_traditional_chinese:				default_enc = "EUC-TW";				break;			case mbfl_no_language_russian:				default_enc = "KOI8-R";				break;			case mbfl_no_language_german:				default_enc = "ISO-8859-15";				break;			case mbfl_no_language_english:			default:				default_enc = "ISO-8859-1";				break;		}		if (default_enc) {			zend_alter_ini_entry("mbstring.internal_encoding",			                     sizeof("mbstring.internal_encoding"),			                     default_enc, strlen(default_enc),			                     PHP_INI_PERDIR, PHP_INI_STAGE_RUNTIME); 		}	}	MBSTRG(current_internal_encoding) = MBSTRG(internal_encoding);	MBSTRG(current_http_output_encoding) = MBSTRG(http_output_encoding);	MBSTRG(current_filter_illegal_mode) = MBSTRG(filter_illegal_mode);	MBSTRG(current_filter_illegal_substchar) = MBSTRG(filter_illegal_substchar);	if (!MBSTRG(encoding_translation)) {		MBSTRG(illegalchars) = 0;	}	n = 0;	if (MBSTRG(detect_order_list)) {		list = MBSTRG(detect_order_list);		n = MBSTRG(detect_order_list_size);	}	if (n <= 0) {		list = MBSTRG(default_detect_order_list);		n = MBSTRG(default_detect_order_list_size);	}	entry = (enum mbfl_no_encoding *)safe_emalloc(n, sizeof(int), 0);	MBSTRG(current_detect_order_list) = entry;	MBSTRG(current_detect_order_list_size) = n;	while (n > 0) {		*entry++ = *list++;		n--;	} 	/* override original function. */	if (MBSTRG(func_overload)){		p = &(mb_ovld[0]);				while (p->type > 0) {			if ((MBSTRG(func_overload) & p->type) == p->type && 				zend_hash_find(EG(function_table), p->save_func,					strlen(p->save_func)+1, (void **)&orig) != SUCCESS) {				zend_hash_find(EG(function_table), p->ovld_func, strlen(p->ovld_func)+1 , (void **)&func);								if (zend_hash_find(EG(function_table), p->orig_func, strlen(p->orig_func)+1, (void **)&orig) != SUCCESS) {					php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't find function %s.", p->orig_func);					return FAILURE;				} else {					zend_hash_add(EG(function_table), p->save_func, strlen(p->save_func)+1, orig, sizeof(zend_function), NULL);					if (zend_hash_update(EG(function_table), p->orig_func, strlen(p->orig_func)+1, func, sizeof(zend_function), 						NULL) == FAILURE) {						php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't replace function %s.", p->orig_func);						return FAILURE;					}				}			}			p++;		}	}#if HAVE_MBREGEX	MBSTRG(regex_default_options) = MBRE_OPTION_POSIXLINE;#endif#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING)	php_mb_set_zend_encoding(TSRMLS_C);#endif /* ZEND_MULTIBYTE && HAVE_MBSTRING */	return SUCCESS;}/* }}} *//* {{{ PHP_RSHUTDOWN_FUNCTION(mbstring) */PHP_RSHUTDOWN_FUNCTION(mbstring){	const struct mb_overload_def *p;	zend_function *orig;	if (MBSTRG(current_detect_order_list) != NULL) {		efree(MBSTRG(current_detect_order_list));		MBSTRG(current_detect_order_list) = NULL;		MBSTRG(current_detect_order_list_size) = 0;	}	if (MBSTRG(outconv) != NULL) {		MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv));		mbfl_buffer_converter_delete(MBSTRG(outconv));		MBSTRG(outconv) = NULL;	}	/* clear http input identification. */	MBSTRG(http_input_identify) = mbfl_no_encoding_invalid;	MBSTRG(http_input_identify_post) = mbfl_no_encoding_invalid;	MBSTRG(http_input_identify_get) = mbfl_no_encoding_invalid;	MBSTRG(http_input_identify_cookie) = mbfl_no_encoding_invalid;	MBSTRG(http_input_identify_string) = mbfl_no_encoding_invalid; 	/*  clear overloaded function. */	if (MBSTRG(func_overload)){		p = &(mb_ovld[0]);		while (p->type > 0 && zend_hash_find(EG(function_table), p->save_func, strlen(p->save_func)+1 , (void **)&orig) == SUCCESS) {			zend_hash_update(EG(function_table), p->orig_func, strlen(p->orig_func)+1, orig, sizeof(zend_function), NULL);			zend_hash_del(EG(function_table), p->save_func, strlen(p->save_func)+1);			p++;		}	}#if HAVE_MBREGEX	MBSTRG(current_mbctype) = MBSTRG(default_mbctype);	if (MBSTRG(search_str)) {		if (ZVAL_REFCOUNT(*MBSTRG(search_str)) > 1) {			ZVAL_DELREF(*MBSTRG(search_str));		} else {			zval_dtor(*MBSTRG(search_str));			FREE_ZVAL(*MBSTRG(search_str));		}		MBSTRG(search_str) = (zval **)0;		MBSTRG(search_str_val) = (zval *)0;	}	MBSTRG(search_pos) = 0;	if (MBSTRG(search_re)) {		efree(MBSTRG(search_re));		MBSTRG(search_re) = (mb_regex_t *)0;	}	if (MBSTRG(search_regs)) {		mbre_free_registers(MBSTRG(search_regs));		efree(MBSTRG(search_regs));		MBSTRG(search_regs) = (struct mbre_registers*)0;	}	zend_hash_clean(&MBSTRG(ht_rc));#endif	return SUCCESS;}/* }}} *//* {{{ PHP_MINFO_FUNCTION(mbstring) */PHP_MINFO_FUNCTION(mbstring){	php_info_print_table_start();	php_info_print_table_row(2, "Multibyte Support", "enabled");	php_info_print_table_row(2, "Japanese support", "enabled");		php_info_print_table_row(2, "Simplified chinese support", "enabled");		php_info_print_table_row(2, "Traditional chinese support", "enabled");		php_info_print_table_row(2, "Korean support", "enabled");		php_info_print_table_row(2, "Russian support", "enabled");		if (MBSTRG(encoding_translation)) {		php_info_print_table_row(2, "HTTP input encoding translation", "enabled");		}#if defined(HAVE_MBREGEX)	php_info_print_table_row(2, "Multibyte (japanese) regex support", "enabled");	#endif	php_info_print_table_end();	php_info_print_table_start();	php_info_print_table_colspan_header(2, "mbstring extension makes use of \"streamable kanji code filter and converter\", which is distributed under the GNU Lesser General Public License version 2.1.");	php_info_print_table_end();	DISPLAY_INI_ENTRIES();}/* }}} *//* {{{ proto string mb_language([string language])   Sets the current language or Returns the current language as a string */PHP_FUNCTION(mb_language){	pval **arg1;	char *name;	enum mbfl_no_language no_language;	if (ZEND_NUM_ARGS() == 0) {		name = (char *)mbfl_no_language2name(MBSTRG(current_language));		if (name != NULL) {			RETURN_STRING(name, 1);		} else {			RETURN_FALSE;		}	} else if (ZEND_NUM_ARGS() == 1 && zend_get_parameters_ex(1, &arg1) != FAILURE) {		convert_to_string_ex(arg1);		no_language = mbfl_name2no_language(Z_STRVAL_PP(arg1));		if (no_language == mbfl_no_language_invalid) {			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown language \"%s\"", Z_STRVAL_PP(arg1));			RETURN_FALSE;		} else {			php_mb_nls_get_default_detect_order_list(no_language, &MBSTRG(default_detect_order_list), &MBSTRG(default_detect_order_list_size));			MBSTRG(current_language) = no_language;			RETURN_TRUE;		}	} else {		WRONG_PARAM_COUNT;	}}/* }}} *//* {{{ proto string mb_internal_encoding([string encoding])   Sets the current internal encoding or Returns the current internal encoding as a string */PHP_FUNCTION(mb_internal_encoding){	pval **arg1;	char *name;	enum mbfl_no_encoding no_encoding;	if (ZEND_NUM_ARGS() == 0) {		name = (char *)mbfl_no_encoding2name(MBSTRG(current_internal_encoding));		if (name != NULL) {			RETURN_STRING(name, 1);		} else {			RETURN_FALSE;		}	} else if (ZEND_NUM_ARGS() == 1 && zend_get_parameters_ex(1, &arg1) != FAILURE) {		convert_to_string_ex(arg1);		no_encoding = mbfl_name2no_encoding(Z_STRVAL_PP(arg1));		if (no_encoding == mbfl_no_encoding_invalid) {			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown encoding \"%s\"", Z_STRVAL_PP(arg1));			RETURN_FALSE;		} else {			MBSTRG(current_internal_encoding) = no_encoding;#ifdef ZEND_MULTIBYTE			zend_multibyte_set_internal_encoding(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1) TSRMLS_CC);#endif /* ZEND_MULTIBYTE */			RETURN_TRUE;		}	} else {		WRONG_PARAM_COUNT;	}}/* }}} *//* {{{ proto mixed mb_http_input([string type])   Returns the input encoding */PHP_FUNCTION(mb_http_input){	pval **arg1;	int result=0, retname, n;	enum mbfl_no_encoding *entry;	char *name, *list, *temp;	retname = 1;	if (ZEND_NUM_ARGS() == 0) {		result = MBSTRG(http_input_identify);	} else if (ARG_COUNT(ht) == 1 && zend_get_parameters_ex(1, &arg1) != FAILURE) {		convert_to_string_ex(arg1);		switch (*(Z_STRVAL_PP(arg1))) {		case 'G':		case 'g':			result = MBSTRG(http_input_identify_get);			break;		case 'P':		case 'p':			result = MBSTRG(http_input_identify_post);			break;		case 'C':		case 'c':			result = MBSTRG(http_input_identify_cookie);			break;		case 'S':		case 's':			result = MBSTRG(http_input_identify_string);			break;		case 'I':		case 'i':			if (array_init(return_value) == FAILURE) {				RETURN_FALSE;			}			entry = MBSTRG(http_input_list);			n = MBSTRG(http_input_list_size);			while (n > 0) {				name = (char *)mbfl_no_encoding2name(*entry);				if (name) {					add_next_index_string(return_value, name, 1);				}				entry++;				n--;			}			retname = 0;			break;		case 'L':		case 'l':			entry = MBSTRG(http_input_list);			n = MBSTRG(http_input_list_size);			list = NULL;			while (n > 0) {				name = (char *)mbfl_no_encoding2name(*entry);				if (name) {					if (list) {						temp = list;						spprintf(&list, 0, "%s,%s", temp, name);						efree(temp);						if (!list) { 							break;						}					} else {						list = estrdup(name);					}				}				entry++;				n--;			}			if (!list) {				RETURN_FALSE;			}			RETVAL_STRING(list, 0);			retname = 0;			break;		default:			result = MBSTRG(http_input_identify);			break;		}	} else {		WRONG_PARAM_COUNT;	}	if (retname) {		name = (char *)mbfl_no_encoding2name(result);		if (name != NULL) {			RETVAL_STRING(name, 1);		} else {			RETVAL_FALSE;		}	}}/* }}} *//* {{{ proto string mb_http_output([string encoding])   Sets the current output_encoding or returns the current output_encoding as a string */PHP_FUNCTION(mb_http_output){	pval **arg1;	char *name;	enum mbfl_no_encoding no_encoding;	if (ZEND_NUM_ARGS() == 0) {		name = (char *)mbfl_no_encoding2name(MBSTRG(current_http_output_encoding));		if (name != NULL) {			RETURN_STRING(name, 1);		} else {			RETURN_FALSE;		}	} else if (ZEND_NUM_ARGS() == 1 && zend_get_parameters_ex(1, &arg1) != FAILURE) {		convert_to_string_ex(arg1);		no_encoding = mbfl_name2no_encoding(Z_STRVAL_PP(arg1));		if (no_encoding == mbfl_no_encoding_invalid) {			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown encoding \"%s\"", Z_STRVAL_PP(arg1));			RETURN_FALSE;		} else {			MBSTRG(current_http_output_encoding) = no_encoding;			RETURN_TRUE;		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -