xref: /PHP-5.4/ext/iconv/php_iconv.h (revision c0d060f5)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2014 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: 26e3f3b2a614c7fef88059b9e69137f694a0de42 $ */
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 #ifdef PHP_ATOM_INC
38 #include "ext/iconv/php_have_iconv.h"
39 #include "ext/iconv/php_have_libiconv.h"
40 #include "ext/iconv/php_iconv_aliased_libiconv.h"
41 #include "ext/iconv/php_have_glibc_iconv.h"
42 #include "ext/iconv/php_have_bsd_iconv.h"
43 #include "ext/iconv/php_have_ibm_iconv.h"
44 #include "ext/iconv/php_iconv_supports_errno.h"
45 #include "ext/iconv/php_php_iconv_impl.h"
46 #include "ext/iconv/php_php_iconv_h_path.h"
47 #endif
48 
49 #ifdef HAVE_ICONV
50 extern zend_module_entry iconv_module_entry;
51 #define iconv_module_ptr &iconv_module_entry
52 
53 PHP_MINIT_FUNCTION(miconv);
54 PHP_MSHUTDOWN_FUNCTION(miconv);
55 PHP_MINFO_FUNCTION(miconv);
56 
57 PHP_NAMED_FUNCTION(php_if_iconv);
58 PHP_FUNCTION(ob_iconv_handler);
59 PHP_FUNCTION(iconv_get_encoding);
60 PHP_FUNCTION(iconv_set_encoding);
61 PHP_FUNCTION(iconv_strlen);
62 PHP_FUNCTION(iconv_substr);
63 PHP_FUNCTION(iconv_strpos);
64 PHP_FUNCTION(iconv_strrpos);
65 PHP_FUNCTION(iconv_mime_encode);
66 PHP_FUNCTION(iconv_mime_decode);
67 PHP_FUNCTION(iconv_mime_decode_headers);
68 
69 ZEND_BEGIN_MODULE_GLOBALS(iconv)
70 	char *input_encoding;
71 	char *internal_encoding;
72 	char *output_encoding;
73 ZEND_END_MODULE_GLOBALS(iconv)
74 
75 #ifdef ZTS
76 # define ICONVG(v) TSRMG(iconv_globals_id, zend_iconv_globals *, v)
77 #else
78 # define ICONVG(v) (iconv_globals.v)
79 #endif
80 
81 #ifdef HAVE_IBM_ICONV
82 # define ICONV_INPUT_ENCODING "ISO8859-1"
83 # define ICONV_OUTPUT_ENCODING "ISO8859-1"
84 # define ICONV_INTERNAL_ENCODING "ISO8859-1"
85 # define ICONV_ASCII_ENCODING "IBM-850"
86 # define ICONV_UCS4_ENCODING "UCS-4"
87 #else
88 # define ICONV_INPUT_ENCODING "ISO-8859-1"
89 # define ICONV_OUTPUT_ENCODING "ISO-8859-1"
90 # define ICONV_INTERNAL_ENCODING "ISO-8859-1"
91 # define ICONV_ASCII_ENCODING "ASCII"
92 # define ICONV_UCS4_ENCODING "UCS-4LE"
93 #endif
94 
95 #ifndef ICONV_CSNMAXLEN
96 #define ICONV_CSNMAXLEN 64
97 #endif
98 
99 /* {{{ typedef enum php_iconv_err_t */
100 typedef enum _php_iconv_err_t {
101 	PHP_ICONV_ERR_SUCCESS           = SUCCESS,
102 	PHP_ICONV_ERR_CONVERTER         = 1,
103 	PHP_ICONV_ERR_WRONG_CHARSET     = 2,
104 	PHP_ICONV_ERR_TOO_BIG           = 3,
105 	PHP_ICONV_ERR_ILLEGAL_SEQ       = 4,
106 	PHP_ICONV_ERR_ILLEGAL_CHAR      = 5,
107 	PHP_ICONV_ERR_UNKNOWN           = 6,
108 	PHP_ICONV_ERR_MALFORMED         = 7,
109 	PHP_ICONV_ERR_ALLOC             = 8
110 } php_iconv_err_t;
111 /* }}} */
112 
113 PHP_ICONV_API php_iconv_err_t php_iconv_string(const char * in_p, size_t in_len, char **out, size_t *out_len, const char *out_charset, const char *in_charset);
114 
115 #else
116 
117 #define iconv_module_ptr NULL
118 
119 #endif /* HAVE_ICONV */
120 
121 #define phpext_iconv_ptr iconv_module_ptr
122 
123 #endif	/* PHP_ICONV_H */
124 
125 /*
126  * Local variables:
127  * tab-width: 4
128  * c-basic-offset: 4
129  * End:
130  */
131