1 /* Header describing internals of libintl library.
2 Copyright (C) 1995-1999, 2000, 2001, 2004-2005, 2007, 2011
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, see
19 <http://www.gnu.org/licenses/>. */
24 #include <stddef.h> /* Get size_t. */
27 # include "../iconv/gconv_int.h"
36 #include "gmo.h" /* Get nls_uint32. */
38 /* @@ end of prolog @@ */
41 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
42 # define PARAMS(args) args
44 # define PARAMS(args) ()
48 #ifndef internal_function
49 # define internal_function
52 #ifndef attribute_hidden
53 # define attribute_hidden
57 # define W(flag, data) ((flag) ? SWAP (data) : (data))
62 # include <byteswap.h>
63 # define SWAP(i) bswap_32 (i)
65 static nls_uint32 SWAP
PARAMS ((nls_uint32 i
));
67 static inline nls_uint32
71 return (i
<< 24) | ((i
& 0xff00) << 8) | ((i
>> 8) & 0xff00) | (i
>> 24);
76 /* In-memory representation of system dependent string. */
77 struct sysdep_string_desc
79 /* Length of addressed string, including the trailing NUL. */
81 /* Pointer to addressed string. */
85 /* Cache of translated strings after charset conversion.
86 Note: The strings are converted to the target encoding only on an as-needed
88 struct converted_domain
90 /* The target encoding name. */
92 /* The descriptor for conversion from the message catalog's encoding to
93 this target encoding. */
101 /* The table of translated strings after charset conversion. */
105 /* The representation of an opened message catalog. */
108 /* Pointer to memory containing the .mo file. */
110 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
112 /* Size of mmap()ed memory. */
114 /* 1 if the .mo file uses a different endianness than this machine. */
116 /* Pointer to additional malloc()ed memory. */
119 /* Number of static strings pairs. */
121 /* Pointer to descriptors of original strings in the file. */
122 const struct string_desc
*orig_tab
;
123 /* Pointer to descriptors of translated strings in the file. */
124 const struct string_desc
*trans_tab
;
126 /* Number of system dependent strings pairs. */
127 nls_uint32 n_sysdep_strings
;
128 /* Pointer to descriptors of original sysdep strings. */
129 const struct sysdep_string_desc
*orig_sysdep_tab
;
130 /* Pointer to descriptors of translated sysdep strings. */
131 const struct sysdep_string_desc
*trans_sysdep_tab
;
133 /* Size of hash table. */
134 nls_uint32 hash_size
;
135 /* Pointer to hash table. */
136 const nls_uint32
*hash_tab
;
137 /* 1 if the hash table uses a different endianness than this machine. */
138 int must_swap_hash_tab
;
140 /* Cache of charset conversions of the translated strings. */
141 struct converted_domain
*conversions
;
143 __libc_rwlock_define (, conversions_lock
);
145 const struct expression
*plural
;
146 unsigned long int nplurals
;
149 /* We want to allocate a string at the end of the struct. But ISO C
150 doesn't allow zero sized arrays. */
157 /* A set of settings bound to a message domain. Used to store settings
158 from bindtextdomain() and bind_textdomain_codeset(). */
161 struct binding
*next
;
164 char domainname
[ZERO
];
167 /* A counter which is incremented each time some previous translations
169 This variable is part of the external ABI of the GNU libintl. */
170 extern int _nl_msg_cat_cntr
;
173 const char *_nl_locale_name
PARAMS ((int category
, const char *categoryname
));
176 struct loaded_l10nfile
*_nl_find_domain
PARAMS ((const char *__dirname
,
178 const char *__domainname
,
179 struct binding
*__domainbinding
))
181 void _nl_load_domain
PARAMS ((struct loaded_l10nfile
*__domain
,
182 struct binding
*__domainbinding
))
185 char *_nl_find_msg
PARAMS ((struct loaded_l10nfile
*domain_file
,
186 struct binding
*domainbinding
, const char *msgid
,
187 int convert
, size_t *lengthp
))
191 extern char *__gettext
PARAMS ((const char *__msgid
));
192 extern char *__dgettext
PARAMS ((const char *__domainname
,
193 const char *__msgid
));
194 extern char *__dcgettext
PARAMS ((const char *__domainname
,
195 const char *__msgid
, int __category
));
196 extern char *__ngettext
PARAMS ((const char *__msgid1
, const char *__msgid2
,
197 unsigned long int __n
));
198 extern char *__dngettext
PARAMS ((const char *__domainname
,
199 const char *__msgid1
, const char *__msgid2
,
200 unsigned long int n
));
201 extern char *__dcngettext
PARAMS ((const char *__domainname
,
202 const char *__msgid1
, const char *__msgid2
,
203 unsigned long int __n
, int __category
));
204 extern char *__dcigettext
PARAMS ((const char *__domainname
,
205 const char *__msgid1
, const char *__msgid2
,
206 int __plural
, unsigned long int __n
,
208 extern char *__textdomain
PARAMS ((const char *__domainname
));
209 extern char *__bindtextdomain
PARAMS ((const char *__domainname
,
210 const char *__dirname
));
211 extern char *__bind_textdomain_codeset
PARAMS ((const char *__domainname
,
212 const char *__codeset
));
213 extern void _nl_finddomain_subfreeres
PARAMS ((void)) attribute_hidden
;
214 extern void _nl_unload_domain
PARAMS ((struct loaded_domain
*__domain
))
215 internal_function attribute_hidden
;
217 extern char *libintl_gettext
PARAMS ((const char *__msgid
));
218 extern char *libintl_dgettext
PARAMS ((const char *__domainname
,
219 const char *__msgid
));
220 extern char *libintl_dcgettext
PARAMS ((const char *__domainname
,
221 const char *__msgid
, int __category
));
222 extern char *libintl_ngettext
PARAMS ((const char *__msgid1
,
223 const char *__msgid2
,
224 unsigned long int __n
));
225 extern char *libintl_dngettext
PARAMS ((const char *__domainname
,
226 const char *__msgid1
,
227 const char *__msgid2
,
228 unsigned long int __n
));
229 extern char *libintl_dcngettext
PARAMS ((const char *__domainname
,
230 const char *__msgid1
,
231 const char *__msgid2
,
232 unsigned long int __n
,
234 extern char *libintl_dcigettext
PARAMS ((const char *__domainname
,
235 const char *__msgid1
,
236 const char *__msgid2
,
237 int __plural
, unsigned long int __n
,
239 extern char *libintl_textdomain
PARAMS ((const char *__domainname
));
240 extern char *libintl_bindtextdomain
PARAMS ((const char *__domainname
,
241 const char *__dirname
));
242 extern char *libintl_bind_textdomain_codeset
PARAMS ((const char *__domainname
,
243 const char *__codeset
));
246 /* @@ begin of epilog @@ */
248 #endif /* gettextP.h */