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