16485Sache/*-
26485Sache * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
36485Sache *		at Electronni Visti IA, Kiev, Ukraine.
46485Sache *			All rights reserved.
56485Sache *
6227753Stheraven * Copyright (c) 2011 The FreeBSD Foundation
7227753Stheraven * All rights reserved.
8227753Stheraven * Portions of this software were developed by David Chisnall
9227753Stheraven * under sponsorship from the FreeBSD Foundation.
10227753Stheraven *
116485Sache * Redistribution and use in source and binary forms, with or without
126485Sache * modification, are permitted provided that the following conditions
136485Sache * are met:
146485Sache * 1. Redistributions of source code must retain the above copyright
156485Sache *    notice, this list of conditions and the following disclaimer.
166485Sache * 2. Redistributions in binary form must reproduce the above copyright
176485Sache *    notice, this list of conditions and the following disclaimer in the
186485Sache *    documentation and/or other materials provided with the distribution.
196485Sache *
206485Sache * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
216485Sache * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
226485Sache * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
236485Sache * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
246485Sache * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
256485Sache * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
266485Sache * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
276485Sache * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
286485Sache * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
296485Sache * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
306485Sache * SUCH DAMAGE.
316485Sache *
3250476Speter * $FreeBSD$
336485Sache */
346485Sache
3588309Sphantom#ifndef _COLLATE_H_
3688309Sphantom#define	_COLLATE_H_
376485Sache
386485Sache#include <sys/cdefs.h>
396485Sache#include <sys/types.h>
406485Sache#include <limits.h>
41227753Stheraven#include "xlocale_private.h"
426485Sache
436485Sache#define STR_LEN 10
446485Sache#define TABLE_SIZE 100
45102638Sache#define COLLATE_VERSION    "1.0\n"
46142686Sru#define COLLATE_VERSION1_2 "1.2\n"
476485Sache
486485Sachestruct __collate_st_char_pri {
496485Sache	int prim, sec;
506485Sache};
516485Sachestruct __collate_st_chain_pri {
526485Sache	u_char str[STR_LEN];
536485Sache	int prim, sec;
546485Sache};
556485Sache
56101820Sache#define __collate_substitute_table (*__collate_substitute_table_ptr)
57101820Sache#define __collate_char_pri_table (*__collate_char_pri_table_ptr)
586485Sache
59227753Stheravenstruct xlocale_collate {
60227753Stheraven	struct xlocale_component header;
61227753Stheraven	int __collate_load_error;
62227753Stheraven	int __collate_substitute_nontrivial;
63227753Stheraven
64227753Stheraven	u_char (*__collate_substitute_table_ptr)[UCHAR_MAX + 1][STR_LEN];
65227753Stheraven	struct __collate_st_char_pri (*__collate_char_pri_table_ptr)[UCHAR_MAX + 1];
66227753Stheraven	struct __collate_st_chain_pri *__collate_chain_pri_table;
67227753Stheraven};
68227753Stheraven
69227753Stheraven
706485Sache__BEGIN_DECLS
7192905Sobrienu_char	*__collate_strdup(u_char *);
72227753Stheravenu_char	*__collate_substitute(struct xlocale_collate *, const u_char *);
73101498Sacheint	__collate_load_tables(const char *);
74227753Stheravenvoid	__collate_lookup(struct xlocale_collate *, const u_char *, int *, int *, int *);
75227753Stheravenint	__collate_range_cmp(struct xlocale_collate *, int, int);
766485Sache#ifdef COLLATE_DEBUG
7792905Sobrienvoid	__collate_print_tables(void);
786485Sache#endif
796485Sache__END_DECLS
806485Sache
8188309Sphantom#endif /* !_COLLATE_H_ */
82