gettextP.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* Header describing internals of libintl library.
  2. Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
  3. Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU Library General Public License as published
  6. by the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
  15. USA. */
  16. #ifndef _GETTEXTP_H
  17. #define _GETTEXTP_H
  18. #include <stddef.h> /* Get size_t. */
  19. #ifdef _LIBC
  20. # include "../iconv/gconv_int.h"
  21. #else
  22. # if HAVE_ICONV
  23. # include <iconv.h>
  24. # endif
  25. #endif
  26. #include "loadinfo.h"
  27. #include "gmo.h" /* Get nls_uint32. */
  28. /* @@ end of prolog @@ */
  29. #ifndef PARAMS
  30. # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
  31. # define PARAMS(args) args
  32. # else
  33. # define PARAMS(args) ()
  34. # endif
  35. #endif
  36. #ifndef internal_function
  37. # define internal_function
  38. #endif
  39. #ifndef attribute_hidden
  40. # define attribute_hidden
  41. #endif
  42. /* Tell the compiler when a conditional or integer expression is
  43. almost always true or almost always false. */
  44. #ifndef HAVE_BUILTIN_EXPECT
  45. # define __builtin_expect(expr, val) (expr)
  46. #endif
  47. #ifndef W
  48. # define W(flag, data) ((flag) ? SWAP (data) : (data))
  49. #endif
  50. #ifdef _LIBC
  51. # include <byteswap.h>
  52. # define SWAP(i) bswap_32 (i)
  53. #else
  54. static inline nls_uint32
  55. SWAP (i)
  56. nls_uint32 i;
  57. {
  58. return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
  59. }
  60. #endif
  61. /* In-memory representation of system dependent string. */
  62. struct sysdep_string_desc
  63. {
  64. /* Length of addressed string, including the trailing NUL. */
  65. size_t length;
  66. /* Pointer to addressed string. */
  67. const char *pointer;
  68. };
  69. /* The representation of an opened message catalog. */
  70. struct loaded_domain
  71. {
  72. /* Pointer to memory containing the .mo file. */
  73. const char *data;
  74. /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
  75. int use_mmap;
  76. /* Size of mmap()ed memory. */
  77. size_t mmap_size;
  78. /* 1 if the .mo file uses a different endianness than this machine. */
  79. int must_swap;
  80. /* Pointer to additional malloc()ed memory. */
  81. void *malloced;
  82. /* Number of static strings pairs. */
  83. nls_uint32 nstrings;
  84. /* Pointer to descriptors of original strings in the file. */
  85. const struct string_desc *orig_tab;
  86. /* Pointer to descriptors of translated strings in the file. */
  87. const struct string_desc *trans_tab;
  88. /* Number of system dependent strings pairs. */
  89. nls_uint32 n_sysdep_strings;
  90. /* Pointer to descriptors of original sysdep strings. */
  91. const struct sysdep_string_desc *orig_sysdep_tab;
  92. /* Pointer to descriptors of translated sysdep strings. */
  93. const struct sysdep_string_desc *trans_sysdep_tab;
  94. /* Size of hash table. */
  95. nls_uint32 hash_size;
  96. /* Pointer to hash table. */
  97. const nls_uint32 *hash_tab;
  98. /* 1 if the hash table uses a different endianness than this machine. */
  99. int must_swap_hash_tab;
  100. int codeset_cntr;
  101. #ifdef _LIBC
  102. __gconv_t conv;
  103. #else
  104. # if HAVE_ICONV
  105. iconv_t conv;
  106. # endif
  107. #endif
  108. char **conv_tab;
  109. struct expression *plural;
  110. unsigned long int nplurals;
  111. };
  112. /* We want to allocate a string at the end of the struct. But ISO C
  113. doesn't allow zero sized arrays. */
  114. #ifdef __GNUC__
  115. # define ZERO 0
  116. #else
  117. # define ZERO 1
  118. #endif
  119. /* A set of settings bound to a message domain. Used to store settings
  120. from bindtextdomain() and bind_textdomain_codeset(). */
  121. struct binding
  122. {
  123. struct binding *next;
  124. char *dirname;
  125. int codeset_cntr; /* Incremented each time codeset changes. */
  126. char *codeset;
  127. char domainname[ZERO];
  128. };
  129. /* A counter which is incremented each time some previous translations
  130. become invalid.
  131. This variable is part of the external ABI of the GNU libintl. */
  132. extern int _nl_msg_cat_cntr;
  133. #ifndef _LIBC
  134. const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
  135. #endif
  136. struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
  137. char *__locale,
  138. const char *__domainname,
  139. struct binding *__domainbinding))
  140. internal_function;
  141. void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
  142. struct binding *__domainbinding))
  143. internal_function;
  144. void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
  145. internal_function;
  146. const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
  147. struct loaded_domain *__domain,
  148. struct binding *__domainbinding))
  149. internal_function;
  150. void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
  151. internal_function;
  152. char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
  153. struct binding *domainbinding,
  154. const char *msgid, size_t *lengthp))
  155. internal_function;
  156. #ifdef _LIBC
  157. extern char *__gettext PARAMS ((const char *__msgid));
  158. extern char *__dgettext PARAMS ((const char *__domainname,
  159. const char *__msgid));
  160. extern char *__dcgettext PARAMS ((const char *__domainname,
  161. const char *__msgid, int __category));
  162. extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
  163. unsigned long int __n));
  164. extern char *__dngettext PARAMS ((const char *__domainname,
  165. const char *__msgid1, const char *__msgid2,
  166. unsigned long int n));
  167. extern char *__dcngettext PARAMS ((const char *__domainname,
  168. const char *__msgid1, const char *__msgid2,
  169. unsigned long int __n, int __category));
  170. extern char *__dcigettext PARAMS ((const char *__domainname,
  171. const char *__msgid1, const char *__msgid2,
  172. int __plural, unsigned long int __n,
  173. int __category));
  174. extern char *__textdomain PARAMS ((const char *__domainname));
  175. extern char *__bindtextdomain PARAMS ((const char *__domainname,
  176. const char *__dirname));
  177. extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
  178. const char *__codeset));
  179. #else
  180. /* Declare the exported libintl_* functions, in a way that allows us to
  181. call them under their real name. */
  182. # define _INTL_REDIRECT_MACROS
  183. # include "libintl.h"
  184. extern char *libintl_dcigettext PARAMS ((const char *__domainname,
  185. const char *__msgid1,
  186. const char *__msgid2,
  187. int __plural, unsigned long int __n,
  188. int __category));
  189. #endif
  190. /* @@ begin of epilog @@ */
  191. #endif /* gettextP.h */