Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

libintl.h

Go to the documentation of this file.
00001 /* Message catalogs for internationalization.
00002    Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    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
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software Foundation,
00016    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00017 
00018 /* Because on some systems (e.g. Solaris) we sometimes have to include
00019    the systems libintl.h as well as this file we have more complex
00020    include protection above.  But the systems header might perhaps also
00021    define _LIBINTL_H and therefore we have to protect the definition here.  */
00022 
00023 #if !defined _LIBINTL_H || !defined _LIBGETTEXT_H
00024 #ifndef _LIBINTL_H
00025 # define _LIBINTL_H  1
00026 #endif
00027 #define _LIBGETTEXT_H   1
00028 
00029 /* We define an additional symbol to signal that we use the GNU
00030    implementation of gettext.  */
00031 #define __USE_GNU_GETTEXT 1
00032 
00033 #include <sys/types.h>
00034 
00035 #if HAVE_LOCALE_H
00036 # include <locale.h>
00037 #endif
00038 
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 /* @@ end of prolog @@ */
00045 
00046 #ifndef PARAMS
00047 # if __STDC__ || defined __cplusplus
00048 #  define PARAMS(args) args
00049 # else
00050 #  define PARAMS(args) ()
00051 # endif
00052 #endif
00053 
00054 #ifndef NULL
00055 # if !defined __cplusplus || defined __GNUC__
00056 #  define NULL ((void *) 0)
00057 # else
00058 #  define NULL (0)
00059 # endif
00060 #endif
00061 
00062 #if !HAVE_LC_MESSAGES
00063 /* This value determines the behaviour of the gettext() and dgettext()
00064    function.  But some system does not have this defined.  Define it
00065    to a default value.  */
00066 # define LC_MESSAGES (-1)
00067 #endif
00068 
00069 
00070 /* Declarations for gettext-using-catgets interface.  Derived from
00071    Jim Meyering's libintl.h.  */
00072 struct _msg_ent
00073 {
00074   const char *_msg;
00075   int _msg_number;
00076 };
00077 
00078 
00079 #if HAVE_CATGETS
00080 /* These two variables are defined in the automatically by po-to-tbl.sed
00081    generated file `cat-id-tbl.c'.  */
00082 extern const struct _msg_ent _msg_tbl[];
00083 extern int _msg_tbl_length;
00084 #endif
00085 
00086 
00087 /* For automatical extraction of messages sometimes no real
00088    translation is needed.  Instead the string itself is the result.  */
00089 #define gettext_noop(Str) Str
00090 
00091 /* Look up MSGID in the current default message catalog for the current
00092    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
00093    text).  */
00094 extern char *gettext PARAMS ((const char *__msgid));
00095 extern char *gettext__ PARAMS ((const char *__msgid));
00096 
00097 /* Look up MSGID in the DOMAINNAME message catalog for the current
00098    LC_MESSAGES locale.  */
00099 extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid));
00100 extern char *dgettext__ PARAMS ((const char *__domainname,
00101              const char *__msgid));
00102 
00103 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
00104    locale.  */
00105 extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid,
00106             int __category));
00107 extern char *dcgettext__ PARAMS ((const char *__domainname,
00108               const char *__msgid, int __category));
00109 
00110 
00111 /* Set the current default message catalog to DOMAINNAME.
00112    If DOMAINNAME is null, return the current default.
00113    If DOMAINNAME is "", reset to the default of "messages".  */
00114 extern char *textdomain PARAMS ((const char *__domainname));
00115 extern char *textdomain__ PARAMS ((const char *__domainname));
00116 
00117 /* Specify that the DOMAINNAME message catalog will be found
00118    in DIRNAME rather than in the system locale data base.  */
00119 extern char *bindtextdomain PARAMS ((const char *__domainname,
00120               const char *__dirname));
00121 extern char *bindtextdomain__ PARAMS ((const char *__domainname,
00122                 const char *__dirname));
00123 
00124 #if ENABLE_NLS
00125 
00126 /* Solaris 2.3 has the gettext function but dcgettext is missing.
00127    So we omit this optimization for Solaris 2.3.  BTW, Solaris 2.4
00128    has dcgettext.  */
00129 # if !HAVE_CATGETS && (!HAVE_GETTEXT || HAVE_DCGETTEXT)
00130 
00131 #  define gettext(Msgid)                        \
00132      dgettext (NULL, Msgid)
00133 
00134 #  define dgettext(Domainname, Msgid)                    \
00135      dcgettext (Domainname, Msgid, LC_MESSAGES)
00136 
00137 #  if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ >= 7
00138 /* This global variable is defined in loadmsgcat.c.  We need a sign,
00139    whether a new catalog was loaded, which can be associated with all
00140    translations.  */
00141 extern int _nl_msg_cat_cntr;
00142 
00143 #   define dcgettext(Domainname, Msgid, Category)              \
00144   (__extension__                          \
00145    ({                               \
00146      char *__result;                         \
00147      if (__builtin_constant_p (Msgid))                   \
00148        {                            \
00149     static char *__translation__;                     \
00150     static int __catalog_counter__;                \
00151     if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr)    \
00152       {                             \
00153         __translation__ =                       \
00154           dcgettext__ (Domainname, Msgid, Category);           \
00155         __catalog_counter__ = _nl_msg_cat_cntr;             \
00156       }                             \
00157     __result = __translation__;                    \
00158        }                            \
00159      else                              \
00160        __result = dcgettext__ (Domainname, Msgid, Category);            \
00161      __result;                            \
00162     }))
00163 #  endif
00164 # endif
00165 
00166 #else
00167 
00168 # define gettext(Msgid) (Msgid)
00169 # define dgettext(Domainname, Msgid) (Msgid)
00170 # define dcgettext(Domainname, Msgid, Category) (Msgid)
00171 # define textdomain(Domainname) ((char *) Domainname)
00172 # define bindtextdomain(Domainname, Dirname) ((char *) Dirname)
00173 
00174 #endif
00175 
00176 /* @@ begin of epilog @@ */
00177 
00178 #ifdef __cplusplus
00179 }
00180 #endif
00181 
00182 #endif

Generated on Mon Apr 7 19:41:45 2003 for DuTree by doxygen1.2.18