1*440a403fSchristos /* Header describing internals of libintl library.
2*440a403fSchristos    Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
3*440a403fSchristos    Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
4*440a403fSchristos 
5*440a403fSchristos    This program is free software; you can redistribute it and/or modify it
6*440a403fSchristos    under the terms of the GNU Library General Public License as published
7*440a403fSchristos    by the Free Software Foundation; either version 2, or (at your option)
8*440a403fSchristos    any later version.
9*440a403fSchristos 
10*440a403fSchristos    This program is distributed in the hope that it will be useful,
11*440a403fSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
12*440a403fSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13*440a403fSchristos    Library General Public License for more details.
14*440a403fSchristos 
15*440a403fSchristos    You should have received a copy of the GNU Library General Public
16*440a403fSchristos    License along with this program; if not, write to the Free Software
17*440a403fSchristos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
18*440a403fSchristos    USA.  */
19*440a403fSchristos 
20*440a403fSchristos #ifndef _GETTEXTP_H
21*440a403fSchristos #define _GETTEXTP_H
22*440a403fSchristos 
23*440a403fSchristos #include <stddef.h>		/* Get size_t.  */
24*440a403fSchristos 
25*440a403fSchristos #ifdef _LIBC
26*440a403fSchristos # include "../iconv/gconv_int.h"
27*440a403fSchristos #else
28*440a403fSchristos # if HAVE_ICONV
29*440a403fSchristos #  include <iconv.h>
30*440a403fSchristos # endif
31*440a403fSchristos #endif
32*440a403fSchristos 
33*440a403fSchristos #include "loadinfo.h"
34*440a403fSchristos 
35*440a403fSchristos #include "gmo.h"		/* Get nls_uint32.  */
36*440a403fSchristos 
37*440a403fSchristos /* @@ end of prolog @@ */
38*440a403fSchristos 
39*440a403fSchristos #ifndef PARAMS
40*440a403fSchristos # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
41*440a403fSchristos #  define PARAMS(args) args
42*440a403fSchristos # else
43*440a403fSchristos #  define PARAMS(args) ()
44*440a403fSchristos # endif
45*440a403fSchristos #endif
46*440a403fSchristos 
47*440a403fSchristos #ifndef internal_function
48*440a403fSchristos # define internal_function
49*440a403fSchristos #endif
50*440a403fSchristos 
51*440a403fSchristos #ifndef attribute_hidden
52*440a403fSchristos # define attribute_hidden
53*440a403fSchristos #endif
54*440a403fSchristos 
55*440a403fSchristos /* Tell the compiler when a conditional or integer expression is
56*440a403fSchristos    almost always true or almost always false.  */
57*440a403fSchristos #ifndef HAVE_BUILTIN_EXPECT
58*440a403fSchristos # define __builtin_expect(expr, val) (expr)
59*440a403fSchristos #endif
60*440a403fSchristos 
61*440a403fSchristos #ifndef W
62*440a403fSchristos # define W(flag, data) ((flag) ? SWAP (data) : (data))
63*440a403fSchristos #endif
64*440a403fSchristos 
65*440a403fSchristos 
66*440a403fSchristos #ifdef _LIBC
67*440a403fSchristos # include <byteswap.h>
68*440a403fSchristos # define SWAP(i) bswap_32 (i)
69*440a403fSchristos #else
70*440a403fSchristos static inline nls_uint32
SWAP(i)71*440a403fSchristos SWAP (i)
72*440a403fSchristos      nls_uint32 i;
73*440a403fSchristos {
74*440a403fSchristos   return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
75*440a403fSchristos }
76*440a403fSchristos #endif
77*440a403fSchristos 
78*440a403fSchristos 
79*440a403fSchristos /* In-memory representation of system dependent string.  */
80*440a403fSchristos struct sysdep_string_desc
81*440a403fSchristos {
82*440a403fSchristos   /* Length of addressed string, including the trailing NUL.  */
83*440a403fSchristos   size_t length;
84*440a403fSchristos   /* Pointer to addressed string.  */
85*440a403fSchristos   const char *pointer;
86*440a403fSchristos };
87*440a403fSchristos 
88*440a403fSchristos /* The representation of an opened message catalog.  */
89*440a403fSchristos struct loaded_domain
90*440a403fSchristos {
91*440a403fSchristos   /* Pointer to memory containing the .mo file.  */
92*440a403fSchristos   const char *data;
93*440a403fSchristos   /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed.  */
94*440a403fSchristos   int use_mmap;
95*440a403fSchristos   /* Size of mmap()ed memory.  */
96*440a403fSchristos   size_t mmap_size;
97*440a403fSchristos   /* 1 if the .mo file uses a different endianness than this machine.  */
98*440a403fSchristos   int must_swap;
99*440a403fSchristos   /* Pointer to additional malloc()ed memory.  */
100*440a403fSchristos   void *malloced;
101*440a403fSchristos 
102*440a403fSchristos   /* Number of static strings pairs.  */
103*440a403fSchristos   nls_uint32 nstrings;
104*440a403fSchristos   /* Pointer to descriptors of original strings in the file.  */
105*440a403fSchristos   const struct string_desc *orig_tab;
106*440a403fSchristos   /* Pointer to descriptors of translated strings in the file.  */
107*440a403fSchristos   const struct string_desc *trans_tab;
108*440a403fSchristos 
109*440a403fSchristos   /* Number of system dependent strings pairs.  */
110*440a403fSchristos   nls_uint32 n_sysdep_strings;
111*440a403fSchristos   /* Pointer to descriptors of original sysdep strings.  */
112*440a403fSchristos   const struct sysdep_string_desc *orig_sysdep_tab;
113*440a403fSchristos   /* Pointer to descriptors of translated sysdep strings.  */
114*440a403fSchristos   const struct sysdep_string_desc *trans_sysdep_tab;
115*440a403fSchristos 
116*440a403fSchristos   /* Size of hash table.  */
117*440a403fSchristos   nls_uint32 hash_size;
118*440a403fSchristos   /* Pointer to hash table.  */
119*440a403fSchristos   const nls_uint32 *hash_tab;
120*440a403fSchristos   /* 1 if the hash table uses a different endianness than this machine.  */
121*440a403fSchristos   int must_swap_hash_tab;
122*440a403fSchristos 
123*440a403fSchristos   int codeset_cntr;
124*440a403fSchristos #ifdef _LIBC
125*440a403fSchristos   __gconv_t conv;
126*440a403fSchristos #else
127*440a403fSchristos # if HAVE_ICONV
128*440a403fSchristos   iconv_t conv;
129*440a403fSchristos # endif
130*440a403fSchristos #endif
131*440a403fSchristos   char **conv_tab;
132*440a403fSchristos 
133*440a403fSchristos   struct expression *plural;
134*440a403fSchristos   unsigned long int nplurals;
135*440a403fSchristos };
136*440a403fSchristos 
137*440a403fSchristos /* We want to allocate a string at the end of the struct.  But ISO C
138*440a403fSchristos    doesn't allow zero sized arrays.  */
139*440a403fSchristos #ifdef __GNUC__
140*440a403fSchristos # define ZERO 0
141*440a403fSchristos #else
142*440a403fSchristos # define ZERO 1
143*440a403fSchristos #endif
144*440a403fSchristos 
145*440a403fSchristos /* A set of settings bound to a message domain.  Used to store settings
146*440a403fSchristos    from bindtextdomain() and bind_textdomain_codeset().  */
147*440a403fSchristos struct binding
148*440a403fSchristos {
149*440a403fSchristos   struct binding *next;
150*440a403fSchristos   char *dirname;
151*440a403fSchristos   int codeset_cntr;	/* Incremented each time codeset changes.  */
152*440a403fSchristos   char *codeset;
153*440a403fSchristos   char domainname[ZERO];
154*440a403fSchristos };
155*440a403fSchristos 
156*440a403fSchristos /* A counter which is incremented each time some previous translations
157*440a403fSchristos    become invalid.
158*440a403fSchristos    This variable is part of the external ABI of the GNU libintl.  */
159*440a403fSchristos extern int _nl_msg_cat_cntr;
160*440a403fSchristos 
161*440a403fSchristos #ifndef _LIBC
162*440a403fSchristos const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
163*440a403fSchristos #endif
164*440a403fSchristos 
165*440a403fSchristos struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
166*440a403fSchristos 						 char *__locale,
167*440a403fSchristos 						 const char *__domainname,
168*440a403fSchristos 					      struct binding *__domainbinding))
169*440a403fSchristos      internal_function;
170*440a403fSchristos void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
171*440a403fSchristos 			      struct binding *__domainbinding))
172*440a403fSchristos      internal_function;
173*440a403fSchristos void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
174*440a403fSchristos      internal_function;
175*440a403fSchristos const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
176*440a403fSchristos 					  struct loaded_domain *__domain,
177*440a403fSchristos 					  struct binding *__domainbinding))
178*440a403fSchristos      internal_function;
179*440a403fSchristos void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
180*440a403fSchristos      internal_function;
181*440a403fSchristos 
182*440a403fSchristos char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
183*440a403fSchristos 			    struct binding *domainbinding,
184*440a403fSchristos 			    const char *msgid, size_t *lengthp))
185*440a403fSchristos      internal_function;
186*440a403fSchristos 
187*440a403fSchristos #ifdef _LIBC
188*440a403fSchristos extern char *__gettext PARAMS ((const char *__msgid));
189*440a403fSchristos extern char *__dgettext PARAMS ((const char *__domainname,
190*440a403fSchristos 				 const char *__msgid));
191*440a403fSchristos extern char *__dcgettext PARAMS ((const char *__domainname,
192*440a403fSchristos 				  const char *__msgid, int __category));
193*440a403fSchristos extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
194*440a403fSchristos 				 unsigned long int __n));
195*440a403fSchristos extern char *__dngettext PARAMS ((const char *__domainname,
196*440a403fSchristos 				  const char *__msgid1, const char *__msgid2,
197*440a403fSchristos 				  unsigned long int n));
198*440a403fSchristos extern char *__dcngettext PARAMS ((const char *__domainname,
199*440a403fSchristos 				   const char *__msgid1, const char *__msgid2,
200*440a403fSchristos 				   unsigned long int __n, int __category));
201*440a403fSchristos extern char *__dcigettext PARAMS ((const char *__domainname,
202*440a403fSchristos 				   const char *__msgid1, const char *__msgid2,
203*440a403fSchristos 				   int __plural, unsigned long int __n,
204*440a403fSchristos 				   int __category));
205*440a403fSchristos extern char *__textdomain PARAMS ((const char *__domainname));
206*440a403fSchristos extern char *__bindtextdomain PARAMS ((const char *__domainname,
207*440a403fSchristos 				       const char *__dirname));
208*440a403fSchristos extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
209*440a403fSchristos 						const char *__codeset));
210*440a403fSchristos #else
211*440a403fSchristos /* Declare the exported libintl_* functions, in a way that allows us to
212*440a403fSchristos    call them under their real name.  */
213*440a403fSchristos # define _INTL_REDIRECT_MACROS
214*440a403fSchristos # include "libintl.h"
215*440a403fSchristos extern char *libintl_dcigettext PARAMS ((const char *__domainname,
216*440a403fSchristos 					 const char *__msgid1,
217*440a403fSchristos 					 const char *__msgid2,
218*440a403fSchristos 					 int __plural, unsigned long int __n,
219*440a403fSchristos 					 int __category));
220*440a403fSchristos #endif
221*440a403fSchristos 
222*440a403fSchristos /* @@ begin of epilog @@ */
223*440a403fSchristos 
224*440a403fSchristos #endif /* gettextP.h  */
225