1 /* $NetBSD: runetype_local.h,v 1.4 2009/11/09 14:20:49 tnozaki Exp $ */
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Paul Borman at Krystal Technologies.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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
34 * @(#)runetype.h 8.1 (Berkeley) 6/2/93
37 #ifndef _RUNETYPE_LOCAL_H_
38 #define _RUNETYPE_LOCAL_H_
40 #include <sys/cdefs.h>
41 #include <sys/types.h>
43 /* for cross host tools on older systems */
45 /* assumes sizeof(unsigned int)>=4 */
46 #define UINT32_C(c) ((uint32_t)(c##U))
49 typedef uint32_t __nbrune_t
;
50 typedef uint64_t __runepad_t
;
52 #define _NB_CACHED_RUNES (1 << 8) /* Must be a power of 2 */
53 #define _NB_RUNE_ISCACHED(c) ((c)>=0 && (c)<_CACHED_RUNES)
55 #define _NB_DEFAULT_INVALID_RUNE ((__nbrune_t)-3)
58 * The lower 8 bits of runetype[] contain the digit value of the rune.
60 typedef uint32_t _RuneType
;
61 #define _RUNETYPE_A UINT32_C(0x00000100) /* Alpha */
62 #define _RUNETYPE_C UINT32_C(0x00000200) /* Control */
63 #define _RUNETYPE_D UINT32_C(0x00000400) /* Digit */
64 #define _RUNETYPE_G UINT32_C(0x00000800) /* Graph */
65 #define _RUNETYPE_L UINT32_C(0x00001000) /* Lower */
66 #define _RUNETYPE_P UINT32_C(0x00002000) /* Punct */
67 #define _RUNETYPE_S UINT32_C(0x00004000) /* Space */
68 #define _RUNETYPE_U UINT32_C(0x00008000) /* Upper */
69 #define _RUNETYPE_X UINT32_C(0x00010000) /* X digit */
70 #define _RUNETYPE_B UINT32_C(0x00020000) /* Blank */
71 #define _RUNETYPE_R UINT32_C(0x00040000) /* Print */
72 #define _RUNETYPE_I UINT32_C(0x00080000) /* Ideogram */
73 #define _RUNETYPE_T UINT32_C(0x00100000) /* Special */
74 #define _RUNETYPE_Q UINT32_C(0x00200000) /* Phonogram */
75 #define _RUNETYPE_SWM UINT32_C(0xc0000000)/* Mask to get screen width data */
76 #define _RUNETYPE_SWS 30 /* Bits to shift to get width */
77 #define _RUNETYPE_SW0 UINT32_C(0x20000000) /* 0 width character */
78 #define _RUNETYPE_SW1 UINT32_C(0x40000000) /* 1 width character */
79 #define _RUNETYPE_SW2 UINT32_C(0x80000000) /* 2 width character */
80 #define _RUNETYPE_SW3 UINT32_C(0xc0000000) /* 3 width character */
84 * rune file format. network endian.
87 int32_t fre_min
; /* First rune of the range */
88 int32_t fre_max
; /* Last rune (inclusive) of the range */
89 int32_t fre_map
; /* What first maps to in maps */
90 uint32_t fre_pad1
; /* backward compatibility */
91 __runepad_t fre_pad2
; /* backward compatibility */
92 } __packed _FileRuneEntry
;
96 uint32_t frr_nranges
; /* Number of ranges stored */
97 uint32_t frr_pad1
; /* backward compatibility */
98 __runepad_t frr_pad2
; /* backward compatibility */
99 } __packed _FileRuneRange
;
103 char frl_magic
[8]; /* Magic saying what version we are */
104 char frl_encoding
[32];/* ASCII name of this encoding */
106 __runepad_t frl_pad1
; /* backward compatibility */
107 __runepad_t frl_pad2
; /* backward compatibility */
108 int32_t frl_invalid_rune
;
109 uint32_t frl_pad3
; /* backward compatibility */
111 _RuneType frl_runetype
[_NB_CACHED_RUNES
];
112 int32_t frl_maplower
[_NB_CACHED_RUNES
];
113 int32_t frl_mapupper
[_NB_CACHED_RUNES
];
116 * The following are to deal with Runes larger than _CACHED_RUNES - 1.
117 * Their data is actually contiguous with this structure so as to make
118 * it easier to read/write from/to disk.
120 _FileRuneRange frl_runetype_ext
;
121 _FileRuneRange frl_maplower_ext
;
122 _FileRuneRange frl_mapupper_ext
;
124 __runepad_t frl_pad4
; /* backward compatibility */
125 int32_t frl_variable_len
;/* how long that data is */
126 uint32_t frl_pad5
; /* backward compatibility */
128 /* variable size data follows */
129 } __packed _FileRuneLocale
;
133 * expanded rune locale declaration. local to the host. host endian.
136 __nbrune_t re_min
; /* First rune of the range */
137 __nbrune_t re_max
; /* Last rune (inclusive) of the range */
138 __nbrune_t re_map
; /* What first maps to in maps */
139 _RuneType
*re_rune_types
; /* Array of types in range */
144 uint32_t rr_nranges
; /* Number of ranges stored */
145 _NBRuneEntry
*rr_rune_ranges
;
152 typedef struct _WCTransEntry
{
154 __nbrune_t
*te_cached
;
155 _NBRuneRange
*te_extmap
;
157 #define _WCTRANS_INDEX_LOWER 0
158 #define _WCTRANS_INDEX_UPPER 1
159 #define _WCTRANS_NINDEXES 2
164 typedef struct _WCTypeEntry
{
168 #define _WCTYPE_INDEX_ALNUM 0
169 #define _WCTYPE_INDEX_ALPHA 1
170 #define _WCTYPE_INDEX_BLANK 2
171 #define _WCTYPE_INDEX_CNTRL 3
172 #define _WCTYPE_INDEX_DIGIT 4
173 #define _WCTYPE_INDEX_GRAPH 5
174 #define _WCTYPE_INDEX_LOWER 6
175 #define _WCTYPE_INDEX_PRINT 7
176 #define _WCTYPE_INDEX_PUNCT 8
177 #define _WCTYPE_INDEX_SPACE 9
178 #define _WCTYPE_INDEX_UPPER 10
179 #define _WCTYPE_INDEX_XDIGIT 11
180 #define _WCTYPE_NINDEXES 12
186 typedef struct _NBRuneLocale
{
188 * copied from _FileRuneLocale
190 char rl_magic
[8]; /* Magic saying what version we are */
191 char rl_encoding
[32];/* ASCII name of this encoding */
192 __nbrune_t rl_invalid_rune
;
193 _RuneType rl_runetype
[_NB_CACHED_RUNES
];
194 __nbrune_t rl_maplower
[_NB_CACHED_RUNES
];
195 __nbrune_t rl_mapupper
[_NB_CACHED_RUNES
];
196 _NBRuneRange rl_runetype_ext
;
197 _NBRuneRange rl_maplower_ext
;
198 _NBRuneRange rl_mapupper_ext
;
201 size_t rl_variable_len
;
204 * the following portion is generated on the fly
206 const char *rl_codeset
;
207 struct _citrus_ctype_rec
*rl_citrus_ctype
;
208 _WCTransEntry rl_wctrans
[_WCTRANS_NINDEXES
];
209 _WCTypeEntry rl_wctype
[_WCTYPE_NINDEXES
];
211 const unsigned char *rl_ctype_tab
;
212 const short *rl_tolower_tab
;
213 const short *rl_toupper_tab
;
217 /* magic number for LC_CTYPE (rune)locale declaration */
218 #define _NB_RUNE_MAGIC_1 "RuneCT10" /* Indicates version 0 of RuneLocale */
220 /* magic string for dynamic link module - type should be like "LC_CTYPE" */
221 #define _NB_RUNE_MODULE_1(type) "RuneModule10." type
224 #define _NB_RUNE_CODESET "CODESET="
226 #endif /* !_RUNETYPE_LOCAL_H_ */