Back to index

courier  0.68.2
gettextP.h
Go to the documentation of this file.
00001 /* Header describing internals of libintl library.
00002    Copyright (C) 1995-1999, 2000-2007, 2009-2010 Free Software Foundation, Inc.
00003    Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
00004 
00005    This program is free software; you can redistribute it and/or modify it
00006    under the terms of the GNU Library General Public License as published
00007    by the Free Software Foundation; either version 2, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public
00016    License along with this program; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00018    USA.  */
00019 
00020 #ifndef _GETTEXTP_H
00021 #define _GETTEXTP_H
00022 
00023 #include <stddef.h>         /* Get size_t.  */
00024 
00025 #ifdef _LIBC
00026 # include "../iconv/gconv_int.h"
00027 #else
00028 # if HAVE_ICONV
00029 #  include <iconv.h>
00030 # endif
00031 #endif
00032 
00033 /* Handle multi-threaded applications.  */
00034 #ifdef _LIBC
00035 # include <bits/libc-lock.h>
00036 # define gl_rwlock_define __libc_rwlock_define
00037 #else
00038 # include "lock.h"
00039 #endif
00040 
00041 #ifdef _LIBC
00042 extern char *__gettext (const char *__msgid);
00043 extern char *__dgettext (const char *__domainname, const char *__msgid);
00044 extern char *__dcgettext (const char *__domainname, const char *__msgid,
00045                        int __category);
00046 extern char *__ngettext (const char *__msgid1, const char *__msgid2,
00047                       unsigned long int __n);
00048 extern char *__dngettext (const char *__domainname,
00049                        const char *__msgid1, const char *__msgid2,
00050                        unsigned long int n);
00051 extern char *__dcngettext (const char *__domainname,
00052                         const char *__msgid1, const char *__msgid2,
00053                         unsigned long int __n, int __category);
00054 extern char *__dcigettext (const char *__domainname,
00055                         const char *__msgid1, const char *__msgid2,
00056                         int __plural, unsigned long int __n,
00057                         int __category);
00058 extern char *__textdomain (const char *__domainname);
00059 extern char *__bindtextdomain (const char *__domainname,
00060                             const char *__dirname);
00061 extern char *__bind_textdomain_codeset (const char *__domainname,
00062                                    const char *__codeset);
00063 extern void _nl_finddomain_subfreeres (void) attribute_hidden;
00064 extern void _nl_unload_domain (struct loaded_domain *__domain)
00065      internal_function attribute_hidden;
00066 #else
00067 /* Declare the exported libintl_* functions, in a way that allows us to
00068    call them under their real name.  */
00069 # undef _INTL_REDIRECT_INLINE
00070 # undef _INTL_REDIRECT_MACROS
00071 # define _INTL_REDIRECT_MACROS
00072 # include "libgnuintl.h"
00073 # ifdef IN_LIBGLOCALE
00074 extern char *gl_dcigettext (const char *__domainname,
00075                          const char *__msgid1, const char *__msgid2,
00076                          int __plural, unsigned long int __n,
00077                          int __category,
00078                          const char *__localename, const char *__encoding);
00079 # else
00080 extern char *libintl_dcigettext (const char *__domainname,
00081                              const char *__msgid1, const char *__msgid2,
00082                              int __plural, unsigned long int __n,
00083                              int __category);
00084 # endif
00085 #endif
00086 
00087 #include "loadinfo.h"
00088 
00089 #include "gmo.h"            /* Get nls_uint32.  */
00090 
00091 /* @@ end of prolog @@ */
00092 
00093 #ifndef internal_function
00094 # define internal_function
00095 #endif
00096 
00097 #ifndef attribute_hidden
00098 # define attribute_hidden
00099 #endif
00100 
00101 /* Tell the compiler when a conditional or integer expression is
00102    almost always true or almost always false.  */
00103 #ifndef HAVE_BUILTIN_EXPECT
00104 # define __builtin_expect(expr, val) (expr)
00105 #endif
00106 
00107 #ifndef W
00108 # define W(flag, data) ((flag) ? SWAP (data) : (data))
00109 #endif
00110 
00111 
00112 #ifdef _LIBC
00113 # include <byteswap.h>
00114 # define SWAP(i) bswap_32 (i)
00115 #else
00116 static inline nls_uint32
00117 # ifdef __cplusplus
00118 SWAP (nls_uint32 i)
00119 # else
00120 SWAP (i)
00121      nls_uint32 i;
00122 # endif
00123 {
00124   return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
00125 }
00126 #endif
00127 
00128 
00129 /* In-memory representation of system dependent string.  */
00130 struct sysdep_string_desc
00131 {
00132   /* Length of addressed string, including the trailing NUL.  */
00133   size_t length;
00134   /* Pointer to addressed string.  */
00135   const char *pointer;
00136 };
00137 
00138 /* Cache of translated strings after charset conversion.
00139    Note: The strings are converted to the target encoding only on an as-needed
00140    basis.  */
00141 struct converted_domain
00142 {
00143   /* The target encoding name.  */
00144   const char *encoding;
00145   /* The descriptor for conversion from the message catalog's encoding to
00146      this target encoding.  */
00147 #ifdef _LIBC
00148   __gconv_t conv;
00149 #else
00150 # if HAVE_ICONV
00151   iconv_t conv;
00152 # endif
00153 #endif
00154   /* The table of translated strings after charset conversion.  */
00155   char **conv_tab;
00156 };
00157 
00158 /* The representation of an opened message catalog.  */
00159 struct loaded_domain
00160 {
00161   /* Pointer to memory containing the .mo file.  */
00162   const char *data;
00163   /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed.  */
00164   int use_mmap;
00165   /* Size of mmap()ed memory.  */
00166   size_t mmap_size;
00167   /* 1 if the .mo file uses a different endianness than this machine.  */
00168   int must_swap;
00169   /* Pointer to additional malloc()ed memory.  */
00170   void *malloced;
00171 
00172   /* Number of static strings pairs.  */
00173   nls_uint32 nstrings;
00174   /* Pointer to descriptors of original strings in the file.  */
00175   const struct string_desc *orig_tab;
00176   /* Pointer to descriptors of translated strings in the file.  */
00177   const struct string_desc *trans_tab;
00178 
00179   /* Number of system dependent strings pairs.  */
00180   nls_uint32 n_sysdep_strings;
00181   /* Pointer to descriptors of original sysdep strings.  */
00182   const struct sysdep_string_desc *orig_sysdep_tab;
00183   /* Pointer to descriptors of translated sysdep strings.  */
00184   const struct sysdep_string_desc *trans_sysdep_tab;
00185 
00186   /* Size of hash table.  */
00187   nls_uint32 hash_size;
00188   /* Pointer to hash table.  */
00189   const nls_uint32 *hash_tab;
00190   /* 1 if the hash table uses a different endianness than this machine.  */
00191   int must_swap_hash_tab;
00192 
00193   /* Cache of charset conversions of the translated strings.  */
00194   struct converted_domain *conversions;
00195   size_t nconversions;
00196   gl_rwlock_define (, conversions_lock)
00197 
00198   const struct expression *plural;
00199   unsigned long int nplurals;
00200 };
00201 
00202 /* We want to allocate a string at the end of the struct.  But ISO C
00203    doesn't allow zero sized arrays.  */
00204 #ifdef __GNUC__
00205 # define ZERO 0
00206 #else
00207 # define ZERO 1
00208 #endif
00209 
00210 /* A set of settings bound to a message domain.  Used to store settings
00211    from bindtextdomain() and bind_textdomain_codeset().  */
00212 struct binding
00213 {
00214   struct binding *next;
00215   char *dirname;
00216   char *codeset;
00217   char domainname[ZERO];
00218 };
00219 
00220 /* A counter which is incremented each time some previous translations
00221    become invalid.
00222    This variable is part of the external ABI of the GNU libintl.  */
00223 #ifdef IN_LIBGLOCALE
00224 # include <glocale/config.h>
00225 extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr;
00226 #else
00227 extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr;
00228 #endif
00229 
00230 #ifndef _LIBC
00231 extern const char *_nl_language_preferences_default (void);
00232 # define gl_locale_name_canonicalize _nl_locale_name_canonicalize
00233 extern void _nl_locale_name_canonicalize (char *name);
00234 # define gl_locale_name_from_win32_LANGID _nl_locale_name_from_win32_LANGID
00235 /* extern const char *_nl_locale_name_from_win32_LANGID (LANGID langid); */
00236 # define gl_locale_name_from_win32_LCID _nl_locale_name_from_win32_LCID
00237 /* extern const char *_nl_locale_name_from_win32_LCID (LCID lcid); */
00238 # define gl_locale_name_thread_unsafe _nl_locale_name_thread_unsafe
00239 extern const char *_nl_locale_name_thread_unsafe (int category,
00240                                             const char *categoryname);
00241 # define gl_locale_name_thread _nl_locale_name_thread
00242 /* extern const char *_nl_locale_name_thread (int category,
00243                                          const char *categoryname); */
00244 # define gl_locale_name_posix _nl_locale_name_posix
00245 extern const char *_nl_locale_name_posix (int category,
00246                                      const char *categoryname);
00247 # define gl_locale_name_environ _nl_locale_name_environ
00248 extern const char *_nl_locale_name_environ (int category,
00249                                        const char *categoryname);
00250 # define gl_locale_name_default _nl_locale_name_default
00251 extern const char *_nl_locale_name_default (void);
00252 # define gl_locale_name _nl_locale_name
00253 /* extern const char *_nl_locale_name (int category,
00254                                    const char *categoryname); */
00255 #endif
00256 
00257 struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale,
00258                                     const char *__domainname,
00259                                     struct binding *__domainbinding)
00260      internal_function;
00261 void _nl_load_domain (struct loaded_l10nfile *__domain,
00262                     struct binding *__domainbinding)
00263      internal_function;
00264 
00265 #ifdef IN_LIBGLOCALE
00266 char *_nl_find_msg (struct loaded_l10nfile *domain_file,
00267                   struct binding *domainbinding, const char *encoding,
00268                   const char *msgid,
00269                   size_t *lengthp)
00270      internal_function;
00271 #else
00272 char *_nl_find_msg (struct loaded_l10nfile *domain_file,
00273                   struct binding *domainbinding, const char *msgid,
00274                   int convert, size_t *lengthp)
00275      internal_function;
00276 #endif
00277 
00278 /* The internal variables in the standalone libintl.a must have different
00279    names than the internal variables in GNU libc, otherwise programs
00280    using libintl.a cannot be linked statically.  */
00281 #if !defined _LIBC
00282 # define _nl_default_dirname libintl_nl_default_dirname
00283 # define _nl_domain_bindings libintl_nl_domain_bindings
00284 #endif
00285 
00286 /* Contains the default location of the message catalogs.  */
00287 extern const char _nl_default_dirname[];
00288 #ifdef _LIBC
00289 libc_hidden_proto (_nl_default_dirname)
00290 #endif
00291 
00292 /* List with bindings of specific domains.  */
00293 extern struct binding *_nl_domain_bindings;
00294 
00295 /* The internal variables in the standalone libintl.a must have different
00296    names than the internal variables in GNU libc, otherwise programs
00297    using libintl.a cannot be linked statically.  */
00298 #if !defined _LIBC
00299 # define _nl_default_default_domain libintl_nl_default_default_domain
00300 # define _nl_current_default_domain libintl_nl_current_default_domain
00301 #endif
00302 
00303 /* Name of the default text domain.  */
00304 extern const char _nl_default_default_domain[] attribute_hidden;
00305 
00306 /* Default text domain in which entries for gettext(3) are to be found.  */
00307 extern const char *_nl_current_default_domain attribute_hidden;
00308 
00309 /* @@ begin of epilog @@ */
00310 
00311 #endif /* gettextP.h  */