[Expat-checkins] expat/lib expat.h, 1.58, 1.59 libexpat.def, 1.5,
1.6 libexpatw.def, 1.5, 1.6 xmlparse.c, 1.120, 1.121
Karl Waclawek
kwaclaw at users.sourceforge.net
Wed Jan 7 12:10:55 EST 2004
Update of /cvsroot/expat/expat/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv28999
Modified Files:
expat.h libexpat.def libexpatw.def xmlparse.c
Log Message:
Applied patch #835123: Suspend/Resume functionality.
For details check the patch description.
Index: expat.h
===================================================================
RCS file: /cvsroot/expat/expat/lib/expat.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- expat.h 2 Nov 2003 20:37:22 -0000 1.58
+++ expat.h 7 Jan 2004 17:10:52 -0000 1.59
@@ -127,8 +127,10 @@
enum XML_Status {
XML_STATUS_ERROR = 0,
#define XML_STATUS_ERROR XML_STATUS_ERROR
- XML_STATUS_OK = 1
+ XML_STATUS_OK = 1,
#define XML_STATUS_OK XML_STATUS_OK
+ XML_STATUS_SUSPENDED = 2,
+#define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED
};
enum XML_Error {
@@ -159,7 +161,11 @@
XML_ERROR_ENTITY_DECLARED_IN_PE,
XML_ERROR_FEATURE_REQUIRES_XML_DTD,
XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
- XML_ERROR_UNBOUND_PREFIX
+ XML_ERROR_UNBOUND_PREFIX,
+ XML_ERROR_SUSPENDED,
+ XML_ERROR_NOT_SUSPENDED,
+ XML_ERROR_ABORTED,
+ XML_ERROR_FINISHED
};
enum XML_Content_Type {
@@ -817,6 +823,53 @@
XMLPARSEAPI(enum XML_Status)
XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
+
+/* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return as
+ soon as possible, but some handler call-backs - which would otherwise
+ get lost - may still follow. Examples: endElementHandler() for empty
+ elements when stopped in startElementHandler(), endNameSpaceDeclHandler()
+ when stopped in endElementHandler(), and possibly others.
+
+ Can be called from most handlers, including DTD related call-backs.
+ Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise.
+ Possible error codes: XML_ERROR_SUSPENDED, XML_ERROR_FINISHED.
+ When resumable = XML_TRUE then parsing is suspended, that is,
+ XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED.
+ Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
+ return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.
+
+ When suspended, parsing can be resumed by calling XML_ResumeParser().
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_StopParser(XML_Parser parser, XML_Bool resumable);
+
+/* Resumes parsing after it has been suspended with XML_StopParser().
+ Must not be called from within a handler call-back. Returns same
+ status codes as XML_Parse() or XML_ParseBuffer().
+ Additional error code XML_ERROR_NOT_SUSPENDED possible.
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_ResumeParser(XML_Parser parser);
+
+enum XML_Parsing {
+ XML_INITIALIZED,
+ XML_PARSING,
+ XML_FINISHED,
+ XML_SUSPENDED
+};
+
+typedef struct {
+ enum XML_Parsing parsing;
+ XML_Bool finalBuffer;
+} XML_ParsingStatus;
+
+/* Returns status of parser with respect to being initialized, parsing,
+ finished, or suspended and processing the final buffer.
+ XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus,
+ XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED
+*/
+XMLPARSEAPI(XML_ParsingStatus)
+XML_GetParsingStatus(XML_Parser parser);
/* Creates an XML_Parser object that can parse an external general
entity; context is a '\0'-terminated string specifying the parse
Index: libexpat.def
===================================================================
RCS file: /cvsroot/expat/expat/lib/libexpat.def,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- libexpat.def 16 Jan 2003 23:22:56 -0000 1.5
+++ libexpat.def 7 Jan 2004 17:10:52 -0000 1.6
@@ -67,3 +67,7 @@
XML_MemMalloc @60
XML_MemRealloc @61
XML_MemFree @62
+; added with version 1.95.8
+ XML_StopParser @63
+ XML_ResumeParser @64
+ XML_GetParsingStatus @65
Index: libexpatw.def
===================================================================
RCS file: /cvsroot/expat/expat/lib/libexpatw.def,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- libexpatw.def 16 Jan 2003 23:22:56 -0000 1.5
+++ libexpatw.def 7 Jan 2004 17:10:52 -0000 1.6
@@ -67,3 +67,7 @@
XML_MemMalloc @60
XML_MemRealloc @61
XML_MemFree @62
+; added with version 1.95.8
+ XML_StopParser @63
+ XML_ResumeParser @64
+ XML_GetParsingStatus @65
Index: xmlparse.c
===================================================================
RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- xmlparse.c 2 Nov 2003 09:44:55 -0000 1.120
+++ xmlparse.c 7 Jan 2004 17:10:52 -0000 1.121
@@ -182,7 +182,8 @@
typedef struct {
const XML_Char *name;
const XML_Char *textPtr;
- int textLen;
+ int textLen; /* length in XML_Chars */
+ int processed; /* # of processed bytes - when suspended */
const XML_Char *systemId;
const XML_Char *base;
const XML_Char *publicId;
@@ -307,29 +308,32 @@
static Processor externalEntityInitProcessor2;
[...1257 lines suppressed...]
+
+#ifdef XML_DTD
+ if (entity->is_param) {
+ int tok;
+ processor = prologProcessor;
+ tok = XmlPrologTok(encoding, s, end, &next);
+ return doProlog(parser, encoding, s, end, tok, next, nextPtr,
+ (XML_Bool)!finalBuffer);
+ }
+ else
+#endif /* XML_DTD */
+ {
+ processor = contentProcessor;
+ return doContent(parser, processorTagLevel, encoding, s, end, nextPtr,
+ (XML_Bool)!finalBuffer);
+ }
+}
static enum XML_Error PTRCALL
errorProcessor(XML_Parser parser,
More information about the Expat-checkins
mailing list