/* internal.h12Internal definitions used by Expat. This is not needed to compile3client code.45The following calling convention macros are defined for frequently6called functions:78FASTCALL - Used for those internal functions that have a simple9body and a low number of arguments and local variables.1011PTRCALL - Used for functions called though function pointers.1213PTRFASTCALL - Like PTRCALL, but for low number of arguments.1415inline - Used for selected internal functions for which inlining16may improve performance on some platforms.1718Note: Use of these macros is based on judgement, not hard rules,19and therefore subject to change.20__ __ _21___\ \/ /_ __ __ _| |_22/ _ \\ /| '_ \ / _` | __|23| __// \| |_) | (_| | |_24\___/_/\_\ .__/ \__,_|\__|25|_| XML parser2627Copyright (c) 2002-2003 Fred L. Drake, Jr. <[email protected]>28Copyright (c) 2002-2006 Karl Waclawek <[email protected]>29Copyright (c) 2003 Greg Stein <[email protected]>30Copyright (c) 2016-2024 Sebastian Pipping <[email protected]>31Copyright (c) 2018 Yury Gribov <[email protected]>32Copyright (c) 2019 David Loffredo <[email protected]>33Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <[email protected]>34Copyright (c) 2024 Taichi Haradaguchi <[email protected]>35Licensed under the MIT license:3637Permission is hereby granted, free of charge, to any person obtaining38a copy of this software and associated documentation files (the39"Software"), to deal in the Software without restriction, including40without limitation the rights to use, copy, modify, merge, publish,41distribute, sublicense, and/or sell copies of the Software, and to permit42persons to whom the Software is furnished to do so, subject to the43following conditions:4445The above copyright notice and this permission notice shall be included46in all copies or substantial portions of the Software.4748THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,49EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF50MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN51NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,52DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR53OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE54USE OR OTHER DEALINGS IN THE SOFTWARE.55*/5657#if defined(__GNUC__) && defined(__i386__) && ! defined(__MINGW32__)58/* We'll use this version by default only where we know it helps.5960regparm() generates warnings on Solaris boxes. See SF bug #692878.6162Instability reported with egcs on a RedHat Linux 7.3.63Let's comment out:64#define FASTCALL __attribute__((stdcall, regparm(3)))65and let's try this:66*/67# define FASTCALL __attribute__((regparm(3)))68# define PTRFASTCALL __attribute__((regparm(3)))69#endif7071/* Using __fastcall seems to have an unexpected negative effect under72MS VC++, especially for function pointers, so we won't use it for73now on that platform. It may be reconsidered for a future release74if it can be made more effective.75Likely reason: __fastcall on Windows is like stdcall, therefore76the compiler cannot perform stack optimizations for call clusters.77*/7879/* Make sure all of these are defined if they aren't already. */8081#ifndef FASTCALL82# define FASTCALL83#endif8485#ifndef PTRCALL86# define PTRCALL87#endif8889#ifndef PTRFASTCALL90# define PTRFASTCALL91#endif9293#ifndef XML_MIN_SIZE94# if ! defined(__cplusplus) && ! defined(inline)95# ifdef __GNUC__96# define inline __inline97# endif /* __GNUC__ */98# endif99#endif /* XML_MIN_SIZE */100101#ifdef __cplusplus102# define inline inline103#else104# ifndef inline105# define inline106# endif107#endif108109#include <limits.h> // ULONG_MAX110111#if defined(_WIN32) \112&& (! defined(__USE_MINGW_ANSI_STDIO) \113|| (1 - __USE_MINGW_ANSI_STDIO - 1 == 0))114# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u"115# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW116# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d"117# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u"118# else119# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"120# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"121# endif122#else123# define EXPAT_FMT_ULL(midpart) "%" midpart "llu"124# if ! defined(ULONG_MAX)125# error Compiler did not define ULONG_MAX for us126# elif ULONG_MAX == 18446744073709551615u // 2^64-1127# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"128# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"129# else130# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"131# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"132# endif133#endif134135#ifndef UNUSED_P136# define UNUSED_P(p) (void)p137#endif138139/* NOTE BEGIN If you ever patch these defaults to greater values140for non-attack XML payload in your environment,141please file a bug report with libexpat. Thank you!142*/143#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT \144100.0f145#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \1468388608 // 8 MiB, 2^23147/* NOTE END */148149#include "expat.h" // so we can use type XML_Parser below150151#ifdef __cplusplus152extern "C" {153#endif154155void _INTERNAL_trim_to_complete_utf8_characters(const char *from,156const char **fromLimRef);157158#if defined(XML_GE) && XML_GE == 1159unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);160unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);161const char *unsignedCharToPrintable(unsigned char c);162#endif163164extern165#if ! defined(XML_TESTING)166const167#endif168XML_Bool g_reparseDeferralEnabledDefault; // written ONLY in runtests.c169#if defined(XML_TESTING)170extern unsigned int g_bytesScanned; // used for testing only171#endif172173#ifdef __cplusplus174}175#endif176177178