1 |
/* Message catalogs for internationalization.
|
2 |
Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
|
3 |
|
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.
|
8 |
|
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.
|
13 |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
17 |
USA. */
|
18 |
|
19 |
#ifndef _LIBINTL_H
|
20 |
#define _LIBINTL_H 1
|
21 |
#include "config.h"
|
22 |
|
23 |
#include <locale.h>
|
24 |
|
25 |
/* The LC_MESSAGES locale category is the category used by the functions
|
26 |
gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
|
27 |
On systems that don't define it, use an arbitrary value instead.
|
28 |
On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
|
29 |
then includes <libintl.h> (i.e. this file!) and then only defines
|
30 |
LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
|
31 |
in this case. */
|
32 |
#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
|
33 |
# define LC_MESSAGES 1729
|
34 |
#endif
|
35 |
|
36 |
/* We define an additional symbol to signal that we use the GNU
|
37 |
implementation of gettext. */
|
38 |
#define __USE_GNU_GETTEXT 1
|
39 |
|
40 |
/* Provide information about the supported file formats. Returns the
|
41 |
maximum minor revision number supported for a given major revision. */
|
42 |
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
|
43 |
((major) == 0 ? 1 : -1)
|
44 |
|
45 |
/* Resolve a platform specific conflict on DJGPP. GNU gettext takes
|
46 |
precedence over _conio_gettext. */
|
47 |
#ifdef __DJGPP__
|
48 |
# undef gettext
|
49 |
#endif
|
50 |
|
51 |
#ifdef __cplusplus
|
52 |
extern "C" {
|
53 |
#endif
|
54 |
|
55 |
|
56 |
/* We redirect the functions to those prefixed with "libintl_". This is
|
57 |
necessary, because some systems define gettext/textdomain/... in the C
|
58 |
library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
|
59 |
If we used the unprefixed names, there would be cases where the
|
60 |
definition in the C library would override the one in the libintl.so
|
61 |
shared library. Recall that on ELF systems, the symbols are looked
|
62 |
up in the following order:
|
63 |
1. in the executable,
|
64 |
2. in the shared libraries specified on the link command line, in order,
|
65 |
3. in the dependencies of the shared libraries specified on the link
|
66 |
command line,
|
67 |
4. in the dlopen()ed shared libraries, in the order in which they were
|
68 |
dlopen()ed.
|
69 |
The definition in the C library would override the one in libintl.so if
|
70 |
either
|
71 |
* -lc is given on the link command line and -lintl isn't, or
|
72 |
* -lc is given on the link command line before -lintl, or
|
73 |
* libintl.so is a dependency of a dlopen()ed shared library but not
|
74 |
linked to the executable at link time.
|
75 |
Since Solaris gettext() behaves differently than GNU gettext(), this
|
76 |
would be unacceptable.
|
77 |
|
78 |
The redirection happens by default through macros in C, so that &gettext
|
79 |
is independent of the compilation unit, but through inline functions in
|
80 |
C++, in order not to interfere with the name mangling of class fields or
|
81 |
class methods called 'gettext'. */
|
82 |
|
83 |
/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
|
84 |
If he doesn't, we choose the method. A third possible method is
|
85 |
_INTL_REDIRECT_ASM, supported only by GCC. */
|
86 |
#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
|
87 |
# if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
|
88 |
# define _INTL_REDIRECT_ASM
|
89 |
# else
|
90 |
# ifdef __cplusplus
|
91 |
# define _INTL_REDIRECT_INLINE
|
92 |
# else
|
93 |
# define _INTL_REDIRECT_MACROS
|
94 |
# endif
|
95 |
# endif
|
96 |
#endif
|
97 |
/* Auxiliary macros. */
|
98 |
#ifdef _INTL_REDIRECT_ASM
|
99 |
# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
|
100 |
# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
|
101 |
# define _INTL_STRINGIFY(prefix) #prefix
|
102 |
#else
|
103 |
# define _INTL_ASM(cname)
|
104 |
#endif
|
105 |
|
106 |
/* Look up MSGID in the current default message catalog for the current
|
107 |
LC_MESSAGES locale. If not found, returns MSGID itself (the default
|
108 |
text). */
|
109 |
#ifdef _INTL_REDIRECT_INLINE
|
110 |
extern char *libintl_gettext (const char *__msgid);
|
111 |
static inline char *gettext (const char *__msgid)
|
112 |
{
|
113 |
return libintl_gettext (__msgid);
|
114 |
}
|
115 |
#else
|
116 |
#ifdef _INTL_REDIRECT_MACROS
|
117 |
# define gettext libintl_gettext
|
118 |
#endif
|
119 |
extern char *gettext (const char *__msgid)
|
120 |
_INTL_ASM (libintl_gettext);
|
121 |
#endif
|
122 |
|
123 |
/* Look up MSGID in the DOMAINNAME message catalog for the current
|
124 |
LC_MESSAGES locale. */
|
125 |
#ifdef _INTL_REDIRECT_INLINE
|
126 |
extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
|
127 |
static inline char *dgettext (const char *__domainname, const char *__msgid)
|
128 |
{
|
129 |
return libintl_dgettext (__domainname, __msgid);
|
130 |
}
|
131 |
#else
|
132 |
#ifdef _INTL_REDIRECT_MACROS
|
133 |
# define dgettext libintl_dgettext
|
134 |
#endif
|
135 |
extern char *dgettext (const char *__domainname, const char *__msgid)
|
136 |
_INTL_ASM (libintl_dgettext);
|
137 |
#endif
|
138 |
|
139 |
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
|
140 |
locale. */
|
141 |
#ifdef _INTL_REDIRECT_INLINE
|
142 |
extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
|
143 |
int __category);
|
144 |
static inline char *dcgettext (const char *__domainname, const char *__msgid,
|
145 |
int __category)
|
146 |
{
|
147 |
return libintl_dcgettext (__domainname, __msgid, __category);
|
148 |
}
|
149 |
#else
|
150 |
#ifdef _INTL_REDIRECT_MACROS
|
151 |
# define dcgettext libintl_dcgettext
|
152 |
#endif
|
153 |
extern char *dcgettext (const char *__domainname, const char *__msgid,
|
154 |
int __category)
|
155 |
_INTL_ASM (libintl_dcgettext);
|
156 |
#endif
|
157 |
|
158 |
|
159 |
/* Similar to `gettext' but select the plural form corresponding to the
|
160 |
number N. */
|
161 |
#ifdef _INTL_REDIRECT_INLINE
|
162 |
extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
|
163 |
unsigned long int __n);
|
164 |
static inline char *ngettext (const char *__msgid1, const char *__msgid2,
|
165 |
unsigned long int __n)
|
166 |
{
|
167 |
return libintl_ngettext (__msgid1, __msgid2, __n);
|
168 |
}
|
169 |
#else
|
170 |
#ifdef _INTL_REDIRECT_MACROS
|
171 |
# define ngettext libintl_ngettext
|
172 |
#endif
|
173 |
extern char *ngettext (const char *__msgid1, const char *__msgid2,
|
174 |
unsigned long int __n)
|
175 |
_INTL_ASM (libintl_ngettext);
|
176 |
#endif
|
177 |
|
178 |
/* Similar to `dgettext' but select the plural form corresponding to the
|
179 |
number N. */
|
180 |
#ifdef _INTL_REDIRECT_INLINE
|
181 |
extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
|
182 |
const char *__msgid2, unsigned long int __n);
|
183 |
static inline char *dngettext (const char *__domainname, const char *__msgid1,
|
184 |
const char *__msgid2, unsigned long int __n)
|
185 |
{
|
186 |
return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
|
187 |
}
|
188 |
#else
|
189 |
#ifdef _INTL_REDIRECT_MACROS
|
190 |
# define dngettext libintl_dngettext
|
191 |
#endif
|
192 |
extern char *dngettext (const char *__domainname,
|
193 |
const char *__msgid1, const char *__msgid2,
|
194 |
unsigned long int __n)
|
195 |
_INTL_ASM (libintl_dngettext);
|
196 |
#endif
|
197 |
|
198 |
/* Similar to `dcgettext' but select the plural form corresponding to the
|
199 |
number N. */
|
200 |
#ifdef _INTL_REDIRECT_INLINE
|
201 |
extern char *libintl_dcngettext (const char *__domainname,
|
202 |
const char *__msgid1, const char *__msgid2,
|
203 |
unsigned long int __n, int __category);
|
204 |
static inline char *dcngettext (const char *__domainname,
|
205 |
const char *__msgid1, const char *__msgid2,
|
206 |
unsigned long int __n, int __category)
|
207 |
{
|
208 |
return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
|
209 |
}
|
210 |
#else
|
211 |
#ifdef _INTL_REDIRECT_MACROS
|
212 |
# define dcngettext libintl_dcngettext
|
213 |
#endif
|
214 |
extern char *dcngettext (const char *__domainname,
|
215 |
const char *__msgid1, const char *__msgid2,
|
216 |
unsigned long int __n, int __category)
|
217 |
_INTL_ASM (libintl_dcngettext);
|
218 |
#endif
|
219 |
|
220 |
|
221 |
/* Set the current default message catalog to DOMAINNAME.
|
222 |
If DOMAINNAME is null, return the current default.
|
223 |
If DOMAINNAME is "", reset to the default of "messages". */
|
224 |
#ifdef _INTL_REDIRECT_INLINE
|
225 |
extern char *libintl_textdomain (const char *__domainname);
|
226 |
static inline char *textdomain (const char *__domainname)
|
227 |
{
|
228 |
return libintl_textdomain (__domainname);
|
229 |
}
|
230 |
#else
|
231 |
#ifdef _INTL_REDIRECT_MACROS
|
232 |
# define textdomain libintl_textdomain
|
233 |
#endif
|
234 |
extern char *textdomain (const char *__domainname)
|
235 |
_INTL_ASM (libintl_textdomain);
|
236 |
#endif
|
237 |
|
238 |
/* Specify that the DOMAINNAME message catalog will be found
|
239 |
in DIRNAME rather than in the system locale data base. */
|
240 |
#ifdef _INTL_REDIRECT_INLINE
|
241 |
extern char *libintl_bindtextdomain (const char *__domainname,
|
242 |
const char *__dirname);
|
243 |
static inline char *bindtextdomain (const char *__domainname,
|
244 |
const char *__dirname)
|
245 |
{
|
246 |
return libintl_bindtextdomain (__domainname, __dirname);
|
247 |
}
|
248 |
#else
|
249 |
#ifdef _INTL_REDIRECT_MACROS
|
250 |
# define bindtextdomain libintl_bindtextdomain
|
251 |
#endif
|
252 |
extern char *bindtextdomain (const char *__domainname, const char *__dirname)
|
253 |
_INTL_ASM (libintl_bindtextdomain);
|
254 |
#endif
|
255 |
|
256 |
/* Specify the character encoding in which the messages from the
|
257 |
DOMAINNAME message catalog will be returned. */
|
258 |
#ifdef _INTL_REDIRECT_INLINE
|
259 |
extern char *libintl_bind_textdomain_codeset (const char *__domainname,
|
260 |
const char *__codeset);
|
261 |
static inline char *bind_textdomain_codeset (const char *__domainname,
|
262 |
const char *__codeset)
|
263 |
{
|
264 |
return libintl_bind_textdomain_codeset (__domainname, __codeset);
|
265 |
}
|
266 |
#else
|
267 |
#ifdef _INTL_REDIRECT_MACROS
|
268 |
# define bind_textdomain_codeset libintl_bind_textdomain_codeset
|
269 |
#endif
|
270 |
extern char *bind_textdomain_codeset (const char *__domainname,
|
271 |
const char *__codeset)
|
272 |
_INTL_ASM (libintl_bind_textdomain_codeset);
|
273 |
#endif
|
274 |
|
275 |
|
276 |
/* Support for format strings with positions in *printf(), following the
|
277 |
POSIX/XSI specification.
|
278 |
Note: These replacements for the *printf() functions are visible only
|
279 |
in source files that #include <libintl.h> or #include "gettext.h".
|
280 |
Packages that use *printf() in source files that don't refer to _()
|
281 |
or gettext() but for which the format string could be the return value
|
282 |
of _() or gettext() need to add this #include. Oh well. */
|
283 |
|
284 |
#if 1
|
285 |
|
286 |
#include <stdio.h>
|
287 |
#include <stddef.h>
|
288 |
|
289 |
/* Get va_list. */
|
290 |
#if __STDC__ || defined __cplusplus || defined _MSC_VER
|
291 |
# include <stdarg.h>
|
292 |
#else
|
293 |
# include <varargs.h>
|
294 |
#endif
|
295 |
|
296 |
#undef fprintf
|
297 |
#define fprintf libintl_fprintf
|
298 |
extern int fprintf (FILE *, const char *, ...);
|
299 |
#undef vfprintf
|
300 |
#define vfprintf libintl_vfprintf
|
301 |
extern int vfprintf (FILE *, const char *, va_list);
|
302 |
|
303 |
#undef printf
|
304 |
#define printf libintl_printf
|
305 |
extern int printf (const char *, ...);
|
306 |
#undef vprintf
|
307 |
#define vprintf libintl_vprintf
|
308 |
extern int vprintf (const char *, va_list);
|
309 |
|
310 |
#undef sprintf
|
311 |
#define sprintf libintl_sprintf
|
312 |
extern int sprintf (char *, const char *, ...);
|
313 |
#undef vsprintf
|
314 |
#define vsprintf libintl_vsprintf
|
315 |
extern int vsprintf (char *, const char *, va_list);
|
316 |
|
317 |
#if HAVE_SNPRINTF
|
318 |
|
319 |
#undef snprintf
|
320 |
#define snprintf libintl_snprintf
|
321 |
extern int snprintf (char *, size_t, const char *, ...);
|
322 |
#undef vsnprintf
|
323 |
#define vsnprintf libintl_vsnprintf
|
324 |
extern int vsnprintf (char *, size_t, const char *, va_list);
|
325 |
|
326 |
#endif
|
327 |
|
328 |
#if HAVE_ASPRINTF
|
329 |
|
330 |
#undef asprintf
|
331 |
#define asprintf libintl_asprintf
|
332 |
extern int asprintf (char **, const char *, ...);
|
333 |
#undef vasprintf
|
334 |
#define vasprintf libintl_vasprintf
|
335 |
extern int vasprintf (char **, const char *, va_list);
|
336 |
|
337 |
#endif
|
338 |
|
339 |
#if HAVE_WPRINTF
|
340 |
|
341 |
#undef fwprintf
|
342 |
#define fwprintf libintl_fwprintf
|
343 |
extern int fwprintf (FILE *, const wchar_t *, ...);
|
344 |
#undef vfwprintf
|
345 |
#define vfwprintf libintl_vfwprintf
|
346 |
extern int vfwprintf (FILE *, const wchar_t *, va_list);
|
347 |
|
348 |
#undef wprintf
|
349 |
#define wprintf libintl_wprintf
|
350 |
extern int wprintf (const wchar_t *, ...);
|
351 |
#undef vwprintf
|
352 |
#define vwprintf libintl_vwprintf
|
353 |
extern int vwprintf (const wchar_t *, va_list);
|
354 |
|
355 |
#undef swprintf
|
356 |
#define swprintf libintl_swprintf
|
357 |
extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
|
358 |
#undef vswprintf
|
359 |
#define vswprintf libintl_vswprintf
|
360 |
extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
|
361 |
|
362 |
#endif
|
363 |
|
364 |
#endif
|
365 |
|
366 |
|
367 |
/* Support for relocatable packages. */
|
368 |
|
369 |
/* Sets the original and the current installation prefix of the package.
|
370 |
Relocation simply replaces a pathname starting with the original prefix
|
371 |
by the corresponding pathname with the current prefix instead. Both
|
372 |
prefixes should be directory names without trailing slash (i.e. use ""
|
373 |
instead of "/"). */
|
374 |
#define libintl_set_relocation_prefix libintl_set_relocation_prefix
|
375 |
extern void
|
376 |
libintl_set_relocation_prefix (const char *orig_prefix,
|
377 |
const char *curr_prefix);
|
378 |
|
379 |
|
380 |
#ifdef __cplusplus
|
381 |
}
|
382 |
#endif
|
383 |
|
384 |
#endif /* libintl.h */
|