1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 5 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1997-2013 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 +----------------------------------------------------------------------+ 17 */ 18 19 /* $Id$ */ 20 21 /* 22 * PHP 4 Multibyte String module "mbstring" (currently only for Japanese) 23 * 24 * History: 25 * 2000.5.19 Release php-4.0RC2_jstring-1.0 26 * 2001.4.1 Release php4_jstring-1.0.91 27 * 2001.4.30 Release php4-jstring-1.1 (contribute to The PHP Group) 28 * 2001.5.1 Renamed from jstring to mbstring (hirokawa@php.net) 29 */ 30 31 /* 32 * PHP3 Internationalization support program. 33 * 34 * Copyright (c) 1999,2000 by the PHP3 internationalization team. 35 * All rights reserved. 36 * 37 * See README_PHP3-i18n-ja for more detail. 38 * 39 * Authors: 40 * Hironori Sato <satoh@jpnnet.com> 41 * Shigeru Kanemoto <sgk@happysize.co.jp> 42 * Tsukada Takuya <tsukada@fminn.nagano.nagano.jp> 43 */ 44 45 46 #ifndef _MBSTRING_H 47 #define _MBSTRING_H 48 49 #ifdef COMPILE_DL_MBSTRING 50 #undef HAVE_MBSTRING 51 #define HAVE_MBSTRING 1 52 #endif 53 54 #ifdef PHP_WIN32 55 # undef MBSTRING_API 56 # ifdef MBSTRING_EXPORTS 57 # define MBSTRING_API __declspec(dllexport) 58 # elif defined(COMPILE_DL_MBSTRING) 59 # define MBSTRING_API __declspec(dllimport) 60 # else 61 # define MBSTRING_API /* nothing special */ 62 # endif 63 #elif defined(__GNUC__) && __GNUC__ >= 4 64 # undef MBSTRING_API 65 # define MBSTRING_API __attribute__ ((visibility("default"))) 66 #else 67 # undef MBSTRING_API 68 # define MBSTRING_API /* nothing special */ 69 #endif 70 71 72 #if HAVE_MBSTRING 73 74 #include "libmbfl/mbfl/mbfilter.h" 75 #include "SAPI.h" 76 77 #define PHP_MBSTRING_API 20021024 78 79 extern zend_module_entry mbstring_module_entry; 80 #define mbstring_module_ptr &mbstring_module_entry 81 82 PHP_MINIT_FUNCTION(mbstring); 83 PHP_MSHUTDOWN_FUNCTION(mbstring); 84 PHP_RINIT_FUNCTION(mbstring); 85 PHP_RSHUTDOWN_FUNCTION(mbstring); 86 PHP_MINFO_FUNCTION(mbstring); 87 88 /* functions in php_unicode.c */ 89 PHP_FUNCTION(mb_convert_case); 90 PHP_FUNCTION(mb_strtoupper); 91 PHP_FUNCTION(mb_strtolower); 92 93 /* php function registration */ 94 PHP_FUNCTION(mb_language); 95 PHP_FUNCTION(mb_internal_encoding); 96 PHP_FUNCTION(mb_http_input); 97 PHP_FUNCTION(mb_http_output); 98 PHP_FUNCTION(mb_detect_order); 99 PHP_FUNCTION(mb_substitute_character); 100 PHP_FUNCTION(mb_preferred_mime_name); 101 PHP_FUNCTION(mb_parse_str); 102 PHP_FUNCTION(mb_output_handler); 103 PHP_FUNCTION(mb_strlen); 104 PHP_FUNCTION(mb_strpos); 105 PHP_FUNCTION(mb_strrpos); 106 PHP_FUNCTION(mb_stripos); 107 PHP_FUNCTION(mb_strripos); 108 PHP_FUNCTION(mb_strstr); 109 PHP_FUNCTION(mb_strrchr); 110 PHP_FUNCTION(mb_stristr); 111 PHP_FUNCTION(mb_strrichr); 112 PHP_FUNCTION(mb_substr_count); 113 PHP_FUNCTION(mb_substr); 114 PHP_FUNCTION(mb_strcut); 115 PHP_FUNCTION(mb_strwidth); 116 PHP_FUNCTION(mb_strimwidth); 117 PHP_FUNCTION(mb_convert_encoding); 118 PHP_FUNCTION(mb_detect_encoding); 119 PHP_FUNCTION(mb_list_encodings); 120 PHP_FUNCTION(mb_encoding_aliases); 121 PHP_FUNCTION(mb_convert_kana); 122 PHP_FUNCTION(mb_encode_mimeheader); 123 PHP_FUNCTION(mb_decode_mimeheader); 124 PHP_FUNCTION(mb_convert_variables); 125 PHP_FUNCTION(mb_encode_numericentity); 126 PHP_FUNCTION(mb_decode_numericentity); 127 PHP_FUNCTION(mb_send_mail); 128 PHP_FUNCTION(mb_get_info); 129 PHP_FUNCTION(mb_check_encoding); 130 131 MBSTRING_API int php_mb_encoding_translation(TSRMLS_D); 132 133 MBSTRING_API char *php_mb_safe_strrchr_ex(const char *s, unsigned int c, 134 size_t nbytes, const mbfl_encoding *enc); 135 MBSTRING_API char *php_mb_safe_strrchr(const char *s, unsigned int c, 136 size_t nbytes TSRMLS_DC); 137 MBSTRING_API char *php_mb_strrchr(const char *s, char c TSRMLS_DC); 138 139 MBSTRING_API char * php_mb_convert_encoding(const char *input, size_t length, 140 const char *_to_encoding, 141 const char *_from_encodings, 142 size_t *output_len TSRMLS_DC); 143 144 MBSTRING_API int php_mb_check_encoding_list(const char *encoding_list TSRMLS_DC); 145 146 MBSTRING_API size_t php_mb_mbchar_bytes_ex(const char *s, const mbfl_encoding *enc); 147 MBSTRING_API size_t php_mb_mbchar_bytes(const char *s TSRMLS_DC); 148 149 MBSTRING_API size_t php_mb_gpc_mbchar_bytes(const char *s TSRMLS_DC); 150 151 MBSTRING_API int php_mb_encoding_detector_ex(const char *arg_string, int arg_length, 152 char *arg_list TSRMLS_DC); 153 154 MBSTRING_API int php_mb_encoding_converter_ex(char **str, int *len, const char *encoding_to, 155 const char *encoding_from TSRMLS_DC); 156 MBSTRING_API int php_mb_gpc_encoding_converter(char **str, int *len, int num, const char *encoding_to, const char *encoding_from TSRMLS_DC); 157 158 MBSTRING_API int php_mb_gpc_encoding_detector(char **arg_string, int *arg_length, int num, char *arg_list TSRMLS_DC); 159 160 MBSTRING_API int php_mb_stripos(int mode, const char *old_haystack, unsigned int old_haystack_len, const char *old_needle, unsigned int old_needle_len, long offset, const char *from_encoding TSRMLS_DC); 161 162 /* internal use only */ 163 int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_value_length TSRMLS_DC); 164 165 ZEND_BEGIN_MODULE_GLOBALS(mbstring) 166 enum mbfl_no_language language; 167 enum mbfl_no_encoding internal_encoding; 168 enum mbfl_no_encoding current_internal_encoding; 169 #ifdef ZEND_MULTIBYTE 170 enum mbfl_no_encoding *script_encoding_list; 171 int script_encoding_list_size; 172 #endif /* ZEND_MULTIBYTE */ 173 enum mbfl_no_encoding http_output_encoding; 174 enum mbfl_no_encoding current_http_output_encoding; 175 enum mbfl_no_encoding http_input_identify; 176 enum mbfl_no_encoding http_input_identify_get; 177 enum mbfl_no_encoding http_input_identify_post; 178 enum mbfl_no_encoding http_input_identify_cookie; 179 enum mbfl_no_encoding http_input_identify_string; 180 enum mbfl_no_encoding *http_input_list; 181 int http_input_list_size; 182 enum mbfl_no_encoding *detect_order_list; 183 int detect_order_list_size; 184 enum mbfl_no_encoding *current_detect_order_list; 185 int current_detect_order_list_size; 186 enum mbfl_no_encoding *default_detect_order_list; 187 int default_detect_order_list_size; 188 int filter_illegal_mode; 189 int filter_illegal_substchar; 190 int current_filter_illegal_mode; 191 int current_filter_illegal_substchar; 192 long func_overload; 193 zend_bool encoding_translation; 194 long strict_detection; 195 long illegalchars; 196 mbfl_buffer_converter *outconv; 197 void *http_output_conv_mimetypes; 198 #if HAVE_MBREGEX 199 struct _zend_mb_regex_globals *mb_regex_globals; 200 #endif 201 ZEND_END_MODULE_GLOBALS(mbstring) 202 203 #define MB_OVERLOAD_MAIL 1 204 #define MB_OVERLOAD_STRING 2 205 #define MB_OVERLOAD_REGEX 4 206 207 struct mb_overload_def { 208 int type; 209 char *orig_func; 210 char *ovld_func; 211 char *save_func; 212 }; 213 214 #ifdef ZTS 215 #define MBSTRG(v) TSRMG(mbstring_globals_id, zend_mbstring_globals *, v) 216 #else 217 #define MBSTRG(v) (mbstring_globals.v) 218 #endif 219 220 #else /* HAVE_MBSTRING */ 221 222 #define mbstring_module_ptr NULL 223 224 #endif /* HAVE_MBSTRING */ 225 226 #define phpext_mbstring_ptr mbstring_module_ptr 227 228 #endif /* _MBSTRING_H */ 229 230 /* 231 * Local variables: 232 * tab-width: 4 233 * c-basic-offset: 4 234 * End: 235 */ 236