Back to index

cell-binutils  2.17cvs20070401
gettextP.h
Go to the documentation of this file.
00001 /* Header describing internals of libintl library.
00002    Copyright (C) 1995-1999, 2000-2003 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 #include "loadinfo.h"
00034 
00035 #include "gmo.h"            /* Get nls_uint32.  */
00036 
00037 /* @@ end of prolog @@ */
00038 
00039 #ifndef PARAMS
00040 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
00041 #  define PARAMS(args) args
00042 # else
00043 #  define PARAMS(args) ()
00044 # endif
00045 #endif
00046 
00047 #ifndef internal_function
00048 # define internal_function
00049 #endif
00050 
00051 #ifndef attribute_hidden
00052 # define attribute_hidden
00053 #endif
00054 
00055 /* Tell the compiler when a conditional or integer expression is
00056    almost always true or almost always false.  */
00057 #ifndef HAVE_BUILTIN_EXPECT
00058 # define __builtin_expect(expr, val) (expr)
00059 #endif
00060 
00061 #ifndef W
00062 # define W(flag, data) ((flag) ? SWAP (data) : (data))
00063 #endif
00064 
00065 
00066 #ifdef _LIBC
00067 # include <byteswap.h>
00068 # define SWAP(i) bswap_32 (i)
00069 #else
00070 static inline nls_uint32
00071 SWAP (i)
00072      nls_uint32 i;
00073 {
00074   return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
00075 }
00076 #endif
00077 
00078 
00079 /* In-memory representation of system dependent string.  */
00080 struct sysdep_string_desc
00081 {
00082   /* Length of addressed string, including the trailing NUL.  */
00083   size_t length;
00084   /* Pointer to addressed string.  */
00085   const char *pointer;
00086 };
00087 
00088 /* The representation of an opened message catalog.  */
00089 struct loaded_domain
00090 {
00091   /* Pointer to memory containing the .mo file.  */
00092   const char *data;
00093   /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed.  */
00094   int use_mmap;
00095   /* Size of mmap()ed memory.  */
00096   size_t mmap_size;
00097   /* 1 if the .mo file uses a different endianness than this machine.  */
00098   int must_swap;
00099   /* Pointer to additional malloc()ed memory.  */
00100   void *malloced;
00101 
00102   /* Number of static strings pairs.  */
00103   nls_uint32 nstrings;
00104   /* Pointer to descriptors of original strings in the file.  */
00105   const struct string_desc *orig_tab;
00106   /* Pointer to descriptors of translated strings in the file.  */
00107   const struct string_desc *trans_tab;
00108 
00109   /* Number of system dependent strings pairs.  */
00110   nls_uint32 n_sysdep_strings;
00111   /* Pointer to descriptors of original sysdep strings.  */
00112   const struct sysdep_string_desc *orig_sysdep_tab;
00113   /* Pointer to descriptors of translated sysdep strings.  */
00114   const struct sysdep_string_desc *trans_sysdep_tab;
00115 
00116   /* Size of hash table.  */
00117   nls_uint32 hash_size;
00118   /* Pointer to hash table.  */
00119   const nls_uint32 *hash_tab;
00120   /* 1 if the hash table uses a different endianness than this machine.  */
00121   int must_swap_hash_tab;
00122 
00123   int codeset_cntr;
00124 #ifdef _LIBC
00125   __gconv_t conv;
00126 #else
00127 # if HAVE_ICONV
00128   iconv_t conv;
00129 # endif
00130 #endif
00131   char **conv_tab;
00132 
00133   struct expression *plural;
00134   unsigned long int nplurals;
00135 };
00136 
00137 /* We want to allocate a string at the end of the struct.  But ISO C
00138    doesn't allow zero sized arrays.  */
00139 #ifdef __GNUC__
00140 # define ZERO 0
00141 #else
00142 # define ZERO 1
00143 #endif
00144 
00145 /* A set of settings bound to a message domain.  Used to store settings
00146    from bindtextdomain() and bind_textdomain_codeset().  */
00147 struct binding
00148 {
00149   struct binding *next;
00150   char *dirname;
00151   int codeset_cntr;  /* Incremented each time codeset changes.  */
00152   char *codeset;
00153   char domainname[ZERO];
00154 };
00155 
00156 /* A counter which is incremented each time some previous translations
00157    become invalid.
00158    This variable is part of the external ABI of the GNU libintl.  */
00159 extern int _nl_msg_cat_cntr;
00160 
00161 #ifndef _LIBC
00162 const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
00163 #endif
00164 
00165 struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
00166                                            char *__locale,
00167                                            const char *__domainname,
00168                                          struct binding *__domainbinding))
00169      internal_function;
00170 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
00171                            struct binding *__domainbinding))
00172      internal_function;
00173 void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
00174      internal_function;
00175 const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
00176                                      struct loaded_domain *__domain,
00177                                      struct binding *__domainbinding))
00178      internal_function;
00179 void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
00180      internal_function;
00181 
00182 char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
00183                          struct binding *domainbinding,
00184                          const char *msgid, size_t *lengthp))
00185      internal_function;
00186 
00187 #ifdef _LIBC
00188 extern char *__gettext PARAMS ((const char *__msgid));
00189 extern char *__dgettext PARAMS ((const char *__domainname,
00190                              const char *__msgid));
00191 extern char *__dcgettext PARAMS ((const char *__domainname,
00192                               const char *__msgid, int __category));
00193 extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
00194                              unsigned long int __n));
00195 extern char *__dngettext PARAMS ((const char *__domainname,
00196                               const char *__msgid1, const char *__msgid2,
00197                               unsigned long int n));
00198 extern char *__dcngettext PARAMS ((const char *__domainname,
00199                                const char *__msgid1, const char *__msgid2,
00200                                unsigned long int __n, int __category));
00201 extern char *__dcigettext PARAMS ((const char *__domainname,
00202                                const char *__msgid1, const char *__msgid2,
00203                                int __plural, unsigned long int __n,
00204                                int __category));
00205 extern char *__textdomain PARAMS ((const char *__domainname));
00206 extern char *__bindtextdomain PARAMS ((const char *__domainname,
00207                                    const char *__dirname));
00208 extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
00209                                           const char *__codeset));
00210 #else
00211 /* Declare the exported libintl_* functions, in a way that allows us to
00212    call them under their real name.  */
00213 # define _INTL_REDIRECT_MACROS
00214 # include "libintl.h"
00215 extern char *libintl_dcigettext PARAMS ((const char *__domainname,
00216                                     const char *__msgid1,
00217                                     const char *__msgid2,
00218                                     int __plural, unsigned long int __n,
00219                                     int __category));
00220 #endif
00221 
00222 /* @@ begin of epilog @@ */
00223 
00224 #endif /* gettextP.h  */