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 // already defined in config.h but not with 0/1 values
23 #undef HAVE_POSIX_PRINTF
26 #cmakedefine01 HAVE_POSIX_PRINTF
27 #cmakedefine01 HAVE_ASPRINTF
28 #cmakedefine01 HAVE_WPRINTF
32 /* The LC_MESSAGES locale category is the category used by the functions
33 gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
34 On systems that don't define it, use an arbitrary value instead.
35 On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
36 then includes <libintl.h> (i.e. this file!) and then only defines
37 LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
39 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
40 # define LC_MESSAGES 1729
43 /* We define an additional symbol to signal that we use the GNU
44 implementation of gettext. */
45 #define __USE_GNU_GETTEXT 1
47 /* Provide information about the supported file formats. Returns the
48 maximum minor revision number supported for a given major revision. */
49 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
50 ((major) == 0 ? 1 : -1)
52 /* Resolve a platform specific conflict on DJGPP. GNU gettext takes
53 precedence over _conio_gettext. */
63 /* Version number: (major<<16) + (minor<<8) + subminor */
64 #define LIBINTL_VERSION 0x001000
65 extern int libintl_version;
68 /* We redirect the functions to those prefixed with "libintl_". This is
69 necessary, because some systems define gettext/textdomain/... in the C
70 library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
71 If we used the unprefixed names, there would be cases where the
72 definition in the C library would override the one in the libintl.so
73 shared library. Recall that on ELF systems, the symbols are looked
74 up in the following order:
76 2. in the shared libraries specified on the link command line, in order,
77 3. in the dependencies of the shared libraries specified on the link
79 4. in the dlopen()ed shared libraries, in the order in which they were
81 The definition in the C library would override the one in libintl.so if
83 * -lc is given on the link command line and -lintl isn't, or
84 * -lc is given on the link command line before -lintl, or
85 * libintl.so is a dependency of a dlopen()ed shared library but not
86 linked to the executable at link time.
87 Since Solaris gettext() behaves differently than GNU gettext(), this
88 would be unacceptable.
90 The redirection happens by default through macros in C, so that &gettext
91 is independent of the compilation unit, but through inline functions in
92 C++, in order not to interfere with the name mangling of class fields or
93 class methods called 'gettext'. */
95 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
96 If he doesn't, we choose the method. A third possible method is
97 _INTL_REDIRECT_ASM, supported only by GCC. */
98 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
99 # if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
100 # define _INTL_REDIRECT_ASM
103 # define _INTL_REDIRECT_INLINE
105 # define _INTL_REDIRECT_MACROS
109 /* Auxiliary macros. */
110 #ifdef _INTL_REDIRECT_ASM
111 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
112 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
113 # define _INTL_STRINGIFY(prefix) #prefix
115 # define _INTL_ASM(cname)
118 /* Look up MSGID in the current default message catalog for the current
119 LC_MESSAGES locale. If not found, returns MSGID itself (the default
121 #ifdef _INTL_REDIRECT_INLINE
122 extern char *libintl_gettext (const char *__msgid);
123 static inline char *gettext (const char *__msgid)
125 return libintl_gettext (__msgid);
128 #ifdef _INTL_REDIRECT_MACROS
129 # define gettext libintl_gettext
131 extern char *gettext (const char *__msgid)
132 _INTL_ASM (libintl_gettext);
135 /* Look up MSGID in the DOMAINNAME message catalog for the current
136 LC_MESSAGES locale. */
137 #ifdef _INTL_REDIRECT_INLINE
138 extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
139 static inline char *dgettext (const char *__domainname, const char *__msgid)
141 return libintl_dgettext (__domainname, __msgid);
144 #ifdef _INTL_REDIRECT_MACROS
145 # define dgettext libintl_dgettext
147 extern char *dgettext (const char *__domainname, const char *__msgid)
148 _INTL_ASM (libintl_dgettext);
151 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
153 #ifdef _INTL_REDIRECT_INLINE
154 extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
156 static inline char *dcgettext (const char *__domainname, const char *__msgid,
159 return libintl_dcgettext (__domainname, __msgid, __category);
162 #ifdef _INTL_REDIRECT_MACROS
163 # define dcgettext libintl_dcgettext
165 extern char *dcgettext (const char *__domainname, const char *__msgid,
167 _INTL_ASM (libintl_dcgettext);
171 /* Similar to `gettext' but select the plural form corresponding to the
173 #ifdef _INTL_REDIRECT_INLINE
174 extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
175 unsigned long int __n);
176 static inline char *ngettext (const char *__msgid1, const char *__msgid2,
177 unsigned long int __n)
179 return libintl_ngettext (__msgid1, __msgid2, __n);
182 #ifdef _INTL_REDIRECT_MACROS
183 # define ngettext libintl_ngettext
185 extern char *ngettext (const char *__msgid1, const char *__msgid2,
186 unsigned long int __n)
187 _INTL_ASM (libintl_ngettext);
190 /* Similar to `dgettext' but select the plural form corresponding to the
192 #ifdef _INTL_REDIRECT_INLINE
193 extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
194 const char *__msgid2, unsigned long int __n);
195 static inline char *dngettext (const char *__domainname, const char *__msgid1,
196 const char *__msgid2, unsigned long int __n)
198 return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
201 #ifdef _INTL_REDIRECT_MACROS
202 # define dngettext libintl_dngettext
204 extern char *dngettext (const char *__domainname,
205 const char *__msgid1, const char *__msgid2,
206 unsigned long int __n)
207 _INTL_ASM (libintl_dngettext);
210 /* Similar to `dcgettext' but select the plural form corresponding to the
212 #ifdef _INTL_REDIRECT_INLINE
213 extern char *libintl_dcngettext (const char *__domainname,
214 const char *__msgid1, const char *__msgid2,
215 unsigned long int __n, int __category);
216 static inline char *dcngettext (const char *__domainname,
217 const char *__msgid1, const char *__msgid2,
218 unsigned long int __n, int __category)
220 return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
223 #ifdef _INTL_REDIRECT_MACROS
224 # define dcngettext libintl_dcngettext
226 extern char *dcngettext (const char *__domainname,
227 const char *__msgid1, const char *__msgid2,
228 unsigned long int __n, int __category)
229 _INTL_ASM (libintl_dcngettext);
233 #ifndef IN_LIBGLOCALE
235 /* Set the current default message catalog to DOMAINNAME.
236 If DOMAINNAME is null, return the current default.
237 If DOMAINNAME is "", reset to the default of "messages". */
238 #ifdef _INTL_REDIRECT_INLINE
239 extern char *libintl_textdomain (const char *__domainname);
240 static inline char *textdomain (const char *__domainname)
242 return libintl_textdomain (__domainname);
245 #ifdef _INTL_REDIRECT_MACROS
246 # define textdomain libintl_textdomain
248 extern char *textdomain (const char *__domainname)
249 _INTL_ASM (libintl_textdomain);
252 /* Specify that the DOMAINNAME message catalog will be found
253 in DIRNAME rather than in the system locale data base. */
254 #ifdef _INTL_REDIRECT_INLINE
255 extern char *libintl_bindtextdomain (const char *__domainname,
256 const char *__dirname);
257 static inline char *bindtextdomain (const char *__domainname,
258 const char *__dirname)
260 return libintl_bindtextdomain (__domainname, __dirname);
263 #ifdef _INTL_REDIRECT_MACROS
264 # define bindtextdomain libintl_bindtextdomain
266 extern char *bindtextdomain (const char *__domainname, const char *__dirname)
267 _INTL_ASM (libintl_bindtextdomain);
270 /* Specify the character encoding in which the messages from the
271 DOMAINNAME message catalog will be returned. */
272 #ifdef _INTL_REDIRECT_INLINE
273 extern char *libintl_bind_textdomain_codeset (const char *__domainname,
274 const char *__codeset);
275 static inline char *bind_textdomain_codeset (const char *__domainname,
276 const char *__codeset)
278 return libintl_bind_textdomain_codeset (__domainname, __codeset);
281 #ifdef _INTL_REDIRECT_MACROS
282 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
284 extern char *bind_textdomain_codeset (const char *__domainname,
285 const char *__codeset)
286 _INTL_ASM (libintl_bind_textdomain_codeset);
289 #endif /* IN_LIBGLOCALE */
292 /* Support for format strings with positions in *printf(), following the
293 POSIX/XSI specification.
294 Note: These replacements for the *printf() functions are visible only
295 in source files that #include <libintl.h> or #include "gettext.h".
296 Packages that use *printf() in source files that don't refer to _()
297 or gettext() but for which the format string could be the return value
298 of _() or gettext() need to add this #include. Oh well. */
300 #if !HAVE_POSIX_PRINTF
306 #if __STDC__ || defined __cplusplus || defined _MSC_VER
309 # include <varargs.h>
313 #define fprintf libintl_fprintf
314 extern int fprintf (FILE *, const char *, ...);
316 #define vfprintf libintl_vfprintf
317 extern int vfprintf (FILE *, const char *, va_list);
320 #if defined __NetBSD__ || defined __CYGWIN__ || defined __MINGW32__
321 /* Don't break __attribute__((format(printf,M,N))).
322 This redefinition is only possible because the libc in NetBSD, Cygwin,
323 mingw does not have a function __printf__. */
324 # define libintl_printf __printf__
326 #define printf libintl_printf
327 extern int printf (const char *, ...);
329 #define vprintf libintl_vprintf
330 extern int vprintf (const char *, va_list);
333 #define sprintf libintl_sprintf
334 extern int sprintf (char *, const char *, ...);
336 #define vsprintf libintl_vsprintf
337 extern int vsprintf (char *, const char *, va_list);
342 #define snprintf libintl_snprintf
343 extern int snprintf (char *, size_t, const char *, ...);
345 #define vsnprintf libintl_vsnprintf
346 extern int vsnprintf (char *, size_t, const char *, va_list);
353 #define asprintf libintl_asprintf
354 extern int asprintf (char **, const char *, ...);
356 #define vasprintf libintl_vasprintf
357 extern int vasprintf (char **, const char *, va_list);
364 #define fwprintf libintl_fwprintf
365 extern int fwprintf (FILE *, const wchar_t *, ...);
367 #define vfwprintf libintl_vfwprintf
368 extern int vfwprintf (FILE *, const wchar_t *, va_list);
371 #define wprintf libintl_wprintf
372 extern int wprintf (const wchar_t *, ...);
374 #define vwprintf libintl_vwprintf
375 extern int vwprintf (const wchar_t *, va_list);
378 #define swprintf libintl_swprintf
379 extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
381 #define vswprintf libintl_vswprintf
382 extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
389 /* Support for relocatable packages. */
391 /* Sets the original and the current installation prefix of the package.
392 Relocation simply replaces a pathname starting with the original prefix
393 by the corresponding pathname with the current prefix instead. Both
394 prefixes should be directory names without trailing slash (i.e. use ""
396 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
398 libintl_set_relocation_prefix (const char *orig_prefix,
399 const char *curr_prefix);
406 #endif /* libintl.h */