1ad30f8e7SGabor Kovesdan /* $NetBSD: citrus_johab.c,v 1.4 2008/06/14 16:01:07 tnozaki Exp $ */
2ad30f8e7SGabor Kovesdan
3ad30f8e7SGabor Kovesdan /*-
45e53a4f9SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause
55e53a4f9SPedro F. Giffuni *
6ad30f8e7SGabor Kovesdan * Copyright (c)2006 Citrus Project,
7ad30f8e7SGabor Kovesdan * All rights reserved.
8ad30f8e7SGabor Kovesdan *
9ad30f8e7SGabor Kovesdan * Redistribution and use in source and binary forms, with or without
10ad30f8e7SGabor Kovesdan * modification, are permitted provided that the following conditions
11ad30f8e7SGabor Kovesdan * are met:
12ad30f8e7SGabor Kovesdan * 1. Redistributions of source code must retain the above copyright
13ad30f8e7SGabor Kovesdan * notice, this list of conditions and the following disclaimer.
14ad30f8e7SGabor Kovesdan * 2. Redistributions in binary form must reproduce the above copyright
15ad30f8e7SGabor Kovesdan * notice, this list of conditions and the following disclaimer in the
16ad30f8e7SGabor Kovesdan * documentation and/or other materials provided with the distribution.
17ad30f8e7SGabor Kovesdan *
18ad30f8e7SGabor Kovesdan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19ad30f8e7SGabor Kovesdan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20ad30f8e7SGabor Kovesdan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ad30f8e7SGabor Kovesdan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22ad30f8e7SGabor Kovesdan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23ad30f8e7SGabor Kovesdan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24ad30f8e7SGabor Kovesdan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25ad30f8e7SGabor Kovesdan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26ad30f8e7SGabor Kovesdan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27ad30f8e7SGabor Kovesdan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28ad30f8e7SGabor Kovesdan * SUCH DAMAGE.
29ad30f8e7SGabor Kovesdan */
30*a2f733abSWarner Losh
31ad30f8e7SGabor Kovesdan #include <sys/types.h>
32ad30f8e7SGabor Kovesdan
33ad30f8e7SGabor Kovesdan #include <assert.h>
34ad30f8e7SGabor Kovesdan #include <errno.h>
35ad30f8e7SGabor Kovesdan #include <limits.h>
36ad30f8e7SGabor Kovesdan #include <stdbool.h>
37ad30f8e7SGabor Kovesdan #include <stddef.h>
38ad30f8e7SGabor Kovesdan #include <stdint.h>
39ad30f8e7SGabor Kovesdan #include <stdio.h>
40ad30f8e7SGabor Kovesdan #include <stdlib.h>
41ad30f8e7SGabor Kovesdan #include <string.h>
42ad30f8e7SGabor Kovesdan #include <wchar.h>
43ad30f8e7SGabor Kovesdan
44ad30f8e7SGabor Kovesdan #include "citrus_namespace.h"
45ad30f8e7SGabor Kovesdan #include "citrus_types.h"
46ad30f8e7SGabor Kovesdan #include "citrus_bcs.h"
47ad30f8e7SGabor Kovesdan #include "citrus_module.h"
48ad30f8e7SGabor Kovesdan #include "citrus_stdenc.h"
49ad30f8e7SGabor Kovesdan #include "citrus_johab.h"
50ad30f8e7SGabor Kovesdan
51ad30f8e7SGabor Kovesdan /* ----------------------------------------------------------------------
52ad30f8e7SGabor Kovesdan * private stuffs used by templates
53ad30f8e7SGabor Kovesdan */
54ad30f8e7SGabor Kovesdan
55ad30f8e7SGabor Kovesdan typedef struct {
56ad30f8e7SGabor Kovesdan int chlen;
57ad30f8e7SGabor Kovesdan char ch[2];
58ad30f8e7SGabor Kovesdan } _JOHABState;
59ad30f8e7SGabor Kovesdan
60ad30f8e7SGabor Kovesdan typedef struct {
61ad30f8e7SGabor Kovesdan int dummy;
62ad30f8e7SGabor Kovesdan } _JOHABEncodingInfo;
63ad30f8e7SGabor Kovesdan
64ad30f8e7SGabor Kovesdan #define _CEI_TO_EI(_cei_) (&(_cei_)->ei)
65ad30f8e7SGabor Kovesdan #define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_
66ad30f8e7SGabor Kovesdan
67ad30f8e7SGabor Kovesdan #define _FUNCNAME(m) _citrus_JOHAB_##m
68ad30f8e7SGabor Kovesdan #define _ENCODING_INFO _JOHABEncodingInfo
69ad30f8e7SGabor Kovesdan #define _ENCODING_STATE _JOHABState
70ad30f8e7SGabor Kovesdan #define _ENCODING_MB_CUR_MAX(_ei_) 2
71ad30f8e7SGabor Kovesdan #define _ENCODING_IS_STATE_DEPENDENT 0
72ad30f8e7SGabor Kovesdan #define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0
73ad30f8e7SGabor Kovesdan
74ad30f8e7SGabor Kovesdan
75ad30f8e7SGabor Kovesdan static __inline void
76ad30f8e7SGabor Kovesdan /*ARGSUSED*/
_citrus_JOHAB_init_state(_JOHABEncodingInfo * __restrict ei __unused,_JOHABState * __restrict psenc)77ad30f8e7SGabor Kovesdan _citrus_JOHAB_init_state(_JOHABEncodingInfo * __restrict ei __unused,
78ad30f8e7SGabor Kovesdan _JOHABState * __restrict psenc)
79ad30f8e7SGabor Kovesdan {
80ad30f8e7SGabor Kovesdan
81ad30f8e7SGabor Kovesdan psenc->chlen = 0;
82ad30f8e7SGabor Kovesdan }
83ad30f8e7SGabor Kovesdan
84b61949ddSDimitry Andric #if 0
85ad30f8e7SGabor Kovesdan static __inline void
86ad30f8e7SGabor Kovesdan /*ARGSUSED*/
87ad30f8e7SGabor Kovesdan _citrus_JOHAB_pack_state(_JOHABEncodingInfo * __restrict ei __unused,
88ad30f8e7SGabor Kovesdan void * __restrict pspriv, const _JOHABState * __restrict psenc)
89ad30f8e7SGabor Kovesdan {
90ad30f8e7SGabor Kovesdan
91ad30f8e7SGabor Kovesdan memcpy(pspriv, (const void *)psenc, sizeof(*psenc));
92ad30f8e7SGabor Kovesdan }
93ad30f8e7SGabor Kovesdan
94ad30f8e7SGabor Kovesdan static __inline void
95ad30f8e7SGabor Kovesdan /*ARGSUSED*/
96ad30f8e7SGabor Kovesdan _citrus_JOHAB_unpack_state(_JOHABEncodingInfo * __restrict ei __unused,
97ad30f8e7SGabor Kovesdan _JOHABState * __restrict psenc, const void * __restrict pspriv)
98ad30f8e7SGabor Kovesdan {
99ad30f8e7SGabor Kovesdan
100ad30f8e7SGabor Kovesdan memcpy((void *)psenc, pspriv, sizeof(*psenc));
101ad30f8e7SGabor Kovesdan }
102b61949ddSDimitry Andric #endif
103ad30f8e7SGabor Kovesdan
104ad30f8e7SGabor Kovesdan static void
105ad30f8e7SGabor Kovesdan /*ARGSUSED*/
_citrus_JOHAB_encoding_module_uninit(_JOHABEncodingInfo * ei __unused)106ad30f8e7SGabor Kovesdan _citrus_JOHAB_encoding_module_uninit(_JOHABEncodingInfo *ei __unused)
107ad30f8e7SGabor Kovesdan {
108ad30f8e7SGabor Kovesdan
109ad30f8e7SGabor Kovesdan /* ei may be null */
110ad30f8e7SGabor Kovesdan }
111ad30f8e7SGabor Kovesdan
112ad30f8e7SGabor Kovesdan static int
113ad30f8e7SGabor Kovesdan /*ARGSUSED*/
_citrus_JOHAB_encoding_module_init(_JOHABEncodingInfo * __restrict ei __unused,const void * __restrict var __unused,size_t lenvar __unused)114ad30f8e7SGabor Kovesdan _citrus_JOHAB_encoding_module_init(_JOHABEncodingInfo * __restrict ei __unused,
115ad30f8e7SGabor Kovesdan const void * __restrict var __unused, size_t lenvar __unused)
116ad30f8e7SGabor Kovesdan {
117ad30f8e7SGabor Kovesdan
118ad30f8e7SGabor Kovesdan /* ei may be null */
119ad30f8e7SGabor Kovesdan return (0);
120ad30f8e7SGabor Kovesdan }
121ad30f8e7SGabor Kovesdan
122ad30f8e7SGabor Kovesdan static __inline bool
ishangul(int l,int t)123ad30f8e7SGabor Kovesdan ishangul(int l, int t)
124ad30f8e7SGabor Kovesdan {
125ad30f8e7SGabor Kovesdan
126ad30f8e7SGabor Kovesdan return ((l >= 0x84 && l <= 0xD3) &&
127ad30f8e7SGabor Kovesdan ((t >= 0x41 && t <= 0x7E) || (t >= 0x81 && t <= 0xFE)));
128ad30f8e7SGabor Kovesdan }
129ad30f8e7SGabor Kovesdan
130ad30f8e7SGabor Kovesdan static __inline bool
isuda(int l,int t)131ad30f8e7SGabor Kovesdan isuda(int l, int t)
132ad30f8e7SGabor Kovesdan {
133ad30f8e7SGabor Kovesdan
134ad30f8e7SGabor Kovesdan return ((l == 0xD8) &&
135ad30f8e7SGabor Kovesdan ((t >= 0x31 && t <= 0x7E) || (t >= 0x91 && t <= 0xFE)));
136ad30f8e7SGabor Kovesdan }
137ad30f8e7SGabor Kovesdan
138ad30f8e7SGabor Kovesdan static __inline bool
ishanja(int l,int t)139ad30f8e7SGabor Kovesdan ishanja(int l, int t)
140ad30f8e7SGabor Kovesdan {
141ad30f8e7SGabor Kovesdan
142ad30f8e7SGabor Kovesdan return (((l >= 0xD9 && l <= 0xDE) || (l >= 0xE0 && l <= 0xF9)) &&
143ad30f8e7SGabor Kovesdan ((t >= 0x31 && t <= 0x7E) || (t >= 0x91 && t <= 0xFE)));
144ad30f8e7SGabor Kovesdan }
145ad30f8e7SGabor Kovesdan
146ad30f8e7SGabor Kovesdan static int
147ad30f8e7SGabor Kovesdan /*ARGSUSED*/
_citrus_JOHAB_mbrtowc_priv(_JOHABEncodingInfo * __restrict ei,wchar_t * __restrict pwc,char ** __restrict s,size_t n,_JOHABState * __restrict psenc,size_t * __restrict nresult)148ad30f8e7SGabor Kovesdan _citrus_JOHAB_mbrtowc_priv(_JOHABEncodingInfo * __restrict ei,
1491243a98eSTijl Coosemans wchar_t * __restrict pwc, char ** __restrict s, size_t n,
150ad30f8e7SGabor Kovesdan _JOHABState * __restrict psenc, size_t * __restrict nresult)
151ad30f8e7SGabor Kovesdan {
1521243a98eSTijl Coosemans char *s0;
153ad30f8e7SGabor Kovesdan int l, t;
154ad30f8e7SGabor Kovesdan
155ad30f8e7SGabor Kovesdan if (*s == NULL) {
156ad30f8e7SGabor Kovesdan _citrus_JOHAB_init_state(ei, psenc);
157ad30f8e7SGabor Kovesdan *nresult = _ENCODING_IS_STATE_DEPENDENT;
158ad30f8e7SGabor Kovesdan return (0);
159ad30f8e7SGabor Kovesdan }
160ad30f8e7SGabor Kovesdan s0 = *s;
161ad30f8e7SGabor Kovesdan
162ad30f8e7SGabor Kovesdan switch (psenc->chlen) {
163ad30f8e7SGabor Kovesdan case 0:
164ad30f8e7SGabor Kovesdan if (n-- < 1)
165ad30f8e7SGabor Kovesdan goto restart;
166ad30f8e7SGabor Kovesdan l = *s0++ & 0xFF;
167ad30f8e7SGabor Kovesdan if (l <= 0x7F) {
168ad30f8e7SGabor Kovesdan if (pwc != NULL)
169ad30f8e7SGabor Kovesdan *pwc = (wchar_t)l;
170ad30f8e7SGabor Kovesdan *nresult = (l == 0) ? 0 : 1;
171ad30f8e7SGabor Kovesdan *s = s0;
172ad30f8e7SGabor Kovesdan return (0);
173ad30f8e7SGabor Kovesdan }
174ad30f8e7SGabor Kovesdan psenc->ch[psenc->chlen++] = l;
175ad30f8e7SGabor Kovesdan break;
176ad30f8e7SGabor Kovesdan case 1:
177ad30f8e7SGabor Kovesdan l = psenc->ch[0] & 0xFF;
178ad30f8e7SGabor Kovesdan break;
179ad30f8e7SGabor Kovesdan default:
180ad30f8e7SGabor Kovesdan return (EINVAL);
181ad30f8e7SGabor Kovesdan }
182ad30f8e7SGabor Kovesdan if (n-- < 1) {
183ad30f8e7SGabor Kovesdan restart:
184ad30f8e7SGabor Kovesdan *nresult = (size_t)-2;
185ad30f8e7SGabor Kovesdan *s = s0;
186ad30f8e7SGabor Kovesdan return (0);
187ad30f8e7SGabor Kovesdan }
188ad30f8e7SGabor Kovesdan t = *s0++ & 0xFF;
189ad30f8e7SGabor Kovesdan if (!ishangul(l, t) && !isuda(l, t) && !ishanja(l, t)) {
190ad30f8e7SGabor Kovesdan *nresult = (size_t)-1;
191ad30f8e7SGabor Kovesdan return (EILSEQ);
192ad30f8e7SGabor Kovesdan }
193ad30f8e7SGabor Kovesdan if (pwc != NULL)
194ad30f8e7SGabor Kovesdan *pwc = (wchar_t)(l << 8 | t);
195ad30f8e7SGabor Kovesdan *nresult = s0 - *s;
196ad30f8e7SGabor Kovesdan *s = s0;
197ad30f8e7SGabor Kovesdan psenc->chlen = 0;
198ad30f8e7SGabor Kovesdan
199ad30f8e7SGabor Kovesdan return (0);
200ad30f8e7SGabor Kovesdan }
201ad30f8e7SGabor Kovesdan
202ad30f8e7SGabor Kovesdan static int
203ad30f8e7SGabor Kovesdan /*ARGSUSED*/
_citrus_JOHAB_wcrtomb_priv(_JOHABEncodingInfo * __restrict ei __unused,char * __restrict s,size_t n,wchar_t wc,_JOHABState * __restrict psenc,size_t * __restrict nresult)204ad30f8e7SGabor Kovesdan _citrus_JOHAB_wcrtomb_priv(_JOHABEncodingInfo * __restrict ei __unused,
205ad30f8e7SGabor Kovesdan char * __restrict s, size_t n, wchar_t wc,
206ad30f8e7SGabor Kovesdan _JOHABState * __restrict psenc, size_t * __restrict nresult)
207ad30f8e7SGabor Kovesdan {
208ad30f8e7SGabor Kovesdan int l, t;
209ad30f8e7SGabor Kovesdan
210ad30f8e7SGabor Kovesdan if (psenc->chlen != 0)
211ad30f8e7SGabor Kovesdan return (EINVAL);
212ad30f8e7SGabor Kovesdan
213ad30f8e7SGabor Kovesdan /* XXX assume wchar_t as int */
214ad30f8e7SGabor Kovesdan if ((uint32_t)wc <= 0x7F) {
215ad30f8e7SGabor Kovesdan if (n < 1)
216ad30f8e7SGabor Kovesdan goto e2big;
217ad30f8e7SGabor Kovesdan *s = wc & 0xFF;
218ad30f8e7SGabor Kovesdan *nresult = 1;
219ad30f8e7SGabor Kovesdan } else if ((uint32_t)wc <= 0xFFFF) {
220ad30f8e7SGabor Kovesdan if (n < 2) {
221ad30f8e7SGabor Kovesdan e2big:
222ad30f8e7SGabor Kovesdan *nresult = (size_t)-1;
223ad30f8e7SGabor Kovesdan return (E2BIG);
224ad30f8e7SGabor Kovesdan }
225ad30f8e7SGabor Kovesdan l = (wc >> 8) & 0xFF;
226ad30f8e7SGabor Kovesdan t = wc & 0xFF;
227ad30f8e7SGabor Kovesdan if (!ishangul(l, t) && !isuda(l, t) && !ishanja(l, t))
228ad30f8e7SGabor Kovesdan goto ilseq;
229ad30f8e7SGabor Kovesdan *s++ = l;
230ad30f8e7SGabor Kovesdan *s = t;
231ad30f8e7SGabor Kovesdan *nresult = 2;
232ad30f8e7SGabor Kovesdan } else {
233ad30f8e7SGabor Kovesdan ilseq:
234ad30f8e7SGabor Kovesdan *nresult = (size_t)-1;
235ad30f8e7SGabor Kovesdan return (EILSEQ);
236ad30f8e7SGabor Kovesdan }
237ad30f8e7SGabor Kovesdan return (0);
238ad30f8e7SGabor Kovesdan
239ad30f8e7SGabor Kovesdan }
240ad30f8e7SGabor Kovesdan
241ad30f8e7SGabor Kovesdan static __inline int
242ad30f8e7SGabor Kovesdan /*ARGSUSED*/
_citrus_JOHAB_stdenc_wctocs(_JOHABEncodingInfo * __restrict ei __unused,_csid_t * __restrict csid,_index_t * __restrict idx,wchar_t wc)243ad30f8e7SGabor Kovesdan _citrus_JOHAB_stdenc_wctocs(_JOHABEncodingInfo * __restrict ei __unused,
244ad30f8e7SGabor Kovesdan _csid_t * __restrict csid, _index_t * __restrict idx, wchar_t wc)
245ad30f8e7SGabor Kovesdan {
246ad30f8e7SGabor Kovesdan int m, l, linear, t;
247ad30f8e7SGabor Kovesdan
248ad30f8e7SGabor Kovesdan /* XXX assume wchar_t as int */
249ad30f8e7SGabor Kovesdan if ((uint32_t)wc <= 0x7F) {
250ad30f8e7SGabor Kovesdan *idx = (_index_t)wc;
251ad30f8e7SGabor Kovesdan *csid = 0;
252ad30f8e7SGabor Kovesdan } else if ((uint32_t)wc <= 0xFFFF) {
253ad30f8e7SGabor Kovesdan l = (wc >> 8) & 0xFF;
254ad30f8e7SGabor Kovesdan t = wc & 0xFF;
255ad30f8e7SGabor Kovesdan if (ishangul(l, t) || isuda(l, t)) {
256ad30f8e7SGabor Kovesdan *idx = (_index_t)wc;
257ad30f8e7SGabor Kovesdan *csid = 1;
258ad30f8e7SGabor Kovesdan } else {
259ad30f8e7SGabor Kovesdan if (l >= 0xD9 && l <= 0xDE) {
260ad30f8e7SGabor Kovesdan linear = l - 0xD9;
261ad30f8e7SGabor Kovesdan m = 0x21;
262ad30f8e7SGabor Kovesdan } else if (l >= 0xE0 && l <= 0xF9) {
263ad30f8e7SGabor Kovesdan linear = l - 0xE0;
264ad30f8e7SGabor Kovesdan m = 0x4A;
265ad30f8e7SGabor Kovesdan } else
266ad30f8e7SGabor Kovesdan return (EILSEQ);
267ad30f8e7SGabor Kovesdan linear *= 188;
268ad30f8e7SGabor Kovesdan if (t >= 0x31 && t <= 0x7E)
269ad30f8e7SGabor Kovesdan linear += t - 0x31;
270ad30f8e7SGabor Kovesdan else if (t >= 0x91 && t <= 0xFE)
271ad30f8e7SGabor Kovesdan linear += t - 0x43;
272ad30f8e7SGabor Kovesdan else
273ad30f8e7SGabor Kovesdan return (EILSEQ);
274ad30f8e7SGabor Kovesdan l = (linear / 94) + m;
275ad30f8e7SGabor Kovesdan t = (linear % 94) + 0x21;
276ad30f8e7SGabor Kovesdan *idx = (_index_t)((l << 8) | t);
277ad30f8e7SGabor Kovesdan *csid = 2;
278ad30f8e7SGabor Kovesdan }
279ad30f8e7SGabor Kovesdan } else
280ad30f8e7SGabor Kovesdan return (EILSEQ);
281ad30f8e7SGabor Kovesdan return (0);
282ad30f8e7SGabor Kovesdan }
283ad30f8e7SGabor Kovesdan
284ad30f8e7SGabor Kovesdan static __inline int
285ad30f8e7SGabor Kovesdan /*ARGSUSED*/
_citrus_JOHAB_stdenc_cstowc(_JOHABEncodingInfo * __restrict ei __unused,wchar_t * __restrict wc,_csid_t csid,_index_t idx)286ad30f8e7SGabor Kovesdan _citrus_JOHAB_stdenc_cstowc(_JOHABEncodingInfo * __restrict ei __unused,
287ad30f8e7SGabor Kovesdan wchar_t * __restrict wc, _csid_t csid, _index_t idx)
288ad30f8e7SGabor Kovesdan {
289ad30f8e7SGabor Kovesdan int m, n, l, linear, t;
290ad30f8e7SGabor Kovesdan
291ad30f8e7SGabor Kovesdan switch (csid) {
292ad30f8e7SGabor Kovesdan case 0:
293ad30f8e7SGabor Kovesdan case 1:
294ad30f8e7SGabor Kovesdan *wc = (wchar_t)idx;
295ad30f8e7SGabor Kovesdan break;
296ad30f8e7SGabor Kovesdan case 2:
297ad30f8e7SGabor Kovesdan if (idx >= 0x2121 && idx <= 0x2C71) {
298ad30f8e7SGabor Kovesdan m = 0xD9;
299ad30f8e7SGabor Kovesdan n = 0x21;
300ad30f8e7SGabor Kovesdan } else if (idx >= 0x4A21 && idx <= 0x7D7E) {
301ad30f8e7SGabor Kovesdan m = 0xE0;
302ad30f8e7SGabor Kovesdan n = 0x4A;
303ad30f8e7SGabor Kovesdan } else
304ad30f8e7SGabor Kovesdan return (EILSEQ);
305ad30f8e7SGabor Kovesdan l = ((idx >> 8) & 0xFF) - n;
306ad30f8e7SGabor Kovesdan t = (idx & 0xFF) - 0x21;
307ad30f8e7SGabor Kovesdan linear = (l * 94) + t;
308ad30f8e7SGabor Kovesdan l = (linear / 188) + m;
309ad30f8e7SGabor Kovesdan t = linear % 188;
310ad30f8e7SGabor Kovesdan t += (t <= 0x4D) ? 0x31 : 0x43;
311ad30f8e7SGabor Kovesdan break;
312ad30f8e7SGabor Kovesdan default:
313ad30f8e7SGabor Kovesdan return (EILSEQ);
314ad30f8e7SGabor Kovesdan }
315ad30f8e7SGabor Kovesdan return (0);
316ad30f8e7SGabor Kovesdan }
317ad30f8e7SGabor Kovesdan
318ad30f8e7SGabor Kovesdan static __inline int
319ad30f8e7SGabor Kovesdan /*ARGSUSED*/
_citrus_JOHAB_stdenc_get_state_desc_generic(_JOHABEncodingInfo * __restrict ei __unused,_JOHABState * __restrict psenc,int * __restrict rstate)320ad30f8e7SGabor Kovesdan _citrus_JOHAB_stdenc_get_state_desc_generic(_JOHABEncodingInfo * __restrict ei __unused,
321ad30f8e7SGabor Kovesdan _JOHABState * __restrict psenc, int * __restrict rstate)
322ad30f8e7SGabor Kovesdan {
323ad30f8e7SGabor Kovesdan
324ad30f8e7SGabor Kovesdan *rstate = (psenc->chlen == 0) ? _STDENC_SDGEN_INITIAL :
325ad30f8e7SGabor Kovesdan _STDENC_SDGEN_INCOMPLETE_CHAR;
326ad30f8e7SGabor Kovesdan return (0);
327ad30f8e7SGabor Kovesdan }
328ad30f8e7SGabor Kovesdan
329ad30f8e7SGabor Kovesdan /* ----------------------------------------------------------------------
330ad30f8e7SGabor Kovesdan * public interface for stdenc
331ad30f8e7SGabor Kovesdan */
332ad30f8e7SGabor Kovesdan
333ad30f8e7SGabor Kovesdan _CITRUS_STDENC_DECLS(JOHAB);
334ad30f8e7SGabor Kovesdan _CITRUS_STDENC_DEF_OPS(JOHAB);
335ad30f8e7SGabor Kovesdan
336ad30f8e7SGabor Kovesdan #include "citrus_stdenc_template.h"
337