collate.h revision 303185
1/*-
2 * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
3 *		at Electronni Visti IA, Kiev, Ukraine.
4 *			All rights reserved.
5 *
6 * Copyright (c) 2011 The FreeBSD Foundation
7 * All rights reserved.
8 * Portions of this software were developed by David Chisnall
9 * under sponsorship from the FreeBSD Foundation.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $FreeBSD: stable/10/lib/libc/locale/collate.h 303185 2016-07-22 14:24:17Z ache $
33 */
34
35#ifndef _COLLATE_H_
36#define	_COLLATE_H_
37
38#include <sys/cdefs.h>
39#include <sys/types.h>
40#include <limits.h>
41#include "xlocale_private.h"
42
43#define STR_LEN 10
44#define TABLE_SIZE 100
45#define COLLATE_VERSION    "1.0\n"
46#define COLLATE_VERSION1_2 "1.2\n"
47
48struct __collate_st_char_pri {
49	int prim, sec;
50};
51struct __collate_st_chain_pri {
52	u_char str[STR_LEN];
53	int prim, sec;
54};
55
56#define __collate_substitute_table (*__collate_substitute_table_ptr)
57#define __collate_char_pri_table (*__collate_char_pri_table_ptr)
58
59struct xlocale_collate {
60	struct xlocale_component header;
61	int __collate_load_error;
62	int __collate_substitute_nontrivial;
63
64	u_char (*__collate_substitute_table_ptr)[UCHAR_MAX + 1][STR_LEN];
65	struct __collate_st_char_pri (*__collate_char_pri_table_ptr)[UCHAR_MAX + 1];
66	struct __collate_st_chain_pri *__collate_chain_pri_table;
67};
68
69
70__BEGIN_DECLS
71u_char	*__collate_strdup(u_char *);
72u_char	*__collate_substitute(struct xlocale_collate *, const u_char *);
73int	__collate_load_tables(const char *);
74void	__collate_lookup(struct xlocale_collate *, const u_char *, int *, int *, int *);
75int	__collate_range_cmp(char, char);
76int	__wcollate_range_cmp(wchar_t, wchar_t);
77#ifdef COLLATE_DEBUG
78void	__collate_print_tables(void);
79#endif
80__END_DECLS
81
82#endif /* !_COLLATE_H_ */
83