Update copyright notices with scripts/update-copyrights
[glibc.git] / intl / gettextP.h
blob3da2322efaad582e48e995f12d3c5bb168b5878b
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/>. */
20 #ifndef _GETTEXTP_H
21 #define _GETTEXTP_H
23 #include <stddef.h> /* Get size_t. */
25 #ifdef _LIBC
26 # include "../iconv/gconv_int.h"
27 #else
28 # if HAVE_ICONV
29 # include <iconv.h>
30 # endif
31 #endif
33 #include "loadinfo.h"
35 #include "gmo.h" /* Get nls_uint32. */
37 /* @@ end of prolog @@ */
39 #ifndef PARAMS
40 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
41 # define PARAMS(args) args
42 # else
43 # define PARAMS(args) ()
44 # endif
45 #endif
47 #ifndef internal_function
48 # define internal_function
49 #endif
51 #ifndef attribute_hidden
52 # define attribute_hidden
53 #endif
55 #ifndef W
56 # define W(flag, data) ((flag) ? SWAP (data) : (data))
57 #endif
60 #ifdef _LIBC
61 # include <byteswap.h>
62 # define SWAP(i) bswap_32 (i)
63 #else
64 static nls_uint32 SWAP PARAMS ((nls_uint32 i));
66 static inline nls_uint32
67 SWAP (i)
68 nls_uint32 i;
70 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
72 #endif
75 /* In-memory representation of system dependent string. */
76 struct sysdep_string_desc
78 /* Length of addressed string, including the trailing NUL. */
79 size_t length;
80 /* Pointer to addressed string. */
81 const char *pointer;
84 /* Cache of translated strings after charset conversion.
85 Note: The strings are converted to the target encoding only on an as-needed
86 basis. */
87 struct converted_domain
89 /* The target encoding name. */
90 const char *encoding;
91 /* The descriptor for conversion from the message catalog's encoding to
92 this target encoding. */
93 #ifdef _LIBC
94 __gconv_t conv;
95 #else
96 # if HAVE_ICONV
97 iconv_t conv;
98 # endif
99 #endif
100 /* The table of translated strings after charset conversion. */
101 char **conv_tab;
104 /* The representation of an opened message catalog. */
105 struct loaded_domain
107 /* Pointer to memory containing the .mo file. */
108 const char *data;
109 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
110 int use_mmap;
111 /* Size of mmap()ed memory. */
112 size_t mmap_size;
113 /* 1 if the .mo file uses a different endianness than this machine. */
114 int must_swap;
115 /* Pointer to additional malloc()ed memory. */
116 void *malloced;
118 /* Number of static strings pairs. */
119 nls_uint32 nstrings;
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;
141 size_t nconversions;
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. */
150 #ifdef __GNUC__
151 # define ZERO 0
152 #else
153 # define ZERO 1
154 #endif
156 /* A set of settings bound to a message domain. Used to store settings
157 from bindtextdomain() and bind_textdomain_codeset(). */
158 struct binding
160 struct binding *next;
161 char *dirname;
162 char *codeset;
163 char domainname[ZERO];
166 /* A counter which is incremented each time some previous translations
167 become invalid.
168 This variable is part of the external ABI of the GNU libintl. */
169 extern int _nl_msg_cat_cntr;
171 #ifndef _LIBC
172 const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
173 #endif
175 struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
176 char *__locale,
177 const char *__domainname,
178 struct binding *__domainbinding))
179 internal_function;
180 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
181 struct binding *__domainbinding))
182 internal_function;
184 char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
185 struct binding *domainbinding, const char *msgid,
186 int convert, size_t *lengthp))
187 internal_function;
189 #ifdef _LIBC
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,
206 int __category));
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;
215 #else
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,
232 int __category));
233 extern char *libintl_dcigettext PARAMS ((const char *__domainname,
234 const char *__msgid1,
235 const char *__msgid2,
236 int __plural, unsigned long int __n,
237 int __category));
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));
243 #endif
245 /* @@ begin of epilog @@ */
247 #endif /* gettextP.h */