]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/Locale/runetype.h
StdLib: Add multi-byte character support. The normal "narrow" character set is now...
[mirror_edk2.git] / StdLib / LibC / Locale / runetype.h
1 /* $NetBSD: runetype.h,v 1.19 2005/11/29 03:11:59 christos Exp $ */
2
3 /*-
4 * Copyright (c) 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Paul Borman at Krystal Technologies.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)runetype.h 8.1 (Berkeley) 6/2/93
35 */
36 #ifndef _NB_RUNETYPE_H_
37 #define _NB_RUNETYPE_H_
38
39 #include <sys/EfiCdefs.h>
40 #include <sys/types.h>
41
42 /* for cross host tools on older systems */
43 #ifndef UINT32_C
44 /* assumes sizeof(unsigned int)>=4 */
45 #define UINT32_C(c) ((uint32_t)(c##U))
46 #endif
47
48 typedef uint32_t __nbrune_t;
49 typedef uint64_t __runepad_t;
50
51 #define _NB_CACHED_RUNES (1 << 8) /* Must be a power of 2 */
52 #define _NB_RUNE_ISCACHED(c) ((c)>=0 && (c)<_CACHED_RUNES)
53
54 #define _NB_DEFAULT_INVALID_RUNE ((__nbrune_t)-3)
55
56 /*
57 * The lower 8 bits of runetype[] contain the digit value of the rune.
58 */
59 typedef uint32_t _RuneType;
60 #define _RUNETYPE_A UINT32_C(0x00000100) /* Alpha */
61 #define _RUNETYPE_C UINT32_C(0x00000200) /* Control */
62 #define _RUNETYPE_D UINT32_C(0x00000400) /* Digit */
63 #define _RUNETYPE_G UINT32_C(0x00000800) /* Graph */
64 #define _RUNETYPE_L UINT32_C(0x00001000) /* Lower */
65 #define _RUNETYPE_P UINT32_C(0x00002000) /* Punct */
66 #define _RUNETYPE_S UINT32_C(0x00004000) /* Space */
67 #define _RUNETYPE_U UINT32_C(0x00008000) /* Upper */
68 #define _RUNETYPE_X UINT32_C(0x00010000) /* X digit */
69 #define _RUNETYPE_B UINT32_C(0x00020000) /* Blank */
70 #define _RUNETYPE_R UINT32_C(0x00040000) /* Print */
71 #define _RUNETYPE_I UINT32_C(0x00080000) /* Ideogram */
72 #define _RUNETYPE_T UINT32_C(0x00100000) /* Special */
73 #define _RUNETYPE_Q UINT32_C(0x00200000) /* Phonogram */
74 #define _RUNETYPE_SWM UINT32_C(0xc0000000)/* Mask to get screen width data */
75 #define _RUNETYPE_SWS 30 /* Bits to shift to get width */
76 #define _RUNETYPE_SW0 UINT32_C(0x00000000) /* 0 width character */
77 #define _RUNETYPE_SW1 UINT32_C(0x40000000) /* 1 width character */
78 #define _RUNETYPE_SW2 UINT32_C(0x80000000) /* 2 width character */
79 #define _RUNETYPE_SW3 UINT32_C(0xc0000000) /* 3 width character */
80
81
82 /*
83 * rune file format. network endian.
84 */
85 typedef struct {
86 int32_t fre_min; /* First rune of the range */
87 int32_t fre_max; /* Last rune (inclusive) of the range */
88 int32_t fre_map; /* What first maps to in maps */
89 uint32_t fre_pad1; /* backward compatibility */
90 __runepad_t fre_pad2; /* backward compatibility */
91 } __attribute__((__packed__)) _FileRuneEntry;
92
93
94 typedef struct {
95 uint32_t frr_nranges; /* Number of ranges stored */
96 uint32_t frr_pad1; /* backward compatibility */
97 __runepad_t frr_pad2; /* backward compatibility */
98 } __attribute__((__packed__)) _FileRuneRange;
99
100
101 typedef struct {
102 char frl_magic[8]; /* Magic saying what version we are */
103 char frl_encoding[32];/* ASCII name of this encoding */
104
105 __runepad_t frl_pad1; /* backward compatibility */
106 __runepad_t frl_pad2; /* backward compatibility */
107 int32_t frl_invalid_rune;
108 uint32_t frl_pad3; /* backward compatibility */
109
110 _RuneType frl_runetype[_NB_CACHED_RUNES];
111 int32_t frl_maplower[_NB_CACHED_RUNES];
112 int32_t frl_mapupper[_NB_CACHED_RUNES];
113
114 /*
115 * The following are to deal with Runes larger than _CACHED_RUNES - 1.
116 * Their data is actually contiguous with this structure so as to make
117 * it easier to read/write from/to disk.
118 */
119 _FileRuneRange frl_runetype_ext;
120 _FileRuneRange frl_maplower_ext;
121 _FileRuneRange frl_mapupper_ext;
122
123 __runepad_t frl_pad4; /* backward compatibility */
124 int32_t frl_variable_len;/* how long that data is */
125 uint32_t frl_pad5; /* backward compatibility */
126
127 /* variable size data follows */
128 } __attribute__((__packed__)) _FileRuneLocale;
129
130
131 /*
132 * expanded rune locale declaration. local to the host. host endian.
133 */
134 typedef struct {
135 __nbrune_t re_min; /* First rune of the range */
136 __nbrune_t re_max; /* Last rune (inclusive) of the range */
137 __nbrune_t re_map; /* What first maps to in maps */
138 _RuneType *re_rune_types; /* Array of types in range */
139 } _NBRuneEntry;
140
141
142 typedef struct {
143 uint32_t rr_nranges; /* Number of ranges stored */
144 _NBRuneEntry *rr_rune_ranges;
145 } _NBRuneRange;
146
147
148 /*
149 * wctrans stuffs.
150 */
151 typedef struct _WCTransEntry {
152 const char *te_name;
153 __nbrune_t *te_cached;
154 _NBRuneRange *te_extmap;
155 } _WCTransEntry;
156 #define _WCTRANS_INDEX_LOWER 0
157 #define _WCTRANS_INDEX_UPPER 1
158 #define _WCTRANS_NINDEXES 2
159
160 /*
161 * wctype stuffs.
162 */
163 typedef struct _WCTypeEntry {
164 const char *te_name;
165 _RuneType te_mask;
166 } _WCTypeEntry;
167 #define _WCTYPE_INDEX_ALNUM 0
168 #define _WCTYPE_INDEX_ALPHA 1
169 #define _WCTYPE_INDEX_BLANK 2
170 #define _WCTYPE_INDEX_CNTRL 3
171 #define _WCTYPE_INDEX_DIGIT 4
172 #define _WCTYPE_INDEX_GRAPH 5
173 #define _WCTYPE_INDEX_LOWER 6
174 #define _WCTYPE_INDEX_PRINT 7
175 #define _WCTYPE_INDEX_PUNCT 8
176 #define _WCTYPE_INDEX_SPACE 9
177 #define _WCTYPE_INDEX_UPPER 10
178 #define _WCTYPE_INDEX_XDIGIT 11
179 #define _WCTYPE_NINDEXES 12
180
181 /*
182 * ctype stuffs
183 */
184
185 typedef struct _NBRuneLocale {
186 /*
187 * copied from _FileRuneLocale
188 */
189 char rl_magic[8]; /* Magic saying what version we are */
190 char rl_encoding[32];/* ASCII name of this encoding */
191 __nbrune_t rl_invalid_rune;
192 _RuneType rl_runetype[_NB_CACHED_RUNES];
193 __nbrune_t rl_maplower[_NB_CACHED_RUNES];
194 __nbrune_t rl_mapupper[_NB_CACHED_RUNES];
195 _NBRuneRange rl_runetype_ext;
196 _NBRuneRange rl_maplower_ext;
197 _NBRuneRange rl_mapupper_ext;
198
199 void *rl_variable;
200 size_t rl_variable_len;
201
202 /*
203 * the following portion is generated on the fly
204 */
205 const char *rl_codeset;
206 struct _citrus_ctype_rec *rl_citrus_ctype;
207 _WCTransEntry rl_wctrans[_WCTRANS_NINDEXES];
208 _WCTypeEntry rl_wctype[_WCTYPE_NINDEXES];
209 } _NBRuneLocale;
210
211
212 /* magic number for LC_CTYPE (rune)locale declaration */
213 #define _NB_RUNE_MAGIC_1 "RuneCT10" /* Indicates version 0 of RuneLocale */
214
215 /* magic string for dynamic link module - type should be like "LC_CTYPE" */
216 #define _NB_RUNE_MODULE_1(type) "RuneModule10." type
217
218 /* codeset tag */
219 #define _NB_RUNE_CODESET "CODESET="
220
221 #endif /* !_NB_RUNETYPE_H_ */