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,
26 /* The LC_MESSAGES locale category is the category used by the functions
27 gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
28 On systems that don't define it, use an arbitrary value instead.
29 On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
30 then includes <libintl.h> (i.e. this file!) and then only defines
31 LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
33 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
34 # define LC_MESSAGES 1729
37 /* We define an additional symbol to signal that we use the GNU
38 implementation of gettext. */
39 #define __USE_GNU_GETTEXT 1
41 /* Provide information about the supported file formats. Returns the
42 maximum minor revision number supported for a given major revision. */
43 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
44 ((major) == 0 ? 1 : -1)
46 /* Resolve a platform specific conflict on DJGPP. GNU gettext takes
47 precedence over _conio_gettext. */
57 /* Version number: (major<<16) + (minor<<8) + subminor */
58 #define LIBINTL_VERSION 0x001000
59 extern int libintl_version;
62 /* We redirect the functions to those prefixed with "libintl_". This is
63 necessary, because some systems define gettext/textdomain/... in the C
64 library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
65 If we used the unprefixed names, there would be cases where the
66 definition in the C library would override the one in the libintl.so
67 shared library. Recall that on ELF systems, the symbols are looked
68 up in the following order:
70 2. in the shared libraries specified on the link command line, in order,
71 3. in the dependencies of the shared libraries specified on the link
73 4. in the dlopen()ed shared libraries, in the order in which they were
75 The definition in the C library would override the one in libintl.so if
77 * -lc is given on the link command line and -lintl isn't, or
78 * -lc is given on the link command line before -lintl, or
79 * libintl.so is a dependency of a dlopen()ed shared library but not
80 linked to the executable at link time.
81 Since Solaris gettext() behaves differently than GNU gettext(), this
82 would be unacceptable.
84 The redirection happens by default through macros in C, so that &gettext
85 is independent of the compilation unit, but through inline functions in
86 C++, in order not to interfere with the name mangling of class fields or
87 class methods called 'gettext'. */
89 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
90 If he doesn't, we choose the method. A third possible method is
91 _INTL_REDIRECT_ASM, supported only by GCC. */
92 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
93 # if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
94 # define _INTL_REDIRECT_ASM
97 # define _INTL_REDIRECT_INLINE
99 # define _INTL_REDIRECT_MACROS
103 /* Auxiliary macros. */
104 #ifdef _INTL_REDIRECT_ASM
105 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
106 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
107 # define _INTL_STRINGIFY(prefix) #prefix
109 # define _INTL_ASM(cname)
112 /* Look up MSGID in the current default message catalog for the current
113 LC_MESSAGES locale. If not found, returns MSGID itself (the default
115 #ifdef _INTL_REDIRECT_INLINE
116 extern char *libintl_gettext (const char *__msgid);
117 static inline char *gettext (const char *__msgid)
119 return libintl_gettext (__msgid);
122 #ifdef _INTL_REDIRECT_MACROS
123 # define gettext libintl_gettext
125 extern char *gettext (const char *__msgid)
126 _INTL_ASM (libintl_gettext);
129 /* Look up MSGID in the DOMAINNAME message catalog for the current
130 LC_MESSAGES locale. */
131 #ifdef _INTL_REDIRECT_INLINE
132 extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
133 static inline char *dgettext (const char *__domainname, const char *__msgid)
135 return libintl_dgettext (__domainname, __msgid);
138 #ifdef _INTL_REDIRECT_MACROS
139 # define dgettext libintl_dgettext
141 extern char *dgettext (const char *__domainname, const char *__msgid)
142 _INTL_ASM (libintl_dgettext);
145 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
147 #ifdef _INTL_REDIRECT_INLINE
148 extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
150 static inline char *dcgettext (const char *__domainname, const char *__msgid,
153 return libintl_dcgettext (__domainname, __msgid, __category);
156 #ifdef _INTL_REDIRECT_MACROS
157 # define dcgettext libintl_dcgettext
159 extern char *dcgettext (const char *__domainname, const char *__msgid,
161 _INTL_ASM (libintl_dcgettext);
165 /* Similar to `gettext' but select the plural form corresponding to the
167 #ifdef _INTL_REDIRECT_INLINE
168 extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
169 unsigned long int __n);
170 static inline char *ngettext (const char *__msgid1, const char *__msgid2,
171 unsigned long int __n)
173 return libintl_ngettext (__msgid1, __msgid2, __n);
176 #ifdef _INTL_REDIRECT_MACROS
177 # define ngettext libintl_ngettext
179 extern char *ngettext (const char *__msgid1, const char *__msgid2,
180 unsigned long int __n)
181 _INTL_ASM (libintl_ngettext);
184 /* Similar to `dgettext' but select the plural form corresponding to the
186 #ifdef _INTL_REDIRECT_INLINE
187 extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
188 const char *__msgid2, unsigned long int __n);
189 static inline char *dngettext (const char *__domainname, const char *__msgid1,
190 const char *__msgid2, unsigned long int __n)
192 return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
195 #ifdef _INTL_REDIRECT_MACROS
196 # define dngettext libintl_dngettext
198 extern char *dngettext (const char *__domainname,
199 const char *__msgid1, const char *__msgid2,
200 unsigned long int __n)
201 _INTL_ASM (libintl_dngettext);
204 /* Similar to `dcgettext' but select the plural form corresponding to the
206 #ifdef _INTL_REDIRECT_INLINE
207 extern char *libintl_dcngettext (const char *__domainname,
208 const char *__msgid1, const char *__msgid2,
209 unsigned long int __n, int __category);
210 static inline char *dcngettext (const char *__domainname,
211 const char *__msgid1, const char *__msgid2,
212 unsigned long int __n, int __category)
214 return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
217 #ifdef _INTL_REDIRECT_MACROS
218 # define dcngettext libintl_dcngettext
220 extern char *dcngettext (const char *__domainname,
221 const char *__msgid1, const char *__msgid2,
222 unsigned long int __n, int __category)
223 _INTL_ASM (libintl_dcngettext);
227 #ifndef IN_LIBGLOCALE
229 /* Set the current default message catalog to DOMAINNAME.
230 If DOMAINNAME is null, return the current default.
231 If DOMAINNAME is "", reset to the default of "messages". */
232 #ifdef _INTL_REDIRECT_INLINE
233 extern char *libintl_textdomain (const char *__domainname);
234 static inline char *textdomain (const char *__domainname)
236 return libintl_textdomain (__domainname);
239 #ifdef _INTL_REDIRECT_MACROS
240 # define textdomain libintl_textdomain
242 extern char *textdomain (const char *__domainname)
243 _INTL_ASM (libintl_textdomain);
246 /* Specify that the DOMAINNAME message catalog will be found
247 in DIRNAME rather than in the system locale data base. */
248 #ifdef _INTL_REDIRECT_INLINE
249 extern char *libintl_bindtextdomain (const char *__domainname,
250 const char *__dirname);
251 static inline char *bindtextdomain (const char *__domainname,
252 const char *__dirname)
254 return libintl_bindtextdomain (__domainname, __dirname);
257 #ifdef _INTL_REDIRECT_MACROS
258 # define bindtextdomain libintl_bindtextdomain
260 extern char *bindtextdomain (const char *__domainname, const char *__dirname)
261 _INTL_ASM (libintl_bindtextdomain);
264 /* Specify the character encoding in which the messages from the
265 DOMAINNAME message catalog will be returned. */
266 #ifdef _INTL_REDIRECT_INLINE
267 extern char *libintl_bind_textdomain_codeset (const char *__domainname,
268 const char *__codeset);
269 static inline char *bind_textdomain_codeset (const char *__domainname,
270 const char *__codeset)
272 return libintl_bind_textdomain_codeset (__domainname, __codeset);
275 #ifdef _INTL_REDIRECT_MACROS
276 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
278 extern char *bind_textdomain_codeset (const char *__domainname,
279 const char *__codeset)
280 _INTL_ASM (libintl_bind_textdomain_codeset);
283 #endif /* IN_LIBGLOCALE */
286 /* Support for format strings with positions in *printf(), following the
287 POSIX/XSI specification.
288 Note: These replacements for the *printf() functions are visible only
289 in source files that #include <libintl.h> or #include "gettext.h".
290 Packages that use *printf() in source files that don't refer to _()
291 or gettext() but for which the format string could be the return value
292 of _() or gettext() need to add this #include. Oh well. */
294 #if !HAVE_POSIX_PRINTF
300 #if __STDC__ || defined __cplusplus || defined _MSC_VER
303 # include <varargs.h>
307 #define fprintf libintl_fprintf
308 extern int fprintf (FILE *, const char *, ...);
310 #define vfprintf libintl_vfprintf
311 extern int vfprintf (FILE *, const char *, va_list);
314 #if defined __NetBSD__ || defined __CYGWIN__ || defined __MINGW32__
315 /* Don't break __attribute__((format(printf,M,N))).
316 This redefinition is only possible because the libc in NetBSD, Cygwin,
317 mingw does not have a function __printf__. */
318 # define libintl_printf __printf__
320 #define printf libintl_printf
321 extern int printf (const char *, ...);
323 #define vprintf libintl_vprintf
324 extern int vprintf (const char *, va_list);
327 #define sprintf libintl_sprintf
328 extern int sprintf (char *, const char *, ...);
330 #define vsprintf libintl_vsprintf
331 extern int vsprintf (char *, const char *, va_list);
336 #define snprintf libintl_snprintf
337 extern int snprintf (char *, size_t, const char *, ...);
339 #define vsnprintf libintl_vsnprintf
340 extern int vsnprintf (char *, size_t, const char *, va_list);
347 #define asprintf libintl_asprintf
348 extern int asprintf (char **, const char *, ...);
350 #define vasprintf libintl_vasprintf
351 extern int vasprintf (char **, const char *, va_list);
358 #define fwprintf libintl_fwprintf
359 extern int fwprintf (FILE *, const wchar_t *, ...);
361 #define vfwprintf libintl_vfwprintf
362 extern int vfwprintf (FILE *, const wchar_t *, va_list);
365 #define wprintf libintl_wprintf
366 extern int wprintf (const wchar_t *, ...);
368 #define vwprintf libintl_vwprintf
369 extern int vwprintf (const wchar_t *, va_list);
372 #define swprintf libintl_swprintf
373 extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
375 #define vswprintf libintl_vswprintf
376 extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
383 /* Support for relocatable packages. */
385 /* Sets the original and the current installation prefix of the package.
386 Relocation simply replaces a pathname starting with the original prefix
387 by the corresponding pathname with the current prefix instead. Both
388 prefixes should be directory names without trailing slash (i.e. use ""
390 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
392 libintl_set_relocation_prefix (const char *orig_prefix,
393 const char *curr_prefix);
400 #endif /* libintl.h */