1 /* Header describing internals of libintl library.
2 Copyright (C) 1995-1999, 2000, 2001, 2004-2005, 2007
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 #include <stddef.h> /* Get size_t. */
28 # include "../iconv/gconv_int.h"
37 #include "gmo.h" /* Get nls_uint32. */
39 /* @@ end of prolog @@ */
42 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
43 # define PARAMS(args) args
45 # define PARAMS(args) ()
49 #ifndef internal_function
50 # define internal_function
53 #ifndef attribute_hidden
54 # define attribute_hidden
57 /* Tell the compiler when a conditional or integer expression is
58 almost always true or almost always false. */
59 #ifndef HAVE_BUILTIN_EXPECT
60 # define __builtin_expect(expr, val) (expr)
64 # define W(flag, data) ((flag) ? SWAP (data) : (data))
69 # include <byteswap.h>
70 # define SWAP(i) bswap_32 (i)
72 static nls_uint32 SWAP
PARAMS ((nls_uint32 i
));
74 static inline nls_uint32
78 return (i
<< 24) | ((i
& 0xff00) << 8) | ((i
>> 8) & 0xff00) | (i
>> 24);
83 /* In-memory representation of system dependent string. */
84 struct sysdep_string_desc
86 /* Length of addressed string, including the trailing NUL. */
88 /* Pointer to addressed string. */
92 /* Cache of translated strings after charset conversion.
93 Note: The strings are converted to the target encoding only on an as-needed
95 struct converted_domain
97 /* The target encoding name. */
99 /* The descriptor for conversion from the message catalog's encoding to
100 this target encoding. */
108 /* The table of translated strings after charset conversion. */
112 /* The representation of an opened message catalog. */
115 /* Pointer to memory containing the .mo file. */
117 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
119 /* Size of mmap()ed memory. */
121 /* 1 if the .mo file uses a different endianness than this machine. */
123 /* Pointer to additional malloc()ed memory. */
126 /* Number of static strings pairs. */
128 /* Pointer to descriptors of original strings in the file. */
129 const struct string_desc
*orig_tab
;
130 /* Pointer to descriptors of translated strings in the file. */
131 const struct string_desc
*trans_tab
;
133 /* Number of system dependent strings pairs. */
134 nls_uint32 n_sysdep_strings
;
135 /* Pointer to descriptors of original sysdep strings. */
136 const struct sysdep_string_desc
*orig_sysdep_tab
;
137 /* Pointer to descriptors of translated sysdep strings. */
138 const struct sysdep_string_desc
*trans_sysdep_tab
;
140 /* Size of hash table. */
141 nls_uint32 hash_size
;
142 /* Pointer to hash table. */
143 const nls_uint32
*hash_tab
;
144 /* 1 if the hash table uses a different endianness than this machine. */
145 int must_swap_hash_tab
;
147 /* Cache of charset conversions of the translated strings. */
148 struct converted_domain
*conversions
;
150 __libc_rwlock_define (, conversions_lock
);
152 const struct expression
*plural
;
153 unsigned long int nplurals
;
156 /* We want to allocate a string at the end of the struct. But ISO C
157 doesn't allow zero sized arrays. */
164 /* A set of settings bound to a message domain. Used to store settings
165 from bindtextdomain() and bind_textdomain_codeset(). */
168 struct binding
*next
;
171 char domainname
[ZERO
];
174 /* A counter which is incremented each time some previous translations
176 This variable is part of the external ABI of the GNU libintl. */
177 extern int _nl_msg_cat_cntr
;
180 const char *_nl_locale_name
PARAMS ((int category
, const char *categoryname
));
183 struct loaded_l10nfile
*_nl_find_domain
PARAMS ((const char *__dirname
,
185 const char *__domainname
,
186 struct binding
*__domainbinding
))
188 void _nl_load_domain
PARAMS ((struct loaded_l10nfile
*__domain
,
189 struct binding
*__domainbinding
))
192 char *_nl_find_msg
PARAMS ((struct loaded_l10nfile
*domain_file
,
193 struct binding
*domainbinding
, const char *msgid
,
194 int convert
, size_t *lengthp
))
198 extern char *__gettext
PARAMS ((const char *__msgid
));
199 extern char *__dgettext
PARAMS ((const char *__domainname
,
200 const char *__msgid
));
201 extern char *__dcgettext
PARAMS ((const char *__domainname
,
202 const char *__msgid
, int __category
));
203 extern char *__ngettext
PARAMS ((const char *__msgid1
, const char *__msgid2
,
204 unsigned long int __n
));
205 extern char *__dngettext
PARAMS ((const char *__domainname
,
206 const char *__msgid1
, const char *__msgid2
,
207 unsigned long int n
));
208 extern char *__dcngettext
PARAMS ((const char *__domainname
,
209 const char *__msgid1
, const char *__msgid2
,
210 unsigned long int __n
, int __category
));
211 extern char *__dcigettext
PARAMS ((const char *__domainname
,
212 const char *__msgid1
, const char *__msgid2
,
213 int __plural
, unsigned long int __n
,
215 extern char *__textdomain
PARAMS ((const char *__domainname
));
216 extern char *__bindtextdomain
PARAMS ((const char *__domainname
,
217 const char *__dirname
));
218 extern char *__bind_textdomain_codeset
PARAMS ((const char *__domainname
,
219 const char *__codeset
));
220 extern void _nl_finddomain_subfreeres
PARAMS ((void)) attribute_hidden
;
221 extern void _nl_unload_domain
PARAMS ((struct loaded_domain
*__domain
))
222 internal_function attribute_hidden
;
224 extern char *libintl_gettext
PARAMS ((const char *__msgid
));
225 extern char *libintl_dgettext
PARAMS ((const char *__domainname
,
226 const char *__msgid
));
227 extern char *libintl_dcgettext
PARAMS ((const char *__domainname
,
228 const char *__msgid
, int __category
));
229 extern char *libintl_ngettext
PARAMS ((const char *__msgid1
,
230 const char *__msgid2
,
231 unsigned long int __n
));
232 extern char *libintl_dngettext
PARAMS ((const char *__domainname
,
233 const char *__msgid1
,
234 const char *__msgid2
,
235 unsigned long int __n
));
236 extern char *libintl_dcngettext
PARAMS ((const char *__domainname
,
237 const char *__msgid1
,
238 const char *__msgid2
,
239 unsigned long int __n
,
241 extern char *libintl_dcigettext
PARAMS ((const char *__domainname
,
242 const char *__msgid1
,
243 const char *__msgid2
,
244 int __plural
, unsigned long int __n
,
246 extern char *libintl_textdomain
PARAMS ((const char *__domainname
));
247 extern char *libintl_bindtextdomain
PARAMS ((const char *__domainname
,
248 const char *__dirname
));
249 extern char *libintl_bind_textdomain_codeset
PARAMS ((const char *__domainname
,
250 const char *__codeset
));
253 /* @@ begin of epilog @@ */
255 #endif /* gettextP.h */