1515#endif
1616
1717#include < stdlib.h>
18-
19- #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
20- #define XML_USE_MSC_EXTENSIONS 1
21- #endif
22-
23- /* Expat tries very hard to make the API boundary very specifically
24- defined. There are two macros defined to control this boundary;
25- each of these can be defined before including this header to
26- achieve some different behavior, but doing so it not recommended or
27- tested frequently.
28-
29- XMLCALL - The calling convention to use for all calls across the
30- "library boundary." This will default to cdecl, and
31- try really hard to tell the compiler that's what we
32- want.
33-
34- XMLIMPORT - Whatever magic is needed to note that a function is
35- to be imported from a dynamically loaded library
36- (.dll, .so, or .sl, depending on your platform).
37-
38- The XMLCALL macro was added in Expat 1.95.7. The only one which is
39- expected to be directly useful in client code is XMLCALL.
40-
41- Note that on at least some Unix versions, the Expat library must be
42- compiled with the cdecl calling convention as the default since
43- system headers may assume the cdecl convention.
44- */
45- #ifndef XMLCALL
46- #if defined(XML_USE_MSC_EXTENSIONS)
47- #define XMLCALL __cdecl
48- #elif defined(__GNUC__)
49- #define XMLCALL __attribute__ ((cdecl))
50- #else
51- /* For any platform which uses this definition and supports more than
52- one calling convention, we need to extend this definition to
53- declare the convention used on that platform, if it's possible to
54- do so.
55-
56- If this is the case for your platform, please file a bug report
57- with information on how to identify your platform via the C
58- pre-processor and how to specify the same calling convention as the
59- platform's malloc() implementation.
60- */
61- #define XMLCALL
62- #endif
63- #endif /* not defined XMLCALL */
64-
65-
66- #if !defined(XML_STATIC) && !defined(XMLIMPORT)
67- #ifndef XML_BUILDING_EXPAT
68- /* using Expat from an application */
69-
70- #ifdef XML_USE_MSC_EXTENSIONS
71- #define XMLIMPORT __declspec (dllimport)
72- #endif
73-
74- #endif
75- #endif /* not defined XML_STATIC */
76-
77- /* If we didn't define it above, define it away: */
78- #ifndef XMLIMPORT
79- #define XMLIMPORT
80- #endif
81-
82-
83- #define XMLPARSEAPI (type ) XMLIMPORT type XMLCALL
84-
85- #ifdef __cplusplus
86- extern " C" {
87- #endif
88-
89- #ifdef XML_UNICODE_WCHAR_T
90- #define XML_UNICODE
91- #endif
18+ #include " expat_external.h"
9219
9320struct XML_ParserStruct ;
9421typedef struct XML_ParserStruct *XML_Parser;
9522
96- #ifdef XML_UNICODE /* Information is UTF-16 encoded. */
97- #ifdef XML_UNICODE_WCHAR_T
98- typedef wchar_t XML_Char;
99- typedef wchar_t XML_LChar;
100- #else
101- typedef unsigned short XML_Char;
102- typedef char XML_LChar;
103- #endif /* XML_UNICODE_WCHAR_T */
104- #else /* Information is UTF-8 encoded. */
105- typedef char XML_Char;
106- typedef char XML_LChar;
107- #endif /* XML_UNICODE */
108-
10923/* Should this be defined using stdbool.h when C99 is available? */
11024typedef unsigned char XML_Bool;
11125#define XML_TRUE ((XML_Bool) 1 )
@@ -127,8 +41,10 @@ typedef unsigned char XML_Bool;
12741enum XML_Status {
12842 XML_STATUS_ERROR = 0 ,
12943#define XML_STATUS_ERROR XML_STATUS_ERROR
130- XML_STATUS_OK = 1
44+ XML_STATUS_OK = 1 ,
13145#define XML_STATUS_OK XML_STATUS_OK
46+ XML_STATUS_SUSPENDED = 2 ,
47+ #define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED
13248};
13349
13450enum XML_Error {
@@ -159,7 +75,19 @@ enum XML_Error {
15975 XML_ERROR_ENTITY_DECLARED_IN_PE,
16076 XML_ERROR_FEATURE_REQUIRES_XML_DTD,
16177 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
162- XML_ERROR_UNBOUND_PREFIX
78+ /* Added in 1.95.7. */
79+ XML_ERROR_UNBOUND_PREFIX,
80+ /* Added in 1.95.8. */
81+ XML_ERROR_UNDECLARING_PREFIX,
82+ XML_ERROR_INCOMPLETE_PE,
83+ XML_ERROR_XML_DECL,
84+ XML_ERROR_TEXT_DECL,
85+ XML_ERROR_PUBLICID,
86+ XML_ERROR_SUSPENDED,
87+ XML_ERROR_NOT_SUSPENDED,
88+ XML_ERROR_ABORTED,
89+ XML_ERROR_FINISHED,
90+ XML_ERROR_SUSPEND_PE
16391};
16492
16593enum XML_Content_Type {
@@ -258,9 +186,9 @@ XML_SetXmlDeclHandler(XML_Parser parser,
258186
259187
260188typedef struct {
261- void *(XMLCALL *malloc_fcn)(size_t size);
262- void *(XMLCALL *realloc_fcn)(void *ptr, size_t size);
263- void (XMLCALL *free_fcn)(void *ptr);
189+ void *(*malloc_fcn)(size_t size);
190+ void *(*realloc_fcn)(void *ptr, size_t size);
191+ void (*free_fcn)(void *ptr);
264192} XML_Memory_Handling_Suite;
265193
266194/* Constructs a new parser; encoding is the encoding specified by the
@@ -600,10 +528,12 @@ XML_SetElementHandler(XML_Parser parser,
600528 XML_EndElementHandler end);
601529
602530XMLPARSEAPI (void )
603- XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
531+ XML_SetStartElementHandler(XML_Parser parser,
532+ XML_StartElementHandler handler);
604533
605534XMLPARSEAPI (void )
606- XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
535+ XML_SetEndElementHandler(XML_Parser parser,
536+ XML_EndElementHandler handler);
607537
608538XMLPARSEAPI (void )
609539XML_SetCharacterDataHandler(XML_Parser parser,
@@ -692,7 +622,8 @@ XML_SetExternalEntityRefHandler(XML_Parser parser,
692622 instead of the parser object.
693623*/
694624XMLPARSEAPI (void )
695- XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
625+ XML_SetExternalEntityRefHandlerArg(XML_Parser parser,
626+ void *arg);
696627
697628XMLPARSEAPI (void )
698629XML_SetSkippedEntityHandler(XML_Parser parser,
@@ -755,6 +686,9 @@ XML_UseParserAsHandlerArg(XML_Parser parser);
755686 specified in the document. In such a case the parser will call the
756687 externalEntityRefHandler with a value of NULL for the systemId
757688 argument (the publicId and context arguments will be NULL as well).
689+ Note: For the purpose of checking WFC: Entity Declared, passing
690+ useDTD == XML_TRUE will make the parser behave as if the document
691+ had a DTD with an external subset.
758692 Note: If this function is called, then this must be done before
759693 the first call to XML_Parse or XML_ParseBuffer, since it will
760694 have no effect after that. Returns
@@ -818,6 +752,75 @@ XML_GetBuffer(XML_Parser parser, int len);
818752XMLPARSEAPI (enum XML_Status)
819753XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
820754
755+ /* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return.
756+ Must be called from within a call-back handler, except when aborting
757+ (resumable = 0) an already suspended parser. Some call-backs may
758+ still follow because they would otherwise get lost. Examples:
759+ - endElementHandler() for empty elements when stopped in
760+ startElementHandler(),
761+ - endNameSpaceDeclHandler() when stopped in endElementHandler(),
762+ and possibly others.
763+
764+ Can be called from most handlers, including DTD related call-backs,
765+ except when parsing an external parameter entity and resumable != 0.
766+ Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise.
767+ Possible error codes:
768+ - XML_ERROR_SUSPENDED: when suspending an already suspended parser.
769+ - XML_ERROR_FINISHED: when the parser has already finished.
770+ - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE.
771+
772+ When resumable != 0 (true) then parsing is suspended, that is,
773+ XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED.
774+ Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
775+ return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.
776+
777+ *Note*:
778+ This will be applied to the current parser instance only, that is, if
779+ there is a parent parser then it will continue parsing when the
780+ externalEntityRefHandler() returns. It is up to the implementation of
781+ the externalEntityRefHandler() to call XML_StopParser() on the parent
782+ parser (recursively), if one wants to stop parsing altogether.
783+
784+ When suspended, parsing can be resumed by calling XML_ResumeParser().
785+ */
786+ XMLPARSEAPI (enum XML_Status)
787+ XML_StopParser(XML_Parser parser, XML_Bool resumable);
788+
789+ /* Resumes parsing after it has been suspended with XML_StopParser().
790+ Must not be called from within a handler call-back. Returns same
791+ status codes as XML_Parse() or XML_ParseBuffer().
792+ Additional error code XML_ERROR_NOT_SUSPENDED possible.
793+
794+ *Note*:
795+ This must be called on the most deeply nested child parser instance
796+ first, and on its parent parser only after the child parser has finished,
797+ to be applied recursively until the document entity's parser is restarted.
798+ That is, the parent parser will not resume by itself and it is up to the
799+ application to call XML_ResumeParser() on it at the appropriate moment.
800+ */
801+ XMLPARSEAPI (enum XML_Status)
802+ XML_ResumeParser(XML_Parser parser);
803+
804+ enum XML_Parsing {
805+ XML_INITIALIZED,
806+ XML_PARSING,
807+ XML_FINISHED,
808+ XML_SUSPENDED
809+ };
810+
811+ typedef struct {
812+ enum XML_Parsing parsing;
813+ XML_Bool finalBuffer;
814+ } XML_ParsingStatus;
815+
816+ /* Returns status of parser with respect to being initialized, parsing,
817+ finished, or suspended and processing the final buffer.
818+ XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus,
819+ XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED
820+ */
821+ XMLPARSEAPI (void )
822+ XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status);
823+
821824/* Creates an XML_Parser object that can parse an external general
822825 entity; context is a '\0'-terminated string specifying the parse
823826 context; encoding is a '\0'-terminated string giving the name of
@@ -992,7 +995,7 @@ XML_GetFeatureList(void);
992995*/
993996#define XML_MAJOR_VERSION 1
994997#define XML_MINOR_VERSION 95
995- #define XML_MICRO_VERSION 7
998+ #define XML_MICRO_VERSION 8
996999
9971000#ifdef __cplusplus
9981001}
0 commit comments