15d9d0b528387242011cdcc6190c9e598cfe3a07yy * CDDL HEADER START
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * The contents of this file are subject to the terms of the
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Common Development and Distribution License (the "License").
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * You may not use this file except in compliance with the License.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * See the License for the specific language governing permissions
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * and limitations under the License.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * When distributing Covered Code, include this CDDL HEADER in each
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * If applicable, add the following below this CDDL HEADER, with the
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * fields enclosed by brackets "[]" replaced with your own identifying
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * information: Portions Copyright [yyyy] [name of copyright owner]
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * CDDL HEADER END
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Use is subject to license terms.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy#pragma ident "%Z%%M% %I% %E% SMI"
15d9d0b528387242011cdcc6190c9e598cfe3a07yystatic int8_t utf8_to_euckr(uint32_t utf8, uchar_t **inbuf, uchar_t *ibtail,
15d9d0b528387242011cdcc6190c9e598cfe3a07yystatic int8_t utf8_to_uhc(uint32_t utf8, uchar_t **inbuf, uchar_t *ibtail,
15d9d0b528387242011cdcc6190c9e598cfe3a07yystatic int8_t ko_to_utf8(uint32_t ko_val, uchar_t *ob, uchar_t *obtail,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy size_t *ret_val, kiconv_table_array_t *table, size_t nitems);
15d9d0b528387242011cdcc6190c9e598cfe3a07yystatic void *
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return ((void *)KICONV_KO_EUCKR);
15d9d0b528387242011cdcc6190c9e598cfe3a07yystatic void *
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return ((void *)KICONV_KO_UHC);
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return (0);
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Encoding convertor from EUC-KR to UTF-8.
15d9d0b528387242011cdcc6190c9e598cfe3a07yykiconv_fr_euckr(void *kcd, char **inbuf, size_t *inbufleft,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy /* Check on the kiconv code conversion descriptor. */
15d9d0b528387242011cdcc6190c9e598cfe3a07yy /* If this is a state reset request, process and return. */
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return (0);
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Issue EILSEQ error if the first byte is not a
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * valid EUC-KR leading byte.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Issue EINVAL error if input buffer has an incomplete
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * character at the end of the buffer.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Issue EILSEQ error if the remaining byte is not
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * a valid EUC-KR byte.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy if (sz < 0) {
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * String based encoding convertor from EUC-KR to UTF-8.
15d9d0b528387242011cdcc6190c9e598cfe3a07yykiconvstr_fr_euckr(char *inarray, size_t *inlen, char *outarray,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy if (sz < 0) {
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Encoding convertor from Unified Hangul Code to UTF-8.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy /* Check on the kiconv code conversion descriptor. */
15d9d0b528387242011cdcc6190c9e598cfe3a07yy /* If this is a state reset request, process and return. */
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return (0);
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Issue EILSEQ error if the first byte is not a
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * valid UHC leading byte.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Issue EINVAL error if input buffer has an incomplete
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * character at the end of the buffer.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Issue EILSEQ error if the remaining byte is not
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * a valid UHC byte.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy if (sz < 0) {
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * String based encoding convertor from Unified Hangul Code to UTF-8.
15d9d0b528387242011cdcc6190c9e598cfe3a07yykiconvstr_fr_uhc(char *inarray, size_t *inlen, char *outarray,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy if (sz < 0) {
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Encoding convertor from UTF-8 to EUC-KR.
15d9d0b528387242011cdcc6190c9e598cfe3a07yykiconv_to_euckr(void *kcd, char **inbuf, size_t *inbytesleft,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return (kiconv_utf8_to_cck(kcd, inbuf, inbytesleft, outbuf,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Encoding convertor from UTF-8 to Unified Hangul Code.
15d9d0b528387242011cdcc6190c9e598cfe3a07yykiconv_to_uhc(void *kcd, char **inbuf, size_t *inbytesleft,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return (kiconv_utf8_to_cck(kcd, inbuf, inbytesleft, outbuf,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * String based encoding convertor from UTF-8 to EUC-KR.
15d9d0b528387242011cdcc6190c9e598cfe3a07yykiconvstr_to_euckr(char *inarray, size_t *inlen, char *outarray,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy (uchar_t *)outarray, outlen, flag, errno, utf8_to_euckr);
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * String based encoding convertor from UTF-8 to Unified Hangul Code.
15d9d0b528387242011cdcc6190c9e598cfe3a07yykiconvstr_to_uhc(char *inarray, size_t *inlen, char *outarray,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Convert an UTF-8 character to a character of ko encodings
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * (EUC-KR or UHC).
15d9d0b528387242011cdcc6190c9e598cfe3a07yyutf8_to_ko(uint32_t utf8, uchar_t *ob, uchar_t *obtail, size_t *ret_val,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy /* User Definable Area handing. */
15d9d0b528387242011cdcc6190c9e598cfe3a07yy kocode = (((utf8 & 0xF0000) >> 4) | ((utf8 & 0x3F00) >> 2) |
15d9d0b528387242011cdcc6190c9e598cfe3a07yy /* 0x43 = 0xA1 - 0x5E */
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return (-1);
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Convert an UTF-8 character to Unified Hangual Code.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy/* ARGSUSED */
15d9d0b528387242011cdcc6190c9e598cfe3a07yyutf8_to_uhc(uint32_t utf8, uchar_t **inbuf, uchar_t *ibtail,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return (utf8_to_ko(utf8, ob, obtail, ret_val, kiconv_utf8_uhc,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Convert an UTF-8 character to EUC-KR.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy/* ARGSUSED */
15d9d0b528387242011cdcc6190c9e598cfe3a07yyutf8_to_euckr(uint32_t utf8, uchar_t **inbuf, uchar_t *ibtail,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return (utf8_to_ko(utf8, ob, obtail, ret_val, kiconv_utf8_euckr,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Convert a single ko encoding (EUC-KR or UHC) character to UTF-8.
15d9d0b528387242011cdcc6190c9e598cfe3a07yyko_to_utf8(uint32_t ko_val, uchar_t *ob, uchar_t *obtail, size_t *ret_val,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy /* UDA(User Definable Area) handling. */
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return (-1);
15d9d0b528387242011cdcc6190c9e598cfe3a07yy return (sz);
15d9d0b528387242011cdcc6190c9e598cfe3a07yy "unifiedhangul", "utf-8", kiconv_open_to_cck, kiconv_to_uhc,
15d9d0b528387242011cdcc6190c9e598cfe3a07yy sizeof (kiconv_ko_ops_tbl) / sizeof (kiconv_ko_ops_tbl[0]),
15d9d0b528387242011cdcc6190c9e598cfe3a07yy "kiconv korean module 1.0",
15d9d0b528387242011cdcc6190c9e598cfe3a07yy cmn_err(CE_WARN, "kiconv_ko: failed to load kernel module");
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * If this module is being used, then, we cannot remove the module.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * The following checking will catch pretty much all usual cases.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Any remaining will be catached by the kiconv_unregister_module()
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * during mod_remove() at below.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy cmn_err(CE_WARN, "kiconv_ko: failed to remove kernel module");