]> git.ipfire.org Git - thirdparty/glibc.git/blame - intl/gettextP.h
* intl/dcigettext.c (DCIGETTEXT): If _nl_find_msg returns -1 don't
[thirdparty/glibc.git] / intl / gettextP.h
CommitLineData
4a4d50f3 1/* Header describing internals of libintl library.
4e82c610 2 Copyright (C) 1995-1999, 2000, 2001, 2004-2005 Free Software Foundation, Inc.
41bdb6e2 3 This file is part of the GNU C Library.
6570e194 4 Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
c84142e8
UD
5
6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
c84142e8
UD
10
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
41bdb6e2 14 Lesser General Public License for more details.
c84142e8 15
41bdb6e2
AJ
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. */
24906b43
RM
20
21#ifndef _GETTEXTP_H
22#define _GETTEXTP_H
23
4a4d50f3
UD
24#include <stddef.h> /* Get size_t. */
25
c90a2db6
UD
26#ifdef _LIBC
27# include "../iconv/gconv_int.h"
28#else
29# if HAVE_ICONV
30# include <iconv.h>
31# endif
6570e194
UD
32#endif
33
7a12c6bb
RM
34#include "loadinfo.h"
35
0f131646 36#include "gmo.h" /* Get nls_uint32. */
4a4d50f3 37
24906b43
RM
38/* @@ end of prolog @@ */
39
be10a868 40#ifndef PARAMS
0f131646 41# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
be10a868 42# define PARAMS(args) args
24906b43 43# else
be10a868 44# define PARAMS(args) ()
24906b43
RM
45# endif
46#endif
47
d0fc4041
UD
48#ifndef internal_function
49# define internal_function
50#endif
51
0f131646
RM
52#ifndef attribute_hidden
53# define attribute_hidden
54#endif
55
17c389fc
UD
56/* Tell the compiler when a conditional or integer expression is
57 almost always true or almost always false. */
58#ifndef HAVE_BUILTIN_EXPECT
59# define __builtin_expect(expr, val) (expr)
60#endif
61
24906b43
RM
62#ifndef W
63# define W(flag, data) ((flag) ? SWAP (data) : (data))
64#endif
65
be10a868 66
c3d6c951
UD
67#ifdef _LIBC
68# include <byteswap.h>
69# define SWAP(i) bswap_32 (i)
70#else
be10a868
RM
71static nls_uint32 SWAP PARAMS ((nls_uint32 i));
72
24906b43
RM
73static inline nls_uint32
74SWAP (i)
75 nls_uint32 i;
76{
77 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
78}
c3d6c951 79#endif
24906b43
RM
80
81
3172f58f
UD
82/* In-memory representation of system dependent string. */
83struct sysdep_string_desc
84{
85 /* Length of addressed string, including the trailing NUL. */
86 size_t length;
87 /* Pointer to addressed string. */
88 const char *pointer;
89};
90
4e82c610
UD
91/* Cache of translated strings after charset conversion.
92 Note: The strings are converted to the target encoding only on an as-needed
93 basis. */
94struct converted_domain
95{
96 /* The target encoding name. */
97 const char *encoding;
98 /* The descriptor for conversion from the message catalog's encoding to
99 this target encoding. */
100#ifdef _LIBC
101 __gconv_t conv;
102#else
103# if HAVE_ICONV
104 iconv_t conv;
105# endif
106#endif
107 /* The table of translated strings after charset conversion. */
108 char **conv_tab;
109};
110
4a4d50f3 111/* The representation of an opened message catalog. */
24906b43
RM
112struct loaded_domain
113{
3172f58f 114 /* Pointer to memory containing the .mo file. */
24906b43 115 const char *data;
3172f58f 116 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
a5a0310d 117 int use_mmap;
3172f58f 118 /* Size of mmap()ed memory. */
a5a0310d 119 size_t mmap_size;
3172f58f 120 /* 1 if the .mo file uses a different endianness than this machine. */
24906b43 121 int must_swap;
3172f58f
UD
122 /* Pointer to additional malloc()ed memory. */
123 void *malloced;
124
125 /* Number of static strings pairs. */
24906b43 126 nls_uint32 nstrings;
3172f58f
UD
127 /* Pointer to descriptors of original strings in the file. */
128 const struct string_desc *orig_tab;
129 /* Pointer to descriptors of translated strings in the file. */
130 const struct string_desc *trans_tab;
131
132 /* Number of system dependent strings pairs. */
133 nls_uint32 n_sysdep_strings;
134 /* Pointer to descriptors of original sysdep strings. */
135 const struct sysdep_string_desc *orig_sysdep_tab;
136 /* Pointer to descriptors of translated sysdep strings. */
137 const struct sysdep_string_desc *trans_sysdep_tab;
138
139 /* Size of hash table. */
24906b43 140 nls_uint32 hash_size;
3172f58f
UD
141 /* Pointer to hash table. */
142 const nls_uint32 *hash_tab;
143 /* 1 if the hash table uses a different endianness than this machine. */
144 int must_swap_hash_tab;
145
4e82c610
UD
146 /* Cache of charset conversions of the translated strings. */
147 struct converted_domain *conversions;
148 size_t nconversions;
abbffdf9
UD
149
150 struct expression *plural;
151 unsigned long int nplurals;
24906b43
RM
152};
153
4a4d50f3
UD
154/* We want to allocate a string at the end of the struct. But ISO C
155 doesn't allow zero sized arrays. */
156#ifdef __GNUC__
157# define ZERO 0
158#else
159# define ZERO 1
160#endif
161
162/* A set of settings bound to a message domain. Used to store settings
163 from bindtextdomain() and bind_textdomain_codeset(). */
24906b43
RM
164struct binding
165{
166 struct binding *next;
24906b43 167 char *dirname;
17c389fc 168 char *codeset;
4a4d50f3 169 char domainname[ZERO];
24906b43
RM
170};
171
4a4d50f3
UD
172/* A counter which is incremented each time some previous translations
173 become invalid.
174 This variable is part of the external ABI of the GNU libintl. */
575b273b
UD
175extern int _nl_msg_cat_cntr;
176
0f131646
RM
177#ifndef _LIBC
178const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
179#endif
180
7a12c6bb
RM
181struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
182 char *__locale,
17c389fc
UD
183 const char *__domainname,
184 struct binding *__domainbinding))
d0fc4041 185 internal_function;
c44a663d
UD
186void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
187 struct binding *__domainbinding))
d0fc4041 188 internal_function;
c44a663d
UD
189
190char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
4e82c610
UD
191 struct binding *domainbinding, const char *msgid,
192 int convert, size_t *lengthp))
c44a663d 193 internal_function;
24906b43 194
abbffdf9 195#ifdef _LIBC
4a4d50f3
UD
196extern char *__gettext PARAMS ((const char *__msgid));
197extern char *__dgettext PARAMS ((const char *__domainname,
198 const char *__msgid));
199extern char *__dcgettext PARAMS ((const char *__domainname,
200 const char *__msgid, int __category));
201extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
202 unsigned long int __n));
203extern char *__dngettext PARAMS ((const char *__domainname,
204 const char *__msgid1, const char *__msgid2,
205 unsigned long int n));
206extern char *__dcngettext PARAMS ((const char *__domainname,
207 const char *__msgid1, const char *__msgid2,
208 unsigned long int __n, int __category));
209extern char *__dcigettext PARAMS ((const char *__domainname,
210 const char *__msgid1, const char *__msgid2,
211 int __plural, unsigned long int __n,
212 int __category));
213extern char *__textdomain PARAMS ((const char *__domainname));
214extern char *__bindtextdomain PARAMS ((const char *__domainname,
215 const char *__dirname));
216extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
217 const char *__codeset));
9e365fe7
UD
218extern void _nl_finddomain_subfreeres PARAMS ((void)) attribute_hidden;
219extern void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
220 internal_function attribute_hidden;
abbffdf9 221#else
0f131646
RM
222extern char *libintl_gettext PARAMS ((const char *__msgid));
223extern char *libintl_dgettext PARAMS ((const char *__domainname,
224 const char *__msgid));
225extern char *libintl_dcgettext PARAMS ((const char *__domainname,
226 const char *__msgid, int __category));
227extern char *libintl_ngettext PARAMS ((const char *__msgid1,
228 const char *__msgid2,
229 unsigned long int __n));
230extern char *libintl_dngettext PARAMS ((const char *__domainname,
231 const char *__msgid1,
232 const char *__msgid2,
233 unsigned long int __n));
234extern char *libintl_dcngettext PARAMS ((const char *__domainname,
235 const char *__msgid1,
236 const char *__msgid2,
237 unsigned long int __n,
238 int __category));
239extern char *libintl_dcigettext PARAMS ((const char *__domainname,
240 const char *__msgid1,
241 const char *__msgid2,
242 int __plural, unsigned long int __n,
243 int __category));
244extern char *libintl_textdomain PARAMS ((const char *__domainname));
245extern char *libintl_bindtextdomain PARAMS ((const char *__domainname,
246 const char *__dirname));
247extern char *libintl_bind_textdomain_codeset PARAMS ((const char *__domainname,
248 const char *__codeset));
abbffdf9
UD
249#endif
250
24906b43
RM
251/* @@ begin of epilog @@ */
252
253#endif /* gettextP.h */