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