xref: /PHP-8.2/ext/mbstring/mbstring.h (revision 49202116)
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(int mode, const char *old_haystack, size_t old_haystack_len, const char *old_needle, size_t old_needle_len, zend_long offset, const mbfl_encoding *encoding);
68 MBSTRING_API int php_mb_check_encoding(const char *input, size_t length, const mbfl_encoding *encoding);
69 
70 ZEND_BEGIN_MODULE_GLOBALS(mbstring)
71 	char *internal_encoding_name;
72 	const mbfl_encoding *internal_encoding;
73 	const mbfl_encoding *current_internal_encoding;
74 	const mbfl_encoding *http_output_encoding;
75 	const mbfl_encoding *current_http_output_encoding;
76 	const mbfl_encoding *http_input_identify;
77 	const mbfl_encoding *http_input_identify_get;
78 	const mbfl_encoding *http_input_identify_post;
79 	const mbfl_encoding *http_input_identify_cookie;
80 	const mbfl_encoding *http_input_identify_string;
81 	const mbfl_encoding **http_input_list;
82 	size_t http_input_list_size;
83 	const mbfl_encoding **detect_order_list;
84 	size_t detect_order_list_size;
85 	const mbfl_encoding **current_detect_order_list;
86 	size_t current_detect_order_list_size;
87 	enum mbfl_no_encoding *default_detect_order_list;
88 	size_t default_detect_order_list_size;
89 	int filter_illegal_mode;
90 	int filter_illegal_substchar;
91 	int current_filter_illegal_mode;
92 	int current_filter_illegal_substchar;
93 	enum mbfl_no_language language;
94 	bool encoding_translation;
95 	bool strict_detection;
96 	size_t illegalchars;
97 	mbfl_buffer_converter *outconv;
98     void *http_output_conv_mimetypes;
99 #ifdef HAVE_MBREGEX
100     struct _zend_mb_regex_globals *mb_regex_globals;
101     zend_long regex_stack_limit;
102 #endif
103 	zend_string *last_used_encoding_name;
104 	const mbfl_encoding *last_used_encoding;
105 	/* Whether an explicit internal_encoding / http_output / http_input encoding was set. */
106 	bool internal_encoding_set;
107 	bool http_output_set;
108 	bool http_input_set;
109 #ifdef HAVE_MBREGEX
110     zend_long regex_retry_limit;
111 #endif
112 ZEND_END_MODULE_GLOBALS(mbstring)
113 
114 #define MBSTRG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mbstring, v)
115 
116 #if defined(ZTS) && defined(COMPILE_DL_MBSTRING)
117 ZEND_TSRMLS_CACHE_EXTERN()
118 #endif
119 
120 #endif /* _MBSTRING_H */
121