newlib-cygwin/newlib/libc/iconv/ces/euc.c

472 lines
13 KiB
C
Raw Normal View History

2004-06-25 Artem B. Bityuckiy <dedekind@oktetlabs.ru> * acinclude.m4: Move iconv options into configure.in. * aclocal.m4: Regenerated. * configure: Ditto. * configure.in: Add iconv options. * newlib.hin: Add new iconv encodings and remove deleted ones. * doc/aclocal.m4: Regenerated. * doc/configure: Ditto. * iconvdata/aclocal.m4: Ditto. * iconvdata/configure: Ditto. * libc/iconv: Design change. New size-optimized ccs format. * libc/iconv/AUTHORS: Removed. * libc/iconv/COPYING: Ditto. * libc/iconv/README.ORIGINAL: Ditto. * libc/iconv/README.TODO: Ditto. * libc/iconv/charset.aliases: Ditto. * libc/iconv/encoding.aliases: New file. * libc/iconv/Makefile.am: Updated. * libc/iconv/Makefile.in: Regenerated. * libc/iconv/iconv.tex: Updated. * libc/iconv/ccs/Makefile.am: Ditto. * libc/iconv/ccs/Makefile.in: Regenerated. * libc/iconv/ccs/big5.c: Updated. * libc/iconv/ccs/cns11643_plane1.c: Ditto. * libc/iconv/ccs/cns11643_plane14.c: Ditto. * libc/iconv/ccs/cns11643_plane2.c: Ditto. * libc/iconv/ccs/cp775.c: Ditto. * libc/iconv/ccs/cp850.c: Ditto. * libc/iconv/ccs/cp852.c: Ditto. * libc/iconv/ccs/cp855.c: Ditto. * libc/iconv/ccs/cp866.c: Ditto. * libc/iconv/ccs/iso_8859_1.c: Ditto. * libc/iconv/ccs/README.CCS.SOURCES: Removed. * libc/iconv/ccs/gb_2312_80.c: Ditto. * libc/iconv/ccs/iconv_mktbl: Ditto. * libc/iconv/ccs/jis_x0201.c: Ditto. * libc/iconv/ccs/jis_x0208_1983.c: Ditto. * libc/iconv/ccs/shift_jis.c: Ditto. * libc/iconv/ccs/us_ascii.c: Ditto. * libc/iconv/ccs/ccs.h: New file. * libc/iconv/ccs/ccsbi.c: Ditto. * libc/iconv/ccs/ccsbi.h: Ditto. * libc/iconv/ccs/ccsnames.h: Ditto. * libc/iconv/ccs/iso_8859_10.c: Ditto. * libc/iconv/ccs/iso_8859_11.c: Ditto. * libc/iconv/ccs/iso_8859_13.c: Ditto. * libc/iconv/ccs/iso_8859_14.c: Ditto. * libc/iconv/ccs/iso_8859_3.c: Ditto. * libc/iconv/ccs/iso_8859_6.c: Ditto. * libc/iconv/ccs/iso_8859_7.c: Ditto. * libc/iconv/ccs/iso_8859_8.c: Ditto. * libc/iconv/ccs/iso_8859_9.c: Ditto. * libc/iconv/ccs/iso_ir_111.c: Ditto. * libc/iconv/ccs/jis_x0201_1976.c: Ditto. * libc/iconv/ccs/jis_x0208_1990.c: Ditto. * libc/iconv/ccs/koi8_ru.c: Ditto. * libc/iconv/ccs/koi8_uni.c: Ditto. * libc/iconv/ccs/mktbl.pl: Ditto. * libc/iconv/ccs/win_1250.c: Ditto. * libc/iconv/ccs/win_1251.c: Ditto. * libc/iconv/ccs/win_1252.c: Ditto. * libc/iconv/ccs/win_1253.c: Ditto. * libc/iconv/ccs/win_1254.c: Ditto. * libc/iconv/ccs/win_1255.c: Ditto. * libc/iconv/ccs/win_1256.c: Ditto. * libc/iconv/ccs/win_1257.c: Ditto. * libc/iconv/ccs/win_1258.c: Ditto. * libc/iconv/ccs/iso_8859_15.c * libc/iconv/ccs/iso_8859_2.c * libc/iconv/ccs/iso_8859_4.c * libc/iconv/ccs/iso_8859_5.c * libc/iconv/ccs/jis_x0212_1990.c * libc/iconv/ccs/koi8_r.c * libc/iconv/ccs/koi8_u.c * libc/iconv/ccs/ksx1001.c * libc/iconv/ccs/binary/gb_2312_80.cct: Removed. * libc/iconv/ccs/binary/jis_x0201.cct: Ditto. * libc/iconv/ccs/binary/shift_jis.cct: Ditto. * libc/iconv/ccs/binary/us_ascii.cct: Ditto. * libc/iconv/ccs/binary/jis_x0208_1983.cct: Ditto. * libc/iconv/ccs/binary/Makefile.am: Updated. * libc/iconv/ccs/binary/Makefile.in: Regenerated. * libc/iconv/ccs/binary/big5.cct: Updated. * libc/iconv/ccs/binary/cns11643_plane1.cct: Ditto. * libc/iconv/ccs/binary/cns11643_plane14.cct: Ditto. * libc/iconv/ccs/binary/cns11643_plane2.cct: Ditto. * libc/iconv/ccs/binary/cp775.cct: Updated.: Ditto. * libc/iconv/ccs/binary/cp850.cct: Ditto.: Ditto. * libc/iconv/ccs/binary/cp852.cct: Ditto.: Ditto. * libc/iconv/ccs/binary/cp855.cct: Ditto.: Ditto. * libc/iconv/ccs/binary/cp866.cct: Ditto.: Ditto. * libc/iconv/ccs/binary/iso_8859_1.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_15.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_4.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_5.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_2.cct: Ditto. * libc/iconv/ccs/binary/jis_x0212_1990.cct: Ditto. * libc/iconv/ccs/binary/koi8_r.cct: Ditto. * libc/iconv/ccs/binary/koi8_u.cct: Ditto. * libc/iconv/ccs/binary/ksx1001.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_10.cct: New file. * libc/iconv/ccs/binary/iso_8859_11.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_13.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_14.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_3.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_6.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_7.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_8.cct: Ditto. * libc/iconv/ccs/binary/iso_8859_9.cct: Ditto. * libc/iconv/ccs/binary/iso_ir_111.cct: Ditto. * libc/iconv/ccs/binary/jis_x0201_1976.cct: Ditto. * libc/iconv/ccs/binary/jis_x0208_1990.cct: Ditto. * libc/iconv/ccs/binary/koi8_ru.cct: Ditto. * libc/iconv/ccs/binary/koi8_uni.cct: Ditto. * libc/iconv/ccs/binary/win_1250.cct: Ditto. * libc/iconv/ccs/binary/win_1251.cct: Ditto. * libc/iconv/ccs/binary/win_1252.cct: Ditto. * libc/iconv/ccs/binary/win_1253.cct: Ditto. * libc/iconv/ccs/binary/win_1254.cct: Ditto. * libc/iconv/ccs/binary/win_1255.cct: Ditto. * libc/iconv/ccs/binary/win_1256.cct: Ditto. * libc/iconv/ccs/binary/win_1257.cct: Ditto. * libc/iconv/ccs/binary/win_1258.cct: Ditto. * libc/iconv/ces/Makefile.am: Updated. * libc/iconv/ces/Makefile.in: Regenerated. * libc/iconv/ces/ucs-2-internal.c: Updated. * libc/iconv/ces/ucs-4-internal.c: Ditto. * libc/iconv/ces/utf-16.c: Ditto. * libc/iconv/ces/utf-8.c: Ditto. * libc/iconv/ces/cesbi.c: New file. * libc/iconv/ces/cesbi.h: Ditto. * libc/iconv/ces/cesdeps.h: Ditto. * libc/iconv/ces/euc.c: Ditto. * libc/iconv/ces/mkdeps.pl: Ditto. * libc/iconv/ces/table-pcs.c: Ditto. * libc/iconv/ces/table.c: Ditto. * libc/iconv/ces/ucs-2.c: Ditto. * libc/iconv/ces/ucs-4.c: Ditto. * libc/iconv/ces/us-ascii.c: Ditto. * libc/iconv/ces/euc-jp.c: Removed. * libc/iconv/ces/euc-kr.c: Ditto. * libc/iconv/ces/euc-tw.c: Ditto. * libc/iconv/ces/gb2312.c: Ditto. * libc/iconv/ces/iso-10646-ucs-2.: Ditto.c * libc/iconv/ces/iso-10646-ucs-4.c: Ditto. * libc/iconv/lib/Makefile.am: Updated. * libc/iconv/lib/Makefile.in: Regenerated. * libc/iconv/lib/endian.h: Updated. * libc/iconv/lib/iconv.c: Ditto. * libc/iconv/lib/local.h: Ditto. * libc/iconv/lib/aliases.c: Removed. * libc/iconv/lib/bialiasesi.c: Ditto. * libc/iconv/lib/biccs.c: Ditto. * libc/iconv/lib/bices.c: Ditto. * libc/iconv/lib/ccs.c: Ditto. * libc/iconv/lib/ces.c: Ditto. * libc/iconv/lib/ces_euc.c: Ditto. * libc/iconv/lib/ces_iso2022.c: Ditto. * libc/iconv/lib/ces_table.c: Ditto. * libc/iconv/lib/converter.c: Ditto. * libc/iconv/lib/deps.h: Ditto. * libc/iconv/lib/aliasesbi.c: Ditto. * libc/iconv/lib/aliasesi.c: Ditto. * libc/iconv/lib/conv.h: Ditto. * libc/iconv/lib/encnames.h: Ditto. * libc/iconv/lib/encoding.deps: Ditto. * libc/iconv/lib/iconvnls.c: Ditto. * libc/iconv/lib/iconvnls.h: Ditto. * libc/iconv/lib/loaddata.c: Ditto. * libc/iconv/lib/nullconv.c: Ditto. * libc/iconv/lib/ucsconv.c: Ditto. * libc/iconv/lib/ucsconv.h: Ditto. * libc/include/iconv.h: Update copyright. * libc/*/aclocal.m4: Regenerated. * libc/*/configure: Ditto. * libm/*/aclocal.m4: Ditto. * libm/*/configure: Ditto.
2004-06-26 04:33:28 +08:00
/*
* Copyright (c) 2003-2004, Artem B. Bityuckiy
* Copyright (c) 1999,2000, Konstantin Chuguev. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "cesbi.h"
#if defined (ICONV_TO_UCS_CES_EUC) \
|| defined (ICONV_FROM_UCS_CES_EUC)
#include <_ansi.h>
#include <reent.h>
#include <newlib.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <sys/types.h>
#include "../lib/local.h"
#include "../lib/ucsconv.h"
#include "../lib/encnames.h"
#include "../ccs/ccsnames.h"
#define TYPE_EUC_JP 0
#define TYPE_EUC_KR 1
#define TYPE_EUC_TW 2
#define MAX_CS_NUM 3
/* CS description structure */
typedef struct
{
char *csname;
char *prefix;
int bytes;
int prefixbytes;
int touchmsb; /* If 1, msb will be set by euc converter */
} euc_cs_desc_t;
typedef struct
{
int type;
int mb_cur_max;
euc_cs_desc_t *desc;
_VOID_PTR data[MAX_CS_NUM];
} euc_data_t;
#if defined (_ICONV_TO_ENCODING_EUC_JP) \
|| defined (_ICONV_FROM_ENCODING_EUC_JP) \
|| defined (_ICONV_ENABLE_EXTERNAL_CCS)
static euc_cs_desc_t euc_jp_cs_desc[] =
{
{ICONV_CCS_JIS_X0208_1990, "", 2, 0, 1},
{ICONV_CCS_JIS_X0201_1976, "\x8e", 1, 1, 0},
{ICONV_CCS_JIS_X0212_1990, "\x8f", 2, 1, 1},
{NULL, NULL, 0, 0}
};
#endif
#if defined (_ICONV_TO_ENCODING_EUC_TW) \
|| defined (_ICONV_FROM_ENCODING_EUC_TW) \
|| defined (_ICONV_ENABLE_EXTERNAL_CCS)
static euc_cs_desc_t euc_tw_cs_desc [] =
{
{ICONV_CCS_CNS11643_PLANE1, "", 2, 0, 1},
{ICONV_CCS_CNS11643_PLANE2, "\x8e\xa2", 2, 2, 1},
{ICONV_CCS_CNS11643_PLANE14, "\x8e\xae", 2, 2, 1},
{NULL, NULL, 0, 0}
};
#endif
#if defined (_ICONV_TO_ENCODING_EUC_KR) \
|| defined (_ICONV_FROM_ENCODING_EUC_KR) \
|| defined (_ICONV_ENABLE_EXTERNAL_CCS)
static euc_cs_desc_t euc_kr_cs_desc [] =
{
{ICONV_CCS_KSX1001, "", 2, 0, 1},
{NULL, NULL, 0, 0}
};
#endif
#if defined (ICONV_FROM_UCS_CES_EUC)
static _VOID_PTR
_DEFUN(euc_from_ucs_init, (rptr, encoding),
struct _reent *rptr _AND
_CONST char *encoding)
{
int i;
euc_data_t *data;
if ((data = (euc_data_t *)_calloc_r (rptr, 1, sizeof (euc_data_t))) == NULL)
return 0;
#if defined (_ICONV_TO_ENCODING_EUC_JP) \
|| defined (_ICONV_ENABLE_EXTERNAL_CCS)
if (strcmp (encoding, ICONV_ENCODING_EUC_JP) == 0)
{
data->type = TYPE_EUC_JP;
data->mb_cur_max = 3;
data->desc = &euc_jp_cs_desc[0];
goto ok;
}
#endif
#if defined (_ICONV_TO_ENCODING_EUC_KR) \
|| defined (_ICONV_ENABLE_EXTERNAL_CCS)
if (strcmp (encoding, ICONV_ENCODING_EUC_KR) == 0)
{
data->type = TYPE_EUC_KR;
data->mb_cur_max = 2;
data->desc = &euc_kr_cs_desc[0];
goto ok;
}
#endif
#if defined (_ICONV_TO_ENCODING_EUC_TW) \
|| defined (_ICONV_ENABLE_EXTERNAL_CCS)
if (strcmp (encoding, ICONV_ENCODING_EUC_TW) == 0)
{
data->type = TYPE_EUC_TW;
data->mb_cur_max = 4;
data->desc = &euc_tw_cs_desc[0];
goto ok;
}
#endif
goto error1;
ok:
for (i = 0; data->desc[i].csname != NULL; i++)
{
data->data[i] = _iconv_from_ucs_ces_handlers_table.init (
rptr,
data->desc[i].csname);
if (data->data == NULL)
goto error;
}
return data;
error:
_iconv_from_ucs_ces_handlers_table.close (rptr, data);
return NULL;
error1:
_free_r (rptr, (_VOID_PTR)data);
return NULL;
}
static size_t
_DEFUN(euc_from_ucs_close, (rptr, data),
struct _reent *rptr _AND
_VOID_PTR data)
{
int i;
size_t res = 0;
for (i = 0; i < MAX_CS_NUM; i++)
{
if (((euc_data_t *)data)->data[i] != NULL)
res |= _iconv_from_ucs_ces_handlers_table.close (
rptr,
((euc_data_t *)data)->data[i]);
}
_free_r(rptr, data);
return res;
}
static size_t
_DEFUN(euc_convert_from_ucs, (data, in, outbuf, outbytesleft),
_VOID_PTR data _AND
register ucs4_t in _AND
unsigned char **outbuf _AND
size_t *outbytesleft)
{
int i;
int j;
int res;
unsigned char *outbuf1;
size_t outbytesleft1;
euc_data_t *d = (euc_data_t *)data;
if (in < 0x80) /* CS0 ASCII */
return _iconv_from_ucs_ces_handlers_us_ascii.convert_from_ucs (
NULL,
in,
outbuf,
outbytesleft);
/* Try other CS */
for (i = 0; d->desc[i].csname != NULL; i++)
{
if (((int)*outbytesleft - d->desc[i].prefixbytes - d->desc[i].bytes) < 0)
{
char buf[ICONV_MB_LEN_MAX];
outbytesleft1 = ICONV_MB_LEN_MAX;
outbuf1 = &buf[0];
/* See wether this is right sequence */
res =
(int)_iconv_from_ucs_ces_handlers_table.convert_from_ucs (
d->data[i],
in,
&outbuf1,
&outbytesleft1);
if (res > 0)
return (size_t)ICONV_CES_NOSPACE;
continue;
}
outbuf1 = *outbuf + d->desc[i].prefixbytes;
outbytesleft1 = *outbytesleft - d->desc[i].prefixbytes;
res = (int)_iconv_from_ucs_ces_handlers_table.convert_from_ucs (
d->data[i],
in,
&outbuf1,
&outbytesleft1);
if (res == d->desc[i].bytes)
{
for (j = 0; j < d->desc[i].prefixbytes; j++)
(*outbuf)[j] = d->desc[i].prefix[j];
if (d->desc[i].touchmsb)
for (j = 0; j < d->desc[i].bytes; j++)
{
if ((*outbuf)[j + d->desc[i].prefixbytes] & 0x80)
return (size_t)ICONV_CES_INVALID_CHARACTER;
(*outbuf)[j + d->desc[i].prefixbytes] |= 0x80;
}
*outbuf = outbuf1;
*outbytesleft = outbytesleft1;
return (size_t)(res + d->desc[i].bytes);
}
}
return (size_t)ICONV_CES_INVALID_CHARACTER;
}
#endif /* ICONV_FROM_UCS_CES_EUC */
#if defined (ICONV_TO_UCS_CES_EUC)
static _VOID_PTR
_DEFUN(euc_to_ucs_init, (rptr, encoding),
struct _reent *rptr _AND
_CONST char *encoding)
{
int i;
euc_data_t *data;
if ((data = (euc_data_t *)_calloc_r (rptr, 1, sizeof (euc_data_t))) == NULL)
return 0;
#if defined (_ICONV_TO_ENCODING_EUC_JP) \
|| defined (_ICONV_ENABLE_EXTERNAL_CCS)
if (strcmp (encoding, ICONV_ENCODING_EUC_JP) == 0)
{
data->type = TYPE_EUC_JP;
data->mb_cur_max = 3;
data->desc = &euc_jp_cs_desc[0];
goto ok;
}
#endif
#if defined (_ICONV_TO_ENCODING_EUC_KR) \
|| defined (_ICONV_ENABLE_EXTERNAL_CCS)
if (strcmp (encoding, ICONV_ENCODING_EUC_KR) == 0)
{
data->type = TYPE_EUC_KR;
data->mb_cur_max = 2;
data->desc = &euc_kr_cs_desc[0];
goto ok;
}
#endif
#if defined (_ICONV_TO_ENCODING_EUC_TW) \
|| defined (_ICONV_ENABLE_EXTERNAL_CCS)
if (strcmp (encoding, ICONV_ENCODING_EUC_TW) == 0)
{
data->type = TYPE_EUC_TW;
data->mb_cur_max = 4;
data->desc = &euc_tw_cs_desc[0];
goto ok;
}
#endif
goto error1;
ok:
for (i = 0; data->desc[i].csname != NULL; i++)
{
data->data[i] = _iconv_to_ucs_ces_handlers_table.init (
rptr,
data->desc[i].csname);
if (data->data == NULL)
goto error;
}
return data;
error:
_iconv_to_ucs_ces_handlers_table.close (rptr, data);
return NULL;
error1:
_free_r (rptr, (_VOID_PTR)data);
return NULL;
}
static size_t
_DEFUN(euc_to_ucs_close, (rptr, data),
struct _reent *rptr _AND
_VOID_PTR data)
{
int i;
size_t res = 0;
for (i = 0; i < MAX_CS_NUM; i++)
{
if (((euc_data_t *)data)->data[i] != NULL)
res |= _iconv_to_ucs_ces_handlers_table.close (
rptr,
((euc_data_t *)data)->data[i]);
}
_free_r(rptr, data);
return res;
}
static ucs4_t
_DEFUN(euc_convert_to_ucs, (data, inbuf, inbytesleft),
_VOID_PTR data _AND
_CONST unsigned char **inbuf _AND
size_t *inbytesleft)
{
int i;
int j;
ucs4_t res;
unsigned char buf[ICONV_MB_LEN_MAX];
size_t inbytesleft1;
euc_data_t *d = (euc_data_t *)data;
unsigned char *inbuf1 = &buf[0];
if (**inbuf < 0x80) /* CS0 is always ASCII */
return _iconv_to_ucs_ces_handlers_us_ascii.convert_to_ucs (
NULL,
inbuf,
inbytesleft);
for (i = 1; d->desc[i].csname != NULL; i++)
{
if (memcmp((_CONST _VOID_PTR)(*inbuf),
(_CONST _VOID_PTR)d->desc[i].prefix,
d->desc[i].prefixbytes) == 0)
{
if (((int)*inbytesleft - d->desc[i].prefixbytes - d->desc[i].bytes) < 0)
return (ucs4_t)ICONV_CES_BAD_SEQUENCE;
if (d->desc[i].touchmsb)
for (j = 0; j < d->desc[i].bytes; j++)
{
if (!((*inbuf)[j + d->desc[i].prefixbytes] & 0x80))
return (ucs4_t)ICONV_CES_INVALID_CHARACTER;
inbuf1[j] = (*inbuf)[j + d->desc[i].prefixbytes] & 0x7F;
}
else
for (j = 0; j < d->desc[i].bytes; j++)
inbuf1[j] = (*inbuf)[j + d->desc[i].prefixbytes];
inbytesleft1 = d->desc[i].bytes;
res = _iconv_to_ucs_ces_handlers_table.convert_to_ucs (
d->data[i],
(_CONST unsigned char **)&inbuf1,
&inbytesleft1);
if (((__int32_t)res) > 0)
{
*inbuf += d->desc[i].bytes + d->desc[i].prefixbytes;
*inbytesleft -= d->desc[i].bytes + d->desc[i].prefixbytes;
}
return res;
}
}
/* Process CS1 */
if (((int)(*inbytesleft - d->desc[0].prefixbytes - d->desc[0].bytes)) < 0)
return (ucs4_t)ICONV_CES_BAD_SEQUENCE;
if (d->desc[0].touchmsb)
for (j = 0; j < d->desc[0].bytes; j++)
{
if (!((*inbuf)[j + d->desc[0].prefixbytes] & 0x80))
return (ucs4_t)ICONV_CES_INVALID_CHARACTER;
inbuf1[j] = (*inbuf)[j] & 0x7F;
}
else
for (j = 0; j < d->desc[0].bytes; j++)
inbuf1[j] = (*inbuf)[j];
inbytesleft1 = d->desc[0].bytes;
res = _iconv_to_ucs_ces_handlers_table.convert_to_ucs (
d->data[0],
(_CONST unsigned char **)&inbuf1,
&inbytesleft1);
if (((__int32_t)res) > 0)
{
*inbuf += d->desc[0].bytes;
*inbytesleft -= d->desc[0].bytes;
}
return res;
}
#endif /* ICONV_TO_UCS_CES_EUC */
static int
_DEFUN(euc_get_mb_cur_max, (data),
_VOID_PTR data)
{
return ((euc_data_t *)data)->mb_cur_max;
}
#if defined (ICONV_FROM_UCS_CES_EUC)
_CONST iconv_from_ucs_ces_handlers_t
_iconv_from_ucs_ces_handlers_euc =
{
euc_from_ucs_init,
euc_from_ucs_close,
euc_get_mb_cur_max,
NULL,
NULL,
NULL,
euc_convert_from_ucs
};
#endif
#if defined (ICONV_TO_UCS_CES_EUC)
_CONST iconv_to_ucs_ces_handlers_t
_iconv_to_ucs_ces_handlers_euc =
{
euc_to_ucs_init,
euc_to_ucs_close,
euc_get_mb_cur_max,
NULL,
NULL,
NULL,
euc_convert_to_ucs
};
#endif
#endif /* ICONV_TO_UCS_CES_EUC || ICONV_FROM_UCS_CES_EUC */