blob: f2b75dda8e27987444b24e831e232a61e7f6318e [file] [log] [blame]
Victor Stinner759e30e2017-09-05 01:58:08 +02001/*
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 Drake31d485c2004-08-03 07:06:22 +000031*/
32
Thomas Wouters0e3f5912006-08-11 14:57:12 +000033#ifndef Expat_External_INCLUDED
34#define Expat_External_INCLUDED 1
35
Fred Drake31d485c2004-08-03 07:06:22 +000036/* External API definitions */
37
Fred Drake31d485c2004-08-03 07:06:22 +000038/* Expat tries very hard to make the API boundary very specifically
39 defined. There are two macros defined to control this boundary;
40 each of these can be defined before including this header to
41 achieve some different behavior, but doing so it not recommended or
42 tested frequently.
43
44 XMLCALL - The calling convention to use for all calls across the
45 "library boundary." This will default to cdecl, and
46 try really hard to tell the compiler that's what we
47 want.
48
49 XMLIMPORT - Whatever magic is needed to note that a function is
50 to be imported from a dynamically loaded library
51 (.dll, .so, or .sl, depending on your platform).
52
53 The XMLCALL macro was added in Expat 1.95.7. The only one which is
54 expected to be directly useful in client code is XMLCALL.
55
56 Note that on at least some Unix versions, the Expat library must be
57 compiled with the cdecl calling convention as the default since
58 system headers may assume the cdecl convention.
59*/
Benjamin Peterson52b94082019-09-25 21:33:58 -070060
61/* Namespace external symbols to allow multiple libexpat version to
62 co-exist. */
63#include "pyexpatns.h"
64
Fred Drake31d485c2004-08-03 07:06:22 +000065#ifndef XMLCALL
Benjamin Peterson52b94082019-09-25 21:33:58 -070066# if defined(_MSC_VER)
67# define XMLCALL __cdecl
68# elif defined(__GNUC__) && defined(__i386) && ! defined(__INTEL_COMPILER)
69# define XMLCALL __attribute__((cdecl))
70# else
Fred Drake31d485c2004-08-03 07:06:22 +000071/* For any platform which uses this definition and supports more than
72 one calling convention, we need to extend this definition to
73 declare the convention used on that platform, if it's possible to
74 do so.
75
76 If this is the case for your platform, please file a bug report
77 with information on how to identify your platform via the C
78 pre-processor and how to specify the same calling convention as the
79 platform's malloc() implementation.
80*/
Benjamin Peterson52b94082019-09-25 21:33:58 -070081# define XMLCALL
82# endif
83#endif /* not defined XMLCALL */
Fred Drake31d485c2004-08-03 07:06:22 +000084
Benjamin Peterson52b94082019-09-25 21:33:58 -070085#if ! defined(XML_STATIC) && ! defined(XMLIMPORT)
86# ifndef XML_BUILDING_EXPAT
Fred Drake31d485c2004-08-03 07:06:22 +000087/* using Expat from an application */
88
Benjamin Peterson52b94082019-09-25 21:33:58 -070089# if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) && ! defined(__CYGWIN__)
90# define XMLIMPORT __declspec(dllimport)
91# endif
Fred Drake31d485c2004-08-03 07:06:22 +000092
Benjamin Peterson52b94082019-09-25 21:33:58 -070093# endif
94#endif /* not defined XML_STATIC */
Fred Drake31d485c2004-08-03 07:06:22 +000095
Benjamin Peterson3b03b092019-06-27 20:54:44 -070096#ifndef XML_ENABLE_VISIBILITY
Benjamin Peterson52b94082019-09-25 21:33:58 -070097# define XML_ENABLE_VISIBILITY 0
Benjamin Peterson3b03b092019-06-27 20:54:44 -070098#endif
99
Benjamin Peterson52b94082019-09-25 21:33:58 -0700100#if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY
101# define XMLIMPORT __attribute__((visibility("default")))
Victor Stinner23ec4b52017-06-15 00:54:36 +0200102#endif
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000103
Fred Drake31d485c2004-08-03 07:06:22 +0000104/* If we didn't define it above, define it away: */
105#ifndef XMLIMPORT
Benjamin Peterson52b94082019-09-25 21:33:58 -0700106# define XMLIMPORT
Fred Drake31d485c2004-08-03 07:06:22 +0000107#endif
108
Benjamin Peterson52b94082019-09-25 21:33:58 -0700109#if defined(__GNUC__) \
110 && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
111# define XML_ATTR_MALLOC __attribute__((__malloc__))
Victor Stinner23ec4b52017-06-15 00:54:36 +0200112#else
Benjamin Peterson52b94082019-09-25 21:33:58 -0700113# define XML_ATTR_MALLOC
Victor Stinner23ec4b52017-06-15 00:54:36 +0200114#endif
115
Benjamin Peterson52b94082019-09-25 21:33:58 -0700116#if defined(__GNUC__) \
117 && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
118# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
Victor Stinner23ec4b52017-06-15 00:54:36 +0200119#else
Benjamin Peterson52b94082019-09-25 21:33:58 -0700120# define XML_ATTR_ALLOC_SIZE(x)
Victor Stinner23ec4b52017-06-15 00:54:36 +0200121#endif
Fred Drake31d485c2004-08-03 07:06:22 +0000122
123#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
124
125#ifdef __cplusplus
126extern "C" {
127#endif
128
129#ifdef XML_UNICODE_WCHAR_T
Benjamin Peterson52b94082019-09-25 21:33:58 -0700130# ifndef XML_UNICODE
131# define XML_UNICODE
132# endif
133# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
134# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
135# endif
Fred Drake31d485c2004-08-03 07:06:22 +0000136#endif
137
Benjamin Peterson52b94082019-09-25 21:33:58 -0700138#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
139# ifdef XML_UNICODE_WCHAR_T
Fred Drake31d485c2004-08-03 07:06:22 +0000140typedef wchar_t XML_Char;
141typedef wchar_t XML_LChar;
Benjamin Peterson52b94082019-09-25 21:33:58 -0700142# else
Fred Drake31d485c2004-08-03 07:06:22 +0000143typedef unsigned short XML_Char;
144typedef char XML_LChar;
Benjamin Peterson52b94082019-09-25 21:33:58 -0700145# endif /* XML_UNICODE_WCHAR_T */
146#else /* Information is UTF-8 encoded. */
Fred Drake31d485c2004-08-03 07:06:22 +0000147typedef char XML_Char;
148typedef char XML_LChar;
Benjamin Peterson52b94082019-09-25 21:33:58 -0700149#endif /* XML_UNICODE */
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000150
Benjamin Peterson52b94082019-09-25 21:33:58 -0700151#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000152typedef long long XML_Index;
153typedef unsigned long long XML_Size;
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000154#else
155typedef long XML_Index;
156typedef unsigned long XML_Size;
157#endif /* XML_LARGE_SIZE */
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif /* not Expat_External_INCLUDED */