set eol-style:native
[reactos.git] / reactos / lib / libxml2 / DOCBparser.c
index b18c8ab..3573743 100644 (file)
-/*\r
- * DOCBparser.c : an attempt to parse SGML Docbook documents\r
- *\r
- * This is deprecated !!!\r
- * Code removed with release 2.6.0 it was broken.\r
- * The doc are expect to be migrated to XML DocBook\r
- *\r
- * See Copyright for the status of this software.\r
- *\r
- * daniel@veillard.com\r
- */\r
-\r
-#define IN_LIBXML\r
-#include "libxml.h"\r
-#ifdef LIBXML_DOCB_ENABLED\r
-\r
-#include <libxml/xmlerror.h>\r
-#include <libxml/DOCBparser.h>\r
-\r
-/**\r
- * docbEncodeEntities:\r
- * @out:  a pointer to an array of bytes to store the result\r
- * @outlen:  the length of @out\r
- * @in:  a pointer to an array of UTF-8 chars\r
- * @inlen:  the length of @in\r
- * @quoteChar: the quote character to escape (' or ") or zero.\r
- *\r
- * Take a block of UTF-8 chars in and try to convert it to an ASCII\r
- * plus SGML entities block of chars out.\r
- *\r
- * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise\r
- * The value of @inlen after return is the number of octets consumed\r
- *     as the return value is positive, else unpredictable.\r
- * The value of @outlen after return is the number of octets consumed.\r
- */\r
-int\r
-docbEncodeEntities(unsigned char *out ATTRIBUTE_UNUSED,\r
-                   int *outlen ATTRIBUTE_UNUSED,\r
-                   const unsigned char *in ATTRIBUTE_UNUSED,\r
-                   int *inlen ATTRIBUTE_UNUSED,\r
-                   int quoteChar ATTRIBUTE_UNUSED)\r
-{\r
-    static int deprecated = 0;\r
-\r
-    if (!deprecated) {\r
-        xmlGenericError(xmlGenericErrorContext,\r
-                        "docbEncodeEntities() deprecated function reached\n");\r
-        deprecated = 1;\r
-    }\r
-    return(-1);\r
-}\r
-\r
-/**\r
- * docbParseDocument:\r
- * @ctxt:  an SGML parser context\r
- * \r
- * parse an SGML document (and build a tree if using the standard SAX\r
- * interface).\r
- *\r
- * Returns 0, -1 in case of error. the parser context is augmented\r
- *                as a result of the parsing.\r
- */\r
-\r
-int\r
-docbParseDocument(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)\r
-{\r
-    static int deprecated = 0;\r
-\r
-    if (!deprecated) {\r
-        xmlGenericError(xmlGenericErrorContext,\r
-                        "docbParseDocument() deprecated function reached\n");\r
-        deprecated = 1;\r
-    }\r
-    return (xmlParseDocument(ctxt));\r
-}\r
-\r
-/**\r
- * docbFreeParserCtxt:\r
- * @ctxt:  an SGML parser context\r
- *\r
- * Free all the memory used by a parser context. However the parsed\r
- * document in ctxt->myDoc is not freed.\r
- */\r
-\r
-void\r
-docbFreeParserCtxt(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)\r
-{\r
-    static int deprecated = 0;\r
-\r
-    if (!deprecated) {\r
-        xmlGenericError(xmlGenericErrorContext,\r
-                        "docbFreeParserCtxt() deprecated function reached\n");\r
-        deprecated = 1;\r
-    }\r
-    xmlFreeParserCtxt(ctxt);\r
-}\r
-\r
-/**\r
- * docbParseChunk:\r
- * @ctxt:  an XML parser context\r
- * @chunk:  an char array\r
- * @size:  the size in byte of the chunk\r
- * @terminate:  last chunk indicator\r
- *\r
- * Parse a Chunk of memory\r
- *\r
- * Returns zero if no error, the xmlParserErrors otherwise.\r
- */\r
-int\r
-docbParseChunk(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED,\r
-               const char *chunk ATTRIBUTE_UNUSED,\r
-              int size ATTRIBUTE_UNUSED,\r
-               int terminate ATTRIBUTE_UNUSED)\r
-{\r
-    static int deprecated = 0;\r
-\r
-    if (!deprecated) {\r
-        xmlGenericError(xmlGenericErrorContext,\r
-                        "docbParseChunk() deprecated function reached\n");\r
-        deprecated = 1;\r
-    }\r
-\r
-    return (xmlParseChunk(ctxt, chunk, size, terminate));\r
-}\r
-\r
-/**\r
- * docbCreatePushParserCtxt:\r
- * @sax:  a SAX handler\r
- * @user_data:  The user data returned on SAX callbacks\r
- * @chunk:  a pointer to an array of chars\r
- * @size:  number of chars in the array\r
- * @filename:  an optional file name or URI\r
- * @enc:  an optional encoding\r
- *\r
- * Create a parser context for using the DocBook SGML parser in push mode\r
- * To allow content encoding detection, @size should be >= 4\r
- * The value of @filename is used for fetching external entities\r
- * and error/warning reports.\r
- *\r
- * Returns the new parser context or NULL\r
- */\r
-docbParserCtxtPtr\r
-docbCreatePushParserCtxt(docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,\r
-                         void *user_data ATTRIBUTE_UNUSED,\r
-                         const char *chunk ATTRIBUTE_UNUSED,\r
-                        int size ATTRIBUTE_UNUSED,\r
-                        const char *filename ATTRIBUTE_UNUSED,\r
-                         xmlCharEncoding enc ATTRIBUTE_UNUSED)\r
-{\r
-    static int deprecated = 0;\r
-\r
-    if (!deprecated) {\r
-        xmlGenericError(xmlGenericErrorContext,\r
-                        "docbParseChunk() deprecated function reached\n");\r
-        deprecated = 1;\r
-    }\r
-\r
-    return(xmlCreatePushParserCtxt(sax, user_data, chunk, size, filename));\r
-}\r
-\r
-/**\r
- * docbSAXParseDoc:\r
- * @cur:  a pointer to an array of xmlChar\r
- * @encoding:  a free form C string describing the SGML document encoding, or NULL\r
- * @sax:  the SAX handler block\r
- * @userData: if using SAX, this pointer will be provided on callbacks. \r
- *\r
- * parse an SGML in-memory document and build a tree.\r
- * It use the given SAX function block to handle the parsing callback.\r
- * If sax is NULL, fallback to the default DOM tree building routines.\r
- * \r
- * Returns the resulting document tree\r
- */\r
-\r
-docbDocPtr\r
-docbSAXParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,\r
-                const char *encoding ATTRIBUTE_UNUSED,\r
-               docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,\r
-                void *userData ATTRIBUTE_UNUSED)\r
-{\r
-    static int deprecated = 0;\r
-\r
-    if (!deprecated) {\r
-        xmlGenericError(xmlGenericErrorContext,\r
-                        "docbParseChunk() deprecated function reached\n");\r
-        deprecated = 1;\r
-    }\r
-\r
-    return (xmlSAXParseMemoryWithData(sax, (const char *)cur,\r
-                         xmlStrlen((const xmlChar *) cur), 0,  userData));\r
-}\r
-\r
-/**\r
- * docbParseDoc:\r
- * @cur:  a pointer to an array of xmlChar\r
- * @encoding:  a free form C string describing the SGML document encoding, or NULL\r
- *\r
- * parse an SGML in-memory document and build a tree.\r
- * \r
- * Returns the resulting document tree\r
- */\r
-\r
-docbDocPtr\r
-docbParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,\r
-             const char *encoding ATTRIBUTE_UNUSED)\r
-{\r
-    static int deprecated = 0;\r
-\r
-    if (!deprecated) {\r
-        xmlGenericError(xmlGenericErrorContext,\r
-                        "docbParseChunk() deprecated function reached\n");\r
-        deprecated = 1;\r
-    }\r
-\r
-    return (xmlParseDoc(cur));\r
-}\r
-\r
-\r
-/**\r
- * docbCreateFileParserCtxt:\r
- * @filename:  the filename\r
- * @encoding:  the SGML document encoding, or NULL\r
- *\r
- * Create a parser context for a file content. \r
- * Automatic support for ZLIB/Compress compressed document is provided\r
- * by default if found at compile-time.\r
- *\r
- * Returns the new parser context or NULL\r
- */\r
-docbParserCtxtPtr\r
-docbCreateFileParserCtxt(const char *filename ATTRIBUTE_UNUSED,\r
-                         const char *encoding ATTRIBUTE_UNUSED)\r
-{\r
-    static int deprecated = 0;\r
-\r
-    if (!deprecated) {\r
-        xmlGenericError(xmlGenericErrorContext,\r
-                        "docbCreateFileParserCtxt() deprecated function reached\n");\r
-        deprecated = 1;\r
-    }\r
-\r
-    return (xmlCreateFileParserCtxt(filename));\r
-}\r
-\r
-/**\r
- * docbSAXParseFile:\r
- * @filename:  the filename\r
- * @encoding:  a free form C string describing the SGML document encoding, or NULL\r
- * @sax:  the SAX handler block\r
- * @userData: if using SAX, this pointer will be provided on callbacks. \r
- *\r
- * parse an SGML file and build a tree. Automatic support for ZLIB/Compress\r
- * compressed document is provided by default if found at compile-time.\r
- * It use the given SAX function block to handle the parsing callback.\r
- * If sax is NULL, fallback to the default DOM tree building routines.\r
- *\r
- * Returns the resulting document tree\r
- */\r
-\r
-docbDocPtr\r
-docbSAXParseFile(const char *filename ATTRIBUTE_UNUSED,\r
-                 const char *encoding ATTRIBUTE_UNUSED,\r
-                 docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,\r
-                void *userData ATTRIBUTE_UNUSED)\r
-{\r
-    static int deprecated = 0;\r
-\r
-    if (!deprecated) {\r
-        xmlGenericError(xmlGenericErrorContext,\r
-                        "docbSAXParseFile() deprecated function reached\n");\r
-        deprecated = 1;\r
-    }\r
-\r
-    return (xmlSAXParseFileWithData(sax, filename, 0, userData));\r
-}\r
-\r
-/**\r
- * docbParseFile:\r
- * @filename:  the filename\r
- * @encoding:  a free form C string describing document encoding, or NULL\r
- *\r
- * parse a Docbook SGML file and build a tree. Automatic support for\r
- * ZLIB/Compress compressed document is provided by default if found\r
- * at compile-time.\r
- *\r
- * Returns the resulting document tree\r
- */\r
-\r
-docbDocPtr\r
-docbParseFile(const char *filename ATTRIBUTE_UNUSED,\r
-              const char *encoding ATTRIBUTE_UNUSED)\r
-{\r
-    static int deprecated = 0;\r
-\r
-    if (!deprecated) {\r
-        xmlGenericError(xmlGenericErrorContext,\r
-                        "docbParseFile() deprecated function reached\n");\r
-        deprecated = 1;\r
-    }\r
-\r
-    return (xmlParseFile(filename));\r
-}\r
-#define bottom_DOCBparser\r
-#include "elfgcchack.h"\r
-#endif /* LIBXML_DOCB_ENABLED */\r
+/*
+ * DOCBparser.c : an attempt to parse SGML Docbook documents
+ *
+ * This is deprecated !!!
+ * Code removed with release 2.6.0 it was broken.
+ * The doc are expect to be migrated to XML DocBook
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXML
+#include "libxml.h"
+#ifdef LIBXML_DOCB_ENABLED
+
+#include <libxml/xmlerror.h>
+#include <libxml/DOCBparser.h>
+
+/**
+ * docbEncodeEntities:
+ * @out:  a pointer to an array of bytes to store the result
+ * @outlen:  the length of @out
+ * @in:  a pointer to an array of UTF-8 chars
+ * @inlen:  the length of @in
+ * @quoteChar: the quote character to escape (' or ") or zero.
+ *
+ * Take a block of UTF-8 chars in and try to convert it to an ASCII
+ * plus SGML entities block of chars out.
+ *
+ * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
+ * The value of @inlen after return is the number of octets consumed
+ *     as the return value is positive, else unpredictable.
+ * The value of @outlen after return is the number of octets consumed.
+ */
+int
+docbEncodeEntities(unsigned char *out ATTRIBUTE_UNUSED,
+                   int *outlen ATTRIBUTE_UNUSED,
+                   const unsigned char *in ATTRIBUTE_UNUSED,
+                   int *inlen ATTRIBUTE_UNUSED,
+                   int quoteChar ATTRIBUTE_UNUSED)
+{
+    static int deprecated = 0;
+
+    if (!deprecated) {
+        xmlGenericError(xmlGenericErrorContext,
+                        "docbEncodeEntities() deprecated function reached\n");
+        deprecated = 1;
+    }
+    return(-1);
+}
+
+/**
+ * docbParseDocument:
+ * @ctxt:  an SGML parser context
+ * 
+ * parse an SGML document (and build a tree if using the standard SAX
+ * interface).
+ *
+ * Returns 0, -1 in case of error. the parser context is augmented
+ *                as a result of the parsing.
+ */
+
+int
+docbParseDocument(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
+{
+    static int deprecated = 0;
+
+    if (!deprecated) {
+        xmlGenericError(xmlGenericErrorContext,
+                        "docbParseDocument() deprecated function reached\n");
+        deprecated = 1;
+    }
+    return (xmlParseDocument(ctxt));
+}
+
+/**
+ * docbFreeParserCtxt:
+ * @ctxt:  an SGML parser context
+ *
+ * Free all the memory used by a parser context. However the parsed
+ * document in ctxt->myDoc is not freed.
+ */
+
+void
+docbFreeParserCtxt(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
+{
+    static int deprecated = 0;
+
+    if (!deprecated) {
+        xmlGenericError(xmlGenericErrorContext,
+                        "docbFreeParserCtxt() deprecated function reached\n");
+        deprecated = 1;
+    }
+    xmlFreeParserCtxt(ctxt);
+}
+
+/**
+ * docbParseChunk:
+ * @ctxt:  an XML parser context
+ * @chunk:  an char array
+ * @size:  the size in byte of the chunk
+ * @terminate:  last chunk indicator
+ *
+ * Parse a Chunk of memory
+ *
+ * Returns zero if no error, the xmlParserErrors otherwise.
+ */
+int
+docbParseChunk(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
+               const char *chunk ATTRIBUTE_UNUSED,
+              int size ATTRIBUTE_UNUSED,
+               int terminate ATTRIBUTE_UNUSED)
+{
+    static int deprecated = 0;
+
+    if (!deprecated) {
+        xmlGenericError(xmlGenericErrorContext,
+                        "docbParseChunk() deprecated function reached\n");
+        deprecated = 1;
+    }
+
+    return (xmlParseChunk(ctxt, chunk, size, terminate));
+}
+
+/**
+ * docbCreatePushParserCtxt:
+ * @sax:  a SAX handler
+ * @user_data:  The user data returned on SAX callbacks
+ * @chunk:  a pointer to an array of chars
+ * @size:  number of chars in the array
+ * @filename:  an optional file name or URI
+ * @enc:  an optional encoding
+ *
+ * Create a parser context for using the DocBook SGML parser in push mode
+ * To allow content encoding detection, @size should be >= 4
+ * The value of @filename is used for fetching external entities
+ * and error/warning reports.
+ *
+ * Returns the new parser context or NULL
+ */
+docbParserCtxtPtr
+docbCreatePushParserCtxt(docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
+                         void *user_data ATTRIBUTE_UNUSED,
+                         const char *chunk ATTRIBUTE_UNUSED,
+                        int size ATTRIBUTE_UNUSED,
+                        const char *filename ATTRIBUTE_UNUSED,
+                         xmlCharEncoding enc ATTRIBUTE_UNUSED)
+{
+    static int deprecated = 0;
+
+    if (!deprecated) {
+        xmlGenericError(xmlGenericErrorContext,
+                        "docbParseChunk() deprecated function reached\n");
+        deprecated = 1;
+    }
+
+    return(xmlCreatePushParserCtxt(sax, user_data, chunk, size, filename));
+}
+
+/**
+ * docbSAXParseDoc:
+ * @cur:  a pointer to an array of xmlChar
+ * @encoding:  a free form C string describing the SGML document encoding, or NULL
+ * @sax:  the SAX handler block
+ * @userData: if using SAX, this pointer will be provided on callbacks. 
+ *
+ * parse an SGML in-memory document and build a tree.
+ * It use the given SAX function block to handle the parsing callback.
+ * If sax is NULL, fallback to the default DOM tree building routines.
+ * 
+ * Returns the resulting document tree
+ */
+
+docbDocPtr
+docbSAXParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
+                const char *encoding ATTRIBUTE_UNUSED,
+               docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
+                void *userData ATTRIBUTE_UNUSED)
+{
+    static int deprecated = 0;
+
+    if (!deprecated) {
+        xmlGenericError(xmlGenericErrorContext,
+                        "docbParseChunk() deprecated function reached\n");
+        deprecated = 1;
+    }
+
+    return (xmlSAXParseMemoryWithData(sax, (const char *)cur,
+                         xmlStrlen((const xmlChar *) cur), 0,  userData));
+}
+
+/**
+ * docbParseDoc:
+ * @cur:  a pointer to an array of xmlChar
+ * @encoding:  a free form C string describing the SGML document encoding, or NULL
+ *
+ * parse an SGML in-memory document and build a tree.
+ * 
+ * Returns the resulting document tree
+ */
+
+docbDocPtr
+docbParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
+             const char *encoding ATTRIBUTE_UNUSED)
+{
+    static int deprecated = 0;
+
+    if (!deprecated) {
+        xmlGenericError(xmlGenericErrorContext,
+                        "docbParseChunk() deprecated function reached\n");
+        deprecated = 1;
+    }
+
+    return (xmlParseDoc(cur));
+}
+
+
+/**
+ * docbCreateFileParserCtxt:
+ * @filename:  the filename
+ * @encoding:  the SGML document encoding, or NULL
+ *
+ * Create a parser context for a file content. 
+ * Automatic support for ZLIB/Compress compressed document is provided
+ * by default if found at compile-time.
+ *
+ * Returns the new parser context or NULL
+ */
+docbParserCtxtPtr
+docbCreateFileParserCtxt(const char *filename ATTRIBUTE_UNUSED,
+                         const char *encoding ATTRIBUTE_UNUSED)
+{
+    static int deprecated = 0;
+
+    if (!deprecated) {
+        xmlGenericError(xmlGenericErrorContext,
+                        "docbCreateFileParserCtxt() deprecated function reached\n");
+        deprecated = 1;
+    }
+
+    return (xmlCreateFileParserCtxt(filename));
+}
+
+/**
+ * docbSAXParseFile:
+ * @filename:  the filename
+ * @encoding:  a free form C string describing the SGML document encoding, or NULL
+ * @sax:  the SAX handler block
+ * @userData: if using SAX, this pointer will be provided on callbacks. 
+ *
+ * parse an SGML file and build a tree. Automatic support for ZLIB/Compress
+ * compressed document is provided by default if found at compile-time.
+ * It use the given SAX function block to handle the parsing callback.
+ * If sax is NULL, fallback to the default DOM tree building routines.
+ *
+ * Returns the resulting document tree
+ */
+
+docbDocPtr
+docbSAXParseFile(const char *filename ATTRIBUTE_UNUSED,
+                 const char *encoding ATTRIBUTE_UNUSED,
+                 docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
+                void *userData ATTRIBUTE_UNUSED)
+{
+    static int deprecated = 0;
+
+    if (!deprecated) {
+        xmlGenericError(xmlGenericErrorContext,
+                        "docbSAXParseFile() deprecated function reached\n");
+        deprecated = 1;
+    }
+
+    return (xmlSAXParseFileWithData(sax, filename, 0, userData));
+}
+
+/**
+ * docbParseFile:
+ * @filename:  the filename
+ * @encoding:  a free form C string describing document encoding, or NULL
+ *
+ * parse a Docbook SGML file and build a tree. Automatic support for
+ * ZLIB/Compress compressed document is provided by default if found
+ * at compile-time.
+ *
+ * Returns the resulting document tree
+ */
+
+docbDocPtr
+docbParseFile(const char *filename ATTRIBUTE_UNUSED,
+              const char *encoding ATTRIBUTE_UNUSED)
+{
+    static int deprecated = 0;
+
+    if (!deprecated) {
+        xmlGenericError(xmlGenericErrorContext,
+                        "docbParseFile() deprecated function reached\n");
+        deprecated = 1;
+    }
+
+    return (xmlParseFile(filename));
+}
+#define bottom_DOCBparser
+#include "elfgcchack.h"
+#endif /* LIBXML_DOCB_ENABLED */