1/* Header describing internals of libintl library. 2 Copyright (C) 1995-1999, 2000-2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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/* Handle multi-threaded applications. */ 34#ifdef _LIBC 35# include <bits/libc-lock.h> 36# define gl_rwlock_define __libc_rwlock_define 37#else 38# include "lock.h" 39#endif 40 41#ifdef _LIBC 42extern char *__gettext (const char *__msgid); 43extern char *__dgettext (const char *__domainname, const char *__msgid); 44extern char *__dcgettext (const char *__domainname, const char *__msgid, 45 int __category); 46extern char *__ngettext (const char *__msgid1, const char *__msgid2, 47 unsigned long int __n); 48extern char *__dngettext (const char *__domainname, 49 const char *__msgid1, const char *__msgid2, 50 unsigned long int n); 51extern char *__dcngettext (const char *__domainname, 52 const char *__msgid1, const char *__msgid2, 53 unsigned long int __n, int __category); 54extern char *__dcigettext (const char *__domainname, 55 const char *__msgid1, const char *__msgid2, 56 int __plural, unsigned long int __n, 57 int __category); 58extern char *__textdomain (const char *__domainname); 59extern char *__bindtextdomain (const char *__domainname, 60 const char *__dirname); 61extern char *__bind_textdomain_codeset (const char *__domainname, 62 const char *__codeset); 63extern void _nl_finddomain_subfreeres (void) attribute_hidden; 64extern void _nl_unload_domain (struct loaded_domain *__domain) 65 internal_function attribute_hidden; 66#else 67/* Declare the exported libintl_* functions, in a way that allows us to 68 call them under their real name. */ 69# undef _INTL_REDIRECT_INLINE 70# undef _INTL_REDIRECT_MACROS 71# define _INTL_REDIRECT_MACROS 72# include "libgnuintl.h" 73# ifdef IN_LIBGLOCALE 74extern char *gl_dcigettext (const char *__domainname, 75 const char *__msgid1, const char *__msgid2, 76 int __plural, unsigned long int __n, 77 int __category, 78 const char *__localename, const char *__encoding); 79# else 80extern char *libintl_dcigettext (const char *__domainname, 81 const char *__msgid1, const char *__msgid2, 82 int __plural, unsigned long int __n, 83 int __category); 84# endif 85#endif 86 87#include "loadinfo.h" 88 89#include "gmo.h" /* Get nls_uint32. */ 90 91/* @@ end of prolog @@ */ 92 93#ifndef internal_function 94# define internal_function 95#endif 96 97#ifndef attribute_hidden 98# define attribute_hidden 99#endif 100 101/* Tell the compiler when a conditional or integer expression is 102 almost always true or almost always false. */ 103#ifndef HAVE_BUILTIN_EXPECT 104# define __builtin_expect(expr, val) (expr) 105#endif 106 107#ifndef W 108# define W(flag, data) ((flag) ? SWAP (data) : (data)) 109#endif 110 111 112#ifdef _LIBC 113# include <byteswap.h> 114# define SWAP(i) bswap_32 (i) 115#else 116static inline nls_uint32 117# ifdef __cplusplus 118SWAP (nls_uint32 i) 119# else 120SWAP (i) 121 nls_uint32 i; 122# endif 123{ 124 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24); 125} 126#endif 127 128 129/* In-memory representation of system dependent string. */ 130struct sysdep_string_desc 131{ 132 /* Length of addressed string, including the trailing NUL. */ 133 size_t length; 134 /* Pointer to addressed string. */ 135 const char *pointer; 136}; 137 138/* Cache of translated strings after charset conversion. 139 Note: The strings are converted to the target encoding only on an as-needed 140 basis. */ 141struct converted_domain 142{ 143 /* The target encoding name. */ 144 const char *encoding; 145 /* The descriptor for conversion from the message catalog's encoding to 146 this target encoding. */ 147#ifdef _LIBC 148 __gconv_t conv; 149#else 150# if HAVE_ICONV 151 iconv_t conv; 152# endif 153#endif 154 /* The table of translated strings after charset conversion. */ 155 char **conv_tab; 156}; 157 158/* The representation of an opened message catalog. */ 159struct loaded_domain 160{ 161 /* Pointer to memory containing the .mo file. */ 162 const char *data; 163 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */ 164 int use_mmap; 165 /* Size of mmap()ed memory. */ 166 size_t mmap_size; 167 /* 1 if the .mo file uses a different endianness than this machine. */ 168 int must_swap; 169 /* Pointer to additional malloc()ed memory. */ 170 void *malloced; 171 172 /* Number of static strings pairs. */ 173 nls_uint32 nstrings; 174 /* Pointer to descriptors of original strings in the file. */ 175 const struct string_desc *orig_tab; 176 /* Pointer to descriptors of translated strings in the file. */ 177 const struct string_desc *trans_tab; 178 179 /* Number of system dependent strings pairs. */ 180 nls_uint32 n_sysdep_strings; 181 /* Pointer to descriptors of original sysdep strings. */ 182 const struct sysdep_string_desc *orig_sysdep_tab; 183 /* Pointer to descriptors of translated sysdep strings. */ 184 const struct sysdep_string_desc *trans_sysdep_tab; 185 186 /* Size of hash table. */ 187 nls_uint32 hash_size; 188 /* Pointer to hash table. */ 189 const nls_uint32 *hash_tab; 190 /* 1 if the hash table uses a different endianness than this machine. */ 191 int must_swap_hash_tab; 192 193 /* Cache of charset conversions of the translated strings. */ 194 struct converted_domain *conversions; 195 size_t nconversions; 196 gl_rwlock_define (, conversions_lock) 197 198 const struct expression *plural; 199 unsigned long int nplurals; 200}; 201 202/* We want to allocate a string at the end of the struct. But ISO C 203 doesn't allow zero sized arrays. */ 204#ifdef __GNUC__ 205# define ZERO 0 206#else 207# define ZERO 1 208#endif 209 210/* A set of settings bound to a message domain. Used to store settings 211 from bindtextdomain() and bind_textdomain_codeset(). */ 212struct binding 213{ 214 struct binding *next; 215 char *dirname; 216 char *codeset; 217 char domainname[ZERO]; 218}; 219 220/* A counter which is incremented each time some previous translations 221 become invalid. 222 This variable is part of the external ABI of the GNU libintl. */ 223#ifdef IN_LIBGLOCALE 224# include <glocale/config.h> 225extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr; 226#else 227extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr; 228#endif 229 230#ifndef _LIBC 231extern const char *_nl_language_preferences_default (void); 232# define gl_locale_name_canonicalize _nl_locale_name_canonicalize 233extern void _nl_locale_name_canonicalize (char *name); 234# define gl_locale_name_posix _nl_locale_name_posix 235extern const char *_nl_locale_name_posix (int category, 236 const char *categoryname); 237# define gl_locale_name_default _nl_locale_name_default 238extern const char *_nl_locale_name_default (void); 239# define gl_locale_name _nl_locale_name 240extern const char *_nl_locale_name (int category, const char *categoryname); 241#endif 242 243struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale, 244 const char *__domainname, 245 struct binding *__domainbinding) 246 internal_function; 247void _nl_load_domain (struct loaded_l10nfile *__domain, 248 struct binding *__domainbinding) 249 internal_function; 250 251#ifdef IN_LIBGLOCALE 252char *_nl_find_msg (struct loaded_l10nfile *domain_file, 253 struct binding *domainbinding, const char *encoding, 254 const char *msgid, 255 size_t *lengthp) 256 internal_function; 257#else 258char *_nl_find_msg (struct loaded_l10nfile *domain_file, 259 struct binding *domainbinding, const char *msgid, 260 int convert, size_t *lengthp) 261 internal_function; 262#endif 263 264/* The internal variables in the standalone libintl.a must have different 265 names than the internal variables in GNU libc, otherwise programs 266 using libintl.a cannot be linked statically. */ 267#if !defined _LIBC 268# define _nl_default_dirname libintl_nl_default_dirname 269# define _nl_domain_bindings libintl_nl_domain_bindings 270#endif 271 272/* Contains the default location of the message catalogs. */ 273extern const char _nl_default_dirname[]; 274#ifdef _LIBC 275libc_hidden_proto (_nl_default_dirname) 276#endif 277 278/* List with bindings of specific domains. */ 279extern struct binding *_nl_domain_bindings; 280 281/* The internal variables in the standalone libintl.a must have different 282 names than the internal variables in GNU libc, otherwise programs 283 using libintl.a cannot be linked statically. */ 284#if !defined _LIBC 285# define _nl_default_default_domain libintl_nl_default_default_domain 286# define _nl_current_default_domain libintl_nl_current_default_domain 287#endif 288 289/* Name of the default text domain. */ 290extern const char _nl_default_default_domain[] attribute_hidden; 291 292/* Default text domain in which entries for gettext(3) are to be found. */ 293extern const char *_nl_current_default_domain attribute_hidden; 294 295/* @@ begin of epilog @@ */ 296 297#endif /* gettextP.h */ 298