1 /* Message catalogs for internationalization.
2 Copyright (C) 1995-1997, 2000-2004 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 #ifdef BUILDING_LIBINTL
23 #define LIBINTL_DLL_EXPORTED __declspec(dllexport)
25 #define LIBINTL_DLL_EXPORTED __declspec(dllimport)
30 /* The LC_MESSAGES locale category is the category used by the functions
31 gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
32 On systems that don't define it, use an arbitrary value instead.
33 On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
34 then includes <libintl.h> (i.e. this file!) and then only defines
35 LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
37 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
38 # define LC_MESSAGES 1729
41 /* We define an additional symbol to signal that we use the GNU
42 implementation of gettext. */
43 #define __USE_GNU_GETTEXT 1
45 /* Provide information about the supported file formats. Returns the
46 maximum minor revision number supported for a given major revision. */
47 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
48 ((major) == 0 || (major) == 1 ? 1 : -1)
50 /* Resolve a platform specific conflict on DJGPP. GNU gettext takes
51 precedence over _conio_gettext. */
61 /* We redirect the functions to those prefixed with "libintl_". This is
62 necessary, because some systems define gettext/textdomain/... in the C
63 library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
64 If we used the unprefixed names, there would be cases where the
65 definition in the C library would override the one in the libintl.so
66 shared library. Recall that on ELF systems, the symbols are looked
67 up in the following order:
69 2. in the shared libraries specified on the link command line, in order,
70 3. in the dependencies of the shared libraries specified on the link
72 4. in the dlopen()ed shared libraries, in the order in which they were
74 The definition in the C library would override the one in libintl.so if
76 * -lc is given on the link command line and -lintl isn't, or
77 * -lc is given on the link command line before -lintl, or
78 * libintl.so is a dependency of a dlopen()ed shared library but not
79 linked to the executable at link time.
80 Since Solaris gettext() behaves differently than GNU gettext(), this
81 would be unacceptable.
83 The redirection happens by default through macros in C, so that &gettext
84 is independent of the compilation unit, but through inline functions in
85 C++, in order not to interfere with the name mangling of class fields or
86 class methods called 'gettext'. */
88 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
89 If he doesn't, we choose the method. A third possible method is
90 _INTL_REDIRECT_ASM, supported only by GCC. */
91 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
92 # if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
93 # define _INTL_REDIRECT_ASM
96 # define _INTL_REDIRECT_INLINE
98 # define _INTL_REDIRECT_MACROS
102 /* Auxiliary macros. */
103 #ifdef _INTL_REDIRECT_ASM
104 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
105 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
106 # define _INTL_STRINGIFY(prefix) #prefix
108 # define _INTL_ASM(cname)
111 /* Look up MSGID in the current default message catalog for the current
112 LC_MESSAGES locale. If not found, returns MSGID itself (the default
114 #ifdef _INTL_REDIRECT_INLINE
115 extern LIBINTL_DLL_EXPORTED
char *libintl_gettext (const char *__msgid
);
116 static inline char *gettext (const char *__msgid
)
118 return libintl_gettext (__msgid
);
121 #ifdef _INTL_REDIRECT_MACROS
122 # define gettext libintl_gettext
124 extern LIBINTL_DLL_EXPORTED
char *gettext (const char *__msgid
)
125 _INTL_ASM (libintl_gettext
);
128 /* Look up MSGID in the DOMAINNAME message catalog for the current
129 LC_MESSAGES locale. */
130 #ifdef _INTL_REDIRECT_INLINE
131 extern LIBINTL_DLL_EXPORTED
char *libintl_dgettext (const char *__domainname
, const char *__msgid
);
132 static inline char *dgettext (const char *__domainname
, const char *__msgid
)
134 return libintl_dgettext (__domainname
, __msgid
);
137 #ifdef _INTL_REDIRECT_MACROS
138 # define dgettext libintl_dgettext
140 extern LIBINTL_DLL_EXPORTED
char *dgettext (const char *__domainname
, const char *__msgid
)
141 _INTL_ASM (libintl_dgettext
);
144 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
146 #ifdef _INTL_REDIRECT_INLINE
147 extern LIBINTL_DLL_EXPORTED
char *libintl_dcgettext (const char *__domainname
, const char *__msgid
,
149 static inline char *dcgettext (const char *__domainname
, const char *__msgid
,
152 return libintl_dcgettext (__domainname
, __msgid
, __category
);
155 #ifdef _INTL_REDIRECT_MACROS
156 # define dcgettext libintl_dcgettext
158 extern LIBINTL_DLL_EXPORTED
char *dcgettext (const char *__domainname
, const char *__msgid
,
160 _INTL_ASM (libintl_dcgettext
);
164 /* Similar to `gettext' but select the plural form corresponding to the
166 #ifdef _INTL_REDIRECT_INLINE
167 extern LIBINTL_DLL_EXPORTED
char *libintl_ngettext (const char *__msgid1
, const char *__msgid2
,
168 unsigned long int __n
);
169 static inline char *ngettext (const char *__msgid1
, const char *__msgid2
,
170 unsigned long int __n
)
172 return libintl_ngettext (__msgid1
, __msgid2
, __n
);
175 #ifdef _INTL_REDIRECT_MACROS
176 # define ngettext libintl_ngettext
178 extern LIBINTL_DLL_EXPORTED
char *ngettext (const char *__msgid1
, const char *__msgid2
,
179 unsigned long int __n
)
180 _INTL_ASM (libintl_ngettext
);
183 /* Similar to `dgettext' but select the plural form corresponding to the
185 #ifdef _INTL_REDIRECT_INLINE
186 extern LIBINTL_DLL_EXPORTED
char *libintl_dngettext (const char *__domainname
, const char *__msgid1
,
187 const char *__msgid2
, unsigned long int __n
);
188 static inline char *dngettext (const char *__domainname
, const char *__msgid1
,
189 const char *__msgid2
, unsigned long int __n
)
191 return libintl_dngettext (__domainname
, __msgid1
, __msgid2
, __n
);
194 #ifdef _INTL_REDIRECT_MACROS
195 # define dngettext libintl_dngettext
197 extern LIBINTL_DLL_EXPORTED
char *dngettext (const char *__domainname
,
198 const char *__msgid1
, const char *__msgid2
,
199 unsigned long int __n
)
200 _INTL_ASM (libintl_dngettext
);
203 /* Similar to `dcgettext' but select the plural form corresponding to the
205 #ifdef _INTL_REDIRECT_INLINE
206 extern LIBINTL_DLL_EXPORTED
char *libintl_dcngettext (const char *__domainname
,
207 const char *__msgid1
, const char *__msgid2
,
208 unsigned long int __n
, int __category
);
209 static inline char *dcngettext (const char *__domainname
,
210 const char *__msgid1
, const char *__msgid2
,
211 unsigned long int __n
, int __category
)
213 return libintl_dcngettext (__domainname
, __msgid1
, __msgid2
, __n
, __category
);
216 #ifdef _INTL_REDIRECT_MACROS
217 # define dcngettext libintl_dcngettext
219 extern LIBINTL_DLL_EXPORTED
char *dcngettext (const char *__domainname
,
220 const char *__msgid1
, const char *__msgid2
,
221 unsigned long int __n
, int __category
)
222 _INTL_ASM (libintl_dcngettext
);
226 /* Set the current default message catalog to DOMAINNAME.
227 If DOMAINNAME is null, return the current default.
228 If DOMAINNAME is "", reset to the default of "messages". */
229 #ifdef _INTL_REDIRECT_INLINE
230 extern LIBINTL_DLL_EXPORTED
char *libintl_textdomain (const char *__domainname
);
231 static inline char *textdomain (const char *__domainname
)
233 return libintl_textdomain (__domainname
);
236 #ifdef _INTL_REDIRECT_MACROS
237 # define textdomain libintl_textdomain
239 extern LIBINTL_DLL_EXPORTED
char *textdomain (const char *__domainname
)
240 _INTL_ASM (libintl_textdomain
);
243 /* Specify that the DOMAINNAME message catalog will be found
244 in DIRNAME rather than in the system locale data base. */
245 #ifdef _INTL_REDIRECT_INLINE
246 extern LIBINTL_DLL_EXPORTED
char *libintl_bindtextdomain (const char *__domainname
,
247 const char *__dirname
);
248 static inline char *bindtextdomain (const char *__domainname
,
249 const char *__dirname
)
251 return libintl_bindtextdomain (__domainname
, __dirname
);
254 #ifdef _INTL_REDIRECT_MACROS
255 # define bindtextdomain libintl_bindtextdomain
257 extern LIBINTL_DLL_EXPORTED
char *bindtextdomain (const char *__domainname
, const char *__dirname
)
258 _INTL_ASM (libintl_bindtextdomain
);
261 /* Specify the character encoding in which the messages from the
262 DOMAINNAME message catalog will be returned. */
263 #ifdef _INTL_REDIRECT_INLINE
264 extern LIBINTL_DLL_EXPORTED
char *libintl_bind_textdomain_codeset (const char *__domainname
,
265 const char *__codeset
);
266 static inline char *bind_textdomain_codeset (const char *__domainname
,
267 const char *__codeset
)
269 return libintl_bind_textdomain_codeset (__domainname
, __codeset
);
272 #ifdef _INTL_REDIRECT_MACROS
273 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
275 extern LIBINTL_DLL_EXPORTED
char *bind_textdomain_codeset (const char *__domainname
,
276 const char *__codeset
)
277 _INTL_ASM (libintl_bind_textdomain_codeset
);
281 /* Support for format strings with positions in *printf(), following the
282 POSIX/XSI specification.
283 Note: These replacements for the *printf() functions are visible only
284 in source files that #include <libintl.h> or #include "gettext.h".
285 Packages that use *printf() in source files that don't refer to _()
286 or gettext() but for which the format string could be the return value
287 of _() or gettext() need to add this #include. Oh well. */
295 #if __STDC__ || defined __cplusplus || defined _MSC_VER
298 # include <varargs.h>
302 #define fprintf libintl_fprintf
303 extern LIBINTL_DLL_EXPORTED
int fprintf (FILE *, const char *, ...);
305 #define vfprintf libintl_vfprintf
306 extern LIBINTL_DLL_EXPORTED
int vfprintf (FILE *, const char *, va_list);
309 #define printf libintl_printf
310 extern LIBINTL_DLL_EXPORTED
int printf (const char *, ...);
312 #define vprintf libintl_vprintf
313 extern LIBINTL_DLL_EXPORTED
int vprintf (const char *, va_list);
316 #define sprintf libintl_sprintf
317 extern LIBINTL_DLL_EXPORTED
int sprintf (char *, const char *, ...);
319 #define vsprintf libintl_vsprintf
320 extern LIBINTL_DLL_EXPORTED
int vsprintf (char *, const char *, va_list);
325 #define snprintf libintl_snprintf
326 extern LIBINTL_DLL_EXPORTED
int snprintf (char *, size_t, const char *, ...);
328 #define vsnprintf libintl_vsnprintf
329 extern LIBINTL_DLL_EXPORTED
int vsnprintf (char *, size_t, const char *, va_list);
336 #define asprintf libintl_asprintf
337 extern LIBINTL_DLL_EXPORTED
int asprintf (char **, const char *, ...);
339 #define vasprintf libintl_vasprintf
340 extern LIBINTL_DLL_EXPORTED
int vasprintf (char **, const char *, va_list);
347 #define fwprintf libintl_fwprintf
348 extern LIBINTL_DLL_EXPORTED
int fwprintf (FILE *, const wchar_t *, ...);
350 #define vfwprintf libintl_vfwprintf
351 extern LIBINTL_DLL_EXPORTED
int vfwprintf (FILE *, const wchar_t *, va_list);
354 #define wprintf libintl_wprintf
355 extern LIBINTL_DLL_EXPORTED
int wprintf (const wchar_t *, ...);
357 #define vwprintf libintl_vwprintf
358 extern LIBINTL_DLL_EXPORTED
int vwprintf (const wchar_t *, va_list);
361 #define swprintf libintl_swprintf
362 extern LIBINTL_DLL_EXPORTED
int swprintf (wchar_t *, size_t, const wchar_t *, ...);
364 #define vswprintf libintl_vswprintf
365 extern LIBINTL_DLL_EXPORTED
int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
372 /* Support for relocatable packages. */
374 /* Sets the original and the current installation prefix of the package.
375 Relocation simply replaces a pathname starting with the original prefix
376 by the corresponding pathname with the current prefix instead. Both
377 prefixes should be directory names without trailing slash (i.e. use ""
379 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
380 extern LIBINTL_DLL_EXPORTED
void
381 libintl_set_relocation_prefix (const char *orig_prefix
,
382 const char *curr_prefix
);
389 #endif /* libintl.h */