Blame intl/gettextP.h

Packit 6c4009
/* Header describing internals of libintl library.
Packit 6c4009
   Copyright (C) 1995-2018 Free Software Foundation, Inc.
Packit 6c4009
   Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
Packit 6c4009
Packit 6c4009
   This program is free software: you can redistribute it and/or modify
Packit 6c4009
   it under the terms of the GNU Lesser General Public License as published by
Packit 6c4009
   the Free Software Foundation; either version 2.1 of the License, or
Packit 6c4009
   (at your option) any later version.
Packit 6c4009
Packit 6c4009
   This program is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 6c4009
   GNU Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public License
Packit 6c4009
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _GETTEXTP_H
Packit 6c4009
#define _GETTEXTP_H
Packit 6c4009
Packit 6c4009
#include <stddef.h>		/* Get size_t.  */
Packit 6c4009
Packit 6c4009
#ifdef _LIBC
Packit 6c4009
# include "../iconv/gconv_int.h"
Packit 6c4009
#else
Packit 6c4009
# if HAVE_ICONV
Packit 6c4009
#  include <iconv.h>
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Handle multi-threaded applications.  */
Packit 6c4009
#ifdef _LIBC
Packit 6c4009
# include <libc-lock.h>
Packit 6c4009
# define gl_rwlock_define __libc_rwlock_define
Packit 6c4009
#else
Packit 6c4009
# include "lock.h"
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef _LIBC
Packit 6c4009
struct loaded_domain;
Packit 6c4009
extern char *__gettext (const char *__msgid);
Packit 6c4009
extern char *__dgettext (const char *__domainname, const char *__msgid);
Packit 6c4009
extern char *__dcgettext (const char *__domainname, const char *__msgid,
Packit 6c4009
			  int __category);
Packit 6c4009
extern char *__ngettext (const char *__msgid1, const char *__msgid2,
Packit 6c4009
			 unsigned long int __n);
Packit 6c4009
extern char *__dngettext (const char *__domainname,
Packit 6c4009
			  const char *__msgid1, const char *__msgid2,
Packit 6c4009
			  unsigned long int n);
Packit 6c4009
extern char *__dcngettext (const char *__domainname,
Packit 6c4009
			   const char *__msgid1, const char *__msgid2,
Packit 6c4009
			   unsigned long int __n, int __category)
Packit 6c4009
     attribute_hidden;
Packit 6c4009
extern char *__dcigettext (const char *__domainname,
Packit 6c4009
			   const char *__msgid1, const char *__msgid2,
Packit 6c4009
			   int __plural, unsigned long int __n,
Packit 6c4009
			   int __category) attribute_hidden;
Packit 6c4009
extern char *__textdomain (const char *__domainname);
Packit 6c4009
extern char *__bindtextdomain (const char *__domainname,
Packit 6c4009
			       const char *__dirname);
Packit 6c4009
extern char *__bind_textdomain_codeset (const char *__domainname,
Packit 6c4009
					const char *__codeset);
Packit 6c4009
extern void _nl_finddomain_subfreeres (void) attribute_hidden;
Packit 6c4009
extern void _nl_unload_domain (struct loaded_domain *__domain)
Packit 6c4009
     attribute_hidden;
Packit 6c4009
#else
Packit 6c4009
/* Declare the exported libintl_* functions, in a way that allows us to
Packit 6c4009
   call them under their real name.  */
Packit 6c4009
# undef _INTL_REDIRECT_INLINE
Packit 6c4009
# undef _INTL_REDIRECT_MACROS
Packit 6c4009
# define _INTL_REDIRECT_MACROS
Packit 6c4009
# include "libgnuintl.h"
Packit 6c4009
# ifdef IN_LIBGLOCALE
Packit 6c4009
extern char *gl_dcigettext (const char *__domainname,
Packit 6c4009
			    const char *__msgid1, const char *__msgid2,
Packit 6c4009
			    int __plural, unsigned long int __n,
Packit 6c4009
			    int __category,
Packit 6c4009
			    const char *__localename, const char *__encoding);
Packit 6c4009
# else
Packit 6c4009
extern char *libintl_dcigettext (const char *__domainname,
Packit 6c4009
				 const char *__msgid1, const char *__msgid2,
Packit 6c4009
				 int __plural, unsigned long int __n,
Packit 6c4009
				 int __category);
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#include "loadinfo.h"
Packit 6c4009
Packit 6c4009
#include "gmo.h"		/* Get nls_uint32.  */
Packit 6c4009
Packit 6c4009
/* @@ end of prolog @@ */
Packit 6c4009
Packit 6c4009
#ifndef attribute_hidden
Packit 6c4009
# define attribute_hidden
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Tell the compiler when a conditional or integer expression is
Packit 6c4009
   almost always true or almost always false.  */
Packit 6c4009
#ifndef HAVE_BUILTIN_EXPECT
Packit 6c4009
# define __builtin_expect(expr, val) (expr)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifndef W
Packit 6c4009
# define W(flag, data) ((flag) ? SWAP (data) : (data))
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef _LIBC
Packit 6c4009
# include <byteswap.h>
Packit 6c4009
# define SWAP(i) bswap_32 (i)
Packit 6c4009
#else
Packit 6c4009
static inline nls_uint32
Packit 6c4009
# ifdef __cplusplus
Packit 6c4009
SWAP (nls_uint32 i)
Packit 6c4009
# else
Packit 6c4009
SWAP (i)
Packit 6c4009
     nls_uint32 i;
Packit 6c4009
# endif
Packit 6c4009
{
Packit 6c4009
  return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
Packit 6c4009
}
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* In-memory representation of system dependent string.  */
Packit 6c4009
struct sysdep_string_desc
Packit 6c4009
{
Packit 6c4009
  /* Length of addressed string, including the trailing NUL.  */
Packit 6c4009
  size_t length;
Packit 6c4009
  /* Pointer to addressed string.  */
Packit 6c4009
  const char *pointer;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* Cache of translated strings after charset conversion.
Packit 6c4009
   Note: The strings are converted to the target encoding only on an as-needed
Packit 6c4009
   basis.  */
Packit 6c4009
struct converted_domain
Packit 6c4009
{
Packit 6c4009
  /* The target encoding name.  */
Packit 6c4009
  const char *encoding;
Packit 6c4009
  /* The descriptor for conversion from the message catalog's encoding to
Packit 6c4009
     this target encoding.  */
Packit 6c4009
#ifdef _LIBC
Packit 6c4009
  __gconv_t conv;
Packit 6c4009
#else
Packit 6c4009
# if HAVE_ICONV
Packit 6c4009
  iconv_t conv;
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
  /* The table of translated strings after charset conversion.  */
Packit 6c4009
  char **conv_tab;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* The representation of an opened message catalog.  */
Packit 6c4009
struct loaded_domain
Packit 6c4009
{
Packit 6c4009
  /* Pointer to memory containing the .mo file.  */
Packit 6c4009
  const char *data;
Packit 6c4009
  /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed.  */
Packit 6c4009
  int use_mmap;
Packit 6c4009
  /* Size of mmap()ed memory.  */
Packit 6c4009
  size_t mmap_size;
Packit 6c4009
  /* 1 if the .mo file uses a different endianness than this machine.  */
Packit 6c4009
  int must_swap;
Packit 6c4009
  /* Pointer to additional malloc()ed memory.  */
Packit 6c4009
  void *malloced;
Packit 6c4009
Packit 6c4009
  /* Number of static strings pairs.  */
Packit 6c4009
  nls_uint32 nstrings;
Packit 6c4009
  /* Pointer to descriptors of original strings in the file.  */
Packit 6c4009
  const struct string_desc *orig_tab;
Packit 6c4009
  /* Pointer to descriptors of translated strings in the file.  */
Packit 6c4009
  const struct string_desc *trans_tab;
Packit 6c4009
Packit 6c4009
  /* Number of system dependent strings pairs.  */
Packit 6c4009
  nls_uint32 n_sysdep_strings;
Packit 6c4009
  /* Pointer to descriptors of original sysdep strings.  */
Packit 6c4009
  const struct sysdep_string_desc *orig_sysdep_tab;
Packit 6c4009
  /* Pointer to descriptors of translated sysdep strings.  */
Packit 6c4009
  const struct sysdep_string_desc *trans_sysdep_tab;
Packit 6c4009
Packit 6c4009
  /* Size of hash table.  */
Packit 6c4009
  nls_uint32 hash_size;
Packit 6c4009
  /* Pointer to hash table.  */
Packit 6c4009
  const nls_uint32 *hash_tab;
Packit 6c4009
  /* 1 if the hash table uses a different endianness than this machine.  */
Packit 6c4009
  int must_swap_hash_tab;
Packit 6c4009
Packit 6c4009
  /* Cache of charset conversions of the translated strings.  */
Packit 6c4009
  struct converted_domain *conversions;
Packit 6c4009
  size_t nconversions;
Packit 6c4009
  gl_rwlock_define (, conversions_lock)
Packit 6c4009
Packit 6c4009
  const struct expression *plural;
Packit 6c4009
  unsigned long int nplurals;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* We want to allocate a string at the end of the struct.  But ISO C
Packit 6c4009
   doesn't allow zero sized arrays.  */
Packit 6c4009
#ifdef __GNUC__
Packit 6c4009
# define ZERO 0
Packit 6c4009
#else
Packit 6c4009
# define ZERO 1
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* A set of settings bound to a message domain.  Used to store settings
Packit 6c4009
   from bindtextdomain() and bind_textdomain_codeset().  */
Packit 6c4009
struct binding
Packit 6c4009
{
Packit 6c4009
  struct binding *next;
Packit 6c4009
  char *dirname;
Packit 6c4009
  char *codeset;
Packit 6c4009
  char domainname[ZERO];
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* A counter which is incremented each time some previous translations
Packit 6c4009
   become invalid.
Packit 6c4009
   This variable is part of the external ABI of the GNU libintl.  */
Packit 6c4009
#ifdef IN_LIBGLOCALE
Packit 6c4009
# include <glocale/config.h>
Packit 6c4009
extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr;
Packit 6c4009
#else
Packit 6c4009
extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr;
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifndef _LIBC
Packit 6c4009
extern const char *_nl_language_preferences_default (void);
Packit 6c4009
# define gl_locale_name_canonicalize _nl_locale_name_canonicalize
Packit 6c4009
extern void _nl_locale_name_canonicalize (char *name);
Packit 6c4009
# define gl_locale_name_from_win32_LANGID _nl_locale_name_from_win32_LANGID
Packit 6c4009
/* extern const char *_nl_locale_name_from_win32_LANGID (LANGID langid); */
Packit 6c4009
# define gl_locale_name_from_win32_LCID _nl_locale_name_from_win32_LCID
Packit 6c4009
/* extern const char *_nl_locale_name_from_win32_LCID (LCID lcid); */
Packit 6c4009
# define gl_locale_name_thread_unsafe _nl_locale_name_thread_unsafe
Packit 6c4009
extern const char *_nl_locale_name_thread_unsafe (int category,
Packit 6c4009
						  const char *categoryname);
Packit 6c4009
# define gl_locale_name_thread _nl_locale_name_thread
Packit 6c4009
/* extern const char *_nl_locale_name_thread (int category,
Packit 6c4009
					      const char *categoryname); */
Packit 6c4009
# define gl_locale_name_posix _nl_locale_name_posix
Packit 6c4009
extern const char *_nl_locale_name_posix (int category,
Packit 6c4009
					  const char *categoryname);
Packit 6c4009
# define gl_locale_name_environ _nl_locale_name_environ
Packit 6c4009
extern const char *_nl_locale_name_environ (int category,
Packit 6c4009
					    const char *categoryname);
Packit 6c4009
# define gl_locale_name_default _nl_locale_name_default
Packit 6c4009
extern const char *_nl_locale_name_default (void);
Packit 6c4009
# define gl_locale_name _nl_locale_name
Packit 6c4009
/* extern const char *_nl_locale_name (int category,
Packit 6c4009
				       const char *categoryname); */
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale,
Packit 6c4009
					 const char *__domainname,
Packit 6c4009
					 struct binding *__domainbinding)
Packit 6c4009
     attribute_hidden;
Packit 6c4009
void _nl_load_domain (struct loaded_l10nfile *__domain,
Packit 6c4009
		      struct binding *__domainbinding)
Packit 6c4009
     attribute_hidden;
Packit 6c4009
Packit 6c4009
#ifdef IN_LIBGLOCALE
Packit 6c4009
char *_nl_find_msg (struct loaded_l10nfile *domain_file,
Packit 6c4009
		    struct binding *domainbinding, const char *encoding,
Packit 6c4009
		    const char *msgid,
Packit 6c4009
		    size_t *lengthp)
Packit 6c4009
     attribute_hidden;
Packit 6c4009
#else
Packit 6c4009
char *_nl_find_msg (struct loaded_l10nfile *domain_file,
Packit 6c4009
		    struct binding *domainbinding, const char *msgid,
Packit 6c4009
		    int convert, size_t *lengthp)
Packit 6c4009
     attribute_hidden;
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* The internal variables in the standalone libintl.a must have different
Packit 6c4009
   names than the internal variables in GNU libc, otherwise programs
Packit 6c4009
   using libintl.a cannot be linked statically.  */
Packit 6c4009
#if !defined _LIBC
Packit 6c4009
# define _nl_default_dirname libintl_nl_default_dirname
Packit 6c4009
# define _nl_domain_bindings libintl_nl_domain_bindings
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Contains the default location of the message catalogs.  */
Packit 6c4009
extern const char _nl_default_dirname[];
Packit 6c4009
#ifdef _LIBC
Packit 6c4009
libc_hidden_proto (_nl_default_dirname)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* List with bindings of specific domains.  */
Packit 6c4009
extern struct binding *_nl_domain_bindings;
Packit 6c4009
Packit 6c4009
/* The internal variables in the standalone libintl.a must have different
Packit 6c4009
   names than the internal variables in GNU libc, otherwise programs
Packit 6c4009
   using libintl.a cannot be linked statically.  */
Packit 6c4009
#if !defined _LIBC
Packit 6c4009
# define _nl_default_default_domain libintl_nl_default_default_domain
Packit 6c4009
# define _nl_current_default_domain libintl_nl_current_default_domain
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Name of the default text domain.  */
Packit 6c4009
extern const char _nl_default_default_domain[] attribute_hidden;
Packit 6c4009
Packit 6c4009
/* Default text domain in which entries for gettext(3) are to be found.  */
Packit 6c4009
extern const char *_nl_current_default_domain attribute_hidden;
Packit 6c4009
Packit 6c4009
/* @@ begin of epilog @@ */
Packit 6c4009
Packit 6c4009
#endif /* gettextP.h  */