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