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