source: vendor/glibc/2005-03-05/intl/gettextP.h

Last change on this file was 1836, checked in by bird, 21 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.7 KB
Line 
1/* Header describing internals of libintl library.
2 Copyright (C) 1995-1999, 2000, 2001, 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
5
6 The GNU C Library is free software; you can redistribute it and/or
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.
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
14 Lesser General Public License for more details.
15
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. */
20
21#ifndef _GETTEXTP_H
22#define _GETTEXTP_H
23
24#include <stddef.h> /* Get size_t. */
25
26#ifdef _LIBC
27# include "../iconv/gconv_int.h"
28#else
29# if HAVE_ICONV
30# include <iconv.h>
31# endif
32#endif
33
34#include "loadinfo.h"
35
36#include "gmo.h" /* Get nls_uint32. */
37
38/* @@ end of prolog @@ */
39
40#ifndef PARAMS
41# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
42# define PARAMS(args) args
43# else
44# define PARAMS(args) ()
45# endif
46#endif
47
48#ifndef internal_function
49# define internal_function
50#endif
51
52#ifndef attribute_hidden
53# define attribute_hidden
54#endif
55
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
62#ifndef W
63# define W(flag, data) ((flag) ? SWAP (data) : (data))
64#endif
65
66
67#ifdef _LIBC
68# include <byteswap.h>
69# define SWAP(i) bswap_32 (i)
70#else
71static nls_uint32 SWAP PARAMS ((nls_uint32 i));
72
73static inline nls_uint32
74SWAP (i)
75 nls_uint32 i;
76{
77 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
78}
79#endif
80
81
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
91/* The representation of an opened message catalog. */
92struct loaded_domain
93{
94 /* Pointer to memory containing the .mo file. */
95 const char *data;
96 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
97 int use_mmap;
98 /* Size of mmap()ed memory. */
99 size_t mmap_size;
100 /* 1 if the .mo file uses a different endianness than this machine. */
101 int must_swap;
102 /* Pointer to additional malloc()ed memory. */
103 void *malloced;
104
105 /* Number of static strings pairs. */
106 nls_uint32 nstrings;
107 /* Pointer to descriptors of original strings in the file. */
108 const struct string_desc *orig_tab;
109 /* Pointer to descriptors of translated strings in the file. */
110 const struct string_desc *trans_tab;
111
112 /* Number of system dependent strings pairs. */
113 nls_uint32 n_sysdep_strings;
114 /* Pointer to descriptors of original sysdep strings. */
115 const struct sysdep_string_desc *orig_sysdep_tab;
116 /* Pointer to descriptors of translated sysdep strings. */
117 const struct sysdep_string_desc *trans_sysdep_tab;
118
119 /* Size of hash table. */
120 nls_uint32 hash_size;
121 /* Pointer to hash table. */
122 const nls_uint32 *hash_tab;
123 /* 1 if the hash table uses a different endianness than this machine. */
124 int must_swap_hash_tab;
125
126 int codeset_cntr;
127#ifdef _LIBC
128 __gconv_t conv;
129#else
130# if HAVE_ICONV
131 iconv_t conv;
132# endif
133#endif
134 char **conv_tab;
135
136 struct expression *plural;
137 unsigned long int nplurals;
138};
139
140/* We want to allocate a string at the end of the struct. But ISO C
141 doesn't allow zero sized arrays. */
142#ifdef __GNUC__
143# define ZERO 0
144#else
145# define ZERO 1
146#endif
147
148/* A set of settings bound to a message domain. Used to store settings
149 from bindtextdomain() and bind_textdomain_codeset(). */
150struct binding
151{
152 struct binding *next;
153 char *dirname;
154 int codeset_cntr; /* Incremented each time codeset changes. */
155 char *codeset;
156 char domainname[ZERO];
157};
158
159/* A counter which is incremented each time some previous translations
160 become invalid.
161 This variable is part of the external ABI of the GNU libintl. */
162extern int _nl_msg_cat_cntr;
163
164#ifndef _LIBC
165const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
166#endif
167
168struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
169 char *__locale,
170 const char *__domainname,
171 struct binding *__domainbinding))
172 internal_function;
173void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
174 struct binding *__domainbinding))
175 internal_function;
176const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
177 struct loaded_domain *__domain,
178 struct binding *__domainbinding))
179 internal_function;
180void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
181 internal_function;
182
183char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
184 struct binding *domainbinding,
185 const char *msgid, size_t *lengthp))
186 internal_function;
187
188#ifdef _LIBC
189extern char *__gettext PARAMS ((const char *__msgid));
190extern char *__dgettext PARAMS ((const char *__domainname,
191 const char *__msgid));
192extern char *__dcgettext PARAMS ((const char *__domainname,
193 const char *__msgid, int __category));
194extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
195 unsigned long int __n));
196extern char *__dngettext PARAMS ((const char *__domainname,
197 const char *__msgid1, const char *__msgid2,
198 unsigned long int n));
199extern char *__dcngettext PARAMS ((const char *__domainname,
200 const char *__msgid1, const char *__msgid2,
201 unsigned long int __n, int __category));
202extern char *__dcigettext PARAMS ((const char *__domainname,
203 const char *__msgid1, const char *__msgid2,
204 int __plural, unsigned long int __n,
205 int __category));
206extern char *__textdomain PARAMS ((const char *__domainname));
207extern char *__bindtextdomain PARAMS ((const char *__domainname,
208 const char *__dirname));
209extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
210 const char *__codeset));
211extern void _nl_finddomain_subfreeres PARAMS ((void)) attribute_hidden;
212extern void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
213 internal_function attribute_hidden;
214#else
215extern char *libintl_gettext PARAMS ((const char *__msgid));
216extern char *libintl_dgettext PARAMS ((const char *__domainname,
217 const char *__msgid));
218extern char *libintl_dcgettext PARAMS ((const char *__domainname,
219 const char *__msgid, int __category));
220extern char *libintl_ngettext PARAMS ((const char *__msgid1,
221 const char *__msgid2,
222 unsigned long int __n));
223extern char *libintl_dngettext PARAMS ((const char *__domainname,
224 const char *__msgid1,
225 const char *__msgid2,
226 unsigned long int __n));
227extern char *libintl_dcngettext PARAMS ((const char *__domainname,
228 const char *__msgid1,
229 const char *__msgid2,
230 unsigned long int __n,
231 int __category));
232extern char *libintl_dcigettext PARAMS ((const char *__domainname,
233 const char *__msgid1,
234 const char *__msgid2,
235 int __plural, unsigned long int __n,
236 int __category));
237extern char *libintl_textdomain PARAMS ((const char *__domainname));
238extern char *libintl_bindtextdomain PARAMS ((const char *__domainname,
239 const char *__dirname));
240extern char *libintl_bind_textdomain_codeset PARAMS ((const char *__domainname,
241 const char *__codeset));
242#endif
243
244/* @@ begin of epilog @@ */
245
246#endif /* gettextP.h */
Note: See TracBrowser for help on using the repository browser.