⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libintl.cpp

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* libintl.cpp -- gettext related functions from glibc-2.0.5   Copyright (C) 1995 Software Foundation, Inc.This file is part of the KDE libraries, but it's derived work outof glibc. The master sources can be found in       bindtextdom.c      dcgettext.c      dgettext.c      explodename.c      finddomain.c      gettext.c      gettext.h      gettextP.h      hash-string.h      l10nflist.c      libintl.h      loadinfo.h      loadmsgcat.c      localealias.c      textdomain.c            which are part of glibc. The license is the same as in GLIBC, whichis the GNU Library General Public License. See COPYING.LIB for moredetails.*//* gettext.c -- implementation of gettext(3) function   Copyright (C) 1995 Software Foundation, Inc.This file is part of the GNU C Library.  Its master source is NOT part ofthe C library, however.  The master source lives in /gd/gnu/lib.The GNU C Library is free software; you can redistribute it and/ormodify it under the terms of the GNU Library General Public License aspublished by the Free Software Foundation; either version 2 of theLicense, or (at your option) any later version.The GNU C Library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULibrary General Public License for more details.You should have received a copy of the GNU Library General PublicLicense along with the GNU C Library; see the file COPYING.LIB.  Ifnot, write to the Free Software Foundation, Inc., 675 Mass Ave,Cambridge, MA 02139, USA.  */#ifdef HAVE_CONFIG_H# include <config.h>#endif/* Stephan Kulow: some defaults */#ifndef GNULOCALEDIR#define GNULOCALEDIR "/usr/share/locale/"#endif#ifndef LOCALE_ALIAS_PATH#define LOCALE_ALIAS_PATH "/usr/share/local"#endif     #include <stdlib.h>#include <stdio.h>#define __USE_GNU#if defined(HAVE_ARGZ_H)#ifdef __BEGIN_DECLS#undef __BEGIN_DECLS#undef __END_DECLS#define __BEGIN_DECLS#define __END_DECLS#define _ARGZ_H_WORKAROUND_extern "C" {#endif# include <argz.h>#ifdef _ARGZ_H_WORKAROUND_}#undef __BEGIN_DECLS#undef __END_DECLS#define __BEGIN_DECLS	extern "C" { #define	__END_DECLS	} #endif // _ARGZ_H_WORKAROUND_#endif // HAVE_ARGZ_H#ifdef HAVE_MALLOC_H# include <malloc.h>#endif#if defined HAVE_STRING_H# include <string.h>#else# include <strings.h>#endif#include <sys/types.h>#include <fcntl.h>#include <sys/stat.h>#if defined __GNUC__ && !defined alloca# define alloca __builtin_alloca# define HAVE_ALLOCA 1#else# if defined HAVE_ALLOCA_H #  include <alloca.h># else#  ifdef _AIX #pragma alloca#  else#   ifndef allocachar *alloca ();#   endif#  endif# endif#endif#include <errno.h>#ifndef errnoextern int errno;#endif#ifndef __set_errno# define __set_errno(val) errno = (val)#endif#if !HAVE_STRCHR# ifndef strchr#  define strchr index# endif#endif#if defined HAVE_UNISTD_H# include <unistd.h>#endif#include <ctype.h>#ifdef NULL#undef NULL#endif#define NULL 0 #if HAVE_LIMITS_H# include <limits.h>#endif#if (defined HAVE_MMAP && defined HAVE_MUNMAP) # include <sys/mman.h>#endif/* The following contortions are an attempt to use the C preprocessor   to determine an unsigned integral type that is 32 bits wide.  An   alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but   doing that would require that the configure script compile and *run*   the resulting executable.  Locally running cross-compiled executables   is usually not possible.  */#if __STDC__# define UINT_MAX_32_BITS 4294967295U#else# define UINT_MAX_32_BITS 0xFFFFFFFF#endif/* If UINT_MAX isn't defined, assume it's a 32-bit type.   This should be valid for all systems GNU cares about because   that doesn't include 16-bit systems, and only modern systems   (that certainly have <limits.h>) have 64+-bit integral types.  */#ifndef UINT_MAX# define UINT_MAX UINT_MAX_32_BITS#endif#if UINT_MAX == UINT_MAX_32_BITStypedef unsigned nls_uint32;#else# if USHRT_MAX == UINT_MAX_32_BITStypedef unsigned short nls_uint32;# else#  if ULONG_MAX == UINT_MAX_32_BITStypedef unsigned long nls_uint32;#  else  /* The following line is intended to throw an error.  Using #error is     not portable enough.  */  "Cannot determine unsigned 32-bit data type."#  endif# endif#endif#ifndef W# define W(flag, data) ((flag) ? SWAP (data) : (data))#endifstruct loaded_domain{  const char *data;  int must_swap;  nls_uint32 nstrings;  struct string_desc *orig_tab;  struct string_desc *trans_tab;  nls_uint32 hash_size;  nls_uint32 *hash_tab;};struct binding{  struct binding *next;  char *domainname;  char *dirname;};/* Encoding of locale name parts.  */#define CEN_REVISION		1#define CEN_SPONSOR		2#define CEN_SPECIAL		4#define XPG_NORM_CODESET	8#define XPG_CODESET		16#define TERRITORY		32#define CEN_AUDIENCE		64#define XPG_MODIFIER		128#define CEN_SPECIFIC	(CEN_REVISION|CEN_SPONSOR|CEN_SPECIAL|CEN_AUDIENCE)#define XPG_SPECIFIC	(XPG_CODESET|XPG_NORM_CODESET|XPG_MODIFIER)struct loaded_l10nfile{  const char *filename;  int decided;  const void *data;  struct loaded_l10nfile *next;  struct loaded_l10nfile *successor[1];};extern const char *_nl_normalize_codeset(const char *codeset,					 size_t name_len);extern struct loaded_l10nfile *_nl_make_l10nflist  (struct loaded_l10nfile **l10nfile_list,		     const char *dirlist, size_t dirlist_len, int mask,		     const char *language, const char *territory,		     const char *codeset,		     const char *normalized_codeset,		     const char *modifier, const char *special,		     const char *sponsor, const char *revision,		     const char *filename, int do_allocate);extern const char *_nl_expand_alias(const char *name);extern int _nl_explode_name  (char *name, const char **language,			      const char **modifier,			      const char **territory,			      const char **codeset,			      const char **normalized_codeset,			      const char **special,			      const char **sponsor,			      const char **revision);struct loaded_l10nfile *_nl_find_domain  (const char *__dirname,					  char *__locale,					  const char *__domainname);void k_nl_load_domain(struct loaded_l10nfile *__domain);static inline nls_uint32SWAP (nls_uint32  i){  return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);}/* @@ end of prolog @@ *//* The magic number of the GNU message catalog format.  */#define _MAGIC 0x950412de#define _MAGIC_SWAPPED 0xde120495/* Revision number of the currently used .mo (binary) file format.  */#define MO_REVISION_NUMBER 0/* Defines the so called `hashpjw' function by P.J. Weinberger   [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,   1986, 1987 Bell Telephone Laboratories, Inc.]  */static inline unsigned long hash_string  (const char *__str_param);/* @@ end of prolog @@ *//* Contains the default location of the message catalogs.  */extern const char k_nl_default_dirname[];/* List with bindings of specific domains.  */extern struct binding *_nl_domain_bindings;/* Header for binary .mo file format.  */struct mo_file_header{  /* The magic number.  */  nls_uint32 magic;  /* The revision number of the file format.  */  nls_uint32 revision;  /* The number of strings pairs.  */  nls_uint32 nstrings;  /* Offset of table with start offsets of original strings.  */  nls_uint32 orig_tab_offset;  /* Offset of table with start offsets of translation strings.  */  nls_uint32 trans_tab_offset;  /* Size of hashing table.  */  nls_uint32 hash_tab_size;  /* Offset of first hashing entry.  */  nls_uint32 hash_tab_offset;};struct string_desc{  /* Length of addressed string.  */  nls_uint32 length;  /* Offset of string in file.  */  nls_uint32 offset;};/* Specify that the DOMAINNAME message catalog will be found   in DIRNAME rather than in the system locale data base.  */char *k_bindtextdomain(const char *domainname, const char *dirname){  struct binding *binding;    /* Some sanity checks.  */  if (domainname == NULL || domainname[0] == '\0')    return NULL;  for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)    {      int compare = strcmp (domainname, binding->domainname);      if (compare == 0)	/* We found it!  */	break;      if (compare < 0)	{	  /* It is not in the list.  */	  binding = NULL;	  break;	}    }  if (dirname == NULL)    /* The current binding has be to returned.  */    return binding == NULL ? (char *) k_nl_default_dirname : binding->dirname;  if (binding != NULL)    {      /* The domain is already bound.  Replace the old binding.  */      char *new_dirname;      if (strcmp (dirname, k_nl_default_dirname) == 0)	new_dirname = (char *) k_nl_default_dirname;      else	{	  size_t len = strlen (dirname) + 1;	  new_dirname = (char *) malloc (len);	  if (new_dirname == NULL)	    return NULL;	  memcpy (new_dirname, dirname, len);	}      if (strcmp (binding->dirname, k_nl_default_dirname) != 0)        free (binding->dirname);      binding->dirname = new_dirname;    }  else    {      /* We have to create a new binding.  */      size_t len;      struct binding *new_binding =	(struct binding *) malloc (sizeof (*new_binding));      if (new_binding == NULL)	return NULL;      len = strlen (domainname) + 1;      new_binding->domainname = (char *) malloc (len);      if (new_binding->domainname == NULL)	  return NULL;      memcpy (new_binding->domainname, domainname, len);      if (strcmp (dirname, k_nl_default_dirname) == 0)	new_binding->dirname = (char *) k_nl_default_dirname;      else	{	  len = strlen (dirname) + 1;	  new_binding->dirname = (char *) malloc (len);	  if (new_binding->dirname == NULL)	    return NULL;	  memcpy (new_binding->dirname, dirname, len);	}      /* Now enqueue it.  */      if (_nl_domain_bindings == NULL	  || strcmp (domainname, _nl_domain_bindings->domainname) < 0)	{	  new_binding->next = _nl_domain_bindings;	  _nl_domain_bindings = new_binding;	}      else	{	  binding = _nl_domain_bindings;	  while (binding->next != NULL		 && strcmp (domainname, binding->next->domainname) > 0)	    binding = binding->next;	  new_binding->next = binding->next;	  binding->next = new_binding;	}      binding = new_binding;    }  return binding->dirname;}# if !defined HAVE_GETCWDchar *getwd ();#  define getcwd(buf, max) getwd (buf)# elsechar *getcwd ();# endif# ifndef HAVE_STPCPYstatic char *stpcpy  (char *dest, const char *src);# endif/* Amount to increase buffer size by in each try.  */#define PATH_INCR 32/* The following is from pathmax.h.  *//* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define   PATH_MAX but might cause redefinition warnings when sys/param.h is   later included (as on MORE/BSD 4.3).  */#ifndef _POSIX_PATH_MAX# define _POSIX_PATH_MAX 255#endif#if !defined(PATH_MAX) && defined(_PC_PATH_MAX)# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX))#endif/* Don't include sys/param.h if it already has been.  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -