14fee23f9Smrg /* Message catalogs for internationalization.
24fee23f9Smrg Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
34fee23f9Smrg
44fee23f9Smrg This program is free software; you can redistribute it and/or modify it
54fee23f9Smrg under the terms of the GNU Library General Public License as published
64fee23f9Smrg by the Free Software Foundation; either version 2, or (at your option)
74fee23f9Smrg any later version.
84fee23f9Smrg
94fee23f9Smrg This program is distributed in the hope that it will be useful,
104fee23f9Smrg but WITHOUT ANY WARRANTY; without even the implied warranty of
114fee23f9Smrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
124fee23f9Smrg Library General Public License for more details.
134fee23f9Smrg
144fee23f9Smrg You should have received a copy of the GNU Library General Public
154fee23f9Smrg License along with this program; if not, write to the Free Software
164fee23f9Smrg Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
174fee23f9Smrg USA. */
184fee23f9Smrg
194fee23f9Smrg #ifndef _LIBINTL_H
204fee23f9Smrg #define _LIBINTL_H 1
214fee23f9Smrg
224fee23f9Smrg #include <locale.h>
234fee23f9Smrg
244fee23f9Smrg /* The LC_MESSAGES locale category is the category used by the functions
254fee23f9Smrg gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
264fee23f9Smrg On systems that don't define it, use an arbitrary value instead.
274fee23f9Smrg On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
284fee23f9Smrg then includes <libintl.h> (i.e. this file!) and then only defines
294fee23f9Smrg LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
304fee23f9Smrg in this case. */
314fee23f9Smrg #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
324fee23f9Smrg # define LC_MESSAGES 1729
334fee23f9Smrg #endif
344fee23f9Smrg
354fee23f9Smrg /* We define an additional symbol to signal that we use the GNU
364fee23f9Smrg implementation of gettext. */
374fee23f9Smrg #define __USE_GNU_GETTEXT 1
384fee23f9Smrg
394fee23f9Smrg /* Provide information about the supported file formats. Returns the
404fee23f9Smrg maximum minor revision number supported for a given major revision. */
414fee23f9Smrg #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
424fee23f9Smrg ((major) == 0 ? 1 : -1)
434fee23f9Smrg
444fee23f9Smrg /* Resolve a platform specific conflict on DJGPP. GNU gettext takes
454fee23f9Smrg precedence over _conio_gettext. */
464fee23f9Smrg #ifdef __DJGPP__
474fee23f9Smrg # undef gettext
484fee23f9Smrg #endif
494fee23f9Smrg
504fee23f9Smrg /* Use _INTL_PARAMS, not PARAMS, in order to avoid clashes with identifiers
514fee23f9Smrg used by programs. Similarly, test __PROTOTYPES, not PROTOTYPES. */
524fee23f9Smrg #ifndef _INTL_PARAMS
534fee23f9Smrg # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
544fee23f9Smrg # define _INTL_PARAMS(args) args
554fee23f9Smrg # else
564fee23f9Smrg # define _INTL_PARAMS(args) ()
574fee23f9Smrg # endif
584fee23f9Smrg #endif
594fee23f9Smrg
604fee23f9Smrg #ifdef __cplusplus
614fee23f9Smrg extern "C" {
624fee23f9Smrg #endif
634fee23f9Smrg
644fee23f9Smrg
654fee23f9Smrg /* We redirect the functions to those prefixed with "libintl_". This is
664fee23f9Smrg necessary, because some systems define gettext/textdomain/... in the C
674fee23f9Smrg library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
684fee23f9Smrg If we used the unprefixed names, there would be cases where the
694fee23f9Smrg definition in the C library would override the one in the libintl.so
704fee23f9Smrg shared library. Recall that on ELF systems, the symbols are looked
714fee23f9Smrg up in the following order:
724fee23f9Smrg 1. in the executable,
734fee23f9Smrg 2. in the shared libraries specified on the link command line, in order,
744fee23f9Smrg 3. in the dependencies of the shared libraries specified on the link
754fee23f9Smrg command line,
764fee23f9Smrg 4. in the dlopen()ed shared libraries, in the order in which they were
774fee23f9Smrg dlopen()ed.
784fee23f9Smrg The definition in the C library would override the one in libintl.so if
794fee23f9Smrg either
804fee23f9Smrg * -lc is given on the link command line and -lintl isn't, or
814fee23f9Smrg * -lc is given on the link command line before -lintl, or
824fee23f9Smrg * libintl.so is a dependency of a dlopen()ed shared library but not
834fee23f9Smrg linked to the executable at link time.
844fee23f9Smrg Since Solaris gettext() behaves differently than GNU gettext(), this
854fee23f9Smrg would be unacceptable.
864fee23f9Smrg
874fee23f9Smrg The redirection happens by default through macros in C, so that &gettext
884fee23f9Smrg is independent of the compilation unit, but through inline functions in
894fee23f9Smrg C++, in order not to interfere with the name mangling of class fields or
904fee23f9Smrg class methods called 'gettext'. */
914fee23f9Smrg
924fee23f9Smrg /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
934fee23f9Smrg If he doesn't, we choose the method. A third possible method is
944fee23f9Smrg _INTL_REDIRECT_ASM, supported only by GCC. */
954fee23f9Smrg #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
964fee23f9Smrg # if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
974fee23f9Smrg # define _INTL_REDIRECT_ASM
984fee23f9Smrg # else
994fee23f9Smrg # ifdef __cplusplus
1004fee23f9Smrg # define _INTL_REDIRECT_INLINE
1014fee23f9Smrg # else
1024fee23f9Smrg # define _INTL_REDIRECT_MACROS
1034fee23f9Smrg # endif
1044fee23f9Smrg # endif
1054fee23f9Smrg #endif
1064fee23f9Smrg /* Auxiliary macros. */
1074fee23f9Smrg #ifdef _INTL_REDIRECT_ASM
1084fee23f9Smrg # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
1094fee23f9Smrg # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
1104fee23f9Smrg # define _INTL_STRINGIFY(prefix) #prefix
1114fee23f9Smrg #else
1124fee23f9Smrg # define _INTL_ASM(cname)
1134fee23f9Smrg #endif
1144fee23f9Smrg
1154fee23f9Smrg /* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
1164fee23f9Smrg its n-th argument literally. This enables GCC to warn for example about
1174fee23f9Smrg printf (gettext ("foo %y")). */
118*181254a7Smrg #if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1 && !(defined __clang__ && __clang__ && __clang_major__ >= 3) && defined __cplusplus)
1194fee23f9Smrg # define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
1204fee23f9Smrg #else
1214fee23f9Smrg # define _INTL_MAY_RETURN_STRING_ARG(n)
1224fee23f9Smrg #endif
1234fee23f9Smrg
1244fee23f9Smrg /* Look up MSGID in the current default message catalog for the current
1254fee23f9Smrg LC_MESSAGES locale. If not found, returns MSGID itself (the default
1264fee23f9Smrg text). */
1274fee23f9Smrg #ifdef _INTL_REDIRECT_INLINE
1284fee23f9Smrg extern char *libintl_gettext (const char *__msgid)
1294fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (1);
130*181254a7Smrg static inline
131*181254a7Smrg _INTL_MAY_RETURN_STRING_ARG (1)
gettext(const char * __msgid)132*181254a7Smrg char *gettext (const char *__msgid)
1334fee23f9Smrg {
1344fee23f9Smrg return libintl_gettext (__msgid);
1354fee23f9Smrg }
1364fee23f9Smrg #else
1374fee23f9Smrg #ifdef _INTL_REDIRECT_MACROS
1384fee23f9Smrg # define gettext libintl_gettext
1394fee23f9Smrg #endif
1404fee23f9Smrg extern char *gettext _INTL_PARAMS ((const char *__msgid))
1414fee23f9Smrg _INTL_ASM (libintl_gettext)
1424fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (1);
1434fee23f9Smrg #endif
1444fee23f9Smrg
1454fee23f9Smrg /* Look up MSGID in the DOMAINNAME message catalog for the current
1464fee23f9Smrg LC_MESSAGES locale. */
1474fee23f9Smrg #ifdef _INTL_REDIRECT_INLINE
1484fee23f9Smrg extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
1494fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (2);
150*181254a7Smrg static inline
151*181254a7Smrg _INTL_MAY_RETURN_STRING_ARG (2)
dgettext(const char * __domainname,const char * __msgid)152*181254a7Smrg char *dgettext (const char *__domainname, const char *__msgid)
1534fee23f9Smrg {
1544fee23f9Smrg return libintl_dgettext (__domainname, __msgid);
1554fee23f9Smrg }
1564fee23f9Smrg #else
1574fee23f9Smrg #ifdef _INTL_REDIRECT_MACROS
1584fee23f9Smrg # define dgettext libintl_dgettext
1594fee23f9Smrg #endif
1604fee23f9Smrg extern char *dgettext _INTL_PARAMS ((const char *__domainname,
1614fee23f9Smrg const char *__msgid))
1624fee23f9Smrg _INTL_ASM (libintl_dgettext)
1634fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (2);
1644fee23f9Smrg #endif
1654fee23f9Smrg
1664fee23f9Smrg /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
1674fee23f9Smrg locale. */
1684fee23f9Smrg #ifdef _INTL_REDIRECT_INLINE
1694fee23f9Smrg extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
1704fee23f9Smrg int __category)
1714fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (2);
172*181254a7Smrg static inline
173*181254a7Smrg _INTL_MAY_RETURN_STRING_ARG (2)
dcgettext(const char * __domainname,const char * __msgid,int __category)174*181254a7Smrg char *dcgettext (const char *__domainname, const char *__msgid, int __category)
1754fee23f9Smrg {
1764fee23f9Smrg return libintl_dcgettext (__domainname, __msgid, __category);
1774fee23f9Smrg }
1784fee23f9Smrg #else
1794fee23f9Smrg #ifdef _INTL_REDIRECT_MACROS
1804fee23f9Smrg # define dcgettext libintl_dcgettext
1814fee23f9Smrg #endif
1824fee23f9Smrg extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
1834fee23f9Smrg const char *__msgid,
1844fee23f9Smrg int __category))
1854fee23f9Smrg _INTL_ASM (libintl_dcgettext)
1864fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (2);
1874fee23f9Smrg #endif
1884fee23f9Smrg
1894fee23f9Smrg
1904fee23f9Smrg /* Similar to `gettext' but select the plural form corresponding to the
1914fee23f9Smrg number N. */
1924fee23f9Smrg #ifdef _INTL_REDIRECT_INLINE
1934fee23f9Smrg extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
1944fee23f9Smrg unsigned long int __n)
1954fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
196*181254a7Smrg static inline
197*181254a7Smrg _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2)
ngettext(const char * __msgid1,const char * __msgid2,unsigned long int __n)198*181254a7Smrg char *ngettext (const char *__msgid1, const char *__msgid2,
1994fee23f9Smrg unsigned long int __n)
2004fee23f9Smrg {
2014fee23f9Smrg return libintl_ngettext (__msgid1, __msgid2, __n);
2024fee23f9Smrg }
2034fee23f9Smrg #else
2044fee23f9Smrg #ifdef _INTL_REDIRECT_MACROS
2054fee23f9Smrg # define ngettext libintl_ngettext
2064fee23f9Smrg #endif
2074fee23f9Smrg extern char *ngettext _INTL_PARAMS ((const char *__msgid1,
2084fee23f9Smrg const char *__msgid2,
2094fee23f9Smrg unsigned long int __n))
2104fee23f9Smrg _INTL_ASM (libintl_ngettext)
2114fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
2124fee23f9Smrg #endif
2134fee23f9Smrg
2144fee23f9Smrg /* Similar to `dgettext' but select the plural form corresponding to the
2154fee23f9Smrg number N. */
2164fee23f9Smrg #ifdef _INTL_REDIRECT_INLINE
2174fee23f9Smrg extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
2184fee23f9Smrg const char *__msgid2, unsigned long int __n)
2194fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
220*181254a7Smrg static inline
221*181254a7Smrg _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3)
dngettext(const char * __domainname,const char * __msgid1,const char * __msgid2,unsigned long int __n)222*181254a7Smrg char *dngettext (const char *__domainname, const char *__msgid1,
2234fee23f9Smrg const char *__msgid2, unsigned long int __n)
2244fee23f9Smrg {
2254fee23f9Smrg return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
2264fee23f9Smrg }
2274fee23f9Smrg #else
2284fee23f9Smrg #ifdef _INTL_REDIRECT_MACROS
2294fee23f9Smrg # define dngettext libintl_dngettext
2304fee23f9Smrg #endif
2314fee23f9Smrg extern char *dngettext _INTL_PARAMS ((const char *__domainname,
2324fee23f9Smrg const char *__msgid1,
2334fee23f9Smrg const char *__msgid2,
2344fee23f9Smrg unsigned long int __n))
2354fee23f9Smrg _INTL_ASM (libintl_dngettext)
2364fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
2374fee23f9Smrg #endif
2384fee23f9Smrg
2394fee23f9Smrg /* Similar to `dcgettext' but select the plural form corresponding to the
2404fee23f9Smrg number N. */
2414fee23f9Smrg #ifdef _INTL_REDIRECT_INLINE
2424fee23f9Smrg extern char *libintl_dcngettext (const char *__domainname,
2434fee23f9Smrg const char *__msgid1, const char *__msgid2,
2444fee23f9Smrg unsigned long int __n, int __category)
2454fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
246*181254a7Smrg static inline
247*181254a7Smrg _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3)
dcngettext(const char * __domainname,const char * __msgid1,const char * __msgid2,unsigned long int __n,int __category)248*181254a7Smrg char *dcngettext (const char *__domainname,
2494fee23f9Smrg const char *__msgid1, const char *__msgid2,
2504fee23f9Smrg unsigned long int __n, int __category)
2514fee23f9Smrg {
2524fee23f9Smrg return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
2534fee23f9Smrg }
2544fee23f9Smrg #else
2554fee23f9Smrg #ifdef _INTL_REDIRECT_MACROS
2564fee23f9Smrg # define dcngettext libintl_dcngettext
2574fee23f9Smrg #endif
2584fee23f9Smrg extern char *dcngettext _INTL_PARAMS ((const char *__domainname,
2594fee23f9Smrg const char *__msgid1,
2604fee23f9Smrg const char *__msgid2,
2614fee23f9Smrg unsigned long int __n,
2624fee23f9Smrg int __category))
2634fee23f9Smrg _INTL_ASM (libintl_dcngettext)
2644fee23f9Smrg _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
2654fee23f9Smrg #endif
2664fee23f9Smrg
2674fee23f9Smrg
2684fee23f9Smrg /* Set the current default message catalog to DOMAINNAME.
2694fee23f9Smrg If DOMAINNAME is null, return the current default.
2704fee23f9Smrg If DOMAINNAME is "", reset to the default of "messages". */
2714fee23f9Smrg #ifdef _INTL_REDIRECT_INLINE
2724fee23f9Smrg extern char *libintl_textdomain (const char *__domainname);
textdomain(const char * __domainname)2734fee23f9Smrg static inline char *textdomain (const char *__domainname)
2744fee23f9Smrg {
2754fee23f9Smrg return libintl_textdomain (__domainname);
2764fee23f9Smrg }
2774fee23f9Smrg #else
2784fee23f9Smrg #ifdef _INTL_REDIRECT_MACROS
2794fee23f9Smrg # define textdomain libintl_textdomain
2804fee23f9Smrg #endif
2814fee23f9Smrg extern char *textdomain _INTL_PARAMS ((const char *__domainname))
2824fee23f9Smrg _INTL_ASM (libintl_textdomain);
2834fee23f9Smrg #endif
2844fee23f9Smrg
2854fee23f9Smrg /* Specify that the DOMAINNAME message catalog will be found
2864fee23f9Smrg in DIRNAME rather than in the system locale data base. */
2874fee23f9Smrg #ifdef _INTL_REDIRECT_INLINE
2884fee23f9Smrg extern char *libintl_bindtextdomain (const char *__domainname,
2894fee23f9Smrg const char *__dirname);
bindtextdomain(const char * __domainname,const char * __dirname)2904fee23f9Smrg static inline char *bindtextdomain (const char *__domainname,
2914fee23f9Smrg const char *__dirname)
2924fee23f9Smrg {
2934fee23f9Smrg return libintl_bindtextdomain (__domainname, __dirname);
2944fee23f9Smrg }
2954fee23f9Smrg #else
2964fee23f9Smrg #ifdef _INTL_REDIRECT_MACROS
2974fee23f9Smrg # define bindtextdomain libintl_bindtextdomain
2984fee23f9Smrg #endif
2994fee23f9Smrg extern char *bindtextdomain _INTL_PARAMS ((const char *__domainname,
3004fee23f9Smrg const char *__dirname))
3014fee23f9Smrg _INTL_ASM (libintl_bindtextdomain);
3024fee23f9Smrg #endif
3034fee23f9Smrg
3044fee23f9Smrg /* Specify the character encoding in which the messages from the
3054fee23f9Smrg DOMAINNAME message catalog will be returned. */
3064fee23f9Smrg #ifdef _INTL_REDIRECT_INLINE
3074fee23f9Smrg extern char *libintl_bind_textdomain_codeset (const char *__domainname,
3084fee23f9Smrg const char *__codeset);
bind_textdomain_codeset(const char * __domainname,const char * __codeset)3094fee23f9Smrg static inline char *bind_textdomain_codeset (const char *__domainname,
3104fee23f9Smrg const char *__codeset)
3114fee23f9Smrg {
3124fee23f9Smrg return libintl_bind_textdomain_codeset (__domainname, __codeset);
3134fee23f9Smrg }
3144fee23f9Smrg #else
3154fee23f9Smrg #ifdef _INTL_REDIRECT_MACROS
3164fee23f9Smrg # define bind_textdomain_codeset libintl_bind_textdomain_codeset
3174fee23f9Smrg #endif
3184fee23f9Smrg extern char *bind_textdomain_codeset _INTL_PARAMS ((const char *__domainname,
3194fee23f9Smrg const char *__codeset))
3204fee23f9Smrg _INTL_ASM (libintl_bind_textdomain_codeset);
3214fee23f9Smrg #endif
3224fee23f9Smrg
3234fee23f9Smrg
3244fee23f9Smrg /* Support for relocatable packages. */
3254fee23f9Smrg
3264fee23f9Smrg /* Sets the original and the current installation prefix of the package.
3274fee23f9Smrg Relocation simply replaces a pathname starting with the original prefix
3284fee23f9Smrg by the corresponding pathname with the current prefix instead. Both
3294fee23f9Smrg prefixes should be directory names without trailing slash (i.e. use ""
3304fee23f9Smrg instead of "/"). */
3314fee23f9Smrg #define libintl_set_relocation_prefix libintl_set_relocation_prefix
3324fee23f9Smrg extern void
3334fee23f9Smrg libintl_set_relocation_prefix _INTL_PARAMS ((const char *orig_prefix,
3344fee23f9Smrg const char *curr_prefix));
3354fee23f9Smrg
3364fee23f9Smrg
3374fee23f9Smrg #ifdef __cplusplus
3384fee23f9Smrg }
3394fee23f9Smrg #endif
3404fee23f9Smrg
3414fee23f9Smrg #endif /* libintl.h */
342