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