Bump to autoconf 2.69 and automake 1.15.1
[deliverable/binutils-gdb.git] / intl / libgnuintl.h
CommitLineData
bf070c84
SE
1/* Message catalogs for internationalization.
2 Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published
6 by the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
17 USA. */
18
19#ifndef _LIBINTL_H
20#define _LIBINTL_H 1
21
22#include <locale.h>
23
24/* The LC_MESSAGES locale category is the category used by the functions
25 gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
26 On systems that don't define it, use an arbitrary value instead.
27 On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
28 then includes <libintl.h> (i.e. this file!) and then only defines
29 LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
30 in this case. */
31#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
32# define LC_MESSAGES 1729
33#endif
34
35/* We define an additional symbol to signal that we use the GNU
36 implementation of gettext. */
37#define __USE_GNU_GETTEXT 1
38
39/* Provide information about the supported file formats. Returns the
40 maximum minor revision number supported for a given major revision. */
41#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
42 ((major) == 0 ? 1 : -1)
43
44/* Resolve a platform specific conflict on DJGPP. GNU gettext takes
45 precedence over _conio_gettext. */
46#ifdef __DJGPP__
47# undef gettext
48#endif
49
50/* Use _INTL_PARAMS, not PARAMS, in order to avoid clashes with identifiers
51 used by programs. Similarly, test __PROTOTYPES, not PROTOTYPES. */
52#ifndef _INTL_PARAMS
53# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
54# define _INTL_PARAMS(args) args
55# else
56# define _INTL_PARAMS(args) ()
57# endif
58#endif
59
60#ifdef __cplusplus
61extern "C" {
62#endif
63
64
65/* We redirect the functions to those prefixed with "libintl_". This is
66 necessary, because some systems define gettext/textdomain/... in the C
67 library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
68 If we used the unprefixed names, there would be cases where the
69 definition in the C library would override the one in the libintl.so
70 shared library. Recall that on ELF systems, the symbols are looked
71 up in the following order:
72 1. in the executable,
73 2. in the shared libraries specified on the link command line, in order,
74 3. in the dependencies of the shared libraries specified on the link
75 command line,
76 4. in the dlopen()ed shared libraries, in the order in which they were
77 dlopen()ed.
78 The definition in the C library would override the one in libintl.so if
79 either
80 * -lc is given on the link command line and -lintl isn't, or
81 * -lc is given on the link command line before -lintl, or
82 * libintl.so is a dependency of a dlopen()ed shared library but not
83 linked to the executable at link time.
84 Since Solaris gettext() behaves differently than GNU gettext(), this
85 would be unacceptable.
86
87 The redirection happens by default through macros in C, so that &gettext
88 is independent of the compilation unit, but through inline functions in
89 C++, in order not to interfere with the name mangling of class fields or
90 class methods called 'gettext'. */
91
92/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
93 If he doesn't, we choose the method. A third possible method is
94 _INTL_REDIRECT_ASM, supported only by GCC. */
95#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
96# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
97# define _INTL_REDIRECT_ASM
98# else
99# ifdef __cplusplus
100# define _INTL_REDIRECT_INLINE
101# else
102# define _INTL_REDIRECT_MACROS
103# endif
104# endif
105#endif
106/* Auxiliary macros. */
107#ifdef _INTL_REDIRECT_ASM
108# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
109# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
110# define _INTL_STRINGIFY(prefix) #prefix
111#else
112# define _INTL_ASM(cname)
113#endif
114
c44c601a
TG
115/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
116 its n-th argument literally. This enables GCC to warn for example about
117 printf (gettext ("foo %y")). */
118#if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus)
119# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
120#else
121# define _INTL_MAY_RETURN_STRING_ARG(n)
122#endif
123
bf070c84
SE
124/* Look up MSGID in the current default message catalog for the current
125 LC_MESSAGES locale. If not found, returns MSGID itself (the default
126 text). */
127#ifdef _INTL_REDIRECT_INLINE
c44c601a
TG
128extern char *libintl_gettext (const char *__msgid)
129 _INTL_MAY_RETURN_STRING_ARG (1);
bf070c84
SE
130static inline char *gettext (const char *__msgid)
131{
132 return libintl_gettext (__msgid);
133}
134#else
135#ifdef _INTL_REDIRECT_MACROS
136# define gettext libintl_gettext
137#endif
138extern char *gettext _INTL_PARAMS ((const char *__msgid))
c44c601a
TG
139 _INTL_ASM (libintl_gettext)
140 _INTL_MAY_RETURN_STRING_ARG (1);
bf070c84
SE
141#endif
142
143/* Look up MSGID in the DOMAINNAME message catalog for the current
144 LC_MESSAGES locale. */
145#ifdef _INTL_REDIRECT_INLINE
c44c601a
TG
146extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
147 _INTL_MAY_RETURN_STRING_ARG (2);
bf070c84
SE
148static inline char *dgettext (const char *__domainname, const char *__msgid)
149{
150 return libintl_dgettext (__domainname, __msgid);
151}
152#else
153#ifdef _INTL_REDIRECT_MACROS
154# define dgettext libintl_dgettext
155#endif
156extern char *dgettext _INTL_PARAMS ((const char *__domainname,
157 const char *__msgid))
c44c601a
TG
158 _INTL_ASM (libintl_dgettext)
159 _INTL_MAY_RETURN_STRING_ARG (2);
bf070c84
SE
160#endif
161
162/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
163 locale. */
164#ifdef _INTL_REDIRECT_INLINE
165extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
c44c601a
TG
166 int __category)
167 _INTL_MAY_RETURN_STRING_ARG (2);
bf070c84
SE
168static inline char *dcgettext (const char *__domainname, const char *__msgid,
169 int __category)
170{
171 return libintl_dcgettext (__domainname, __msgid, __category);
172}
173#else
174#ifdef _INTL_REDIRECT_MACROS
175# define dcgettext libintl_dcgettext
176#endif
177extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
178 const char *__msgid,
179 int __category))
c44c601a
TG
180 _INTL_ASM (libintl_dcgettext)
181 _INTL_MAY_RETURN_STRING_ARG (2);
bf070c84
SE
182#endif
183
184
185/* Similar to `gettext' but select the plural form corresponding to the
186 number N. */
187#ifdef _INTL_REDIRECT_INLINE
188extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
c44c601a
TG
189 unsigned long int __n)
190 _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
bf070c84
SE
191static inline char *ngettext (const char *__msgid1, const char *__msgid2,
192 unsigned long int __n)
193{
194 return libintl_ngettext (__msgid1, __msgid2, __n);
195}
196#else
197#ifdef _INTL_REDIRECT_MACROS
198# define ngettext libintl_ngettext
199#endif
200extern char *ngettext _INTL_PARAMS ((const char *__msgid1,
201 const char *__msgid2,
202 unsigned long int __n))
c44c601a
TG
203 _INTL_ASM (libintl_ngettext)
204 _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
bf070c84
SE
205#endif
206
207/* Similar to `dgettext' but select the plural form corresponding to the
208 number N. */
209#ifdef _INTL_REDIRECT_INLINE
210extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
c44c601a
TG
211 const char *__msgid2, unsigned long int __n)
212 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
bf070c84
SE
213static inline char *dngettext (const char *__domainname, const char *__msgid1,
214 const char *__msgid2, unsigned long int __n)
215{
216 return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
217}
218#else
219#ifdef _INTL_REDIRECT_MACROS
220# define dngettext libintl_dngettext
221#endif
222extern char *dngettext _INTL_PARAMS ((const char *__domainname,
223 const char *__msgid1,
224 const char *__msgid2,
225 unsigned long int __n))
c44c601a
TG
226 _INTL_ASM (libintl_dngettext)
227 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
bf070c84
SE
228#endif
229
230/* Similar to `dcgettext' but select the plural form corresponding to the
231 number N. */
232#ifdef _INTL_REDIRECT_INLINE
233extern char *libintl_dcngettext (const char *__domainname,
234 const char *__msgid1, const char *__msgid2,
c44c601a
TG
235 unsigned long int __n, int __category)
236 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
bf070c84
SE
237static inline char *dcngettext (const char *__domainname,
238 const char *__msgid1, const char *__msgid2,
239 unsigned long int __n, int __category)
240{
241 return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
242}
243#else
244#ifdef _INTL_REDIRECT_MACROS
245# define dcngettext libintl_dcngettext
246#endif
247extern char *dcngettext _INTL_PARAMS ((const char *__domainname,
248 const char *__msgid1,
249 const char *__msgid2,
250 unsigned long int __n,
251 int __category))
c44c601a
TG
252 _INTL_ASM (libintl_dcngettext)
253 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
bf070c84
SE
254#endif
255
256
257/* Set the current default message catalog to DOMAINNAME.
258 If DOMAINNAME is null, return the current default.
259 If DOMAINNAME is "", reset to the default of "messages". */
260#ifdef _INTL_REDIRECT_INLINE
261extern char *libintl_textdomain (const char *__domainname);
262static inline char *textdomain (const char *__domainname)
263{
264 return libintl_textdomain (__domainname);
265}
266#else
267#ifdef _INTL_REDIRECT_MACROS
268# define textdomain libintl_textdomain
269#endif
270extern char *textdomain _INTL_PARAMS ((const char *__domainname))
271 _INTL_ASM (libintl_textdomain);
272#endif
273
274/* Specify that the DOMAINNAME message catalog will be found
275 in DIRNAME rather than in the system locale data base. */
276#ifdef _INTL_REDIRECT_INLINE
277extern char *libintl_bindtextdomain (const char *__domainname,
278 const char *__dirname);
279static inline char *bindtextdomain (const char *__domainname,
280 const char *__dirname)
281{
282 return libintl_bindtextdomain (__domainname, __dirname);
283}
284#else
285#ifdef _INTL_REDIRECT_MACROS
286# define bindtextdomain libintl_bindtextdomain
287#endif
288extern char *bindtextdomain _INTL_PARAMS ((const char *__domainname,
289 const char *__dirname))
290 _INTL_ASM (libintl_bindtextdomain);
291#endif
292
293/* Specify the character encoding in which the messages from the
294 DOMAINNAME message catalog will be returned. */
295#ifdef _INTL_REDIRECT_INLINE
296extern char *libintl_bind_textdomain_codeset (const char *__domainname,
297 const char *__codeset);
298static inline char *bind_textdomain_codeset (const char *__domainname,
299 const char *__codeset)
300{
301 return libintl_bind_textdomain_codeset (__domainname, __codeset);
302}
303#else
304#ifdef _INTL_REDIRECT_MACROS
305# define bind_textdomain_codeset libintl_bind_textdomain_codeset
306#endif
307extern char *bind_textdomain_codeset _INTL_PARAMS ((const char *__domainname,
308 const char *__codeset))
309 _INTL_ASM (libintl_bind_textdomain_codeset);
310#endif
311
312
313/* Support for relocatable packages. */
314
315/* Sets the original and the current installation prefix of the package.
316 Relocation simply replaces a pathname starting with the original prefix
317 by the corresponding pathname with the current prefix instead. Both
318 prefixes should be directory names without trailing slash (i.e. use ""
319 instead of "/"). */
320#define libintl_set_relocation_prefix libintl_set_relocation_prefix
321extern void
322 libintl_set_relocation_prefix _INTL_PARAMS ((const char *orig_prefix,
323 const char *curr_prefix));
324
325
326#ifdef __cplusplus
327}
328#endif
329
330#endif /* libintl.h */
This page took 0.477827 seconds and 4 git commands to generate.