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