]>
Commit | Line | Data |
---|---|---|
4b10dd6c UD |
1 | /* Declarations for internal libc locale interfaces |
2 | Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. | |
5290baf0 UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Library General Public License as | |
7 | published by the Free Software Foundation; either version 2 of the | |
8 | License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Library General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Library General Public | |
16 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18 | Boston, MA 02111-1307, USA. */ | |
28f540f4 | 19 | |
933e73fa RM |
20 | #ifndef _LOCALEINFO_H |
21 | #define _LOCALEINFO_H 1 | |
28f540f4 | 22 | |
933e73fa RM |
23 | #include <stddef.h> |
24 | #include <langinfo.h> | |
c84142e8 | 25 | #include <limits.h> |
c4029823 | 26 | #include <time.h> |
4b10dd6c | 27 | #include <stdint.h> |
933e73fa | 28 | #include <sys/types.h> |
28f540f4 | 29 | |
4b10dd6c UD |
30 | /* This has to be changed whenever a new locale is defined. */ |
31 | #define __LC_LAST 13 | |
32 | ||
33 | #include <intl/loadinfo.h> /* For loaded_l10nfile definition. */ | |
7a12c6bb | 34 | |
933e73fa | 35 | /* Magic number at the beginning of a locale data file for CATEGORY. */ |
4b10dd6c | 36 | #define LIMAGIC(category) (0x980505 ^ (category)) |
19bc17a9 RM |
37 | |
38 | /* Two special weight constants for the collation data. */ | |
4b10dd6c UD |
39 | #define FORWARD_CHAR ((uint32_t) 0xfffffffd) |
40 | #define ELLIPSIS_CHAR ((uint32_t) 0xfffffffe) | |
41 | #define IGNORE_CHAR ((uint32_t) 0xffffffff) | |
28f540f4 | 42 | |
c84142e8 UD |
43 | /* We use a special value for the usage counter in `locale_data' to |
44 | signal that this data must never be removed anymore. */ | |
a5a0310d UD |
45 | #define MAX_USAGE_COUNT (UINT_MAX - 1) |
46 | #define UNDELETABLE UINT_MAX | |
c84142e8 | 47 | |
933e73fa RM |
48 | /* Structure describing locale data in core for a category. */ |
49 | struct locale_data | |
19bc17a9 | 50 | { |
7a12c6bb | 51 | const char *name; |
19bc17a9 RM |
52 | const char *filedata; /* Region mapping the file data. */ |
53 | off_t filesize; /* Size of the file (and the region). */ | |
c84142e8 UD |
54 | int mmaped; /* If nonzero the data is mmaped. */ |
55 | ||
56 | unsigned int usage_count; /* Counter for users. */ | |
933e73fa | 57 | |
19bc17a9 RM |
58 | unsigned int nstrings; /* Number of strings below. */ |
59 | union locale_data_value | |
60 | { | |
4b10dd6c | 61 | const uint32_t *wstr; |
19bc17a9 RM |
62 | const char *string; |
63 | unsigned int word; | |
64 | } | |
65 | values[0]; /* Items, usually pointers into `filedata'. */ | |
66 | }; | |
67 | ||
68 | /* We know three kinds of collation sorting rules. */ | |
69 | enum coll_sort_rule | |
70 | { | |
71 | illegal_0__, | |
72 | sort_forward, | |
73 | sort_backward, | |
74 | illegal_3__, | |
75 | sort_position, | |
76 | sort_forward_position, | |
77 | sort_backward_position, | |
78 | sort_mask | |
79 | }; | |
80 | ||
ec4b0518 | 81 | /* We can map the types of the entries into a few categories. */ |
19bc17a9 RM |
82 | enum value_type |
83 | { | |
84 | none, | |
85 | string, | |
86 | stringarray, | |
87 | byte, | |
88 | bytearray, | |
51702635 | 89 | word, |
4b10dd6c UD |
90 | stringlist, |
91 | wordarray | |
19bc17a9 | 92 | }; |
933e73fa RM |
93 | |
94 | ||
c4029823 UD |
95 | /* Structure to access `era' information from LC_TIME. */ |
96 | struct era_entry | |
97 | { | |
4b10dd6c | 98 | uint32_t direction; /* Contains '+' or '-'. */ |
c4029823 UD |
99 | int32_t offset; |
100 | int32_t start_date[3]; | |
101 | int32_t stop_date[3]; | |
102 | const char name_fmt[0]; | |
103 | }; | |
104 | ||
105 | ||
933e73fa | 106 | /* For each category declare the variable for the current locale data. */ |
4b10dd6c | 107 | #define DEFINE_CATEGORY(category, category_name, items, a) \ |
c84142e8 | 108 | extern struct locale_data *_nl_current_##category; |
933e73fa RM |
109 | #include "categories.def" |
110 | #undef DEFINE_CATEGORY | |
111 | ||
4b10dd6c UD |
112 | extern const char *const _nl_category_names[__LC_LAST]; |
113 | extern const size_t _nl_category_name_sizes[__LC_LAST]; | |
114 | extern struct locale_data * *const _nl_current[__LC_LAST]; | |
933e73fa | 115 | |
a2b08ee5 | 116 | /* Name of the standard locales. */ |
7a12c6bb | 117 | extern const char _nl_C_name[]; |
a2b08ee5 | 118 | extern const char _nl_POSIX_name[]; |
7a12c6bb | 119 | |
933e73fa RM |
120 | /* Extract the current CATEGORY locale's string for ITEM. */ |
121 | #define _NL_CURRENT(category, item) \ | |
4b10dd6c UD |
122 | (_nl_current_##category->values[_NL_ITEM_INDEX (item)].string) |
123 | ||
124 | /* Extract the current CATEGORY locale's string for ITEM. */ | |
125 | #define _NL_CURRENT_WSTR(category, item) \ | |
126 | ((wchar_t *) (_nl_current_##category->values[_NL_ITEM_INDEX (item)].wstr)) | |
19bc17a9 RM |
127 | |
128 | /* Extract the current CATEGORY locale's word for ITEM. */ | |
129 | #define _NL_CURRENT_WORD(category, item) \ | |
130 | (_nl_current_##category->values[_NL_ITEM_INDEX (item)].word) | |
933e73fa RM |
131 | |
132 | /* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY. */ | |
133 | #define _NL_CURRENT_DEFINE(category) \ | |
c84142e8 UD |
134 | extern struct locale_data _nl_C_##category; \ |
135 | struct locale_data *_nl_current_##category = &_nl_C_##category | |
933e73fa RM |
136 | |
137 | /* Load the locale data for CATEGORY from the file specified by *NAME. | |
138 | If *NAME is "", use environment variables as specified by POSIX, | |
7a12c6bb RM |
139 | and fill in *NAME with the actual name used. The directories |
140 | listed in LOCALE_PATH are searched for the locale files. */ | |
c84142e8 UD |
141 | extern struct locale_data *_nl_find_locale (const char *locale_path, |
142 | size_t locale_path_len, | |
143 | int category, const char **name); | |
933e73fa | 144 | |
7a12c6bb RM |
145 | /* Try to load the file described by FILE. */ |
146 | extern void _nl_load_locale (struct loaded_l10nfile *file, int category); | |
28f540f4 | 147 | |
a5a0310d UD |
148 | /* Free all resource. */ |
149 | extern void _nl_unload_locale (struct locale_data *locale); | |
150 | ||
c84142e8 UD |
151 | /* Free the locale and give back all memory if the usage count is one. */ |
152 | extern void _nl_remove_locale (int locale, struct locale_data *data); | |
153 | ||
19bc17a9 | 154 | |
c4029823 | 155 | /* Return `era' entry which corresponds to TP. Used in strftime. */ |
c84142e8 | 156 | extern struct era_entry *_nl_get_era_entry (const struct tm *tp); |
c4029823 UD |
157 | |
158 | /* Return `alt_digit' which corresponds to NUMBER. Used in strftime. */ | |
c84142e8 | 159 | extern const char *_nl_get_alt_digit (unsigned int number); |
c4029823 | 160 | |
4b10dd6c UD |
161 | /* Similar, but now for wide characters. */ |
162 | extern const wchar_t *_nl_get_walt_digit (unsigned int number); | |
163 | ||
c4029823 | 164 | |
19bc17a9 | 165 | /* Global variables for LC_COLLATE category data. */ |
4b10dd6c UD |
166 | extern const uint32_t *__collate_tablewc; |
167 | extern const uint32_t *__collate_extrawc; | |
168 | extern const uint32_t *__collate_element_hash; | |
ce7a5ef4 | 169 | extern const char *__collate_element_strings; |
4b10dd6c UD |
170 | extern const uint32_t *__collate_element_values; |
171 | extern const uint32_t *__collate_symbol_hash; | |
ce7a5ef4 | 172 | extern const char *__collate_symbol_strings; |
4b10dd6c | 173 | extern const uint32_t *__collate_symbol_classes; |
19bc17a9 | 174 | |
933e73fa | 175 | #endif /* localeinfo.h */ |