xref: /PHP-8.1/ext/iconv/php_iconv.h (revision 01b3fc03)
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    | Authors: Rui Hirokawa <rui_hirokawa@ybb.ne.jp>                       |
14    |          Stig Bakken <ssb@php.net>                                   |
15    +----------------------------------------------------------------------+
16  */
17 
18 #ifndef PHP_ICONV_H
19 #define PHP_ICONV_H
20 
21 #ifdef PHP_WIN32
22 # ifdef PHP_ICONV_EXPORTS
23 #  define PHP_ICONV_API __declspec(dllexport)
24 # else
25 #  define PHP_ICONV_API __declspec(dllimport)
26 # endif
27 #elif defined(__GNUC__) && __GNUC__ >= 4
28 # define PHP_ICONV_API __attribute__ ((visibility("default")))
29 #else
30 # define PHP_ICONV_API
31 #endif
32 
33 #include "php_version.h"
34 #define PHP_ICONV_VERSION PHP_VERSION
35 
36 #ifdef HAVE_ICONV
37 extern zend_module_entry iconv_module_entry;
38 #define iconv_module_ptr &iconv_module_entry
39 
40 PHP_MINIT_FUNCTION(miconv);
41 PHP_MSHUTDOWN_FUNCTION(miconv);
42 PHP_MINFO_FUNCTION(miconv);
43 
44 PHP_NAMED_FUNCTION(php_if_iconv);
45 PHP_FUNCTION(ob_iconv_handler);
46 PHP_FUNCTION(iconv_get_encoding);
47 PHP_FUNCTION(iconv_set_encoding);
48 PHP_FUNCTION(iconv_strlen);
49 PHP_FUNCTION(iconv_substr);
50 PHP_FUNCTION(iconv_strpos);
51 PHP_FUNCTION(iconv_strrpos);
52 PHP_FUNCTION(iconv_mime_encode);
53 PHP_FUNCTION(iconv_mime_decode);
54 PHP_FUNCTION(iconv_mime_decode_headers);
55 
56 ZEND_BEGIN_MODULE_GLOBALS(iconv)
57 	char *input_encoding;
58 	char *internal_encoding;
59 	char *output_encoding;
60 ZEND_END_MODULE_GLOBALS(iconv)
61 
62 #define ICONVG(v) ZEND_MODULE_GLOBALS_ACCESSOR(iconv, v)
63 
64 #if defined(ZTS) && defined(COMPILE_DL_ICONV)
65 ZEND_TSRMLS_CACHE_EXTERN()
66 #endif
67 
68 #ifdef HAVE_IBM_ICONV
69 # define ICONV_ASCII_ENCODING "IBM-850"
70 # define ICONV_UCS4_ENCODING "UCS-4"
71 #else
72 # define ICONV_ASCII_ENCODING "ASCII"
73 # define ICONV_UCS4_ENCODING "UCS-4LE"
74 #endif
75 
76 #ifndef ICONV_CSNMAXLEN
77 #define ICONV_CSNMAXLEN 64
78 #endif
79 
80 /* {{{ typedef enum php_iconv_err_t */
81 typedef enum _php_iconv_err_t {
82 	PHP_ICONV_ERR_SUCCESS           = SUCCESS,
83 	PHP_ICONV_ERR_CONVERTER         = 1,
84 	PHP_ICONV_ERR_WRONG_CHARSET     = 2,
85 	PHP_ICONV_ERR_TOO_BIG           = 3,
86 	PHP_ICONV_ERR_ILLEGAL_SEQ       = 4,
87 	PHP_ICONV_ERR_ILLEGAL_CHAR      = 5,
88 	PHP_ICONV_ERR_UNKNOWN           = 6,
89 	PHP_ICONV_ERR_MALFORMED         = 7,
90 	PHP_ICONV_ERR_ALLOC             = 8,
91 	PHP_ICONV_ERR_OUT_BY_BOUNDS     = 9
92 } php_iconv_err_t;
93 /* }}} */
94 
95 PHP_ICONV_API php_iconv_err_t php_iconv_string(const char * in_p, size_t in_len, zend_string **out, const char *out_charset, const char *in_charset);
96 
97 #else
98 
99 #define iconv_module_ptr NULL
100 
101 #endif /* HAVE_ICONV */
102 
103 #define phpext_iconv_ptr iconv_module_ptr
104 
105 #endif	/* PHP_ICONV_H */
106