xref: /PHP-7.3/ext/mbstring/mbstring.h (revision 738016bd)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 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_strlen);
82 PHP_FUNCTION(mb_strpos);
83 PHP_FUNCTION(mb_strrpos);
84 PHP_FUNCTION(mb_stripos);
85 PHP_FUNCTION(mb_strripos);
86 PHP_FUNCTION(mb_strstr);
87 PHP_FUNCTION(mb_strrchr);
88 PHP_FUNCTION(mb_stristr);
89 PHP_FUNCTION(mb_strrichr);
90 PHP_FUNCTION(mb_substr_count);
91 PHP_FUNCTION(mb_substr);
92 PHP_FUNCTION(mb_strcut);
93 PHP_FUNCTION(mb_strwidth);
94 PHP_FUNCTION(mb_strimwidth);
95 PHP_FUNCTION(mb_convert_encoding);
96 PHP_FUNCTION(mb_detect_encoding);
97 PHP_FUNCTION(mb_list_encodings);
98 PHP_FUNCTION(mb_encoding_aliases);
99 PHP_FUNCTION(mb_convert_kana);
100 PHP_FUNCTION(mb_encode_mimeheader);
101 PHP_FUNCTION(mb_decode_mimeheader);
102 PHP_FUNCTION(mb_convert_variables);
103 PHP_FUNCTION(mb_encode_numericentity);
104 PHP_FUNCTION(mb_decode_numericentity);
105 PHP_FUNCTION(mb_send_mail);
106 PHP_FUNCTION(mb_get_info);
107 PHP_FUNCTION(mb_check_encoding);
108 PHP_FUNCTION(mb_ord);
109 PHP_FUNCTION(mb_chr);
110 PHP_FUNCTION(mb_scrub);
111 
112 
113 MBSTRING_API char *php_mb_safe_strrchr_ex(const char *s, unsigned int c,
114                                     size_t nbytes, const mbfl_encoding *enc);
115 MBSTRING_API char *php_mb_safe_strrchr(const char *s, unsigned int c,
116                                  size_t nbytes);
117 
118 MBSTRING_API char *php_mb_convert_encoding_ex(
119 		const char *input, size_t length,
120 		const mbfl_encoding *to_encoding, const mbfl_encoding *from_encoding, size_t *output_len);
121 MBSTRING_API char * php_mb_convert_encoding(const char *input, size_t length,
122                                       const char *_to_encoding,
123                                       const char *_from_encodings,
124                                       size_t *output_len);
125 
126 MBSTRING_API int php_mb_check_encoding_list(const char *encoding_list);
127 
128 MBSTRING_API size_t php_mb_mbchar_bytes_ex(const char *s, const mbfl_encoding *enc);
129 MBSTRING_API size_t php_mb_mbchar_bytes(const char *s);
130 
131 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, const char *from_encoding);
132 MBSTRING_API int php_mb_check_encoding(const char *input, size_t length, const char *enc);
133 
134 /* internal use only */
135 int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, size_t new_value_length);
136 
137 ZEND_BEGIN_MODULE_GLOBALS(mbstring)
138 	char *internal_encoding_name;
139 	const mbfl_encoding *internal_encoding;
140 	const mbfl_encoding *current_internal_encoding;
141 	const mbfl_encoding *http_output_encoding;
142 	const mbfl_encoding *current_http_output_encoding;
143 	const mbfl_encoding *http_input_identify;
144 	const mbfl_encoding *http_input_identify_get;
145 	const mbfl_encoding *http_input_identify_post;
146 	const mbfl_encoding *http_input_identify_cookie;
147 	const mbfl_encoding *http_input_identify_string;
148 	const mbfl_encoding **http_input_list;
149 	size_t http_input_list_size;
150 	const mbfl_encoding **detect_order_list;
151 	size_t detect_order_list_size;
152 	const mbfl_encoding **current_detect_order_list;
153 	size_t current_detect_order_list_size;
154 	enum mbfl_no_encoding *default_detect_order_list;
155 	size_t default_detect_order_list_size;
156 	int filter_illegal_mode;
157 	int filter_illegal_substchar;
158 	int current_filter_illegal_mode;
159 	int current_filter_illegal_substchar;
160 	zend_long func_overload;
161 	enum mbfl_no_language language;
162 	zend_bool encoding_translation;
163 	zend_bool strict_detection;
164 	size_t illegalchars;
165 	mbfl_buffer_converter *outconv;
166     void *http_output_conv_mimetypes;
167 #if HAVE_MBREGEX
168     struct _zend_mb_regex_globals *mb_regex_globals;
169     zend_long regex_stack_limit;
170 #endif
171 	char *last_used_encoding_name;
172 	const mbfl_encoding *last_used_encoding;
173 ZEND_END_MODULE_GLOBALS(mbstring)
174 
175 #define MB_OVERLOAD_MAIL 1
176 #define MB_OVERLOAD_STRING 2
177 #define MB_OVERLOAD_REGEX 4
178 
179 struct mb_overload_def {
180 	int type;
181 	char *orig_func;
182 	char *ovld_func;
183 	char *save_func;
184 };
185 
186 #define MBSTRG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mbstring, v)
187 
188 #if defined(ZTS) && defined(COMPILE_DL_MBSTRING)
189 ZEND_TSRMLS_CACHE_EXTERN()
190 #endif
191 
192 #else	/* HAVE_MBSTRING */
193 
194 #define mbstring_module_ptr NULL
195 
196 #endif	/* HAVE_MBSTRING */
197 
198 #define phpext_mbstring_ptr mbstring_module_ptr
199 
200 #endif		/* _MBSTRING_H */
201 
202 /*
203  * Local variables:
204  * tab-width: 4
205  * c-basic-offset: 4
206  * End:
207  */
208