116dce513Schristos /* Message catalogs for internationalization.
216dce513Schristos Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
316dce513Schristos
416dce513Schristos This program is free software; you can redistribute it and/or modify it
516dce513Schristos under the terms of the GNU Library General Public License as published
616dce513Schristos by the Free Software Foundation; either version 2, or (at your option)
716dce513Schristos any later version.
816dce513Schristos
916dce513Schristos This program is distributed in the hope that it will be useful,
1016dce513Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
1116dce513Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1216dce513Schristos Library General Public License for more details.
1316dce513Schristos
1416dce513Schristos You should have received a copy of the GNU Library General Public
1516dce513Schristos License along with this program; if not, write to the Free Software
1616dce513Schristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
1716dce513Schristos USA. */
1816dce513Schristos
1916dce513Schristos #ifndef _LIBINTL_H
2016dce513Schristos #define _LIBINTL_H 1
2116dce513Schristos
2216dce513Schristos #include <locale.h>
2316dce513Schristos
2416dce513Schristos /* The LC_MESSAGES locale category is the category used by the functions
2516dce513Schristos gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
2616dce513Schristos On systems that don't define it, use an arbitrary value instead.
2716dce513Schristos On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
2816dce513Schristos then includes <libintl.h> (i.e. this file!) and then only defines
2916dce513Schristos LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
3016dce513Schristos in this case. */
3116dce513Schristos #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
3216dce513Schristos # define LC_MESSAGES 1729
3316dce513Schristos #endif
3416dce513Schristos
3516dce513Schristos /* We define an additional symbol to signal that we use the GNU
3616dce513Schristos implementation of gettext. */
3716dce513Schristos #define __USE_GNU_GETTEXT 1
3816dce513Schristos
3916dce513Schristos /* Provide information about the supported file formats. Returns the
4016dce513Schristos maximum minor revision number supported for a given major revision. */
4116dce513Schristos #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
4216dce513Schristos ((major) == 0 ? 1 : -1)
4316dce513Schristos
4416dce513Schristos /* Resolve a platform specific conflict on DJGPP. GNU gettext takes
4516dce513Schristos precedence over _conio_gettext. */
4616dce513Schristos #ifdef __DJGPP__
4716dce513Schristos # undef gettext
4816dce513Schristos #endif
4916dce513Schristos
5016dce513Schristos /* Use _INTL_PARAMS, not PARAMS, in order to avoid clashes with identifiers
5116dce513Schristos used by programs. Similarly, test __PROTOTYPES, not PROTOTYPES. */
5216dce513Schristos #ifndef _INTL_PARAMS
5316dce513Schristos # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
5416dce513Schristos # define _INTL_PARAMS(args) args
5516dce513Schristos # else
5616dce513Schristos # define _INTL_PARAMS(args) ()
5716dce513Schristos # endif
5816dce513Schristos #endif
5916dce513Schristos
6016dce513Schristos #ifdef __cplusplus
6116dce513Schristos extern "C" {
6216dce513Schristos #endif
6316dce513Schristos
6416dce513Schristos
6516dce513Schristos /* We redirect the functions to those prefixed with "libintl_". This is
6616dce513Schristos necessary, because some systems define gettext/textdomain/... in the C
6716dce513Schristos library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
6816dce513Schristos If we used the unprefixed names, there would be cases where the
6916dce513Schristos definition in the C library would override the one in the libintl.so
7016dce513Schristos shared library. Recall that on ELF systems, the symbols are looked
7116dce513Schristos up in the following order:
7216dce513Schristos 1. in the executable,
7316dce513Schristos 2. in the shared libraries specified on the link command line, in order,
7416dce513Schristos 3. in the dependencies of the shared libraries specified on the link
7516dce513Schristos command line,
7616dce513Schristos 4. in the dlopen()ed shared libraries, in the order in which they were
7716dce513Schristos dlopen()ed.
7816dce513Schristos The definition in the C library would override the one in libintl.so if
7916dce513Schristos either
8016dce513Schristos * -lc is given on the link command line and -lintl isn't, or
8116dce513Schristos * -lc is given on the link command line before -lintl, or
8216dce513Schristos * libintl.so is a dependency of a dlopen()ed shared library but not
8316dce513Schristos linked to the executable at link time.
8416dce513Schristos Since Solaris gettext() behaves differently than GNU gettext(), this
8516dce513Schristos would be unacceptable.
8616dce513Schristos
8716dce513Schristos The redirection happens by default through macros in C, so that &gettext
8816dce513Schristos is independent of the compilation unit, but through inline functions in
8916dce513Schristos C++, in order not to interfere with the name mangling of class fields or
9016dce513Schristos class methods called 'gettext'. */
9116dce513Schristos
9216dce513Schristos /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
9316dce513Schristos If he doesn't, we choose the method. A third possible method is
9416dce513Schristos _INTL_REDIRECT_ASM, supported only by GCC. */
9516dce513Schristos #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
9616dce513Schristos # if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
9716dce513Schristos # define _INTL_REDIRECT_ASM
9816dce513Schristos # else
9916dce513Schristos # ifdef __cplusplus
10016dce513Schristos # define _INTL_REDIRECT_INLINE
10116dce513Schristos # else
10216dce513Schristos # define _INTL_REDIRECT_MACROS
10316dce513Schristos # endif
10416dce513Schristos # endif
10516dce513Schristos #endif
10616dce513Schristos /* Auxiliary macros. */
10716dce513Schristos #ifdef _INTL_REDIRECT_ASM
10816dce513Schristos # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
10916dce513Schristos # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
11016dce513Schristos # define _INTL_STRINGIFY(prefix) #prefix
11116dce513Schristos #else
11216dce513Schristos # define _INTL_ASM(cname)
11316dce513Schristos #endif
11416dce513Schristos
11516dce513Schristos /* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
11616dce513Schristos its n-th argument literally. This enables GCC to warn for example about
11716dce513Schristos printf (gettext ("foo %y")). */
118*012573ebSchristos #if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1 && !(defined __clang__ && __clang__ && __clang_major__ >= 3) && defined __cplusplus)
11916dce513Schristos # define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
12016dce513Schristos #else
12116dce513Schristos # define _INTL_MAY_RETURN_STRING_ARG(n)
12216dce513Schristos #endif
12316dce513Schristos
12416dce513Schristos /* Look up MSGID in the current default message catalog for the current
12516dce513Schristos LC_MESSAGES locale. If not found, returns MSGID itself (the default
12616dce513Schristos text). */
12716dce513Schristos #ifdef _INTL_REDIRECT_INLINE
12816dce513Schristos extern char *libintl_gettext (const char *__msgid)
12916dce513Schristos _INTL_MAY_RETURN_STRING_ARG (1);
130*012573ebSchristos static inline
131*012573ebSchristos _INTL_MAY_RETURN_STRING_ARG (1)
gettext(const char * __msgid)132*012573ebSchristos char *gettext (const char *__msgid)
13316dce513Schristos {
13416dce513Schristos return libintl_gettext (__msgid);
13516dce513Schristos }
13616dce513Schristos #else
13716dce513Schristos #ifdef _INTL_REDIRECT_MACROS
13816dce513Schristos # define gettext libintl_gettext
13916dce513Schristos #endif
14016dce513Schristos extern char *gettext _INTL_PARAMS ((const char *__msgid))
14116dce513Schristos _INTL_ASM (libintl_gettext)
14216dce513Schristos _INTL_MAY_RETURN_STRING_ARG (1);
14316dce513Schristos #endif
14416dce513Schristos
14516dce513Schristos /* Look up MSGID in the DOMAINNAME message catalog for the current
14616dce513Schristos LC_MESSAGES locale. */
14716dce513Schristos #ifdef _INTL_REDIRECT_INLINE
14816dce513Schristos extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
14916dce513Schristos _INTL_MAY_RETURN_STRING_ARG (2);
150*012573ebSchristos static inline
151*012573ebSchristos _INTL_MAY_RETURN_STRING_ARG (2)
dgettext(const char * __domainname,const char * __msgid)152*012573ebSchristos char *dgettext (const char *__domainname, const char *__msgid)
15316dce513Schristos {
15416dce513Schristos return libintl_dgettext (__domainname, __msgid);
15516dce513Schristos }
15616dce513Schristos #else
15716dce513Schristos #ifdef _INTL_REDIRECT_MACROS
15816dce513Schristos # define dgettext libintl_dgettext
15916dce513Schristos #endif
16016dce513Schristos extern char *dgettext _INTL_PARAMS ((const char *__domainname,
16116dce513Schristos const char *__msgid))
16216dce513Schristos _INTL_ASM (libintl_dgettext)
16316dce513Schristos _INTL_MAY_RETURN_STRING_ARG (2);
16416dce513Schristos #endif
16516dce513Schristos
16616dce513Schristos /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
16716dce513Schristos locale. */
16816dce513Schristos #ifdef _INTL_REDIRECT_INLINE
16916dce513Schristos extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
17016dce513Schristos int __category)
17116dce513Schristos _INTL_MAY_RETURN_STRING_ARG (2);
172*012573ebSchristos static inline
173*012573ebSchristos _INTL_MAY_RETURN_STRING_ARG (2)
dcgettext(const char * __domainname,const char * __msgid,int __category)174*012573ebSchristos char *dcgettext (const char *__domainname, const char *__msgid, int __category)
17516dce513Schristos {
17616dce513Schristos return libintl_dcgettext (__domainname, __msgid, __category);
17716dce513Schristos }
17816dce513Schristos #else
17916dce513Schristos #ifdef _INTL_REDIRECT_MACROS
18016dce513Schristos # define dcgettext libintl_dcgettext
18116dce513Schristos #endif
18216dce513Schristos extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
18316dce513Schristos const char *__msgid,
18416dce513Schristos int __category))
18516dce513Schristos _INTL_ASM (libintl_dcgettext)
18616dce513Schristos _INTL_MAY_RETURN_STRING_ARG (2);
18716dce513Schristos #endif
18816dce513Schristos
18916dce513Schristos
19016dce513Schristos /* Similar to `gettext' but select the plural form corresponding to the
19116dce513Schristos number N. */
19216dce513Schristos #ifdef _INTL_REDIRECT_INLINE
19316dce513Schristos extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
19416dce513Schristos unsigned long int __n)
19516dce513Schristos _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
196*012573ebSchristos static inline
197*012573ebSchristos _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2)
ngettext(const char * __msgid1,const char * __msgid2,unsigned long int __n)198*012573ebSchristos char *ngettext (const char *__msgid1, const char *__msgid2,
19916dce513Schristos unsigned long int __n)
20016dce513Schristos {
20116dce513Schristos return libintl_ngettext (__msgid1, __msgid2, __n);
20216dce513Schristos }
20316dce513Schristos #else
20416dce513Schristos #ifdef _INTL_REDIRECT_MACROS
20516dce513Schristos # define ngettext libintl_ngettext
20616dce513Schristos #endif
20716dce513Schristos extern char *ngettext _INTL_PARAMS ((const char *__msgid1,
20816dce513Schristos const char *__msgid2,
20916dce513Schristos unsigned long int __n))
21016dce513Schristos _INTL_ASM (libintl_ngettext)
21116dce513Schristos _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
21216dce513Schristos #endif
21316dce513Schristos
21416dce513Schristos /* Similar to `dgettext' but select the plural form corresponding to the
21516dce513Schristos number N. */
21616dce513Schristos #ifdef _INTL_REDIRECT_INLINE
21716dce513Schristos extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
21816dce513Schristos const char *__msgid2, unsigned long int __n)
21916dce513Schristos _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
220*012573ebSchristos static inline
221*012573ebSchristos _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*012573ebSchristos char *dngettext (const char *__domainname, const char *__msgid1,
22316dce513Schristos const char *__msgid2, unsigned long int __n)
22416dce513Schristos {
22516dce513Schristos return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
22616dce513Schristos }
22716dce513Schristos #else
22816dce513Schristos #ifdef _INTL_REDIRECT_MACROS
22916dce513Schristos # define dngettext libintl_dngettext
23016dce513Schristos #endif
23116dce513Schristos extern char *dngettext _INTL_PARAMS ((const char *__domainname,
23216dce513Schristos const char *__msgid1,
23316dce513Schristos const char *__msgid2,
23416dce513Schristos unsigned long int __n))
23516dce513Schristos _INTL_ASM (libintl_dngettext)
23616dce513Schristos _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
23716dce513Schristos #endif
23816dce513Schristos
23916dce513Schristos /* Similar to `dcgettext' but select the plural form corresponding to the
24016dce513Schristos number N. */
24116dce513Schristos #ifdef _INTL_REDIRECT_INLINE
24216dce513Schristos extern char *libintl_dcngettext (const char *__domainname,
24316dce513Schristos const char *__msgid1, const char *__msgid2,
24416dce513Schristos unsigned long int __n, int __category)
24516dce513Schristos _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
246*012573ebSchristos static inline
247*012573ebSchristos _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*012573ebSchristos char *dcngettext (const char *__domainname,
24916dce513Schristos const char *__msgid1, const char *__msgid2,
25016dce513Schristos unsigned long int __n, int __category)
25116dce513Schristos {
25216dce513Schristos return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
25316dce513Schristos }
25416dce513Schristos #else
25516dce513Schristos #ifdef _INTL_REDIRECT_MACROS
25616dce513Schristos # define dcngettext libintl_dcngettext
25716dce513Schristos #endif
25816dce513Schristos extern char *dcngettext _INTL_PARAMS ((const char *__domainname,
25916dce513Schristos const char *__msgid1,
26016dce513Schristos const char *__msgid2,
26116dce513Schristos unsigned long int __n,
26216dce513Schristos int __category))
26316dce513Schristos _INTL_ASM (libintl_dcngettext)
26416dce513Schristos _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
26516dce513Schristos #endif
26616dce513Schristos
26716dce513Schristos
26816dce513Schristos /* Set the current default message catalog to DOMAINNAME.
26916dce513Schristos If DOMAINNAME is null, return the current default.
27016dce513Schristos If DOMAINNAME is "", reset to the default of "messages". */
27116dce513Schristos #ifdef _INTL_REDIRECT_INLINE
27216dce513Schristos extern char *libintl_textdomain (const char *__domainname);
textdomain(const char * __domainname)27316dce513Schristos static inline char *textdomain (const char *__domainname)
27416dce513Schristos {
27516dce513Schristos return libintl_textdomain (__domainname);
27616dce513Schristos }
27716dce513Schristos #else
27816dce513Schristos #ifdef _INTL_REDIRECT_MACROS
27916dce513Schristos # define textdomain libintl_textdomain
28016dce513Schristos #endif
28116dce513Schristos extern char *textdomain _INTL_PARAMS ((const char *__domainname))
28216dce513Schristos _INTL_ASM (libintl_textdomain);
28316dce513Schristos #endif
28416dce513Schristos
28516dce513Schristos /* Specify that the DOMAINNAME message catalog will be found
28616dce513Schristos in DIRNAME rather than in the system locale data base. */
28716dce513Schristos #ifdef _INTL_REDIRECT_INLINE
28816dce513Schristos extern char *libintl_bindtextdomain (const char *__domainname,
28916dce513Schristos const char *__dirname);
bindtextdomain(const char * __domainname,const char * __dirname)29016dce513Schristos static inline char *bindtextdomain (const char *__domainname,
29116dce513Schristos const char *__dirname)
29216dce513Schristos {
29316dce513Schristos return libintl_bindtextdomain (__domainname, __dirname);
29416dce513Schristos }
29516dce513Schristos #else
29616dce513Schristos #ifdef _INTL_REDIRECT_MACROS
29716dce513Schristos # define bindtextdomain libintl_bindtextdomain
29816dce513Schristos #endif
29916dce513Schristos extern char *bindtextdomain _INTL_PARAMS ((const char *__domainname,
30016dce513Schristos const char *__dirname))
30116dce513Schristos _INTL_ASM (libintl_bindtextdomain);
30216dce513Schristos #endif
30316dce513Schristos
30416dce513Schristos /* Specify the character encoding in which the messages from the
30516dce513Schristos DOMAINNAME message catalog will be returned. */
30616dce513Schristos #ifdef _INTL_REDIRECT_INLINE
30716dce513Schristos extern char *libintl_bind_textdomain_codeset (const char *__domainname,
30816dce513Schristos const char *__codeset);
bind_textdomain_codeset(const char * __domainname,const char * __codeset)30916dce513Schristos static inline char *bind_textdomain_codeset (const char *__domainname,
31016dce513Schristos const char *__codeset)
31116dce513Schristos {
31216dce513Schristos return libintl_bind_textdomain_codeset (__domainname, __codeset);
31316dce513Schristos }
31416dce513Schristos #else
31516dce513Schristos #ifdef _INTL_REDIRECT_MACROS
31616dce513Schristos # define bind_textdomain_codeset libintl_bind_textdomain_codeset
31716dce513Schristos #endif
31816dce513Schristos extern char *bind_textdomain_codeset _INTL_PARAMS ((const char *__domainname,
31916dce513Schristos const char *__codeset))
32016dce513Schristos _INTL_ASM (libintl_bind_textdomain_codeset);
32116dce513Schristos #endif
32216dce513Schristos
32316dce513Schristos
32416dce513Schristos /* Support for relocatable packages. */
32516dce513Schristos
32616dce513Schristos /* Sets the original and the current installation prefix of the package.
32716dce513Schristos Relocation simply replaces a pathname starting with the original prefix
32816dce513Schristos by the corresponding pathname with the current prefix instead. Both
32916dce513Schristos prefixes should be directory names without trailing slash (i.e. use ""
33016dce513Schristos instead of "/"). */
33116dce513Schristos #define libintl_set_relocation_prefix libintl_set_relocation_prefix
33216dce513Schristos extern void
33316dce513Schristos libintl_set_relocation_prefix _INTL_PARAMS ((const char *orig_prefix,
33416dce513Schristos const char *curr_prefix));
33516dce513Schristos
33616dce513Schristos
33716dce513Schristos #ifdef __cplusplus
33816dce513Schristos }
33916dce513Schristos #endif
34016dce513Schristos
34116dce513Schristos #endif /* libintl.h */
342