Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
libintl.h465 linesDownload Raw Back to include
1/* Message catalogs for internationalization.2   Copyright (C) 1995-1997, 2000-2016 Free Software Foundation, Inc.3 4   This program is free software: you can redistribute it and/or modify5   it under the terms of the GNU Lesser General Public License as published by6   the Free Software Foundation; either version 2.1 of the License, or7   (at your option) any later version.8 9   This program is distributed in the hope that it will be useful,10   but WITHOUT ANY WARRANTY; without even the implied warranty of11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12   GNU Lesser General Public License for more details.13 14   You should have received a copy of the GNU Lesser General Public License15   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */16 17#ifndef _LIBINTL_H18#define _LIBINTL_H 119 20#include <locale.h>21#if (defined __APPLE__ && defined __MACH__) && 022# include <xlocale.h>23#endif24 25/* The LC_MESSAGES locale category is the category used by the functions26   gettext() and dgettext().  It is specified in POSIX, but not in ANSI C.27   On systems that don't define it, use an arbitrary value instead.28   On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)29   then includes <libintl.h> (i.e. this file!) and then only defines30   LC_MESSAGES.  To avoid a redefinition warning, don't define LC_MESSAGES31   in this case.  */32#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))33# define LC_MESSAGES 172934#endif35 36/* We define an additional symbol to signal that we use the GNU37   implementation of gettext.  */38#define __USE_GNU_GETTEXT 139 40/* Provide information about the supported file formats.  Returns the41   maximum minor revision number supported for a given major revision.  */42#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \43  ((major) == 0 || (major) == 1 ? 1 : -1)44 45/* Resolve a platform specific conflict on DJGPP.  GNU gettext takes46   precedence over _conio_gettext.  */47#ifdef __DJGPP__48# undef gettext49#endif50 51#ifdef __cplusplus52extern "C" {53#endif54 55 56/* Version number: (major<<16) + (minor<<8) + subminor */57#define LIBINTL_VERSION 0x00130858extern int libintl_version;59 60 61/* We redirect the functions to those prefixed with "libintl_".  This is62   necessary, because some systems define gettext/textdomain/... in the C63   library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).64   If we used the unprefixed names, there would be cases where the65   definition in the C library would override the one in the libintl.so66   shared library.  Recall that on ELF systems, the symbols are looked67   up in the following order:68     1. in the executable,69     2. in the shared libraries specified on the link command line, in order,70     3. in the dependencies of the shared libraries specified on the link71        command line,72     4. in the dlopen()ed shared libraries, in the order in which they were73        dlopen()ed.74   The definition in the C library would override the one in libintl.so if75   either76     * -lc is given on the link command line and -lintl isn't, or77     * -lc is given on the link command line before -lintl, or78     * libintl.so is a dependency of a dlopen()ed shared library but not79       linked to the executable at link time.80   Since Solaris gettext() behaves differently than GNU gettext(), this81   would be unacceptable.82 83   The redirection happens by default through macros in C, so that &gettext84   is independent of the compilation unit, but through inline functions in85   C++, in order not to interfere with the name mangling of class fields or86   class methods called 'gettext'.  */87 88/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.89   If he doesn't, we choose the method.  A third possible method is90   _INTL_REDIRECT_ASM, supported only by GCC.  */91#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)92# if defined __GNUC__ && __GNUC__ >= 2 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)93#  define _INTL_REDIRECT_ASM94# else95#  ifdef __cplusplus96#   define _INTL_REDIRECT_INLINE97#  else98#   define _INTL_REDIRECT_MACROS99#  endif100# endif101#endif102/* Auxiliary macros.  */103#ifdef _INTL_REDIRECT_ASM104# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))105# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring106# define _INTL_STRINGIFY(prefix) #prefix107#else108# define _INTL_ASM(cname)109#endif110 111/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return112   its n-th argument literally.  This enables GCC to warn for example about113   printf (gettext ("foo %y")).  */114#if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1 && defined __cplusplus)115# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))116#else117# define _INTL_MAY_RETURN_STRING_ARG(n)118#endif119 120/* Look up MSGID in the current default message catalog for the current121   LC_MESSAGES locale.  If not found, returns MSGID itself (the default122   text).  */123#ifdef _INTL_REDIRECT_INLINE124extern char *libintl_gettext (const char *__msgid)125       _INTL_MAY_RETURN_STRING_ARG (1);126static inline char *gettext (const char *__msgid)127{128  return libintl_gettext (__msgid);129}130#else131#ifdef _INTL_REDIRECT_MACROS132# define gettext libintl_gettext133#endif134extern char *gettext (const char *__msgid)135       _INTL_ASM (libintl_gettext)136       _INTL_MAY_RETURN_STRING_ARG (1);137#endif138 139/* Look up MSGID in the DOMAINNAME message catalog for the current140   LC_MESSAGES locale.  */141#ifdef _INTL_REDIRECT_INLINE142extern char *libintl_dgettext (const char *__domainname, const char *__msgid)143       _INTL_MAY_RETURN_STRING_ARG (2);144static inline char *dgettext (const char *__domainname, const char *__msgid)145{146  return libintl_dgettext (__domainname, __msgid);147}148#else149#ifdef _INTL_REDIRECT_MACROS150# define dgettext libintl_dgettext151#endif152extern char *dgettext (const char *__domainname, const char *__msgid)153       _INTL_ASM (libintl_dgettext)154       _INTL_MAY_RETURN_STRING_ARG (2);155#endif156 157/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY158   locale.  */159#ifdef _INTL_REDIRECT_INLINE160extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,161                                int __category)162       _INTL_MAY_RETURN_STRING_ARG (2);163static inline char *dcgettext (const char *__domainname, const char *__msgid,164                               int __category)165{166  return libintl_dcgettext (__domainname, __msgid, __category);167}168#else169#ifdef _INTL_REDIRECT_MACROS170# define dcgettext libintl_dcgettext171#endif172extern char *dcgettext (const char *__domainname, const char *__msgid,173                        int __category)174       _INTL_ASM (libintl_dcgettext)175       _INTL_MAY_RETURN_STRING_ARG (2);176#endif177 178 179/* Similar to 'gettext' but select the plural form corresponding to the180   number N.  */181#ifdef _INTL_REDIRECT_INLINE182extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,183                               unsigned long int __n)184       _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);185static inline char *ngettext (const char *__msgid1, const char *__msgid2,186                              unsigned long int __n)187{188  return libintl_ngettext (__msgid1, __msgid2, __n);189}190#else191#ifdef _INTL_REDIRECT_MACROS192# define ngettext libintl_ngettext193#endif194extern char *ngettext (const char *__msgid1, const char *__msgid2,195                       unsigned long int __n)196       _INTL_ASM (libintl_ngettext)197       _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);198#endif199 200/* Similar to 'dgettext' but select the plural form corresponding to the201   number N.  */202#ifdef _INTL_REDIRECT_INLINE203extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,204                                const char *__msgid2, unsigned long int __n)205       _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);206static inline char *dngettext (const char *__domainname, const char *__msgid1,207                               const char *__msgid2, unsigned long int __n)208{209  return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);210}211#else212#ifdef _INTL_REDIRECT_MACROS213# define dngettext libintl_dngettext214#endif215extern char *dngettext (const char *__domainname,216                        const char *__msgid1, const char *__msgid2,217                        unsigned long int __n)218       _INTL_ASM (libintl_dngettext)219       _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);220#endif221 222/* Similar to 'dcgettext' but select the plural form corresponding to the223   number N.  */224#ifdef _INTL_REDIRECT_INLINE225extern char *libintl_dcngettext (const char *__domainname,226                                 const char *__msgid1, const char *__msgid2,227                                 unsigned long int __n, int __category)228       _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);229static inline char *dcngettext (const char *__domainname,230                                const char *__msgid1, const char *__msgid2,231                                unsigned long int __n, int __category)232{233  return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);234}235#else236#ifdef _INTL_REDIRECT_MACROS237# define dcngettext libintl_dcngettext238#endif239extern char *dcngettext (const char *__domainname,240                         const char *__msgid1, const char *__msgid2,241                         unsigned long int __n, int __category)242       _INTL_ASM (libintl_dcngettext)243       _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);244#endif245 246 247 248/* Set the current default message catalog to DOMAINNAME.249   If DOMAINNAME is null, return the current default.250   If DOMAINNAME is "", reset to the default of "messages".  */251#ifdef _INTL_REDIRECT_INLINE252extern char *libintl_textdomain (const char *__domainname);253static inline char *textdomain (const char *__domainname)254{255  return libintl_textdomain (__domainname);256}257#else258#ifdef _INTL_REDIRECT_MACROS259# define textdomain libintl_textdomain260#endif261extern char *textdomain (const char *__domainname)262       _INTL_ASM (libintl_textdomain);263#endif264 265/* Specify that the DOMAINNAME message catalog will be found266   in DIRNAME rather than in the system locale data base.  */267#ifdef _INTL_REDIRECT_INLINE268extern char *libintl_bindtextdomain (const char *__domainname,269                                     const char *__dirname);270static inline char *bindtextdomain (const char *__domainname,271                                    const char *__dirname)272{273  return libintl_bindtextdomain (__domainname, __dirname);274}275#else276#ifdef _INTL_REDIRECT_MACROS277# define bindtextdomain libintl_bindtextdomain278#endif279extern char *bindtextdomain (const char *__domainname, const char *__dirname)280       _INTL_ASM (libintl_bindtextdomain);281#endif282 283/* Specify the character encoding in which the messages from the284   DOMAINNAME message catalog will be returned.  */285#ifdef _INTL_REDIRECT_INLINE286extern char *libintl_bind_textdomain_codeset (const char *__domainname,287                                              const char *__codeset);288static inline char *bind_textdomain_codeset (const char *__domainname,289                                             const char *__codeset)290{291  return libintl_bind_textdomain_codeset (__domainname, __codeset);292}293#else294#ifdef _INTL_REDIRECT_MACROS295# define bind_textdomain_codeset libintl_bind_textdomain_codeset296#endif297extern char *bind_textdomain_codeset (const char *__domainname,298                                      const char *__codeset)299       _INTL_ASM (libintl_bind_textdomain_codeset);300#endif301 302 303 304/* Support for format strings with positions in *printf(), following the305   POSIX/XSI specification.306   Note: These replacements for the *printf() functions are visible only307   in source files that #include <libintl.h> or #include "gettext.h".308   Packages that use *printf() in source files that don't refer to _()309   or gettext() but for which the format string could be the return value310   of _() or gettext() need to add this #include.  Oh well.  */311 312#if !0313 314#include <stdio.h>315#include <stddef.h>316 317/* Get va_list.  */318#if (defined __STDC__ && __STDC__) || defined __cplusplus || defined _MSC_VER319# include <stdarg.h>320#else321# include <varargs.h>322#endif323 324#if !(defined fprintf && defined _GL_STDIO_H) /* don't override gnulib */325#undef fprintf326#define fprintf libintl_fprintf327extern int fprintf (FILE *, const char *, ...);328#endif329#if !(defined vfprintf && defined _GL_STDIO_H) /* don't override gnulib */330#undef vfprintf331#define vfprintf libintl_vfprintf332extern int vfprintf (FILE *, const char *, va_list);333#endif334 335#if !(defined printf && defined _GL_STDIO_H) /* don't override gnulib */336#undef printf337#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__338/* Don't break __attribute__((format(printf,M,N))).339   This redefinition is only possible because the libc in NetBSD, Cygwin,340   mingw does not have a function __printf__.341   Alternatively, we could have done this redirection only when compiling with342   __GNUC__, together with a symbol redirection:343       extern int printf (const char *, ...)344              __asm__ (#__USER_LABEL_PREFIX__ "libintl_printf");345   But doing it now would introduce a binary incompatibility with already346   distributed versions of libintl on these systems.  */347# define libintl_printf __printf__348#endif349#define printf libintl_printf350extern int printf (const char *, ...);351#endif352#if !(defined vprintf && defined _GL_STDIO_H) /* don't override gnulib */353#undef vprintf354#define vprintf libintl_vprintf355extern int vprintf (const char *, va_list);356#endif357 358#if !(defined sprintf && defined _GL_STDIO_H) /* don't override gnulib */359#undef sprintf360#define sprintf libintl_sprintf361extern int sprintf (char *, const char *, ...);362#endif363#if !(defined vsprintf && defined _GL_STDIO_H) /* don't override gnulib */364#undef vsprintf365#define vsprintf libintl_vsprintf366extern int vsprintf (char *, const char *, va_list);367#endif368 369#if 1370 371#if !(defined snprintf && defined _GL_STDIO_H) /* don't override gnulib */372#undef snprintf373#define snprintf libintl_snprintf374extern int snprintf (char *, size_t, const char *, ...);375#endif376#if !(defined vsnprintf && defined _GL_STDIO_H) /* don't override gnulib */377#undef vsnprintf378#define vsnprintf libintl_vsnprintf379extern int vsnprintf (char *, size_t, const char *, va_list);380#endif381 382#endif383 384#if 1385 386#if !(defined asprintf && defined _GL_STDIO_H) /* don't override gnulib */387#undef asprintf388#define asprintf libintl_asprintf389extern int asprintf (char **, const char *, ...);390#endif391#if !(defined vasprintf && defined _GL_STDIO_H) /* don't override gnulib */392#undef vasprintf393#define vasprintf libintl_vasprintf394extern int vasprintf (char **, const char *, va_list);395#endif396 397#endif398 399#if 0400 401#undef fwprintf402#define fwprintf libintl_fwprintf403extern int fwprintf (FILE *, const wchar_t *, ...);404#undef vfwprintf405#define vfwprintf libintl_vfwprintf406extern int vfwprintf (FILE *, const wchar_t *, va_list);407 408#undef wprintf409#define wprintf libintl_wprintf410extern int wprintf (const wchar_t *, ...);411#undef vwprintf412#define vwprintf libintl_vwprintf413extern int vwprintf (const wchar_t *, va_list);414 415#undef swprintf416#define swprintf libintl_swprintf417extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);418#undef vswprintf419#define vswprintf libintl_vswprintf420extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);421 422#endif423 424#endif425 426 427/* Support for the locale chosen by the user.  */428#if (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __WIN32__ || defined __CYGWIN__429 430#ifndef GNULIB_defined_setlocale /* don't override gnulib */431#undef setlocale432#define setlocale libintl_setlocale433extern char *setlocale (int, const char *);434#endif435 436#if 0437 438#undef newlocale439#define newlocale libintl_newlocale440extern locale_t newlocale (int, const char *, locale_t);441 442#endif443 444#endif445 446 447/* Support for relocatable packages.  */448 449/* Sets the original and the current installation prefix of the package.450   Relocation simply replaces a pathname starting with the original prefix451   by the corresponding pathname with the current prefix instead.  Both452   prefixes should be directory names without trailing slash (i.e. use ""453   instead of "/").  */454#define libintl_set_relocation_prefix libintl_set_relocation_prefix455extern void456       libintl_set_relocation_prefix (const char *orig_prefix,457                                      const char *curr_prefix);458 459 460#ifdef __cplusplus461}462#endif463 464#endif /* libintl.h */465 
codekingpro/portable-devtools · Team Ai