xref: /freebsd/contrib/expat/lib/expat_external.h (revision cc68614da8232d8baaca0ae0d0dd8f890f06623e)
10a48773fSEric van Gyzen /*
20a48773fSEric van Gyzen                             __  __            _
30a48773fSEric van Gyzen                          ___\ \/ /_ __   __ _| |_
40a48773fSEric van Gyzen                         / _ \\  /| '_ \ / _` | __|
50a48773fSEric van Gyzen                        |  __//  \| |_) | (_| | |_
60a48773fSEric van Gyzen                         \___/_/\_\ .__/ \__,_|\__|
70a48773fSEric van Gyzen                                  |_| XML parser
80a48773fSEric van Gyzen 
90a48773fSEric van Gyzen    Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10*cc68614dSXin LI    Copyright (c) 2000      Clark Cooper <coopercc@users.sourceforge.net>
11*cc68614dSXin LI    Copyright (c) 2000-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
12*cc68614dSXin LI    Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
13*cc68614dSXin LI    Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
14*cc68614dSXin LI    Copyright (c) 2016      Cristian Rodríguez <crrodriguez@opensuse.org>
15*cc68614dSXin LI    Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org>
16*cc68614dSXin LI    Copyright (c) 2017      Rhodri James <rhodri@wildebeest.org.uk>
17*cc68614dSXin LI    Copyright (c) 2018      Yury Gribov <tetra2005@gmail.com>
180a48773fSEric van Gyzen    Licensed under the MIT license:
190a48773fSEric van Gyzen 
200a48773fSEric van Gyzen    Permission is  hereby granted,  free of charge,  to any  person obtaining
210a48773fSEric van Gyzen    a  copy  of  this  software   and  associated  documentation  files  (the
220a48773fSEric van Gyzen    "Software"),  to  deal in  the  Software  without restriction,  including
230a48773fSEric van Gyzen    without  limitation the  rights  to use,  copy,  modify, merge,  publish,
240a48773fSEric van Gyzen    distribute, sublicense, and/or sell copies of the Software, and to permit
250a48773fSEric van Gyzen    persons  to whom  the Software  is  furnished to  do so,  subject to  the
260a48773fSEric van Gyzen    following conditions:
270a48773fSEric van Gyzen 
280a48773fSEric van Gyzen    The above copyright  notice and this permission notice  shall be included
290a48773fSEric van Gyzen    in all copies or substantial portions of the Software.
300a48773fSEric van Gyzen 
310a48773fSEric van Gyzen    THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
320a48773fSEric van Gyzen    EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
330a48773fSEric van Gyzen    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
340a48773fSEric van Gyzen    NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
350a48773fSEric van Gyzen    DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
360a48773fSEric van Gyzen    OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
370a48773fSEric van Gyzen    USE OR OTHER DEALINGS IN THE SOFTWARE.
38220ed979SColeman Kane */
39220ed979SColeman Kane 
40220ed979SColeman Kane #ifndef Expat_External_INCLUDED
41220ed979SColeman Kane #define Expat_External_INCLUDED 1
42220ed979SColeman Kane 
43220ed979SColeman Kane /* External API definitions */
44220ed979SColeman Kane 
45220ed979SColeman Kane /* Expat tries very hard to make the API boundary very specifically
46220ed979SColeman Kane    defined.  There are two macros defined to control this boundary;
47220ed979SColeman Kane    each of these can be defined before including this header to
48220ed979SColeman Kane    achieve some different behavior, but doing so it not recommended or
49220ed979SColeman Kane    tested frequently.
50220ed979SColeman Kane 
51220ed979SColeman Kane    XMLCALL    - The calling convention to use for all calls across the
52220ed979SColeman Kane                 "library boundary."  This will default to cdecl, and
53220ed979SColeman Kane                 try really hard to tell the compiler that's what we
54220ed979SColeman Kane                 want.
55220ed979SColeman Kane 
56220ed979SColeman Kane    XMLIMPORT  - Whatever magic is needed to note that a function is
57220ed979SColeman Kane                 to be imported from a dynamically loaded library
58220ed979SColeman Kane                 (.dll, .so, or .sl, depending on your platform).
59220ed979SColeman Kane 
60220ed979SColeman Kane    The XMLCALL macro was added in Expat 1.95.7.  The only one which is
61220ed979SColeman Kane    expected to be directly useful in client code is XMLCALL.
62220ed979SColeman Kane 
63220ed979SColeman Kane    Note that on at least some Unix versions, the Expat library must be
64220ed979SColeman Kane    compiled with the cdecl calling convention as the default since
65220ed979SColeman Kane    system headers may assume the cdecl convention.
66220ed979SColeman Kane */
67220ed979SColeman Kane #ifndef XMLCALL
68220ed979SColeman Kane #  if defined(_MSC_VER)
69220ed979SColeman Kane #    define XMLCALL __cdecl
70220ed979SColeman Kane #  elif defined(__GNUC__) && defined(__i386) && ! defined(__INTEL_COMPILER)
71220ed979SColeman Kane #    define XMLCALL __attribute__((cdecl))
72220ed979SColeman Kane #  else
73220ed979SColeman Kane /* For any platform which uses this definition and supports more than
74220ed979SColeman Kane    one calling convention, we need to extend this definition to
75220ed979SColeman Kane    declare the convention used on that platform, if it's possible to
76220ed979SColeman Kane    do so.
77220ed979SColeman Kane 
78220ed979SColeman Kane    If this is the case for your platform, please file a bug report
79220ed979SColeman Kane    with information on how to identify your platform via the C
80220ed979SColeman Kane    pre-processor and how to specify the same calling convention as the
81220ed979SColeman Kane    platform's malloc() implementation.
82220ed979SColeman Kane */
83220ed979SColeman Kane #    define XMLCALL
84220ed979SColeman Kane #  endif
85220ed979SColeman Kane #endif /* not defined XMLCALL */
86220ed979SColeman Kane 
87220ed979SColeman Kane #if ! defined(XML_STATIC) && ! defined(XMLIMPORT)
88220ed979SColeman Kane #  ifndef XML_BUILDING_EXPAT
89220ed979SColeman Kane /* using Expat from an application */
90220ed979SColeman Kane 
916b2c1e49SXin LI #    if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) && ! defined(__CYGWIN__)
92220ed979SColeman Kane #      define XMLIMPORT __declspec(dllimport)
93220ed979SColeman Kane #    endif
94220ed979SColeman Kane 
95220ed979SColeman Kane #  endif
96220ed979SColeman Kane #endif /* not defined XML_STATIC */
97220ed979SColeman Kane 
986b2c1e49SXin LI #ifndef XML_ENABLE_VISIBILITY
996b2c1e49SXin LI #  define XML_ENABLE_VISIBILITY 0
1006b2c1e49SXin LI #endif
1016b2c1e49SXin LI 
1026b2c1e49SXin LI #if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY
103be8aff81SXin LI #  define XMLIMPORT __attribute__((visibility("default")))
104be8aff81SXin LI #endif
105220ed979SColeman Kane 
106220ed979SColeman Kane /* If we didn't define it above, define it away: */
107220ed979SColeman Kane #ifndef XMLIMPORT
108220ed979SColeman Kane #  define XMLIMPORT
109220ed979SColeman Kane #endif
110220ed979SColeman Kane 
1116b2c1e49SXin LI #if defined(__GNUC__)                                                          \
1126b2c1e49SXin LI     && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
113be8aff81SXin LI #  define XML_ATTR_MALLOC __attribute__((__malloc__))
114be8aff81SXin LI #else
115be8aff81SXin LI #  define XML_ATTR_MALLOC
116be8aff81SXin LI #endif
117be8aff81SXin LI 
1186b2c1e49SXin LI #if defined(__GNUC__)                                                          \
1196b2c1e49SXin LI     && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
120be8aff81SXin LI #  define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
121be8aff81SXin LI #else
122be8aff81SXin LI #  define XML_ATTR_ALLOC_SIZE(x)
123be8aff81SXin LI #endif
124220ed979SColeman Kane 
125220ed979SColeman Kane #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
126220ed979SColeman Kane 
127220ed979SColeman Kane #ifdef __cplusplus
128220ed979SColeman Kane extern "C" {
129220ed979SColeman Kane #endif
130220ed979SColeman Kane 
131220ed979SColeman Kane #ifdef XML_UNICODE_WCHAR_T
1320a48773fSEric van Gyzen #  ifndef XML_UNICODE
133220ed979SColeman Kane #    define XML_UNICODE
134220ed979SColeman Kane #  endif
1350a48773fSEric van Gyzen #  if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
1360a48773fSEric van Gyzen #    error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
1370a48773fSEric van Gyzen #  endif
1380a48773fSEric van Gyzen #endif
139220ed979SColeman Kane 
140220ed979SColeman Kane #ifdef XML_UNICODE /* Information is UTF-16 encoded. */
141220ed979SColeman Kane #  ifdef XML_UNICODE_WCHAR_T
142220ed979SColeman Kane typedef wchar_t XML_Char;
143220ed979SColeman Kane typedef wchar_t XML_LChar;
144220ed979SColeman Kane #  else
145220ed979SColeman Kane typedef unsigned short XML_Char;
146220ed979SColeman Kane typedef char XML_LChar;
147220ed979SColeman Kane #  endif /* XML_UNICODE_WCHAR_T */
148220ed979SColeman Kane #else    /* Information is UTF-8 encoded. */
149220ed979SColeman Kane typedef char XML_Char;
150220ed979SColeman Kane typedef char XML_LChar;
151220ed979SColeman Kane #endif   /* XML_UNICODE */
152220ed979SColeman Kane 
153220ed979SColeman Kane #ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
154220ed979SColeman Kane typedef long long XML_Index;
155220ed979SColeman Kane typedef unsigned long long XML_Size;
156220ed979SColeman Kane #else
157220ed979SColeman Kane typedef long XML_Index;
158220ed979SColeman Kane typedef unsigned long XML_Size;
159220ed979SColeman Kane #endif /* XML_LARGE_SIZE */
160220ed979SColeman Kane 
161220ed979SColeman Kane #ifdef __cplusplus
162220ed979SColeman Kane }
163220ed979SColeman Kane #endif
164220ed979SColeman Kane 
165220ed979SColeman Kane #endif /* not Expat_External_INCLUDED */
166