Update.
[platform/upstream/glibc.git] / intl / libintl.h
1 /* Message catalogs for internationalization.
2    Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
3    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
4    This file is derived from the file libgettext.h in the GNU gettext package.
5
6    This file is part of the GNU C Library.  Its master source is NOT part of
7    the C library, however.
8
9    The GNU C Library is free software; you can redistribute it and/or
10    modify it under the terms of the GNU Library General Public License as
11    published by the Free Software Foundation; either version 2 of the
12    License, or (at your option) any later version.
13
14    The GNU C Library is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    Library General Public License for more details.
18
19    You should have received a copy of the GNU Library General Public
20    License along with the GNU C Library; see the file COPYING.LIB.  If not,
21    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22    Boston, MA 02111-1307, USA.  */
23
24 #ifndef _LIBINTL_H
25 #define _LIBINTL_H      1
26
27 #include <features.h>
28
29 /* We define an additional symbol to signal that we use the GNU
30    implementation of gettext.  */
31 #define __USE_GNU_GETTEXT 1
32
33 __BEGIN_DECLS
34
35 /* Look up MSGID in the current default message catalog for the current
36    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
37    text).  */
38 extern char *gettext __P ((__const char *__msgid));
39
40 /* Look up MSGID in the DOMAINNAME message catalog for the current
41    LC_MESSAGES locale.  */
42 extern char *dgettext __P ((__const char *__domainname,
43                             __const char *__msgid));
44 extern char *__dgettext __P ((__const char *__domainname,
45                               __const char *__msgid));
46
47 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
48    locale.  */
49 extern char *dcgettext __P ((__const char *__domainname,
50                              __const char *__msgid, int __category));
51 extern char *__dcgettext __P ((__const char *__domainname,
52                                __const char *__msgid, int __category));
53
54
55 /* Set the current default message catalog to DOMAINNAME.
56    If DOMAINNAME is null, return the current default.
57    If DOMAINNAME is "", reset to the default of "messages".  */
58 extern char *textdomain __P ((__const char *__domainname));
59
60 /* Specify that the DOMAINNAME message catalog will be found
61    in DIRNAME rather than in the system locale data base.  */
62 extern char *bindtextdomain __P ((__const char *__domainname,
63                                   __const char *__dirname));
64
65
66 /* Optimized version of the function above.  */
67 #if defined __OPTIMIZE__
68
69 /* We need NULL for `gettext'.  */
70 # define __need_NULL
71 # include <stddef.h>
72
73 /* We need LC_MESSAGES for `dgettext'.  */
74 # include <locale.h>
75
76 /* These must be macros.  Inlined functions are useless because the
77    `__builtin_constant_p' predicate in dcgettext would always return
78    false.  */
79
80 # define gettext(msgid) dgettext (NULL, msgid)
81
82 # define dgettext(domainname, msgid)                                          \
83   dcgettext (domainname, msgid, LC_MESSAGES)
84
85 # if __GNUC_PREREQ (2,7)
86 /* Variable defined in loadmsgcat.c which gets incremented every time a
87    new catalog is loaded.  */
88 extern int _nl_msg_cat_cntr;
89
90 #  define dcgettext(domainname, msgid, category)                              \
91   (__extension__                                                              \
92    ({                                                                         \
93      char *__result;                                                          \
94      if (__builtin_constant_p (msgid))                                        \
95        {                                                                      \
96          static char *__translation__;                                        \
97          static int __catalog_counter__;                                      \
98          if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr)    \
99            {                                                                  \
100              __translation__ =                                                \
101                __dcgettext ((domainname), (msgid), (category));               \
102              __catalog_counter__ = _nl_msg_cat_cntr;                          \
103            }                                                                  \
104          __result = __translation__;                                          \
105        }                                                                      \
106      else                                                                     \
107        __result = __dcgettext ((domainname), (msgid), (category));            \
108      __result;                                                                \
109     }))
110 # endif
111 #endif /* Optimizing. */
112
113
114 __END_DECLS
115
116 #endif /* libintl.h */