Navit SVN

/work/compile/navit/src/navit/intl_cmake/libgnuintl.h

00001 /* Message catalogs for internationalization.
00002    Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify it
00005    under the terms of the GNU Library General Public License as published
00006    by the Free Software Foundation; either version 2, or (at your option)
00007    any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public
00015    License along with this program; if not, write to the Free Software
00016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00017    USA.  */
00018 
00019 #ifndef _LIBINTL_H
00020 #define _LIBINTL_H      1
00021 #include "config.h"
00022 
00023 #include <locale.h>
00024 
00025 /* The LC_MESSAGES locale category is the category used by the functions
00026    gettext() and dgettext().  It is specified in POSIX, but not in ANSI C.
00027    On systems that don't define it, use an arbitrary value instead.
00028    On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
00029    then includes <libintl.h> (i.e. this file!) and then only defines
00030    LC_MESSAGES.  To avoid a redefinition warning, don't define LC_MESSAGES
00031    in this case.  */
00032 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
00033 # define LC_MESSAGES 1729
00034 #endif
00035 
00036 /* We define an additional symbol to signal that we use the GNU
00037    implementation of gettext.  */
00038 #define __USE_GNU_GETTEXT 1
00039 
00040 /* Provide information about the supported file formats.  Returns the
00041    maximum minor revision number supported for a given major revision.  */
00042 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
00043   ((major) == 0 ? 1 : -1)
00044 
00045 /* Resolve a platform specific conflict on DJGPP.  GNU gettext takes
00046    precedence over _conio_gettext.  */
00047 #ifdef __DJGPP__
00048 # undef gettext
00049 #endif
00050 
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054 
00055 
00056 /* We redirect the functions to those prefixed with "libintl_".  This is
00057    necessary, because some systems define gettext/textdomain/... in the C
00058    library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
00059    If we used the unprefixed names, there would be cases where the
00060    definition in the C library would override the one in the libintl.so
00061    shared library.  Recall that on ELF systems, the symbols are looked
00062    up in the following order:
00063      1. in the executable,
00064      2. in the shared libraries specified on the link command line, in order,
00065      3. in the dependencies of the shared libraries specified on the link
00066         command line,
00067      4. in the dlopen()ed shared libraries, in the order in which they were
00068         dlopen()ed.
00069    The definition in the C library would override the one in libintl.so if
00070    either
00071      * -lc is given on the link command line and -lintl isn't, or
00072      * -lc is given on the link command line before -lintl, or
00073      * libintl.so is a dependency of a dlopen()ed shared library but not
00074        linked to the executable at link time.
00075    Since Solaris gettext() behaves differently than GNU gettext(), this
00076    would be unacceptable.
00077 
00078    The redirection happens by default through macros in C, so that &gettext
00079    is independent of the compilation unit, but through inline functions in
00080    C++, in order not to interfere with the name mangling of class fields or
00081    class methods called 'gettext'.  */
00082 
00083 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
00084    If he doesn't, we choose the method.  A third possible method is
00085    _INTL_REDIRECT_ASM, supported only by GCC.  */
00086 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
00087 # if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
00088 #  define _INTL_REDIRECT_ASM
00089 # else
00090 #  ifdef __cplusplus
00091 #   define _INTL_REDIRECT_INLINE
00092 #  else
00093 #   define _INTL_REDIRECT_MACROS
00094 #  endif
00095 # endif
00096 #endif
00097 /* Auxiliary macros.  */
00098 #ifdef _INTL_REDIRECT_ASM
00099 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
00100 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
00101 # define _INTL_STRINGIFY(prefix) #prefix
00102 #else
00103 # define _INTL_ASM(cname)
00104 #endif
00105 
00106 /* Look up MSGID in the current default message catalog for the current
00107    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
00108    text).  */
00109 #ifdef _INTL_REDIRECT_INLINE
00110 extern char *libintl_gettext (const char *__msgid);
00111 static inline char *gettext (const char *__msgid)
00112 {
00113   return libintl_gettext (__msgid);
00114 }
00115 #else
00116 #ifdef _INTL_REDIRECT_MACROS
00117 # define gettext libintl_gettext
00118 #endif
00119 extern char *gettext (const char *__msgid)
00120        _INTL_ASM (libintl_gettext);
00121 #endif
00122 
00123 /* Look up MSGID in the DOMAINNAME message catalog for the current
00124    LC_MESSAGES locale.  */
00125 #ifdef _INTL_REDIRECT_INLINE
00126 extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
00127 static inline char *dgettext (const char *__domainname, const char *__msgid)
00128 {
00129   return libintl_dgettext (__domainname, __msgid);
00130 }
00131 #else
00132 #ifdef _INTL_REDIRECT_MACROS
00133 # define dgettext libintl_dgettext
00134 #endif
00135 extern char *dgettext (const char *__domainname, const char *__msgid)
00136        _INTL_ASM (libintl_dgettext);
00137 #endif
00138 
00139 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
00140    locale.  */
00141 #ifdef _INTL_REDIRECT_INLINE
00142 extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
00143                                 int __category);
00144 static inline char *dcgettext (const char *__domainname, const char *__msgid,
00145                                int __category)
00146 {
00147   return libintl_dcgettext (__domainname, __msgid, __category);
00148 }
00149 #else
00150 #ifdef _INTL_REDIRECT_MACROS
00151 # define dcgettext libintl_dcgettext
00152 #endif
00153 extern char *dcgettext (const char *__domainname, const char *__msgid,
00154                         int __category)
00155        _INTL_ASM (libintl_dcgettext);
00156 #endif
00157 
00158 
00159 /* Similar to `gettext' but select the plural form corresponding to the
00160    number N.  */
00161 #ifdef _INTL_REDIRECT_INLINE
00162 extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
00163                                unsigned long int __n);
00164 static inline char *ngettext (const char *__msgid1, const char *__msgid2,
00165                               unsigned long int __n)
00166 {
00167   return libintl_ngettext (__msgid1, __msgid2, __n);
00168 }
00169 #else
00170 #ifdef _INTL_REDIRECT_MACROS
00171 # define ngettext libintl_ngettext
00172 #endif
00173 extern char *ngettext (const char *__msgid1, const char *__msgid2,
00174                        unsigned long int __n)
00175        _INTL_ASM (libintl_ngettext);
00176 #endif
00177 
00178 /* Similar to `dgettext' but select the plural form corresponding to the
00179    number N.  */
00180 #ifdef _INTL_REDIRECT_INLINE
00181 extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
00182                                 const char *__msgid2, unsigned long int __n);
00183 static inline char *dngettext (const char *__domainname, const char *__msgid1,
00184                                const char *__msgid2, unsigned long int __n)
00185 {
00186   return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
00187 }
00188 #else
00189 #ifdef _INTL_REDIRECT_MACROS
00190 # define dngettext libintl_dngettext
00191 #endif
00192 extern char *dngettext (const char *__domainname,
00193                         const char *__msgid1, const char *__msgid2,
00194                         unsigned long int __n)
00195        _INTL_ASM (libintl_dngettext);
00196 #endif
00197 
00198 /* Similar to `dcgettext' but select the plural form corresponding to the
00199    number N.  */
00200 #ifdef _INTL_REDIRECT_INLINE
00201 extern char *libintl_dcngettext (const char *__domainname,
00202                                  const char *__msgid1, const char *__msgid2,
00203                                  unsigned long int __n, int __category);
00204 static inline char *dcngettext (const char *__domainname,
00205                                 const char *__msgid1, const char *__msgid2,
00206                                 unsigned long int __n, int __category)
00207 {
00208   return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
00209 }
00210 #else
00211 #ifdef _INTL_REDIRECT_MACROS
00212 # define dcngettext libintl_dcngettext
00213 #endif
00214 extern char *dcngettext (const char *__domainname,
00215                          const char *__msgid1, const char *__msgid2,
00216                          unsigned long int __n, int __category)
00217        _INTL_ASM (libintl_dcngettext);
00218 #endif
00219 
00220 
00221 /* Set the current default message catalog to DOMAINNAME.
00222    If DOMAINNAME is null, return the current default.
00223    If DOMAINNAME is "", reset to the default of "messages".  */
00224 #ifdef _INTL_REDIRECT_INLINE
00225 extern char *libintl_textdomain (const char *__domainname);
00226 static inline char *textdomain (const char *__domainname)
00227 {
00228   return libintl_textdomain (__domainname);
00229 }
00230 #else
00231 #ifdef _INTL_REDIRECT_MACROS
00232 # define textdomain libintl_textdomain
00233 #endif
00234 extern char *textdomain (const char *__domainname)
00235        _INTL_ASM (libintl_textdomain);
00236 #endif
00237 
00238 /* Specify that the DOMAINNAME message catalog will be found
00239    in DIRNAME rather than in the system locale data base.  */
00240 #ifdef _INTL_REDIRECT_INLINE
00241 extern char *libintl_bindtextdomain (const char *__domainname,
00242                                      const char *__dirname);
00243 static inline char *bindtextdomain (const char *__domainname,
00244                                     const char *__dirname)
00245 {
00246   return libintl_bindtextdomain (__domainname, __dirname);
00247 }
00248 #else
00249 #ifdef _INTL_REDIRECT_MACROS
00250 # define bindtextdomain libintl_bindtextdomain
00251 #endif
00252 extern char *bindtextdomain (const char *__domainname, const char *__dirname)
00253        _INTL_ASM (libintl_bindtextdomain);
00254 #endif
00255 
00256 /* Specify the character encoding in which the messages from the
00257    DOMAINNAME message catalog will be returned.  */
00258 #ifdef _INTL_REDIRECT_INLINE
00259 extern char *libintl_bind_textdomain_codeset (const char *__domainname,
00260                                               const char *__codeset);
00261 static inline char *bind_textdomain_codeset (const char *__domainname,
00262                                              const char *__codeset)
00263 {
00264   return libintl_bind_textdomain_codeset (__domainname, __codeset);
00265 }
00266 #else
00267 #ifdef _INTL_REDIRECT_MACROS
00268 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
00269 #endif
00270 extern char *bind_textdomain_codeset (const char *__domainname,
00271                                       const char *__codeset)
00272        _INTL_ASM (libintl_bind_textdomain_codeset);
00273 #endif
00274 
00275 
00276 /* Support for format strings with positions in *printf(), following the
00277    POSIX/XSI specification.
00278    Note: These replacements for the *printf() functions are visible only
00279    in source files that #include <libintl.h> or #include "gettext.h".
00280    Packages that use *printf() in source files that don't refer to _()
00281    or gettext() but for which the format string could be the return value
00282    of _() or gettext() need to add this #include.  Oh well.  */
00283 
00284 #if 1
00285 
00286 #include <stdio.h>
00287 #include <stddef.h>
00288 
00289 /* Get va_list.  */
00290 #if __STDC__ || defined __cplusplus || defined _MSC_VER
00291 # include <stdarg.h>
00292 #else
00293 # include <varargs.h>
00294 #endif
00295 
00296 #undef fprintf
00297 #define fprintf libintl_fprintf
00298 extern int fprintf (FILE *, const char *, ...);
00299 #undef vfprintf
00300 #define vfprintf libintl_vfprintf
00301 extern int vfprintf (FILE *, const char *, va_list);
00302 
00303 #undef printf
00304 #define printf libintl_printf
00305 extern int printf (const char *, ...);
00306 #undef vprintf
00307 #define vprintf libintl_vprintf
00308 extern int vprintf (const char *, va_list);
00309 
00310 #undef sprintf
00311 #define sprintf libintl_sprintf
00312 extern int sprintf (char *, const char *, ...);
00313 #undef vsprintf
00314 #define vsprintf libintl_vsprintf
00315 extern int vsprintf (char *, const char *, va_list);
00316 
00317 #if HAVE_SNPRINTF
00318 
00319 #undef snprintf
00320 #define snprintf libintl_snprintf
00321 extern int snprintf (char *, size_t, const char *, ...);
00322 #undef vsnprintf
00323 #define vsnprintf libintl_vsnprintf
00324 extern int vsnprintf (char *, size_t, const char *, va_list);
00325 
00326 #endif
00327 
00328 #if HAVE_ASPRINTF
00329 
00330 #undef asprintf
00331 #define asprintf libintl_asprintf
00332 extern int asprintf (char **, const char *, ...);
00333 #undef vasprintf
00334 #define vasprintf libintl_vasprintf
00335 extern int vasprintf (char **, const char *, va_list);
00336 
00337 #endif
00338 
00339 #if HAVE_WPRINTF
00340 
00341 #undef fwprintf
00342 #define fwprintf libintl_fwprintf
00343 extern int fwprintf (FILE *, const wchar_t *, ...);
00344 #undef vfwprintf
00345 #define vfwprintf libintl_vfwprintf
00346 extern int vfwprintf (FILE *, const wchar_t *, va_list);
00347 
00348 #undef wprintf
00349 #define wprintf libintl_wprintf
00350 extern int wprintf (const wchar_t *, ...);
00351 #undef vwprintf
00352 #define vwprintf libintl_vwprintf
00353 extern int vwprintf (const wchar_t *, va_list);
00354 
00355 #undef swprintf
00356 #define swprintf libintl_swprintf
00357 extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
00358 #undef vswprintf
00359 #define vswprintf libintl_vswprintf
00360 extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
00361 
00362 #endif
00363 
00364 #endif
00365 
00366 
00367 /* Support for relocatable packages.  */
00368 
00369 /* Sets the original and the current installation prefix of the package.
00370    Relocation simply replaces a pathname starting with the original prefix
00371    by the corresponding pathname with the current prefix instead.  Both
00372    prefixes should be directory names without trailing slash (i.e. use ""
00373    instead of "/").  */
00374 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
00375 extern void
00376        libintl_set_relocation_prefix (const char *orig_prefix,
00377                                       const char *curr_prefix);
00378 
00379 
00380 #ifdef __cplusplus
00381 }
00382 #endif
00383 
00384 #endif /* libintl.h */