1/*- 2 * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua> 3 * at Electronni Visti IA, Kiev, Ukraine. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * $FreeBSD: src/lib/libc/locale/collate.h,v 1.15 2005/02/27 20:31:13 ru Exp $ 28 */ 29 30#ifndef _COLLATE_H_ 31#define _COLLATE_H_ 32 33#include <sys/cdefs.h> 34#ifndef __LIBC__ 35#include <sys/types.h> 36#endif /* !__LIBC__ */ 37#include <limits.h> 38 39#define STR_LEN 10 40#define TABLE_SIZE 100 41#define COLLATE_VERSION "1.0\n" 42#define COLLATE_VERSION1_1 "1.1\n" 43#define COLLATE_VERSION1_1A "1.1A\n" 44#define COLLATE_VERSION1_2 "1.2\n" 45 46/* see discussion in string/FreeBSD/strxfrm for this value */ 47#define COLLATE_MAX_PRIORITY ((1 << 24) - 1) 48 49#define DIRECTIVE_UNDEF 0x00 50#define DIRECTIVE_FORWARD 0x01 51#define DIRECTIVE_BACKWARD 0x02 52#define DIRECTIVE_POSITION 0x04 53 54#define DIRECTIVE_DIRECTION_MASK (DIRECTIVE_FORWARD | DIRECTIVE_BACKWARD) 55 56#define COLLATE_SUBST_DUP 0x0001 57 58#define IGNORE_EQUIV_CLASS 1 59 60struct __collate_st_info { 61 __uint8_t directive[COLL_WEIGHTS_MAX]; 62 __uint8_t flags; 63#if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN 64 __uint8_t directive_count:4; 65 __uint8_t chain_max_len:4; 66#else 67 __uint8_t chain_max_len:4; 68 __uint8_t directive_count:4; 69#endif 70 __int32_t undef_pri[COLL_WEIGHTS_MAX]; 71 __int32_t subst_count[COLL_WEIGHTS_MAX]; 72 __int32_t chain_count; 73 __int32_t large_pri_count; 74}; 75 76struct __collate_st_char_pri { 77 __int32_t pri[COLL_WEIGHTS_MAX]; 78}; 79struct __collate_st_chain_pri { 80 __darwin_wchar_t str[STR_LEN]; 81 __int32_t pri[COLL_WEIGHTS_MAX]; 82}; 83struct __collate_st_large_char_pri { 84 __int32_t val; 85 struct __collate_st_char_pri pri; 86}; 87struct __collate_st_subst { 88 __int32_t val; 89 __darwin_wchar_t str[STR_LEN]; 90}; 91 92#ifndef __LIBC__ 93extern int __collate_load_error; 94extern int __collate_substitute_nontrivial; 95#define __collate_char_pri_table (*__collate_char_pri_table_ptr) 96extern struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1]; 97extern struct __collate_st_chain_pri *__collate_chain_pri_table; 98extern __int32_t *__collate_chain_equiv_table; 99extern struct __collate_st_info __collate_info; 100#endif /* !__LIBC__ */ 101 102__BEGIN_DECLS 103#ifdef __LIBC__ 104__darwin_wchar_t *__collate_mbstowcs(const char *, locale_t); 105__darwin_wchar_t *__collate_wcsdup(const __darwin_wchar_t *); 106__darwin_wchar_t *__collate_substitute(const __darwin_wchar_t *, int, locale_t); 107int __collate_load_tables(const char *, locale_t); 108void __collate_lookup_l(const __darwin_wchar_t *, int *, int *, int *, locale_t); 109void __collate_lookup_which(const __darwin_wchar_t *, int *, int *, int, locale_t); 110void __collate_xfrm(const __darwin_wchar_t *, __darwin_wchar_t **, locale_t); 111int __collate_range_cmp(__darwin_wchar_t, __darwin_wchar_t, locale_t); 112size_t __collate_collating_symbol(__darwin_wchar_t *, size_t, const char *, size_t, __darwin_mbstate_t *, locale_t); 113int __collate_equiv_class(const char *, size_t, __darwin_mbstate_t *, locale_t); 114size_t __collate_equiv_match(int, __darwin_wchar_t *, size_t, __darwin_wchar_t, const char *, size_t, __darwin_mbstate_t *, size_t *, locale_t); 115#else /* !__LIBC__ */ 116void __collate_lookup(const unsigned char *, int *, int *, int *); 117#endif /* __LIBC__ */ 118#ifdef COLLATE_DEBUG 119void __collate_print_tables(void); 120#endif 121__END_DECLS 122 123#endif /* !_COLLATE_H_ */ 124