]>
Commit | Line | Data |
---|---|---|
4a4d50f3 | 1 | /* Header describing internals of libintl library. |
6d7e8eda | 2 | Copyright (C) 1995-2023 Free Software Foundation, Inc. |
6570e194 | 3 | Written by Ulrich Drepper <drepper@cygnus.com>, 1995. |
c84142e8 | 4 | |
6d248857 WN |
5 | This program is free software: you can redistribute it and/or modify |
6 | it under the terms of the GNU Lesser General Public License as published by | |
7 | the Free Software Foundation; either version 2.1 of the License, or | |
8 | (at your option) any later version. | |
c84142e8 | 9 | |
6d248857 | 10 | This program is distributed in the hope that it will be useful, |
c84142e8 | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
6d248857 WN |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU Lesser General Public License for more details. | |
c84142e8 | 14 | |
6d248857 | 15 | You should have received a copy of the GNU Lesser General Public License |
5a82c748 | 16 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
24906b43 RM |
17 | |
18 | #ifndef _GETTEXTP_H | |
19 | #define _GETTEXTP_H | |
20 | ||
4a4d50f3 UD |
21 | #include <stddef.h> /* Get size_t. */ |
22 | ||
c90a2db6 UD |
23 | #ifdef _LIBC |
24 | # include "../iconv/gconv_int.h" | |
25 | #else | |
26 | # if HAVE_ICONV | |
27 | # include <iconv.h> | |
28 | # endif | |
6570e194 UD |
29 | #endif |
30 | ||
6d248857 WN |
31 | /* Handle multi-threaded applications. */ |
32 | #ifdef _LIBC | |
ec999b8e | 33 | # include <libc-lock.h> |
6d248857 WN |
34 | # define gl_rwlock_define __libc_rwlock_define |
35 | #else | |
36 | # include "lock.h" | |
37 | #endif | |
38 | ||
39 | #ifdef _LIBC | |
40 | struct loaded_domain; | |
41 | extern char *__gettext (const char *__msgid); | |
42 | extern char *__dgettext (const char *__domainname, const char *__msgid); | |
43 | extern char *__dcgettext (const char *__domainname, const char *__msgid, | |
44 | int __category); | |
45 | extern char *__ngettext (const char *__msgid1, const char *__msgid2, | |
46 | unsigned long int __n); | |
47 | extern char *__dngettext (const char *__domainname, | |
48 | const char *__msgid1, const char *__msgid2, | |
49 | unsigned long int n); | |
50 | extern char *__dcngettext (const char *__domainname, | |
51 | const char *__msgid1, const char *__msgid2, | |
2ff16592 L |
52 | unsigned long int __n, int __category) |
53 | attribute_hidden; | |
6d248857 WN |
54 | extern char *__dcigettext (const char *__domainname, |
55 | const char *__msgid1, const char *__msgid2, | |
56 | int __plural, unsigned long int __n, | |
2ff16592 | 57 | int __category) attribute_hidden; |
6d248857 WN |
58 | extern char *__textdomain (const char *__domainname); |
59 | extern char *__bindtextdomain (const char *__domainname, | |
60 | const char *__dirname); | |
61 | extern char *__bind_textdomain_codeset (const char *__domainname, | |
62 | const char *__codeset); | |
63 | extern void _nl_finddomain_subfreeres (void) attribute_hidden; | |
64 | extern void _nl_unload_domain (struct loaded_domain *__domain) | |
d7ccc6c9 | 65 | attribute_hidden; |
6d248857 WN |
66 | #else |
67 | /* Declare the exported libintl_* functions, in a way that allows us to | |
68 | call them under their real name. */ | |
69 | # undef _INTL_REDIRECT_INLINE | |
70 | # undef _INTL_REDIRECT_MACROS | |
71 | # define _INTL_REDIRECT_MACROS | |
72 | # include "libgnuintl.h" | |
73 | # ifdef IN_LIBGLOCALE | |
74 | extern char *gl_dcigettext (const char *__domainname, | |
75 | const char *__msgid1, const char *__msgid2, | |
76 | int __plural, unsigned long int __n, | |
77 | int __category, | |
78 | const char *__localename, const char *__encoding); | |
79 | # else | |
80 | extern char *libintl_dcigettext (const char *__domainname, | |
81 | const char *__msgid1, const char *__msgid2, | |
82 | int __plural, unsigned long int __n, | |
83 | int __category); | |
84 | # endif | |
85 | #endif | |
86 | ||
7a12c6bb RM |
87 | #include "loadinfo.h" |
88 | ||
0f131646 | 89 | #include "gmo.h" /* Get nls_uint32. */ |
4a4d50f3 | 90 | |
24906b43 RM |
91 | /* @@ end of prolog @@ */ |
92 | ||
0f131646 RM |
93 | #ifndef attribute_hidden |
94 | # define attribute_hidden | |
95 | #endif | |
96 | ||
6d248857 WN |
97 | /* Tell the compiler when a conditional or integer expression is |
98 | almost always true or almost always false. */ | |
99 | #ifndef HAVE_BUILTIN_EXPECT | |
100 | # define __builtin_expect(expr, val) (expr) | |
101 | #endif | |
102 | ||
24906b43 RM |
103 | #ifndef W |
104 | # define W(flag, data) ((flag) ? SWAP (data) : (data)) | |
105 | #endif | |
106 | ||
be10a868 | 107 | |
c3d6c951 UD |
108 | #ifdef _LIBC |
109 | # include <byteswap.h> | |
110 | # define SWAP(i) bswap_32 (i) | |
111 | #else | |
24906b43 | 112 | static inline nls_uint32 |
6d248857 WN |
113 | # ifdef __cplusplus |
114 | SWAP (nls_uint32 i) | |
115 | # else | |
24906b43 RM |
116 | SWAP (i) |
117 | nls_uint32 i; | |
6d248857 | 118 | # endif |
24906b43 RM |
119 | { |
120 | return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24); | |
121 | } | |
c3d6c951 | 122 | #endif |
24906b43 RM |
123 | |
124 | ||
3172f58f UD |
125 | /* In-memory representation of system dependent string. */ |
126 | struct sysdep_string_desc | |
127 | { | |
128 | /* Length of addressed string, including the trailing NUL. */ | |
129 | size_t length; | |
130 | /* Pointer to addressed string. */ | |
131 | const char *pointer; | |
132 | }; | |
133 | ||
4e82c610 UD |
134 | /* Cache of translated strings after charset conversion. |
135 | Note: The strings are converted to the target encoding only on an as-needed | |
136 | basis. */ | |
137 | struct converted_domain | |
138 | { | |
139 | /* The target encoding name. */ | |
140 | const char *encoding; | |
141 | /* The descriptor for conversion from the message catalog's encoding to | |
142 | this target encoding. */ | |
143 | #ifdef _LIBC | |
144 | __gconv_t conv; | |
145 | #else | |
146 | # if HAVE_ICONV | |
147 | iconv_t conv; | |
148 | # endif | |
149 | #endif | |
150 | /* The table of translated strings after charset conversion. */ | |
151 | char **conv_tab; | |
152 | }; | |
153 | ||
4a4d50f3 | 154 | /* The representation of an opened message catalog. */ |
24906b43 RM |
155 | struct loaded_domain |
156 | { | |
3172f58f | 157 | /* Pointer to memory containing the .mo file. */ |
24906b43 | 158 | const char *data; |
3172f58f | 159 | /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */ |
a5a0310d | 160 | int use_mmap; |
3172f58f | 161 | /* Size of mmap()ed memory. */ |
a5a0310d | 162 | size_t mmap_size; |
3172f58f | 163 | /* 1 if the .mo file uses a different endianness than this machine. */ |
24906b43 | 164 | int must_swap; |
3172f58f UD |
165 | /* Pointer to additional malloc()ed memory. */ |
166 | void *malloced; | |
167 | ||
168 | /* Number of static strings pairs. */ | |
24906b43 | 169 | nls_uint32 nstrings; |
3172f58f UD |
170 | /* Pointer to descriptors of original strings in the file. */ |
171 | const struct string_desc *orig_tab; | |
172 | /* Pointer to descriptors of translated strings in the file. */ | |
173 | const struct string_desc *trans_tab; | |
174 | ||
175 | /* Number of system dependent strings pairs. */ | |
176 | nls_uint32 n_sysdep_strings; | |
177 | /* Pointer to descriptors of original sysdep strings. */ | |
178 | const struct sysdep_string_desc *orig_sysdep_tab; | |
179 | /* Pointer to descriptors of translated sysdep strings. */ | |
180 | const struct sysdep_string_desc *trans_sysdep_tab; | |
181 | ||
182 | /* Size of hash table. */ | |
24906b43 | 183 | nls_uint32 hash_size; |
3172f58f UD |
184 | /* Pointer to hash table. */ |
185 | const nls_uint32 *hash_tab; | |
186 | /* 1 if the hash table uses a different endianness than this machine. */ | |
187 | int must_swap_hash_tab; | |
188 | ||
4e82c610 UD |
189 | /* Cache of charset conversions of the translated strings. */ |
190 | struct converted_domain *conversions; | |
191 | size_t nconversions; | |
6d248857 | 192 | gl_rwlock_define (, conversions_lock) |
abbffdf9 | 193 | |
701666b7 | 194 | const struct expression *plural; |
abbffdf9 | 195 | unsigned long int nplurals; |
24906b43 RM |
196 | }; |
197 | ||
4a4d50f3 UD |
198 | /* We want to allocate a string at the end of the struct. But ISO C |
199 | doesn't allow zero sized arrays. */ | |
200 | #ifdef __GNUC__ | |
201 | # define ZERO 0 | |
202 | #else | |
203 | # define ZERO 1 | |
204 | #endif | |
205 | ||
206 | /* A set of settings bound to a message domain. Used to store settings | |
207 | from bindtextdomain() and bind_textdomain_codeset(). */ | |
24906b43 RM |
208 | struct binding |
209 | { | |
210 | struct binding *next; | |
24906b43 | 211 | char *dirname; |
17c389fc | 212 | char *codeset; |
4a4d50f3 | 213 | char domainname[ZERO]; |
24906b43 RM |
214 | }; |
215 | ||
4a4d50f3 UD |
216 | /* A counter which is incremented each time some previous translations |
217 | become invalid. | |
218 | This variable is part of the external ABI of the GNU libintl. */ | |
6d248857 WN |
219 | #ifdef IN_LIBGLOCALE |
220 | # include <glocale/config.h> | |
221 | extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr; | |
222 | #else | |
223 | extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr; | |
224 | #endif | |
575b273b | 225 | |
0f131646 | 226 | #ifndef _LIBC |
6d248857 WN |
227 | extern const char *_nl_language_preferences_default (void); |
228 | # define gl_locale_name_canonicalize _nl_locale_name_canonicalize | |
229 | extern void _nl_locale_name_canonicalize (char *name); | |
230 | # define gl_locale_name_from_win32_LANGID _nl_locale_name_from_win32_LANGID | |
231 | /* extern const char *_nl_locale_name_from_win32_LANGID (LANGID langid); */ | |
232 | # define gl_locale_name_from_win32_LCID _nl_locale_name_from_win32_LCID | |
233 | /* extern const char *_nl_locale_name_from_win32_LCID (LCID lcid); */ | |
234 | # define gl_locale_name_thread_unsafe _nl_locale_name_thread_unsafe | |
235 | extern const char *_nl_locale_name_thread_unsafe (int category, | |
236 | const char *categoryname); | |
237 | # define gl_locale_name_thread _nl_locale_name_thread | |
238 | /* extern const char *_nl_locale_name_thread (int category, | |
239 | const char *categoryname); */ | |
240 | # define gl_locale_name_posix _nl_locale_name_posix | |
241 | extern const char *_nl_locale_name_posix (int category, | |
242 | const char *categoryname); | |
243 | # define gl_locale_name_environ _nl_locale_name_environ | |
244 | extern const char *_nl_locale_name_environ (int category, | |
245 | const char *categoryname); | |
246 | # define gl_locale_name_default _nl_locale_name_default | |
247 | extern const char *_nl_locale_name_default (void); | |
248 | # define gl_locale_name _nl_locale_name | |
249 | /* extern const char *_nl_locale_name (int category, | |
250 | const char *categoryname); */ | |
0f131646 RM |
251 | #endif |
252 | ||
6d248857 WN |
253 | struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale, |
254 | const char *__domainname, | |
8bcdb7e0 L |
255 | struct binding *__domainbinding) |
256 | attribute_hidden; | |
6d248857 | 257 | void _nl_load_domain (struct loaded_l10nfile *__domain, |
8bcdb7e0 L |
258 | struct binding *__domainbinding) |
259 | attribute_hidden; | |
c44a663d | 260 | |
6d248857 WN |
261 | #ifdef IN_LIBGLOCALE |
262 | char *_nl_find_msg (struct loaded_l10nfile *domain_file, | |
263 | struct binding *domainbinding, const char *encoding, | |
264 | const char *msgid, | |
8bcdb7e0 L |
265 | size_t *lengthp) |
266 | attribute_hidden; | |
6d248857 WN |
267 | #else |
268 | char *_nl_find_msg (struct loaded_l10nfile *domain_file, | |
269 | struct binding *domainbinding, const char *msgid, | |
8bcdb7e0 L |
270 | int convert, size_t *lengthp) |
271 | attribute_hidden; | |
6d248857 | 272 | #endif |
24906b43 | 273 | |
6d248857 WN |
274 | /* The internal variables in the standalone libintl.a must have different |
275 | names than the internal variables in GNU libc, otherwise programs | |
276 | using libintl.a cannot be linked statically. */ | |
277 | #if !defined _LIBC | |
278 | # define _nl_default_dirname libintl_nl_default_dirname | |
279 | # define _nl_domain_bindings libintl_nl_domain_bindings | |
280 | #endif | |
281 | ||
282 | /* Contains the default location of the message catalogs. */ | |
283 | extern const char _nl_default_dirname[]; | |
abbffdf9 | 284 | #ifdef _LIBC |
6d248857 WN |
285 | libc_hidden_proto (_nl_default_dirname) |
286 | #endif | |
287 | ||
288 | /* List with bindings of specific domains. */ | |
289 | extern struct binding *_nl_domain_bindings; | |
290 | ||
291 | /* The internal variables in the standalone libintl.a must have different | |
292 | names than the internal variables in GNU libc, otherwise programs | |
293 | using libintl.a cannot be linked statically. */ | |
294 | #if !defined _LIBC | |
295 | # define _nl_default_default_domain libintl_nl_default_default_domain | |
296 | # define _nl_current_default_domain libintl_nl_current_default_domain | |
abbffdf9 UD |
297 | #endif |
298 | ||
6d248857 WN |
299 | /* Name of the default text domain. */ |
300 | extern const char _nl_default_default_domain[] attribute_hidden; | |
301 | ||
302 | /* Default text domain in which entries for gettext(3) are to be found. */ | |
303 | extern const char *_nl_current_default_domain attribute_hidden; | |
304 | ||
24906b43 RM |
305 | /* @@ begin of epilog @@ */ |
306 | ||
307 | #endif /* gettextP.h */ |