Update.
[glibc.git] / intl / gettextP.h
blobd90e59a36426eaaa4b3388a29a8311a4f0482ac8
1 /* Header describing internals of libintl library.
2 Copyright (C) 1995-1999, 2000, 2001 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, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 #ifndef _GETTEXTP_H
22 #define _GETTEXTP_H
24 #include <stddef.h> /* Get size_t. */
26 #ifdef _LIBC
27 # include "../iconv/gconv_int.h"
28 #else
29 # if HAVE_ICONV
30 # include <iconv.h>
31 # endif
32 #endif
34 #include "loadinfo.h"
36 #include "gettext.h" /* Get nls_uint32. */
38 /* @@ end of prolog @@ */
40 #ifndef PARAMS
41 # if __STDC__
42 # define PARAMS(args) args
43 # else
44 # define PARAMS(args) ()
45 # endif
46 #endif
48 #ifndef internal_function
49 # define internal_function
50 #endif
52 /* Tell the compiler when a conditional or integer expression is
53 almost always true or almost always false. */
54 #ifndef HAVE_BUILTIN_EXPECT
55 # define __builtin_expect(expr, val) (expr)
56 #endif
58 #ifndef W
59 # define W(flag, data) ((flag) ? SWAP (data) : (data))
60 #endif
63 #ifdef _LIBC
64 # include <byteswap.h>
65 # define SWAP(i) bswap_32 (i)
66 #else
67 static nls_uint32 SWAP PARAMS ((nls_uint32 i));
69 static inline nls_uint32
70 SWAP (i)
71 nls_uint32 i;
73 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
75 #endif
78 /* In-memory representation of system dependent string. */
79 struct sysdep_string_desc
81 /* Length of addressed string, including the trailing NUL. */
82 size_t length;
83 /* Pointer to addressed string. */
84 const char *pointer;
87 /* The representation of an opened message catalog. */
88 struct loaded_domain
90 /* Pointer to memory containing the .mo file. */
91 const char *data;
92 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
93 int use_mmap;
94 /* Size of mmap()ed memory. */
95 size_t mmap_size;
96 /* 1 if the .mo file uses a different endianness than this machine. */
97 int must_swap;
98 /* Pointer to additional malloc()ed memory. */
99 void *malloced;
101 /* Number of static strings pairs. */
102 nls_uint32 nstrings;
103 /* Pointer to descriptors of original strings in the file. */
104 const struct string_desc *orig_tab;
105 /* Pointer to descriptors of translated strings in the file. */
106 const struct string_desc *trans_tab;
108 /* Number of system dependent strings pairs. */
109 nls_uint32 n_sysdep_strings;
110 /* Pointer to descriptors of original sysdep strings. */
111 const struct sysdep_string_desc *orig_sysdep_tab;
112 /* Pointer to descriptors of translated sysdep strings. */
113 const struct sysdep_string_desc *trans_sysdep_tab;
115 /* Size of hash table. */
116 nls_uint32 hash_size;
117 /* Pointer to hash table. */
118 const nls_uint32 *hash_tab;
119 /* 1 if the hash table uses a different endianness than this machine. */
120 int must_swap_hash_tab;
122 int codeset_cntr;
123 #ifdef _LIBC
124 __gconv_t conv;
125 #else
126 # if HAVE_ICONV
127 iconv_t conv;
128 # endif
129 #endif
130 char **conv_tab;
132 struct expression *plural;
133 unsigned long int nplurals;
136 /* We want to allocate a string at the end of the struct. But ISO C
137 doesn't allow zero sized arrays. */
138 #ifdef __GNUC__
139 # define ZERO 0
140 #else
141 # define ZERO 1
142 #endif
144 /* A set of settings bound to a message domain. Used to store settings
145 from bindtextdomain() and bind_textdomain_codeset(). */
146 struct binding
148 struct binding *next;
149 char *dirname;
150 int codeset_cntr; /* Incremented each time codeset changes. */
151 char *codeset;
152 char domainname[ZERO];
155 /* A counter which is incremented each time some previous translations
156 become invalid.
157 This variable is part of the external ABI of the GNU libintl. */
158 extern int _nl_msg_cat_cntr;
160 struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
161 char *__locale,
162 const char *__domainname,
163 struct binding *__domainbinding))
164 internal_function;
165 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
166 struct binding *__domainbinding))
167 internal_function;
168 void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
169 internal_function;
170 const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
171 struct loaded_domain *__domain,
172 struct binding *__domainbinding))
173 internal_function;
174 void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
175 internal_function;
177 char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
178 struct binding *domainbinding,
179 const char *msgid, size_t *lengthp))
180 internal_function;
182 #ifdef _LIBC
183 extern char *__gettext PARAMS ((const char *__msgid));
184 extern char *__dgettext PARAMS ((const char *__domainname,
185 const char *__msgid));
186 extern char *__dcgettext PARAMS ((const char *__domainname,
187 const char *__msgid, int __category));
188 extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
189 unsigned long int __n));
190 extern char *__dngettext PARAMS ((const char *__domainname,
191 const char *__msgid1, const char *__msgid2,
192 unsigned long int n));
193 extern char *__dcngettext PARAMS ((const char *__domainname,
194 const char *__msgid1, const char *__msgid2,
195 unsigned long int __n, int __category));
196 extern char *__dcigettext PARAMS ((const char *__domainname,
197 const char *__msgid1, const char *__msgid2,
198 int __plural, unsigned long int __n,
199 int __category));
200 extern char *__textdomain PARAMS ((const char *__domainname));
201 extern char *__bindtextdomain PARAMS ((const char *__domainname,
202 const char *__dirname));
203 extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
204 const char *__codeset));
205 #else
206 extern char *gettext__ PARAMS ((const char *__msgid));
207 extern char *dgettext__ PARAMS ((const char *__domainname,
208 const char *__msgid));
209 extern char *dcgettext__ PARAMS ((const char *__domainname,
210 const char *__msgid, int __category));
211 extern char *ngettext__ PARAMS ((const char *__msgid1, const char *__msgid2,
212 unsigned long int __n));
213 extern char *dngettext__ PARAMS ((const char *__domainname,
214 const char *__msgid1, const char *__msgid2,
215 unsigned long int __n));
216 extern char *dcngettext__ PARAMS ((const char *__domainname,
217 const char *__msgid1, const char *__msgid2,
218 unsigned long int __n, int __category));
219 extern char *dcigettext__ PARAMS ((const char *__domainname,
220 const char *__msgid1, const char *__msgid2,
221 int __plural, unsigned long int __n,
222 int __category));
223 extern char *textdomain__ PARAMS ((const char *__domainname));
224 extern char *bindtextdomain__ PARAMS ((const char *__domainname,
225 const char *__dirname));
226 extern char *bind_textdomain_codeset__ PARAMS ((const char *__domainname,
227 const char *__codeset));
228 #endif
230 /* @@ begin of epilog @@ */
232 #endif /* gettextP.h */