libgnuintl.h.in 14 KB

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