* locale/programs/xmalloc.c: Test _LIBC as well as STDC_HEADERS.
[platform/upstream/glibc.git] / intl / libintl.h
1 /* libgettext.h -- Message catalogs for internationalization.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Contributed by Ulrich Drepper.
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.  The master source lives in /gd/gnu/lib.
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
21 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
22 Cambridge, MA 02139, USA.  */
23
24 #ifndef _LIBINTL_H
25 #define _LIBINTL_H      1
26 #include <features.h>
27
28 #include <locale.h>
29
30 #define __need_NULL
31 #include <stddef.h>
32
33 /* We define an additional symbol to signal that we use the GNU
34    implementation of gettext.  */
35 #define __USE_GNU_GETTEXT 1
36
37 __BEGIN_DECLS
38
39 /* Look up MSGID in the current default message catalog for the current
40    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
41    text).  */
42 extern char *gettext __P ((__const char *__msgid));
43 extern char *__gettext __P ((__const char *__msgid));
44
45 /* Look up MSGID in the DOMAINNAME message catalog for the current
46    LC_MESSAGES locale.  */
47 extern char *dgettext __P ((__const char *__domainname,
48                             __const char *__msgid));
49 extern char *__dgettext __P ((__const char *__domainname,
50                               __const char *__msgid));
51
52 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
53    locale.  */
54 extern char *dcgettext __P ((__const char *__domainname,
55                              __const char *__msgid, int __category));
56 extern char *__dcgettext __P ((__const char *__domainname,
57                                __const char *__msgid, int __category));
58
59
60 /* Set the current default message catalog to DOMAINNAME.
61    If DOMAINNAME is null, return the current default.
62    If DOMAINNAME is "", reset to the default of "messages".  */
63 extern char *textdomain __P ((__const char *__domainname));
64 extern char *__textdomain __P ((__const char *__domainname));
65
66 /* Specify that the DOMAINNAME message catalog will be found
67    in DIRNAME rather than in the system locale data base.  */
68 extern char *bindtextdomain __P ((__const char *__domainname,
69                                   __const char *__dirname));
70 extern char *__bindtextdomain __P ((__const char *__domainname,
71                                     __const char *__dirname));
72
73
74 /* Optimized version of the function above.  */
75 #if defined __OPTIMIZED
76 /* These must be a macro.  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__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
86 #  define dcgettext(domainname, msgid, category)                              \
87   (__extension__                                                              \
88    ({                                                                         \
89      char *result;                                                            \
90      if (__builtin_constant_p (msgid))                                        \
91        {                                                                      \
92          extern int _nl_msg_cat_cntr;                                         \
93          static char *__translation__;                                        \
94          static int __catalog_counter__;                                      \
95          if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr)    \
96            {                                                                  \
97              __translation__ =                                                \
98                __dcgettext ((domainname), (msgid), (category));               \
99              __catalog_counter__ = _nl_msg_cat_cntr;                          \
100            }                                                                  \
101          result = __translation__;                                            \
102        }                                                                      \
103      else                                                                     \
104        result = __dcgettext ((domainname), (msgid), (category));              \
105      result;                                                                  \
106     }))
107 # endif
108 #endif /* Optimizing. */
109
110
111 __END_DECLS
112
113 #endif /* libintl.h */