citrus_mskanji.c revision 1.11 1 1.11 tshiozak /* $NetBSD: citrus_mskanji.c,v 1.11 2005/12/07 06:20:20 tshiozak Exp $ */
2 1.1 tshiozak
3 1.1 tshiozak /*-
4 1.1 tshiozak * Copyright (c)2002 Citrus Project,
5 1.1 tshiozak * All rights reserved.
6 1.1 tshiozak *
7 1.1 tshiozak * Redistribution and use in source and binary forms, with or without
8 1.1 tshiozak * modification, are permitted provided that the following conditions
9 1.1 tshiozak * are met:
10 1.1 tshiozak * 1. Redistributions of source code must retain the above copyright
11 1.1 tshiozak * notice, this list of conditions and the following disclaimer.
12 1.1 tshiozak * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 tshiozak * notice, this list of conditions and the following disclaimer in the
14 1.1 tshiozak * documentation and/or other materials provided with the distribution.
15 1.1 tshiozak *
16 1.1 tshiozak * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.1 tshiozak * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.1 tshiozak * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.1 tshiozak * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.1 tshiozak * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1 tshiozak * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.1 tshiozak * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1 tshiozak * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.1 tshiozak * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 tshiozak * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 tshiozak * SUCH DAMAGE.
27 1.1 tshiozak */
28 1.1 tshiozak
29 1.1 tshiozak /*
30 1.1 tshiozak * ja_JP.SJIS locale table for BSD4.4/rune
31 1.1 tshiozak * version 1.0
32 1.1 tshiozak * (C) Sin'ichiro MIYATANI / Phase One, Inc
33 1.1 tshiozak * May 12, 1995
34 1.1 tshiozak *
35 1.1 tshiozak * Redistribution and use in source and binary forms, with or without
36 1.1 tshiozak * modification, are permitted provided that the following conditions
37 1.1 tshiozak * are met:
38 1.1 tshiozak * 1. Redistributions of source code must retain the above copyright
39 1.1 tshiozak * notice, this list of conditions and the following disclaimer.
40 1.1 tshiozak * 2. Redistributions in binary form must reproduce the above copyright
41 1.1 tshiozak * notice, this list of conditions and the following disclaimer in the
42 1.1 tshiozak * documentation and/or other materials provided with the distribution.
43 1.1 tshiozak * 3. All advertising materials mentioning features or use of this software
44 1.1 tshiozak * must display the following acknowledgement:
45 1.1 tshiozak * This product includes software developed by Phase One, Inc.
46 1.1 tshiozak * 4. The name of Phase One, Inc. may be used to endorse or promote products
47 1.1 tshiozak * derived from this software without specific prior written permission.
48 1.1 tshiozak *
49 1.1 tshiozak * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
50 1.1 tshiozak * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51 1.1 tshiozak * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52 1.1 tshiozak * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 1.1 tshiozak * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 1.1 tshiozak * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 1.1 tshiozak * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 1.1 tshiozak * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 1.1 tshiozak * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 1.1 tshiozak * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 1.1 tshiozak * SUCH DAMAGE.
60 1.1 tshiozak */
61 1.1 tshiozak
62 1.1 tshiozak
63 1.1 tshiozak #include <sys/cdefs.h>
64 1.1 tshiozak #if defined(LIBC_SCCS) && !defined(lint)
65 1.11 tshiozak __RCSID("$NetBSD: citrus_mskanji.c,v 1.11 2005/12/07 06:20:20 tshiozak Exp $");
66 1.1 tshiozak #endif /* LIBC_SCCS and not lint */
67 1.1 tshiozak
68 1.1 tshiozak #include <assert.h>
69 1.1 tshiozak #include <errno.h>
70 1.1 tshiozak #include <string.h>
71 1.1 tshiozak #include <stdio.h>
72 1.1 tshiozak #include <stdlib.h>
73 1.1 tshiozak #include <stddef.h>
74 1.1 tshiozak #include <locale.h>
75 1.1 tshiozak #include <wchar.h>
76 1.1 tshiozak #include <sys/types.h>
77 1.1 tshiozak #include <limits.h>
78 1.6 tshiozak
79 1.6 tshiozak #include "citrus_namespace.h"
80 1.6 tshiozak #include "citrus_types.h"
81 1.1 tshiozak #include "citrus_module.h"
82 1.1 tshiozak #include "citrus_ctype.h"
83 1.6 tshiozak #include "citrus_stdenc.h"
84 1.1 tshiozak #include "citrus_mskanji.h"
85 1.1 tshiozak
86 1.1 tshiozak
87 1.1 tshiozak /* ----------------------------------------------------------------------
88 1.1 tshiozak * private stuffs used by templates
89 1.1 tshiozak */
90 1.1 tshiozak
91 1.1 tshiozak typedef struct _MSKanjiState {
92 1.1 tshiozak char ch[2];
93 1.1 tshiozak int chlen;
94 1.1 tshiozak } _MSKanjiState;
95 1.1 tshiozak
96 1.1 tshiozak typedef struct {
97 1.1 tshiozak int dummy;
98 1.1 tshiozak } _MSKanjiEncodingInfo;
99 1.1 tshiozak
100 1.1 tshiozak typedef struct {
101 1.1 tshiozak _MSKanjiEncodingInfo ei;
102 1.1 tshiozak struct {
103 1.1 tshiozak /* for future multi-locale facility */
104 1.1 tshiozak _MSKanjiState s_mblen;
105 1.1 tshiozak _MSKanjiState s_mbrlen;
106 1.1 tshiozak _MSKanjiState s_mbrtowc;
107 1.1 tshiozak _MSKanjiState s_mbtowc;
108 1.1 tshiozak _MSKanjiState s_mbsrtowcs;
109 1.1 tshiozak _MSKanjiState s_wcrtomb;
110 1.1 tshiozak _MSKanjiState s_wcsrtombs;
111 1.1 tshiozak _MSKanjiState s_wctomb;
112 1.1 tshiozak } states;
113 1.1 tshiozak } _MSKanjiCTypeInfo;
114 1.1 tshiozak
115 1.1 tshiozak #define _CEI_TO_EI(_cei_) (&(_cei_)->ei)
116 1.1 tshiozak #define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_
117 1.1 tshiozak
118 1.1 tshiozak #define _FUNCNAME(m) _citrus_MSKanji_##m
119 1.1 tshiozak #define _ENCODING_INFO _MSKanjiEncodingInfo
120 1.1 tshiozak #define _CTYPE_INFO _MSKanjiCTypeInfo
121 1.1 tshiozak #define _ENCODING_STATE _MSKanjiState
122 1.2 yamt #define _ENCODING_MB_CUR_MAX(_ei_) 2
123 1.1 tshiozak #define _ENCODING_IS_STATE_DEPENDENT 0
124 1.4 yamt #define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0
125 1.1 tshiozak
126 1.1 tshiozak
127 1.1 tshiozak static int
128 1.1 tshiozak _mskanji1(int c)
129 1.1 tshiozak {
130 1.1 tshiozak
131 1.10 tshiozak if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc))
132 1.1 tshiozak return 1;
133 1.1 tshiozak else
134 1.1 tshiozak return 0;
135 1.1 tshiozak }
136 1.1 tshiozak
137 1.1 tshiozak static int
138 1.1 tshiozak _mskanji2(int c)
139 1.1 tshiozak {
140 1.1 tshiozak
141 1.1 tshiozak if ((c >= 0x40 && c <= 0x7e) || (c >= 0x80 && c <= 0xfc))
142 1.1 tshiozak return 1;
143 1.1 tshiozak else
144 1.1 tshiozak return 0;
145 1.1 tshiozak }
146 1.1 tshiozak
147 1.1 tshiozak static __inline void
148 1.1 tshiozak /*ARGSUSED*/
149 1.1 tshiozak _citrus_MSKanji_init_state(_MSKanjiEncodingInfo * __restrict ei,
150 1.1 tshiozak _MSKanjiState * __restrict s)
151 1.1 tshiozak {
152 1.1 tshiozak memset(s, 0, sizeof(*s));
153 1.1 tshiozak }
154 1.1 tshiozak
155 1.1 tshiozak static __inline void
156 1.1 tshiozak /*ARGSUSED*/
157 1.1 tshiozak _citrus_MSKanji_pack_state(_MSKanjiEncodingInfo * __restrict ei,
158 1.1 tshiozak void * __restrict pspriv,
159 1.1 tshiozak const _MSKanjiState * __restrict s)
160 1.1 tshiozak {
161 1.1 tshiozak memcpy(pspriv, (const void *)s, sizeof(*s));
162 1.1 tshiozak }
163 1.1 tshiozak
164 1.1 tshiozak static __inline void
165 1.1 tshiozak /*ARGSUSED*/
166 1.1 tshiozak _citrus_MSKanji_unpack_state(_MSKanjiEncodingInfo * __restrict ei,
167 1.1 tshiozak _MSKanjiState * __restrict s,
168 1.1 tshiozak const void * __restrict pspriv)
169 1.1 tshiozak {
170 1.1 tshiozak memcpy((void *)s, pspriv, sizeof(*s));
171 1.1 tshiozak }
172 1.1 tshiozak
173 1.1 tshiozak static int
174 1.1 tshiozak /*ARGSUSED*/
175 1.1 tshiozak _citrus_MSKanji_mbrtowc_priv(_MSKanjiEncodingInfo * __restrict ei,
176 1.1 tshiozak wchar_t * __restrict pwc,
177 1.1 tshiozak const char ** __restrict s, size_t n,
178 1.1 tshiozak _MSKanjiState * __restrict psenc,
179 1.1 tshiozak size_t * __restrict nresult)
180 1.1 tshiozak {
181 1.1 tshiozak wchar_t wchar;
182 1.1 tshiozak int len;
183 1.1 tshiozak int chlenbak;
184 1.1 tshiozak const char *s0;
185 1.1 tshiozak
186 1.1 tshiozak _DIAGASSERT(nresult != 0);
187 1.1 tshiozak _DIAGASSERT(ei != NULL);
188 1.1 tshiozak _DIAGASSERT(s != NULL);
189 1.1 tshiozak _DIAGASSERT(psenc != NULL);
190 1.1 tshiozak
191 1.1 tshiozak s0 = *s;
192 1.1 tshiozak
193 1.1 tshiozak if (s0 == NULL) {
194 1.1 tshiozak _citrus_MSKanji_init_state(ei, psenc);
195 1.1 tshiozak *nresult = 0; /* state independent */
196 1.1 tshiozak return (0);
197 1.1 tshiozak }
198 1.1 tshiozak
199 1.1 tshiozak chlenbak = psenc->chlen;
200 1.1 tshiozak
201 1.1 tshiozak /* make sure we have the first byte in the buffer */
202 1.1 tshiozak switch (psenc->chlen) {
203 1.1 tshiozak case 0:
204 1.1 tshiozak if (n < 1)
205 1.1 tshiozak goto restart;
206 1.1 tshiozak psenc->ch[0] = *s0++;
207 1.1 tshiozak psenc->chlen = 1;
208 1.1 tshiozak n--;
209 1.1 tshiozak break;
210 1.1 tshiozak case 1:
211 1.1 tshiozak break;
212 1.1 tshiozak default:
213 1.1 tshiozak /* illegal state */
214 1.1 tshiozak goto encoding_error;
215 1.1 tshiozak }
216 1.1 tshiozak
217 1.1 tshiozak len = _mskanji1(psenc->ch[0] & 0xff) ? 2 : 1;
218 1.1 tshiozak while (psenc->chlen < len) {
219 1.1 tshiozak if (n < 1)
220 1.1 tshiozak goto restart;
221 1.1 tshiozak psenc->ch[psenc->chlen] = *s0++;
222 1.1 tshiozak psenc->chlen++;
223 1.1 tshiozak n--;
224 1.1 tshiozak }
225 1.1 tshiozak
226 1.1 tshiozak *s = s0;
227 1.1 tshiozak
228 1.1 tshiozak switch (len) {
229 1.1 tshiozak case 1:
230 1.1 tshiozak wchar = psenc->ch[0] & 0xff;
231 1.1 tshiozak break;
232 1.1 tshiozak case 2:
233 1.1 tshiozak if (!_mskanji2(psenc->ch[1] & 0xff))
234 1.1 tshiozak goto encoding_error;
235 1.1 tshiozak wchar = ((psenc->ch[0] & 0xff) << 8) | (psenc->ch[1] & 0xff);
236 1.1 tshiozak break;
237 1.1 tshiozak default:
238 1.1 tshiozak /* illegal state */
239 1.1 tshiozak goto encoding_error;
240 1.1 tshiozak }
241 1.1 tshiozak
242 1.1 tshiozak psenc->chlen = 0;
243 1.1 tshiozak
244 1.1 tshiozak if (pwc)
245 1.1 tshiozak *pwc = wchar;
246 1.1 tshiozak
247 1.1 tshiozak if (!wchar)
248 1.1 tshiozak *nresult = 0;
249 1.1 tshiozak else
250 1.1 tshiozak *nresult = len - chlenbak;
251 1.1 tshiozak
252 1.1 tshiozak return (0);
253 1.1 tshiozak
254 1.1 tshiozak encoding_error:
255 1.1 tshiozak psenc->chlen = 0;
256 1.1 tshiozak *nresult = (size_t)-1;
257 1.1 tshiozak return (EILSEQ);
258 1.1 tshiozak
259 1.1 tshiozak restart:
260 1.1 tshiozak *nresult = (size_t)-2;
261 1.1 tshiozak *s = s0;
262 1.1 tshiozak return (0);
263 1.1 tshiozak }
264 1.1 tshiozak
265 1.1 tshiozak
266 1.1 tshiozak static int
267 1.1 tshiozak _citrus_MSKanji_wcrtomb_priv(_MSKanjiEncodingInfo * __restrict ei,
268 1.1 tshiozak char * __restrict s, size_t n, wchar_t wc,
269 1.1 tshiozak _MSKanjiState * __restrict psenc,
270 1.1 tshiozak size_t * __restrict nresult)
271 1.1 tshiozak {
272 1.6 tshiozak int ret;
273 1.1 tshiozak
274 1.1 tshiozak _DIAGASSERT(ei != NULL);
275 1.1 tshiozak _DIAGASSERT(psenc != NULL);
276 1.1 tshiozak _DIAGASSERT(s != NULL);
277 1.6 tshiozak
278 1.1 tshiozak /* check invalid sequence */
279 1.6 tshiozak if (wc & ~0xffff) {
280 1.6 tshiozak ret = EILSEQ;
281 1.6 tshiozak goto err;
282 1.6 tshiozak }
283 1.1 tshiozak
284 1.1 tshiozak if (wc & 0xff00) {
285 1.6 tshiozak if (n < 2) {
286 1.6 tshiozak ret = E2BIG;
287 1.6 tshiozak goto err;
288 1.6 tshiozak }
289 1.1 tshiozak
290 1.1 tshiozak s[0] = (wc >> 8) & 0xff;
291 1.1 tshiozak s[1] = wc & 0xff;
292 1.6 tshiozak if (!_mskanji1(s[0] & 0xff) || !_mskanji2(s[1] & 0xff)) {
293 1.6 tshiozak ret = EILSEQ;
294 1.6 tshiozak goto err;
295 1.6 tshiozak }
296 1.1 tshiozak
297 1.1 tshiozak *nresult = 2;
298 1.6 tshiozak return 0;
299 1.1 tshiozak } else {
300 1.8 yamt if (n < 1) {
301 1.8 yamt ret = E2BIG;
302 1.8 yamt goto err;
303 1.8 yamt }
304 1.8 yamt
305 1.1 tshiozak s[0] = wc & 0xff;
306 1.6 tshiozak if (_mskanji1(s[0] & 0xff)) {
307 1.6 tshiozak ret = EILSEQ;
308 1.6 tshiozak goto err;
309 1.6 tshiozak }
310 1.1 tshiozak
311 1.1 tshiozak *nresult = 1;
312 1.6 tshiozak return 0;
313 1.1 tshiozak }
314 1.1 tshiozak
315 1.6 tshiozak err:
316 1.1 tshiozak *nresult = (size_t)-1;
317 1.6 tshiozak return ret;
318 1.1 tshiozak }
319 1.1 tshiozak
320 1.1 tshiozak
321 1.6 tshiozak static __inline int
322 1.6 tshiozak /*ARGSUSED*/
323 1.6 tshiozak _citrus_MSKanji_stdenc_wctocs(_MSKanjiEncodingInfo * __restrict ei,
324 1.6 tshiozak _csid_t * __restrict csid,
325 1.6 tshiozak _index_t * __restrict idx, wchar_t wc)
326 1.6 tshiozak {
327 1.6 tshiozak _index_t row, col;
328 1.6 tshiozak
329 1.6 tshiozak _DIAGASSERT(csid != NULL && idx != NULL);
330 1.6 tshiozak
331 1.6 tshiozak if ((_wc_t)wc < 0x80) {
332 1.6 tshiozak /* ISO-646 */
333 1.6 tshiozak *csid = 0;
334 1.6 tshiozak *idx = (_index_t)wc;
335 1.6 tshiozak } else if ((_wc_t)wc < 0x100) {
336 1.6 tshiozak /* KANA */
337 1.6 tshiozak *csid = 1;
338 1.6 tshiozak *idx = (_index_t)wc & 0x7F;
339 1.6 tshiozak } else if ((0x8140 <= (_wc_t)wc && (_wc_t)wc <= 0x9FFC) ||
340 1.6 tshiozak (0xE040 <= (_wc_t)wc && (_wc_t)wc <= 0xFCFC)) {
341 1.6 tshiozak /* Kanji (containing Gaiji zone) */
342 1.6 tshiozak /*
343 1.6 tshiozak * 94^2 zone (contains a part of Gaiji (0xED40 - 0xEEFC)):
344 1.6 tshiozak * 0x8140 - 0x817E -> 0x2121 - 0x215F
345 1.6 tshiozak * 0x8180 - 0x819E -> 0x2160 - 0x217E
346 1.6 tshiozak * 0x819F - 0x81FC -> 0x2221 - 0x227E
347 1.6 tshiozak *
348 1.6 tshiozak * 0x8240 - 0x827E -> 0x2321 - 0x235F
349 1.6 tshiozak * ...
350 1.6 tshiozak * 0x9F9F - 0x9FFc -> 0x5E21 - 0x5E7E
351 1.6 tshiozak *
352 1.6 tshiozak * 0xE040 - 0xE07E -> 0x5F21 - 0x5F5F
353 1.6 tshiozak * ...
354 1.6 tshiozak * 0xEF9F - 0xEFFC -> 0x7E21 - 0x7E7E
355 1.6 tshiozak *
356 1.6 tshiozak * extended Gaiji zone:
357 1.6 tshiozak * 0xF040 - 0xFCFC
358 1.6 tshiozak */
359 1.6 tshiozak *csid = 2;
360 1.6 tshiozak row = ((_wc_t)wc >> 8) - 0x81;
361 1.6 tshiozak if (row >= 0x5F)
362 1.6 tshiozak row -= 0x40;
363 1.6 tshiozak row = row * 2 + 0x21;
364 1.6 tshiozak col = (wc & 0xFF) - 0x1F;
365 1.6 tshiozak if (col >= 0x61)
366 1.6 tshiozak col -= 1;
367 1.6 tshiozak if (col > 0x7E) {
368 1.6 tshiozak row += 1;
369 1.6 tshiozak col -= 0x5E;
370 1.6 tshiozak }
371 1.6 tshiozak *idx = ((_index_t)row << 8) | col;
372 1.6 tshiozak } else
373 1.6 tshiozak return EILSEQ;
374 1.6 tshiozak
375 1.6 tshiozak return 0;
376 1.6 tshiozak }
377 1.6 tshiozak
378 1.6 tshiozak static __inline int
379 1.6 tshiozak /*ARGSUSED*/
380 1.6 tshiozak _citrus_MSKanji_stdenc_cstowc(_MSKanjiEncodingInfo * __restrict ei,
381 1.6 tshiozak wchar_t * __restrict wc,
382 1.6 tshiozak _csid_t csid, _index_t idx)
383 1.6 tshiozak {
384 1.6 tshiozak u_int32_t row, col;
385 1.6 tshiozak
386 1.6 tshiozak _DIAGASSERT(wc != NULL);
387 1.6 tshiozak
388 1.6 tshiozak switch (csid) {
389 1.6 tshiozak case 0:
390 1.6 tshiozak /* ISO-646 */
391 1.6 tshiozak if (idx >= 0x80)
392 1.6 tshiozak return EILSEQ;
393 1.6 tshiozak *wc = (wchar_t)idx;
394 1.6 tshiozak break;
395 1.6 tshiozak case 1:
396 1.6 tshiozak /* kana */
397 1.6 tshiozak if (idx >= 0x80)
398 1.6 tshiozak return EILSEQ;
399 1.6 tshiozak *wc = (wchar_t)idx + 0x80;
400 1.6 tshiozak break;
401 1.6 tshiozak case 2:
402 1.6 tshiozak /* kanji */
403 1.6 tshiozak row = (idx >> 8);
404 1.6 tshiozak col = idx & 0x7F;
405 1.6 tshiozak if (row<0x21 || row>0x97 || col<0x21 || col>0x7E)
406 1.6 tshiozak return EILSEQ;
407 1.6 tshiozak row -= 0x21; col -= 0x21;
408 1.6 tshiozak if ((row & 1)==0) {
409 1.6 tshiozak col += 0x40;
410 1.6 tshiozak if (col>=0x7F)
411 1.6 tshiozak col += 1;
412 1.6 tshiozak } else
413 1.6 tshiozak col += 0x9F;
414 1.6 tshiozak if (row<0x3E)
415 1.6 tshiozak row = row/2 + 0x81;
416 1.6 tshiozak else
417 1.6 tshiozak row = row/2 + 0xc1;
418 1.6 tshiozak *wc = ((wchar_t)row << 8) | col;
419 1.6 tshiozak break;
420 1.6 tshiozak default:
421 1.6 tshiozak return EILSEQ;
422 1.6 tshiozak }
423 1.6 tshiozak
424 1.6 tshiozak return 0;
425 1.6 tshiozak }
426 1.6 tshiozak
427 1.11 tshiozak static __inline int
428 1.11 tshiozak /*ARGSUSED*/
429 1.11 tshiozak _citrus_MSKanji_stdenc_get_state_desc_generic(_MSKanjiEncodingInfo * __restrict ei,
430 1.11 tshiozak _MSKanjiState * __restrict psenc,
431 1.11 tshiozak int * __restrict rstate)
432 1.11 tshiozak {
433 1.11 tshiozak
434 1.11 tshiozak if (psenc->chlen == 0)
435 1.11 tshiozak *rstate = _STDENC_SDGEN_INITIAL;
436 1.11 tshiozak else
437 1.11 tshiozak *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR;
438 1.11 tshiozak
439 1.11 tshiozak return 0;
440 1.11 tshiozak }
441 1.11 tshiozak
442 1.1 tshiozak static int
443 1.1 tshiozak /*ARGSUSED*/
444 1.6 tshiozak _citrus_MSKanji_encoding_module_init(_MSKanjiEncodingInfo * __restrict ei,
445 1.6 tshiozak const void * __restrict var,
446 1.6 tshiozak size_t lenvar)
447 1.1 tshiozak {
448 1.1 tshiozak
449 1.9 tnozaki _DIAGASSERT(ei != NULL);
450 1.1 tshiozak
451 1.1 tshiozak return (0);
452 1.1 tshiozak }
453 1.1 tshiozak
454 1.1 tshiozak static void
455 1.6 tshiozak _citrus_MSKanji_encoding_module_uninit(_MSKanjiEncodingInfo *ei)
456 1.1 tshiozak {
457 1.1 tshiozak }
458 1.1 tshiozak
459 1.1 tshiozak /* ----------------------------------------------------------------------
460 1.1 tshiozak * public interface for ctype
461 1.1 tshiozak */
462 1.1 tshiozak
463 1.1 tshiozak _CITRUS_CTYPE_DECLS(MSKanji);
464 1.1 tshiozak _CITRUS_CTYPE_DEF_OPS(MSKanji);
465 1.1 tshiozak
466 1.1 tshiozak #include "citrus_ctype_template.h"
467 1.6 tshiozak
468 1.6 tshiozak /* ----------------------------------------------------------------------
469 1.6 tshiozak * public interface for stdenc
470 1.6 tshiozak */
471 1.6 tshiozak
472 1.6 tshiozak _CITRUS_STDENC_DECLS(MSKanji);
473 1.6 tshiozak _CITRUS_STDENC_DEF_OPS(MSKanji);
474 1.6 tshiozak
475 1.6 tshiozak #include "citrus_stdenc_template.h"
476