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