xmlIO.h.svn-base
上传用户:szjkjd
上传日期:2022-06-27
资源大小:8968k
文件大小:10k
源码类别:

浏览器

开发平台:

Visual C++

  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.     
  120.     xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
  121.     
  122.     xmlBufferPtr buffer;    /* Local buffer encoded in UTF-8 */
  123.     xmlBufferPtr raw;       /* if encoder != NULL buffer for raw input */
  124.     int compressed;     /* -1=unknown, 0=not compressed, 1=compressed */
  125.     int error;
  126.     unsigned long rawconsumed;/* amount consumed from raw */
  127. };
  128. #ifdef LIBXML_OUTPUT_ENABLED
  129. struct _xmlOutputBuffer {
  130.     void*                   context;
  131.     xmlOutputWriteCallback  writecallback;
  132.     xmlOutputCloseCallback  closecallback;
  133.     
  134.     xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
  135.     
  136.     xmlBufferPtr buffer;    /* Local buffer encoded in UTF-8 or ISOLatin */
  137.     xmlBufferPtr conv;      /* if encoder != NULL buffer for output */
  138.     int written;            /* total number of byte written */
  139.     int error;
  140. };
  141. #endif /* LIBXML_OUTPUT_ENABLED */
  142. /*
  143.  * Interfaces for input
  144.  */
  145. XMLPUBFUN void XMLCALL
  146. xmlCleanupInputCallbacks (void);
  147. XMLPUBFUN int XMLCALL
  148. xmlPopInputCallbacks (void);
  149. XMLPUBFUN void XMLCALL
  150. xmlRegisterDefaultInputCallbacks (void);
  151. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  152. xmlAllocParserInputBuffer (xmlCharEncoding enc);
  153. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  154. xmlParserInputBufferCreateFilename (const char *URI,
  155.                                                  xmlCharEncoding enc);
  156. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  157. xmlParserInputBufferCreateFile (FILE *file,
  158.                                                  xmlCharEncoding enc);
  159. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  160. xmlParserInputBufferCreateFd (int fd,
  161.                                          xmlCharEncoding enc);
  162. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  163. xmlParserInputBufferCreateMem (const char *mem, int size,
  164.                                          xmlCharEncoding enc);
  165. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  166. xmlParserInputBufferCreateStatic (const char *mem, int size,
  167.                                          xmlCharEncoding enc);
  168. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  169. xmlParserInputBufferCreateIO (xmlInputReadCallback   ioread,
  170.  xmlInputCloseCallback  ioclose,
  171.  void *ioctx,
  172.                                          xmlCharEncoding enc);
  173. XMLPUBFUN int XMLCALL
  174. xmlParserInputBufferRead (xmlParserInputBufferPtr in,
  175.  int len);
  176. XMLPUBFUN int XMLCALL
  177. xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
  178.  int len);
  179. XMLPUBFUN int XMLCALL
  180. xmlParserInputBufferPush (xmlParserInputBufferPtr in,
  181.  int len,
  182.  const char *buf);
  183. XMLPUBFUN void XMLCALL
  184. xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
  185. XMLPUBFUN char * XMLCALL
  186. xmlParserGetDirectory (const char *filename);
  187. XMLPUBFUN int XMLCALL     
  188. xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
  189.  xmlInputOpenCallback openFunc,
  190.  xmlInputReadCallback readFunc,
  191.  xmlInputCloseCallback closeFunc);
  192. xmlParserInputBufferPtr
  193. __xmlParserInputBufferCreateFilename(const char *URI,
  194. xmlCharEncoding enc);
  195. #ifdef LIBXML_OUTPUT_ENABLED
  196. /*
  197.  * Interfaces for output
  198.  */
  199. XMLPUBFUN void XMLCALL
  200. xmlCleanupOutputCallbacks (void);
  201. XMLPUBFUN void XMLCALL
  202. xmlRegisterDefaultOutputCallbacks(void);
  203. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  204. xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
  205. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  206. xmlOutputBufferCreateFilename (const char *URI,
  207.  xmlCharEncodingHandlerPtr encoder,
  208.  int compression);
  209. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  210. xmlOutputBufferCreateFile (FILE *file,
  211.  xmlCharEncodingHandlerPtr encoder);
  212. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  213. xmlOutputBufferCreateBuffer (xmlBufferPtr buffer,
  214.  xmlCharEncodingHandlerPtr encoder);
  215. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  216. xmlOutputBufferCreateFd (int fd,
  217.  xmlCharEncodingHandlerPtr encoder);
  218. XMLPUBFUN xmlOutputBufferPtr XMLCALL
  219. xmlOutputBufferCreateIO (xmlOutputWriteCallback   iowrite,
  220.  xmlOutputCloseCallback  ioclose,
  221.  void *ioctx,
  222.  xmlCharEncodingHandlerPtr encoder);
  223. XMLPUBFUN int XMLCALL
  224. xmlOutputBufferWrite (xmlOutputBufferPtr out,
  225.  int len,
  226.  const char *buf);
  227. XMLPUBFUN int XMLCALL
  228. xmlOutputBufferWriteString (xmlOutputBufferPtr out,
  229.  const char *str);
  230. XMLPUBFUN int XMLCALL
  231. xmlOutputBufferWriteEscape (xmlOutputBufferPtr out,
  232.  const xmlChar *str,
  233.  xmlCharEncodingOutputFunc escaping);
  234. XMLPUBFUN int XMLCALL
  235. xmlOutputBufferFlush (xmlOutputBufferPtr out);
  236. XMLPUBFUN int XMLCALL
  237. xmlOutputBufferClose (xmlOutputBufferPtr out);
  238. XMLPUBFUN int XMLCALL     
  239. xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
  240.  xmlOutputOpenCallback openFunc,
  241.  xmlOutputWriteCallback writeFunc,
  242.  xmlOutputCloseCallback closeFunc);
  243. xmlOutputBufferPtr
  244. __xmlOutputBufferCreateFilename(const char *URI,
  245.                               xmlCharEncodingHandlerPtr encoder,
  246.                               int compression);
  247. #ifdef LIBXML_HTTP_ENABLED
  248. /*  This function only exists if HTTP support built into the library  */
  249. XMLPUBFUN void XMLCALL
  250. xmlRegisterHTTPPostCallbacks (void );
  251. #endif /* LIBXML_HTTP_ENABLED */
  252. #endif /* LIBXML_OUTPUT_ENABLED */
  253. XMLPUBFUN xmlParserInputPtr XMLCALL
  254. xmlCheckHTTPInput (xmlParserCtxtPtr ctxt,
  255.  xmlParserInputPtr ret);
  256. /*
  257.  * A predefined entity loader disabling network accesses
  258.  */
  259. XMLPUBFUN xmlParserInputPtr XMLCALL 
  260. xmlNoNetExternalEntityLoader (const char *URL,
  261.  const char *ID,
  262.  xmlParserCtxtPtr ctxt);
  263. /* 
  264.  * xmlNormalizeWindowsPath is obsolete, don't use it. 
  265.  * Check xmlCanonicPath in uri.h for a better alternative.
  266.  */
  267. XMLPUBFUN xmlChar * XMLCALL 
  268. xmlNormalizeWindowsPath (const xmlChar *path);
  269. XMLPUBFUN int XMLCALL
  270. xmlCheckFilename (const char *path);
  271. /**
  272.  * Default 'file://' protocol callbacks 
  273.  */
  274. XMLPUBFUN int XMLCALL
  275. xmlFileMatch  (const char *filename);
  276. XMLPUBFUN void * XMLCALL
  277. xmlFileOpen  (const char *filename);
  278. XMLPUBFUN int XMLCALL
  279. xmlFileRead  (void * context, 
  280.  char * buffer, 
  281.  int len);
  282. XMLPUBFUN int XMLCALL
  283. xmlFileClose  (void * context);
  284. /**
  285.  * Default 'http://' protocol callbacks 
  286.  */
  287. #ifdef LIBXML_HTTP_ENABLED
  288. XMLPUBFUN int XMLCALL
  289. xmlIOHTTPMatch  (const char *filename);
  290. XMLPUBFUN void * XMLCALL
  291. xmlIOHTTPOpen  (const char *filename);
  292. #ifdef LIBXML_OUTPUT_ENABLED
  293. XMLPUBFUN void * XMLCALL
  294. xmlIOHTTPOpenW (const char * post_uri,
  295.  int   compression );
  296. #endif /* LIBXML_OUTPUT_ENABLED */
  297. XMLPUBFUN int XMLCALL 
  298. xmlIOHTTPRead (void * context, 
  299.  char * buffer, 
  300.  int len);
  301. XMLPUBFUN int XMLCALL
  302. xmlIOHTTPClose  (void * context);
  303. #endif /* LIBXML_HTTP_ENABLED */
  304. /**
  305.  * Default 'ftp://' protocol callbacks 
  306.  */
  307. #ifdef LIBXML_FTP_ENABLED 
  308. XMLPUBFUN int XMLCALL
  309. xmlIOFTPMatch  (const char *filename);
  310. XMLPUBFUN void * XMLCALL
  311. xmlIOFTPOpen  (const char *filename);
  312. XMLPUBFUN int XMLCALL 
  313. xmlIOFTPRead (void * context, 
  314.  char * buffer, 
  315.  int len);
  316. XMLPUBFUN int XMLCALL 
  317. xmlIOFTPClose  (void * context);
  318. #endif /* LIBXML_FTP_ENABLED */
  319. #ifdef __cplusplus
  320. }
  321. #endif
  322. #endif /* __XML_IO_H__ */