blob: 690a492e5bd88b19a1ccab39aa3aaa225eec22a8 [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +00001/*
2 * xmlIO.h : interface for the I/O interfaces used by the parser
3 *
4 * See Copyright for the status of this software.
5 *
Daniel Veillardc5d64342001-06-24 12:13:24 +00006 * daniel@veillard.com
Owen Taylor3473f882001-02-23 17:55:21 +00007 *
Owen Taylor3473f882001-02-23 17:55:21 +00008 */
9
10#ifndef __XML_IO_H__
11#define __XML_IO_H__
12
13#include <stdio.h>
Daniel Veillardf012a642001-07-23 19:10:52 +000014#include <libxml/xmlversion.h>
Owen Taylor3473f882001-02-23 17:55:21 +000015
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/*
21 * Those are the functions and datatypes for the parser input
22 * I/O structures.
23 */
24
Daniel Veillard9d06d302002-01-22 18:15:52 +000025/**
26 * xmlInputMatchCallback:
27 * @filename: the filename or URI
28 *
29 * Callback used in the I/O Input API to detect if the current handler
30 * can provide input fonctionnalities for this resource.
31 *
32 * Returns 1 if yes and 0 if another Input module should be used
33 */
Owen Taylor3473f882001-02-23 17:55:21 +000034typedef int (*xmlInputMatchCallback) (char const *filename);
Daniel Veillard9d06d302002-01-22 18:15:52 +000035/**
36 * xmlInputOpenCallback:
37 * @filename: the filename or URI
38 *
39 * Callback used in the I/O Input API to open the resource
40 *
41 * Returns an Input context or NULL in case or error
42 */
Owen Taylor3473f882001-02-23 17:55:21 +000043typedef void * (*xmlInputOpenCallback) (char const *filename);
Daniel Veillard9d06d302002-01-22 18:15:52 +000044/**
45 * xmlInputReadCallback:
46 * @context: an Input context
47 * @buffer: the buffer to store data read
48 * @len: the length of the buffer in bytes
49 *
50 * Callback used in the I/O Input API to read the resource
51 *
52 * Returns the number of bytes read or -1 in case of error
53 */
Owen Taylor3473f882001-02-23 17:55:21 +000054typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
Daniel Veillard9d06d302002-01-22 18:15:52 +000055/**
56 * xmlInputCloseCallback:
57 * @context: an Input context
58 *
59 * Callback used in the I/O Input API to close the resource
60 *
61 * Returns 0 or -1 in case of error
62 */
Daniel Veillardf012a642001-07-23 19:10:52 +000063typedef int (*xmlInputCloseCallback) (void * context);
Owen Taylor3473f882001-02-23 17:55:21 +000064
Daniel Veillarda9cce9c2003-09-29 13:20:24 +000065#ifdef LIBXML_OUTPUT_ENABLED
Owen Taylor3473f882001-02-23 17:55:21 +000066/*
67 * Those are the functions and datatypes for the library output
68 * I/O structures.
69 */
70
Daniel Veillard9d06d302002-01-22 18:15:52 +000071/**
72 * xmlOutputMatchCallback:
73 * @filename: the filename or URI
74 *
75 * Callback used in the I/O Output API to detect if the current handler
76 * can provide output fonctionnalities for this resource.
77 *
78 * Returns 1 if yes and 0 if another Output module should be used
79 */
Owen Taylor3473f882001-02-23 17:55:21 +000080typedef int (*xmlOutputMatchCallback) (char const *filename);
Daniel Veillard9d06d302002-01-22 18:15:52 +000081/**
82 * xmlOutputOpenCallback:
83 * @filename: the filename or URI
84 *
85 * Callback used in the I/O Output API to open the resource
86 *
87 * Returns an Output context or NULL in case or error
88 */
Owen Taylor3473f882001-02-23 17:55:21 +000089typedef void * (*xmlOutputOpenCallback) (char const *filename);
Daniel Veillard9d06d302002-01-22 18:15:52 +000090/**
91 * xmlOutputWriteCallback:
92 * @context: an Output context
93 * @buffer: the buffer of data to write
94 * @len: the length of the buffer in bytes
95 *
96 * Callback used in the I/O Output API to write to the resource
97 *
98 * Returns the number of bytes written or -1 in case of error
99 */
Owen Taylor3473f882001-02-23 17:55:21 +0000100typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
101 int len);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000102/**
103 * xmlOutputCloseCallback:
104 * @context: an Output context
105 *
106 * Callback used in the I/O Output API to close the resource
107 *
108 * Returns 0 or -1 in case of error
109 */
Daniel Veillardf012a642001-07-23 19:10:52 +0000110typedef int (*xmlOutputCloseCallback) (void * context);
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000111#endif /* LIBXML_OUTPUT_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +0000112
Daniel Veillarda8a89fe2002-04-12 21:03:34 +0000113#ifdef __cplusplus
114}
115#endif
116
117#include <libxml/globals.h>
118#include <libxml/tree.h>
119#include <libxml/parser.h>
120#include <libxml/encoding.h>
121
122#ifdef __cplusplus
123extern "C" {
124#endif
125struct _xmlParserInputBuffer {
126 void* context;
127 xmlInputReadCallback readcallback;
128 xmlInputCloseCallback closecallback;
129
130 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
131
132 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
133 xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
William M. Brackc07329e2003-09-08 01:57:30 +0000134 int compressed; /* -1=unknown, 0=not compressed, 1=compressed */
Daniel Veillard97bf4d02003-10-08 18:58:28 +0000135 int error;
Daniel Veillarda8a89fe2002-04-12 21:03:34 +0000136};
137
138
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000139#ifdef LIBXML_OUTPUT_ENABLED
Owen Taylor3473f882001-02-23 17:55:21 +0000140struct _xmlOutputBuffer {
141 void* context;
142 xmlOutputWriteCallback writecallback;
143 xmlOutputCloseCallback closecallback;
144
145 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
146
147 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
148 xmlBufferPtr conv; /* if encoder != NULL buffer for output */
149 int written; /* total number of byte written */
Daniel Veillard97bf4d02003-10-08 18:58:28 +0000150 int error;
Owen Taylor3473f882001-02-23 17:55:21 +0000151};
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000152#endif /* LIBXML_OUTPUT_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +0000153
154/*
155 * Interfaces for input
156 */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000157XMLPUBFUN void XMLCALL
158 xmlCleanupInputCallbacks (void);
Owen Taylor3473f882001-02-23 17:55:21 +0000159
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000160XMLPUBFUN void XMLCALL
161 xmlRegisterDefaultInputCallbacks (void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000162XMLPUBFUN xmlParserInputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000163 xmlAllocParserInputBuffer (xmlCharEncoding enc);
164
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000165XMLPUBFUN xmlParserInputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000166 xmlParserInputBufferCreateFilename (const char *URI,
167 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000168XMLPUBFUN xmlParserInputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000169 xmlParserInputBufferCreateFile (FILE *file,
170 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000171XMLPUBFUN xmlParserInputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000172 xmlParserInputBufferCreateFd (int fd,
173 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000174XMLPUBFUN xmlParserInputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000175 xmlParserInputBufferCreateMem (const char *mem, int size,
176 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000177XMLPUBFUN xmlParserInputBufferPtr XMLCALL
Daniel Veillard53350552003-09-18 13:35:51 +0000178 xmlParserInputBufferCreateStatic (const char *mem, int size,
179 xmlCharEncoding enc);
180XMLPUBFUN xmlParserInputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000181 xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
182 xmlInputCloseCallback ioclose,
183 void *ioctx,
184 xmlCharEncoding enc);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000185XMLPUBFUN int XMLCALL
186 xmlParserInputBufferRead (xmlParserInputBufferPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000187 int len);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000188XMLPUBFUN int XMLCALL
189 xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000190 int len);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000191XMLPUBFUN int XMLCALL
192 xmlParserInputBufferPush (xmlParserInputBufferPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000193 int len,
194 const char *buf);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000195XMLPUBFUN void XMLCALL
196 xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
197XMLPUBFUN char * XMLCALL
198 xmlParserGetDirectory (const char *filename);
Owen Taylor3473f882001-02-23 17:55:21 +0000199
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000200XMLPUBFUN int XMLCALL
201 xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000202 xmlInputOpenCallback openFunc,
203 xmlInputReadCallback readFunc,
204 xmlInputCloseCallback closeFunc);
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000205#ifdef LIBXML_OUTPUT_ENABLED
Owen Taylor3473f882001-02-23 17:55:21 +0000206/*
207 * Interfaces for output
208 */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000209XMLPUBFUN void XMLCALL
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000210 xmlCleanupOutputCallbacks (void);
211XMLPUBFUN void XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000212 xmlRegisterDefaultOutputCallbacks(void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000213XMLPUBFUN xmlOutputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000214 xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
215
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000216XMLPUBFUN xmlOutputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000217 xmlOutputBufferCreateFilename (const char *URI,
218 xmlCharEncodingHandlerPtr encoder,
219 int compression);
220
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000221XMLPUBFUN xmlOutputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000222 xmlOutputBufferCreateFile (FILE *file,
223 xmlCharEncodingHandlerPtr encoder);
224
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000225XMLPUBFUN xmlOutputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000226 xmlOutputBufferCreateFd (int fd,
227 xmlCharEncodingHandlerPtr encoder);
228
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000229XMLPUBFUN xmlOutputBufferPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000230 xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
231 xmlOutputCloseCallback ioclose,
232 void *ioctx,
233 xmlCharEncodingHandlerPtr encoder);
234
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000235XMLPUBFUN int XMLCALL
236 xmlOutputBufferWrite (xmlOutputBufferPtr out,
Owen Taylor3473f882001-02-23 17:55:21 +0000237 int len,
238 const char *buf);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000239XMLPUBFUN int XMLCALL
240 xmlOutputBufferWriteString (xmlOutputBufferPtr out,
Owen Taylor3473f882001-02-23 17:55:21 +0000241 const char *str);
242
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000243XMLPUBFUN int XMLCALL
244 xmlOutputBufferFlush (xmlOutputBufferPtr out);
245XMLPUBFUN int XMLCALL
246 xmlOutputBufferClose (xmlOutputBufferPtr out);
Owen Taylor3473f882001-02-23 17:55:21 +0000247
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000248XMLPUBFUN int XMLCALL
249 xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000250 xmlOutputOpenCallback openFunc,
251 xmlOutputWriteCallback writeFunc,
252 xmlOutputCloseCallback closeFunc);
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000253#endif /* LIBXML_OUTPUT_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +0000254
Daniel Veillardf012a642001-07-23 19:10:52 +0000255/* This function only exists if HTTP support built into the library */
256#ifdef LIBXML_HTTP_ENABLED
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000257XMLPUBFUN void * XMLCALL
258 xmlIOHTTPOpenW (const char * post_uri,
Daniel Veillardf012a642001-07-23 19:10:52 +0000259 int compression );
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000260XMLPUBFUN void XMLCALL
261 xmlRegisterHTTPPostCallbacks (void );
Daniel Veillardf012a642001-07-23 19:10:52 +0000262#endif
263
Owen Taylor3473f882001-02-23 17:55:21 +0000264/*
Daniel Veillard8bdb91d2001-10-31 17:52:43 +0000265 * A predefined entity loader disabling network accesses
266 */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000267XMLPUBFUN xmlParserInputPtr XMLCALL
268 xmlNoNetExternalEntityLoader (const char *URL,
Daniel Veillard8bdb91d2001-10-31 17:52:43 +0000269 const char *ID,
270 xmlParserCtxtPtr ctxt);
271
Igor Zlatkovic5f9fada2003-02-19 14:51:00 +0000272/*
273 * xmlNormalizeWindowsPath is obsolete, don't use it.
274 * Check xmlCanonicPath in uri.h for a better alternative.
275 */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000276XMLPUBFUN xmlChar * XMLCALL
277 xmlNormalizeWindowsPath (const xmlChar *path);
Aleksey Sanin5aac8b82002-05-01 18:32:28 +0000278
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000279XMLPUBFUN int XMLCALL
280 xmlCheckFilename (const char *path);
Aleksey Sanin5aac8b82002-05-01 18:32:28 +0000281/**
282 * Default 'file://' protocol callbacks
283 */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000284XMLPUBFUN int XMLCALL
285 xmlFileMatch (const char *filename);
286XMLPUBFUN void * XMLCALL
287 xmlFileOpen (const char *filename);
288XMLPUBFUN int XMLCALL
289 xmlFileRead (void * context,
Aleksey Sanin5aac8b82002-05-01 18:32:28 +0000290 char * buffer,
291 int len);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000292XMLPUBFUN int XMLCALL
293 xmlFileClose (void * context);
Aleksey Sanin5aac8b82002-05-01 18:32:28 +0000294
295/**
296 * Default 'http://' protocol callbacks
297 */
298#ifdef LIBXML_HTTP_ENABLED
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000299XMLPUBFUN int XMLCALL
300 xmlIOHTTPMatch (const char *filename);
301XMLPUBFUN void * XMLCALL
302 xmlIOHTTPOpen (const char *filename);
303XMLPUBFUN int XMLCALL
304 xmlIOHTTPRead (void * context,
Aleksey Sanin5aac8b82002-05-01 18:32:28 +0000305 char * buffer,
306 int len);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000307XMLPUBFUN int XMLCALL
308 xmlIOHTTPClose (void * context);
Aleksey Sanin5aac8b82002-05-01 18:32:28 +0000309#endif /* LIBXML_HTTP_ENABLED */
310
311/**
312 * Default 'ftp://' protocol callbacks
313 */
314#ifdef LIBXML_FTP_ENABLED
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000315XMLPUBFUN int XMLCALL
316 xmlIOFTPMatch (const char *filename);
317XMLPUBFUN void * XMLCALL
318 xmlIOFTPOpen (const char *filename);
319XMLPUBFUN int XMLCALL
320 xmlIOFTPRead (void * context,
Aleksey Sanin5aac8b82002-05-01 18:32:28 +0000321 char * buffer,
322 int len);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000323XMLPUBFUN int XMLCALL
324 xmlIOFTPClose (void * context);
Aleksey Sanin5aac8b82002-05-01 18:32:28 +0000325#endif /* LIBXML_FTP_ENABLED */
326
Owen Taylor3473f882001-02-23 17:55:21 +0000327#ifdef __cplusplus
328}
329#endif
330
331#endif /* __XML_IO_H__ */