kiconv_cck_common.c 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/byteorder.h>
#include <sys/u8_textprep.h>
#include <sys/kiconv_cck_common.h>
/*LINTLIBRARY*/
/*
* Common kiconv_open method for UTF-8 -> CCK conversion.
*/
void *
{
st->bom_processed = 0;
return ((void *)st);
}
/*
* Common kiconv_close method for UTF-8 -> CCK conversion.
*/
int
kiconv_close_to_cck(void *kcd)
{
return (EBADF);
return (0);
}
/*
* Common routine to convert UTF-8 sequence to CCK legal character sequence.
*/
{
size_t i; /* temp variable in for loop */
/* Check on the kiconv code conversion descriptor. */
return ((size_t)-1);
}
/* If this is a state reset request, process and return. */
return (0);
}
ret_val = 0;
/*
* If it is a 7-bit ASCII character, we don't need to
* process further and we just copy the character over.
*
* If not, we connect the chracter bytes up to four bytes,
* validate the bytes, and binary search for the corresponding
* table. If we find it from the mapping table, we put that
* into the output buffer; otherwise, we put a replacement
* character instead as a non-identical conversion.
*/
if (sz == 1) {
}
continue;
}
/*
* Issue EILSEQ error if the first byte is a
* invalid UTF-8 character leading byte.
*/
if (sz <= 0) {
}
/*
* Issue EINVAL error if input buffer has an incomplete
* character at the end of the buffer.
*/
}
/*
* We collect UTF-8 character bytes and also check if this
* is a valid UTF-8 character without any bogus bytes based
* on the latest UTF-8 binary representation.
*/
goto ILLEGAL_CHAR_PROCESS;
for (i = 2; i < sz; i++) {
goto ILLEGAL_CHAR_ERR;
}
}
/* Now we have a valid UTF-8 character. */
if (sz < 0) {
}
}
return (ret_val);
}
{
size_t i; /* temp variable in for loop */
ret_val = 0;
break;
if (sz == 1) {
}
continue;
}
if (sz <= 0) {
}
if (flag & KICONV_REPLACE_INVALID) {
goto REPLACE_INVALID;
}
}
goto ILLEGAL_CHAR_PROCESS;
for (i = 2; i < sz; i++) {
if (flag & KICONV_REPLACE_INVALID) {
goto REPLACE_INVALID;
}
goto ILLEGAL_CHAR_ERR;
}
}
/* Now we get a valid character encoded in UTF-8. */
if (sz < 0) {
}
continue;
}
ret_val++;
}
return (ret_val);
}
/*
* Search key in tbl[0] <= tbl[1] <= ... <= tbl[n-1]. Return 0 if not found.
* tbl[0] is a special element for non-identical conversion.
*/
{
low = 1;
else
return (mid);
}
return (0);
}