Upload Tizen:Base source
[external/bash.git] / lib / intl / libgnuintl.h.in
1 /* libgnuintl.h - Message catalogs for internationalization. */
2
3 /* Copyright (C) 1995-1997, 2000-2003, 2004-2009 Free Software Foundation, Inc.
4
5    This file is part of GNU Bash.
6
7    Bash is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11
12    Bash is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Bash.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _LIBINTL_H
22 #define _LIBINTL_H      1
23
24 #include <locale.h>
25
26 /* The LC_MESSAGES locale category is the category used by the functions
27    gettext() and dgettext().  It is specified in POSIX, but not in ANSI C.
28    On systems that don't define it, use an arbitrary value instead.
29    On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
30    then includes <libintl.h> (i.e. this file!) and then only defines
31    LC_MESSAGES.  To avoid a redefinition warning, don't define LC_MESSAGES
32    in this case.  */
33 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
34 # define LC_MESSAGES 1729
35 #endif
36
37 /* We define an additional symbol to signal that we use the GNU
38    implementation of gettext.  */
39 #define __USE_GNU_GETTEXT 1
40
41 /* Provide information about the supported file formats.  Returns the
42    maximum minor revision number supported for a given major revision.  */
43 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
44   ((major) == 0 ? 1 : -1)
45
46 /* Resolve a platform specific conflict on DJGPP.  GNU gettext takes
47    precedence over _conio_gettext.  */
48 #ifdef __DJGPP__
49 # undef gettext
50 #endif
51
52 /* Use _INTL_PARAMS, not PARAMS, in order to avoid clashes with identifiers
53    used by programs.  Similarly, test __PROTOTYPES, not PROTOTYPES.  */
54 #ifndef _INTL_PARAMS
55 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
56 #  define _INTL_PARAMS(args) args
57 # else
58 #  define _INTL_PARAMS(args) ()
59 # endif
60 #endif
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66
67 /* We redirect the functions to those prefixed with "libintl_".  This is
68    necessary, because some systems define gettext/textdomain/... in the C
69    library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
70    If we used the unprefixed names, there would be cases where the
71    definition in the C library would override the one in the libintl.so
72    shared library.  Recall that on ELF systems, the symbols are looked
73    up in the following order:
74      1. in the executable,
75      2. in the shared libraries specified on the link command line, in order,
76      3. in the dependencies of the shared libraries specified on the link
77         command line,
78      4. in the dlopen()ed shared libraries, in the order in which they were
79         dlopen()ed.
80    The definition in the C library would override the one in libintl.so if
81    either
82      * -lc is given on the link command line and -lintl isn't, or
83      * -lc is given on the link command line before -lintl, or
84      * libintl.so is a dependency of a dlopen()ed shared library but not
85        linked to the executable at link time.
86    Since Solaris gettext() behaves differently than GNU gettext(), this
87    would be unacceptable.
88
89    The redirection happens by default through macros in C, so that &gettext
90    is independent of the compilation unit, but through inline functions in
91    C++, in order not to interfere with the name mangling of class fields or
92    class methods called 'gettext'.  */
93
94 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
95    If he doesn't, we choose the method.  A third possible method is
96    _INTL_REDIRECT_ASM, supported only by GCC.  */
97 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
98 # if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
99 #  define _INTL_REDIRECT_ASM
100 # else
101 #  ifdef __cplusplus
102 #   define _INTL_REDIRECT_INLINE
103 #  else
104 #   define _INTL_REDIRECT_MACROS
105 #  endif
106 # endif
107 #endif
108 /* Auxiliary macros.  */
109 #ifdef _INTL_REDIRECT_ASM
110 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
111 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
112 # define _INTL_STRINGIFY(prefix) #prefix
113 #else
114 # define _INTL_ASM(cname)
115 #endif
116
117 /* Look up MSGID in the current default message catalog for the current
118    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
119    text).  */
120 #ifdef _INTL_REDIRECT_INLINE
121 extern char *libintl_gettext (const char *__msgid);
122 static inline char *gettext (const char *__msgid)
123 {
124   return libintl_gettext (__msgid);
125 }
126 #else
127 #ifdef _INTL_REDIRECT_MACROS
128 # define gettext libintl_gettext
129 #endif
130 extern char *gettext _INTL_PARAMS ((const char *__msgid))
131        _INTL_ASM (libintl_gettext);
132 #endif
133
134 /* Look up MSGID in the DOMAINNAME message catalog for the current
135    LC_MESSAGES locale.  */
136 #ifdef _INTL_REDIRECT_INLINE
137 extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
138 static inline char *dgettext (const char *__domainname, const char *__msgid)
139 {
140   return libintl_dgettext (__domainname, __msgid);
141 }
142 #else
143 #ifdef _INTL_REDIRECT_MACROS
144 # define dgettext libintl_dgettext
145 #endif
146 extern char *dgettext _INTL_PARAMS ((const char *__domainname,
147                                      const char *__msgid))
148        _INTL_ASM (libintl_dgettext);
149 #endif
150
151 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
152    locale.  */
153 #ifdef _INTL_REDIRECT_INLINE
154 extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
155                                 int __category);
156 static inline char *dcgettext (const char *__domainname, const char *__msgid,
157                                int __category)
158 {
159   return libintl_dcgettext (__domainname, __msgid, __category);
160 }
161 #else
162 #ifdef _INTL_REDIRECT_MACROS
163 # define dcgettext libintl_dcgettext
164 #endif
165 extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
166                                       const char *__msgid,
167                                       int __category))
168        _INTL_ASM (libintl_dcgettext);
169 #endif
170
171
172 /* Similar to `gettext' but select the plural form corresponding to the
173    number N.  */
174 #ifdef _INTL_REDIRECT_INLINE
175 extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
176                                unsigned long int __n);
177 static inline char *ngettext (const char *__msgid1, const char *__msgid2,
178                               unsigned long int __n)
179 {
180   return libintl_ngettext (__msgid1, __msgid2, __n);
181 }
182 #else
183 #ifdef _INTL_REDIRECT_MACROS
184 # define ngettext libintl_ngettext
185 #endif
186 extern char *ngettext _INTL_PARAMS ((const char *__msgid1,
187                                      const char *__msgid2,
188                                      unsigned long int __n))
189        _INTL_ASM (libintl_ngettext);
190 #endif
191
192 /* Similar to `dgettext' but select the plural form corresponding to the
193    number N.  */
194 #ifdef _INTL_REDIRECT_INLINE
195 extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
196                                 const char *__msgid2, unsigned long int __n);
197 static inline char *dngettext (const char *__domainname, const char *__msgid1,
198                                const char *__msgid2, unsigned long int __n)
199 {
200   return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
201 }
202 #else
203 #ifdef _INTL_REDIRECT_MACROS
204 # define dngettext libintl_dngettext
205 #endif
206 extern char *dngettext _INTL_PARAMS ((const char *__domainname,
207                                       const char *__msgid1,
208                                       const char *__msgid2,
209                                       unsigned long int __n))
210        _INTL_ASM (libintl_dngettext);
211 #endif
212
213 /* Similar to `dcgettext' but select the plural form corresponding to the
214    number N.  */
215 #ifdef _INTL_REDIRECT_INLINE
216 extern char *libintl_dcngettext (const char *__domainname,
217                                  const char *__msgid1, const char *__msgid2,
218                                  unsigned long int __n, int __category);
219 static inline char *dcngettext (const char *__domainname,
220                                 const char *__msgid1, const char *__msgid2,
221                                 unsigned long int __n, int __category)
222 {
223   return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
224 }
225 #else
226 #ifdef _INTL_REDIRECT_MACROS
227 # define dcngettext libintl_dcngettext
228 #endif
229 extern char *dcngettext _INTL_PARAMS ((const char *__domainname,
230                                        const char *__msgid1,
231                                        const char *__msgid2,
232                                        unsigned long int __n,
233                                        int __category))
234        _INTL_ASM (libintl_dcngettext);
235 #endif
236
237
238 /* Set the current default message catalog to DOMAINNAME.
239    If DOMAINNAME is null, return the current default.
240    If DOMAINNAME is "", reset to the default of "messages".  */
241 #ifdef _INTL_REDIRECT_INLINE
242 extern char *libintl_textdomain (const char *__domainname);
243 static inline char *textdomain (const char *__domainname)
244 {
245   return libintl_textdomain (__domainname);
246 }
247 #else
248 #ifdef _INTL_REDIRECT_MACROS
249 # define textdomain libintl_textdomain
250 #endif
251 extern char *textdomain _INTL_PARAMS ((const char *__domainname))
252        _INTL_ASM (libintl_textdomain);
253 #endif
254
255 /* Specify that the DOMAINNAME message catalog will be found
256    in DIRNAME rather than in the system locale data base.  */
257 #ifdef _INTL_REDIRECT_INLINE
258 extern char *libintl_bindtextdomain (const char *__domainname,
259                                      const char *__dirname);
260 static inline char *bindtextdomain (const char *__domainname,
261                                     const char *__dirname)
262 {
263   return libintl_bindtextdomain (__domainname, __dirname);
264 }
265 #else
266 #ifdef _INTL_REDIRECT_MACROS
267 # define bindtextdomain libintl_bindtextdomain
268 #endif
269 extern char *bindtextdomain _INTL_PARAMS ((const char *__domainname,
270                                            const char *__dirname))
271        _INTL_ASM (libintl_bindtextdomain);
272 #endif
273
274 /* Specify the character encoding in which the messages from the
275    DOMAINNAME message catalog will be returned.  */
276 #ifdef _INTL_REDIRECT_INLINE
277 extern char *libintl_bind_textdomain_codeset (const char *__domainname,
278                                               const char *__codeset);
279 static inline char *bind_textdomain_codeset (const char *__domainname,
280                                              const char *__codeset)
281 {
282   return libintl_bind_textdomain_codeset (__domainname, __codeset);
283 }
284 #else
285 #ifdef _INTL_REDIRECT_MACROS
286 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
287 #endif
288 extern char *bind_textdomain_codeset _INTL_PARAMS ((const char *__domainname,
289                                                     const char *__codeset))
290        _INTL_ASM (libintl_bind_textdomain_codeset);
291 #endif
292
293
294 /* Support for relocatable packages.  */
295
296 /* Sets the original and the current installation prefix of the package.
297    Relocation simply replaces a pathname starting with the original prefix
298    by the corresponding pathname with the current prefix instead.  Both
299    prefixes should be directory names without trailing slash (i.e. use ""
300    instead of "/").  */
301 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
302 extern void
303        libintl_set_relocation_prefix _INTL_PARAMS ((const char *orig_prefix,
304                                                     const char *curr_prefix));
305
306
307 #ifdef __cplusplus
308 }
309 #endif
310
311 #endif /* libintl.h */