1 /* Message catalogs for internationalization.
\r
2 Copyright (C) 1995-1997, 2000-2010 Free Software Foundation, Inc.
\r
4 This program is free software; you can redistribute it and/or modify it
\r
5 under the terms of the GNU Library General Public License as published
\r
6 by the Free Software Foundation; either version 2, or (at your option)
\r
9 This program is distributed in the hope that it will be useful,
\r
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
12 Library General Public License for more details.
\r
14 You should have received a copy of the GNU Library General Public
\r
15 License along with this program; if not, write to the Free Software
\r
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
\r
20 #define _LIBINTL_H 1
\r
23 #define inline __inline
\r
27 #if (defined __APPLE__ && defined __MACH__) && 0
\r
28 # include <xlocale.h>
\r
31 /* The LC_MESSAGES locale category is the category used by the functions
\r
32 gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
\r
33 On systems that don't define it, use an arbitrary value instead.
\r
34 On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
\r
35 then includes <libintl.h> (i.e. this file!) and then only defines
\r
36 LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
\r
38 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
\r
39 # define LC_MESSAGES 1729
\r
42 /* We define an additional symbol to signal that we use the GNU
\r
43 implementation of gettext. */
\r
44 #define __USE_GNU_GETTEXT 1
\r
46 /* Provide information about the supported file formats. Returns the
\r
47 maximum minor revision number supported for a given major revision. */
\r
48 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
\r
49 ((major) == 0 || (major) == 1 ? 1 : -1)
\r
51 /* Resolve a platform specific conflict on DJGPP. GNU gettext takes
\r
52 precedence over _conio_gettext. */
\r
62 /* Version number: (major<<16) + (minor<<8) + subminor */
\r
63 #define LIBINTL_VERSION 0x001200
\r
64 extern int libintl_version;
\r
67 /* We redirect the functions to those prefixed with "libintl_". This is
\r
68 necessary, because some systems define gettext/textdomain/... in the C
\r
69 library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
\r
70 If we used the unprefixed names, there would be cases where the
\r
71 definition in the C library would override the one in the libintl.so
\r
72 shared library. Recall that on ELF systems, the symbols are looked
\r
73 up in the following order:
\r
74 1. in the executable,
\r
75 2. in the shared libraries specified on the link command line, in order,
\r
76 3. in the dependencies of the shared libraries specified on the link
\r
78 4. in the dlopen()ed shared libraries, in the order in which they were
\r
80 The definition in the C library would override the one in libintl.so if
\r
82 * -lc is given on the link command line and -lintl isn't, or
\r
83 * -lc is given on the link command line before -lintl, or
\r
84 * libintl.so is a dependency of a dlopen()ed shared library but not
\r
85 linked to the executable at link time.
\r
86 Since Solaris gettext() behaves differently than GNU gettext(), this
\r
87 would be unacceptable.
\r
89 The redirection happens by default through macros in C, so that &gettext
\r
90 is independent of the compilation unit, but through inline functions in
\r
91 C++, in order not to interfere with the name mangling of class fields or
\r
92 class methods called 'gettext'. */
\r
94 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
\r
95 If he doesn't, we choose the method. A third possible method is
\r
96 _INTL_REDIRECT_ASM, supported only by GCC. */
\r
97 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
\r
98 # if defined __GNUC__ && __GNUC__ >= 2 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
\r
99 # define _INTL_REDIRECT_ASM
\r
101 # ifdef __cplusplus
\r
102 # define _INTL_REDIRECT_INLINE
\r
104 # define _INTL_REDIRECT_MACROS
\r
108 /* Auxiliary macros. */
\r
109 #ifdef _INTL_REDIRECT_ASM
\r
110 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
\r
111 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
\r
112 # define _INTL_STRINGIFY(prefix) #prefix
\r
114 # define _INTL_ASM(cname)
\r
117 /* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
\r
118 its n-th argument literally. This enables GCC to warn for example about
\r
119 printf (gettext ("foo %y")). */
\r
120 #if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1 && defined __cplusplus)
\r
121 # define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
\r
123 # define _INTL_MAY_RETURN_STRING_ARG(n)
\r
126 /* Look up MSGID in the current default message catalog for the current
\r
127 LC_MESSAGES locale. If not found, returns MSGID itself (the default
\r
129 #ifdef _INTL_REDIRECT_INLINE
\r
130 extern char *libintl_gettext (const char *__msgid)
\r
131 _INTL_MAY_RETURN_STRING_ARG (1);
\r
132 static inline char *gettext (const char *__msgid)
\r
134 return libintl_gettext (__msgid);
\r
137 #ifdef _INTL_REDIRECT_MACROS
\r
138 # define gettext libintl_gettext
\r
140 extern char *gettext (const char *__msgid)
\r
141 _INTL_ASM (libintl_gettext)
\r
142 _INTL_MAY_RETURN_STRING_ARG (1);
\r
145 /* Look up MSGID in the DOMAINNAME message catalog for the current
\r
146 LC_MESSAGES locale. */
\r
147 #ifdef _INTL_REDIRECT_INLINE
\r
148 extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
\r
149 _INTL_MAY_RETURN_STRING_ARG (2);
\r
150 static inline char *dgettext (const char *__domainname, const char *__msgid)
\r
152 //return libintl_dgettext (__domainname, __msgid);
\r
156 #ifdef _INTL_REDIRECT_MACROS
\r
157 # define dgettext libintl_dgettext
\r
159 extern char *dgettext (const char *__domainname, const char *__msgid)
\r
160 _INTL_ASM (libintl_dgettext)
\r
161 _INTL_MAY_RETURN_STRING_ARG (2);
\r
164 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
\r
166 #ifdef _INTL_REDIRECT_INLINE
\r
167 extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
\r
169 _INTL_MAY_RETURN_STRING_ARG (2);
\r
170 static inline char *dcgettext (const char *__domainname, const char *__msgid,
\r
173 return libintl_dcgettext (__domainname, __msgid, __category);
\r
176 #ifdef _INTL_REDIRECT_MACROS
\r
177 # define dcgettext libintl_dcgettext
\r
179 extern char *dcgettext (const char *__domainname, const char *__msgid,
\r
181 _INTL_ASM (libintl_dcgettext)
\r
182 _INTL_MAY_RETURN_STRING_ARG (2);
\r
186 /* Similar to `gettext' but select the plural form corresponding to the
\r
188 #ifdef _INTL_REDIRECT_INLINE
\r
189 extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
\r
190 unsigned long int __n)
\r
191 _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
\r
192 static inline char *ngettext (const char *__msgid1, const char *__msgid2,
\r
193 unsigned long int __n)
\r
195 return libintl_ngettext (__msgid1, __msgid2, __n);
\r
198 #ifdef _INTL_REDIRECT_MACROS
\r
199 # define ngettext libintl_ngettext
\r
201 extern char *ngettext (const char *__msgid1, const char *__msgid2,
\r
202 unsigned long int __n)
\r
203 _INTL_ASM (libintl_ngettext)
\r
204 _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
\r
207 /* Similar to `dgettext' but select the plural form corresponding to the
\r
209 #ifdef _INTL_REDIRECT_INLINE
\r
210 extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
\r
211 const char *__msgid2, unsigned long int __n)
\r
212 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
\r
213 static inline char *dngettext (const char *__domainname, const char *__msgid1,
\r
214 const char *__msgid2, unsigned long int __n)
\r
216 return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
\r
219 #ifdef _INTL_REDIRECT_MACROS
\r
220 # define dngettext libintl_dngettext
\r
222 extern char *dngettext (const char *__domainname,
\r
223 const char *__msgid1, const char *__msgid2,
\r
224 unsigned long int __n)
\r
225 _INTL_ASM (libintl_dngettext)
\r
226 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
\r
229 /* Similar to `dcgettext' but select the plural form corresponding to the
\r
231 #ifdef _INTL_REDIRECT_INLINE
\r
232 extern char *libintl_dcngettext (const char *__domainname,
\r
233 const char *__msgid1, const char *__msgid2,
\r
234 unsigned long int __n, int __category)
\r
235 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
\r
236 static inline char *dcngettext (const char *__domainname,
\r
237 const char *__msgid1, const char *__msgid2,
\r
238 unsigned long int __n, int __category)
\r
240 return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
\r
243 #ifdef _INTL_REDIRECT_MACROS
\r
244 # define dcngettext libintl_dcngettext
\r
246 extern char *dcngettext (const char *__domainname,
\r
247 const char *__msgid1, const char *__msgid2,
\r
248 unsigned long int __n, int __category)
\r
249 _INTL_ASM (libintl_dcngettext)
\r
250 _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
\r
254 #ifndef IN_LIBGLOCALE
\r
256 /* Set the current default message catalog to DOMAINNAME.
\r
257 If DOMAINNAME is null, return the current default.
\r
258 If DOMAINNAME is "", reset to the default of "messages". */
\r
259 #ifdef _INTL_REDIRECT_INLINE
\r
260 extern char *libintl_textdomain (const char *__domainname);
\r
261 static inline char *textdomain (const char *__domainname)
\r
263 return libintl_textdomain (__domainname);
\r
266 #ifdef _INTL_REDIRECT_MACROS
\r
267 # define textdomain libintl_textdomain
\r
269 extern char *textdomain (const char *__domainname)
\r
270 _INTL_ASM (libintl_textdomain);
\r
273 /* Specify that the DOMAINNAME message catalog will be found
\r
274 in DIRNAME rather than in the system locale data base. */
\r
275 #ifdef _INTL_REDIRECT_INLINE
\r
276 extern char *libintl_bindtextdomain (const char *__domainname,
\r
277 const char *__dirname);
\r
278 static inline char *bindtextdomain (const char *__domainname,
\r
279 const char *__dirname)
\r
281 return libintl_bindtextdomain (__domainname, __dirname);
\r
284 #ifdef _INTL_REDIRECT_MACROS
\r
285 # define bindtextdomain libintl_bindtextdomain
\r
287 extern char *bindtextdomain (const char *__domainname, const char *__dirname)
\r
288 _INTL_ASM (libintl_bindtextdomain);
\r
291 /* Specify the character encoding in which the messages from the
\r
292 DOMAINNAME message catalog will be returned. */
\r
293 #ifdef _INTL_REDIRECT_INLINE
\r
294 extern char *libintl_bind_textdomain_codeset (const char *__domainname,
\r
295 const char *__codeset);
\r
296 static inline char *bind_textdomain_codeset (const char *__domainname,
\r
297 const char *__codeset)
\r
299 return libintl_bind_textdomain_codeset (__domainname, __codeset);
\r
302 #ifdef _INTL_REDIRECT_MACROS
\r
303 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
\r
305 extern char *bind_textdomain_codeset (const char *__domainname,
\r
306 const char *__codeset)
\r
307 _INTL_ASM (libintl_bind_textdomain_codeset);
\r
310 #endif /* IN_LIBGLOCALE */
\r
313 /* Support for format strings with positions in *printf(), following the
\r
314 POSIX/XSI specification.
\r
315 Note: These replacements for the *printf() functions are visible only
\r
316 in source files that #include <libintl.h> or #include "gettext.h".
\r
317 Packages that use *printf() in source files that don't refer to _()
\r
318 or gettext() but for which the format string could be the return value
\r
319 of _() or gettext() need to add this #include. Oh well. */
\r
324 #include <stddef.h>
\r
327 #if (defined __STDC__ && __STDC__) || defined __cplusplus || defined _MSC_VER
\r
328 # include <stdarg.h>
\r
330 # include <varargs.h>
\r
333 #if !(defined fprintf && defined _GL_STDIO_H) /* don't override gnulib */
\r
335 #define fprintf libintl_fprintf
\r
336 extern int fprintf (FILE *, const char *, ...);
\r
338 #if !(defined vfprintf && defined _GL_STDIO_H) /* don't override gnulib */
\r
340 #define vfprintf libintl_vfprintf
\r
341 extern int vfprintf (FILE *, const char *, va_list);
\r
344 #if !(defined printf && defined _GL_STDIO_H) /* don't override gnulib */
\r
346 #if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__
\r
347 /* Don't break __attribute__((format(printf,M,N))).
\r
348 This redefinition is only possible because the libc in NetBSD, Cygwin,
\r
349 mingw does not have a function __printf__. */
\r
350 # define libintl_printf __printf__
\r
352 #define printf libintl_printf
\r
353 extern int printf (const char *, ...);
\r
355 #if !(defined vprintf && defined _GL_STDIO_H) /* don't override gnulib */
\r
357 #define vprintf libintl_vprintf
\r
358 extern int vprintf (const char *, va_list);
\r
361 #if !(defined sprintf && defined _GL_STDIO_H) /* don't override gnulib */
\r
363 #define sprintf libintl_sprintf
\r
364 extern int sprintf (char *, const char *, ...);
\r
366 #if !(defined vsprintf && defined _GL_STDIO_H) /* don't override gnulib */
\r
368 #define vsprintf libintl_vsprintf
\r
369 extern int vsprintf (char *, const char *, va_list);
\r
374 #if !(defined snprintf && defined _GL_STDIO_H) /* don't override gnulib */
\r
376 #define snprintf libintl_snprintf
\r
377 extern int snprintf (char *, size_t, const char *, ...);
\r
379 #if !(defined vsnprintf && defined _GL_STDIO_H) /* don't override gnulib */
\r
381 #define vsnprintf libintl_vsnprintf
\r
382 extern int vsnprintf (char *, size_t, const char *, va_list);
\r
389 #if !(defined asprintf && defined _GL_STDIO_H) /* don't override gnulib */
\r
391 #define asprintf libintl_asprintf
\r
392 extern int asprintf (char **, const char *, ...);
\r
394 #if !(defined vasprintf && defined _GL_STDIO_H) /* don't override gnulib */
\r
396 #define vasprintf libintl_vasprintf
\r
397 extern int vasprintf (char **, const char *, va_list);
\r
405 #define fwprintf libintl_fwprintf
\r
406 extern int fwprintf (FILE *, const wchar_t *, ...);
\r
408 #define vfwprintf libintl_vfwprintf
\r
409 extern int vfwprintf (FILE *, const wchar_t *, va_list);
\r
412 #define wprintf libintl_wprintf
\r
413 extern int wprintf (const wchar_t *, ...);
\r
415 #define vwprintf libintl_vwprintf
\r
416 extern int vwprintf (const wchar_t *, va_list);
\r
419 #define swprintf libintl_swprintf
\r
420 extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
\r
422 #define vswprintf libintl_vswprintf
\r
423 extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
\r
430 /* Support for the locale chosen by the user. */
\r
431 #if (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
\r
434 #define setlocale libintl_setlocale
\r
435 extern char *setlocale (int, const char *);
\r
440 #define newlocale libintl_newlocale
\r
441 extern locale_t newlocale (int, const char *, locale_t);
\r
448 /* Support for relocatable packages. */
\r
450 /* Sets the original and the current installation prefix of the package.
\r
451 Relocation simply replaces a pathname starting with the original prefix
\r
452 by the corresponding pathname with the current prefix instead. Both
\r
453 prefixes should be directory names without trailing slash (i.e. use ""
\r
454 instead of "/"). */
\r
455 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
\r
457 libintl_set_relocation_prefix (const char *orig_prefix,
\r
458 const char *curr_prefix);
\r
465 #endif /* libintl.h */
\r