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