Home | History | Annotate | Line # | Download | only in modules
      1  1.16  christos /*	$NetBSD: citrus_euc.c,v 1.17 2014/01/18 15:21:41 christos 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  * Copyright (c) 1993
     31   1.1  tshiozak  *	The Regents of the University of California.  All rights reserved.
     32   1.1  tshiozak  *
     33   1.1  tshiozak  * This code is derived from software contributed to Berkeley by
     34   1.1  tshiozak  * Paul Borman at Krystal Technologies.
     35   1.1  tshiozak  *
     36   1.1  tshiozak  * Redistribution and use in source and binary forms, with or without
     37   1.1  tshiozak  * modification, are permitted provided that the following conditions
     38   1.1  tshiozak  * are met:
     39   1.1  tshiozak  * 1. Redistributions of source code must retain the above copyright
     40   1.1  tshiozak  *    notice, this list of conditions and the following disclaimer.
     41   1.1  tshiozak  * 2. Redistributions in binary form must reproduce the above copyright
     42   1.1  tshiozak  *    notice, this list of conditions and the following disclaimer in the
     43   1.1  tshiozak  *    documentation and/or other materials provided with the distribution.
     44   1.8       agc  * 3. Neither the name of the University nor the names of its contributors
     45   1.1  tshiozak  *    may be used to endorse or promote products derived from this software
     46   1.1  tshiozak  *    without specific prior written permission.
     47   1.1  tshiozak  *
     48   1.1  tshiozak  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     49   1.1  tshiozak  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     50   1.1  tshiozak  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     51   1.1  tshiozak  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     52   1.1  tshiozak  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     53   1.1  tshiozak  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     54   1.1  tshiozak  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     55   1.1  tshiozak  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     56   1.1  tshiozak  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     57   1.1  tshiozak  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     58   1.1  tshiozak  * SUCH DAMAGE.
     59   1.1  tshiozak  */
     60   1.1  tshiozak 
     61   1.1  tshiozak #include <sys/cdefs.h>
     62   1.1  tshiozak #if defined(LIBC_SCCS) && !defined(lint)
     63  1.16  christos __RCSID("$NetBSD: citrus_euc.c,v 1.17 2014/01/18 15:21:41 christos Exp $");
     64   1.1  tshiozak #endif /* LIBC_SCCS and not lint */
     65   1.1  tshiozak 
     66   1.1  tshiozak #include <assert.h>
     67   1.1  tshiozak #include <errno.h>
     68   1.1  tshiozak #include <string.h>
     69   1.1  tshiozak #include <stdio.h>
     70   1.1  tshiozak #include <stdlib.h>
     71   1.1  tshiozak #include <stddef.h>
     72   1.1  tshiozak #include <wchar.h>
     73   1.1  tshiozak #include <sys/types.h>
     74   1.1  tshiozak #include <limits.h>
     75   1.6  tshiozak 
     76   1.6  tshiozak #include "citrus_namespace.h"
     77  1.13   tnozaki #include "citrus_bcs.h"
     78   1.6  tshiozak #include "citrus_types.h"
     79   1.1  tshiozak #include "citrus_module.h"
     80   1.1  tshiozak #include "citrus_ctype.h"
     81   1.6  tshiozak #include "citrus_stdenc.h"
     82   1.1  tshiozak #include "citrus_euc.h"
     83   1.1  tshiozak 
     84   1.1  tshiozak 
     85   1.1  tshiozak /* ----------------------------------------------------------------------
     86   1.1  tshiozak  * private stuffs used by templates
     87   1.1  tshiozak  */
     88   1.1  tshiozak 
     89   1.1  tshiozak typedef struct {
     90   1.1  tshiozak 	char ch[3];
     91   1.1  tshiozak 	int chlen;
     92   1.1  tshiozak } _EUCState;
     93   1.1  tshiozak 
     94   1.1  tshiozak typedef struct {
     95   1.1  tshiozak 	unsigned	count[4];
     96   1.1  tshiozak 	wchar_t		bits[4];
     97   1.1  tshiozak 	wchar_t		mask;
     98   1.1  tshiozak 	unsigned	mb_cur_max;
     99   1.1  tshiozak } _EUCEncodingInfo;
    100   1.1  tshiozak 
    101   1.1  tshiozak typedef struct {
    102   1.1  tshiozak 	_EUCEncodingInfo	ei;
    103   1.1  tshiozak 	struct {
    104   1.1  tshiozak 		/* for future multi-locale facility */
    105   1.1  tshiozak 		_EUCState	s_mblen;
    106   1.1  tshiozak 		_EUCState	s_mbrlen;
    107   1.1  tshiozak 		_EUCState	s_mbrtowc;
    108   1.1  tshiozak 		_EUCState	s_mbtowc;
    109   1.1  tshiozak 		_EUCState	s_mbsrtowcs;
    110  1.15     joerg 		_EUCState	s_mbsnrtowcs;
    111   1.1  tshiozak 		_EUCState	s_wcrtomb;
    112   1.1  tshiozak 		_EUCState	s_wcsrtombs;
    113  1.15     joerg 		_EUCState	s_wcsnrtombs;
    114   1.1  tshiozak 		_EUCState	s_wctomb;
    115   1.1  tshiozak 	} states;
    116   1.1  tshiozak } _EUCCTypeInfo;
    117   1.1  tshiozak 
    118   1.1  tshiozak #define	_SS2	0x008e
    119   1.1  tshiozak #define	_SS3	0x008f
    120   1.1  tshiozak 
    121   1.1  tshiozak #define _CEI_TO_EI(_cei_)		(&(_cei_)->ei)
    122   1.1  tshiozak #define _CEI_TO_STATE(_cei_, _func_)	(_cei_)->states.s_##_func_
    123   1.1  tshiozak 
    124   1.1  tshiozak #define _FUNCNAME(m)			_citrus_EUC_##m
    125   1.1  tshiozak #define _ENCODING_INFO			_EUCEncodingInfo
    126   1.1  tshiozak #define _CTYPE_INFO			_EUCCTypeInfo
    127   1.1  tshiozak #define _ENCODING_STATE			_EUCState
    128   1.2      yamt #define _ENCODING_MB_CUR_MAX(_ei_)	(_ei_)->mb_cur_max
    129   1.1  tshiozak #define _ENCODING_IS_STATE_DEPENDENT	0
    130   1.4      yamt #define _STATE_NEEDS_EXPLICIT_INIT(_ps_)	0
    131   1.1  tshiozak 
    132   1.1  tshiozak 
    133   1.1  tshiozak static __inline int
    134   1.1  tshiozak _citrus_EUC_cs(unsigned int c)
    135   1.1  tshiozak {
    136   1.1  tshiozak 	c &= 0xff;
    137   1.1  tshiozak 
    138   1.1  tshiozak 	return ((c & 0x80) ? c == _SS3 ? 3 : c == _SS2 ? 2 : 1 : 0);
    139   1.1  tshiozak }
    140   1.1  tshiozak 
    141   1.1  tshiozak static __inline int
    142   1.1  tshiozak _citrus_EUC_parse_variable(_EUCEncodingInfo *ei,
    143   1.1  tshiozak 			   const void *var, size_t lenvar)
    144   1.1  tshiozak {
    145   1.1  tshiozak 	const char *v, *e;
    146   1.1  tshiozak 	int x;
    147   1.1  tshiozak 
    148   1.1  tshiozak 	/* parse variable string */
    149   1.1  tshiozak 	if (!var)
    150   1.1  tshiozak 		return (EFTYPE);
    151   1.1  tshiozak 
    152   1.1  tshiozak 	v = (const char *) var;
    153   1.1  tshiozak 
    154   1.1  tshiozak 	while (*v == ' ' || *v == '\t')
    155   1.1  tshiozak 		++v;
    156   1.1  tshiozak 
    157   1.1  tshiozak 	ei->mb_cur_max = 1;
    158   1.1  tshiozak 	for (x = 0; x < 4; ++x) {
    159  1.13   tnozaki 		ei->count[x] = (int)_bcs_strtol(v, (char **)&e, 0);
    160   1.1  tshiozak 		if (v == e || !(v = e) || ei->count[x]<1 || ei->count[x]>4) {
    161   1.1  tshiozak 			return (EFTYPE);
    162   1.1  tshiozak 		}
    163   1.1  tshiozak 		if (ei->mb_cur_max < ei->count[x])
    164   1.1  tshiozak 			ei->mb_cur_max = ei->count[x];
    165   1.1  tshiozak 		while (*v == ' ' || *v == '\t')
    166   1.1  tshiozak 			++v;
    167  1.13   tnozaki 		ei->bits[x] = (int)_bcs_strtol(v, (char **)&e, 0);
    168   1.1  tshiozak 		if (v == e || !(v = e)) {
    169   1.1  tshiozak 			return (EFTYPE);
    170   1.1  tshiozak 		}
    171   1.1  tshiozak 		while (*v == ' ' || *v == '\t')
    172   1.1  tshiozak 			++v;
    173   1.1  tshiozak 	}
    174  1.13   tnozaki 	ei->mask = (int)_bcs_strtol(v, (char **)&e, 0);
    175   1.1  tshiozak 	if (v == e || !(v = e)) {
    176   1.1  tshiozak 		return (EFTYPE);
    177   1.1  tshiozak 	}
    178   1.1  tshiozak 
    179   1.1  tshiozak 	return 0;
    180   1.1  tshiozak }
    181   1.1  tshiozak 
    182   1.1  tshiozak 
    183   1.1  tshiozak static __inline void
    184   1.1  tshiozak /*ARGSUSED*/
    185   1.1  tshiozak _citrus_EUC_init_state(_EUCEncodingInfo *ei, _EUCState *s)
    186   1.1  tshiozak {
    187   1.1  tshiozak 	memset(s, 0, sizeof(*s));
    188   1.1  tshiozak }
    189   1.1  tshiozak 
    190   1.1  tshiozak static __inline void
    191   1.1  tshiozak /*ARGSUSED*/
    192   1.1  tshiozak _citrus_EUC_pack_state(_EUCEncodingInfo *ei, void *pspriv, const _EUCState *s)
    193   1.1  tshiozak {
    194   1.1  tshiozak 	memcpy(pspriv, (const void *)s, sizeof(*s));
    195   1.1  tshiozak }
    196   1.1  tshiozak 
    197   1.1  tshiozak static __inline void
    198   1.1  tshiozak /*ARGSUSED*/
    199   1.1  tshiozak _citrus_EUC_unpack_state(_EUCEncodingInfo *ei, _EUCState *s,
    200   1.1  tshiozak 			 const void *pspriv)
    201   1.1  tshiozak {
    202   1.1  tshiozak 	memcpy((void *)s, pspriv, sizeof(*s));
    203   1.1  tshiozak }
    204   1.1  tshiozak 
    205   1.1  tshiozak static int
    206   1.1  tshiozak _citrus_EUC_mbrtowc_priv(_EUCEncodingInfo *ei, wchar_t *pwc, const char **s,
    207   1.1  tshiozak 			 size_t n, _EUCState *psenc, size_t *nresult)
    208   1.1  tshiozak {
    209   1.1  tshiozak 	wchar_t wchar;
    210   1.1  tshiozak 	int c, cs, len;
    211   1.1  tshiozak 	int chlenbak;
    212   1.1  tshiozak 	const char *s0, *s1 = NULL;
    213   1.1  tshiozak 
    214   1.1  tshiozak 	_DIAGASSERT(nresult != 0);
    215   1.1  tshiozak 	_DIAGASSERT(ei != NULL);
    216   1.1  tshiozak 	_DIAGASSERT(psenc != NULL);
    217   1.1  tshiozak 	_DIAGASSERT(s != NULL);
    218   1.1  tshiozak 
    219   1.1  tshiozak 	s0 = *s;
    220   1.1  tshiozak 
    221   1.1  tshiozak 	if (s0 == NULL) {
    222   1.1  tshiozak 		_citrus_EUC_init_state(ei, psenc);
    223   1.1  tshiozak 		*nresult = 0; /* state independent */
    224   1.1  tshiozak 		return (0);
    225   1.1  tshiozak 	}
    226   1.1  tshiozak 
    227   1.1  tshiozak 	chlenbak = psenc->chlen;
    228   1.1  tshiozak 
    229   1.1  tshiozak 	/* make sure we have the first byte in the buffer */
    230   1.1  tshiozak 	switch (psenc->chlen) {
    231   1.1  tshiozak 	case 0:
    232   1.1  tshiozak 		if (n < 1)
    233   1.1  tshiozak 			goto restart;
    234   1.1  tshiozak 		psenc->ch[0] = *s0++;
    235   1.1  tshiozak 		psenc->chlen = 1;
    236   1.1  tshiozak 		n--;
    237   1.1  tshiozak 		break;
    238   1.1  tshiozak 	case 1:
    239   1.1  tshiozak 	case 2:
    240   1.1  tshiozak 		break;
    241   1.1  tshiozak 	default:
    242   1.1  tshiozak 		/* illgeal state */
    243   1.1  tshiozak 		goto encoding_error;
    244   1.1  tshiozak 	}
    245   1.1  tshiozak 
    246   1.1  tshiozak 	c = ei->count[cs = _citrus_EUC_cs(psenc->ch[0] & 0xff)];
    247   1.1  tshiozak 	if (c == 0)
    248   1.1  tshiozak 		goto encoding_error;
    249   1.1  tshiozak 	while (psenc->chlen < c) {
    250   1.1  tshiozak 		if (n < 1)
    251   1.1  tshiozak 			goto restart;
    252   1.1  tshiozak 		psenc->ch[psenc->chlen] = *s0++;
    253   1.1  tshiozak 		psenc->chlen++;
    254   1.1  tshiozak 		n--;
    255   1.1  tshiozak 	}
    256   1.1  tshiozak 	*s = s0;
    257   1.1  tshiozak 
    258   1.1  tshiozak 	switch (cs) {
    259   1.1  tshiozak 	case 3:
    260   1.1  tshiozak 	case 2:
    261   1.1  tshiozak 		/* skip SS2/SS3 */
    262   1.1  tshiozak 		len = c - 1;
    263   1.1  tshiozak 		s1 = &psenc->ch[1];
    264   1.1  tshiozak 		break;
    265   1.1  tshiozak 	case 1:
    266   1.1  tshiozak 	case 0:
    267   1.1  tshiozak 		len = c;
    268   1.1  tshiozak 		s1 = &psenc->ch[0];
    269   1.1  tshiozak 		break;
    270  1.11  christos 	default:
    271  1.11  christos 		goto encoding_error;
    272   1.1  tshiozak 	}
    273   1.1  tshiozak 	wchar = 0;
    274   1.1  tshiozak 	while (len-- > 0)
    275   1.1  tshiozak 		wchar = (wchar << 8) | (*s1++ & 0xff);
    276  1.17  christos 	wchar = (wchar & ~ei->mask) | ei->bits[cs];
    277   1.1  tshiozak 
    278   1.1  tshiozak 	psenc->chlen = 0;
    279   1.1  tshiozak 	if (pwc)
    280   1.1  tshiozak 		*pwc = wchar;
    281   1.1  tshiozak 
    282   1.1  tshiozak 	if (!wchar) {
    283   1.1  tshiozak 		*nresult = 0;
    284   1.1  tshiozak 	} else {
    285   1.1  tshiozak 		*nresult = (size_t)(c - chlenbak);
    286   1.1  tshiozak 	}
    287   1.1  tshiozak 
    288   1.1  tshiozak 	return 0;
    289   1.1  tshiozak 
    290   1.1  tshiozak encoding_error:
    291   1.1  tshiozak 	psenc->chlen = 0;
    292   1.1  tshiozak 	*nresult = (size_t)-1;
    293   1.1  tshiozak 	return (EILSEQ);
    294   1.1  tshiozak 
    295   1.1  tshiozak restart:
    296   1.1  tshiozak 	*nresult = (size_t)-2;
    297   1.1  tshiozak 	*s = s0;
    298   1.1  tshiozak 	return (0);
    299   1.1  tshiozak }
    300   1.1  tshiozak 
    301   1.1  tshiozak static int
    302   1.1  tshiozak _citrus_EUC_wcrtomb_priv(_EUCEncodingInfo *ei, char *s, size_t n, wchar_t wc,
    303   1.1  tshiozak 			 _EUCState *psenc, size_t *nresult)
    304   1.1  tshiozak {
    305   1.1  tshiozak 	wchar_t m, nm;
    306   1.6  tshiozak 	int cs, i, ret;
    307   1.1  tshiozak 
    308   1.1  tshiozak 	_DIAGASSERT(ei != NULL);
    309   1.1  tshiozak 	_DIAGASSERT(nresult != 0);
    310   1.1  tshiozak 	_DIAGASSERT(s != NULL);
    311   1.6  tshiozak 
    312   1.1  tshiozak 	m = wc & ei->mask;
    313   1.1  tshiozak 	nm = wc & ~m;
    314   1.1  tshiozak 
    315   1.1  tshiozak 	for (cs = 0;
    316   1.1  tshiozak 	     cs < sizeof(ei->count)/sizeof(ei->count[0]);
    317   1.1  tshiozak 	     cs++) {
    318   1.1  tshiozak 		if (m == ei->bits[cs])
    319   1.1  tshiozak 			break;
    320   1.1  tshiozak 	}
    321   1.1  tshiozak 	/* fallback case - not sure if it is necessary */
    322   1.1  tshiozak 	if (cs == sizeof(ei->count)/sizeof(ei->count[0]))
    323   1.1  tshiozak 		cs = 1;
    324   1.1  tshiozak 
    325   1.1  tshiozak 	i = ei->count[cs];
    326   1.6  tshiozak 	if (n < i) {
    327   1.6  tshiozak 		ret = E2BIG;
    328   1.6  tshiozak 		goto err;
    329   1.6  tshiozak 	}
    330   1.9  tshiozak 	m = (cs) ? 0x80 : 0x00;
    331   1.1  tshiozak 	switch (cs) {
    332   1.1  tshiozak 	case 2:
    333   1.1  tshiozak 		*s++ = _SS2;
    334   1.1  tshiozak 		i--;
    335   1.1  tshiozak 		break;
    336   1.1  tshiozak 	case 3:
    337   1.1  tshiozak 		*s++ = _SS3;
    338   1.1  tshiozak 		i--;
    339   1.1  tshiozak 		break;
    340   1.1  tshiozak 	}
    341   1.1  tshiozak 
    342   1.1  tshiozak 	while (i-- > 0)
    343   1.1  tshiozak 		*s++ = ((nm >> (i << 3)) & 0xff) | m;
    344   1.1  tshiozak 
    345   1.1  tshiozak 	*nresult = (size_t)ei->count[cs];
    346   1.1  tshiozak 	return 0;
    347   1.1  tshiozak 
    348   1.6  tshiozak err:
    349   1.1  tshiozak 	*nresult = (size_t)-1;
    350   1.6  tshiozak 	return ret;
    351   1.6  tshiozak }
    352   1.6  tshiozak 
    353   1.6  tshiozak static __inline int
    354   1.6  tshiozak /*ARGSUSED*/
    355   1.6  tshiozak _citrus_EUC_stdenc_wctocs(_EUCEncodingInfo * __restrict ei,
    356   1.6  tshiozak 			  _csid_t * __restrict csid,
    357   1.6  tshiozak 			  _index_t * __restrict idx, wchar_t wc)
    358   1.6  tshiozak {
    359   1.6  tshiozak 	wchar_t m, nm;
    360   1.6  tshiozak 
    361   1.6  tshiozak 	_DIAGASSERT(ei != NULL && csid != NULL && idx != NULL);
    362   1.6  tshiozak 
    363   1.6  tshiozak 	m = wc & ei->mask;
    364   1.6  tshiozak 	nm = wc & ~m;
    365   1.6  tshiozak 
    366   1.6  tshiozak 	*csid = (_citrus_csid_t)m;
    367   1.6  tshiozak 	*idx  = (_citrus_index_t)nm;
    368   1.6  tshiozak 
    369   1.6  tshiozak 	return (0);
    370   1.6  tshiozak }
    371   1.6  tshiozak 
    372   1.6  tshiozak static __inline int
    373   1.6  tshiozak /*ARGSUSED*/
    374   1.6  tshiozak _citrus_EUC_stdenc_cstowc(_EUCEncodingInfo * __restrict ei,
    375   1.6  tshiozak 			  wchar_t * __restrict wc,
    376   1.6  tshiozak 			  _csid_t csid, _index_t idx)
    377   1.6  tshiozak {
    378   1.6  tshiozak 
    379   1.6  tshiozak 	_DIAGASSERT(ei != NULL && wc != NULL);
    380   1.6  tshiozak 
    381   1.6  tshiozak 	if ((csid & ~ei->mask) != 0 || (idx & ei->mask) != 0)
    382   1.6  tshiozak 		return (EINVAL);
    383   1.6  tshiozak 
    384   1.6  tshiozak 	*wc = (wchar_t)csid | (wchar_t)idx;
    385   1.6  tshiozak 
    386   1.6  tshiozak 	return (0);
    387   1.1  tshiozak }
    388   1.1  tshiozak 
    389  1.10  tshiozak static __inline int
    390  1.10  tshiozak /*ARGSUSED*/
    391  1.10  tshiozak _citrus_EUC_stdenc_get_state_desc_generic(_EUCEncodingInfo * __restrict ei,
    392  1.10  tshiozak 					  _EUCState * __restrict psenc,
    393  1.10  tshiozak 					  int * __restrict rstate)
    394  1.10  tshiozak {
    395  1.10  tshiozak 
    396  1.10  tshiozak 	if (psenc->chlen == 0)
    397  1.10  tshiozak 		*rstate = _STDENC_SDGEN_INITIAL;
    398  1.10  tshiozak 	else
    399  1.10  tshiozak 		*rstate = _STDENC_SDGEN_INCOMPLETE_CHAR;
    400  1.10  tshiozak 
    401  1.10  tshiozak 	return 0;
    402  1.10  tshiozak }
    403  1.10  tshiozak 
    404   1.1  tshiozak static int
    405   1.1  tshiozak /*ARGSUSED*/
    406   1.6  tshiozak _citrus_EUC_encoding_module_init(_EUCEncodingInfo * __restrict ei,
    407   1.6  tshiozak 				 const void * __restrict var, size_t lenvar)
    408   1.1  tshiozak {
    409   1.1  tshiozak 
    410   1.1  tshiozak 	_DIAGASSERT(ei != NULL);
    411   1.1  tshiozak 
    412   1.1  tshiozak 	return (_citrus_EUC_parse_variable(ei, var, lenvar));
    413   1.1  tshiozak }
    414   1.1  tshiozak 
    415   1.1  tshiozak static void
    416   1.1  tshiozak /*ARGSUSED*/
    417   1.6  tshiozak _citrus_EUC_encoding_module_uninit(_EUCEncodingInfo * __restrict ei)
    418   1.1  tshiozak {
    419   1.1  tshiozak }
    420   1.1  tshiozak 
    421   1.1  tshiozak /* ----------------------------------------------------------------------
    422   1.1  tshiozak  * public interface for ctype
    423   1.1  tshiozak  */
    424   1.1  tshiozak 
    425   1.1  tshiozak _CITRUS_CTYPE_DECLS(EUC);
    426   1.1  tshiozak _CITRUS_CTYPE_DEF_OPS(EUC);
    427   1.1  tshiozak 
    428   1.1  tshiozak #include "citrus_ctype_template.h"
    429   1.6  tshiozak 
    430   1.6  tshiozak /* ----------------------------------------------------------------------
    431   1.6  tshiozak  * public interface for stdenc
    432   1.6  tshiozak  */
    433   1.6  tshiozak 
    434   1.6  tshiozak _CITRUS_STDENC_DECLS(EUC);
    435   1.6  tshiozak _CITRUS_STDENC_DEF_OPS(EUC);
    436   1.6  tshiozak 
    437   1.6  tshiozak #include "citrus_stdenc_template.h"
    438