DOCBparser.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /*
  2. * DOCBparser.c : an attempt to parse SGML Docbook documents
  3. *
  4. * This is deprecated !!!
  5. * Code removed with release 2.6.0 it was broken.
  6. * The doc are expect to be migrated to XML DocBook
  7. *
  8. * See Copyright for the status of this software.
  9. *
  10. * daniel@veillard.com
  11. */
  12. #define IN_LIBXML
  13. #include "libxml.h"
  14. #ifdef LIBXML_DOCB_ENABLED
  15. #include <libxml/xmlerror.h>
  16. #include <libxml/DOCBparser.h>
  17. /**
  18. * docbEncodeEntities:
  19. * @out: a pointer to an array of bytes to store the result
  20. * @outlen: the length of @out
  21. * @in: a pointer to an array of UTF-8 chars
  22. * @inlen: the length of @in
  23. * @quoteChar: the quote character to escape (' or ") or zero.
  24. *
  25. * Take a block of UTF-8 chars in and try to convert it to an ASCII
  26. * plus SGML entities block of chars out.
  27. *
  28. * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
  29. * The value of @inlen after return is the number of octets consumed
  30. * as the return value is positive, else unpredictable.
  31. * The value of @outlen after return is the number of octets consumed.
  32. */
  33. int
  34. docbEncodeEntities(unsigned char *out ATTRIBUTE_UNUSED,
  35. int *outlen ATTRIBUTE_UNUSED,
  36. const unsigned char *in ATTRIBUTE_UNUSED,
  37. int *inlen ATTRIBUTE_UNUSED,
  38. int quoteChar ATTRIBUTE_UNUSED)
  39. {
  40. static int deprecated = 0;
  41. if (!deprecated) {
  42. xmlGenericError(xmlGenericErrorContext,
  43. "docbEncodeEntities() deprecated function reached\n");
  44. deprecated = 1;
  45. }
  46. return(-1);
  47. }
  48. /**
  49. * docbParseDocument:
  50. * @ctxt: an SGML parser context
  51. *
  52. * parse an SGML document (and build a tree if using the standard SAX
  53. * interface).
  54. *
  55. * Returns 0, -1 in case of error. the parser context is augmented
  56. * as a result of the parsing.
  57. */
  58. int
  59. docbParseDocument(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
  60. {
  61. static int deprecated = 0;
  62. if (!deprecated) {
  63. xmlGenericError(xmlGenericErrorContext,
  64. "docbParseDocument() deprecated function reached\n");
  65. deprecated = 1;
  66. }
  67. return (xmlParseDocument(ctxt));
  68. }
  69. /**
  70. * docbFreeParserCtxt:
  71. * @ctxt: an SGML parser context
  72. *
  73. * Free all the memory used by a parser context. However the parsed
  74. * document in ctxt->myDoc is not freed.
  75. */
  76. void
  77. docbFreeParserCtxt(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
  78. {
  79. static int deprecated = 0;
  80. if (!deprecated) {
  81. xmlGenericError(xmlGenericErrorContext,
  82. "docbFreeParserCtxt() deprecated function reached\n");
  83. deprecated = 1;
  84. }
  85. xmlFreeParserCtxt(ctxt);
  86. }
  87. /**
  88. * docbParseChunk:
  89. * @ctxt: an XML parser context
  90. * @chunk: an char array
  91. * @size: the size in byte of the chunk
  92. * @terminate: last chunk indicator
  93. *
  94. * Parse a Chunk of memory
  95. *
  96. * Returns zero if no error, the xmlParserErrors otherwise.
  97. */
  98. int
  99. docbParseChunk(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
  100. const char *chunk ATTRIBUTE_UNUSED,
  101. int size ATTRIBUTE_UNUSED,
  102. int terminate ATTRIBUTE_UNUSED)
  103. {
  104. static int deprecated = 0;
  105. if (!deprecated) {
  106. xmlGenericError(xmlGenericErrorContext,
  107. "docbParseChunk() deprecated function reached\n");
  108. deprecated = 1;
  109. }
  110. return (xmlParseChunk(ctxt, chunk, size, terminate));
  111. }
  112. /**
  113. * docbCreatePushParserCtxt:
  114. * @sax: a SAX handler
  115. * @user_data: The user data returned on SAX callbacks
  116. * @chunk: a pointer to an array of chars
  117. * @size: number of chars in the array
  118. * @filename: an optional file name or URI
  119. * @enc: an optional encoding
  120. *
  121. * Create a parser context for using the DocBook SGML parser in push mode
  122. * To allow content encoding detection, @size should be >= 4
  123. * The value of @filename is used for fetching external entities
  124. * and error/warning reports.
  125. *
  126. * Returns the new parser context or NULL
  127. */
  128. docbParserCtxtPtr
  129. docbCreatePushParserCtxt(docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
  130. void *user_data ATTRIBUTE_UNUSED,
  131. const char *chunk ATTRIBUTE_UNUSED,
  132. int size ATTRIBUTE_UNUSED,
  133. const char *filename ATTRIBUTE_UNUSED,
  134. xmlCharEncoding enc ATTRIBUTE_UNUSED)
  135. {
  136. static int deprecated = 0;
  137. if (!deprecated) {
  138. xmlGenericError(xmlGenericErrorContext,
  139. "docbParseChunk() deprecated function reached\n");
  140. deprecated = 1;
  141. }
  142. return(xmlCreatePushParserCtxt(sax, user_data, chunk, size, filename));
  143. }
  144. /**
  145. * docbSAXParseDoc:
  146. * @cur: a pointer to an array of xmlChar
  147. * @encoding: a free form C string describing the SGML document encoding, or NULL
  148. * @sax: the SAX handler block
  149. * @userData: if using SAX, this pointer will be provided on callbacks.
  150. *
  151. * parse an SGML in-memory document and build a tree.
  152. * It use the given SAX function block to handle the parsing callback.
  153. * If sax is NULL, fallback to the default DOM tree building routines.
  154. *
  155. * Returns the resulting document tree
  156. */
  157. docbDocPtr
  158. docbSAXParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
  159. const char *encoding ATTRIBUTE_UNUSED,
  160. docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
  161. void *userData ATTRIBUTE_UNUSED)
  162. {
  163. static int deprecated = 0;
  164. if (!deprecated) {
  165. xmlGenericError(xmlGenericErrorContext,
  166. "docbParseChunk() deprecated function reached\n");
  167. deprecated = 1;
  168. }
  169. return (xmlSAXParseMemoryWithData(sax, (const char *)cur,
  170. xmlStrlen((const xmlChar *) cur), 0, userData));
  171. }
  172. /**
  173. * docbParseDoc:
  174. * @cur: a pointer to an array of xmlChar
  175. * @encoding: a free form C string describing the SGML document encoding, or NULL
  176. *
  177. * parse an SGML in-memory document and build a tree.
  178. *
  179. * Returns the resulting document tree
  180. */
  181. docbDocPtr
  182. docbParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
  183. const char *encoding ATTRIBUTE_UNUSED)
  184. {
  185. static int deprecated = 0;
  186. if (!deprecated) {
  187. xmlGenericError(xmlGenericErrorContext,
  188. "docbParseChunk() deprecated function reached\n");
  189. deprecated = 1;
  190. }
  191. return (xmlParseDoc(cur));
  192. }
  193. /**
  194. * docbCreateFileParserCtxt:
  195. * @filename: the filename
  196. * @encoding: the SGML document encoding, or NULL
  197. *
  198. * Create a parser context for a file content.
  199. * Automatic support for ZLIB/Compress compressed document is provided
  200. * by default if found at compile-time.
  201. *
  202. * Returns the new parser context or NULL
  203. */
  204. docbParserCtxtPtr
  205. docbCreateFileParserCtxt(const char *filename ATTRIBUTE_UNUSED,
  206. const char *encoding ATTRIBUTE_UNUSED)
  207. {
  208. static int deprecated = 0;
  209. if (!deprecated) {
  210. xmlGenericError(xmlGenericErrorContext,
  211. "docbCreateFileParserCtxt() deprecated function reached\n");
  212. deprecated = 1;
  213. }
  214. return (xmlCreateFileParserCtxt(filename));
  215. }
  216. /**
  217. * docbSAXParseFile:
  218. * @filename: the filename
  219. * @encoding: a free form C string describing the SGML document encoding, or NULL
  220. * @sax: the SAX handler block
  221. * @userData: if using SAX, this pointer will be provided on callbacks.
  222. *
  223. * parse an SGML file and build a tree. Automatic support for ZLIB/Compress
  224. * compressed document is provided by default if found at compile-time.
  225. * It use the given SAX function block to handle the parsing callback.
  226. * If sax is NULL, fallback to the default DOM tree building routines.
  227. *
  228. * Returns the resulting document tree
  229. */
  230. docbDocPtr
  231. docbSAXParseFile(const char *filename ATTRIBUTE_UNUSED,
  232. const char *encoding ATTRIBUTE_UNUSED,
  233. docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
  234. void *userData ATTRIBUTE_UNUSED)
  235. {
  236. static int deprecated = 0;
  237. if (!deprecated) {
  238. xmlGenericError(xmlGenericErrorContext,
  239. "docbSAXParseFile() deprecated function reached\n");
  240. deprecated = 1;
  241. }
  242. return (xmlSAXParseFileWithData(sax, filename, 0, userData));
  243. }
  244. /**
  245. * docbParseFile:
  246. * @filename: the filename
  247. * @encoding: a free form C string describing document encoding, or NULL
  248. *
  249. * parse a Docbook SGML file and build a tree. Automatic support for
  250. * ZLIB/Compress compressed document is provided by default if found
  251. * at compile-time.
  252. *
  253. * Returns the resulting document tree
  254. */
  255. docbDocPtr
  256. docbParseFile(const char *filename ATTRIBUTE_UNUSED,
  257. const char *encoding ATTRIBUTE_UNUSED)
  258. {
  259. static int deprecated = 0;
  260. if (!deprecated) {
  261. xmlGenericError(xmlGenericErrorContext,
  262. "docbParseFile() deprecated function reached\n");
  263. deprecated = 1;
  264. }
  265. return (xmlParseFile(filename));
  266. }
  267. #define bottom_DOCBparser
  268. #include "elfgcchack.h"
  269. #endif /* LIBXML_DOCB_ENABLED */