gettextP.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /* Header describing internals of libintl library.
  2. Copyright (C) 1995-1999, 2000, 2001 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
  5. it under the terms of the GNU General Public License as published by
  6. 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
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  15. #ifndef _GETTEXTP_H
  16. #define _GETTEXTP_H
  17. #include <stddef.h> /* Get size_t. */
  18. #ifdef _LIBC
  19. # include "../iconv/gconv_int.h"
  20. #else
  21. # if HAVE_ICONV
  22. # include <iconv.h>
  23. # endif
  24. #endif
  25. #include "loadinfo.h"
  26. #include "gettext.h" /* Get nls_uint32. */
  27. /* @@ end of prolog @@ */
  28. #ifndef PARAMS
  29. # if __STDC__
  30. # define PARAMS(args) args
  31. # else
  32. # define PARAMS(args) ()
  33. # endif
  34. #endif
  35. #ifndef internal_function
  36. # define internal_function
  37. #endif
  38. /* Tell the compiler when a conditional or integer expression is
  39. almost always true or almost always false. */
  40. #ifndef HAVE_BUILTIN_EXPECT
  41. # define __builtin_expect(expr, val) (expr)
  42. #endif
  43. #ifndef W
  44. # define W(flag, data) ((flag) ? SWAP (data) : (data))
  45. #endif
  46. #ifdef _LIBC
  47. # include <byteswap.h>
  48. # define SWAP(i) bswap_32 (i)
  49. #else
  50. static inline nls_uint32
  51. SWAP (i)
  52. nls_uint32 i;
  53. {
  54. return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
  55. }
  56. #endif
  57. /* This is the representation of the expressions to determine the
  58. plural form. */
  59. struct expression
  60. {
  61. int nargs; /* Number of arguments. */
  62. enum operator
  63. {
  64. /* Without arguments: */
  65. var, /* The variable "n". */
  66. num, /* Decimal number. */
  67. /* Unary operators: */
  68. lnot, /* Logical NOT. */
  69. /* Binary operators: */
  70. mult, /* Multiplication. */
  71. divide, /* Division. */
  72. module, /* Module operation. */
  73. plus, /* Addition. */
  74. minus, /* Subtraction. */
  75. less_than, /* Comparison. */
  76. greater_than, /* Comparison. */
  77. less_or_equal, /* Comparison. */
  78. greater_or_equal, /* Comparison. */
  79. equal, /* Comparision for equality. */
  80. not_equal, /* Comparision for inequality. */
  81. land, /* Logical AND. */
  82. lor, /* Logical OR. */
  83. /* Ternary operators: */
  84. qmop /* Question mark operator. */
  85. } operation;
  86. union
  87. {
  88. unsigned long int num; /* Number value for `num'. */
  89. struct expression *args[3]; /* Up to three arguments. */
  90. } val;
  91. };
  92. /* This is the data structure to pass information to the parser and get
  93. the result in a thread-safe way. */
  94. struct parse_args
  95. {
  96. const char *cp;
  97. struct expression *res;
  98. };
  99. /* The representation of an opened message catalog. */
  100. struct loaded_domain
  101. {
  102. const char *data;
  103. int use_mmap;
  104. size_t mmap_size;
  105. int must_swap;
  106. nls_uint32 nstrings;
  107. struct string_desc *orig_tab;
  108. struct string_desc *trans_tab;
  109. nls_uint32 hash_size;
  110. nls_uint32 *hash_tab;
  111. int codeset_cntr;
  112. #ifdef _LIBC
  113. __gconv_t conv;
  114. #else
  115. # if HAVE_ICONV
  116. iconv_t conv;
  117. # endif
  118. #endif
  119. char **conv_tab;
  120. struct expression *plural;
  121. unsigned long int nplurals;
  122. };
  123. /* We want to allocate a string at the end of the struct. But ISO C
  124. doesn't allow zero sized arrays. */
  125. #ifdef __GNUC__
  126. # define ZERO 0
  127. #else
  128. # define ZERO 1
  129. #endif
  130. /* A set of settings bound to a message domain. Used to store settings
  131. from bindtextdomain() and bind_textdomain_codeset(). */
  132. struct binding
  133. {
  134. struct binding *next;
  135. char *dirname;
  136. int codeset_cntr; /* Incremented each time codeset changes. */
  137. char *codeset;
  138. char domainname[ZERO];
  139. };
  140. /* A counter which is incremented each time some previous translations
  141. become invalid.
  142. This variable is part of the external ABI of the GNU libintl. */
  143. extern int _nl_msg_cat_cntr;
  144. struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
  145. char *__locale,
  146. const char *__domainname,
  147. struct binding *__domainbinding))
  148. internal_function;
  149. void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
  150. struct binding *__domainbinding))
  151. internal_function;
  152. void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
  153. internal_function;
  154. const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
  155. struct loaded_domain *__domain,
  156. struct binding *__domainbinding))
  157. internal_function;
  158. void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
  159. internal_function;
  160. char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
  161. struct binding *domainbinding,
  162. const char *msgid, size_t *lengthp))
  163. internal_function;
  164. #ifdef _LIBC
  165. extern char *__gettext PARAMS ((const char *__msgid));
  166. extern char *__dgettext PARAMS ((const char *__domainname,
  167. const char *__msgid));
  168. extern char *__dcgettext PARAMS ((const char *__domainname,
  169. const char *__msgid, int __category));
  170. extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
  171. unsigned long int __n));
  172. extern char *__dngettext PARAMS ((const char *__domainname,
  173. const char *__msgid1, const char *__msgid2,
  174. unsigned long int n));
  175. extern char *__dcngettext PARAMS ((const char *__domainname,
  176. const char *__msgid1, const char *__msgid2,
  177. unsigned long int __n, int __category));
  178. extern char *__dcigettext PARAMS ((const char *__domainname,
  179. const char *__msgid1, const char *__msgid2,
  180. int __plural, unsigned long int __n,
  181. int __category));
  182. extern char *__textdomain PARAMS ((const char *__domainname));
  183. extern char *__bindtextdomain PARAMS ((const char *__domainname,
  184. const char *__dirname));
  185. extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
  186. const char *__codeset));
  187. #else
  188. extern char *gettext__ PARAMS ((const char *__msgid));
  189. extern char *dgettext__ PARAMS ((const char *__domainname,
  190. const char *__msgid));
  191. extern char *dcgettext__ PARAMS ((const char *__domainname,
  192. const char *__msgid, int __category));
  193. extern char *ngettext__ PARAMS ((const char *__msgid1, const char *__msgid2,
  194. unsigned long int __n));
  195. extern char *dngettext__ PARAMS ((const char *__domainname,
  196. const char *__msgid1, const char *__msgid2,
  197. unsigned long int __n));
  198. extern char *dcngettext__ PARAMS ((const char *__domainname,
  199. const char *__msgid1, const char *__msgid2,
  200. unsigned long int __n, int __category));
  201. extern char *dcigettext__ PARAMS ((const char *__domainname,
  202. const char *__msgid1, const char *__msgid2,
  203. int __plural, unsigned long int __n,
  204. int __category));
  205. extern char *textdomain__ PARAMS ((const char *__domainname));
  206. extern char *bindtextdomain__ PARAMS ((const char *__domainname,
  207. const char *__dirname));
  208. extern char *bind_textdomain_codeset__ PARAMS ((const char *__domainname,
  209. const char *__codeset));
  210. #endif
  211. #ifdef _LIBC
  212. extern void __gettext_free_exp PARAMS ((struct expression *exp))
  213. internal_function;
  214. extern int __gettextparse PARAMS ((void *arg));
  215. #else
  216. extern void gettext_free_exp__ PARAMS ((struct expression *exp))
  217. internal_function;
  218. extern int gettextparse__ PARAMS ((void *arg));
  219. #endif
  220. /* @@ begin of epilog @@ */
  221. #endif /* gettextP.h */