xref: /php-src/ext/mbstring/mbstring.h (revision 3ab10da7)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | https://www.php.net/license/3_01.txt                                 |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Author: Tsukada Takuya <tsukada@fminn.nagano.nagano.jp>              |
14    |         Hironori Sato <satoh@jpnnet.com>                             |
15    |         Shigeru Kanemoto <sgk@happysize.co.jp>                       |
16    +----------------------------------------------------------------------+
17  */
18 
19 #ifndef _MBSTRING_H
20 #define _MBSTRING_H
21 
22 #include "php_version.h"
23 #define PHP_MBSTRING_VERSION PHP_VERSION
24 
25 #ifdef PHP_WIN32
26 #	undef MBSTRING_API
27 #	ifdef MBSTRING_EXPORTS
28 #		define MBSTRING_API __declspec(dllexport)
29 #	elif defined(COMPILE_DL_MBSTRING)
30 #		define MBSTRING_API __declspec(dllimport)
31 #	else
32 #		define MBSTRING_API /* nothing special */
33 #	endif
34 #elif defined(__GNUC__) && __GNUC__ >= 4
35 #	undef MBSTRING_API
36 #	define MBSTRING_API __attribute__ ((visibility("default")))
37 #else
38 #	undef MBSTRING_API
39 #	define MBSTRING_API /* nothing special */
40 #endif
41 
42 #include "libmbfl/mbfl/mbfilter.h"
43 #include "SAPI.h"
44 
45 #define PHP_MBSTRING_API 20021024
46 
47 extern zend_module_entry mbstring_module_entry;
48 #define phpext_mbstring_ptr &mbstring_module_entry
49 
50 PHP_MINIT_FUNCTION(mbstring);
51 PHP_MSHUTDOWN_FUNCTION(mbstring);
52 PHP_RINIT_FUNCTION(mbstring);
53 PHP_RSHUTDOWN_FUNCTION(mbstring);
54 PHP_MINFO_FUNCTION(mbstring);
55 
56 MBSTRING_API char *php_mb_safe_strrchr(const char *s, unsigned int c, size_t nbytes, const mbfl_encoding *enc);
57 
58 MBSTRING_API zend_string* php_mb_convert_encoding_ex(
59 		const char *input, size_t length,
60 		const mbfl_encoding *to_encoding, const mbfl_encoding *from_encoding);
61 MBSTRING_API zend_string* php_mb_convert_encoding(
62 		const char *input, size_t length, const mbfl_encoding *to_encoding,
63 		const mbfl_encoding **from_encodings, size_t num_from_encodings);
64 
65 MBSTRING_API size_t php_mb_mbchar_bytes(const char *s, const mbfl_encoding *enc);
66 
67 MBSTRING_API size_t php_mb_stripos(bool mode, zend_string *haystack, zend_string *needle, zend_long offset, const mbfl_encoding *enc);
68 MBSTRING_API bool php_mb_check_encoding(const char *input, size_t length, const mbfl_encoding *encoding);
69 
70 MBSTRING_API const mbfl_encoding* mb_guess_encoding_for_strings(const unsigned char **strings, size_t *str_lengths, size_t n, const mbfl_encoding **elist, unsigned int elist_size, bool strict, bool order_significant);
71 
72 ZEND_BEGIN_MODULE_GLOBALS(mbstring)
73 	char *internal_encoding_name;
74 	const mbfl_encoding *internal_encoding;
75 	const mbfl_encoding *current_internal_encoding;
76 	const mbfl_encoding *http_output_encoding;
77 	const mbfl_encoding *current_http_output_encoding;
78 	const mbfl_encoding *http_input_identify;
79 	const mbfl_encoding *http_input_identify_get;
80 	const mbfl_encoding *http_input_identify_post;
81 	const mbfl_encoding *http_input_identify_cookie;
82 	const mbfl_encoding *http_input_identify_string;
83 	const mbfl_encoding **http_input_list;
84 	size_t http_input_list_size;
85 	const mbfl_encoding **detect_order_list;
86 	size_t detect_order_list_size;
87 	const mbfl_encoding **current_detect_order_list;
88 	size_t current_detect_order_list_size;
89 	enum mbfl_no_encoding *default_detect_order_list;
90 	size_t default_detect_order_list_size;
91 	HashTable *all_encodings_list;
92 	int filter_illegal_mode;
93 	uint32_t filter_illegal_substchar;
94 	int current_filter_illegal_mode;
95 	uint32_t current_filter_illegal_substchar;
96 	enum mbfl_no_language language;
97 	bool encoding_translation;
98 	bool strict_detection;
99 	size_t illegalchars;
100 	bool outconv_enabled;
101 	unsigned int outconv_state;
102     void *http_output_conv_mimetypes;
103 #ifdef HAVE_MBREGEX
104     struct _zend_mb_regex_globals *mb_regex_globals;
105     zend_long regex_stack_limit;
106 #endif
107 	zend_string *last_used_encoding_name;
108 	const mbfl_encoding *last_used_encoding;
109 	/* Whether an explicit internal_encoding / http_output / http_input encoding was set. */
110 	bool internal_encoding_set;
111 	bool http_output_set;
112 	bool http_input_set;
113 #ifdef HAVE_MBREGEX
114     zend_long regex_retry_limit;
115 #endif
116 ZEND_END_MODULE_GLOBALS(mbstring)
117 
118 #define MBSTRG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mbstring, v)
119 
120 #if defined(ZTS) && defined(COMPILE_DL_MBSTRING)
121 ZEND_TSRMLS_CACHE_EXTERN()
122 #endif
123 
124 #endif /* _MBSTRING_H */
125