diff options
author | is <none@none> | 2007-09-14 10:25:36 -0700 |
---|---|---|
committer | is <none@none> | 2007-09-14 10:25:36 -0700 |
commit | 4703203d9b3e06246d73931f07359a7ef70f47bf (patch) | |
tree | bfdb58f3d5d45519ed69f54012fcfb8c86d033ac | |
parent | cbcdac8f95bd87f5b3243184b35ed7bd79fc1533 (diff) | |
download | illumos-gate-4703203d9b3e06246d73931f07359a7ef70f47bf.tar.gz |
6603632 PSARC/2007/458 User land UTF-8 text preparation functions
6603633 PSARC/2007/517 Uconv functions at libc
--HG--
rename : usr/src/uts/common/os/u8_textprep.c => usr/src/common/unicode/u8_textprep.c
rename : usr/src/uts/common/os/uconv.c => usr/src/common/unicode/uconv.c
-rw-r--r-- | usr/src/common/unicode/u8_textprep.c (renamed from usr/src/uts/common/os/u8_textprep.c) | 10 | ||||
-rw-r--r-- | usr/src/common/unicode/uconv.c (renamed from usr/src/uts/common/os/uconv.c) | 54 | ||||
-rw-r--r-- | usr/src/lib/libc/Makefile.targ | 4 | ||||
-rw-r--r-- | usr/src/lib/libc/amd64/Makefile | 6 | ||||
-rw-r--r-- | usr/src/lib/libc/i386/Makefile.com | 6 | ||||
-rw-r--r-- | usr/src/lib/libc/port/mapfile-vers | 9 | ||||
-rw-r--r-- | usr/src/lib/libc/sparc/Makefile | 6 | ||||
-rw-r--r-- | usr/src/lib/libc/sparcv9/Makefile | 6 | ||||
-rw-r--r-- | usr/src/pkgdefs/SUNWhea/prototype_com | 1 | ||||
-rw-r--r-- | usr/src/uts/common/Makefile.rules | 7 | ||||
-rw-r--r-- | usr/src/uts/common/sys/Makefile | 1 | ||||
-rw-r--r-- | usr/src/uts/common/sys/sunddi.h | 71 | ||||
-rw-r--r-- | usr/src/uts/common/sys/u8_textprep.h | 113 |
13 files changed, 198 insertions, 96 deletions
diff --git a/usr/src/uts/common/os/u8_textprep.c b/usr/src/common/unicode/u8_textprep.c index 7bb2312e92..37a01b83b1 100644 --- a/usr/src/uts/common/os/u8_textprep.c +++ b/usr/src/common/unicode/u8_textprep.c @@ -27,14 +27,16 @@ /* - * UTF-8 text preparation functions (PSARC/2007/149). + * UTF-8 text preparation functions (PSARC/2007/149, PSARC/2007/458). * * Man pages: u8_textprep_open(9F), u8_textprep_buf(9F), u8_textprep_close(9F), - * u8_textprep_str(9F), u8_strcmp(9F), and u8_validate(9F). + * u8_textprep_str(9F), u8_strcmp(9F), and u8_validate(9F). See also + * the section 3C man pages. * Interface stability: Committed. */ #include <sys/types.h> +#ifdef _KERNEL #include <sys/param.h> #include <sys/sysmacros.h> #include <sys/systm.h> @@ -42,6 +44,10 @@ #include <sys/kmem.h> #include <sys/ddi.h> #include <sys/sunddi.h> +#else +#include <sys/u8_textprep.h> +#include <strings.h> +#endif /* _KERNEL */ #include <sys/byteorder.h> #include <sys/errno.h> #include <sys/u8_textprep_data.h> diff --git a/usr/src/uts/common/os/uconv.c b/usr/src/common/unicode/uconv.c index 678928976d..f4e634a952 100644 --- a/usr/src/uts/common/os/uconv.c +++ b/usr/src/common/unicode/uconv.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * 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 * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -28,17 +27,24 @@ /* * Unicode encoding conversion functions among UTF-8, UTF-16, and UTF-32. - * Man page: /shared/sac/PSARC/2005/446/materials/uconv_functions.9f - * Interface stability: Consolidation Private + * (PSARC/2005/446, PSARC/2007/038, PSARC/2007/517) + * Man pages: uconv_u16tou32(9F), uconv_u16tou8(9F), uconv_u32tou16(9F), + * uconv_u32tou8(9F), uconv_u8tou16(9F), and uconv_u8tou32(9F). See also + * the section 3C man pages. + * Interface stability: Committed */ #include <sys/types.h> +#ifdef _KERNEL #include <sys/param.h> #include <sys/sysmacros.h> #include <sys/systm.h> #include <sys/debug.h> #include <sys/kmem.h> #include <sys/sunddi.h> +#else +#include <sys/u8_textprep.h> +#endif /* _KERNEL */ #include <sys/byteorder.h> #include <sys/errno.h> @@ -355,7 +361,7 @@ uconv_u16tou32(const uint16_t *u16s, size_t *utf16len, */ if (*utf16len > 0 && *utf32len > 0 && (flag & UCONV_OUT_EMIT_BOM)) u32s[u32l++] = (outendian) ? UCONV_BOM_NORMAL : - UCONV_BOM_SWAPPED_32; + UCONV_BOM_SWAPPED_32; /* * Do conversion; if encounter a surrogate pair, assemble high and @@ -378,8 +384,8 @@ uconv_u16tou32(const uint16_t *u16s, size_t *utf16len, if (! hi) return (EILSEQ); lo = (((hi - UCONV_U16_HI_MIN) * UCONV_U16_BIT_SHIFT + - lo - UCONV_U16_LO_MIN) & UCONV_U16_BIT_MASK) - + UCONV_U16_START; + lo - UCONV_U16_LO_MIN) & UCONV_U16_BIT_MASK) + + UCONV_U16_START; hi = 0; } else if (hi) { return (EILSEQ); @@ -457,8 +463,8 @@ uconv_u16tou8(const uint16_t *u16s, size_t *utf16len, if (! hi) return (EILSEQ); lo = (((hi - UCONV_U16_HI_MIN) * UCONV_U16_BIT_SHIFT + - lo - UCONV_U16_LO_MIN) & UCONV_U16_BIT_MASK) - + UCONV_U16_START; + lo - UCONV_U16_LO_MIN) & UCONV_U16_BIT_MASK) + + UCONV_U16_START; hi = 0; } else if (hi) { return (EILSEQ); @@ -538,7 +544,7 @@ uconv_u32tou16(const uint32_t *u32s, size_t *utf32len, if (*utf32len > 0 && *utf16len > 0 && (flag & UCONV_OUT_EMIT_BOM)) u16s[u16l++] = (outendian) ? UCONV_BOM_NORMAL : - UCONV_BOM_SWAPPED; + UCONV_BOM_SWAPPED; for (; u32l < *utf32len; u32l++) { if (u32s[u32l] == 0 && do_not_ignore_null) @@ -560,9 +566,9 @@ uconv_u32tou16(const uint32_t *u32s, size_t *utf32len, */ if (hi >= UCONV_U16_START) { lo = ((hi - UCONV_U16_START) % UCONV_U16_BIT_SHIFT) + - UCONV_U16_LO_MIN; + UCONV_U16_LO_MIN; hi = ((hi - UCONV_U16_START) / UCONV_U16_BIT_SHIFT) + - UCONV_U16_HI_MIN; + UCONV_U16_HI_MIN; if ((u16l + 1) >= *utf16len) return (E2BIG); @@ -578,7 +584,7 @@ uconv_u32tou16(const uint32_t *u32s, size_t *utf32len, if (u16l >= *utf16len) return (E2BIG); u16s[u16l++] = (outendian) ? (uint16_t)hi : - BSWAP_16(((uint16_t)hi)); + BSWAP_16(((uint16_t)hi)); } } @@ -686,7 +692,7 @@ uconv_u8tou16(const uchar_t *u8s, size_t *utf8len, if (*utf8len > 0 && *utf16len > 0 && (flag & UCONV_OUT_EMIT_BOM)) u16s[u16l++] = (outendian) ? UCONV_BOM_NORMAL : - UCONV_BOM_SWAPPED; + UCONV_BOM_SWAPPED; for (; u8l < *utf8len; ) { if (u8s[u8l] == 0 && do_not_ignore_null) @@ -728,19 +734,19 @@ uconv_u8tou16(const uchar_t *u8s, size_t *utf8len, return (EILSEQ); first_b = 0; } else if (lo < UCONV_U8_BYTE_MIN || - lo > UCONV_U8_BYTE_MAX) { + lo > UCONV_U8_BYTE_MAX) { return (EILSEQ); } hi = (hi << UCONV_U8_BIT_SHIFT) | - (lo & UCONV_U8_BIT_MASK); + (lo & UCONV_U8_BIT_MASK); } } if (hi >= UCONV_U16_START) { lo = ((hi - UCONV_U16_START) % UCONV_U16_BIT_SHIFT) + - UCONV_U16_LO_MIN; + UCONV_U16_LO_MIN; hi = ((hi - UCONV_U16_START) / UCONV_U16_BIT_SHIFT) + - UCONV_U16_HI_MIN; + UCONV_U16_HI_MIN; if ((u16l + 1) >= *utf16len) return (E2BIG); @@ -757,7 +763,7 @@ uconv_u8tou16(const uchar_t *u8s, size_t *utf8len, return (E2BIG); u16s[u16l++] = (outendian) ? (uint16_t)hi : - BSWAP_16(((uint16_t)hi)); + BSWAP_16(((uint16_t)hi)); } } @@ -797,7 +803,7 @@ uconv_u8tou32(const uchar_t *u8s, size_t *utf8len, if (*utf8len > 0 && *utf32len > 0 && (flag & UCONV_OUT_EMIT_BOM)) u32s[u32l++] = (outendian) ? UCONV_BOM_NORMAL : - UCONV_BOM_SWAPPED_32; + UCONV_BOM_SWAPPED_32; for (; u8l < *utf8len; ) { if (u8s[u8l] == 0 && do_not_ignore_null) @@ -824,11 +830,11 @@ uconv_u8tou32(const uchar_t *u8s, size_t *utf8len, return (EILSEQ); first_b = 0; } else if (c < UCONV_U8_BYTE_MIN || - c > UCONV_U8_BYTE_MAX) { + c > UCONV_U8_BYTE_MAX) { return (EILSEQ); } hi = (hi << UCONV_U8_BIT_SHIFT) | - (c & UCONV_U8_BIT_MASK); + (c & UCONV_U8_BIT_MASK); } } diff --git a/usr/src/lib/libc/Makefile.targ b/usr/src/lib/libc/Makefile.targ index 38d73741c3..b8237246a4 100644 --- a/usr/src/lib/libc/Makefile.targ +++ b/usr/src/lib/libc/Makefile.targ @@ -276,6 +276,10 @@ $(DTRACEOBJS:%=pics/%): $(SRC)/common/dtrace/$$(@F:.o=.c) $(COMPILE.c) -o $@ $(SRC)/common/dtrace/$(@F:.o=.c) $(POST_PROCESS_O) +$(UNICODEOBJS:%=pics/%): $(SRC)/common/unicode/$$(@F:.o=.c) + $(COMPILE.c) -o $@ $(SRC)/common/unicode/$(@F:.o=.c) + $(POST_PROCESS_O) + # DTrace rules pics/%.o: ../port/threads/%.d $(THREADSOBJS:%=pics/%) $(COMPILE.d) -C -xlazyload -s $< -o $@ $(THREADSOBJS:%=pics/%) diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile index 3f4cd4fea2..0e2d924805 100644 --- a/usr/src/lib/libc/amd64/Makefile +++ b/usr/src/lib/libc/amd64/Makefile @@ -762,6 +762,10 @@ THREADSMACHOBJS= \ THREADSASMOBJS= \ asm_subr.o +UNICODEOBJS= \ + u8_textprep.o \ + uconv.o + UNWINDMACHOBJS= \ call_frame_inst.o \ eh_frame.o \ @@ -866,6 +870,7 @@ MOSTOBJS= \ $(THREADSOBJS) \ $(THREADSMACHOBJS) \ $(THREADSASMOBJS) \ + $(UNICODEOBJS) \ $(UNWINDMACHOBJS) \ $(UNWINDASMOBJS) \ $(COMSYSOBJS) \ @@ -974,6 +979,7 @@ SRCS= \ $(TPOOLOBJS:%.o=../port/tpool/%.c) \ $(THREADSOBJS:%.o=../port/threads/%.c) \ $(THREADSMACHOBJS:%.o=threads/%.c) \ + $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \ $(UNWINDMACHOBJS:%.o=unwind/%.c) \ $(FPOBJS:%.o=fp/%.c) \ $(I386FPOBJS:%.o=../i386/fp/%.c) \ diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com index cbc0843f80..6fe1a1c5cc 100644 --- a/usr/src/lib/libc/i386/Makefile.com +++ b/usr/src/lib/libc/i386/Makefile.com @@ -804,6 +804,10 @@ THREADSMACHOBJS= \ THREADSASMOBJS= \ asm_subr.o +UNICODEOBJS= \ + u8_textprep.o \ + uconv.o + UNWINDMACHOBJS= \ unwind.o @@ -904,6 +908,7 @@ MOSTOBJS= \ $(THREADSOBJS) \ $(THREADSMACHOBJS) \ $(THREADSASMOBJS) \ + $(UNICODEOBJS) \ $(UNWINDMACHOBJS) \ $(UNWINDASMOBJS) \ $(COMSYSOBJS) \ @@ -1035,6 +1040,7 @@ SRCS= \ $(TPOOLOBJS:%.o=../port/tpool/%.c) \ $(THREADSOBJS:%.o=../port/threads/%.c) \ $(THREADSMACHOBJS:%.o=../$(MACH)/threads/%.c) \ + $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \ $(UNWINDMACHOBJS:%.o=../port/unwind/%.c) \ $(FPOBJS:%.o=../$(MACH)/fp/%.c) \ $(LIBCBASE)/gen/ecvt.c \ diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers index 5b8612a19c..161df2efb8 100644 --- a/usr/src/lib/libc/port/mapfile-vers +++ b/usr/src/lib/libc/port/mapfile-vers @@ -123,6 +123,15 @@ SUNW_1.23 { # SunOS 5.11 (Solaris 11) timer_getoverrun; timer_gettime; timer_settime; + u8_strcmp; + u8_textprep_str; + u8_validate; + uconv_u16tou32; + uconv_u16tou8; + uconv_u32tou16; + uconv_u32tou8; + uconv_u8tou16; + uconv_u8tou32; uucopy; uucopystr; vforkx; diff --git a/usr/src/lib/libc/sparc/Makefile b/usr/src/lib/libc/sparc/Makefile index ce8627d963..c67463652b 100644 --- a/usr/src/lib/libc/sparc/Makefile +++ b/usr/src/lib/libc/sparc/Makefile @@ -830,6 +830,10 @@ THREADSMACHOBJS= \ THREADSASMOBJS= \ asm_subr.o +UNICODEOBJS= \ + u8_textprep.o \ + uconv.o + UNWINDMACHOBJS= \ unwind.o @@ -932,6 +936,7 @@ MOSTOBJS= \ $(THREADSOBJS) \ $(THREADSMACHOBJS) \ $(THREADSASMOBJS) \ + $(UNICODEOBJS) \ $(UNWINDMACHOBJS) \ $(UNWINDASMOBJS) \ $(COMSYSOBJS) \ @@ -1053,6 +1058,7 @@ SRCS= \ $(TPOOLOBJS:%.o=../port/tpool/%.c) \ $(THREADSOBJS:%.o=../port/threads/%.c) \ $(THREADSMACHOBJS:%.o=../$(MACH)/threads/%.c) \ + $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \ $(UNWINDMACHOBJS:%.o=../port/unwind/%.c) \ $(FPOBJS:%.o=../$(MACH)/fp/%.c) \ $(LIBCBASE)/crt/_ftou.c \ diff --git a/usr/src/lib/libc/sparcv9/Makefile b/usr/src/lib/libc/sparcv9/Makefile index a2a6084b87..c114126bfe 100644 --- a/usr/src/lib/libc/sparcv9/Makefile +++ b/usr/src/lib/libc/sparcv9/Makefile @@ -777,6 +777,10 @@ THREADSMACHOBJS= \ THREADSASMOBJS= \ asm_subr.o +UNICODEOBJS= \ + u8_textprep.o \ + uconv.o + UNWINDMACHOBJS= \ unwind.o @@ -875,6 +879,7 @@ MOSTOBJS= \ $(THREADSOBJS) \ $(THREADSMACHOBJS) \ $(THREADSASMOBJS) \ + $(UNICODEOBJS) \ $(UNWINDMACHOBJS) \ $(UNWINDASMOBJS) \ $(COMSYSOBJS) \ @@ -986,6 +991,7 @@ SRCS= \ $(TPOOLOBJS:%.o=../port/tpool/%.c) \ $(THREADSOBJS:%.o=../port/threads/%.c) \ $(THREADSMACHOBJS:%.o=../$(MACH)/threads/%.c) \ + $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \ $(UNWINDMACHOBJS:%.o=../port/unwind/%.c) \ $(FPOBJS:%.o=../$(MACH)/fp/%.c) \ $(FPOBJS64:%.o=$(LIBCBASE)/fp/%.c) \ diff --git a/usr/src/pkgdefs/SUNWhea/prototype_com b/usr/src/pkgdefs/SUNWhea/prototype_com index 74727e566a..a726754cda 100644 --- a/usr/src/pkgdefs/SUNWhea/prototype_com +++ b/usr/src/pkgdefs/SUNWhea/prototype_com @@ -1293,6 +1293,7 @@ f none usr/include/sys/tuneable.h 644 root bin f none usr/include/sys/turnstile.h 644 root bin f none usr/include/sys/types.h 644 root bin f none usr/include/sys/types32.h 644 root bin +f none usr/include/sys/u8_textprep.h 644 root bin f none usr/include/sys/uadmin.h 644 root bin f none usr/include/sys/ucontext.h 644 root bin f none usr/include/sys/uio.h 644 root bin diff --git a/usr/src/uts/common/Makefile.rules b/usr/src/uts/common/Makefile.rules index d9e8413118..2d10397e7c 100644 --- a/usr/src/uts/common/Makefile.rules +++ b/usr/src/uts/common/Makefile.rules @@ -951,6 +951,10 @@ $(OBJS_DIR)/%.o: $(COMMONBASE)/util/%.c $(COMPILE.c) -o $@ $< $(CTFCONVERT_O) +$(OBJS_DIR)/%.o: $(COMMONBASE)/unicode/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + $(OBJS_DIR)/%.o: $(UTSBASE)/common/vm/%.c $(COMPILE.c) -o $@ $< $(CTFCONVERT_O) @@ -1673,6 +1677,9 @@ $(LINTS_DIR)/%.ln: $(COMMONBASE)/tsol/%.c $(LINTS_DIR)/%.ln: $(COMMONBASE)/util/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) +$(LINTS_DIR)/%.ln: $(COMMONBASE)/unicode/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) + $(LINTS_DIR)/%.ln: $(UTSBASE)/common/vm/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile index a2d180667b..b5bf354dcb 100644 --- a/usr/src/uts/common/sys/Makefile +++ b/usr/src/uts/common/sys/Makefile @@ -534,6 +534,7 @@ CHKHDRS= \ turnstile.h \ types.h \ types32.h \ + u8_textprep.h \ u8_textprep_data.h \ uadmin.h \ ucred.h \ diff --git a/usr/src/uts/common/sys/sunddi.h b/usr/src/uts/common/sys/sunddi.h index 126b1b5e4a..69b62b20c4 100644 --- a/usr/src/uts/common/sys/sunddi.h +++ b/usr/src/uts/common/sys/sunddi.h @@ -59,6 +59,7 @@ #ifdef _KERNEL #include <sys/ddi_obsolete.h> #endif +#include <sys/u8_textprep.h> #ifdef __cplusplus extern "C" { @@ -441,76 +442,6 @@ extern int ddi_strtol(const char *, char **, int, long *); extern int ddi_strtoul(const char *, char **, int, unsigned long *); /* - * Unicode encoding conversion functions and their macros. - */ -#define UCONV_IN_BIG_ENDIAN 0x0001 -#define UCONV_OUT_BIG_ENDIAN 0x0002 -#define UCONV_IN_SYSTEM_ENDIAN 0x0004 -#define UCONV_OUT_SYSTEM_ENDIAN 0x0008 -#define UCONV_IN_LITTLE_ENDIAN 0x0010 -#define UCONV_OUT_LITTLE_ENDIAN 0x0020 -#define UCONV_IGNORE_NULL 0x0040 -#define UCONV_IN_ACCEPT_BOM 0x0080 -#define UCONV_OUT_EMIT_BOM 0x0100 - -extern int uconv_u16tou32(const uint16_t *, size_t *, uint32_t *, size_t *, - int); -extern int uconv_u16tou8(const uint16_t *, size_t *, uchar_t *, size_t *, int); -extern int uconv_u32tou16(const uint32_t *, size_t *, uint16_t *, size_t *, - int); -extern int uconv_u32tou8(const uint32_t *, size_t *, uchar_t *, size_t *, int); -extern int uconv_u8tou16(const uchar_t *, size_t *, uint16_t *, size_t *, int); -extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int); - -/* - * UTF-8 text preparation functions and their macros. - * - * Among the macros defined, U8_CANON_DECOMP, U8_COMPAT_DECOMP, and - * U8_CANON_COMP are not public interfaces and must not be used directly - * at the flag input argument. - */ -#define U8_STRCMP_CS (0x00000001) -#define U8_STRCMP_CI_UPPER (0x00000002) -#define U8_STRCMP_CI_LOWER (0x00000004) - -#define U8_CANON_DECOMP (0x00000010) -#define U8_COMPAT_DECOMP (0x00000020) -#define U8_CANON_COMP (0x00000040) - -#define U8_STRCMP_NFD (U8_CANON_DECOMP) -#define U8_STRCMP_NFC (U8_CANON_DECOMP | U8_CANON_COMP) -#define U8_STRCMP_NFKD (U8_COMPAT_DECOMP) -#define U8_STRCMP_NFKC (U8_COMPAT_DECOMP | U8_CANON_COMP) - -#define U8_TEXTPREP_TOUPPER (U8_STRCMP_CI_UPPER) -#define U8_TEXTPREP_TOLOWER (U8_STRCMP_CI_LOWER) - -#define U8_TEXTPREP_NFD (U8_STRCMP_NFD) -#define U8_TEXTPREP_NFC (U8_STRCMP_NFC) -#define U8_TEXTPREP_NFKD (U8_STRCMP_NFKD) -#define U8_TEXTPREP_NFKC (U8_STRCMP_NFKC) - -#define U8_TEXTPREP_IGNORE_NULL (0x00010000) -#define U8_TEXTPREP_IGNORE_INVALID (0x00020000) -#define U8_TEXTPREP_NOWAIT (0x00040000) - -#define U8_UNICODE_320 (0) -#define U8_UNICODE_500 (1) -#define U8_UNICODE_LATEST (U8_UNICODE_500) - -#define U8_VALIDATE_ENTIRE (0x00100000) -#define U8_VALIDATE_CHECK_ADDITIONAL (0x00200000) -#define U8_VALIDATE_UCS2_RANGE (0x00400000) - -#define U8_ILLEGAL_CHAR (-1) -#define U8_OUT_OF_RANGE_CHAR (-2) - -extern int u8_validate(char *, size_t, char **, int, int *); -extern int u8_strcmp(const char *, const char *, size_t, int, size_t, int *); -extern size_t u8_textprep_str(char *, size_t *, char *, size_t *, int, size_t, - int *); - -/* * ddi_map_regs * * Map in the register set given by rnumber. diff --git a/usr/src/uts/common/sys/u8_textprep.h b/usr/src/uts/common/sys/u8_textprep.h new file mode 100644 index 0000000000..e30f064b2d --- /dev/null +++ b/usr/src/uts/common/sys/u8_textprep.h @@ -0,0 +1,113 @@ +/* + * 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 + * or http://www.opensolaris.org/os/licensing. + * 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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_U8_TEXTPREP_H +#define _SYS_U8_TEXTPREP_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/isa_defs.h> +#include <sys/types.h> +#include <sys/errno.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Unicode encoding conversion functions and their macros. + */ +#define UCONV_IN_BIG_ENDIAN 0x0001 +#define UCONV_OUT_BIG_ENDIAN 0x0002 +#define UCONV_IN_SYSTEM_ENDIAN 0x0004 +#define UCONV_OUT_SYSTEM_ENDIAN 0x0008 +#define UCONV_IN_LITTLE_ENDIAN 0x0010 +#define UCONV_OUT_LITTLE_ENDIAN 0x0020 +#define UCONV_IGNORE_NULL 0x0040 +#define UCONV_IN_ACCEPT_BOM 0x0080 +#define UCONV_OUT_EMIT_BOM 0x0100 + +extern int uconv_u16tou32(const uint16_t *, size_t *, uint32_t *, size_t *, + int); +extern int uconv_u16tou8(const uint16_t *, size_t *, uchar_t *, size_t *, int); +extern int uconv_u32tou16(const uint32_t *, size_t *, uint16_t *, size_t *, + int); +extern int uconv_u32tou8(const uint32_t *, size_t *, uchar_t *, size_t *, int); +extern int uconv_u8tou16(const uchar_t *, size_t *, uint16_t *, size_t *, int); +extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int); + +/* + * UTF-8 text preparation functions and their macros. + * + * Among the macros defined, U8_CANON_DECOMP, U8_COMPAT_DECOMP, and + * U8_CANON_COMP are not public interfaces and must not be used directly + * at the flag input argument. + */ +#define U8_STRCMP_CS (0x00000001) +#define U8_STRCMP_CI_UPPER (0x00000002) +#define U8_STRCMP_CI_LOWER (0x00000004) + +#define U8_CANON_DECOMP (0x00000010) +#define U8_COMPAT_DECOMP (0x00000020) +#define U8_CANON_COMP (0x00000040) + +#define U8_STRCMP_NFD (U8_CANON_DECOMP) +#define U8_STRCMP_NFC (U8_CANON_DECOMP | U8_CANON_COMP) +#define U8_STRCMP_NFKD (U8_COMPAT_DECOMP) +#define U8_STRCMP_NFKC (U8_COMPAT_DECOMP | U8_CANON_COMP) + +#define U8_TEXTPREP_TOUPPER (U8_STRCMP_CI_UPPER) +#define U8_TEXTPREP_TOLOWER (U8_STRCMP_CI_LOWER) + +#define U8_TEXTPREP_NFD (U8_STRCMP_NFD) +#define U8_TEXTPREP_NFC (U8_STRCMP_NFC) +#define U8_TEXTPREP_NFKD (U8_STRCMP_NFKD) +#define U8_TEXTPREP_NFKC (U8_STRCMP_NFKC) + +#define U8_TEXTPREP_IGNORE_NULL (0x00010000) +#define U8_TEXTPREP_IGNORE_INVALID (0x00020000) +#define U8_TEXTPREP_NOWAIT (0x00040000) + +#define U8_UNICODE_320 (0) +#define U8_UNICODE_500 (1) +#define U8_UNICODE_LATEST (U8_UNICODE_500) + +#define U8_VALIDATE_ENTIRE (0x00100000) +#define U8_VALIDATE_CHECK_ADDITIONAL (0x00200000) +#define U8_VALIDATE_UCS2_RANGE (0x00400000) + +#define U8_ILLEGAL_CHAR (-1) +#define U8_OUT_OF_RANGE_CHAR (-2) + +extern int u8_validate(char *, size_t, char **, int, int *); +extern int u8_strcmp(const char *, const char *, size_t, int, size_t, int *); +extern size_t u8_textprep_str(char *, size_t *, char *, size_t *, int, size_t, + int *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_U8_TEXTPREP_H */ |