1/* Message catalogs for internationalization. 2 Copyright (C) 1995-1997, 2000-2004 Free Software Foundation, Inc. 3 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) 7 any later version. 8 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. 13 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, 17 USA. */ 18 19#ifndef _LIBINTL_H 20#define _LIBINTL_H 1 21 22#ifdef BUILDING_LIBINTL 23#define LIBINTL_DLL_EXPORTED __declspec(dllexport) 24#else 25#define LIBINTL_DLL_EXPORTED __declspec(dllimport) 26#endif 27 28#include <locale.h> 29 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 36 in this case. */ 37#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun)) 38# define LC_MESSAGES 1729 39#endif 40 41/* We define an additional symbol to signal that we use the GNU 42 implementation of gettext. */ 43#define __USE_GNU_GETTEXT 1 44 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) 49 50/* Resolve a platform specific conflict on DJGPP. GNU gettext takes 51 precedence over _conio_gettext. */ 52#ifdef __DJGPP__ 53# undef gettext 54#endif 55 56#ifdef __cplusplus 57extern "C" { 58#endif 59 60 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: 68 1. in the executable, 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 71 command line, 72 4. in the dlopen()ed shared libraries, in the order in which they were 73 dlopen()ed. 74 The definition in the C library would override the one in libintl.so if 75 either 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. 82 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'. */ 87 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 94# else 95# ifdef __cplusplus 96# define _INTL_REDIRECT_INLINE 97# else 98# define _INTL_REDIRECT_MACROS 99# endif 100# endif 101#endif 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 107#else 108# define _INTL_ASM(cname) 109#endif 110 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 113 text). */ 114#ifdef _INTL_REDIRECT_INLINE 115extern LIBINTL_DLL_EXPORTED char *libintl_gettext (const char *__msgid); 116static inline char *gettext (const char *__msgid) 117{ 118 return libintl_gettext (__msgid); 119} 120#else 121#ifdef _INTL_REDIRECT_MACROS 122# define gettext libintl_gettext 123#endif 124extern LIBINTL_DLL_EXPORTED char *gettext (const char *__msgid) 125 _INTL_ASM (libintl_gettext); 126#endif 127 128/* Look up MSGID in the DOMAINNAME message catalog for the current 129 LC_MESSAGES locale. */ 130#ifdef _INTL_REDIRECT_INLINE 131extern LIBINTL_DLL_EXPORTED char *libintl_dgettext (const char *__domainname, const char *__msgid); 132static inline char *dgettext (const char *__domainname, const char *__msgid) 133{ 134 return libintl_dgettext (__domainname, __msgid); 135} 136#else 137#ifdef _INTL_REDIRECT_MACROS 138# define dgettext libintl_dgettext 139#endif 140extern LIBINTL_DLL_EXPORTED char *dgettext (const char *__domainname, const char *__msgid) 141 _INTL_ASM (libintl_dgettext); 142#endif 143 144/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY 145 locale. */ 146#ifdef _INTL_REDIRECT_INLINE 147extern LIBINTL_DLL_EXPORTED char *libintl_dcgettext (const char *__domainname, const char *__msgid, 148 int __category); 149static inline char *dcgettext (const char *__domainname, const char *__msgid, 150 int __category) 151{ 152 return libintl_dcgettext (__domainname, __msgid, __category); 153} 154#else 155#ifdef _INTL_REDIRECT_MACROS 156# define dcgettext libintl_dcgettext 157#endif 158extern LIBINTL_DLL_EXPORTED char *dcgettext (const char *__domainname, const char *__msgid, 159 int __category) 160 _INTL_ASM (libintl_dcgettext); 161#endif 162 163 164/* Similar to `gettext' but select the plural form corresponding to the 165 number N. */ 166#ifdef _INTL_REDIRECT_INLINE 167extern LIBINTL_DLL_EXPORTED char *libintl_ngettext (const char *__msgid1, const char *__msgid2, 168 unsigned long int __n); 169static inline char *ngettext (const char *__msgid1, const char *__msgid2, 170 unsigned long int __n) 171{ 172 return libintl_ngettext (__msgid1, __msgid2, __n); 173} 174#else 175#ifdef _INTL_REDIRECT_MACROS 176# define ngettext libintl_ngettext 177#endif 178extern LIBINTL_DLL_EXPORTED char *ngettext (const char *__msgid1, const char *__msgid2, 179 unsigned long int __n) 180 _INTL_ASM (libintl_ngettext); 181#endif 182 183/* Similar to `dgettext' but select the plural form corresponding to the 184 number N. */ 185#ifdef _INTL_REDIRECT_INLINE 186extern LIBINTL_DLL_EXPORTED char *libintl_dngettext (const char *__domainname, const char *__msgid1, 187 const char *__msgid2, unsigned long int __n); 188static inline char *dngettext (const char *__domainname, const char *__msgid1, 189 const char *__msgid2, unsigned long int __n) 190{ 191 return libintl_dngettext (__domainname, __msgid1, __msgid2, __n); 192} 193#else 194#ifdef _INTL_REDIRECT_MACROS 195# define dngettext libintl_dngettext 196#endif 197extern 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); 201#endif 202 203/* Similar to `dcgettext' but select the plural form corresponding to the 204 number N. */ 205#ifdef _INTL_REDIRECT_INLINE 206extern LIBINTL_DLL_EXPORTED char *libintl_dcngettext (const char *__domainname, 207 const char *__msgid1, const char *__msgid2, 208 unsigned long int __n, int __category); 209static inline char *dcngettext (const char *__domainname, 210 const char *__msgid1, const char *__msgid2, 211 unsigned long int __n, int __category) 212{ 213 return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category); 214} 215#else 216#ifdef _INTL_REDIRECT_MACROS 217# define dcngettext libintl_dcngettext 218#endif 219extern 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); 223#endif 224 225 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 230extern LIBINTL_DLL_EXPORTED char *libintl_textdomain (const char *__domainname); 231static inline char *textdomain (const char *__domainname) 232{ 233 return libintl_textdomain (__domainname); 234} 235#else 236#ifdef _INTL_REDIRECT_MACROS 237# define textdomain libintl_textdomain 238#endif 239extern LIBINTL_DLL_EXPORTED char *textdomain (const char *__domainname) 240 _INTL_ASM (libintl_textdomain); 241#endif 242 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 246extern LIBINTL_DLL_EXPORTED char *libintl_bindtextdomain (const char *__domainname, 247 const char *__dirname); 248static inline char *bindtextdomain (const char *__domainname, 249 const char *__dirname) 250{ 251 return libintl_bindtextdomain (__domainname, __dirname); 252} 253#else 254#ifdef _INTL_REDIRECT_MACROS 255# define bindtextdomain libintl_bindtextdomain 256#endif 257extern LIBINTL_DLL_EXPORTED char *bindtextdomain (const char *__domainname, const char *__dirname) 258 _INTL_ASM (libintl_bindtextdomain); 259#endif 260 261/* Specify the character encoding in which the messages from the 262 DOMAINNAME message catalog will be returned. */ 263#ifdef _INTL_REDIRECT_INLINE 264extern LIBINTL_DLL_EXPORTED char *libintl_bind_textdomain_codeset (const char *__domainname, 265 const char *__codeset); 266static inline char *bind_textdomain_codeset (const char *__domainname, 267 const char *__codeset) 268{ 269 return libintl_bind_textdomain_codeset (__domainname, __codeset); 270} 271#else 272#ifdef _INTL_REDIRECT_MACROS 273# define bind_textdomain_codeset libintl_bind_textdomain_codeset 274#endif 275extern LIBINTL_DLL_EXPORTED char *bind_textdomain_codeset (const char *__domainname, 276 const char *__codeset) 277 _INTL_ASM (libintl_bind_textdomain_codeset); 278#endif 279 280 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. */ 288 289#if !0 290 291#include <stdio.h> 292#include <stddef.h> 293 294/* Get va_list. */ 295#if __STDC__ || defined __cplusplus || defined _MSC_VER 296# include <stdarg.h> 297#else 298# include <varargs.h> 299#endif 300 301#undef fprintf 302#define fprintf libintl_fprintf 303extern LIBINTL_DLL_EXPORTED int fprintf (FILE *, const char *, ...); 304#undef vfprintf 305#define vfprintf libintl_vfprintf 306extern LIBINTL_DLL_EXPORTED int vfprintf (FILE *, const char *, va_list); 307 308#undef printf 309#define printf libintl_printf 310extern LIBINTL_DLL_EXPORTED int printf (const char *, ...); 311#undef vprintf 312#define vprintf libintl_vprintf 313extern LIBINTL_DLL_EXPORTED int vprintf (const char *, va_list); 314 315#undef sprintf 316#define sprintf libintl_sprintf 317extern LIBINTL_DLL_EXPORTED int sprintf (char *, const char *, ...); 318#undef vsprintf 319#define vsprintf libintl_vsprintf 320extern LIBINTL_DLL_EXPORTED int vsprintf (char *, const char *, va_list); 321 322#if 0 323 324#undef snprintf 325#define snprintf libintl_snprintf 326extern LIBINTL_DLL_EXPORTED int snprintf (char *, size_t, const char *, ...); 327#undef vsnprintf 328#define vsnprintf libintl_vsnprintf 329extern LIBINTL_DLL_EXPORTED int vsnprintf (char *, size_t, const char *, va_list); 330 331#endif 332 333#if 0 334 335#undef asprintf 336#define asprintf libintl_asprintf 337extern LIBINTL_DLL_EXPORTED int asprintf (char **, const char *, ...); 338#undef vasprintf 339#define vasprintf libintl_vasprintf 340extern LIBINTL_DLL_EXPORTED int vasprintf (char **, const char *, va_list); 341 342#endif 343 344#if 1 345 346#undef fwprintf 347#define fwprintf libintl_fwprintf 348extern LIBINTL_DLL_EXPORTED int fwprintf (FILE *, const wchar_t *, ...); 349#undef vfwprintf 350#define vfwprintf libintl_vfwprintf 351extern LIBINTL_DLL_EXPORTED int vfwprintf (FILE *, const wchar_t *, va_list); 352 353#undef wprintf 354#define wprintf libintl_wprintf 355extern LIBINTL_DLL_EXPORTED int wprintf (const wchar_t *, ...); 356#undef vwprintf 357#define vwprintf libintl_vwprintf 358extern LIBINTL_DLL_EXPORTED int vwprintf (const wchar_t *, va_list); 359 360#undef swprintf 361#define swprintf libintl_swprintf 362extern LIBINTL_DLL_EXPORTED int swprintf (wchar_t *, size_t, const wchar_t *, ...); 363#undef vswprintf 364#define vswprintf libintl_vswprintf 365extern LIBINTL_DLL_EXPORTED int vswprintf (wchar_t *, size_t, const wchar_t *, va_list); 366 367#endif 368 369#endif 370 371 372/* Support for relocatable packages. */ 373 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 "" 378 instead of "/"). */ 379#define libintl_set_relocation_prefix libintl_set_relocation_prefix 380extern LIBINTL_DLL_EXPORTED void 381 libintl_set_relocation_prefix (const char *orig_prefix, 382 const char *curr_prefix); 383 384 385#ifdef __cplusplus 386} 387#endif 388 389#endif /* libintl.h */ 390