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