]> git.ipfire.org Git - thirdparty/glibc.git/blob - intl/gettextP.h
Regnerate with modern bison
[thirdparty/glibc.git] / intl / gettextP.h
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.
6
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.
11
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.
16
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. */
21
22 #ifndef _GETTEXTP_H
23 #define _GETTEXTP_H
24
25 #include <stddef.h> /* Get size_t. */
26
27 #ifdef _LIBC
28 # include "../iconv/gconv_int.h"
29 #else
30 # if HAVE_ICONV
31 # include <iconv.h>
32 # endif
33 #endif
34
35 #include "loadinfo.h"
36
37 #include "gmo.h" /* Get nls_uint32. */
38
39 /* @@ end of prolog @@ */
40
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
48
49 #ifndef internal_function
50 # define internal_function
51 #endif
52
53 #ifndef attribute_hidden
54 # define attribute_hidden
55 #endif
56
57 #ifndef W
58 # define W(flag, data) ((flag) ? SWAP (data) : (data))
59 #endif
60
61
62 #ifdef _LIBC
63 # include <byteswap.h>
64 # define SWAP(i) bswap_32 (i)
65 #else
66 static nls_uint32 SWAP PARAMS ((nls_uint32 i));
67
68 static inline nls_uint32
69 SWAP (i)
70 nls_uint32 i;
71 {
72 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
73 }
74 #endif
75
76
77 /* In-memory representation of system dependent string. */
78 struct sysdep_string_desc
79 {
80 /* Length of addressed string, including the trailing NUL. */
81 size_t length;
82 /* Pointer to addressed string. */
83 const char *pointer;
84 };
85
86 /* Cache of translated strings after charset conversion.
87 Note: The strings are converted to the target encoding only on an as-needed
88 basis. */
89 struct converted_domain
90 {
91 /* The target encoding name. */
92 const char *encoding;
93 /* The descriptor for conversion from the message catalog's encoding to
94 this target encoding. */
95 #ifdef _LIBC
96 __gconv_t conv;
97 #else
98 # if HAVE_ICONV
99 iconv_t conv;
100 # endif
101 #endif
102 /* The table of translated strings after charset conversion. */
103 char **conv_tab;
104 };
105
106 /* The representation of an opened message catalog. */
107 struct loaded_domain
108 {
109 /* Pointer to memory containing the .mo file. */
110 const char *data;
111 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
112 int use_mmap;
113 /* Size of mmap()ed memory. */
114 size_t mmap_size;
115 /* 1 if the .mo file uses a different endianness than this machine. */
116 int must_swap;
117 /* Pointer to additional malloc()ed memory. */
118 void *malloced;
119
120 /* Number of static strings pairs. */
121 nls_uint32 nstrings;
122 /* Pointer to descriptors of original strings in the file. */
123 const struct string_desc *orig_tab;
124 /* Pointer to descriptors of translated strings in the file. */
125 const struct string_desc *trans_tab;
126
127 /* Number of system dependent strings pairs. */
128 nls_uint32 n_sysdep_strings;
129 /* Pointer to descriptors of original sysdep strings. */
130 const struct sysdep_string_desc *orig_sysdep_tab;
131 /* Pointer to descriptors of translated sysdep strings. */
132 const struct sysdep_string_desc *trans_sysdep_tab;
133
134 /* Size of hash table. */
135 nls_uint32 hash_size;
136 /* Pointer to hash table. */
137 const nls_uint32 *hash_tab;
138 /* 1 if the hash table uses a different endianness than this machine. */
139 int must_swap_hash_tab;
140
141 /* Cache of charset conversions of the translated strings. */
142 struct converted_domain *conversions;
143 size_t nconversions;
144 __libc_rwlock_define (, conversions_lock);
145
146 const struct expression *plural;
147 unsigned long int nplurals;
148 };
149
150 /* We want to allocate a string at the end of the struct. But ISO C
151 doesn't allow zero sized arrays. */
152 #ifdef __GNUC__
153 # define ZERO 0
154 #else
155 # define ZERO 1
156 #endif
157
158 /* A set of settings bound to a message domain. Used to store settings
159 from bindtextdomain() and bind_textdomain_codeset(). */
160 struct binding
161 {
162 struct binding *next;
163 char *dirname;
164 char *codeset;
165 char domainname[ZERO];
166 };
167
168 /* A counter which is incremented each time some previous translations
169 become invalid.
170 This variable is part of the external ABI of the GNU libintl. */
171 extern int _nl_msg_cat_cntr;
172
173 #ifndef _LIBC
174 const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
175 #endif
176
177 struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
178 char *__locale,
179 const char *__domainname,
180 struct binding *__domainbinding))
181 internal_function;
182 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
183 struct binding *__domainbinding))
184 internal_function;
185
186 char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
187 struct binding *domainbinding, const char *msgid,
188 int convert, size_t *lengthp))
189 internal_function;
190
191 #ifdef _LIBC
192 extern char *__gettext PARAMS ((const char *__msgid));
193 extern char *__dgettext PARAMS ((const char *__domainname,
194 const char *__msgid));
195 extern char *__dcgettext PARAMS ((const char *__domainname,
196 const char *__msgid, int __category));
197 extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
198 unsigned long int __n));
199 extern char *__dngettext PARAMS ((const char *__domainname,
200 const char *__msgid1, const char *__msgid2,
201 unsigned long int n));
202 extern char *__dcngettext PARAMS ((const char *__domainname,
203 const char *__msgid1, const char *__msgid2,
204 unsigned long int __n, int __category));
205 extern char *__dcigettext PARAMS ((const char *__domainname,
206 const char *__msgid1, const char *__msgid2,
207 int __plural, unsigned long int __n,
208 int __category));
209 extern char *__textdomain PARAMS ((const char *__domainname));
210 extern char *__bindtextdomain PARAMS ((const char *__domainname,
211 const char *__dirname));
212 extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
213 const char *__codeset));
214 extern void _nl_finddomain_subfreeres PARAMS ((void)) attribute_hidden;
215 extern void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
216 internal_function attribute_hidden;
217 #else
218 extern char *libintl_gettext PARAMS ((const char *__msgid));
219 extern char *libintl_dgettext PARAMS ((const char *__domainname,
220 const char *__msgid));
221 extern char *libintl_dcgettext PARAMS ((const char *__domainname,
222 const char *__msgid, int __category));
223 extern char *libintl_ngettext PARAMS ((const char *__msgid1,
224 const char *__msgid2,
225 unsigned long int __n));
226 extern char *libintl_dngettext PARAMS ((const char *__domainname,
227 const char *__msgid1,
228 const char *__msgid2,
229 unsigned long int __n));
230 extern char *libintl_dcngettext PARAMS ((const char *__domainname,
231 const char *__msgid1,
232 const char *__msgid2,
233 unsigned long int __n,
234 int __category));
235 extern char *libintl_dcigettext PARAMS ((const char *__domainname,
236 const char *__msgid1,
237 const char *__msgid2,
238 int __plural, unsigned long int __n,
239 int __category));
240 extern char *libintl_textdomain PARAMS ((const char *__domainname));
241 extern char *libintl_bindtextdomain PARAMS ((const char *__domainname,
242 const char *__dirname));
243 extern char *libintl_bind_textdomain_codeset PARAMS ((const char *__domainname,
244 const char *__codeset));
245 #endif
246
247 /* @@ begin of epilog @@ */
248
249 #endif /* gettextP.h */