blob: f085c59bb963e95d1ca7f21cc5907bb233a6a4a6 [file] [log] [blame]
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001/* Header describing internals of libintl library.
2 Copyright (C) 1995-1999, 2000-2002 Free Software Foundation, Inc.
3 Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
Theodore Ts'o5bc5a892000-02-08 20:20:46 +00004
Theodore Ts'oa04eba32003-05-03 16:35:17 -04005 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published
7 by the Free Software Foundation; either version 2, or (at your option)
Theodore Ts'o5bc5a892000-02-08 20:20:46 +00008 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
Theodore Ts'oa04eba32003-05-03 16:35:17 -040012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
Theodore Ts'o5bc5a892000-02-08 20:20:46 +000014
Theodore Ts'oa04eba32003-05-03 16:35:17 -040015 You should have received a copy of the GNU Library General Public
16 License along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 USA. */
Theodore Ts'o5bc5a892000-02-08 20:20:46 +000019
20#ifndef _GETTEXTP_H
21#define _GETTEXTP_H
22
Theodore Ts'oa04eba32003-05-03 16:35:17 -040023#include <stddef.h> /* Get size_t. */
24
25#ifdef _LIBC
26# include "../iconv/gconv_int.h"
27#else
28# if HAVE_ICONV
29# include <iconv.h>
30# endif
31#endif
32
Theodore Ts'o5bc5a892000-02-08 20:20:46 +000033#include "loadinfo.h"
34
Theodore Ts'oa04eba32003-05-03 16:35:17 -040035#include "gmo.h" /* Get nls_uint32. */
36
Theodore Ts'o5bc5a892000-02-08 20:20:46 +000037/* @@ end of prolog @@ */
38
39#ifndef PARAMS
Theodore Ts'oa04eba32003-05-03 16:35:17 -040040# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
Theodore Ts'o5bc5a892000-02-08 20:20:46 +000041# define PARAMS(args) args
42# else
43# define PARAMS(args) ()
44# endif
45#endif
46
47#ifndef internal_function
48# define internal_function
49#endif
50
Theodore Ts'oa04eba32003-05-03 16:35:17 -040051#ifndef attribute_hidden
52# define attribute_hidden
53#endif
54
55/* Tell the compiler when a conditional or integer expression is
56 almost always true or almost always false. */
57#ifndef HAVE_BUILTIN_EXPECT
58# define __builtin_expect(expr, val) (expr)
59#endif
60
Theodore Ts'o5bc5a892000-02-08 20:20:46 +000061#ifndef W
62# define W(flag, data) ((flag) ? SWAP (data) : (data))
63#endif
64
65
66#ifdef _LIBC
67# include <byteswap.h>
68# define SWAP(i) bswap_32 (i)
69#else
Theodore Ts'o5bc5a892000-02-08 20:20:46 +000070static inline nls_uint32
71SWAP (i)
72 nls_uint32 i;
73{
74 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
75}
76#endif
77
78
Theodore Ts'oa04eba32003-05-03 16:35:17 -040079/* In-memory representation of system dependent string. */
80struct sysdep_string_desc
Theodore Ts'o5bc5a892000-02-08 20:20:46 +000081{
Theodore Ts'oa04eba32003-05-03 16:35:17 -040082 /* Length of addressed string, including the trailing NUL. */
83 size_t length;
84 /* Pointer to addressed string. */
85 const char *pointer;
Theodore Ts'o5bc5a892000-02-08 20:20:46 +000086};
87
Theodore Ts'oa04eba32003-05-03 16:35:17 -040088/* The representation of an opened message catalog. */
89struct loaded_domain
90{
91 /* Pointer to memory containing the .mo file. */
92 const char *data;
93 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
94 int use_mmap;
95 /* Size of mmap()ed memory. */
96 size_t mmap_size;
97 /* 1 if the .mo file uses a different endianness than this machine. */
98 int must_swap;
99 /* Pointer to additional malloc()ed memory. */
100 void *malloced;
101
102 /* Number of static strings pairs. */
103 nls_uint32 nstrings;
104 /* Pointer to descriptors of original strings in the file. */
105 const struct string_desc *orig_tab;
106 /* Pointer to descriptors of translated strings in the file. */
107 const struct string_desc *trans_tab;
108
109 /* Number of system dependent strings pairs. */
110 nls_uint32 n_sysdep_strings;
111 /* Pointer to descriptors of original sysdep strings. */
112 const struct sysdep_string_desc *orig_sysdep_tab;
113 /* Pointer to descriptors of translated sysdep strings. */
114 const struct sysdep_string_desc *trans_sysdep_tab;
115
116 /* Size of hash table. */
117 nls_uint32 hash_size;
118 /* Pointer to hash table. */
119 const nls_uint32 *hash_tab;
120 /* 1 if the hash table uses a different endianness than this machine. */
121 int must_swap_hash_tab;
122
123 int codeset_cntr;
124#ifdef _LIBC
125 __gconv_t conv;
126#else
127# if HAVE_ICONV
128 iconv_t conv;
129# endif
130#endif
131 char **conv_tab;
132
133 struct expression *plural;
134 unsigned long int nplurals;
135};
136
137/* We want to allocate a string at the end of the struct. But ISO C
138 doesn't allow zero sized arrays. */
139#ifdef __GNUC__
140# define ZERO 0
141#else
142# define ZERO 1
143#endif
144
145/* A set of settings bound to a message domain. Used to store settings
146 from bindtextdomain() and bind_textdomain_codeset(). */
Theodore Ts'o5bc5a892000-02-08 20:20:46 +0000147struct binding
148{
149 struct binding *next;
Theodore Ts'o5bc5a892000-02-08 20:20:46 +0000150 char *dirname;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400151 int codeset_cntr; /* Incremented each time codeset changes. */
152 char *codeset;
153 char domainname[ZERO];
Theodore Ts'o5bc5a892000-02-08 20:20:46 +0000154};
155
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400156/* A counter which is incremented each time some previous translations
157 become invalid.
158 This variable is part of the external ABI of the GNU libintl. */
159extern int _nl_msg_cat_cntr;
160
161#ifndef _LIBC
162const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
163#endif
164
Theodore Ts'o5bc5a892000-02-08 20:20:46 +0000165struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
166 char *__locale,
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400167 const char *__domainname,
168 struct binding *__domainbinding))
Theodore Ts'o5bc5a892000-02-08 20:20:46 +0000169 internal_function;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400170void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
171 struct binding *__domainbinding))
Theodore Ts'o5bc5a892000-02-08 20:20:46 +0000172 internal_function;
173void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
174 internal_function;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400175const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
176 struct loaded_domain *__domain,
177 struct binding *__domainbinding))
178 internal_function;
179void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
180 internal_function;
181
182char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
183 struct binding *domainbinding,
184 const char *msgid, size_t *lengthp))
185 internal_function;
186
187#ifdef _LIBC
188extern char *__gettext PARAMS ((const char *__msgid));
189extern char *__dgettext PARAMS ((const char *__domainname,
190 const char *__msgid));
191extern char *__dcgettext PARAMS ((const char *__domainname,
192 const char *__msgid, int __category));
193extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
194 unsigned long int __n));
195extern char *__dngettext PARAMS ((const char *__domainname,
196 const char *__msgid1, const char *__msgid2,
197 unsigned long int n));
198extern char *__dcngettext PARAMS ((const char *__domainname,
199 const char *__msgid1, const char *__msgid2,
200 unsigned long int __n, int __category));
201extern char *__dcigettext PARAMS ((const char *__domainname,
202 const char *__msgid1, const char *__msgid2,
203 int __plural, unsigned long int __n,
204 int __category));
205extern char *__textdomain PARAMS ((const char *__domainname));
206extern char *__bindtextdomain PARAMS ((const char *__domainname,
207 const char *__dirname));
208extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
209 const char *__codeset));
210#else
211extern char *libintl_gettext PARAMS ((const char *__msgid));
212extern char *libintl_dgettext PARAMS ((const char *__domainname,
213 const char *__msgid));
214extern char *libintl_dcgettext PARAMS ((const char *__domainname,
215 const char *__msgid, int __category));
216extern char *libintl_ngettext PARAMS ((const char *__msgid1,
217 const char *__msgid2,
218 unsigned long int __n));
219extern char *libintl_dngettext PARAMS ((const char *__domainname,
220 const char *__msgid1,
221 const char *__msgid2,
222 unsigned long int __n));
223extern char *libintl_dcngettext PARAMS ((const char *__domainname,
224 const char *__msgid1,
225 const char *__msgid2,
226 unsigned long int __n,
227 int __category));
228extern char *libintl_dcigettext PARAMS ((const char *__domainname,
229 const char *__msgid1,
230 const char *__msgid2,
231 int __plural, unsigned long int __n,
232 int __category));
233extern char *libintl_textdomain PARAMS ((const char *__domainname));
234extern char *libintl_bindtextdomain PARAMS ((const char *__domainname,
235 const char *__dirname));
236extern char *libintl_bind_textdomain_codeset PARAMS ((const char *__domainname,
237 const char *__codeset));
238#endif
Theodore Ts'o5bc5a892000-02-08 20:20:46 +0000239
240/* @@ begin of epilog @@ */
241
242#endif /* gettextP.h */