]> git.ipfire.org Git - thirdparty/glibc.git/blame - intl/gettextP.h
Fix rule dependency in last change.
[thirdparty/glibc.git] / intl / gettextP.h
CommitLineData
4a4d50f3 1/* Header describing internals of libintl library.
3ce1f295 2 Copyright (C) 1995-1999, 2000, 2001, 2004-2005, 2007, 2011
701666b7 3 Free Software Foundation, Inc.
41bdb6e2 4 This file is part of the GNU C Library.
6570e194 5 Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
c84142e8
UD
6
7 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
c84142e8
UD
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 15 Lesser General Public License for more details.
c84142e8 16
41bdb6e2 17 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
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
24906b43
RM
56#ifndef W
57# define W(flag, data) ((flag) ? SWAP (data) : (data))
58#endif
59
be10a868 60
c3d6c951
UD
61#ifdef _LIBC
62# include <byteswap.h>
63# define SWAP(i) bswap_32 (i)
64#else
be10a868
RM
65static nls_uint32 SWAP PARAMS ((nls_uint32 i));
66
24906b43
RM
67static inline nls_uint32
68SWAP (i)
69 nls_uint32 i;
70{
71 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
72}
c3d6c951 73#endif
24906b43
RM
74
75
3172f58f
UD
76/* In-memory representation of system dependent string. */
77struct sysdep_string_desc
78{
79 /* Length of addressed string, including the trailing NUL. */
80 size_t length;
81 /* Pointer to addressed string. */
82 const char *pointer;
83};
84
4e82c610
UD
85/* Cache of translated strings after charset conversion.
86 Note: The strings are converted to the target encoding only on an as-needed
87 basis. */
88struct converted_domain
89{
90 /* The target encoding name. */
91 const char *encoding;
92 /* The descriptor for conversion from the message catalog's encoding to
93 this target encoding. */
94#ifdef _LIBC
95 __gconv_t conv;
96#else
97# if HAVE_ICONV
98 iconv_t conv;
99# endif
100#endif
101 /* The table of translated strings after charset conversion. */
102 char **conv_tab;
103};
104
4a4d50f3 105/* The representation of an opened message catalog. */
24906b43
RM
106struct loaded_domain
107{
3172f58f 108 /* Pointer to memory containing the .mo file. */
24906b43 109 const char *data;
3172f58f 110 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
a5a0310d 111 int use_mmap;
3172f58f 112 /* Size of mmap()ed memory. */
a5a0310d 113 size_t mmap_size;
3172f58f 114 /* 1 if the .mo file uses a different endianness than this machine. */
24906b43 115 int must_swap;
3172f58f
UD
116 /* Pointer to additional malloc()ed memory. */
117 void *malloced;
118
119 /* Number of static strings pairs. */
24906b43 120 nls_uint32 nstrings;
3172f58f
UD
121 /* Pointer to descriptors of original strings in the file. */
122 const struct string_desc *orig_tab;
123 /* Pointer to descriptors of translated strings in the file. */
124 const struct string_desc *trans_tab;
125
126 /* Number of system dependent strings pairs. */
127 nls_uint32 n_sysdep_strings;
128 /* Pointer to descriptors of original sysdep strings. */
129 const struct sysdep_string_desc *orig_sysdep_tab;
130 /* Pointer to descriptors of translated sysdep strings. */
131 const struct sysdep_string_desc *trans_sysdep_tab;
132
133 /* Size of hash table. */
24906b43 134 nls_uint32 hash_size;
3172f58f
UD
135 /* Pointer to hash table. */
136 const nls_uint32 *hash_tab;
137 /* 1 if the hash table uses a different endianness than this machine. */
138 int must_swap_hash_tab;
139
4e82c610
UD
140 /* Cache of charset conversions of the translated strings. */
141 struct converted_domain *conversions;
142 size_t nconversions;
a389bcaa 143 __libc_rwlock_define (, conversions_lock);
abbffdf9 144
701666b7 145 const struct expression *plural;
abbffdf9 146 unsigned long int nplurals;
24906b43
RM
147};
148
4a4d50f3
UD
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
156
157/* A set of settings bound to a message domain. Used to store settings
158 from bindtextdomain() and bind_textdomain_codeset(). */
24906b43
RM
159struct binding
160{
161 struct binding *next;
24906b43 162 char *dirname;
17c389fc 163 char *codeset;
4a4d50f3 164 char domainname[ZERO];
24906b43
RM
165};
166
4a4d50f3
UD
167/* A counter which is incremented each time some previous translations
168 become invalid.
169 This variable is part of the external ABI of the GNU libintl. */
575b273b
UD
170extern int _nl_msg_cat_cntr;
171
0f131646
RM
172#ifndef _LIBC
173const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
174#endif
175
7a12c6bb
RM
176struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
177 char *__locale,
17c389fc
UD
178 const char *__domainname,
179 struct binding *__domainbinding))
d0fc4041 180 internal_function;
c44a663d
UD
181void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
182 struct binding *__domainbinding))
d0fc4041 183 internal_function;
c44a663d
UD
184
185char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
4e82c610
UD
186 struct binding *domainbinding, const char *msgid,
187 int convert, size_t *lengthp))
c44a663d 188 internal_function;
24906b43 189
abbffdf9 190#ifdef _LIBC
4a4d50f3
UD
191extern char *__gettext PARAMS ((const char *__msgid));
192extern char *__dgettext PARAMS ((const char *__domainname,
193 const char *__msgid));
194extern char *__dcgettext PARAMS ((const char *__domainname,
195 const char *__msgid, int __category));
196extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
197 unsigned long int __n));
198extern char *__dngettext PARAMS ((const char *__domainname,
199 const char *__msgid1, const char *__msgid2,
200 unsigned long int n));
201extern char *__dcngettext PARAMS ((const char *__domainname,
202 const char *__msgid1, const char *__msgid2,
203 unsigned long int __n, int __category));
204extern char *__dcigettext PARAMS ((const char *__domainname,
205 const char *__msgid1, const char *__msgid2,
206 int __plural, unsigned long int __n,
207 int __category));
208extern char *__textdomain PARAMS ((const char *__domainname));
209extern char *__bindtextdomain PARAMS ((const char *__domainname,
210 const char *__dirname));
211extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
212 const char *__codeset));
9e365fe7
UD
213extern void _nl_finddomain_subfreeres PARAMS ((void)) attribute_hidden;
214extern void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
215 internal_function attribute_hidden;
abbffdf9 216#else
0f131646
RM
217extern char *libintl_gettext PARAMS ((const char *__msgid));
218extern char *libintl_dgettext PARAMS ((const char *__domainname,
219 const char *__msgid));
220extern char *libintl_dcgettext PARAMS ((const char *__domainname,
221 const char *__msgid, int __category));
222extern char *libintl_ngettext PARAMS ((const char *__msgid1,
223 const char *__msgid2,
224 unsigned long int __n));
225extern char *libintl_dngettext PARAMS ((const char *__domainname,
226 const char *__msgid1,
227 const char *__msgid2,
228 unsigned long int __n));
229extern char *libintl_dcngettext PARAMS ((const char *__domainname,
230 const char *__msgid1,
231 const char *__msgid2,
232 unsigned long int __n,
233 int __category));
234extern char *libintl_dcigettext PARAMS ((const char *__domainname,
235 const char *__msgid1,
236 const char *__msgid2,
237 int __plural, unsigned long int __n,
238 int __category));
239extern char *libintl_textdomain PARAMS ((const char *__domainname));
240extern char *libintl_bindtextdomain PARAMS ((const char *__domainname,
241 const char *__dirname));
242extern char *libintl_bind_textdomain_codeset PARAMS ((const char *__domainname,
243 const char *__codeset));
abbffdf9
UD
244#endif
245
24906b43
RM
246/* @@ begin of epilog @@ */
247
248#endif /* gettextP.h */