Define __ASSUME_AT_RANDOM.
[glibc/history.git] / intl / gettextP.h
blobf1aa329e4715b8e7887d702df6891461e9c322dc
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
20 02111-1307 USA. */
22 #ifndef _GETTEXTP_H
23 #define _GETTEXTP_H
25 #include <stddef.h> /* Get size_t. */
27 #ifdef _LIBC
28 # include "../iconv/gconv_int.h"
29 #else
30 # if HAVE_ICONV
31 # include <iconv.h>
32 # endif
33 #endif
35 #include "loadinfo.h"
37 #include "gmo.h" /* Get nls_uint32. */
39 /* @@ end of prolog @@ */
41 #ifndef PARAMS
42 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
43 # define PARAMS(args) args
44 # else
45 # define PARAMS(args) ()
46 # endif
47 #endif
49 #ifndef internal_function
50 # define internal_function
51 #endif
53 #ifndef attribute_hidden
54 # define attribute_hidden
55 #endif
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)
61 #endif
63 #ifndef W
64 # define W(flag, data) ((flag) ? SWAP (data) : (data))
65 #endif
68 #ifdef _LIBC
69 # include <byteswap.h>
70 # define SWAP(i) bswap_32 (i)
71 #else
72 static nls_uint32 SWAP PARAMS ((nls_uint32 i));
74 static inline nls_uint32
75 SWAP (i)
76 nls_uint32 i;
78 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
80 #endif
83 /* In-memory representation of system dependent string. */
84 struct sysdep_string_desc
86 /* Length of addressed string, including the trailing NUL. */
87 size_t length;
88 /* Pointer to addressed string. */
89 const char *pointer;
92 /* Cache of translated strings after charset conversion.
93 Note: The strings are converted to the target encoding only on an as-needed
94 basis. */
95 struct converted_domain
97 /* The target encoding name. */
98 const char *encoding;
99 /* The descriptor for conversion from the message catalog's encoding to
100 this target encoding. */
101 #ifdef _LIBC
102 __gconv_t conv;
103 #else
104 # if HAVE_ICONV
105 iconv_t conv;
106 # endif
107 #endif
108 /* The table of translated strings after charset conversion. */
109 char **conv_tab;
112 /* The representation of an opened message catalog. */
113 struct loaded_domain
115 /* Pointer to memory containing the .mo file. */
116 const char *data;
117 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
118 int use_mmap;
119 /* Size of mmap()ed memory. */
120 size_t mmap_size;
121 /* 1 if the .mo file uses a different endianness than this machine. */
122 int must_swap;
123 /* Pointer to additional malloc()ed memory. */
124 void *malloced;
126 /* Number of static strings pairs. */
127 nls_uint32 nstrings;
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;
149 size_t nconversions;
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. */
158 #ifdef __GNUC__
159 # define ZERO 0
160 #else
161 # define ZERO 1
162 #endif
164 /* A set of settings bound to a message domain. Used to store settings
165 from bindtextdomain() and bind_textdomain_codeset(). */
166 struct binding
168 struct binding *next;
169 char *dirname;
170 char *codeset;
171 char domainname[ZERO];
174 /* A counter which is incremented each time some previous translations
175 become invalid.
176 This variable is part of the external ABI of the GNU libintl. */
177 extern int _nl_msg_cat_cntr;
179 #ifndef _LIBC
180 const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
181 #endif
183 struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
184 char *__locale,
185 const char *__domainname,
186 struct binding *__domainbinding))
187 internal_function;
188 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
189 struct binding *__domainbinding))
190 internal_function;
192 char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
193 struct binding *domainbinding, const char *msgid,
194 int convert, size_t *lengthp))
195 internal_function;
197 #ifdef _LIBC
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,
214 int __category));
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;
223 #else
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,
240 int __category));
241 extern char *libintl_dcigettext PARAMS ((const char *__domainname,
242 const char *__msgid1,
243 const char *__msgid2,
244 int __plural, unsigned long int __n,
245 int __category));
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));
251 #endif
253 /* @@ begin of epilog @@ */
255 #endif /* gettextP.h */