1
/* Message catalogs for internationalization.
2
Copyright (C) 1995-1997, 2000-2007 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)
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,
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
31
#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
32
# define LC_MESSAGES 1729
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 || (major) == 1 ? 1 : -1)
44
/* Resolve a platform specific conflict on DJGPP. GNU gettext takes
45
precedence over _conio_gettext. */
55
/* Version number: (major<<16) + (minor<<8) + subminor */
56
#define LIBINTL_VERSION 0x001100
57
extern int libintl_version;
60
/* We redirect the functions to those prefixed with "libintl_". This is
61
necessary, because some systems define gettext/textdomain/... in the C
62
library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
63
If we used the unprefixed names, there would be cases where the
64
definition in the C library would override the one in the libintl.so
65
shared library. Recall that on ELF systems, the symbols are looked
66
up in the following order:
68
2. in the shared libraries specified on the link command line, in order,
69
3. in the dependencies of the shared libraries specified on the link
71
4. in the dlopen()ed shared libraries, in the order in which they were
73
The definition in the C library would override the one in libintl.so if
75
* -lc is given on the link command line and -lintl isn't, or
76
* -lc is given on the link command line before -lintl, or
77
* libintl.so is a dependency of a dlopen()ed shared library but not
78
linked to the executable at link time.
79
Since Solaris gettext() behaves differently than GNU gettext(), this
80
would be unacceptable.
82
The redirection happens by default through macros in C, so that &gettext
83
is independent of the compilation unit, but through inline functions in
84
C++, in order not to interfere with the name mangling of class fields or
85
class methods called 'gettext'. */
87
/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
88
If he doesn't, we choose the method. A third possible method is
89
_INTL_REDIRECT_ASM, supported only by GCC. */
90
#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
91
# if __GNUC__ >= 2 && !(__APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
92
# define _INTL_REDIRECT_ASM
95
# define _INTL_REDIRECT_INLINE
97
# define _INTL_REDIRECT_MACROS
101
/* Auxiliary macros. */
102
#ifdef _INTL_REDIRECT_ASM
103
# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
104
# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
105
# define _INTL_STRINGIFY(prefix) #prefix
107
# define _INTL_ASM(cname)
110
/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
111
its n-th argument literally. This enables GCC to warn for example about
112
printf (gettext ("foo %y")). */
113
#if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus)
114
# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
116
# define _INTL_MAY_RETURN_STRING_ARG(n)
119
/* Look up MSGID in the current default message catalog for the current
120
LC_MESSAGES locale. If not found, returns MSGID itself (the default
122
#ifdef _INTL_REDIRECT_INLINE
123
extern char *libintl_gettext (const char *__msgid)
124
_INTL_MAY_RETURN_STRING_ARG (1);
125
static inline char *gettext (const char *__msgid)
127
return libintl_gettext (__msgid);
130
#ifdef _INTL_REDIRECT_MACROS
131
# define gettext libintl_gettext
133
extern char *gettext (const char *__msgid)
134
_INTL_ASM (libintl_gettext)
135
_INTL_MAY_RETURN_STRING_ARG (1);
138
/* Look up MSGID in the DOMAINNAME message catalog for the current
139
LC_MESSAGES locale. */
140
#ifdef _INTL_REDIRECT_INLINE
141
extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
142
_INTL_MAY_RETURN_STRING_ARG (2);
143
static inline char *dgettext (const char *__domainname, const char *__msgid)
145
return libintl_dgettext (__domainname, __msgid);
148
#ifdef _INTL_REDIRECT_MACROS
149
# define dgettext libintl_dgettext
151
extern char *dgettext (const char *__domainname, const char *__msgid)
152
_INTL_ASM (libintl_dgettext)
153
_INTL_MAY_RETURN_STRING_ARG (2);
156
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
158
#ifdef _INTL_REDIRECT_INLINE
159
extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
161
_INTL_MAY_RETURN_STRING_ARG (2);
162
static inline char *dcgettext (const char *__domainname, const char *__msgid,
165
return libintl_dcgettext (__domainname, __msgid, __category);
168
#ifdef _INTL_REDIRECT_MACROS
169
# define dcgettext libintl_dcgettext
171
extern char *dcgettext (const char *__domainname, const char *__msgid,
173
_INTL_ASM (libintl_dcgettext)
174
_INTL_MAY_RETURN_STRING_ARG (2);
178
/* Similar to `gettext' but select the plural form corresponding to the
180
#ifdef _INTL_REDIRECT_INLINE
181
extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
182
unsigned long int __n)
183
_INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
184
static inline char *ngettext (const char *__msgid1, const char *__msgid2,
185
unsigned long int __n)
187
return libintl_ngettext (__msgid1, __msgid2, __n);
190
#ifdef _INTL_REDIRECT_MACROS
191
# define ngettext libintl_ngettext
193
extern char *ngettext (const char *__msgid1, const char *__msgid2,
194
unsigned long int __n)
195
_INTL_ASM (libintl_ngettext)
196
_INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
199
/* Similar to `dgettext' but select the plural form corresponding to the
201
#ifdef _INTL_REDIRECT_INLINE
202
extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
203
const char *__msgid2, unsigned long int __n)
204
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
205
static inline char *dngettext (const char *__domainname, const char *__msgid1,
206
const char *__msgid2, unsigned long int __n)
208
return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
211
#ifdef _INTL_REDIRECT_MACROS
212
# define dngettext libintl_dngettext
214
extern char *dngettext (const char *__domainname,
215
const char *__msgid1, const char *__msgid2,
216
unsigned long int __n)
217
_INTL_ASM (libintl_dngettext)
218
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
221
/* Similar to `dcgettext' but select the plural form corresponding to the
223
#ifdef _INTL_REDIRECT_INLINE
224
extern char *libintl_dcngettext (const char *__domainname,
225
const char *__msgid1, const char *__msgid2,
226
unsigned long int __n, int __category)
227
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
228
static inline char *dcngettext (const char *__domainname,
229
const char *__msgid1, const char *__msgid2,
230
unsigned long int __n, int __category)
232
return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
235
#ifdef _INTL_REDIRECT_MACROS
236
# define dcngettext libintl_dcngettext
238
extern char *dcngettext (const char *__domainname,
239
const char *__msgid1, const char *__msgid2,
240
unsigned long int __n, int __category)
241
_INTL_ASM (libintl_dcngettext)
242
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
246
#ifndef IN_LIBGLOCALE
248
/* Set the current default message catalog to DOMAINNAME.
249
If DOMAINNAME is null, return the current default.
250
If DOMAINNAME is "", reset to the default of "messages". */
251
#ifdef _INTL_REDIRECT_INLINE
252
extern char *libintl_textdomain (const char *__domainname);
253
static inline char *textdomain (const char *__domainname)
255
return libintl_textdomain (__domainname);
258
#ifdef _INTL_REDIRECT_MACROS
259
# define textdomain libintl_textdomain
261
extern char *textdomain (const char *__domainname)
262
_INTL_ASM (libintl_textdomain);
265
/* Specify that the DOMAINNAME message catalog will be found
266
in DIRNAME rather than in the system locale data base. */
267
#ifdef _INTL_REDIRECT_INLINE
268
extern char *libintl_bindtextdomain (const char *__domainname,
269
const char *__dirname);
270
static inline char *bindtextdomain (const char *__domainname,
271
const char *__dirname)
273
return libintl_bindtextdomain (__domainname, __dirname);
276
#ifdef _INTL_REDIRECT_MACROS
277
# define bindtextdomain libintl_bindtextdomain
279
extern char *bindtextdomain (const char *__domainname, const char *__dirname)
280
_INTL_ASM (libintl_bindtextdomain);
283
/* Specify the character encoding in which the messages from the
284
DOMAINNAME message catalog will be returned. */
285
#ifdef _INTL_REDIRECT_INLINE
286
extern char *libintl_bind_textdomain_codeset (const char *__domainname,
287
const char *__codeset);
288
static inline char *bind_textdomain_codeset (const char *__domainname,
289
const char *__codeset)
291
return libintl_bind_textdomain_codeset (__domainname, __codeset);
294
#ifdef _INTL_REDIRECT_MACROS
295
# define bind_textdomain_codeset libintl_bind_textdomain_codeset
297
extern char *bind_textdomain_codeset (const char *__domainname,
298
const char *__codeset)
299
_INTL_ASM (libintl_bind_textdomain_codeset);
302
#endif /* IN_LIBGLOCALE */
305
/* Support for format strings with positions in *printf(), following the
306
POSIX/XSI specification.
307
Note: These replacements for the *printf() functions are visible only
308
in source files that #include <libintl.h> or #include "gettext.h".
309
Packages that use *printf() in source files that don't refer to _()
310
or gettext() but for which the format string could be the return value
311
of _() or gettext() need to add this #include. Oh well. */
313
#if !@HAVE_POSIX_PRINTF@
319
#if __STDC__ || defined __cplusplus || defined _MSC_VER
322
# include <varargs.h>
326
#define fprintf libintl_fprintf
327
extern int fprintf (FILE *, const char *, ...);
329
#define vfprintf libintl_vfprintf
330
extern int vfprintf (FILE *, const char *, va_list);
333
#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__
334
/* Don't break __attribute__((format(printf,M,N))).
335
This redefinition is only possible because the libc in NetBSD, Cygwin,
336
mingw does not have a function __printf__. */
337
# define libintl_printf __printf__
339
#define printf libintl_printf
340
extern int printf (const char *, ...);
342
#define vprintf libintl_vprintf
343
extern int vprintf (const char *, va_list);
346
#define sprintf libintl_sprintf
347
extern int sprintf (char *, const char *, ...);
349
#define vsprintf libintl_vsprintf
350
extern int vsprintf (char *, const char *, va_list);
355
#define snprintf libintl_snprintf
356
extern int snprintf (char *, size_t, const char *, ...);
358
#define vsnprintf libintl_vsnprintf
359
extern int vsnprintf (char *, size_t, const char *, va_list);
366
#define asprintf libintl_asprintf
367
extern int asprintf (char **, const char *, ...);
369
#define vasprintf libintl_vasprintf
370
extern int vasprintf (char **, const char *, va_list);
377
#define fwprintf libintl_fwprintf
378
extern int fwprintf (FILE *, const wchar_t *, ...);
380
#define vfwprintf libintl_vfwprintf
381
extern int vfwprintf (FILE *, const wchar_t *, va_list);
384
#define wprintf libintl_wprintf
385
extern int wprintf (const wchar_t *, ...);
387
#define vwprintf libintl_vwprintf
388
extern int vwprintf (const wchar_t *, va_list);
391
#define swprintf libintl_swprintf
392
extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
394
#define vswprintf libintl_vswprintf
395
extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
402
/* Support for relocatable packages. */
404
/* Sets the original and the current installation prefix of the package.
405
Relocation simply replaces a pathname starting with the original prefix
406
by the corresponding pathname with the current prefix instead. Both
407
prefixes should be directory names without trailing slash (i.e. use ""
409
#define libintl_set_relocation_prefix libintl_set_relocation_prefix
411
libintl_set_relocation_prefix (const char *orig_prefix,
412
const char *curr_prefix);
419
#endif /* libintl.h */