xref: /PHP-5.6/ext/mbstring/mbstring.h (revision 49493a2d)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2016 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 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 /* internal use only */
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	/* HAVE_MBSTRING */
209 
210 #define mbstring_module_ptr NULL
211 
212 #endif	/* HAVE_MBSTRING */
213 
214 #define phpext_mbstring_ptr mbstring_module_ptr
215 
216 #endif		/* _MBSTRING_H */
217 
218 /*
219  * Local variables:
220  * tab-width: 4
221  * c-basic-offset: 4
222  * End:
223  */
224