1 /* Header describing internals of libintl library.
2 Copyright (C) 1995-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
23 #include <stddef.h> /* Get size_t. */
26 # include "../iconv/gconv_int.h"
35 #include "gmo.h" /* Get nls_uint32. */
37 /* @@ end of prolog @@ */
40 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
41 # define PARAMS(args) args
43 # define PARAMS(args) ()
47 #ifndef internal_function
48 # define internal_function
51 #ifndef attribute_hidden
52 # define attribute_hidden
56 # define W(flag, data) ((flag) ? SWAP (data) : (data))
61 # include <byteswap.h>
62 # define SWAP(i) bswap_32 (i)
64 static nls_uint32 SWAP
PARAMS ((nls_uint32 i
));
66 static inline nls_uint32
70 return (i
<< 24) | ((i
& 0xff00) << 8) | ((i
>> 8) & 0xff00) | (i
>> 24);
75 /* In-memory representation of system dependent string. */
76 struct sysdep_string_desc
78 /* Length of addressed string, including the trailing NUL. */
80 /* Pointer to addressed string. */
84 /* Cache of translated strings after charset conversion.
85 Note: The strings are converted to the target encoding only on an as-needed
87 struct converted_domain
89 /* The target encoding name. */
91 /* The descriptor for conversion from the message catalog's encoding to
92 this target encoding. */
100 /* The table of translated strings after charset conversion. */
104 /* The representation of an opened message catalog. */
107 /* Pointer to memory containing the .mo file. */
109 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
111 /* Size of mmap()ed memory. */
113 /* 1 if the .mo file uses a different endianness than this machine. */
115 /* Pointer to additional malloc()ed memory. */
118 /* Number of static strings pairs. */
120 /* Pointer to descriptors of original strings in the file. */
121 const struct string_desc
*orig_tab
;
122 /* Pointer to descriptors of translated strings in the file. */
123 const struct string_desc
*trans_tab
;
125 /* Number of system dependent strings pairs. */
126 nls_uint32 n_sysdep_strings
;
127 /* Pointer to descriptors of original sysdep strings. */
128 const struct sysdep_string_desc
*orig_sysdep_tab
;
129 /* Pointer to descriptors of translated sysdep strings. */
130 const struct sysdep_string_desc
*trans_sysdep_tab
;
132 /* Size of hash table. */
133 nls_uint32 hash_size
;
134 /* Pointer to hash table. */
135 const nls_uint32
*hash_tab
;
136 /* 1 if the hash table uses a different endianness than this machine. */
137 int must_swap_hash_tab
;
139 /* Cache of charset conversions of the translated strings. */
140 struct converted_domain
*conversions
;
142 __libc_rwlock_define (, conversions_lock
);
144 const struct expression
*plural
;
145 unsigned long int nplurals
;
148 /* We want to allocate a string at the end of the struct. But ISO C
149 doesn't allow zero sized arrays. */
156 /* A set of settings bound to a message domain. Used to store settings
157 from bindtextdomain() and bind_textdomain_codeset(). */
160 struct binding
*next
;
163 char domainname
[ZERO
];
166 /* A counter which is incremented each time some previous translations
168 This variable is part of the external ABI of the GNU libintl. */
169 extern int _nl_msg_cat_cntr
;
172 const char *_nl_locale_name
PARAMS ((int category
, const char *categoryname
));
175 struct loaded_l10nfile
*_nl_find_domain
PARAMS ((const char *__dirname
,
177 const char *__domainname
,
178 struct binding
*__domainbinding
))
180 void _nl_load_domain
PARAMS ((struct loaded_l10nfile
*__domain
,
181 struct binding
*__domainbinding
))
184 char *_nl_find_msg
PARAMS ((struct loaded_l10nfile
*domain_file
,
185 struct binding
*domainbinding
, const char *msgid
,
186 int convert
, size_t *lengthp
))
190 extern char *__gettext
PARAMS ((const char *__msgid
));
191 extern char *__dgettext
PARAMS ((const char *__domainname
,
192 const char *__msgid
));
193 extern char *__dcgettext
PARAMS ((const char *__domainname
,
194 const char *__msgid
, int __category
));
195 extern char *__ngettext
PARAMS ((const char *__msgid1
, const char *__msgid2
,
196 unsigned long int __n
));
197 extern char *__dngettext
PARAMS ((const char *__domainname
,
198 const char *__msgid1
, const char *__msgid2
,
199 unsigned long int n
));
200 extern char *__dcngettext
PARAMS ((const char *__domainname
,
201 const char *__msgid1
, const char *__msgid2
,
202 unsigned long int __n
, int __category
));
203 extern char *__dcigettext
PARAMS ((const char *__domainname
,
204 const char *__msgid1
, const char *__msgid2
,
205 int __plural
, unsigned long int __n
,
207 extern char *__textdomain
PARAMS ((const char *__domainname
));
208 extern char *__bindtextdomain
PARAMS ((const char *__domainname
,
209 const char *__dirname
));
210 extern char *__bind_textdomain_codeset
PARAMS ((const char *__domainname
,
211 const char *__codeset
));
212 extern void _nl_finddomain_subfreeres
PARAMS ((void)) attribute_hidden
;
213 extern void _nl_unload_domain
PARAMS ((struct loaded_domain
*__domain
))
214 internal_function attribute_hidden
;
216 extern char *libintl_gettext
PARAMS ((const char *__msgid
));
217 extern char *libintl_dgettext
PARAMS ((const char *__domainname
,
218 const char *__msgid
));
219 extern char *libintl_dcgettext
PARAMS ((const char *__domainname
,
220 const char *__msgid
, int __category
));
221 extern char *libintl_ngettext
PARAMS ((const char *__msgid1
,
222 const char *__msgid2
,
223 unsigned long int __n
));
224 extern char *libintl_dngettext
PARAMS ((const char *__domainname
,
225 const char *__msgid1
,
226 const char *__msgid2
,
227 unsigned long int __n
));
228 extern char *libintl_dcngettext
PARAMS ((const char *__domainname
,
229 const char *__msgid1
,
230 const char *__msgid2
,
231 unsigned long int __n
,
233 extern char *libintl_dcigettext
PARAMS ((const char *__domainname
,
234 const char *__msgid1
,
235 const char *__msgid2
,
236 int __plural
, unsigned long int __n
,
238 extern char *libintl_textdomain
PARAMS ((const char *__domainname
));
239 extern char *libintl_bindtextdomain
PARAMS ((const char *__domainname
,
240 const char *__dirname
));
241 extern char *libintl_bind_textdomain_codeset
PARAMS ((const char *__domainname
,
242 const char *__codeset
));
245 /* @@ begin of epilog @@ */
247 #endif /* gettextP.h */