1 /* Header describing internals of libintl library.
2 Copyright (C) 1995-2017 Free Software Foundation, Inc.
3 Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
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.
10 This program 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
13 GNU Lesser General Public License for more details.
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/>. */
21 #include <stddef.h> /* Get size_t. */
24 # include "../iconv/gconv_int.h"
31 /* Handle multi-threaded applications. */
33 # include <libc-lock.h>
34 # define gl_rwlock_define __libc_rwlock_define
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
,
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
,
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
,
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
)
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"
73 extern char *gl_dcigettext (const char *__domainname
,
74 const char *__msgid1
, const char *__msgid2
,
75 int __plural
, unsigned long int __n
,
77 const char *__localename
, const char *__encoding
);
79 extern char *libintl_dcigettext (const char *__domainname
,
80 const char *__msgid1
, const char *__msgid2
,
81 int __plural
, unsigned long int __n
,
88 #include "gmo.h" /* Get nls_uint32. */
90 /* @@ end of prolog @@ */
92 #ifndef attribute_hidden
93 # define attribute_hidden
96 /* Tell the compiler when a conditional or integer expression is
97 almost always true or almost always false. */
98 #ifndef HAVE_BUILTIN_EXPECT
99 # define __builtin_expect(expr, val) (expr)
103 # define W(flag, data) ((flag) ? SWAP (data) : (data))
108 # include <byteswap.h>
109 # define SWAP(i) bswap_32 (i)
111 static inline nls_uint32
119 return (i
<< 24) | ((i
& 0xff00) << 8) | ((i
>> 8) & 0xff00) | (i
>> 24);
124 /* In-memory representation of system dependent string. */
125 struct sysdep_string_desc
127 /* Length of addressed string, including the trailing NUL. */
129 /* Pointer to addressed string. */
133 /* Cache of translated strings after charset conversion.
134 Note: The strings are converted to the target encoding only on an as-needed
136 struct converted_domain
138 /* The target encoding name. */
139 const char *encoding
;
140 /* The descriptor for conversion from the message catalog's encoding to
141 this target encoding. */
149 /* The table of translated strings after charset conversion. */
153 /* The representation of an opened message catalog. */
156 /* Pointer to memory containing the .mo file. */
158 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
160 /* Size of mmap()ed memory. */
162 /* 1 if the .mo file uses a different endianness than this machine. */
164 /* Pointer to additional malloc()ed memory. */
167 /* Number of static strings pairs. */
169 /* Pointer to descriptors of original strings in the file. */
170 const struct string_desc
*orig_tab
;
171 /* Pointer to descriptors of translated strings in the file. */
172 const struct string_desc
*trans_tab
;
174 /* Number of system dependent strings pairs. */
175 nls_uint32 n_sysdep_strings
;
176 /* Pointer to descriptors of original sysdep strings. */
177 const struct sysdep_string_desc
*orig_sysdep_tab
;
178 /* Pointer to descriptors of translated sysdep strings. */
179 const struct sysdep_string_desc
*trans_sysdep_tab
;
181 /* Size of hash table. */
182 nls_uint32 hash_size
;
183 /* Pointer to hash table. */
184 const nls_uint32
*hash_tab
;
185 /* 1 if the hash table uses a different endianness than this machine. */
186 int must_swap_hash_tab
;
188 /* Cache of charset conversions of the translated strings. */
189 struct converted_domain
*conversions
;
191 gl_rwlock_define (, conversions_lock
)
193 const struct expression
*plural
;
194 unsigned long int nplurals
;
197 /* We want to allocate a string at the end of the struct. But ISO C
198 doesn't allow zero sized arrays. */
205 /* A set of settings bound to a message domain. Used to store settings
206 from bindtextdomain() and bind_textdomain_codeset(). */
209 struct binding
*next
;
212 char domainname
[ZERO
];
215 /* A counter which is incremented each time some previous translations
217 This variable is part of the external ABI of the GNU libintl. */
219 # include <glocale/config.h>
220 extern LIBGLOCALE_DLL_EXPORTED
int _nl_msg_cat_cntr
;
222 extern LIBINTL_DLL_EXPORTED
int _nl_msg_cat_cntr
;
226 extern const char *_nl_language_preferences_default (void);
227 # define gl_locale_name_canonicalize _nl_locale_name_canonicalize
228 extern void _nl_locale_name_canonicalize (char *name
);
229 # define gl_locale_name_from_win32_LANGID _nl_locale_name_from_win32_LANGID
230 /* extern const char *_nl_locale_name_from_win32_LANGID (LANGID langid); */
231 # define gl_locale_name_from_win32_LCID _nl_locale_name_from_win32_LCID
232 /* extern const char *_nl_locale_name_from_win32_LCID (LCID lcid); */
233 # define gl_locale_name_thread_unsafe _nl_locale_name_thread_unsafe
234 extern const char *_nl_locale_name_thread_unsafe (int category
,
235 const char *categoryname
);
236 # define gl_locale_name_thread _nl_locale_name_thread
237 /* extern const char *_nl_locale_name_thread (int category,
238 const char *categoryname); */
239 # define gl_locale_name_posix _nl_locale_name_posix
240 extern const char *_nl_locale_name_posix (int category
,
241 const char *categoryname
);
242 # define gl_locale_name_environ _nl_locale_name_environ
243 extern const char *_nl_locale_name_environ (int category
,
244 const char *categoryname
);
245 # define gl_locale_name_default _nl_locale_name_default
246 extern const char *_nl_locale_name_default (void);
247 # define gl_locale_name _nl_locale_name
248 /* extern const char *_nl_locale_name (int category,
249 const char *categoryname); */
252 struct loaded_l10nfile
*_nl_find_domain (const char *__dirname
, char *__locale
,
253 const char *__domainname
,
254 struct binding
*__domainbinding
);
255 void _nl_load_domain (struct loaded_l10nfile
*__domain
,
256 struct binding
*__domainbinding
);
259 char *_nl_find_msg (struct loaded_l10nfile
*domain_file
,
260 struct binding
*domainbinding
, const char *encoding
,
264 char *_nl_find_msg (struct loaded_l10nfile
*domain_file
,
265 struct binding
*domainbinding
, const char *msgid
,
266 int convert
, size_t *lengthp
);
269 /* The internal variables in the standalone libintl.a must have different
270 names than the internal variables in GNU libc, otherwise programs
271 using libintl.a cannot be linked statically. */
273 # define _nl_default_dirname libintl_nl_default_dirname
274 # define _nl_domain_bindings libintl_nl_domain_bindings
277 /* Contains the default location of the message catalogs. */
278 extern const char _nl_default_dirname
[];
280 libc_hidden_proto (_nl_default_dirname
)
283 /* List with bindings of specific domains. */
284 extern struct binding
*_nl_domain_bindings
;
286 /* The internal variables in the standalone libintl.a must have different
287 names than the internal variables in GNU libc, otherwise programs
288 using libintl.a cannot be linked statically. */
290 # define _nl_default_default_domain libintl_nl_default_default_domain
291 # define _nl_current_default_domain libintl_nl_current_default_domain
294 /* Name of the default text domain. */
295 extern const char _nl_default_default_domain
[] attribute_hidden
;
297 /* Default text domain in which entries for gettext(3) are to be found. */
298 extern const char *_nl_current_default_domain attribute_hidden
;
300 /* @@ begin of epilog @@ */
302 #endif /* gettextP.h */