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