iconv: Bail out of the loop when an illegal sequence of bytes occurs.
[elinks/elinks-j605.git] / src / intl / gettext / gettextP.h
blobe2654daeb7b4310ed4df840e02ba3237ee12b85b
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.
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.
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.
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. */
19 #ifndef _GETTEXTP_H
20 #define _GETTEXTP_H
22 #include <stddef.h> /* Get size_t. */
24 #include "util/string.h" /* Get possible stubs. */
26 #ifdef HAVE_ICONV
27 #include <iconv.h>
28 #endif
30 #include "intl/gettext/loadinfo.h"
31 #include "intl/gettext/gettext.h" /* Get nls_uint32. */
33 #ifndef W
34 #define W(flag, data) ((flag) ? SWAP (data) : (data))
35 #endif
37 static inline nls_uint32
38 SWAP(nls_uint32 i)
40 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >>
41 24);
44 /* This is the representation of the expressions to determine the
45 plural form. */
46 struct expression {
47 int nargs; /* Number of arguments. */
48 enum operator {
49 /* Without arguments: */
50 var, /* The variable "n". */
51 num, /* Decimal number. */
52 /* Unary operators: */
53 lnot, /* Logical NOT. */
54 /* Binary operators: */
55 mult, /* Multiplication. */
56 divide, /* Division. */
57 module, /* Module operation. */
58 plus, /* Addition. */
59 minus, /* Subtraction. */
60 less_than, /* Comparison. */
61 greater_than, /* Comparison. */
62 less_or_equal, /* Comparison. */
63 greater_or_equal, /* Comparison. */
64 equal, /* Comparision for equality. */
65 not_equal, /* Comparision for inequality. */
66 land, /* Logical AND. */
67 lor, /* Logical OR. */
68 /* Ternary operators: */
69 qmop /* Question mark operator. */
70 } operation;
71 union {
72 unsigned long int num; /* Number value for `num'. */
73 struct expression *args[3]; /* Up to three arguments. */
74 } val;
77 /* This is the data structure to pass information to the parser and get
78 the result in a thread-safe way. */
79 struct parse_args {
80 const unsigned char *cp;
81 struct expression *res;
84 /* The representation of an opened message catalog. */
85 struct loaded_domain {
86 const unsigned char *data;
87 int use_mmap;
88 size_t mmap_size;
89 int must_swap;
90 nls_uint32 nstrings;
91 struct string_desc *orig_tab;
92 struct string_desc *trans_tab;
93 nls_uint32 hash_size;
94 nls_uint32 *hash_tab;
95 int codeset_cntr;
96 #if HAVE_ICONV
97 iconv_t conv;
98 #endif
99 unsigned char **conv_tab;
101 struct expression *plural;
102 unsigned long int nplurals;
105 /* A set of settings bound to a message domain. Used to store settings
106 from bindtextdomain() and bind_textdomain_codeset(). */
107 struct binding {
108 struct binding *next;
109 unsigned char *dirname;
110 int codeset_cntr; /* Incremented each time codeset changes. */
111 unsigned char *codeset;
112 unsigned char domainname[1];
115 extern unsigned char *LANGUAGE;
117 /* A counter which is incremented each time some previous translations
118 become invalid.
119 This variable is part of the external ABI of the GNU libintl. */
120 extern int _nl_msg_cat_cntr;
122 struct loaded_l10nfile *_nl_find_domain(const unsigned char *__dirname,
123 unsigned char *__locale,
124 const unsigned char *__domainname,
125 struct binding *
126 __domainbinding);
127 void _nl_load_domain(struct loaded_l10nfile * __domain,
128 struct binding * __domainbinding);
129 void _nl_unload_domain(struct loaded_domain * __domain);
130 const unsigned char *_nl_init_domain_conv(struct loaded_l10nfile * __domain_file,
131 struct loaded_domain * __domain,
132 struct binding * __domainbinding);
133 void _nl_free_domain_conv(struct loaded_domain * __domain);
135 unsigned char *_nl_find_msg(struct loaded_l10nfile * domain_file,
136 struct binding * domainbinding,
137 const unsigned char *msgid, size_t * lengthp);
139 extern unsigned char *gettext__(const unsigned char *__msgid);
140 extern unsigned char *dgettext__(const unsigned char *__domainname, const unsigned char *__msgid);
141 extern unsigned char *dcgettext__(const unsigned char *__domainname,
142 const unsigned char *__msgid, int __category);
143 extern unsigned char *ngettext__(const unsigned char *__msgid1, const unsigned char *__msgid2,
144 unsigned long int __n);
145 extern unsigned char *dngettext__(const unsigned char *__domainname,
146 const unsigned char *__msgid1, const unsigned char *__msgid2,
147 unsigned long int __n);
148 extern unsigned char *dcngettext__(const unsigned char *__domainname,
149 const unsigned char *__msgid1, const unsigned char *__msgid2,
150 unsigned long int __n, int __category);
151 extern unsigned char *dcigettext__(const unsigned char *__domainname,
152 const unsigned char *__msgid1, const unsigned char *__msgid2,
153 int __plural, unsigned long int __n,
154 int __category);
155 extern unsigned char *textdomain__(const unsigned char *__domainname);
156 extern unsigned char *bindtextdomain__(const unsigned char *__domainname,
157 const unsigned char *__dirname);
158 extern unsigned char *bind_textdomain_codeset__(const unsigned char *__domainname,
159 const unsigned char *__codeset);
161 extern void gettext_free_exp__(struct expression * exp);
162 extern int gettext__parse(void *arg);
164 #endif /* gettextP.h */