This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / intl / gettextP.h
blob78372d0392812d5b8e5b9c1ce31608fba3b792cd
1 /* Header describing internals of libintl library.
2 Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
3 Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published
7 by the Free Software Foundation; either version 2, or (at your option)
8 any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 USA. */
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 /* Tell the compiler when a conditional or integer expression is
56 almost always true or almost always false. */
57 #ifndef HAVE_BUILTIN_EXPECT
58 # define __builtin_expect(expr, val) (expr)
59 #endif
61 #ifndef W
62 # define W(flag, data) ((flag) ? SWAP (data) : (data))
63 #endif
66 #ifdef _LIBC
67 # include <byteswap.h>
68 # define SWAP(i) bswap_32 (i)
69 #else
71 #ifndef __GNUC__
72 #define inline /* nothing: don't inline if the compiler is not GCC */
73 #endif
75 static inline nls_uint32
76 SWAP (i)
77 nls_uint32 i;
79 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
81 #endif
84 /* In-memory representation of system dependent string. */
85 struct sysdep_string_desc
87 /* Length of addressed string, including the trailing NUL. */
88 size_t length;
89 /* Pointer to addressed string. */
90 const char *pointer;
93 /* The representation of an opened message catalog. */
94 struct loaded_domain
96 /* Pointer to memory containing the .mo file. */
97 const char *data;
98 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
99 int use_mmap;
100 /* Size of mmap()ed memory. */
101 size_t mmap_size;
102 /* 1 if the .mo file uses a different endianness than this machine. */
103 int must_swap;
104 /* Pointer to additional malloc()ed memory. */
105 void *malloced;
107 /* Number of static strings pairs. */
108 nls_uint32 nstrings;
109 /* Pointer to descriptors of original strings in the file. */
110 const struct string_desc *orig_tab;
111 /* Pointer to descriptors of translated strings in the file. */
112 const struct string_desc *trans_tab;
114 /* Number of system dependent strings pairs. */
115 nls_uint32 n_sysdep_strings;
116 /* Pointer to descriptors of original sysdep strings. */
117 const struct sysdep_string_desc *orig_sysdep_tab;
118 /* Pointer to descriptors of translated sysdep strings. */
119 const struct sysdep_string_desc *trans_sysdep_tab;
121 /* Size of hash table. */
122 nls_uint32 hash_size;
123 /* Pointer to hash table. */
124 const nls_uint32 *hash_tab;
125 /* 1 if the hash table uses a different endianness than this machine. */
126 int must_swap_hash_tab;
128 int codeset_cntr;
129 #ifdef _LIBC
130 __gconv_t conv;
131 #else
132 # if HAVE_ICONV
133 iconv_t conv;
134 # endif
135 #endif
136 char **conv_tab;
138 struct expression *plural;
139 unsigned long int nplurals;
142 /* We want to allocate a string at the end of the struct. But ISO C
143 doesn't allow zero sized arrays. */
144 #ifdef __GNUC__
145 # define ZERO 0
146 #else
147 # define ZERO 1
148 #endif
150 /* A set of settings bound to a message domain. Used to store settings
151 from bindtextdomain() and bind_textdomain_codeset(). */
152 struct binding
154 struct binding *next;
155 char *dirname;
156 int codeset_cntr; /* Incremented each time codeset changes. */
157 char *codeset;
158 char domainname[ZERO];
161 /* A counter which is incremented each time some previous translations
162 become invalid.
163 This variable is part of the external ABI of the GNU libintl. */
164 extern int _nl_msg_cat_cntr;
166 #ifndef _LIBC
167 const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
168 #endif
170 struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
171 char *__locale,
172 const char *__domainname,
173 struct binding *__domainbinding))
174 internal_function;
175 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
176 struct binding *__domainbinding))
177 internal_function;
178 void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
179 internal_function;
180 const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
181 struct loaded_domain *__domain,
182 struct binding *__domainbinding))
183 internal_function;
184 void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
185 internal_function;
187 char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
188 struct binding *domainbinding,
189 const char *msgid, size_t *lengthp))
190 internal_function;
192 #ifdef _LIBC
193 extern char *__gettext PARAMS ((const char *__msgid));
194 extern char *__dgettext PARAMS ((const char *__domainname,
195 const char *__msgid));
196 extern char *__dcgettext PARAMS ((const char *__domainname,
197 const char *__msgid, int __category));
198 extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
199 unsigned long int __n));
200 extern char *__dngettext PARAMS ((const char *__domainname,
201 const char *__msgid1, const char *__msgid2,
202 unsigned long int n));
203 extern char *__dcngettext PARAMS ((const char *__domainname,
204 const char *__msgid1, const char *__msgid2,
205 unsigned long int __n, int __category));
206 extern char *__dcigettext PARAMS ((const char *__domainname,
207 const char *__msgid1, const char *__msgid2,
208 int __plural, unsigned long int __n,
209 int __category));
210 extern char *__textdomain PARAMS ((const char *__domainname));
211 extern char *__bindtextdomain PARAMS ((const char *__domainname,
212 const char *__dirname));
213 extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
214 const char *__codeset));
215 #else
216 /* Declare the exported libintl_* functions, in a way that allows us to
217 call them under their real name. */
218 # define _INTL_REDIRECT_MACROS
219 # include "libintl.h"
220 extern char *libintl_dcigettext PARAMS ((const char *__domainname,
221 const char *__msgid1,
222 const char *__msgid2,
223 int __plural, unsigned long int __n,
224 int __category));
225 #endif
227 /* @@ begin of epilog @@ */
229 #endif /* gettextP.h */