xref: /PHP-7.0/ext/mbstring/mbstring.h (revision 478f119a)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2017 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 #include "php_version.h"
55 #define PHP_MBSTRING_VERSION PHP_VERSION
56 
57 #ifdef PHP_WIN32
58 #	undef MBSTRING_API
59 #	ifdef MBSTRING_EXPORTS
60 #		define MBSTRING_API __declspec(dllexport)
61 #	elif defined(COMPILE_DL_MBSTRING)
62 #		define MBSTRING_API __declspec(dllimport)
63 #	else
64 #		define MBSTRING_API /* nothing special */
65 #	endif
66 #elif defined(__GNUC__) && __GNUC__ >= 4
67 #	undef MBSTRING_API
68 #	define MBSTRING_API __attribute__ ((visibility("default")))
69 #else
70 #	undef MBSTRING_API
71 #	define MBSTRING_API /* nothing special */
72 #endif
73 
74 
75 #if HAVE_MBSTRING
76 
77 #include "libmbfl/mbfl/mbfilter.h"
78 #include "SAPI.h"
79 
80 #define PHP_MBSTRING_API 20021024
81 
82 extern zend_module_entry mbstring_module_entry;
83 #define mbstring_module_ptr &mbstring_module_entry
84 
85 PHP_MINIT_FUNCTION(mbstring);
86 PHP_MSHUTDOWN_FUNCTION(mbstring);
87 PHP_RINIT_FUNCTION(mbstring);
88 PHP_RSHUTDOWN_FUNCTION(mbstring);
89 PHP_MINFO_FUNCTION(mbstring);
90 
91 /* functions in php_unicode.c */
92 PHP_FUNCTION(mb_convert_case);
93 PHP_FUNCTION(mb_strtoupper);
94 PHP_FUNCTION(mb_strtolower);
95 
96 /* php function registration */
97 PHP_FUNCTION(mb_language);
98 PHP_FUNCTION(mb_internal_encoding);
99 PHP_FUNCTION(mb_http_input);
100 PHP_FUNCTION(mb_http_output);
101 PHP_FUNCTION(mb_detect_order);
102 PHP_FUNCTION(mb_substitute_character);
103 PHP_FUNCTION(mb_preferred_mime_name);
104 PHP_FUNCTION(mb_parse_str);
105 PHP_FUNCTION(mb_output_handler);
106 PHP_FUNCTION(mb_strlen);
107 PHP_FUNCTION(mb_strpos);
108 PHP_FUNCTION(mb_strrpos);
109 PHP_FUNCTION(mb_stripos);
110 PHP_FUNCTION(mb_strripos);
111 PHP_FUNCTION(mb_strstr);
112 PHP_FUNCTION(mb_strrchr);
113 PHP_FUNCTION(mb_stristr);
114 PHP_FUNCTION(mb_strrichr);
115 PHP_FUNCTION(mb_substr_count);
116 PHP_FUNCTION(mb_substr);
117 PHP_FUNCTION(mb_strcut);
118 PHP_FUNCTION(mb_strwidth);
119 PHP_FUNCTION(mb_strimwidth);
120 PHP_FUNCTION(mb_convert_encoding);
121 PHP_FUNCTION(mb_detect_encoding);
122 PHP_FUNCTION(mb_list_encodings);
123 PHP_FUNCTION(mb_encoding_aliases);
124 PHP_FUNCTION(mb_convert_kana);
125 PHP_FUNCTION(mb_encode_mimeheader);
126 PHP_FUNCTION(mb_decode_mimeheader);
127 PHP_FUNCTION(mb_convert_variables);
128 PHP_FUNCTION(mb_encode_numericentity);
129 PHP_FUNCTION(mb_decode_numericentity);
130 PHP_FUNCTION(mb_send_mail);
131 PHP_FUNCTION(mb_get_info);
132 PHP_FUNCTION(mb_check_encoding);
133 
134 MBSTRING_API char *php_mb_safe_strrchr_ex(const char *s, unsigned int c,
135                                     size_t nbytes, const mbfl_encoding *enc);
136 MBSTRING_API char *php_mb_safe_strrchr(const char *s, unsigned int c,
137                                  size_t nbytes);
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);
143 
144 MBSTRING_API int php_mb_check_encoding_list(const char *encoding_list);
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);
148 
149 MBSTRING_API int php_mb_encoding_detector_ex(const char *arg_string, int arg_length,
150 											 char *arg_list);
151 
152 MBSTRING_API int php_mb_encoding_converter_ex(char **str, int *len, const char *encoding_to,
153 											  const char *encoding_from);
154 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);
155 
156 /* internal use only */
157 int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_value_length);
158 
159 ZEND_BEGIN_MODULE_GLOBALS(mbstring)
160 	char *internal_encoding_name;
161 	enum mbfl_no_language language;
162 	const mbfl_encoding *internal_encoding;
163 	const mbfl_encoding *current_internal_encoding;
164 	const mbfl_encoding *http_output_encoding;
165 	const mbfl_encoding *current_http_output_encoding;
166 	const mbfl_encoding *http_input_identify;
167 	const mbfl_encoding *http_input_identify_get;
168 	const mbfl_encoding *http_input_identify_post;
169 	const mbfl_encoding *http_input_identify_cookie;
170 	const mbfl_encoding *http_input_identify_string;
171 	const mbfl_encoding **http_input_list;
172 	size_t http_input_list_size;
173 	const mbfl_encoding **detect_order_list;
174 	size_t detect_order_list_size;
175 	const mbfl_encoding **current_detect_order_list;
176 	size_t current_detect_order_list_size;
177 	enum mbfl_no_encoding *default_detect_order_list;
178 	size_t default_detect_order_list_size;
179 	int filter_illegal_mode;
180 	int filter_illegal_substchar;
181 	int current_filter_illegal_mode;
182 	int current_filter_illegal_substchar;
183 	long func_overload;
184 	zend_bool encoding_translation;
185 	long strict_detection;
186 	long illegalchars;
187 	mbfl_buffer_converter *outconv;
188     void *http_output_conv_mimetypes;
189 #if HAVE_MBREGEX
190     struct _zend_mb_regex_globals *mb_regex_globals;
191 #endif
192 ZEND_END_MODULE_GLOBALS(mbstring)
193 
194 #define MB_OVERLOAD_MAIL 1
195 #define MB_OVERLOAD_STRING 2
196 #define MB_OVERLOAD_REGEX 4
197 
198 struct mb_overload_def {
199 	int type;
200 	char *orig_func;
201 	char *ovld_func;
202 	char *save_func;
203 };
204 
205 #define MBSTRG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mbstring, v)
206 
207 #if defined(ZTS) && defined(COMPILE_DL_MBSTRING)
208 ZEND_TSRMLS_CACHE_EXTERN()
209 #endif
210 
211 #else	/* HAVE_MBSTRING */
212 
213 #define mbstring_module_ptr NULL
214 
215 #endif	/* HAVE_MBSTRING */
216 
217 #define phpext_mbstring_ptr mbstring_module_ptr
218 
219 #endif		/* _MBSTRING_H */
220 
221 /*
222  * Local variables:
223  * tab-width: 4
224  * c-basic-offset: 4
225  * End:
226  */
227