Automatic date update in version.in
[binutils-gdb.git] / intl / libgnuintl.h
blob7616d6fc0827c63d0fe0bd8f6fc7e7eca1458c65
1 /* Message catalogs for internationalization.
2 Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
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.
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.
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. */
19 #ifndef _LIBINTL_H
20 #define _LIBINTL_H 1
22 #include <locale.h>
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
35 /* We define an additional symbol to signal that we use the GNU
36 implementation of gettext. */
37 #define __USE_GNU_GETTEXT 1
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)
44 /* Resolve a platform specific conflict on DJGPP. GNU gettext takes
45 precedence over _conio_gettext. */
46 #ifdef __DJGPP__
47 # undef gettext
48 #endif
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
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
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.
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'. */
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
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 defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1 && !(defined __clang__ && __clang__ && __clang_major__ >= 3) && 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
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
128 extern char *libintl_gettext (const char *__msgid)
129 _INTL_MAY_RETURN_STRING_ARG (1);
130 static inline
131 _INTL_MAY_RETURN_STRING_ARG (1)
132 char *gettext (const char *__msgid)
134 return libintl_gettext (__msgid);
136 #else
137 #ifdef _INTL_REDIRECT_MACROS
138 # define gettext libintl_gettext
139 #endif
140 extern char *gettext _INTL_PARAMS ((const char *__msgid))
141 _INTL_ASM (libintl_gettext)
142 _INTL_MAY_RETURN_STRING_ARG (1);
143 #endif
145 /* Look up MSGID in the DOMAINNAME message catalog for the current
146 LC_MESSAGES locale. */
147 #ifdef _INTL_REDIRECT_INLINE
148 extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
149 _INTL_MAY_RETURN_STRING_ARG (2);
150 static inline
151 _INTL_MAY_RETURN_STRING_ARG (2)
152 char *dgettext (const char *__domainname, const char *__msgid)
154 return libintl_dgettext (__domainname, __msgid);
156 #else
157 #ifdef _INTL_REDIRECT_MACROS
158 # define dgettext libintl_dgettext
159 #endif
160 extern char *dgettext _INTL_PARAMS ((const char *__domainname,
161 const char *__msgid))
162 _INTL_ASM (libintl_dgettext)
163 _INTL_MAY_RETURN_STRING_ARG (2);
164 #endif
166 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
167 locale. */
168 #ifdef _INTL_REDIRECT_INLINE
169 extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
170 int __category)
171 _INTL_MAY_RETURN_STRING_ARG (2);
172 static inline
173 _INTL_MAY_RETURN_STRING_ARG (2)
174 char *dcgettext (const char *__domainname, const char *__msgid, int __category)
176 return libintl_dcgettext (__domainname, __msgid, __category);
178 #else
179 #ifdef _INTL_REDIRECT_MACROS
180 # define dcgettext libintl_dcgettext
181 #endif
182 extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
183 const char *__msgid,
184 int __category))
185 _INTL_ASM (libintl_dcgettext)
186 _INTL_MAY_RETURN_STRING_ARG (2);
187 #endif
190 /* Similar to `gettext' but select the plural form corresponding to the
191 number N. */
192 #ifdef _INTL_REDIRECT_INLINE
193 extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
194 unsigned long int __n)
195 _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
196 static inline
197 _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2)
198 char *ngettext (const char *__msgid1, const char *__msgid2,
199 unsigned long int __n)
201 return libintl_ngettext (__msgid1, __msgid2, __n);
203 #else
204 #ifdef _INTL_REDIRECT_MACROS
205 # define ngettext libintl_ngettext
206 #endif
207 extern char *ngettext _INTL_PARAMS ((const char *__msgid1,
208 const char *__msgid2,
209 unsigned long int __n))
210 _INTL_ASM (libintl_ngettext)
211 _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
212 #endif
214 /* Similar to `dgettext' but select the plural form corresponding to the
215 number N. */
216 #ifdef _INTL_REDIRECT_INLINE
217 extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
218 const char *__msgid2, unsigned long int __n)
219 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
220 static inline
221 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3)
222 char *dngettext (const char *__domainname, const char *__msgid1,
223 const char *__msgid2, unsigned long int __n)
225 return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
227 #else
228 #ifdef _INTL_REDIRECT_MACROS
229 # define dngettext libintl_dngettext
230 #endif
231 extern char *dngettext _INTL_PARAMS ((const char *__domainname,
232 const char *__msgid1,
233 const char *__msgid2,
234 unsigned long int __n))
235 _INTL_ASM (libintl_dngettext)
236 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
237 #endif
239 /* Similar to `dcgettext' but select the plural form corresponding to the
240 number N. */
241 #ifdef _INTL_REDIRECT_INLINE
242 extern char *libintl_dcngettext (const char *__domainname,
243 const char *__msgid1, const char *__msgid2,
244 unsigned long int __n, int __category)
245 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
246 static inline
247 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3)
248 char *dcngettext (const char *__domainname,
249 const char *__msgid1, const char *__msgid2,
250 unsigned long int __n, int __category)
252 return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
254 #else
255 #ifdef _INTL_REDIRECT_MACROS
256 # define dcngettext libintl_dcngettext
257 #endif
258 extern char *dcngettext _INTL_PARAMS ((const char *__domainname,
259 const char *__msgid1,
260 const char *__msgid2,
261 unsigned long int __n,
262 int __category))
263 _INTL_ASM (libintl_dcngettext)
264 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
265 #endif
268 /* Set the current default message catalog to DOMAINNAME.
269 If DOMAINNAME is null, return the current default.
270 If DOMAINNAME is "", reset to the default of "messages". */
271 #ifdef _INTL_REDIRECT_INLINE
272 extern char *libintl_textdomain (const char *__domainname);
273 static inline char *textdomain (const char *__domainname)
275 return libintl_textdomain (__domainname);
277 #else
278 #ifdef _INTL_REDIRECT_MACROS
279 # define textdomain libintl_textdomain
280 #endif
281 extern char *textdomain _INTL_PARAMS ((const char *__domainname))
282 _INTL_ASM (libintl_textdomain);
283 #endif
285 /* Specify that the DOMAINNAME message catalog will be found
286 in DIRNAME rather than in the system locale data base. */
287 #ifdef _INTL_REDIRECT_INLINE
288 extern char *libintl_bindtextdomain (const char *__domainname,
289 const char *__dirname);
290 static inline char *bindtextdomain (const char *__domainname,
291 const char *__dirname)
293 return libintl_bindtextdomain (__domainname, __dirname);
295 #else
296 #ifdef _INTL_REDIRECT_MACROS
297 # define bindtextdomain libintl_bindtextdomain
298 #endif
299 extern char *bindtextdomain _INTL_PARAMS ((const char *__domainname,
300 const char *__dirname))
301 _INTL_ASM (libintl_bindtextdomain);
302 #endif
304 /* Specify the character encoding in which the messages from the
305 DOMAINNAME message catalog will be returned. */
306 #ifdef _INTL_REDIRECT_INLINE
307 extern char *libintl_bind_textdomain_codeset (const char *__domainname,
308 const char *__codeset);
309 static inline char *bind_textdomain_codeset (const char *__domainname,
310 const char *__codeset)
312 return libintl_bind_textdomain_codeset (__domainname, __codeset);
314 #else
315 #ifdef _INTL_REDIRECT_MACROS
316 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
317 #endif
318 extern char *bind_textdomain_codeset _INTL_PARAMS ((const char *__domainname,
319 const char *__codeset))
320 _INTL_ASM (libintl_bind_textdomain_codeset);
321 #endif
324 /* Support for relocatable packages. */
326 /* Sets the original and the current installation prefix of the package.
327 Relocation simply replaces a pathname starting with the original prefix
328 by the corresponding pathname with the current prefix instead. Both
329 prefixes should be directory names without trailing slash (i.e. use ""
330 instead of "/"). */
331 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
332 extern void
333 libintl_set_relocation_prefix _INTL_PARAMS ((const char *orig_prefix,
334 const char *curr_prefix));
337 #ifdef __cplusplus
339 #endif
341 #endif /* libintl.h */