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