xref: /PHP-7.1/ext/iconv/php_iconv.h (revision ccd4716e)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 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    | Authors: Rui Hirokawa <rui_hirokawa@ybb.ne.jp>                       |
16    |          Stig Bakken <ssb@php.net>                                   |
17    +----------------------------------------------------------------------+
18  */
19 
20 /* $Id: 88766408cdeacfcbba56e228a175f2ee616642c9 $ */
21 
22 #ifndef PHP_ICONV_H
23 #define PHP_ICONV_H
24 
25 #ifdef PHP_WIN32
26 # ifdef PHP_ICONV_EXPORTS
27 #  define PHP_ICONV_API __declspec(dllexport)
28 # else
29 #  define PHP_ICONV_API __declspec(dllimport)
30 # endif
31 #elif defined(__GNUC__) && __GNUC__ >= 4
32 # define PHP_ICONV_API __attribute__ ((visibility("default")))
33 #else
34 # define PHP_ICONV_API
35 #endif
36 
37 #include "php_version.h"
38 #define PHP_ICONV_VERSION PHP_VERSION
39 
40 #ifdef PHP_ATOM_INC
41 #include "ext/iconv/php_have_iconv.h"
42 #include "ext/iconv/php_have_libiconv.h"
43 #include "ext/iconv/php_iconv_aliased_libiconv.h"
44 #include "ext/iconv/php_have_glibc_iconv.h"
45 #include "ext/iconv/php_have_bsd_iconv.h"
46 #include "ext/iconv/php_have_ibm_iconv.h"
47 #include "ext/iconv/php_iconv_supports_errno.h"
48 #include "ext/iconv/php_php_iconv_impl.h"
49 #include "ext/iconv/php_php_iconv_h_path.h"
50 #endif
51 
52 #ifdef HAVE_ICONV
53 extern zend_module_entry iconv_module_entry;
54 #define iconv_module_ptr &iconv_module_entry
55 
56 PHP_MINIT_FUNCTION(miconv);
57 PHP_MSHUTDOWN_FUNCTION(miconv);
58 PHP_MINFO_FUNCTION(miconv);
59 
60 PHP_NAMED_FUNCTION(php_if_iconv);
61 PHP_FUNCTION(ob_iconv_handler);
62 PHP_FUNCTION(iconv_get_encoding);
63 PHP_FUNCTION(iconv_set_encoding);
64 PHP_FUNCTION(iconv_strlen);
65 PHP_FUNCTION(iconv_substr);
66 PHP_FUNCTION(iconv_strpos);
67 PHP_FUNCTION(iconv_strrpos);
68 PHP_FUNCTION(iconv_mime_encode);
69 PHP_FUNCTION(iconv_mime_decode);
70 PHP_FUNCTION(iconv_mime_decode_headers);
71 
72 ZEND_BEGIN_MODULE_GLOBALS(iconv)
73 	char *input_encoding;
74 	char *internal_encoding;
75 	char *output_encoding;
76 ZEND_END_MODULE_GLOBALS(iconv)
77 
78 #define ICONVG(v) ZEND_MODULE_GLOBALS_ACCESSOR(iconv, v)
79 
80 #if defined(ZTS) && defined(COMPILE_DL_ICONV)
81 ZEND_TSRMLS_CACHE_EXTERN()
82 #endif
83 
84 #ifdef HAVE_IBM_ICONV
85 # define ICONV_ASCII_ENCODING "IBM-850"
86 # define ICONV_UCS4_ENCODING "UCS-4"
87 #else
88 # define ICONV_ASCII_ENCODING "ASCII"
89 # define ICONV_UCS4_ENCODING "UCS-4LE"
90 #endif
91 
92 #ifndef ICONV_CSNMAXLEN
93 #define ICONV_CSNMAXLEN 64
94 #endif
95 
96 /* {{{ typedef enum php_iconv_err_t */
97 typedef enum _php_iconv_err_t {
98 	PHP_ICONV_ERR_SUCCESS           = SUCCESS,
99 	PHP_ICONV_ERR_CONVERTER         = 1,
100 	PHP_ICONV_ERR_WRONG_CHARSET     = 2,
101 	PHP_ICONV_ERR_TOO_BIG           = 3,
102 	PHP_ICONV_ERR_ILLEGAL_SEQ       = 4,
103 	PHP_ICONV_ERR_ILLEGAL_CHAR      = 5,
104 	PHP_ICONV_ERR_UNKNOWN           = 6,
105 	PHP_ICONV_ERR_MALFORMED         = 7,
106 	PHP_ICONV_ERR_ALLOC             = 8
107 } php_iconv_err_t;
108 /* }}} */
109 
110 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);
111 
112 #else
113 
114 #define iconv_module_ptr NULL
115 
116 #endif /* HAVE_ICONV */
117 
118 #define phpext_iconv_ptr iconv_module_ptr
119 
120 #endif	/* PHP_ICONV_H */
121 
122 /*
123  * Local variables:
124  * tab-width: 4
125  * c-basic-offset: 4
126  * End:
127  */
128