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