Victor Stinner | 759e30e | 2017-09-05 01:58:08 +0200 | [diff] [blame] | 1 | /* |
| 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ |
| 4 | / _ \\ /| '_ \ / _` | __| |
| 5 | | __// \| |_) | (_| | |_ |
| 6 | \___/_/\_\ .__/ \__,_|\__| |
| 7 | |_| XML parser |
| 8 | |
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd |
| 10 | Copyright (c) 2000-2017 Expat development team |
| 11 | Licensed under the MIT license: |
| 12 | |
| 13 | Permission is hereby granted, free of charge, to any person obtaining |
| 14 | a copy of this software and associated documentation files (the |
| 15 | "Software"), to deal in the Software without restriction, including |
| 16 | without limitation the rights to use, copy, modify, merge, publish, |
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit |
| 18 | persons to whom the Software is furnished to do so, subject to the |
| 19 | following conditions: |
| 20 | |
| 21 | The above copyright notice and this permission notice shall be included |
| 22 | in all copies or substantial portions of the Software. |
| 23 | |
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. |
Fred Drake | 31d485c | 2004-08-03 07:06:22 +0000 | [diff] [blame] | 31 | */ |
| 32 | |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 33 | #ifndef Expat_External_INCLUDED |
| 34 | #define Expat_External_INCLUDED 1 |
| 35 | |
Fred Drake | 31d485c | 2004-08-03 07:06:22 +0000 | [diff] [blame] | 36 | /* External API definitions */ |
| 37 | |
Benjamin Peterson | 091d017 | 2014-02-04 10:10:55 -0500 | [diff] [blame] | 38 | /* Namespace external symbols to allow multiple libexpat version to |
| 39 | co-exist. */ |
| 40 | #include "pyexpatns.h" |
| 41 | |
Gregory P. Smith | 7c6309c | 2012-07-14 14:12:35 -0700 | [diff] [blame] | 42 | #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) |
Fred Drake | 31d485c | 2004-08-03 07:06:22 +0000 | [diff] [blame] | 43 | #define XML_USE_MSC_EXTENSIONS 1 |
| 44 | #endif |
| 45 | |
| 46 | /* Expat tries very hard to make the API boundary very specifically |
| 47 | defined. There are two macros defined to control this boundary; |
| 48 | each of these can be defined before including this header to |
| 49 | achieve some different behavior, but doing so it not recommended or |
| 50 | tested frequently. |
| 51 | |
| 52 | XMLCALL - The calling convention to use for all calls across the |
| 53 | "library boundary." This will default to cdecl, and |
| 54 | try really hard to tell the compiler that's what we |
| 55 | want. |
| 56 | |
| 57 | XMLIMPORT - Whatever magic is needed to note that a function is |
| 58 | to be imported from a dynamically loaded library |
| 59 | (.dll, .so, or .sl, depending on your platform). |
| 60 | |
| 61 | The XMLCALL macro was added in Expat 1.95.7. The only one which is |
| 62 | expected to be directly useful in client code is XMLCALL. |
| 63 | |
| 64 | Note that on at least some Unix versions, the Expat library must be |
| 65 | compiled with the cdecl calling convention as the default since |
| 66 | system headers may assume the cdecl convention. |
| 67 | */ |
| 68 | #ifndef XMLCALL |
Gregory P. Smith | 7c6309c | 2012-07-14 14:12:35 -0700 | [diff] [blame] | 69 | #if defined(_MSC_VER) |
Fred Drake | 31d485c | 2004-08-03 07:06:22 +0000 | [diff] [blame] | 70 | #define XMLCALL __cdecl |
Gregory P. Smith | 7c6309c | 2012-07-14 14:12:35 -0700 | [diff] [blame] | 71 | #elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER) |
Fred Drake | 31d485c | 2004-08-03 07:06:22 +0000 | [diff] [blame] | 72 | #define XMLCALL __attribute__((cdecl)) |
| 73 | #else |
| 74 | /* For any platform which uses this definition and supports more than |
| 75 | one calling convention, we need to extend this definition to |
| 76 | declare the convention used on that platform, if it's possible to |
| 77 | do so. |
| 78 | |
| 79 | If this is the case for your platform, please file a bug report |
| 80 | with information on how to identify your platform via the C |
| 81 | pre-processor and how to specify the same calling convention as the |
| 82 | platform's malloc() implementation. |
| 83 | */ |
| 84 | #define XMLCALL |
| 85 | #endif |
| 86 | #endif /* not defined XMLCALL */ |
| 87 | |
| 88 | |
| 89 | #if !defined(XML_STATIC) && !defined(XMLIMPORT) |
| 90 | #ifndef XML_BUILDING_EXPAT |
| 91 | /* using Expat from an application */ |
| 92 | |
| 93 | #ifdef XML_USE_MSC_EXTENSIONS |
| 94 | #define XMLIMPORT __declspec(dllimport) |
| 95 | #endif |
| 96 | |
| 97 | #endif |
| 98 | #endif /* not defined XML_STATIC */ |
| 99 | |
Victor Stinner | 23ec4b5 | 2017-06-15 00:54:36 +0200 | [diff] [blame] | 100 | #if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4) |
| 101 | #define XMLIMPORT __attribute__ ((visibility ("default"))) |
| 102 | #endif |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 103 | |
Fred Drake | 31d485c | 2004-08-03 07:06:22 +0000 | [diff] [blame] | 104 | /* If we didn't define it above, define it away: */ |
| 105 | #ifndef XMLIMPORT |
| 106 | #define XMLIMPORT |
| 107 | #endif |
| 108 | |
Victor Stinner | 23ec4b5 | 2017-06-15 00:54:36 +0200 | [diff] [blame] | 109 | #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)) |
| 110 | #define XML_ATTR_MALLOC __attribute__((__malloc__)) |
| 111 | #else |
| 112 | #define XML_ATTR_MALLOC |
| 113 | #endif |
| 114 | |
| 115 | #if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) |
| 116 | #define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) |
| 117 | #else |
| 118 | #define XML_ATTR_ALLOC_SIZE(x) |
| 119 | #endif |
Fred Drake | 31d485c | 2004-08-03 07:06:22 +0000 | [diff] [blame] | 120 | |
| 121 | #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL |
| 122 | |
| 123 | #ifdef __cplusplus |
| 124 | extern "C" { |
| 125 | #endif |
| 126 | |
| 127 | #ifdef XML_UNICODE_WCHAR_T |
Victor Stinner | 5ff7132 | 2017-06-21 14:39:22 +0200 | [diff] [blame] | 128 | # define XML_UNICODE |
| 129 | # if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2) |
| 130 | # error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc" |
| 131 | # endif |
Fred Drake | 31d485c | 2004-08-03 07:06:22 +0000 | [diff] [blame] | 132 | #endif |
| 133 | |
| 134 | #ifdef XML_UNICODE /* Information is UTF-16 encoded. */ |
| 135 | #ifdef XML_UNICODE_WCHAR_T |
| 136 | typedef wchar_t XML_Char; |
| 137 | typedef wchar_t XML_LChar; |
| 138 | #else |
| 139 | typedef unsigned short XML_Char; |
| 140 | typedef char XML_LChar; |
| 141 | #endif /* XML_UNICODE_WCHAR_T */ |
| 142 | #else /* Information is UTF-8 encoded. */ |
| 143 | typedef char XML_Char; |
| 144 | typedef char XML_LChar; |
| 145 | #endif /* XML_UNICODE */ |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 146 | |
| 147 | #ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */ |
| 148 | #if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 |
| 149 | typedef __int64 XML_Index; |
| 150 | typedef unsigned __int64 XML_Size; |
| 151 | #else |
| 152 | typedef long long XML_Index; |
| 153 | typedef unsigned long long XML_Size; |
| 154 | #endif |
| 155 | #else |
| 156 | typedef long XML_Index; |
| 157 | typedef unsigned long XML_Size; |
| 158 | #endif /* XML_LARGE_SIZE */ |
| 159 | |
| 160 | #ifdef __cplusplus |
| 161 | } |
| 162 | #endif |
| 163 | |
| 164 | #endif /* not Expat_External_INCLUDED */ |