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