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.

gettextP.h 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  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 internal_function
  30. # define internal_function
  31. #endif
  32. #ifndef attribute_hidden
  33. # define attribute_hidden
  34. #endif
  35. /* Tell the compiler when a conditional or integer expression is
  36. almost always true or almost always false. */
  37. #ifndef HAVE_BUILTIN_EXPECT
  38. # define __builtin_expect(expr, val) (expr)
  39. #endif
  40. #ifndef W
  41. # define W(flag, data) ((flag) ? SWAP (data) : (data))
  42. #endif
  43. #ifdef _LIBC
  44. # include <byteswap.h>
  45. # define SWAP(i) bswap_32 (i)
  46. #else
  47. static inline nls_uint32
  48. SWAP (i)
  49. nls_uint32 i;
  50. {
  51. return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
  52. }
  53. #endif
  54. /* In-memory representation of system dependent string. */
  55. struct sysdep_string_desc
  56. {
  57. /* Length of addressed string, including the trailing NUL. */
  58. size_t length;
  59. /* Pointer to addressed string. */
  60. const char *pointer;
  61. };
  62. /* The representation of an opened message catalog. */
  63. struct loaded_domain
  64. {
  65. /* Pointer to memory containing the .mo file. */
  66. const char *data;
  67. /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
  68. int use_mmap;
  69. /* Size of mmap()ed memory. */
  70. size_t mmap_size;
  71. /* 1 if the .mo file uses a different endianness than this machine. */
  72. int must_swap;
  73. /* Pointer to additional malloc()ed memory. */
  74. void *malloced;
  75. /* Number of static strings pairs. */
  76. nls_uint32 nstrings;
  77. /* Pointer to descriptors of original strings in the file. */
  78. const struct string_desc *orig_tab;
  79. /* Pointer to descriptors of translated strings in the file. */
  80. const struct string_desc *trans_tab;
  81. /* Number of system dependent strings pairs. */
  82. nls_uint32 n_sysdep_strings;
  83. /* Pointer to descriptors of original sysdep strings. */
  84. const struct sysdep_string_desc *orig_sysdep_tab;
  85. /* Pointer to descriptors of translated sysdep strings. */
  86. const struct sysdep_string_desc *trans_sysdep_tab;
  87. /* Size of hash table. */
  88. nls_uint32 hash_size;
  89. /* Pointer to hash table. */
  90. const nls_uint32 *hash_tab;
  91. /* 1 if the hash table uses a different endianness than this machine. */
  92. int must_swap_hash_tab;
  93. int codeset_cntr;
  94. #ifdef _LIBC
  95. __gconv_t conv;
  96. #else
  97. # if HAVE_ICONV
  98. iconv_t conv;
  99. # endif
  100. #endif
  101. char **conv_tab;
  102. struct expression *plural;
  103. unsigned long int nplurals;
  104. };
  105. /* We want to allocate a string at the end of the struct. But ISO C
  106. doesn't allow zero sized arrays. */
  107. #ifdef __GNUC__
  108. # define ZERO 0
  109. #else
  110. # define ZERO 1
  111. #endif
  112. /* A set of settings bound to a message domain. Used to store settings
  113. from bindtextdomain() and bind_textdomain_codeset(). */
  114. struct binding
  115. {
  116. struct binding *next;
  117. char *dirname;
  118. int codeset_cntr; /* Incremented each time codeset changes. */
  119. char *codeset;
  120. char domainname[ZERO];
  121. };
  122. /* A counter which is incremented each time some previous translations
  123. become invalid.
  124. This variable is part of the external ABI of the GNU libintl. */
  125. extern int _nl_msg_cat_cntr;
  126. #ifndef _LIBC
  127. const char *_nl_locale_name (int category, const char *categoryname);
  128. #endif
  129. struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale,
  130. const char *__domainname,
  131. struct binding *__domainbinding)
  132. internal_function;
  133. void _nl_load_domain (struct loaded_l10nfile *__domain,
  134. struct binding *__domainbinding)
  135. internal_function;
  136. void _nl_unload_domain (struct loaded_domain *__domain)
  137. internal_function;
  138. const char *_nl_init_domain_conv (struct loaded_l10nfile *__domain_file,
  139. struct loaded_domain *__domain,
  140. struct binding *__domainbinding)
  141. internal_function;
  142. void _nl_free_domain_conv (struct loaded_domain *__domain)
  143. internal_function;
  144. char *_nl_find_msg (struct loaded_l10nfile *domain_file,
  145. struct binding *domainbinding, const char *msgid,
  146. size_t *lengthp)
  147. internal_function;
  148. #ifdef _LIBC
  149. extern char *__gettext (const char *__msgid);
  150. extern char *__dgettext (const char *__domainname, const char *__msgid);
  151. extern char *__dcgettext (const char *__domainname, const char *__msgid,
  152. int __category);
  153. extern char *__ngettext (const char *__msgid1, const char *__msgid2,
  154. unsigned long int __n);
  155. extern char *__dngettext (const char *__domainname,
  156. const char *__msgid1, const char *__msgid2,
  157. unsigned long int n);
  158. extern char *__dcngettext (const char *__domainname,
  159. const char *__msgid1, const char *__msgid2,
  160. unsigned long int __n, int __category);
  161. extern char *__dcigettext (const char *__domainname,
  162. const char *__msgid1, const char *__msgid2,
  163. int __plural, unsigned long int __n,
  164. int __category);
  165. extern char *__textdomain (const char *__domainname);
  166. extern char *__bindtextdomain (const char *__domainname,
  167. const char *__dirname);
  168. extern char *__bind_textdomain_codeset (const char *__domainname,
  169. const char *__codeset);
  170. #else
  171. /* Declare the exported libintl_* functions, in a way that allows us to
  172. call them under their real name. */
  173. # undef _INTL_REDIRECT_INLINE
  174. # undef _INTL_REDIRECT_MACROS
  175. # define _INTL_REDIRECT_MACROS
  176. # include "libgnuintl.h"
  177. extern char *libintl_dcigettext (const char *__domainname,
  178. const char *__msgid1, const char *__msgid2,
  179. int __plural, unsigned long int __n,
  180. int __category);
  181. #endif
  182. /* @@ begin of epilog @@ */
  183. #endif /* gettextP.h */