1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20: #ifndef _LOCALEINFO_H
21: #define _LOCALEINFO_H 1
22:
23: #include <stddef.h>
24: #include <langinfo.h>
25: #include <limits.h>
26: #include <locale.h>
27: #include <time.h>
28: #include <stdint.h>
29: #include <sys/types.h>
30:
31: #include <intl/loadinfo.h>
32:
33:
34: #define LIMAGIC(category) \
35: (category == LC_COLLATE \
36: ? ((unsigned int) (0x20051014 ^ (category))) \
37: : ((unsigned int) (0x20031115 ^ (category))))
38:
39:
40: #define IGNORE_CHAR 2
41:
42:
43:
44: #define MAX_USAGE_COUNT (UINT_MAX - 1)
45: #define UNDELETABLE UINT_MAX
46:
47:
48: struct locale_data
49: {
50: const char *name;
51: const char *filedata;
52: off_t filesize;
53: enum
54: {
55: ld_malloced,
56: ld_mapped,
57: ld_archive
58: } alloc;
59:
60:
61:
62:
63: struct
64: {
65: void (*cleanup) (struct locale_data *) internal_function;
66: union
67: {
68: void *data;
69: struct lc_time_data *time;
70: const struct gconv_fcts *ctype;
71: };
72: } private;
73:
74: unsigned int usage_count;
75:
76: int use_translit;
77:
78:
79: unsigned int nstrings;
80: union locale_data_value
81: {
82: const uint32_t *wstr;
83: const char *string;
84: unsigned int word;
85: }
86: values __flexarr;
87: };
88:
89:
90: enum coll_sort_rule
91: {
92: illegal_0__,
93: sort_forward,
94: sort_backward,
95: illegal_3__,
96: sort_position,
97: sort_forward_position,
98: sort_backward_position,
99: sort_mask
100: };
101:
102:
103: enum value_type
104: {
105: none,
106: string,
107: stringarray,
108: byte,
109: bytearray,
110: word,
111: stringlist,
112: wordarray,
113: wstring,
114: wstringarray,
115: wstringlist
116: };
117:
118:
119:
120: #define ERA_NAME_FORMAT_MEMBERS 4
121: #define ERA_M_NAME 0
122: #define ERA_M_FORMAT 1
123: #define ERA_W_NAME 2
124: #define ERA_W_FORMAT 3
125:
126:
127:
128: struct era_entry
129: {
130: uint32_t direction;
131: int32_t offset;
132: int32_t start_date[3];
133: int32_t stop_date[3];
134: const char *era_name;
135: const char *era_format;
136: const wchar_t *era_wname;
137: const wchar_t *era_wformat;
138: int absolute_direction;
139:
140:
141:
142: };
143:
144:
145:
146: struct lc_time_data
147: {
148: struct era_entry *eras;
149: size_t num_eras;
150: int era_initialized;
151:
152: const char **alt_digits;
153: const wchar_t **walt_digits;
154: int alt_digits_initialized;
155: int walt_digits_initialized;
156: };
157:
158:
159:
160:
161: enum
162: {
163: __TOW_toupper = 0,
164: __TOW_tolower = 1
165: };
166:
167:
168:
169:
170:
171:
172: #define _ISCTYPE(c, desc) \
173: (((((const uint32_t *) (desc)) - 8)[(c) >> 5] >> ((c) & 0x1f)) & 1)
174:
175:
176: #define CATNAMEMF(line) CATNAMEMF1 (line)
177: #define CATNAMEMF1(line) str##line
178: extern const union catnamestr_t
179: {
180: struct
181: {
182: #define DEFINE_CATEGORY(category, category_name, items, a) \
183: char CATNAMEMF (__LINE__)[sizeof (category_name)];
184: #include "categories.def"
185: #undef DEFINE_CATEGORY
186: };
187: char str[0];
188: } _nl_category_names attribute_hidden;
189: extern const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden;
190: extern const uint8_t _nl_category_name_sizes[__LC_LAST] attribute_hidden;
191:
192:
193: extern const char _nl_C_name[] attribute_hidden;
194: extern const char _nl_POSIX_name[] attribute_hidden;
195:
196:
197: extern const char _nl_C_codeset[] attribute_hidden;
198:
199:
200:
201:
202: extern struct __locale_struct _nl_global_locale attribute_hidden;
203:
204:
205:
206: #define _NL_CURRENT_LOCALE ((__locale_t) __libc_tsd_get (LOCALE))
207: #include <bits/libc-tsd.h>
208: __libc_tsd_define (extern, LOCALE)
209:
210:
211:
212:
213:
214:
215:
216: #if !defined SHARED && defined HAVE___THREAD && defined HAVE_WEAK_SYMBOLS
217: # include <tls.h>
218: # define NL_CURRENT_INDIRECT 1
219: #endif
220:
221: #ifdef NL_CURRENT_INDIRECT
222:
223:
224:
225:
226:
227:
228:
229:
230:
231: #define DEFINE_CATEGORY(category, category_name, items, a) \
232: extern __thread struct locale_data *const *_nl_current_##category \
233: attribute_hidden attribute_tls_model_ie;
234: #include "categories.def"
235: #undef DEFINE_CATEGORY
236:
237:
238: #define _NL_CURRENT_DATA(category) (*_nl_current_##category)
239:
240:
241: #define _NL_CURRENT(category, item) \
242: ((*_nl_current_##category)->values[_NL_ITEM_INDEX (item)].string)
243:
244:
245: #define _NL_CURRENT_WSTR(category, item) \
246: ((wchar_t *) (*_nl_current_##category)->values[_NL_ITEM_INDEX (item)].wstr)
247:
248:
249: #define _NL_CURRENT_WORD(category, item) \
250: ((uint32_t) (*_nl_current_##category)->values[_NL_ITEM_INDEX (item)].word)
251:
252:
253: #define _NL_CURRENT_DEFINE(category) \
254: __thread struct locale_data *const *_nl_current_##category \
255: attribute_hidden = &_nl_global_locale.__locales[category]; \
256: asm (_NL_CURRENT_DEFINE_STRINGIFY (ASM_GLOBAL_DIRECTIVE) \
257: " " __SYMBOL_PREFIX "_nl_current_" #category "_used\n" \
258: _NL_CURRENT_DEFINE_ABS (_nl_current_##category##_used, 1));
259: #define _NL_CURRENT_DEFINE_STRINGIFY(x) _NL_CURRENT_DEFINE_STRINGIFY_1 (x)
260: #define _NL_CURRENT_DEFINE_STRINGIFY_1(x) #x
261: #ifdef HAVE_ASM_SET_DIRECTIVE
262: # define _NL_CURRENT_DEFINE_ABS(sym, val) ".set " #sym ", " #val
263: #else
264: # define _NL_CURRENT_DEFINE_ABS(sym, val) #sym " = " #val
265: #endif
266:
267: #else
268:
269:
270:
271:
272:
273: # define _NL_CURRENT_DATA(category) \
274: (_NL_CURRENT_LOCALE->__locales[category])
275:
276:
277: # define _NL_CURRENT(category, item) \
278: (_NL_CURRENT_DATA (category)->values[_NL_ITEM_INDEX (item)].string)
279:
280:
281: # define _NL_CURRENT_WSTR(category, item) \
282: ((wchar_t *) _NL_CURRENT_DATA (category)->values[_NL_ITEM_INDEX (item)].wstr)
283:
284:
285: # define _NL_CURRENT_WORD(category, item) \
286: ((uint32_t) _NL_CURRENT_DATA (category)->values[_NL_ITEM_INDEX (item)].word)
287:
288:
289: # define _NL_CURRENT_DEFINE(category) \
290:
291:
292: #endif
293:
294:
295:
296: extern const char _nl_default_locale_path[] attribute_hidden;
297:
298:
299:
300:
301:
302:
303:
304: extern struct locale_data *_nl_find_locale (const char *locale_path,
305: size_t locale_path_len,
306: int category, const char **name)
307: internal_function attribute_hidden;
308:
309:
310: extern void _nl_load_locale (struct loaded_l10nfile *file, int category)
311: internal_function attribute_hidden;
312:
313:
314: extern void _nl_unload_locale (struct locale_data *locale)
315: internal_function attribute_hidden;
316:
317:
318: extern void _nl_remove_locale (int locale, struct locale_data *data)
319: internal_function attribute_hidden;
320:
321:
322:
323:
324:
325:
326: extern struct locale_data *_nl_load_locale_from_archive (int category,
327: const char **namep)
328: internal_function attribute_hidden;
329:
330:
331: extern void _nl_archive_subfreeres (void) attribute_hidden;
332:
333:
334: extern void _nl_locale_subfreeres (void) attribute_hidden;
335:
336:
337:
338:
339:
340:
341: extern struct locale_data *_nl_intern_locale_data (int category,
342: const void *data,
343: size_t datasize)
344: internal_function attribute_hidden;
345:
346:
347:
348: extern struct era_entry *_nl_get_era_entry (const struct tm *tp,
349: struct locale_data *lc_time)
350: internal_function attribute_hidden;
351:
352:
353: extern struct era_entry *_nl_select_era_entry (int cnt,
354: struct locale_data *lc_time)
355: internal_function attribute_hidden;
356:
357:
358: extern const char *_nl_get_alt_digit (unsigned int number,
359: struct locale_data *lc_time)
360: internal_function attribute_hidden;
361:
362:
363: extern const wchar_t *_nl_get_walt_digit (unsigned int number,
364: struct locale_data *lc_time)
365: internal_function attribute_hidden;
366:
367:
368: extern int _nl_parse_alt_digit (const char **strp,
369: struct locale_data *lc_time)
370: internal_function attribute_hidden;
371:
372:
373: extern void _nl_postload_ctype (void);
374:
375:
376: extern void _nl_cleanup_time (struct locale_data *)
377: internal_function attribute_hidden;
378:
379:
380: #endif