Update.
[glibc.git] / intl / gettextP.h
blob8dcbaf2859e901d9cf19d779bc3327d8fb34841c
1 /* Header describing internals of gettext library
2 Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
3 Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library 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 GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #ifndef _GETTEXTP_H
21 #define _GETTEXTP_H
23 #ifdef _LIBC
24 # include "../iconv/gconv_int.h"
25 #else
26 # if HAVE_ICONV
27 # include <iconv.h>
28 # endif
29 #endif
31 #include "loadinfo.h"
33 /* @@ end of prolog @@ */
35 #ifndef PARAMS
36 # if __STDC__
37 # define PARAMS(args) args
38 # else
39 # define PARAMS(args) ()
40 # endif
41 #endif
43 #ifndef internal_function
44 # define internal_function
45 #endif
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
53 #ifndef W
54 # define W(flag, data) ((flag) ? SWAP (data) : (data))
55 #endif
58 #ifdef _LIBC
59 # include <byteswap.h>
60 # define SWAP(i) bswap_32 (i)
61 #else
62 static nls_uint32 SWAP PARAMS ((nls_uint32 i));
64 static inline nls_uint32
65 SWAP (i)
66 nls_uint32 i;
68 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
70 #endif
73 /* This is the representation of the expressions to determine the
74 plural form. */
75 struct expression
77 enum operator
79 var, /* The variable "n". */
80 num, /* Decimal number. */
81 mult, /* Multiplication. */
82 divide, /* Division. */
83 module, /* Module operation. */
84 plus, /* Addition. */
85 minus, /* Subtraction. */
86 equal, /* Comparision for equality. */
87 not_equal, /* Comparision for inequality. */
88 land, /* Logical AND. */
89 lor, /* Logical OR. */
90 qmop /* Question mark operator. */
91 } operation;
92 union
94 unsigned long int num; /* Number value for `num'. */
95 struct
97 struct expression *left; /* Left expression in binary operation. */
98 struct expression *right; /* Right expression in binary operation. */
99 } args2;
100 struct
102 struct expression *bexp; /* Boolean expression in ?: operation. */
103 struct expression *tbranch; /* True-branch in ?: operation. */
104 struct expression *fbranch; /* False-branch in ?: operation. */
105 } args3;
106 } val;
109 /* This is the data structure to pass information to the parser and get
110 the result in a thread-safe way. */
111 struct parse_args
113 const char *cp;
114 struct expression *res;
118 struct loaded_domain
120 const char *data;
121 int use_mmap;
122 size_t mmap_size;
123 int must_swap;
124 nls_uint32 nstrings;
125 struct string_desc *orig_tab;
126 struct string_desc *trans_tab;
127 nls_uint32 hash_size;
128 nls_uint32 *hash_tab;
129 #ifdef _LIBC
130 __gconv_t conv;
131 #else
132 # if HAVE_ICONV
133 iconv_t conv;
134 # endif
135 #endif
136 char **conv_tab;
138 struct expression *plural;
139 unsigned long int nplurals;
142 struct binding
144 struct binding *next;
145 char *dirname;
146 char *codeset;
147 #ifdef __GNUC__
148 char domainname[0];
149 #else
150 char domainname[1];
151 #endif
154 extern int _nl_msg_cat_cntr;
156 struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
157 char *__locale,
158 const char *__domainname,
159 struct binding *__domainbinding))
160 internal_function;
161 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain))
162 internal_function;
163 void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
164 internal_function;
166 #ifdef _LIBC
167 extern char *__ngettext PARAMS ((const char *msgid1, const char *msgid2,
168 unsigned long int n));
169 extern char *__dngettext PARAMS ((const char *domainname, const char *msgid1,
170 const char *msgid2, unsigned long int n));
171 extern char *__dcngettext PARAMS ((const char *domainname, const char *msgid1,
172 const char *msgid2, unsigned long int n,
173 int category));
174 extern char *__dcigettext PARAMS ((const char *domainname, const char *msgid1,
175 const char *msgid2, int plural,
176 unsigned long int n, int category));
177 #else
178 extern char *ngettext__ PARAMS ((const char *msgid1, const char *msgid2,
179 unsigned long int n));
180 extern char *dngettext__ PARAMS ((const char *domainname, const char *msgid1,
181 const char *msgid2, unsigned long int n));
182 extern char *dcngettext__ PARAMS ((const char *domainname, const char *msgid1,
183 const char *msgid2, unsigned long int n,
184 int category));
185 extern char *dcigettext__ PARAMS ((const char *domainname, const char *msgid1,
186 const char *msgid2, int plural,
187 unsigned long int n, int category));
188 #endif
190 extern int __gettextdebug;
191 extern void __gettext_free_exp (struct expression *exp) internal_function;
192 extern int __gettextparse (void *arg);
194 /* @@ begin of epilog @@ */
196 #endif /* gettextP.h */