Back to index

cell-binutils  2.17cvs20070401
libgnuintl.h
Go to the documentation of this file.
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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
00017    USA.  */
00018 
00019 #ifndef _LIBINTL_H
00020 #define _LIBINTL_H   1
00021 
00022 #include <locale.h>
00023 
00024 /* The LC_MESSAGES locale category is the category used by the functions
00025    gettext() and dgettext().  It is specified in POSIX, but not in ANSI C.
00026    On systems that don't define it, use an arbitrary value instead.
00027    On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
00028    then includes <libintl.h> (i.e. this file!) and then only defines
00029    LC_MESSAGES.  To avoid a redefinition warning, don't define LC_MESSAGES
00030    in this case.  */
00031 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
00032 # define LC_MESSAGES 1729
00033 #endif
00034 
00035 /* We define an additional symbol to signal that we use the GNU
00036    implementation of gettext.  */
00037 #define __USE_GNU_GETTEXT 1
00038 
00039 /* Provide information about the supported file formats.  Returns the
00040    maximum minor revision number supported for a given major revision.  */
00041 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
00042   ((major) == 0 ? 1 : -1)
00043 
00044 /* Resolve a platform specific conflict on DJGPP.  GNU gettext takes
00045    precedence over _conio_gettext.  */
00046 #ifdef __DJGPP__
00047 # undef gettext
00048 #endif
00049 
00050 /* Use _INTL_PARAMS, not PARAMS, in order to avoid clashes with identifiers
00051    used by programs.  Similarly, test __PROTOTYPES, not PROTOTYPES.  */
00052 #ifndef _INTL_PARAMS
00053 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
00054 #  define _INTL_PARAMS(args) args
00055 # else
00056 #  define _INTL_PARAMS(args) ()
00057 # endif
00058 #endif
00059 
00060 #ifdef __cplusplus
00061 extern "C" {
00062 #endif
00063 
00064 
00065 /* We redirect the functions to those prefixed with "libintl_".  This is
00066    necessary, because some systems define gettext/textdomain/... in the C
00067    library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
00068    If we used the unprefixed names, there would be cases where the
00069    definition in the C library would override the one in the libintl.so
00070    shared library.  Recall that on ELF systems, the symbols are looked
00071    up in the following order:
00072      1. in the executable,
00073      2. in the shared libraries specified on the link command line, in order,
00074      3. in the dependencies of the shared libraries specified on the link
00075         command line,
00076      4. in the dlopen()ed shared libraries, in the order in which they were
00077         dlopen()ed.
00078    The definition in the C library would override the one in libintl.so if
00079    either
00080      * -lc is given on the link command line and -lintl isn't, or
00081      * -lc is given on the link command line before -lintl, or
00082      * libintl.so is a dependency of a dlopen()ed shared library but not
00083        linked to the executable at link time.
00084    Since Solaris gettext() behaves differently than GNU gettext(), this
00085    would be unacceptable.
00086 
00087    The redirection happens by default through macros in C, so that &gettext
00088    is independent of the compilation unit, but through inline functions in
00089    C++, in order not to interfere with the name mangling of class fields or
00090    class methods called 'gettext'.  */
00091 
00092 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
00093    If he doesn't, we choose the method.  A third possible method is
00094    _INTL_REDIRECT_ASM, supported only by GCC.  */
00095 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
00096 # if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
00097 #  define _INTL_REDIRECT_ASM
00098 # else
00099 #  ifdef __cplusplus
00100 #   define _INTL_REDIRECT_INLINE
00101 #  else
00102 #   define _INTL_REDIRECT_MACROS
00103 #  endif
00104 # endif
00105 #endif
00106 /* Auxiliary macros.  */
00107 #ifdef _INTL_REDIRECT_ASM
00108 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
00109 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
00110 # define _INTL_STRINGIFY(prefix) #prefix
00111 #else
00112 # define _INTL_ASM(cname)
00113 #endif
00114 
00115 /* Look up MSGID in the current default message catalog for the current
00116    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
00117    text).  */
00118 #ifdef _INTL_REDIRECT_INLINE
00119 extern char *libintl_gettext (const char *__msgid);
00120 static inline char *gettext (const char *__msgid)
00121 {
00122   return libintl_gettext (__msgid);
00123 }
00124 #else
00125 #ifdef _INTL_REDIRECT_MACROS
00126 # define gettext libintl_gettext
00127 #endif
00128 extern char *gettext _INTL_PARAMS ((const char *__msgid))
00129        _INTL_ASM (libintl_gettext);
00130 #endif
00131 
00132 /* Look up MSGID in the DOMAINNAME message catalog for the current
00133    LC_MESSAGES locale.  */
00134 #ifdef _INTL_REDIRECT_INLINE
00135 extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
00136 static inline char *dgettext (const char *__domainname, const char *__msgid)
00137 {
00138   return libintl_dgettext (__domainname, __msgid);
00139 }
00140 #else
00141 #ifdef _INTL_REDIRECT_MACROS
00142 # define dgettext libintl_dgettext
00143 #endif
00144 extern char *dgettext _INTL_PARAMS ((const char *__domainname,
00145                                  const char *__msgid))
00146        _INTL_ASM (libintl_dgettext);
00147 #endif
00148 
00149 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
00150    locale.  */
00151 #ifdef _INTL_REDIRECT_INLINE
00152 extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
00153                             int __category);
00154 static inline char *dcgettext (const char *__domainname, const char *__msgid,
00155                             int __category)
00156 {
00157   return libintl_dcgettext (__domainname, __msgid, __category);
00158 }
00159 #else
00160 #ifdef _INTL_REDIRECT_MACROS
00161 # define dcgettext libintl_dcgettext
00162 #endif
00163 extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
00164                                   const char *__msgid,
00165                                   int __category))
00166        _INTL_ASM (libintl_dcgettext);
00167 #endif
00168 
00169 
00170 /* Similar to `gettext' but select the plural form corresponding to the
00171    number N.  */
00172 #ifdef _INTL_REDIRECT_INLINE
00173 extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
00174                             unsigned long int __n);
00175 static inline char *ngettext (const char *__msgid1, const char *__msgid2,
00176                            unsigned long int __n)
00177 {
00178   return libintl_ngettext (__msgid1, __msgid2, __n);
00179 }
00180 #else
00181 #ifdef _INTL_REDIRECT_MACROS
00182 # define ngettext libintl_ngettext
00183 #endif
00184 extern char *ngettext _INTL_PARAMS ((const char *__msgid1,
00185                                  const char *__msgid2,
00186                                  unsigned long int __n))
00187        _INTL_ASM (libintl_ngettext);
00188 #endif
00189 
00190 /* Similar to `dgettext' but select the plural form corresponding to the
00191    number N.  */
00192 #ifdef _INTL_REDIRECT_INLINE
00193 extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
00194                             const char *__msgid2, unsigned long int __n);
00195 static inline char *dngettext (const char *__domainname, const char *__msgid1,
00196                             const char *__msgid2, unsigned long int __n)
00197 {
00198   return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
00199 }
00200 #else
00201 #ifdef _INTL_REDIRECT_MACROS
00202 # define dngettext libintl_dngettext
00203 #endif
00204 extern char *dngettext _INTL_PARAMS ((const char *__domainname,
00205                                   const char *__msgid1,
00206                                   const char *__msgid2,
00207                                   unsigned long int __n))
00208        _INTL_ASM (libintl_dngettext);
00209 #endif
00210 
00211 /* Similar to `dcgettext' but select the plural form corresponding to the
00212    number N.  */
00213 #ifdef _INTL_REDIRECT_INLINE
00214 extern char *libintl_dcngettext (const char *__domainname,
00215                              const char *__msgid1, const char *__msgid2,
00216                              unsigned long int __n, int __category);
00217 static inline char *dcngettext (const char *__domainname,
00218                             const char *__msgid1, const char *__msgid2,
00219                             unsigned long int __n, int __category)
00220 {
00221   return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
00222 }
00223 #else
00224 #ifdef _INTL_REDIRECT_MACROS
00225 # define dcngettext libintl_dcngettext
00226 #endif
00227 extern char *dcngettext _INTL_PARAMS ((const char *__domainname,
00228                                    const char *__msgid1,
00229                                    const char *__msgid2,
00230                                    unsigned long int __n,
00231                                    int __category))
00232        _INTL_ASM (libintl_dcngettext);
00233 #endif
00234 
00235 
00236 /* Set the current default message catalog to DOMAINNAME.
00237    If DOMAINNAME is null, return the current default.
00238    If DOMAINNAME is "", reset to the default of "messages".  */
00239 #ifdef _INTL_REDIRECT_INLINE
00240 extern char *libintl_textdomain (const char *__domainname);
00241 static inline char *textdomain (const char *__domainname)
00242 {
00243   return libintl_textdomain (__domainname);
00244 }
00245 #else
00246 #ifdef _INTL_REDIRECT_MACROS
00247 # define textdomain libintl_textdomain
00248 #endif
00249 extern char *textdomain _INTL_PARAMS ((const char *__domainname))
00250        _INTL_ASM (libintl_textdomain);
00251 #endif
00252 
00253 /* Specify that the DOMAINNAME message catalog will be found
00254    in DIRNAME rather than in the system locale data base.  */
00255 #ifdef _INTL_REDIRECT_INLINE
00256 extern char *libintl_bindtextdomain (const char *__domainname,
00257                                  const char *__dirname);
00258 static inline char *bindtextdomain (const char *__domainname,
00259                                 const char *__dirname)
00260 {
00261   return libintl_bindtextdomain (__domainname, __dirname);
00262 }
00263 #else
00264 #ifdef _INTL_REDIRECT_MACROS
00265 # define bindtextdomain libintl_bindtextdomain
00266 #endif
00267 extern char *bindtextdomain _INTL_PARAMS ((const char *__domainname,
00268                                       const char *__dirname))
00269        _INTL_ASM (libintl_bindtextdomain);
00270 #endif
00271 
00272 /* Specify the character encoding in which the messages from the
00273    DOMAINNAME message catalog will be returned.  */
00274 #ifdef _INTL_REDIRECT_INLINE
00275 extern char *libintl_bind_textdomain_codeset (const char *__domainname,
00276                                          const char *__codeset);
00277 static inline char *bind_textdomain_codeset (const char *__domainname,
00278                                         const char *__codeset)
00279 {
00280   return libintl_bind_textdomain_codeset (__domainname, __codeset);
00281 }
00282 #else
00283 #ifdef _INTL_REDIRECT_MACROS
00284 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
00285 #endif
00286 extern char *bind_textdomain_codeset _INTL_PARAMS ((const char *__domainname,
00287                                               const char *__codeset))
00288        _INTL_ASM (libintl_bind_textdomain_codeset);
00289 #endif
00290 
00291 
00292 /* Support for relocatable packages.  */
00293 
00294 /* Sets the original and the current installation prefix of the package.
00295    Relocation simply replaces a pathname starting with the original prefix
00296    by the corresponding pathname with the current prefix instead.  Both
00297    prefixes should be directory names without trailing slash (i.e. use ""
00298    instead of "/").  */
00299 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
00300 extern void
00301        libintl_set_relocation_prefix _INTL_PARAMS ((const char *orig_prefix,
00302                                               const char *curr_prefix));
00303 
00304 
00305 #ifdef __cplusplus
00306 }
00307 #endif
00308 
00309 #endif /* libintl.h */