xmlIO.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /*
  2. * Summary: interface for the I/O interfaces used by the parser
  3. * Description: interface for the I/O interfaces used by the parser
  4. *
  5. * Copy: See Copyright for the status of this software.
  6. *
  7. * Author: Daniel Veillard
  8. */
  9. #ifndef __XML_IO_H__
  10. #define __XML_IO_H__
  11. #include <stdio.h>
  12. #include <libxml/xmlversion.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /*
  17. * Those are the functions and datatypes for the parser input
  18. * I/O structures.
  19. */
  20. /**
  21. * xmlInputMatchCallback:
  22. * @filename: the filename or URI
  23. *
  24. * Callback used in the I/O Input API to detect if the current handler
  25. * can provide input fonctionnalities for this resource.
  26. *
  27. * Returns 1 if yes and 0 if another Input module should be used
  28. */
  29. typedef int (XMLCALL *xmlInputMatchCallback) (char const *filename);
  30. /**
  31. * xmlInputOpenCallback:
  32. * @filename: the filename or URI
  33. *
  34. * Callback used in the I/O Input API to open the resource
  35. *
  36. * Returns an Input context or NULL in case or error
  37. */
  38. typedef void * (XMLCALL *xmlInputOpenCallback) (char const *filename);
  39. /**
  40. * xmlInputReadCallback:
  41. * @context: an Input context
  42. * @buffer: the buffer to store data read
  43. * @len: the length of the buffer in bytes
  44. *
  45. * Callback used in the I/O Input API to read the resource
  46. *
  47. * Returns the number of bytes read or -1 in case of error
  48. */
  49. typedef int (XMLCALL *xmlInputReadCallback) (void * context, char * buffer, int len);
  50. /**
  51. * xmlInputCloseCallback:
  52. * @context: an Input context
  53. *
  54. * Callback used in the I/O Input API to close the resource
  55. *
  56. * Returns 0 or -1 in case of error
  57. */
  58. typedef int (XMLCALL *xmlInputCloseCallback) (void * context);
  59. #ifdef LIBXML_OUTPUT_ENABLED
  60. /*
  61. * Those are the functions and datatypes for the library output
  62. * I/O structures.
  63. */
  64. /**
  65. * xmlOutputMatchCallback:
  66. * @filename: the filename or URI
  67. *
  68. * Callback used in the I/O Output API to detect if the current handler
  69. * can provide output fonctionnalities for this resource.
  70. *
  71. * Returns 1 if yes and 0 if another Output module should be used
  72. */
  73. typedef int (XMLCALL *xmlOutputMatchCallback) (char const *filename);
  74. /**
  75. * xmlOutputOpenCallback:
  76. * @filename: the filename or URI
  77. *
  78. * Callback used in the I/O Output API to open the resource
  79. *
  80. * Returns an Output context or NULL in case or error
  81. */
  82. typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename);
  83. /**
  84. * xmlOutputWriteCallback:
  85. * @context: an Output context
  86. * @buffer: the buffer of data to write
  87. * @len: the length of the buffer in bytes
  88. *
  89. * Callback used in the I/O Output API to write to the resource
  90. *
  91. * Returns the number of bytes written or -1 in case of error
  92. */
  93. typedef int (XMLCALL *xmlOutputWriteCallback) (void * context, const char * buffer,
  94. int len);
  95. /**
  96. * xmlOutputCloseCallback:
  97. * @context: an Output context
  98. *
  99. * Callback used in the I/O Output API to close the resource
  100. *
  101. * Returns 0 or -1 in case of error
  102. */
  103. typedef int (XMLCALL *xmlOutputCloseCallback) (void * context);
  104. #endif /* LIBXML_OUTPUT_ENABLED */
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #include <libxml/globals.h>
  109. #include <libxml/tree.h>
  110. #include <libxml/parser.h>
  111. #include <libxml/encoding.h>
  112. #ifdef __cplusplus
  113. extern "C" {
  114. #endif
  115. struct _xmlParserInputBuffer {
  116. void* context;
  117. xmlInputReadCallback readcallback;
  118. xmlInputCloseCallback closecallback;
  119. xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
  120. xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
  121. xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
  122. int compressed; /* -1=unknown, 0=not compressed, 1=compressed */
  123. int error;
  124. unsigned long rawconsumed;/* amount consumed from raw */
  125. };
  126. #ifdef LIBXML_OUTPUT_ENABLED
  127. struct _xmlOutputBuffer {
  128. void* context;
  129. xmlOutputWriteCallback writecallback;
  130. xmlOutputCloseCallback closecallback;
  131. xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
  132. xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
  133. xmlBufferPtr conv; /* if encoder != NULL buffer for output */
  134. int written; /* total number of byte written */
  135. int error;
  136. };
  137. #endif /* LIBXML_OUTPUT_ENABLED */
  138. /*
  139. * Interfaces for input
  140. */
  141. XMLPUBFUN void XMLCALL
  142. xmlCleanupInputCallbacks (void);
  143. XMLPUBFUN int XMLCALL
  144. xmlPopInputCallbacks (void);
  145. XMLPUBFUN void XMLCALL
  146. xmlRegisterDefaultInputCallbacks (void);
  147. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  148. xmlAllocParserInputBuffer (xmlCharEncoding enc);
  149. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  150. xmlParserInputBufferCreateFilename (const char *URI,
  151. xmlCharEncoding enc);
  152. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  153. xmlParserInputBufferCreateFile (FILE *file,
  154. xmlCharEncoding enc);
  155. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  156. xmlParserInputBufferCreateFd (int fd,
  157. xmlCharEncoding enc);
  158. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  159. xmlParserInputBufferCreateMem (const char *mem, int size,
  160. xmlCharEncoding enc);
  161. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  162. xmlParserInputBufferCreateStatic (const char *mem, int size,
  163. xmlCharEncoding enc);
  164. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  165. xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
  166. xmlInputCloseCallback ioclose,
  167. void *ioctx,
  168. xmlCharEncoding enc);
  169. XMLPUBFUN int XMLCALL
  170. xmlParserInputBufferRead (xmlParserInputBufferPtr in,
  171. int len);
  172. XMLPUBFUN int XMLCALL
  173. xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
  174. int len);
  175. XMLPUBFUN int XMLCALL
  176. xmlParserInputBufferPush (xmlParserInputBufferPtr in,
  177. int len,
  178. const char *buf);
  179. XMLPUBFUN void XMLCALL
  180. xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
  181. XMLPUBFUN char * XMLCALL
  182. xmlParserGetDirectory (const char *filename);
  183. XMLPUBFUN int XMLCALL
  184. xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
  185. xmlInputOpenCallback openFunc,
  186. xmlInputReadCallback readFunc,
  187. xmlInputCloseCallback closeFunc);
  188. xmlParserInputBufferPtr
  189. __xmlParserInputBufferCreateFilename(const char *URI,
  190. xmlCharEncoding enc);
  191. #ifdef LIBXML_OUTPUT_ENABLED
  192. /*
  193. * Interfaces for output
  194. */
  195. XMLPUBFUN void XMLCALL
  196. xmlCleanupOutputCallbacks (void);
  197. XMLPUBFUN void XMLCALL
  198. xmlRegisterDefaultOutputCallbacks(void);
  199. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  200. xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
  201. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  202. xmlOutputBufferCreateFilename (const char *URI,
  203. xmlCharEncodingHandlerPtr encoder,
  204. int compression);
  205. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  206. xmlOutputBufferCreateFile (FILE *file,
  207. xmlCharEncodingHandlerPtr encoder);
  208. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  209. xmlOutputBufferCreateBuffer (xmlBufferPtr buffer,
  210. xmlCharEncodingHandlerPtr encoder);
  211. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  212. xmlOutputBufferCreateFd (int fd,
  213. xmlCharEncodingHandlerPtr encoder);
  214. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  215. xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
  216. xmlOutputCloseCallback ioclose,
  217. void *ioctx,
  218. xmlCharEncodingHandlerPtr encoder);
  219. XMLPUBFUN int XMLCALL
  220. xmlOutputBufferWrite (xmlOutputBufferPtr out,
  221. int len,
  222. const char *buf);
  223. XMLPUBFUN int XMLCALL
  224. xmlOutputBufferWriteString (xmlOutputBufferPtr out,
  225. const char *str);
  226. XMLPUBFUN int XMLCALL
  227. xmlOutputBufferWriteEscape (xmlOutputBufferPtr out,
  228. const xmlChar *str,
  229. xmlCharEncodingOutputFunc escaping);
  230. XMLPUBFUN int XMLCALL
  231. xmlOutputBufferFlush (xmlOutputBufferPtr out);
  232. XMLPUBFUN int XMLCALL
  233. xmlOutputBufferClose (xmlOutputBufferPtr out);
  234. XMLPUBFUN int XMLCALL
  235. xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
  236. xmlOutputOpenCallback openFunc,
  237. xmlOutputWriteCallback writeFunc,
  238. xmlOutputCloseCallback closeFunc);
  239. xmlOutputBufferPtr
  240. __xmlOutputBufferCreateFilename(const char *URI,
  241. xmlCharEncodingHandlerPtr encoder,
  242. int compression);
  243. #ifdef LIBXML_HTTP_ENABLED
  244. /* This function only exists if HTTP support built into the library */
  245. XMLPUBFUN void XMLCALL
  246. xmlRegisterHTTPPostCallbacks (void );
  247. #endif /* LIBXML_HTTP_ENABLED */
  248. #endif /* LIBXML_OUTPUT_ENABLED */
  249. XMLPUBFUN xmlParserInputPtr XMLCALL
  250. xmlCheckHTTPInput (xmlParserCtxtPtr ctxt,
  251. xmlParserInputPtr ret);
  252. /*
  253. * A predefined entity loader disabling network accesses
  254. */
  255. XMLPUBFUN xmlParserInputPtr XMLCALL
  256. xmlNoNetExternalEntityLoader (const char *URL,
  257. const char *ID,
  258. xmlParserCtxtPtr ctxt);
  259. /*
  260. * xmlNormalizeWindowsPath is obsolete, don't use it.
  261. * Check xmlCanonicPath in uri.h for a better alternative.
  262. */
  263. XMLPUBFUN xmlChar * XMLCALL
  264. xmlNormalizeWindowsPath (const xmlChar *path);
  265. XMLPUBFUN int XMLCALL
  266. xmlCheckFilename (const char *path);
  267. /**
  268. * Default 'file://' protocol callbacks
  269. */
  270. XMLPUBFUN int XMLCALL
  271. xmlFileMatch (const char *filename);
  272. XMLPUBFUN void * XMLCALL
  273. xmlFileOpen (const char *filename);
  274. XMLPUBFUN int XMLCALL
  275. xmlFileRead (void * context,
  276. char * buffer,
  277. int len);
  278. XMLPUBFUN int XMLCALL
  279. xmlFileClose (void * context);
  280. /**
  281. * Default 'http://' protocol callbacks
  282. */
  283. #ifdef LIBXML_HTTP_ENABLED
  284. XMLPUBFUN int XMLCALL
  285. xmlIOHTTPMatch (const char *filename);
  286. XMLPUBFUN void * XMLCALL
  287. xmlIOHTTPOpen (const char *filename);
  288. #ifdef LIBXML_OUTPUT_ENABLED
  289. XMLPUBFUN void * XMLCALL
  290. xmlIOHTTPOpenW (const char * post_uri,
  291. int compression );
  292. #endif /* LIBXML_OUTPUT_ENABLED */
  293. XMLPUBFUN int XMLCALL
  294. xmlIOHTTPRead (void * context,
  295. char * buffer,
  296. int len);
  297. XMLPUBFUN int XMLCALL
  298. xmlIOHTTPClose (void * context);
  299. #endif /* LIBXML_HTTP_ENABLED */
  300. /**
  301. * Default 'ftp://' protocol callbacks
  302. */
  303. #ifdef LIBXML_FTP_ENABLED
  304. XMLPUBFUN int XMLCALL
  305. xmlIOFTPMatch (const char *filename);
  306. XMLPUBFUN void * XMLCALL
  307. xmlIOFTPOpen (const char *filename);
  308. XMLPUBFUN int XMLCALL
  309. xmlIOFTPRead (void * context,
  310. char * buffer,
  311. int len);
  312. XMLPUBFUN int XMLCALL
  313. xmlIOFTPClose (void * context);
  314. #endif /* LIBXML_FTP_ENABLED */
  315. #ifdef __cplusplus
  316. }
  317. #endif
  318. #endif /* __XML_IO_H__ */