1 /* Begin of libgettext.h */
2 
3 /* Message catalogs for internationalization.
4    Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software Foundation,
18    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19 
20 /* Because on some systems (e.g. Solaris) we sometimes have to include
21    the systems libintl.h as well as this file we have more complex
22    include protection above.  But the systems header might perhaps also
23    define _LIBINTL_H and therefore we have to protect the definition here.  */
24 
25 #if !defined _LIBINTL_H || !defined _LIBGETTEXT_H
26 #ifndef _LIBINTL_H
27 # define _LIBINTL_H	1
28 #endif
29 #define _LIBGETTEXT_H	1
30 
31 /* We define an additional symbol to signal that we use the GNU
32    implementation of gettext.  */
33 #define __USE_GNU_GETTEXT 1
34 
35 #include <sys/types.h>
36 
37 #if HAVE_LOCALE_H
38 # include <locale.h>
39 #endif
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #ifndef PARAMS
46 # if __STDC__ || defined __cplusplus
47 #  define PARAMS(args) args
48 # else
49 #  define PARAMS(args) ()
50 # endif
51 #endif
52 
53 #ifndef NULL
54 # if !defined __cplusplus || defined __GNUC__
55 #  define NULL ((void *) 0)
56 # else
57 #  define NULL (0)
58 # endif
59 #endif
60 
61 #if !HAVE_LC_MESSAGES
62 /* This value determines the behaviour of the gettext() and dgettext()
63    function.  But some system does not have this defined.  Define it
64    to a default value.  */
65 # define LC_MESSAGES (-1)
66 #endif
67 
68 /* Declarations for gettext-using-catgets interface.  Derived from
69    Jim Meyering's libintl.h.  */
70 struct _msg_ent
71 {
72   const char *_msg;
73   int _msg_number;
74 };
75 
76 #if HAVE_CATGETS
77 /* These two variables are defined in the automatically by po-to-tbl.sed
78    generated file `cat-id-tbl.c'.  */
79 extern const struct _msg_ent _msg_tbl[];
80 extern int _msg_tbl_length;
81 #endif
82 
83 /* For automatical extraction of messages sometimes no real
84    translation is needed.  Instead the string itself is the result.  */
85 #define gettext_noop(Str) (Str)
86 
87 /* Look up MSGID in the current default message catalog for the current
88    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
89    text).  */
90 extern char *gettext PARAMS ((const char *__msgid));
91 static char *gettext__ PARAMS ((const char *__msgid));
92 
93 /* Look up MSGID in the DOMAINNAME message catalog for the current
94    LC_MESSAGES locale.  */
95 extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid));
96 static char *dgettext__ PARAMS ((const char *__domainname,
97 				 const char *__msgid));
98 
99 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
100    locale.  */
101 extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid,
102 				int __category));
103 extern char *dcgettext__ PARAMS ((const char *__domainname,
104 				  const char *__msgid, int __category));
105 
106 /* Set the current default message catalog to DOMAINNAME.
107    If DOMAINNAME is null, return the current default.
108    If DOMAINNAME is "", reset to the default of "messages".  */
109 extern char *textdomain PARAMS ((const char *__domainname));
110 static char *textdomain__ PARAMS ((const char *__domainname));
111 
112 /* Specify that the DOMAINNAME message catalog will be found
113    in DIRNAME rather than in the system locale data base.  */
114 extern char *bindtextdomain PARAMS ((const char *__domainname,
115 				  const char *__dirname));
116 static char *bindtextdomain__ PARAMS ((const char *__domainname,
117 				    const char *__dirname));
118 
119 #if ENABLE_NLS
120 
121 /* Solaris 2.3 has the gettext function but dcgettext is missing.
122    So we omit this optimization for Solaris 2.3.  BTW, Solaris 2.4
123    has dcgettext.  */
124 # if !HAVE_CATGETS && (!HAVE_GETTEXT || HAVE_DCGETTEXT)
125 
126 #  define gettext(Msgid)						      \
127      dgettext (NULL, Msgid)
128 
129 #  define dgettext(Domainname, Msgid)					      \
130      dcgettext (Domainname, Msgid, LC_MESSAGES)
131 
132 #  if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ >= 7
133 /* This global variable is defined in loadmsgcat.c.  We need a sign,
134    whether a new catalog was loaded, which can be associated with all
135    translations.  */
136 extern int _nl_msg_cat_cntr;
137 
138 #   define dcgettext(Domainname, Msgid, Category)			      \
139   (__extension__							      \
140    ({									      \
141      char *__result;							      \
142      if (__builtin_constant_p (Msgid))					      \
143        {								      \
144 	 static char *__translation__;					      \
145 	 static int __catalog_counter__;				      \
146 	 if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr)    \
147 	   {								      \
148 	     __translation__ =						      \
149 	       dcgettext__ (Domainname, Msgid, Category);		      \
150 	     __catalog_counter__ = _nl_msg_cat_cntr;			      \
151 	   }								      \
152 	 __result = __translation__;					      \
153        }								      \
154      else								      \
155        __result = dcgettext__ (Domainname, Msgid, Category);		      \
156      __result;								      \
157     }))
158 #  endif
159 # endif
160 
161 #else
162 
163 # define gettext(Msgid) (Msgid)
164 # define dgettext(Domainname, Msgid) (Msgid)
165 # define dcgettext(Domainname, Msgid, Category) (Msgid)
166 # define textdomain(Domainname) ((char *) Domainname)
167 # define bindtextdomain(Domainname, Dirname) ((char *) Dirname)
168 
169 #endif
170 
171 #ifdef __cplusplus
172 }
173 #endif
174 
175 #endif
176 
177 /* End of libgettext.h */
178