xref: /php-src/ext/iconv/php_iconv.h (revision a1a8e903)
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 ZEND_BEGIN_MODULE_GLOBALS(iconv)
45 	char *input_encoding;
46 	char *internal_encoding;
47 	char *output_encoding;
48 ZEND_END_MODULE_GLOBALS(iconv)
49 
50 #define ICONVG(v) ZEND_MODULE_GLOBALS_ACCESSOR(iconv, v)
51 
52 #if defined(ZTS) && defined(COMPILE_DL_ICONV)
53 ZEND_TSRMLS_CACHE_EXTERN()
54 #endif
55 
56 #ifdef HAVE_IBM_ICONV
57 # define ICONV_ASCII_ENCODING "IBM-850"
58 # define ICONV_UCS4_ENCODING "UCS-4"
59 #else
60 # define ICONV_ASCII_ENCODING "ASCII"
61 # define ICONV_UCS4_ENCODING "UCS-4LE"
62 #endif
63 
64 #ifndef ICONV_CSNMAXLEN
65 #define ICONV_CSNMAXLEN 64
66 #endif
67 
68 /* {{{ typedef enum php_iconv_err_t */
69 typedef enum _php_iconv_err_t {
70 	PHP_ICONV_ERR_SUCCESS           = SUCCESS,
71 	PHP_ICONV_ERR_CONVERTER         = 1,
72 	PHP_ICONV_ERR_WRONG_CHARSET     = 2,
73 	PHP_ICONV_ERR_TOO_BIG           = 3,
74 	PHP_ICONV_ERR_ILLEGAL_SEQ       = 4,
75 	PHP_ICONV_ERR_ILLEGAL_CHAR      = 5,
76 	PHP_ICONV_ERR_UNKNOWN           = 6,
77 	PHP_ICONV_ERR_MALFORMED         = 7,
78 	PHP_ICONV_ERR_ALLOC             = 8,
79 	PHP_ICONV_ERR_OUT_BY_BOUNDS     = 9
80 } php_iconv_err_t;
81 /* }}} */
82 
83 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);
84 
85 #else
86 
87 #define iconv_module_ptr NULL
88 
89 #endif /* HAVE_ICONV */
90 
91 #define phpext_iconv_ptr iconv_module_ptr
92 
93 #endif	/* PHP_ICONV_H */
94