You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

465 regels
16 KiB

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