xref: /freebsd/lib/libc/locale/collate.h (revision f4b37ed0f8b307b1f3f0f630ca725d68f1dff30d)
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$
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 
48 struct __collate_st_char_pri {
49 	int prim, sec;
50 };
51 struct __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 
59 struct 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
71 u_char	*__collate_strdup(u_char *);
72 u_char	*__collate_substitute(struct xlocale_collate *, const u_char *);
73 int	__collate_load_tables(const char *);
74 void	__collate_lookup(struct xlocale_collate *, const u_char *, int *, int *, int *);
75 int	__collate_range_cmp(struct xlocale_collate *, int, int);
76 #ifdef COLLATE_DEBUG
77 void	__collate_print_tables(void);
78 #endif
79 __END_DECLS
80 
81 #endif /* !_COLLATE_H_ */
82