您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

libgnuintl.h.in 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /* Message catalogs for internationalization.
  2. Copyright (C) 1995-1997, 2000-2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  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 ? 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. /* We redirect the functions to those prefixed with "libintl_". This is
  44. necessary, because some systems define gettext/textdomain/... in the C
  45. library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
  46. If we used the unprefixed names, there would be cases where the
  47. definition in the C library would override the one in the libintl.so
  48. shared library. Recall that on ELF systems, the symbols are looked
  49. up in the following order:
  50. 1. in the executable,
  51. 2. in the shared libraries specified on the link command line, in order,
  52. 3. in the dependencies of the shared libraries specified on the link
  53. command line,
  54. 4. in the dlopen()ed shared libraries, in the order in which they were
  55. dlopen()ed.
  56. The definition in the C library would override the one in libintl.so if
  57. either
  58. * -lc is given on the link command line and -lintl isn't, or
  59. * -lc is given on the link command line before -lintl, or
  60. * libintl.so is a dependency of a dlopen()ed shared library but not
  61. linked to the executable at link time.
  62. Since Solaris gettext() behaves differently than GNU gettext(), this
  63. would be unacceptable.
  64. The redirection happens by default through macros in C, so that &gettext
  65. is independent of the compilation unit, but through inline functions in
  66. C++, in order not to interfere with the name mangling of class fields or
  67. class methods called 'gettext'. */
  68. /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
  69. If he doesn't, we choose the method. A third possible method is
  70. _INTL_REDIRECT_ASM, supported only by GCC. */
  71. #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
  72. # if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
  73. # define _INTL_REDIRECT_ASM
  74. # else
  75. # ifdef __cplusplus
  76. # define _INTL_REDIRECT_INLINE
  77. # else
  78. # define _INTL_REDIRECT_MACROS
  79. # endif
  80. # endif
  81. #endif
  82. /* Auxiliary macros. */
  83. #ifdef _INTL_REDIRECT_ASM
  84. # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
  85. # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
  86. # define _INTL_STRINGIFY(prefix) #prefix
  87. #else
  88. # define _INTL_ASM(cname)
  89. #endif
  90. /* Look up MSGID in the current default message catalog for the current
  91. LC_MESSAGES locale. If not found, returns MSGID itself (the default
  92. text). */
  93. #ifdef _INTL_REDIRECT_INLINE
  94. extern char *libintl_gettext (const char *__msgid);
  95. static inline char *gettext (const char *__msgid)
  96. {
  97. return libintl_gettext (__msgid);
  98. }
  99. #else
  100. #ifdef _INTL_REDIRECT_MACROS
  101. # define gettext libintl_gettext
  102. #endif
  103. extern char *gettext (const char *__msgid)
  104. _INTL_ASM (libintl_gettext);
  105. #endif
  106. /* Look up MSGID in the DOMAINNAME message catalog for the current
  107. LC_MESSAGES locale. */
  108. #ifdef _INTL_REDIRECT_INLINE
  109. extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
  110. static inline char *dgettext (const char *__domainname, const char *__msgid)
  111. {
  112. return libintl_dgettext (__domainname, __msgid);
  113. }
  114. #else
  115. #ifdef _INTL_REDIRECT_MACROS
  116. # define dgettext libintl_dgettext
  117. #endif
  118. extern char *dgettext (const char *__domainname, const char *__msgid)
  119. _INTL_ASM (libintl_dgettext);
  120. #endif
  121. /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
  122. locale. */
  123. #ifdef _INTL_REDIRECT_INLINE
  124. extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
  125. int __category);
  126. static inline char *dcgettext (const char *__domainname, const char *__msgid,
  127. int __category)
  128. {
  129. return libintl_dcgettext (__domainname, __msgid, __category);
  130. }
  131. #else
  132. #ifdef _INTL_REDIRECT_MACROS
  133. # define dcgettext libintl_dcgettext
  134. #endif
  135. extern char *dcgettext (const char *__domainname, const char *__msgid,
  136. int __category)
  137. _INTL_ASM (libintl_dcgettext);
  138. #endif
  139. /* Similar to `gettext' but select the plural form corresponding to the
  140. number N. */
  141. #ifdef _INTL_REDIRECT_INLINE
  142. extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
  143. unsigned long int __n);
  144. static inline char *ngettext (const char *__msgid1, const char *__msgid2,
  145. unsigned long int __n)
  146. {
  147. return libintl_ngettext (__msgid1, __msgid2, __n);
  148. }
  149. #else
  150. #ifdef _INTL_REDIRECT_MACROS
  151. # define ngettext libintl_ngettext
  152. #endif
  153. extern char *ngettext (const char *__msgid1, const char *__msgid2,
  154. unsigned long int __n)
  155. _INTL_ASM (libintl_ngettext);
  156. #endif
  157. /* Similar to `dgettext' but select the plural form corresponding to the
  158. number N. */
  159. #ifdef _INTL_REDIRECT_INLINE
  160. extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
  161. const char *__msgid2, unsigned long int __n);
  162. static inline char *dngettext (const char *__domainname, const char *__msgid1,
  163. const char *__msgid2, unsigned long int __n)
  164. {
  165. return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
  166. }
  167. #else
  168. #ifdef _INTL_REDIRECT_MACROS
  169. # define dngettext libintl_dngettext
  170. #endif
  171. extern char *dngettext (const char *__domainname,
  172. const char *__msgid1, const char *__msgid2,
  173. unsigned long int __n)
  174. _INTL_ASM (libintl_dngettext);
  175. #endif
  176. /* Similar to `dcgettext' but select the plural form corresponding to the
  177. number N. */
  178. #ifdef _INTL_REDIRECT_INLINE
  179. extern char *libintl_dcngettext (const char *__domainname,
  180. const char *__msgid1, const char *__msgid2,
  181. unsigned long int __n, int __category);
  182. static inline char *dcngettext (const char *__domainname,
  183. const char *__msgid1, const char *__msgid2,
  184. unsigned long int __n, int __category)
  185. {
  186. return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
  187. }
  188. #else
  189. #ifdef _INTL_REDIRECT_MACROS
  190. # define dcngettext libintl_dcngettext
  191. #endif
  192. extern char *dcngettext (const char *__domainname,
  193. const char *__msgid1, const char *__msgid2,
  194. unsigned long int __n, int __category)
  195. _INTL_ASM (libintl_dcngettext);
  196. #endif
  197. /* Set the current default message catalog to DOMAINNAME.
  198. If DOMAINNAME is null, return the current default.
  199. If DOMAINNAME is "", reset to the default of "messages". */
  200. #ifdef _INTL_REDIRECT_INLINE
  201. extern char *libintl_textdomain (const char *__domainname);
  202. static inline char *textdomain (const char *__domainname)
  203. {
  204. return libintl_textdomain (__domainname);
  205. }
  206. #else
  207. #ifdef _INTL_REDIRECT_MACROS
  208. # define textdomain libintl_textdomain
  209. #endif
  210. extern char *textdomain (const char *__domainname)
  211. _INTL_ASM (libintl_textdomain);
  212. #endif
  213. /* Specify that the DOMAINNAME message catalog will be found
  214. in DIRNAME rather than in the system locale data base. */
  215. #ifdef _INTL_REDIRECT_INLINE
  216. extern char *libintl_bindtextdomain (const char *__domainname,
  217. const char *__dirname);
  218. static inline char *bindtextdomain (const char *__domainname,
  219. const char *__dirname)
  220. {
  221. return libintl_bindtextdomain (__domainname, __dirname);
  222. }
  223. #else
  224. #ifdef _INTL_REDIRECT_MACROS
  225. # define bindtextdomain libintl_bindtextdomain
  226. #endif
  227. extern char *bindtextdomain (const char *__domainname, const char *__dirname)
  228. _INTL_ASM (libintl_bindtextdomain);
  229. #endif
  230. /* Specify the character encoding in which the messages from the
  231. DOMAINNAME message catalog will be returned. */
  232. #ifdef _INTL_REDIRECT_INLINE
  233. extern char *libintl_bind_textdomain_codeset (const char *__domainname,
  234. const char *__codeset);
  235. static inline char *bind_textdomain_codeset (const char *__domainname,
  236. const char *__codeset)
  237. {
  238. return libintl_bind_textdomain_codeset (__domainname, __codeset);
  239. }
  240. #else
  241. #ifdef _INTL_REDIRECT_MACROS
  242. # define bind_textdomain_codeset libintl_bind_textdomain_codeset
  243. #endif
  244. extern char *bind_textdomain_codeset (const char *__domainname,
  245. const char *__codeset)
  246. _INTL_ASM (libintl_bind_textdomain_codeset);
  247. #endif
  248. /* Support for format strings with positions in *printf(), following the
  249. POSIX/XSI specification.
  250. Note: These replacements for the *printf() functions are visible only
  251. in source files that #include <libintl.h> or #include "gettext.h".
  252. Packages that use *printf() in source files that don't refer to _()
  253. or gettext() but for which the format string could be the return value
  254. of _() or gettext() need to add this #include. Oh well. */
  255. #if !@HAVE_POSIX_PRINTF@
  256. #include <stdio.h>
  257. #include <stddef.h>
  258. /* Get va_list. */
  259. #if __STDC__ || defined __cplusplus || defined _MSC_VER
  260. # include <stdarg.h>
  261. #else
  262. # include <varargs.h>
  263. #endif
  264. #undef fprintf
  265. #define fprintf libintl_fprintf
  266. extern int fprintf (FILE *, const char *, ...);
  267. #undef vfprintf
  268. #define vfprintf libintl_vfprintf
  269. extern int vfprintf (FILE *, const char *, va_list);
  270. #undef printf
  271. #define printf libintl_printf
  272. extern int printf (const char *, ...);
  273. #undef vprintf
  274. #define vprintf libintl_vprintf
  275. extern int vprintf (const char *, va_list);
  276. #undef sprintf
  277. #define sprintf libintl_sprintf
  278. extern int sprintf (char *, const char *, ...);
  279. #undef vsprintf
  280. #define vsprintf libintl_vsprintf
  281. extern int vsprintf (char *, const char *, va_list);
  282. #if @HAVE_SNPRINTF@
  283. #undef snprintf
  284. #define snprintf libintl_snprintf
  285. extern int snprintf (char *, size_t, const char *, ...);
  286. #undef vsnprintf
  287. #define vsnprintf libintl_vsnprintf
  288. extern int vsnprintf (char *, size_t, const char *, va_list);
  289. #endif
  290. #if @HAVE_ASPRINTF@
  291. #undef asprintf
  292. #define asprintf libintl_asprintf
  293. extern int asprintf (char **, const char *, ...);
  294. #undef vasprintf
  295. #define vasprintf libintl_vasprintf
  296. extern int vasprintf (char **, const char *, va_list);
  297. #endif
  298. #if @HAVE_WPRINTF@
  299. #undef fwprintf
  300. #define fwprintf libintl_fwprintf
  301. extern int fwprintf (FILE *, const wchar_t *, ...);
  302. #undef vfwprintf
  303. #define vfwprintf libintl_vfwprintf
  304. extern int vfwprintf (FILE *, const wchar_t *, va_list);
  305. #undef wprintf
  306. #define wprintf libintl_wprintf
  307. extern int wprintf (const wchar_t *, ...);
  308. #undef vwprintf
  309. #define vwprintf libintl_vwprintf
  310. extern int vwprintf (const wchar_t *, va_list);
  311. #undef swprintf
  312. #define swprintf libintl_swprintf
  313. extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
  314. #undef vswprintf
  315. #define vswprintf libintl_vswprintf
  316. extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
  317. #endif
  318. #endif
  319. /* Support for relocatable packages. */
  320. /* Sets the original and the current installation prefix of the package.
  321. Relocation simply replaces a pathname starting with the original prefix
  322. by the corresponding pathname with the current prefix instead. Both
  323. prefixes should be directory names without trailing slash (i.e. use ""
  324. instead of "/"). */
  325. #define libintl_set_relocation_prefix libintl_set_relocation_prefix
  326. extern void
  327. libintl_set_relocation_prefix (const char *orig_prefix,
  328. const char *curr_prefix);
  329. #ifdef __cplusplus
  330. }
  331. #endif
  332. #endif /* libintl.h */