kiconv_cck_common.h revision 15d9d0b528387242011cdcc6190c9e598cfe3a07
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_KICONV_CCK_COMMON_H
#define _SYS_KICONV_CCK_COMMON_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/* The start value of leading byte of EUC encoding. */
#define KICONV_EUC_START (0xA1)
/* Valid EUC range or not. */
/* Is ASCII character or not: 0x00 - 0x7F. */
/* UTF-8 replacement character for non-identicals and its length. */
#define KICONV_UTF8_REPLACEMENT_CHAR1 (0xEF)
#define KICONV_UTF8_REPLACEMENT_CHAR2 (0xBF)
#define KICONV_UTF8_REPLACEMENT_CHAR3 (0xBD)
#define KICONV_UTF8_REPLACEMENT_CHAR (0xefbfbd)
#define KICONV_UTF8_REPLACEMENT_CHAR_LEN (3)
/*
* Whether the 2nd byte of 3 or 4 bytes UTF-8 character is invalid or not.
*/
/*
* If we haven't checked on the UTF-8 signature BOM character in
* the beginning of the conversion data stream, we check it and if
* find one, we skip it since we have no use for it.
*/
(ib) += 3; \
} \
/*
* Check BOM of UTF-8 without state information.
*/
(ib) += 3; \
}
/*
* Set errno and break.
*/
#define KICONV_SET_ERRNO_AND_BREAK(err) \
break
/*
* Handling flag, advance input buffer, set errno and break.
*/
if (flag & KICONV_REPLACE_INVALID) { \
goto REPLACE_INVALID; \
} \
/* Conversion table for UTF-8 -> CCK encoding. */
typedef struct {
/* Conversion table for CCK encoding -> utf8. */
typedef struct {
/*
*/
/* Common open and close function for UTF-8 to CCK conversion. */
void * kiconv_open_to_cck(void);
int kiconv_close_to_cck(void *);
/* Binary search funciton. */
/*
*/
/*
* The following tables are coming from u8_textprep.c. We use them to
* check on validity of UTF-8 characters and their bytes.
*/
extern const int8_t u8_number_of_bytes[];
extern const uint8_t u8_valid_min_2nd_byte[];
extern const uint8_t u8_valid_max_2nd_byte[];
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_KICONV_CCK_COMMON_H */