1 /*
2  * "streamable kanji code filter and converter"
3  * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
4  *
5  * LICENSE NOTICES
6  *
7  * This file is part of "streamable kanji code filter and converter",
8  * which is distributed under the terms of GNU Lesser General Public
9  * License (version 2) as published by the Free Software Foundation.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with "streamable kanji code filter and converter";
18  * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19  * Suite 330, Boston, MA  02111-1307  USA
20  *
21  * The author of this file:
22  *
23  */
24 /*
25  * The source code included in this files was separated from mbfilter.h
26  * by Moriyoshi Koizumi <moriyoshi@php.net> on 20 Dec 2002. The file
27  * mbfilter.h is included in this package .
28  *
29  */
30 
31 #ifndef MBFL_ENCODING_H
32 #define MBFL_ENCODING_H
33 
34 #include "mbfl_defs.h"
35 
36 enum mbfl_no_encoding {
37 	mbfl_no_encoding_invalid = -1,
38 	mbfl_no_encoding_pass,
39 	mbfl_no_encoding_wchar,
40 	mbfl_no_encoding_byte2be,
41 	mbfl_no_encoding_byte2le,
42 	mbfl_no_encoding_byte4be,
43 	mbfl_no_encoding_byte4le,
44 	mbfl_no_encoding_base64,
45 	mbfl_no_encoding_uuencode,
46 	mbfl_no_encoding_html_ent,
47 	mbfl_no_encoding_qprint,
48 	mbfl_no_encoding_7bit,
49 	mbfl_no_encoding_8bit,
50 	mbfl_no_encoding_charset_min,
51 	mbfl_no_encoding_ucs4,
52 	mbfl_no_encoding_ucs4be,
53 	mbfl_no_encoding_ucs4le,
54 	mbfl_no_encoding_ucs2,
55 	mbfl_no_encoding_ucs2be,
56 	mbfl_no_encoding_ucs2le,
57 	mbfl_no_encoding_utf32,
58 	mbfl_no_encoding_utf32be,
59 	mbfl_no_encoding_utf32le,
60 	mbfl_no_encoding_utf16,
61 	mbfl_no_encoding_utf16be,
62 	mbfl_no_encoding_utf16le,
63 	mbfl_no_encoding_utf8,
64 	mbfl_no_encoding_utf8_docomo,
65 	mbfl_no_encoding_utf8_kddi_a,
66 	mbfl_no_encoding_utf8_kddi_b,
67 	mbfl_no_encoding_utf8_sb,
68 	mbfl_no_encoding_utf7,
69 	mbfl_no_encoding_utf7imap,
70 	mbfl_no_encoding_ascii,
71 	mbfl_no_encoding_euc_jp,
72 	mbfl_no_encoding_eucjp2004,
73 	mbfl_no_encoding_sjis,
74 	mbfl_no_encoding_eucjp_win,
75 	mbfl_no_encoding_sjis_open,
76  	mbfl_no_encoding_sjis_docomo,
77  	mbfl_no_encoding_sjis_kddi,
78  	mbfl_no_encoding_sjis_sb,
79  	mbfl_no_encoding_sjis_mac,
80 	mbfl_no_encoding_sjis2004,
81 	mbfl_no_encoding_cp932,
82 	mbfl_no_encoding_cp51932,
83 	mbfl_no_encoding_jis,
84 	mbfl_no_encoding_2022jp,
85 	mbfl_no_encoding_2022jp_2004,
86 	mbfl_no_encoding_2022jp_kddi,
87 	mbfl_no_encoding_2022jpms,
88 	mbfl_no_encoding_gb18030,
89 	mbfl_no_encoding_cp1252,
90 	mbfl_no_encoding_cp1254,
91 	mbfl_no_encoding_8859_1,
92 	mbfl_no_encoding_8859_2,
93 	mbfl_no_encoding_8859_3,
94 	mbfl_no_encoding_8859_4,
95 	mbfl_no_encoding_8859_5,
96 	mbfl_no_encoding_8859_6,
97 	mbfl_no_encoding_8859_7,
98 	mbfl_no_encoding_8859_8,
99 	mbfl_no_encoding_8859_9,
100 	mbfl_no_encoding_8859_10,
101 	mbfl_no_encoding_8859_13,
102 	mbfl_no_encoding_8859_14,
103 	mbfl_no_encoding_8859_15,
104 	mbfl_no_encoding_euc_cn,
105 	mbfl_no_encoding_cp936,
106 	mbfl_no_encoding_euc_tw,
107 	mbfl_no_encoding_big5,
108 	mbfl_no_encoding_cp950,
109 	mbfl_no_encoding_euc_kr,
110 	mbfl_no_encoding_2022kr,
111 	mbfl_no_encoding_uhc,
112 	mbfl_no_encoding_hz,
113 	mbfl_no_encoding_cp1251,
114 	mbfl_no_encoding_cp866,
115 	mbfl_no_encoding_koi8r,
116 	mbfl_no_encoding_koi8u,
117 	mbfl_no_encoding_8859_16,
118 	mbfl_no_encoding_armscii8,
119 	mbfl_no_encoding_cp850,
120 	mbfl_no_encoding_jis_ms,
121 	mbfl_no_encoding_cp50220,
122 	mbfl_no_encoding_cp50220raw,
123 	mbfl_no_encoding_cp50221,
124 	mbfl_no_encoding_cp50222,
125 	mbfl_no_encoding_charset_max
126 };
127 
128 typedef enum mbfl_no_encoding mbfl_encoding_id;
129 
130 struct _mbfl_convert_filter;
131 struct mbfl_convert_vtbl {
132 	enum mbfl_no_encoding from;
133 	enum mbfl_no_encoding to;
134 	void (*filter_ctor)(struct _mbfl_convert_filter *filter);
135 	void (*filter_dtor)(struct _mbfl_convert_filter *filter);
136 	int (*filter_function)(int c, struct _mbfl_convert_filter *filter);
137 	int (*filter_flush)(struct _mbfl_convert_filter *filter);
138 	void (*filter_copy)(struct _mbfl_convert_filter *src, struct _mbfl_convert_filter *dest);
139 };
140 
141 /*
142  * encoding
143  */
144 typedef struct _mbfl_encoding {
145 	enum mbfl_no_encoding no_encoding;
146 	const char *name;
147 	const char *mime_name;
148 	const char *(*aliases)[];
149 	const unsigned char *mblen_table;
150 	unsigned int flag;
151 	const struct mbfl_convert_vtbl *input_filter;
152 	const struct mbfl_convert_vtbl *output_filter;
153 } mbfl_encoding;
154 
155 MBFLAPI extern const mbfl_encoding * mbfl_name2encoding(const char *name);
156 MBFLAPI extern const mbfl_encoding * mbfl_no2encoding(enum mbfl_no_encoding no_encoding);
157 MBFLAPI extern enum mbfl_no_encoding mbfl_name2no_encoding(const char *name);
158 MBFLAPI extern const mbfl_encoding ** mbfl_get_supported_encodings();
159 MBFLAPI extern const char * mbfl_no_encoding2name(enum mbfl_no_encoding no_encoding);
160 MBFLAPI extern const char * mbfl_no2preferred_mime_name(enum mbfl_no_encoding no_encoding);
161 
162 
163 #endif /* MBFL_ENCODING_H */
164