xref: /titanic_50/usr/src/lib/libxcurses/h/collate.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1996, by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate /*
30*7c478bd9Sstevel@tonic-gate  * collate.h
31*7c478bd9Sstevel@tonic-gate  *
32*7c478bd9Sstevel@tonic-gate  *   MKS extension to ANSI/POSIX to retrieve additional locale information.
33*7c478bd9Sstevel@tonic-gate  *   Specifically collation information.
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * Copyright 1989, 1993 by Mortice Kern Systems Inc.  All rights reserved.
36*7c478bd9Sstevel@tonic-gate  *
37*7c478bd9Sstevel@tonic-gate  * $Header: /rd/h/rcs/collate.h 1.16 1993/12/02 21:54:23 mark Exp $
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate #ifndef	__COLLATE_H__
40*7c478bd9Sstevel@tonic-gate #define	__COLLATE_H__
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate #include <mks.h>
43*7c478bd9Sstevel@tonic-gate #include <limits.h>
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate /*
46*7c478bd9Sstevel@tonic-gate  * include prototypes of the MKS i18n routines
47*7c478bd9Sstevel@tonic-gate  */
48*7c478bd9Sstevel@tonic-gate #include <m_collat.h>
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate /*
51*7c478bd9Sstevel@tonic-gate  * constants and structure definitions used in MKS internal implementation
52*7c478bd9Sstevel@tonic-gate  *
53*7c478bd9Sstevel@tonic-gate  *  -- used by strxfrm(), localedef.
54*7c478bd9Sstevel@tonic-gate  */
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate /* string length limitations */
57*7c478bd9Sstevel@tonic-gate #define _M_COLLATE_MAX	32	/* max length of a collation string */
58*7c478bd9Sstevel@tonic-gate #define _M_COTOM_MAX	4	/* max length of one to many map */
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate /* forward, backward... -- or'ed into cmode */
61*7c478bd9Sstevel@tonic-gate #define _M_FORWARD_MODE	 1 	/* compare based on string forward */
62*7c478bd9Sstevel@tonic-gate #define _M_BACKWARD_MODE 2 	/* compare based on string backward */
63*7c478bd9Sstevel@tonic-gate #define _M_POSITION_MODE 4 	/* consider relative position of non-IGNOREd */
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate /* flags used in cord.cflag */
66*7c478bd9Sstevel@tonic-gate #define _M_NOCOLLSTR	0
67*7c478bd9Sstevel@tonic-gate #define _M_MANYTOONEF	1	/* Potential many-to-one mapping in forward */
68*7c478bd9Sstevel@tonic-gate #define _M_MANYTOONEB	2	/* Potential many-to-one mapping in backward */
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate /* typedef's */
71*7c478bd9Sstevel@tonic-gate typedef short	_m_weight_t;
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate /* collate database file header */
74*7c478bd9Sstevel@tonic-gate struct _m_cinfo {
75*7c478bd9Sstevel@tonic-gate 	int		cnstr;			/* number of collate strings */
76*7c478bd9Sstevel@tonic-gate 	int		cnotom;			/* number of one to many maps */
77*7c478bd9Sstevel@tonic-gate 	int		cnweight;		/* Number of weights in cmode */
78*7c478bd9Sstevel@tonic-gate 	unsigned char	cmode[COLL_WEIGHTS_MAX];/* order mode: forward... */
79*7c478bd9Sstevel@tonic-gate 	struct _m_cstr	*cstr;			/* Pointer to collating strs */
80*7c478bd9Sstevel@tonic-gate 	struct _m_cord	*cord;			/* weight tables */
81*7c478bd9Sstevel@tonic-gate 	struct _m_cotom	*cotom;			/* one-to-many mapping tables */
82*7c478bd9Sstevel@tonic-gate 	m_collel_t	*cindex,		/* index to range table map */
83*7c478bd9Sstevel@tonic-gate 			*range;			/* Range table */
84*7c478bd9Sstevel@tonic-gate 	m_collel_t	*equivo,		/* equiv class offsets */
85*7c478bd9Sstevel@tonic-gate 			*cequiv;		/* equiv class table */
86*7c478bd9Sstevel@tonic-gate };
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate /* Per character and per collating-sequence structure */
89*7c478bd9Sstevel@tonic-gate struct _m_cord {				/* order */
90*7c478bd9Sstevel@tonic-gate 	unsigned char	cflag;	/* =1, beginning of a collation string */
91*7c478bd9Sstevel@tonic-gate 	_m_weight_t	cweight[COLL_WEIGHTS_MAX]; /* relative weight */
92*7c478bd9Sstevel@tonic-gate };
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate /*l
95*7c478bd9Sstevel@tonic-gate  * The _m_cstr structure is per many-to-one mapping (collating element from...)
96*7c478bd9Sstevel@tonic-gate  * Pointed at by _m_cinfo.cstr, indexed by (m_collel_t - M_CSETSIZE).
97*7c478bd9Sstevel@tonic-gate  * Stored both forwards and backwards to make it easy for strxfrm parsing
98*7c478bd9Sstevel@tonic-gate  * for order_start backward.
99*7c478bd9Sstevel@tonic-gate  */
100*7c478bd9Sstevel@tonic-gate struct _m_cstr {				/* collating-element */
101*7c478bd9Sstevel@tonic-gate 	char		csf[_M_COLLATE_MAX];	/* collating string forward */
102*7c478bd9Sstevel@tonic-gate 	char		csb[_M_COLLATE_MAX];	/* collating string backward */
103*7c478bd9Sstevel@tonic-gate };
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate /*l
106*7c478bd9Sstevel@tonic-gate  * Per one-to-many mapping entry.  A cweight entry in the _cord structure
107*7c478bd9Sstevel@tonic-gate  * which is negative, will index into this table.
108*7c478bd9Sstevel@tonic-gate  * Pointed at by _m_cinfo.cotom.
109*7c478bd9Sstevel@tonic-gate  */
110*7c478bd9Sstevel@tonic-gate struct _m_cotom {				/* one to many map */
111*7c478bd9Sstevel@tonic-gate 	_m_weight_t	weight[_M_COTOM_MAX];
112*7c478bd9Sstevel@tonic-gate };
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate #ifdef I18N
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate extern struct _m_cinfo	_m_cinfo;
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate #endif	/* I18N */
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate #endif	/* __COLLATE_H_ */
121