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