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