[Expat-checkins] expat/lib expat.h,1.29,1.30
Fred L. Drake
fdrake@users.sourceforge.net
Fri Aug 2 13:16:42 2002
Update of /cvsroot/expat/expat/lib
In directory usw-pr-cvs1:/tmp/cvs-serv6238/lib
Modified Files:
expat.h
Log Message:
Define specific return values for the XML_Parse*() functions, and use them
to test all XML_Parse*() return values in the test and sample code.
This is binary-compatible with previous Expat 1.95.x releases.
Index: expat.h
===================================================================
RCS file: /cvsroot/expat/expat/lib/expat.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- expat.h 31 Jul 2002 22:10:42 -0000 1.29
+++ expat.h 2 Aug 2002 19:40:09 -0000 1.30
@@ -648,17 +648,39 @@
XMLPARSEAPI(int)
XML_GetIdAttributeIndex(XML_Parser parser);
-/* Parses some input. Returns 0 if a fatal error is detected. The
- last call to XML_Parse must have isFinal true; len may be zero for
- this call (or any other).
+/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
+ detected. The last call to XML_Parse must have isFinal true; len
+ may be zero for this call (or any other).
+
+ The XML_Status enum gives the possible return values for the
+ XML_Parse and XML_ParseBuffer functions. Though the return values
+ for these functions has always been described as a Boolean value,
+ the implementation, at least for the 1.95.x series, has always
+ returned exactly one of these values. The preprocessor #defines
+ are included so this stanza can be added to code that still needs
+ to support older versions of Expat 1.95.x:
+
+ #ifndef XML_STATUS_OK
+ #define XML_STATUS_OK 1
+ #define XML_STATUS_ERROR 0
+ #endif
+
+ Otherwise, the #define hackery is quite ugly and would have been dropped.
*/
-XMLPARSEAPI(int)
+enum XML_Status {
+ XML_STATUS_ERROR = 0,
+#define XML_STATUS_ERROR XML_STATUS_ERROR
+ XML_STATUS_OK = 1
+#define XML_STATUS_OK XML_STATUS_OK
+};
+
+XMLPARSEAPI(enum XML_Status)
XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
XMLPARSEAPI(void *)
XML_GetBuffer(XML_Parser parser, int len);
-XMLPARSEAPI(int)
+XMLPARSEAPI(enum XML_Status)
XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
/* Creates an XML_Parser object that can parse an external general