Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-runtime / intl / libgnuintl.in.h
1 /* Message catalogs for internationalization.
2    Copyright (C) 1995-1997, 2000-2015 Free Software Foundation,
3    Inc.
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU Lesser General Public License as published by
7    the Free Software Foundation; either version 2.1 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 #ifndef _LIBINTL_H
19 #define _LIBINTL_H 1
20
21 #include <locale.h>
22 #if (defined __APPLE__ && defined __MACH__) && @HAVE_NEWLOCALE@
23 # include <xlocale.h>
24 #endif
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 || (major) == 1 ? 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 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56
57 /* Version number: (major<<16) + (minor<<8) + subminor */
58 #define LIBINTL_VERSION 0x001307
59 extern int libintl_version;
60
61
62 /* We redirect the functions to those prefixed with "libintl_".  This is
63    necessary, because some systems define gettext/textdomain/... in the C
64    library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
65    If we used the unprefixed names, there would be cases where the
66    definition in the C library would override the one in the libintl.so
67    shared library.  Recall that on ELF systems, the symbols are looked
68    up in the following order:
69      1. in the executable,
70      2. in the shared libraries specified on the link command line, in order,
71      3. in the dependencies of the shared libraries specified on the link
72         command line,
73      4. in the dlopen()ed shared libraries, in the order in which they were
74         dlopen()ed.
75    The definition in the C library would override the one in libintl.so if
76    either
77      * -lc is given on the link command line and -lintl isn't, or
78      * -lc is given on the link command line before -lintl, or
79      * libintl.so is a dependency of a dlopen()ed shared library but not
80        linked to the executable at link time.
81    Since Solaris gettext() behaves differently than GNU gettext(), this
82    would be unacceptable.
83
84    The redirection happens by default through macros in C, so that &gettext
85    is independent of the compilation unit, but through inline functions in
86    C++, in order not to interfere with the name mangling of class fields or
87    class methods called 'gettext'.  */
88
89 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
90    If he doesn't, we choose the method.  A third possible method is
91    _INTL_REDIRECT_ASM, supported only by GCC.  */
92 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
93 # if defined __GNUC__ && __GNUC__ >= 2 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
94 #  define _INTL_REDIRECT_ASM
95 # else
96 #  ifdef __cplusplus
97 #   define _INTL_REDIRECT_INLINE
98 #  else
99 #   define _INTL_REDIRECT_MACROS
100 #  endif
101 # endif
102 #endif
103 /* Auxiliary macros.  */
104 #ifdef _INTL_REDIRECT_ASM
105 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
106 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
107 # define _INTL_STRINGIFY(prefix) #prefix
108 #else
109 # define _INTL_ASM(cname)
110 #endif
111
112 /* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
113    its n-th argument literally.  This enables GCC to warn for example about
114    printf (gettext ("foo %y")).  */
115 #if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1 && defined __cplusplus)
116 # define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
117 #else
118 # define _INTL_MAY_RETURN_STRING_ARG(n)
119 #endif
120
121 /* Look up MSGID in the current default message catalog for the current
122    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
123    text).  */
124 #ifdef _INTL_REDIRECT_INLINE
125 extern char *libintl_gettext (const char *__msgid)
126        _INTL_MAY_RETURN_STRING_ARG (1);
127 static inline char *gettext (const char *__msgid)
128 {
129   return libintl_gettext (__msgid);
130 }
131 #else
132 #ifdef _INTL_REDIRECT_MACROS
133 # define gettext libintl_gettext
134 #endif
135 extern char *gettext (const char *__msgid)
136        _INTL_ASM (libintl_gettext)
137        _INTL_MAY_RETURN_STRING_ARG (1);
138 #endif
139
140 /* Look up MSGID in the DOMAINNAME message catalog for the current
141    LC_MESSAGES locale.  */
142 #ifdef _INTL_REDIRECT_INLINE
143 extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
144        _INTL_MAY_RETURN_STRING_ARG (2);
145 static inline char *dgettext (const char *__domainname, const char *__msgid)
146 {
147   return libintl_dgettext (__domainname, __msgid);
148 }
149 #else
150 #ifdef _INTL_REDIRECT_MACROS
151 # define dgettext libintl_dgettext
152 #endif
153 extern char *dgettext (const char *__domainname, const char *__msgid)
154        _INTL_ASM (libintl_dgettext)
155        _INTL_MAY_RETURN_STRING_ARG (2);
156 #endif
157
158 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
159    locale.  */
160 #ifdef _INTL_REDIRECT_INLINE
161 extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
162                                 int __category)
163        _INTL_MAY_RETURN_STRING_ARG (2);
164 static inline char *dcgettext (const char *__domainname, const char *__msgid,
165                                int __category)
166 {
167   return libintl_dcgettext (__domainname, __msgid, __category);
168 }
169 #else
170 #ifdef _INTL_REDIRECT_MACROS
171 # define dcgettext libintl_dcgettext
172 #endif
173 extern char *dcgettext (const char *__domainname, const char *__msgid,
174                         int __category)
175        _INTL_ASM (libintl_dcgettext)
176        _INTL_MAY_RETURN_STRING_ARG (2);
177 #endif
178
179
180 /* Similar to 'gettext' but select the plural form corresponding to the
181    number N.  */
182 #ifdef _INTL_REDIRECT_INLINE
183 extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
184                                unsigned long int __n)
185        _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
186 static inline char *ngettext (const char *__msgid1, const char *__msgid2,
187                               unsigned long int __n)
188 {
189   return libintl_ngettext (__msgid1, __msgid2, __n);
190 }
191 #else
192 #ifdef _INTL_REDIRECT_MACROS
193 # define ngettext libintl_ngettext
194 #endif
195 extern char *ngettext (const char *__msgid1, const char *__msgid2,
196                        unsigned long int __n)
197        _INTL_ASM (libintl_ngettext)
198        _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
199 #endif
200
201 /* Similar to 'dgettext' but select the plural form corresponding to the
202    number N.  */
203 #ifdef _INTL_REDIRECT_INLINE
204 extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
205                                 const char *__msgid2, unsigned long int __n)
206        _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
207 static inline char *dngettext (const char *__domainname, const char *__msgid1,
208                                const char *__msgid2, unsigned long int __n)
209 {
210   return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
211 }
212 #else
213 #ifdef _INTL_REDIRECT_MACROS
214 # define dngettext libintl_dngettext
215 #endif
216 extern char *dngettext (const char *__domainname,
217                         const char *__msgid1, const char *__msgid2,
218                         unsigned long int __n)
219        _INTL_ASM (libintl_dngettext)
220        _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
221 #endif
222
223 /* Similar to 'dcgettext' but select the plural form corresponding to the
224    number N.  */
225 #ifdef _INTL_REDIRECT_INLINE
226 extern char *libintl_dcngettext (const char *__domainname,
227                                  const char *__msgid1, const char *__msgid2,
228                                  unsigned long int __n, int __category)
229        _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
230 static inline char *dcngettext (const char *__domainname,
231                                 const char *__msgid1, const char *__msgid2,
232                                 unsigned long int __n, int __category)
233 {
234   return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
235 }
236 #else
237 #ifdef _INTL_REDIRECT_MACROS
238 # define dcngettext libintl_dcngettext
239 #endif
240 extern char *dcngettext (const char *__domainname,
241                          const char *__msgid1, const char *__msgid2,
242                          unsigned long int __n, int __category)
243        _INTL_ASM (libintl_dcngettext)
244        _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
245 #endif
246
247
248 #ifndef IN_LIBGLOCALE
249
250 /* Set the current default message catalog to DOMAINNAME.
251    If DOMAINNAME is null, return the current default.
252    If DOMAINNAME is "", reset to the default of "messages".  */
253 #ifdef _INTL_REDIRECT_INLINE
254 extern char *libintl_textdomain (const char *__domainname);
255 static inline char *textdomain (const char *__domainname)
256 {
257   return libintl_textdomain (__domainname);
258 }
259 #else
260 #ifdef _INTL_REDIRECT_MACROS
261 # define textdomain libintl_textdomain
262 #endif
263 extern char *textdomain (const char *__domainname)
264        _INTL_ASM (libintl_textdomain);
265 #endif
266
267 /* Specify that the DOMAINNAME message catalog will be found
268    in DIRNAME rather than in the system locale data base.  */
269 #ifdef _INTL_REDIRECT_INLINE
270 extern char *libintl_bindtextdomain (const char *__domainname,
271                                      const char *__dirname);
272 static inline char *bindtextdomain (const char *__domainname,
273                                     const char *__dirname)
274 {
275   return libintl_bindtextdomain (__domainname, __dirname);
276 }
277 #else
278 #ifdef _INTL_REDIRECT_MACROS
279 # define bindtextdomain libintl_bindtextdomain
280 #endif
281 extern char *bindtextdomain (const char *__domainname, const char *__dirname)
282        _INTL_ASM (libintl_bindtextdomain);
283 #endif
284
285 /* Specify the character encoding in which the messages from the
286    DOMAINNAME message catalog will be returned.  */
287 #ifdef _INTL_REDIRECT_INLINE
288 extern char *libintl_bind_textdomain_codeset (const char *__domainname,
289                                               const char *__codeset);
290 static inline char *bind_textdomain_codeset (const char *__domainname,
291                                              const char *__codeset)
292 {
293   return libintl_bind_textdomain_codeset (__domainname, __codeset);
294 }
295 #else
296 #ifdef _INTL_REDIRECT_MACROS
297 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
298 #endif
299 extern char *bind_textdomain_codeset (const char *__domainname,
300                                       const char *__codeset)
301        _INTL_ASM (libintl_bind_textdomain_codeset);
302 #endif
303
304 #endif /* IN_LIBGLOCALE */
305
306
307 /* Support for format strings with positions in *printf(), following the
308    POSIX/XSI specification.
309    Note: These replacements for the *printf() functions are visible only
310    in source files that #include <libintl.h> or #include "gettext.h".
311    Packages that use *printf() in source files that don't refer to _()
312    or gettext() but for which the format string could be the return value
313    of _() or gettext() need to add this #include.  Oh well.  */
314
315 #if !@HAVE_POSIX_PRINTF@
316
317 #include <stdio.h>
318 #include <stddef.h>
319
320 /* Get va_list.  */
321 #if (defined __STDC__ && __STDC__) || defined __cplusplus || defined _MSC_VER
322 # include <stdarg.h>
323 #else
324 # include <varargs.h>
325 #endif
326
327 #if !(defined fprintf && defined _GL_STDIO_H) /* don't override gnulib */
328 #undef fprintf
329 #define fprintf libintl_fprintf
330 extern int fprintf (FILE *, const char *, ...);
331 #endif
332 #if !(defined vfprintf && defined _GL_STDIO_H) /* don't override gnulib */
333 #undef vfprintf
334 #define vfprintf libintl_vfprintf
335 extern int vfprintf (FILE *, const char *, va_list);
336 #endif
337
338 #if !(defined printf && defined _GL_STDIO_H) /* don't override gnulib */
339 #undef printf
340 #if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__
341 /* Don't break __attribute__((format(printf,M,N))).
342    This redefinition is only possible because the libc in NetBSD, Cygwin,
343    mingw does not have a function __printf__.
344    Alternatively, we could have done this redirection only when compiling with
345    __GNUC__, together with a symbol redirection:
346        extern int printf (const char *, ...)
347               __asm__ (#__USER_LABEL_PREFIX__ "libintl_printf");
348    But doing it now would introduce a binary incompatibility with already
349    distributed versions of libintl on these systems.  */
350 # define libintl_printf __printf__
351 #endif
352 #define printf libintl_printf
353 extern int printf (const char *, ...);
354 #endif
355 #if !(defined vprintf && defined _GL_STDIO_H) /* don't override gnulib */
356 #undef vprintf
357 #define vprintf libintl_vprintf
358 extern int vprintf (const char *, va_list);
359 #endif
360
361 #if !(defined sprintf && defined _GL_STDIO_H) /* don't override gnulib */
362 #undef sprintf
363 #define sprintf libintl_sprintf
364 extern int sprintf (char *, const char *, ...);
365 #endif
366 #if !(defined vsprintf && defined _GL_STDIO_H) /* don't override gnulib */
367 #undef vsprintf
368 #define vsprintf libintl_vsprintf
369 extern int vsprintf (char *, const char *, va_list);
370 #endif
371
372 #if @HAVE_SNPRINTF@
373
374 #if !(defined snprintf && defined _GL_STDIO_H) /* don't override gnulib */
375 #undef snprintf
376 #define snprintf libintl_snprintf
377 extern int snprintf (char *, size_t, const char *, ...);
378 #endif
379 #if !(defined vsnprintf && defined _GL_STDIO_H) /* don't override gnulib */
380 #undef vsnprintf
381 #define vsnprintf libintl_vsnprintf
382 extern int vsnprintf (char *, size_t, const char *, va_list);
383 #endif
384
385 #endif
386
387 #if @HAVE_ASPRINTF@
388
389 #if !(defined asprintf && defined _GL_STDIO_H) /* don't override gnulib */
390 #undef asprintf
391 #define asprintf libintl_asprintf
392 extern int asprintf (char **, const char *, ...);
393 #endif
394 #if !(defined vasprintf && defined _GL_STDIO_H) /* don't override gnulib */
395 #undef vasprintf
396 #define vasprintf libintl_vasprintf
397 extern int vasprintf (char **, const char *, va_list);
398 #endif
399
400 #endif
401
402 #if @HAVE_WPRINTF@
403
404 #undef fwprintf
405 #define fwprintf libintl_fwprintf
406 extern int fwprintf (FILE *, const wchar_t *, ...);
407 #undef vfwprintf
408 #define vfwprintf libintl_vfwprintf
409 extern int vfwprintf (FILE *, const wchar_t *, va_list);
410
411 #undef wprintf
412 #define wprintf libintl_wprintf
413 extern int wprintf (const wchar_t *, ...);
414 #undef vwprintf
415 #define vwprintf libintl_vwprintf
416 extern int vwprintf (const wchar_t *, va_list);
417
418 #undef swprintf
419 #define swprintf libintl_swprintf
420 extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
421 #undef vswprintf
422 #define vswprintf libintl_vswprintf
423 extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
424
425 #endif
426
427 #endif
428
429
430 /* Support for the locale chosen by the user.  */
431 #if (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
432
433 #ifndef GNULIB_defined_setlocale /* don't override gnulib */
434 #undef setlocale
435 #define setlocale libintl_setlocale
436 extern char *setlocale (int, const char *);
437 #endif
438
439 #if @HAVE_NEWLOCALE@
440
441 #undef newlocale
442 #define newlocale libintl_newlocale
443 extern locale_t newlocale (int, const char *, locale_t);
444
445 #endif
446
447 #endif
448
449
450 /* Support for relocatable packages.  */
451
452 /* Sets the original and the current installation prefix of the package.
453    Relocation simply replaces a pathname starting with the original prefix
454    by the corresponding pathname with the current prefix instead.  Both
455    prefixes should be directory names without trailing slash (i.e. use ""
456    instead of "/").  */
457 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
458 extern void
459        libintl_set_relocation_prefix (const char *orig_prefix,
460                                       const char *curr_prefix);
461
462
463 #ifdef __cplusplus
464 }
465 #endif
466
467 #endif /* libintl.h */