blob: 0a73ce42faa38f1b9b999124fc411bea8efa5f55 [file] [log] [blame]
Daniel Veillardeae522a2001-04-23 13:41:34 +00001/*
2 * DOCBparser.c : an attempt to parse SGML Docbook documents
3 *
Daniel Veillard877a7bd2003-09-13 00:16:32 +00004 * This is deprecated !!!
5 * Code removed with release 2.6.0 it was broken.
6 * Empty interface kept purely for symbols binary compatibility
Daniel Veillarde95e2392001-06-06 10:46:28 +00007 *
Daniel Veillardeae522a2001-04-23 13:41:34 +00008 * See Copyright for the status of this software.
9 *
Daniel Veillardc5d64342001-06-24 12:13:24 +000010 * daniel@veillard.com
Daniel Veillardeae522a2001-04-23 13:41:34 +000011 */
12
Daniel Veillard34ce8be2002-03-18 19:37:11 +000013#define IN_LIBXML
Daniel Veillardeae522a2001-04-23 13:41:34 +000014#include "libxml.h"
15#ifdef LIBXML_DOCB_ENABLED
16
Daniel Veillardeae522a2001-04-23 13:41:34 +000017#include <libxml/xmlerror.h>
18#include <libxml/DOCBparser.h>
Daniel Veillardeae522a2001-04-23 13:41:34 +000019
20/**
21 * docbEncodeEntities:
22 * @out: a pointer to an array of bytes to store the result
23 * @outlen: the length of @out
24 * @in: a pointer to an array of UTF-8 chars
25 * @inlen: the length of @in
26 * @quoteChar: the quote character to escape (' or ") or zero.
27 *
28 * Take a block of UTF-8 chars in and try to convert it to an ASCII
29 * plus SGML entities block of chars out.
30 *
31 * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
32 * The value of @inlen after return is the number of octets consumed
Daniel Veillardcbaf3992001-12-31 16:16:02 +000033 * as the return value is positive, else unpredictable.
Daniel Veillardeae522a2001-04-23 13:41:34 +000034 * The value of @outlen after return is the number of octets consumed.
35 */
36int
Daniel Veillard877a7bd2003-09-13 00:16:32 +000037docbEncodeEntities(unsigned char *out ATTRIBUTE_UNUSED,
38 int *outlen ATTRIBUTE_UNUSED,
39 const unsigned char *in ATTRIBUTE_UNUSED,
40 int *inlen ATTRIBUTE_UNUSED,
41 int quoteChar ATTRIBUTE_UNUSED)
Daniel Veillard84666b32001-06-11 17:31:08 +000042{
Daniel Veillard877a7bd2003-09-13 00:16:32 +000043 static int deprecated = 0;
Daniel Veillardeae522a2001-04-23 13:41:34 +000044
Daniel Veillard877a7bd2003-09-13 00:16:32 +000045 if (!deprecated) {
46 xmlGenericError(xmlGenericErrorContext,
47 "docbEncodeEntities() deprecated function reached\n");
48 deprecated = 1;
Daniel Veillardeae522a2001-04-23 13:41:34 +000049 }
Daniel Veillard877a7bd2003-09-13 00:16:32 +000050 return(-1);
Daniel Veillardeae522a2001-04-23 13:41:34 +000051}
52
53/**
Daniel Veillard01c13b52002-12-10 15:19:08 +000054 * docbParseDocument:
Daniel Veillardeae522a2001-04-23 13:41:34 +000055 * @ctxt: an SGML parser context
56 *
57 * parse an SGML document (and build a tree if using the standard SAX
58 * interface).
59 *
60 * Returns 0, -1 in case of error. the parser context is augmented
61 * as a result of the parsing.
62 */
63
64int
Daniel Veillard877a7bd2003-09-13 00:16:32 +000065docbParseDocument(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
Daniel Veillardeae522a2001-04-23 13:41:34 +000066{
Daniel Veillard877a7bd2003-09-13 00:16:32 +000067 static int deprecated = 0;
Daniel Veillardeae522a2001-04-23 13:41:34 +000068
Daniel Veillard877a7bd2003-09-13 00:16:32 +000069 if (!deprecated) {
Daniel Veillardeae522a2001-04-23 13:41:34 +000070 xmlGenericError(xmlGenericErrorContext,
Daniel Veillard877a7bd2003-09-13 00:16:32 +000071 "docbParseDocument() deprecated function reached\n");
72 deprecated = 1;
Daniel Veillardeae522a2001-04-23 13:41:34 +000073 }
Daniel Veillard877a7bd2003-09-13 00:16:32 +000074 return (-1);
Daniel Veillardeae522a2001-04-23 13:41:34 +000075}
76
77/**
78 * docbFreeParserCtxt:
79 * @ctxt: an SGML parser context
80 *
81 * Free all the memory used by a parser context. However the parsed
82 * document in ctxt->myDoc is not freed.
83 */
84
85void
Daniel Veillard877a7bd2003-09-13 00:16:32 +000086docbFreeParserCtxt(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
Daniel Veillardeae522a2001-04-23 13:41:34 +000087{
Daniel Veillard877a7bd2003-09-13 00:16:32 +000088 static int deprecated = 0;
Daniel Veillardeae522a2001-04-23 13:41:34 +000089
Daniel Veillard877a7bd2003-09-13 00:16:32 +000090 if (!deprecated) {
91 xmlGenericError(xmlGenericErrorContext,
92 "docbFreeParserCtxt() deprecated function reached\n");
93 deprecated = 1;
Daniel Veillardeae522a2001-04-23 13:41:34 +000094 }
Daniel Veillardeae522a2001-04-23 13:41:34 +000095}
96
97/**
98 * docbParseChunk:
99 * @ctxt: an XML parser context
100 * @chunk: an char array
101 * @size: the size in byte of the chunk
102 * @terminate: last chunk indicator
103 *
104 * Parse a Chunk of memory
105 *
106 * Returns zero if no error, the xmlParserErrors otherwise.
107 */
108int
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000109docbParseChunk(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
110 const char *chunk ATTRIBUTE_UNUSED,
111 int size ATTRIBUTE_UNUSED,
112 int terminate ATTRIBUTE_UNUSED)
113{
114 static int deprecated = 0;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000115
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000116 if (!deprecated) {
117 xmlGenericError(xmlGenericErrorContext,
118 "docbParseChunk() deprecated function reached\n");
119 deprecated = 1;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000120 }
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000121
122 return (-1);
Daniel Veillardeae522a2001-04-23 13:41:34 +0000123}
124
Daniel Veillardeae522a2001-04-23 13:41:34 +0000125/**
Daniel Veillard01c13b52002-12-10 15:19:08 +0000126 * docbCreatePushParserCtxt:
Daniel Veillardeae522a2001-04-23 13:41:34 +0000127 * @sax: a SAX handler
128 * @user_data: The user data returned on SAX callbacks
129 * @chunk: a pointer to an array of chars
130 * @size: number of chars in the array
131 * @filename: an optional file name or URI
132 * @enc: an optional encoding
133 *
134 * Create a parser context for using the DocBook SGML parser in push mode
135 * To allow content encoding detection, @size should be >= 4
136 * The value of @filename is used for fetching external entities
137 * and error/warning reports.
138 *
139 * Returns the new parser context or NULL
140 */
141docbParserCtxtPtr
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000142docbCreatePushParserCtxt(docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
143 void *user_data ATTRIBUTE_UNUSED,
144 const char *chunk ATTRIBUTE_UNUSED,
145 int size ATTRIBUTE_UNUSED,
146 const char *filename ATTRIBUTE_UNUSED,
147 xmlCharEncoding enc ATTRIBUTE_UNUSED)
148{
149 static int deprecated = 0;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000150
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000151 if (!deprecated) {
152 xmlGenericError(xmlGenericErrorContext,
153 "docbParseChunk() deprecated function reached\n");
154 deprecated = 1;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000155 }
156
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000157 return (NULL);
Daniel Veillardeae522a2001-04-23 13:41:34 +0000158}
159
160/**
Daniel Veillard01c13b52002-12-10 15:19:08 +0000161 * docbSAXParseDoc:
Daniel Veillardeae522a2001-04-23 13:41:34 +0000162 * @cur: a pointer to an array of xmlChar
163 * @encoding: a free form C string describing the SGML document encoding, or NULL
164 * @sax: the SAX handler block
165 * @userData: if using SAX, this pointer will be provided on callbacks.
166 *
167 * parse an SGML in-memory document and build a tree.
168 * It use the given SAX function block to handle the parsing callback.
169 * If sax is NULL, fallback to the default DOM tree building routines.
170 *
171 * Returns the resulting document tree
172 */
173
174docbDocPtr
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000175docbSAXParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
176 const char *encoding ATTRIBUTE_UNUSED,
177 docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
178 void *userData ATTRIBUTE_UNUSED)
179{
180 static int deprecated = 0;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000181
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000182 if (!deprecated) {
183 xmlGenericError(xmlGenericErrorContext,
184 "docbParseChunk() deprecated function reached\n");
185 deprecated = 1;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000186 }
187
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000188 return (NULL);
Daniel Veillardeae522a2001-04-23 13:41:34 +0000189}
190
191/**
Daniel Veillard01c13b52002-12-10 15:19:08 +0000192 * docbParseDoc:
Daniel Veillardeae522a2001-04-23 13:41:34 +0000193 * @cur: a pointer to an array of xmlChar
194 * @encoding: a free form C string describing the SGML document encoding, or NULL
195 *
196 * parse an SGML in-memory document and build a tree.
197 *
198 * Returns the resulting document tree
199 */
200
201docbDocPtr
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000202docbParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
203 const char *encoding ATTRIBUTE_UNUSED)
204{
205 static int deprecated = 0;
206
207 if (!deprecated) {
208 xmlGenericError(xmlGenericErrorContext,
209 "docbParseChunk() deprecated function reached\n");
210 deprecated = 1;
211 }
212
213 return (NULL);
Daniel Veillardeae522a2001-04-23 13:41:34 +0000214}
215
216
217/**
Daniel Veillard01c13b52002-12-10 15:19:08 +0000218 * docbCreateFileParserCtxt:
Daniel Veillardeae522a2001-04-23 13:41:34 +0000219 * @filename: the filename
Daniel Veillard1034da22001-04-25 19:06:28 +0000220 * @encoding: the SGML document encoding, or NULL
Daniel Veillardeae522a2001-04-23 13:41:34 +0000221 *
222 * Create a parser context for a file content.
223 * Automatic support for ZLIB/Compress compressed document is provided
224 * by default if found at compile-time.
225 *
226 * Returns the new parser context or NULL
227 */
228docbParserCtxtPtr
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000229docbCreateFileParserCtxt(const char *filename ATTRIBUTE_UNUSED,
230 const char *encoding ATTRIBUTE_UNUSED)
Daniel Veillardeae522a2001-04-23 13:41:34 +0000231{
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000232 static int deprecated = 0;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000233
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000234 if (!deprecated) {
235 xmlGenericError(xmlGenericErrorContext,
236 "docbCreateFileParserCtxt() deprecated function reached\n");
237 deprecated = 1;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000238 }
Daniel Veillardeae522a2001-04-23 13:41:34 +0000239
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000240 return (NULL);
Daniel Veillardeae522a2001-04-23 13:41:34 +0000241}
242
243/**
Daniel Veillard01c13b52002-12-10 15:19:08 +0000244 * docbSAXParseFile:
Daniel Veillardeae522a2001-04-23 13:41:34 +0000245 * @filename: the filename
246 * @encoding: a free form C string describing the SGML document encoding, or NULL
247 * @sax: the SAX handler block
248 * @userData: if using SAX, this pointer will be provided on callbacks.
249 *
250 * parse an SGML file and build a tree. Automatic support for ZLIB/Compress
251 * compressed document is provided by default if found at compile-time.
252 * It use the given SAX function block to handle the parsing callback.
253 * If sax is NULL, fallback to the default DOM tree building routines.
254 *
255 * Returns the resulting document tree
256 */
257
258docbDocPtr
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000259docbSAXParseFile(const char *filename ATTRIBUTE_UNUSED,
260 const char *encoding ATTRIBUTE_UNUSED,
261 docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
262 void *userData ATTRIBUTE_UNUSED)
263{
264 static int deprecated = 0;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000265
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000266 if (!deprecated) {
267 xmlGenericError(xmlGenericErrorContext,
268 "docbSAXParseFile() deprecated function reached\n");
269 deprecated = 1;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000270 }
271
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000272 return (NULL);
Daniel Veillardeae522a2001-04-23 13:41:34 +0000273}
274
275/**
Daniel Veillard01c13b52002-12-10 15:19:08 +0000276 * docbParseFile:
Daniel Veillardeae522a2001-04-23 13:41:34 +0000277 * @filename: the filename
278 * @encoding: a free form C string describing document encoding, or NULL
279 *
280 * parse a Docbook SGML file and build a tree. Automatic support for
281 * ZLIB/Compress compressed document is provided by default if found
282 * at compile-time.
283 *
284 * Returns the resulting document tree
285 */
286
287docbDocPtr
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000288docbParseFile(const char *filename ATTRIBUTE_UNUSED,
289 const char *encoding ATTRIBUTE_UNUSED)
290{
291 static int deprecated = 0;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000292
Daniel Veillard877a7bd2003-09-13 00:16:32 +0000293 if (!deprecated) {
294 xmlGenericError(xmlGenericErrorContext,
295 "docbParseFile() deprecated function reached\n");
296 deprecated = 1;
297 }
298
299 return (NULL);
300}
Daniel Veillardeae522a2001-04-23 13:41:34 +0000301#endif /* LIBXML_DOCB_ENABLED */