1 /* Header describing internals of libintl library.
2 Copyright (C) 1995-1999, 2000-2007, 2009-2010 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 it
6 under the terms of the GNU Library General Public License as published
7 by the Free Software Foundation; either version 2, or (at your option)
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 GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 #include <stddef.h> /* Get size_t. */
26 # include "../iconv/gconv_int.h"
33 /* Handle multi-threaded applications. */
35 # include <bits/libc-lock.h>
36 # define gl_rwlock_define __libc_rwlock_define
42 extern char *__gettext (const char *__msgid);
43 extern char *__dgettext (const char *__domainname, const char *__msgid);
44 extern char *__dcgettext (const char *__domainname, const char *__msgid,
46 extern char *__ngettext (const char *__msgid1, const char *__msgid2,
47 unsigned long int __n);
48 extern char *__dngettext (const char *__domainname,
49 const char *__msgid1, const char *__msgid2,
51 extern char *__dcngettext (const char *__domainname,
52 const char *__msgid1, const char *__msgid2,
53 unsigned long int __n, int __category);
54 extern char *__dcigettext (const char *__domainname,
55 const char *__msgid1, const char *__msgid2,
56 int __plural, unsigned long int __n,
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)
65 internal_function attribute_hidden;
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"
74 extern char *gl_dcigettext (const char *__domainname,
75 const char *__msgid1, const char *__msgid2,
76 int __plural, unsigned long int __n,
78 const char *__localename, const char *__encoding);
80 extern char *libintl_dcigettext (const char *__domainname,
81 const char *__msgid1, const char *__msgid2,
82 int __plural, unsigned long int __n,
89 #include "gmo.h" /* Get nls_uint32. */
91 /* @@ end of prolog @@ */
93 #ifndef internal_function
94 # define internal_function
97 #ifndef attribute_hidden
98 # define attribute_hidden
101 /* Tell the compiler when a conditional or integer expression is
102 almost always true or almost always false. */
103 #ifndef HAVE_BUILTIN_EXPECT
104 # define __builtin_expect(expr, val) (expr)
108 # define W(flag, data) ((flag) ? SWAP (data) : (data))
113 # include <byteswap.h>
114 # define SWAP(i) bswap_32 (i)
116 static inline nls_uint32
124 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
129 /* In-memory representation of system dependent string. */
130 struct sysdep_string_desc
132 /* Length of addressed string, including the trailing NUL. */
134 /* Pointer to addressed string. */
138 /* Cache of translated strings after charset conversion.
139 Note: The strings are converted to the target encoding only on an as-needed
141 struct converted_domain
143 /* The target encoding name. */
144 const char *encoding;
145 /* The descriptor for conversion from the message catalog's encoding to
146 this target encoding. */
154 /* The table of translated strings after charset conversion. */
158 /* The representation of an opened message catalog. */
161 /* Pointer to memory containing the .mo file. */
163 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
165 /* Size of mmap()ed memory. */
167 /* 1 if the .mo file uses a different endianness than this machine. */
169 /* Pointer to additional malloc()ed memory. */
172 /* Number of static strings pairs. */
174 /* Pointer to descriptors of original strings in the file. */
175 const struct string_desc *orig_tab;
176 /* Pointer to descriptors of translated strings in the file. */
177 const struct string_desc *trans_tab;
179 /* Number of system dependent strings pairs. */
180 nls_uint32 n_sysdep_strings;
181 /* Pointer to descriptors of original sysdep strings. */
182 const struct sysdep_string_desc *orig_sysdep_tab;
183 /* Pointer to descriptors of translated sysdep strings. */
184 const struct sysdep_string_desc *trans_sysdep_tab;
186 /* Size of hash table. */
187 nls_uint32 hash_size;
188 /* Pointer to hash table. */
189 const nls_uint32 *hash_tab;
190 /* 1 if the hash table uses a different endianness than this machine. */
191 int must_swap_hash_tab;
193 /* Cache of charset conversions of the translated strings. */
194 struct converted_domain *conversions;
196 gl_rwlock_define (, conversions_lock)
198 const struct expression *plural;
199 unsigned long int nplurals;
202 /* We want to allocate a string at the end of the struct. But ISO C
203 doesn't allow zero sized arrays. */
210 /* A set of settings bound to a message domain. Used to store settings
211 from bindtextdomain() and bind_textdomain_codeset(). */
214 struct binding *next;
217 char domainname[ZERO];
220 /* A counter which is incremented each time some previous translations
222 This variable is part of the external ABI of the GNU libintl. */
224 # include <glocale/config.h>
225 extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr;
227 extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr;
231 extern const char *_nl_language_preferences_default (void);
232 # define gl_locale_name_canonicalize _nl_locale_name_canonicalize
233 extern void _nl_locale_name_canonicalize (char *name);
234 # define gl_locale_name_from_win32_LANGID _nl_locale_name_from_win32_LANGID
235 /* extern const char *_nl_locale_name_from_win32_LANGID (LANGID langid); */
236 # define gl_locale_name_from_win32_LCID _nl_locale_name_from_win32_LCID
237 /* extern const char *_nl_locale_name_from_win32_LCID (LCID lcid); */
238 # define gl_locale_name_thread_unsafe _nl_locale_name_thread_unsafe
239 extern const char *_nl_locale_name_thread_unsafe (int category,
240 const char *categoryname);
241 # define gl_locale_name_thread _nl_locale_name_thread
242 /* extern const char *_nl_locale_name_thread (int category,
243 const char *categoryname); */
244 # define gl_locale_name_posix _nl_locale_name_posix
245 extern const char *_nl_locale_name_posix (int category,
246 const char *categoryname);
247 # define gl_locale_name_environ _nl_locale_name_environ
248 extern const char *_nl_locale_name_environ (int category,
249 const char *categoryname);
250 # define gl_locale_name_default _nl_locale_name_default
251 extern const char *_nl_locale_name_default (void);
252 # define gl_locale_name _nl_locale_name
253 /* extern const char *_nl_locale_name (int category,
254 const char *categoryname); */
257 struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale,
258 const char *__domainname,
259 struct binding *__domainbinding)
261 void _nl_load_domain (struct loaded_l10nfile *__domain,
262 struct binding *__domainbinding)
266 char *_nl_find_msg (struct loaded_l10nfile *domain_file,
267 struct binding *domainbinding, const char *encoding,
272 char *_nl_find_msg (struct loaded_l10nfile *domain_file,
273 struct binding *domainbinding, const char *msgid,
274 int convert, size_t *lengthp)
278 /* The internal variables in the standalone libintl.a must have different
279 names than the internal variables in GNU libc, otherwise programs
280 using libintl.a cannot be linked statically. */
282 # define _nl_default_dirname libintl_nl_default_dirname
283 # define _nl_domain_bindings libintl_nl_domain_bindings
286 /* Contains the default location of the message catalogs. */
287 extern const char _nl_default_dirname[];
289 libc_hidden_proto (_nl_default_dirname)
292 /* List with bindings of specific domains. */
293 extern struct binding *_nl_domain_bindings;
295 /* The internal variables in the standalone libintl.a must have different
296 names than the internal variables in GNU libc, otherwise programs
297 using libintl.a cannot be linked statically. */
299 # define _nl_default_default_domain libintl_nl_default_default_domain
300 # define _nl_current_default_domain libintl_nl_current_default_domain
303 /* Name of the default text domain. */
304 extern const char _nl_default_default_domain[] attribute_hidden;
306 /* Default text domain in which entries for gettext(3) are to be found. */
307 extern const char *_nl_current_default_domain attribute_hidden;
309 /* @@ begin of epilog @@ */
311 #endif /* gettextP.h */