Git init
[external/popt.git] / intl / gettextP.h
1 /* 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.
4
5    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)
8    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
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14
15    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.  */
19
20 #ifndef _GETTEXTP_H
21 #define _GETTEXTP_H
22
23 #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
33 #include "loadinfo.h"
34
35 #include "gmo.h"                /* Get nls_uint32.  */
36
37 /* @@ end of prolog @@ */
38
39 #ifndef PARAMS
40 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
41 #  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
51 #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
61 #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
70 static inline nls_uint32
71 SWAP (i)
72      nls_uint32 i;
73 {
74   return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
75 }
76 #endif
77
78
79 /* The representation of an opened message catalog.  */
80 struct loaded_domain
81 {
82   const char *data;
83   int use_mmap;
84   size_t mmap_size;
85   int must_swap;
86   nls_uint32 nstrings;
87   struct string_desc *orig_tab;
88   struct string_desc *trans_tab;
89   nls_uint32 hash_size;
90   nls_uint32 *hash_tab;
91   int codeset_cntr;
92 #ifdef _LIBC
93   __gconv_t conv;
94 #else
95 # if HAVE_ICONV
96   iconv_t conv;
97 # endif
98 #endif
99   char **conv_tab;
100
101   struct expression *plural;
102   unsigned long int nplurals;
103 };
104
105 /* We want to allocate a string at the end of the struct.  But ISO C
106    doesn't allow zero sized arrays.  */
107 #ifdef __GNUC__
108 # define ZERO 0
109 #else
110 # define ZERO 1
111 #endif
112
113 /* A set of settings bound to a message domain.  Used to store settings
114    from bindtextdomain() and bind_textdomain_codeset().  */
115 struct binding
116 {
117   struct binding *next;
118   char *dirname;
119   int codeset_cntr;     /* Incremented each time codeset changes.  */
120   char *codeset;
121   char domainname[ZERO];
122 };
123
124 /* A counter which is incremented each time some previous translations
125    become invalid.
126    This variable is part of the external ABI of the GNU libintl.  */
127 extern int _nl_msg_cat_cntr;
128
129 #ifndef _LIBC
130 const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
131 #endif
132
133 struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
134                                                  char *__locale,
135                                                  const char *__domainname,
136                                               struct binding *__domainbinding))
137      internal_function;
138 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
139                               struct binding *__domainbinding))
140      internal_function;
141 void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
142      internal_function;
143 const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
144                                           struct loaded_domain *__domain,
145                                           struct binding *__domainbinding))
146      internal_function;
147 void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
148      internal_function;
149
150 char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
151                             struct binding *domainbinding,
152                             const char *msgid, size_t *lengthp))
153      internal_function;
154
155 #ifdef _LIBC
156 extern char *__gettext PARAMS ((const char *__msgid));
157 extern char *__dgettext PARAMS ((const char *__domainname,
158                                  const char *__msgid));
159 extern char *__dcgettext PARAMS ((const char *__domainname,
160                                   const char *__msgid, int __category));
161 extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
162                                  unsigned long int __n));
163 extern char *__dngettext PARAMS ((const char *__domainname,
164                                   const char *__msgid1, const char *__msgid2,
165                                   unsigned long int n));
166 extern char *__dcngettext PARAMS ((const char *__domainname,
167                                    const char *__msgid1, const char *__msgid2,
168                                    unsigned long int __n, int __category));
169 extern char *__dcigettext PARAMS ((const char *__domainname,
170                                    const char *__msgid1, const char *__msgid2,
171                                    int __plural, unsigned long int __n,
172                                    int __category));
173 extern char *__textdomain PARAMS ((const char *__domainname));
174 extern char *__bindtextdomain PARAMS ((const char *__domainname,
175                                        const char *__dirname));
176 extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
177                                                 const char *__codeset));
178 #else
179 extern char *gettext__ PARAMS ((const char *__msgid));
180 extern char *dgettext__ PARAMS ((const char *__domainname,
181                                  const char *__msgid));
182 extern char *dcgettext__ PARAMS ((const char *__domainname,
183                                   const char *__msgid, int __category));
184 extern char *ngettext__ PARAMS ((const char *__msgid1, const char *__msgid2,
185                                  unsigned long int __n));
186 extern char *dngettext__ PARAMS ((const char *__domainname,
187                                   const char *__msgid1, const char *__msgid2,
188                                   unsigned long int __n));
189 extern char *dcngettext__ PARAMS ((const char *__domainname,
190                                    const char *__msgid1, const char *__msgid2,
191                                    unsigned long int __n, int __category));
192 extern char *dcigettext__ PARAMS ((const char *__domainname,
193                                    const char *__msgid1, const char *__msgid2,
194                                    int __plural, unsigned long int __n,
195                                    int __category));
196 extern char *textdomain__ PARAMS ((const char *__domainname));
197 extern char *bindtextdomain__ PARAMS ((const char *__domainname,
198                                        const char *__dirname));
199 extern char *bind_textdomain_codeset__ PARAMS ((const char *__domainname,
200                                                 const char *__codeset));
201 #endif
202
203 /* @@ begin of epilog @@ */
204
205 #endif /* gettextP.h  */