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