home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / tar-1.11.8-src.tgz / tar.out / fsf / tar / intl / libgettext.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  4KB  |  126 lines

  1. /* libgettext.h -- Message catalogs for internationalization.
  2.    Copyright (C) 1995 Software Foundation, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. 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
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. #ifndef _LIBINTL_H
  19. #define    _LIBINTL_H    1
  20.  
  21. #include <locale.h>
  22.  
  23. /* @@ end of prolog @@ */
  24.  
  25. #ifndef __P
  26. # ifdef __STDC__
  27. #  define __P(args) args
  28. # else
  29. #  define __P(args) ()
  30. # endif
  31. #endif
  32.  
  33. #ifndef HAVE_LC_MESSAGES
  34. /* This value determines the behaviour of the gettext() and dgettext()
  35.    function.  But some system does not have this defined.  Define it
  36.    to a default value.  */
  37. # define LC_MESSAGES (-1)
  38. #endif
  39.  
  40. /* Declarations for gettext-using-catgets interface.  Derived from
  41.    Jim Meyering's libintl.h.  */
  42.  
  43. struct _msg_ent
  44. {
  45.   const char *_msg;
  46.   int _msg_number;
  47. };
  48.  
  49. /* These two variables are defined in the automatically by po-to-tbl.sed
  50.    generated file `cat-id-tbl.c'.  */
  51. extern const struct _msg_ent _msg_tbl[];
  52. extern int _msg_tbl_length;
  53.  
  54.  
  55. /* Look up MSGID in the current default message catalog for the current
  56.    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
  57.    text).  */
  58. extern char *gettext __P ((const char *__msgid));
  59.  
  60. /* Look up MSGID in the DOMAINNAME message catalog for the current
  61.    LC_MESSAGES locale.  */
  62. extern char *dgettext __P ((const char *__domainname, const char *__msgid));
  63.  
  64. /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
  65.    locale.  */
  66. extern char *dcgettext __P ((const char *__domainname, const char *__msgid,
  67.                  int __category));
  68.  
  69.  
  70. /* Set the current default message catalog to DOMAINNAME.
  71.    If DOMAINNAME is null, return the current default.
  72.    If DOMAINNAME is "", reset to the default of "messages".  */
  73. extern char *textdomain __P ((const char *__domainname));
  74.  
  75. /* Specify that the DOMAINNAME message catalog will be found
  76.    in DIRNAME rather than in the system locale data base.  */
  77. extern char *bindtextdomain __P ((const char *__domainname,
  78.                   const char *__dirname));
  79.  
  80. #if defined ENABLE_NLS
  81.  
  82. # if !defined HAVE_CATGETS
  83.  
  84. #  define gettext(msgid)                dgettext (NULL, msgid)
  85.  
  86. #  define dgettext(domainname, msgid) \
  87.                                      dcgettext (domainname, msgid, LC_MESSAGES)
  88.  
  89. /* Amiga Hack - the following fails for the Amiga 2.7.0 compiler for some reason. */
  90. #  if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ >= 7 && 0
  91. #   define    dcgettext(domainname, msgid, category)                  \
  92.   (__extension__                                  \
  93.    ({                                          \
  94.      if (__builtin_constant_p (msgid))                          \
  95.        {                                      \
  96.      extern int _nl_msg_cat_cntr;                          \
  97.      static char *__translation__;                          \
  98.      static int __catalog_counter__;                      \
  99.      if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr)    \
  100.        {                                      \
  101.          __translation__ =                              \
  102.            (dcgettext) ((domainname), (msgid), (category));              \
  103.          __catalog_counter__ = _nl_msg_cat_cntr;                  \
  104.        }                                      \
  105.      __translation__;                              \
  106.        }                                      \
  107.      else                                      \
  108.        (dcgettext) ((domainname), (msgid), (category));                  \
  109.     }))
  110. #  endif
  111. # endif
  112.  
  113. #else
  114.  
  115. # define gettext(msgid) (msgid)
  116. # define dgettext(domainname, msgid) (msgid)
  117. # define dcgettext(domainname, msgid, category) (msgid)
  118. # define textdomain(domainname) while (0) /* nothing */
  119. # define bindtextdomain(domainname, dirname) while (0) /* nothing */
  120.  
  121. #endif
  122.  
  123. /* @@ begin of epilog @@ */
  124.  
  125. #endif    /* libgettext.h */
  126.