root/lang/c/libintl-msvc/recipes/gettext-runtime/intl/libgnuintl.h @ 23481

Revision 23481, 14.9 kB (checked in by saturday06, 5 years ago)

initial commit

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