1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 7 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) The PHP Group | 6 +----------------------------------------------------------------------+ 7 | This source file is subject to version 3.01 of the PHP license, | 8 | that is bundled with this package in the file LICENSE, and is | 9 | available through the world-wide-web at the following url: | 10 | http://www.php.net/license/3_01.txt | 11 | If you did not receive a copy of the PHP license and are unable to | 12 | obtain it through the world-wide-web, please send a note to | 13 | license@php.net so we can mail you a copy immediately. | 14 +----------------------------------------------------------------------+ 15 | Author: Tsukada Takuya <tsukada@fminn.nagano.nagano.jp> | 16 | Hironori Sato <satoh@jpnnet.com> | 17 | Shigeru Kanemoto <sgk@happysize.co.jp> | 18 +----------------------------------------------------------------------+ 19 */ 20 21 #ifndef _MBSTRING_H 22 #define _MBSTRING_H 23 24 #ifdef COMPILE_DL_MBSTRING 25 #undef HAVE_MBSTRING 26 #define HAVE_MBSTRING 1 27 #endif 28 29 #include "php_version.h" 30 #define PHP_MBSTRING_VERSION PHP_VERSION 31 32 #ifdef PHP_WIN32 33 # undef MBSTRING_API 34 # ifdef MBSTRING_EXPORTS 35 # define MBSTRING_API __declspec(dllexport) 36 # elif defined(COMPILE_DL_MBSTRING) 37 # define MBSTRING_API __declspec(dllimport) 38 # else 39 # define MBSTRING_API /* nothing special */ 40 # endif 41 #elif defined(__GNUC__) && __GNUC__ >= 4 42 # undef MBSTRING_API 43 # define MBSTRING_API __attribute__ ((visibility("default"))) 44 #else 45 # undef MBSTRING_API 46 # define MBSTRING_API /* nothing special */ 47 #endif 48 49 50 #if HAVE_MBSTRING 51 52 #include "libmbfl/mbfl/mbfilter.h" 53 #include "SAPI.h" 54 55 #define PHP_MBSTRING_API 20021024 56 57 extern zend_module_entry mbstring_module_entry; 58 #define mbstring_module_ptr &mbstring_module_entry 59 60 PHP_MINIT_FUNCTION(mbstring); 61 PHP_MSHUTDOWN_FUNCTION(mbstring); 62 PHP_RINIT_FUNCTION(mbstring); 63 PHP_RSHUTDOWN_FUNCTION(mbstring); 64 PHP_MINFO_FUNCTION(mbstring); 65 66 /* functions in php_unicode.c */ 67 PHP_FUNCTION(mb_convert_case); 68 PHP_FUNCTION(mb_strtoupper); 69 PHP_FUNCTION(mb_strtolower); 70 71 /* php function registration */ 72 PHP_FUNCTION(mb_language); 73 PHP_FUNCTION(mb_internal_encoding); 74 PHP_FUNCTION(mb_http_input); 75 PHP_FUNCTION(mb_http_output); 76 PHP_FUNCTION(mb_detect_order); 77 PHP_FUNCTION(mb_substitute_character); 78 PHP_FUNCTION(mb_preferred_mime_name); 79 PHP_FUNCTION(mb_parse_str); 80 PHP_FUNCTION(mb_output_handler); 81 PHP_FUNCTION(mb_str_split); 82 PHP_FUNCTION(mb_strlen); 83 PHP_FUNCTION(mb_strpos); 84 PHP_FUNCTION(mb_strrpos); 85 PHP_FUNCTION(mb_stripos); 86 PHP_FUNCTION(mb_strripos); 87 PHP_FUNCTION(mb_strstr); 88 PHP_FUNCTION(mb_strrchr); 89 PHP_FUNCTION(mb_stristr); 90 PHP_FUNCTION(mb_strrichr); 91 PHP_FUNCTION(mb_substr_count); 92 PHP_FUNCTION(mb_substr); 93 PHP_FUNCTION(mb_strcut); 94 PHP_FUNCTION(mb_strwidth); 95 PHP_FUNCTION(mb_strimwidth); 96 PHP_FUNCTION(mb_convert_encoding); 97 PHP_FUNCTION(mb_detect_encoding); 98 PHP_FUNCTION(mb_list_encodings); 99 PHP_FUNCTION(mb_encoding_aliases); 100 PHP_FUNCTION(mb_convert_kana); 101 PHP_FUNCTION(mb_encode_mimeheader); 102 PHP_FUNCTION(mb_decode_mimeheader); 103 PHP_FUNCTION(mb_convert_variables); 104 PHP_FUNCTION(mb_encode_numericentity); 105 PHP_FUNCTION(mb_decode_numericentity); 106 PHP_FUNCTION(mb_send_mail); 107 PHP_FUNCTION(mb_get_info); 108 PHP_FUNCTION(mb_check_encoding); 109 PHP_FUNCTION(mb_ord); 110 PHP_FUNCTION(mb_chr); 111 PHP_FUNCTION(mb_scrub); 112 113 114 MBSTRING_API char *php_mb_safe_strrchr_ex(const char *s, unsigned int c, 115 size_t nbytes, const mbfl_encoding *enc); 116 MBSTRING_API char *php_mb_safe_strrchr(const char *s, unsigned int c, 117 size_t nbytes); 118 119 MBSTRING_API char *php_mb_convert_encoding_ex( 120 const char *input, size_t length, 121 const mbfl_encoding *to_encoding, const mbfl_encoding *from_encoding, size_t *output_len); 122 MBSTRING_API char * php_mb_convert_encoding(const char *input, size_t length, 123 const char *_to_encoding, 124 const char *_from_encodings, 125 size_t *output_len); 126 127 MBSTRING_API size_t php_mb_mbchar_bytes_ex(const char *s, const mbfl_encoding *enc); 128 MBSTRING_API size_t php_mb_mbchar_bytes(const char *s); 129 130 MBSTRING_API size_t php_mb_stripos(int mode, const char *old_haystack, size_t old_haystack_len, const char *old_needle, size_t old_needle_len, zend_long offset, zend_string *from_encoding); 131 MBSTRING_API int php_mb_check_encoding(const char *input, size_t length, const char *enc); 132 133 ZEND_BEGIN_MODULE_GLOBALS(mbstring) 134 char *internal_encoding_name; 135 const mbfl_encoding *internal_encoding; 136 const mbfl_encoding *current_internal_encoding; 137 const mbfl_encoding *http_output_encoding; 138 const mbfl_encoding *current_http_output_encoding; 139 const mbfl_encoding *http_input_identify; 140 const mbfl_encoding *http_input_identify_get; 141 const mbfl_encoding *http_input_identify_post; 142 const mbfl_encoding *http_input_identify_cookie; 143 const mbfl_encoding *http_input_identify_string; 144 const mbfl_encoding **http_input_list; 145 size_t http_input_list_size; 146 const mbfl_encoding **detect_order_list; 147 size_t detect_order_list_size; 148 const mbfl_encoding **current_detect_order_list; 149 size_t current_detect_order_list_size; 150 enum mbfl_no_encoding *default_detect_order_list; 151 size_t default_detect_order_list_size; 152 int filter_illegal_mode; 153 int filter_illegal_substchar; 154 int current_filter_illegal_mode; 155 int current_filter_illegal_substchar; 156 zend_long func_overload; 157 enum mbfl_no_language language; 158 zend_bool encoding_translation; 159 zend_bool strict_detection; 160 size_t illegalchars; 161 mbfl_buffer_converter *outconv; 162 void *http_output_conv_mimetypes; 163 #if HAVE_MBREGEX 164 struct _zend_mb_regex_globals *mb_regex_globals; 165 zend_long regex_stack_limit; 166 #endif 167 zend_string *last_used_encoding_name; 168 const mbfl_encoding *last_used_encoding; 169 /* Whether an explicit internal_encoding / http_output / http_input encoding was set. */ 170 zend_bool internal_encoding_set; 171 zend_bool http_output_set; 172 zend_bool http_input_set; 173 #if HAVE_MBREGEX 174 zend_long regex_retry_limit; 175 #endif 176 ZEND_END_MODULE_GLOBALS(mbstring) 177 178 #define MB_OVERLOAD_MAIL 1 179 #define MB_OVERLOAD_STRING 2 180 #define MB_OVERLOAD_REGEX 4 181 182 struct mb_overload_def { 183 int type; 184 char *orig_func; 185 char *ovld_func; 186 char *save_func; 187 }; 188 189 #define MBSTRG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mbstring, v) 190 191 #if defined(ZTS) && defined(COMPILE_DL_MBSTRING) 192 ZEND_TSRMLS_CACHE_EXTERN() 193 #endif 194 195 #else /* HAVE_MBSTRING */ 196 197 #define mbstring_module_ptr NULL 198 199 #endif /* HAVE_MBSTRING */ 200 201 #define phpext_mbstring_ptr mbstring_module_ptr 202 203 #endif /* _MBSTRING_H */ 204