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)
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 #cmakedefine01 HAVE_POSIX_PRINTF
23 #cmakedefine01 HAVE_ASPRINTF
24 #cmakedefine01 HAVE_WPRINTF
28 /* The LC_MESSAGES locale category is the category used by the functions
29 gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
30 On systems that don't define it, use an arbitrary value instead.
31 On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
32 then includes <libintl.h> (i.e. this file!) and then only defines
33 LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
35 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
36 # define LC_MESSAGES 1729
39 /* We define an additional symbol to signal that we use the GNU
40 implementation of gettext. */
41 #define __USE_GNU_GETTEXT 1
43 /* Provide information about the supported file formats. Returns the
44 maximum minor revision number supported for a given major revision. */
45 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
46 ((major) == 0 ? 1 : -1)
48 /* Resolve a platform specific conflict on DJGPP. GNU gettext takes
49 precedence over _conio_gettext. */
59 /* Version number: (major<<16) + (minor<<8) + subminor */
60 #define LIBINTL_VERSION 0x001000
61 extern int libintl_version;
64 /* We redirect the functions to those prefixed with "libintl_". This is
65 necessary, because some systems define gettext/textdomain/... in the C
66 library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
67 If we used the unprefixed names, there would be cases where the
68 definition in the C library would override the one in the libintl.so
69 shared library. Recall that on ELF systems, the symbols are looked
70 up in the following order:
72 2. in the shared libraries specified on the link command line, in order,
73 3. in the dependencies of the shared libraries specified on the link
75 4. in the dlopen()ed shared libraries, in the order in which they were
77 The definition in the C library would override the one in libintl.so if
79 * -lc is given on the link command line and -lintl isn't, or
80 * -lc is given on the link command line before -lintl, or
81 * libintl.so is a dependency of a dlopen()ed shared library but not
82 linked to the executable at link time.
83 Since Solaris gettext() behaves differently than GNU gettext(), this
84 would be unacceptable.
86 The redirection happens by default through macros in C, so that &gettext
87 is independent of the compilation unit, but through inline functions in
88 C++, in order not to interfere with the name mangling of class fields or
89 class methods called 'gettext'. */
91 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
92 If he doesn't, we choose the method. A third possible method is
93 _INTL_REDIRECT_ASM, supported only by GCC. */
94 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
95 # if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
96 # define _INTL_REDIRECT_ASM
99 # define _INTL_REDIRECT_INLINE
101 # define _INTL_REDIRECT_MACROS
105 /* Auxiliary macros. */
106 #ifdef _INTL_REDIRECT_ASM
107 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
108 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
109 # define _INTL_STRINGIFY(prefix) #prefix
111 # define _INTL_ASM(cname)
114 /* Look up MSGID in the current default message catalog for the current
115 LC_MESSAGES locale. If not found, returns MSGID itself (the default
117 #ifdef _INTL_REDIRECT_INLINE
118 extern char *libintl_gettext (const char *__msgid);
119 static inline char *gettext (const char *__msgid)
121 return libintl_gettext (__msgid);
124 #ifdef _INTL_REDIRECT_MACROS
125 # define gettext libintl_gettext
127 extern char *gettext (const char *__msgid)
128 _INTL_ASM (libintl_gettext);
131 /* Look up MSGID in the DOMAINNAME message catalog for the current
132 LC_MESSAGES locale. */
133 #ifdef _INTL_REDIRECT_INLINE
134 extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
135 static inline char *dgettext (const char *__domainname, const char *__msgid)
137 return libintl_dgettext (__domainname, __msgid);
140 #ifdef _INTL_REDIRECT_MACROS
141 # define dgettext libintl_dgettext
143 extern char *dgettext (const char *__domainname, const char *__msgid)
144 _INTL_ASM (libintl_dgettext);
147 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
149 #ifdef _INTL_REDIRECT_INLINE
150 extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
152 static inline char *dcgettext (const char *__domainname, const char *__msgid,
155 return libintl_dcgettext (__domainname, __msgid, __category);
158 #ifdef _INTL_REDIRECT_MACROS
159 # define dcgettext libintl_dcgettext
161 extern char *dcgettext (const char *__domainname, const char *__msgid,
163 _INTL_ASM (libintl_dcgettext);
167 /* Similar to `gettext' but select the plural form corresponding to the
169 #ifdef _INTL_REDIRECT_INLINE
170 extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
171 unsigned long int __n);
172 static inline char *ngettext (const char *__msgid1, const char *__msgid2,
173 unsigned long int __n)
175 return libintl_ngettext (__msgid1, __msgid2, __n);
178 #ifdef _INTL_REDIRECT_MACROS
179 # define ngettext libintl_ngettext
181 extern char *ngettext (const char *__msgid1, const char *__msgid2,
182 unsigned long int __n)
183 _INTL_ASM (libintl_ngettext);
186 /* Similar to `dgettext' but select the plural form corresponding to the
188 #ifdef _INTL_REDIRECT_INLINE
189 extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
190 const char *__msgid2, unsigned long int __n);
191 static inline char *dngettext (const char *__domainname, const char *__msgid1,
192 const char *__msgid2, unsigned long int __n)
194 return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
197 #ifdef _INTL_REDIRECT_MACROS
198 # define dngettext libintl_dngettext
200 extern char *dngettext (const char *__domainname,
201 const char *__msgid1, const char *__msgid2,
202 unsigned long int __n)
203 _INTL_ASM (libintl_dngettext);
206 /* Similar to `dcgettext' but select the plural form corresponding to the
208 #ifdef _INTL_REDIRECT_INLINE
209 extern char *libintl_dcngettext (const char *__domainname,
210 const char *__msgid1, const char *__msgid2,
211 unsigned long int __n, int __category);
212 static inline char *dcngettext (const char *__domainname,
213 const char *__msgid1, const char *__msgid2,
214 unsigned long int __n, int __category)
216 return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
219 #ifdef _INTL_REDIRECT_MACROS
220 # define dcngettext libintl_dcngettext
222 extern char *dcngettext (const char *__domainname,
223 const char *__msgid1, const char *__msgid2,
224 unsigned long int __n, int __category)
225 _INTL_ASM (libintl_dcngettext);
229 #ifndef IN_LIBGLOCALE
231 /* Set the current default message catalog to DOMAINNAME.
232 If DOMAINNAME is null, return the current default.
233 If DOMAINNAME is "", reset to the default of "messages". */
234 #ifdef _INTL_REDIRECT_INLINE
235 extern char *libintl_textdomain (const char *__domainname);
236 static inline char *textdomain (const char *__domainname)
238 return libintl_textdomain (__domainname);
241 #ifdef _INTL_REDIRECT_MACROS
242 # define textdomain libintl_textdomain
244 extern char *textdomain (const char *__domainname)
245 _INTL_ASM (libintl_textdomain);
248 /* Specify that the DOMAINNAME message catalog will be found
249 in DIRNAME rather than in the system locale data base. */
250 #ifdef _INTL_REDIRECT_INLINE
251 extern char *libintl_bindtextdomain (const char *__domainname,
252 const char *__dirname);
253 static inline char *bindtextdomain (const char *__domainname,
254 const char *__dirname)
256 return libintl_bindtextdomain (__domainname, __dirname);
259 #ifdef _INTL_REDIRECT_MACROS
260 # define bindtextdomain libintl_bindtextdomain
262 extern char *bindtextdomain (const char *__domainname, const char *__dirname)
263 _INTL_ASM (libintl_bindtextdomain);
266 /* Specify the character encoding in which the messages from the
267 DOMAINNAME message catalog will be returned. */
268 #ifdef _INTL_REDIRECT_INLINE
269 extern char *libintl_bind_textdomain_codeset (const char *__domainname,
270 const char *__codeset);
271 static inline char *bind_textdomain_codeset (const char *__domainname,
272 const char *__codeset)
274 return libintl_bind_textdomain_codeset (__domainname, __codeset);
277 #ifdef _INTL_REDIRECT_MACROS
278 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
280 extern char *bind_textdomain_codeset (const char *__domainname,
281 const char *__codeset)
282 _INTL_ASM (libintl_bind_textdomain_codeset);
285 #endif /* IN_LIBGLOCALE */
288 /* Support for format strings with positions in *printf(), following the
289 POSIX/XSI specification.
290 Note: These replacements for the *printf() functions are visible only
291 in source files that #include <libintl.h> or #include "gettext.h".
292 Packages that use *printf() in source files that don't refer to _()
293 or gettext() but for which the format string could be the return value
294 of _() or gettext() need to add this #include. Oh well. */
296 #if !HAVE_POSIX_PRINTF
302 #if __STDC__ || defined __cplusplus || defined _MSC_VER
305 # include <varargs.h>
309 #define fprintf libintl_fprintf
310 extern int fprintf (FILE *, const char *, ...);
312 #define vfprintf libintl_vfprintf
313 extern int vfprintf (FILE *, const char *, va_list);
316 #if defined __NetBSD__ || defined __CYGWIN__ || defined __MINGW32__
317 /* Don't break __attribute__((format(printf,M,N))).
318 This redefinition is only possible because the libc in NetBSD, Cygwin,
319 mingw does not have a function __printf__. */
320 # define libintl_printf __printf__
322 #define printf libintl_printf
323 extern int printf (const char *, ...);
325 #define vprintf libintl_vprintf
326 extern int vprintf (const char *, va_list);
329 #define sprintf libintl_sprintf
330 extern int sprintf (char *, const char *, ...);
332 #define vsprintf libintl_vsprintf
333 extern int vsprintf (char *, const char *, va_list);
338 #define snprintf libintl_snprintf
339 extern int snprintf (char *, size_t, const char *, ...);
341 #define vsnprintf libintl_vsnprintf
342 extern int vsnprintf (char *, size_t, const char *, va_list);
349 #define asprintf libintl_asprintf
350 extern int asprintf (char **, const char *, ...);
352 #define vasprintf libintl_vasprintf
353 extern int vasprintf (char **, const char *, va_list);
360 #define fwprintf libintl_fwprintf
361 extern int fwprintf (FILE *, const wchar_t *, ...);
363 #define vfwprintf libintl_vfwprintf
364 extern int vfwprintf (FILE *, const wchar_t *, va_list);
367 #define wprintf libintl_wprintf
368 extern int wprintf (const wchar_t *, ...);
370 #define vwprintf libintl_vwprintf
371 extern int vwprintf (const wchar_t *, va_list);
374 #define swprintf libintl_swprintf
375 extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
377 #define vswprintf libintl_vswprintf
378 extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
385 /* Support for relocatable packages. */
387 /* Sets the original and the current installation prefix of the package.
388 Relocation simply replaces a pathname starting with the original prefix
389 by the corresponding pathname with the current prefix instead. Both
390 prefixes should be directory names without trailing slash (i.e. use ""
392 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
394 libintl_set_relocation_prefix (const char *orig_prefix,
395 const char *curr_prefix);
402 #endif /* libintl.h */