1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
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
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
89 PHP_FUNCTION(mb_convert_case);
90 PHP_FUNCTION(mb_strtoupper);
91 PHP_FUNCTION(mb_strtolower);
92
93
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 char *php_mb_safe_strrchr_ex(const char *s, unsigned int c,
132 size_t nbytes, const mbfl_encoding *enc);
133 MBSTRING_API char *php_mb_safe_strrchr(const char *s, unsigned int c,
134 size_t nbytes TSRMLS_DC);
135
136 MBSTRING_API char * php_mb_convert_encoding(const char *input, size_t length,
137 const char *_to_encoding,
138 const char *_from_encodings,
139 size_t *output_len TSRMLS_DC);
140
141 MBSTRING_API int php_mb_check_encoding_list(const char *encoding_list TSRMLS_DC);
142
143 MBSTRING_API size_t php_mb_mbchar_bytes_ex(const char *s, const mbfl_encoding *enc);
144 MBSTRING_API size_t php_mb_mbchar_bytes(const char *s TSRMLS_DC);
145
146 MBSTRING_API int php_mb_encoding_detector_ex(const char *arg_string, int arg_length,
147 char *arg_list TSRMLS_DC);
148
149 MBSTRING_API int php_mb_encoding_converter_ex(char **str, int *len, const char *encoding_to,
150 const char *encoding_from TSRMLS_DC);
151 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);
152
153
154 int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_value_length TSRMLS_DC);
155
156 ZEND_BEGIN_MODULE_GLOBALS(mbstring)
157 char *internal_encoding_name;
158 enum mbfl_no_language language;
159 const mbfl_encoding *internal_encoding;
160 const mbfl_encoding *current_internal_encoding;
161 const mbfl_encoding *http_output_encoding;
162 const mbfl_encoding *current_http_output_encoding;
163 const mbfl_encoding *http_input_identify;
164 const mbfl_encoding *http_input_identify_get;
165 const mbfl_encoding *http_input_identify_post;
166 const mbfl_encoding *http_input_identify_cookie;
167 const mbfl_encoding *http_input_identify_string;
168 const mbfl_encoding **http_input_list;
169 size_t http_input_list_size;
170 const mbfl_encoding **detect_order_list;
171 size_t detect_order_list_size;
172 const mbfl_encoding **current_detect_order_list;
173 size_t current_detect_order_list_size;
174 enum mbfl_no_encoding *default_detect_order_list;
175 size_t default_detect_order_list_size;
176 int filter_illegal_mode;
177 int filter_illegal_substchar;
178 int current_filter_illegal_mode;
179 int current_filter_illegal_substchar;
180 long func_overload;
181 zend_bool encoding_translation;
182 long strict_detection;
183 long illegalchars;
184 mbfl_buffer_converter *outconv;
185 void *http_output_conv_mimetypes;
186 #if HAVE_MBREGEX
187 struct _zend_mb_regex_globals *mb_regex_globals;
188 #endif
189 ZEND_END_MODULE_GLOBALS(mbstring)
190
191 #define MB_OVERLOAD_MAIL 1
192 #define MB_OVERLOAD_STRING 2
193 #define MB_OVERLOAD_REGEX 4
194
195 struct mb_overload_def {
196 int type;
197 char *orig_func;
198 char *ovld_func;
199 char *save_func;
200 };
201
202 #ifdef ZTS
203 #define MBSTRG(v) TSRMG(mbstring_globals_id, zend_mbstring_globals *, v)
204 #else
205 #define MBSTRG(v) (mbstring_globals.v)
206 #endif
207
208 #else
209
210 #define mbstring_module_ptr NULL
211
212 #endif
213
214 #define phpext_mbstring_ptr mbstring_module_ptr
215
216 #endif
217
218
219
220
221
222
223