2 * Summary: interface for the I/O interfaces used by the parser
3 * Description: interface for the I/O interfaces used by the parser
5 * Copy: See Copyright for the status of this software.
7 * Author: Daniel Veillard
14 #include <libxml/xmlversion.h>
21 * Those are the functions and datatypes for the parser input
26 * xmlInputMatchCallback:
27 * @filename: the filename or URI
29 * Callback used in the I/O Input API to detect if the current handler
30 * can provide input fonctionnalities for this resource.
32 * Returns 1 if yes and 0 if another Input module should be used
34 typedef int (XMLCALL
*xmlInputMatchCallback
) (char const *filename
);
36 * xmlInputOpenCallback:
37 * @filename: the filename or URI
39 * Callback used in the I/O Input API to open the resource
41 * Returns an Input context or NULL in case or error
43 typedef void * (XMLCALL
*xmlInputOpenCallback
) (char const *filename
);
45 * xmlInputReadCallback:
46 * @context: an Input context
47 * @buffer: the buffer to store data read
48 * @len: the length of the buffer in bytes
50 * Callback used in the I/O Input API to read the resource
52 * Returns the number of bytes read or -1 in case of error
54 typedef int (XMLCALL
*xmlInputReadCallback
) (void * context
, char * buffer
, int len
);
56 * xmlInputCloseCallback:
57 * @context: an Input context
59 * Callback used in the I/O Input API to close the resource
61 * Returns 0 or -1 in case of error
63 typedef int (XMLCALL
*xmlInputCloseCallback
) (void * context
);
65 #ifdef LIBXML_OUTPUT_ENABLED
67 * Those are the functions and datatypes for the library output
72 * xmlOutputMatchCallback:
73 * @filename: the filename or URI
75 * Callback used in the I/O Output API to detect if the current handler
76 * can provide output fonctionnalities for this resource.
78 * Returns 1 if yes and 0 if another Output module should be used
80 typedef int (XMLCALL
*xmlOutputMatchCallback
) (char const *filename
);
82 * xmlOutputOpenCallback:
83 * @filename: the filename or URI
85 * Callback used in the I/O Output API to open the resource
87 * Returns an Output context or NULL in case or error
89 typedef void * (XMLCALL
*xmlOutputOpenCallback
) (char const *filename
);
91 * xmlOutputWriteCallback:
92 * @context: an Output context
93 * @buffer: the buffer of data to write
94 * @len: the length of the buffer in bytes
96 * Callback used in the I/O Output API to write to the resource
98 * Returns the number of bytes written or -1 in case of error
100 typedef int (XMLCALL
*xmlOutputWriteCallback
) (void * context
, const char * buffer
,
103 * xmlOutputCloseCallback:
104 * @context: an Output context
106 * Callback used in the I/O Output API to close the resource
108 * Returns 0 or -1 in case of error
110 typedef int (XMLCALL
*xmlOutputCloseCallback
) (void * context
);
111 #endif /* LIBXML_OUTPUT_ENABLED */
117 #include <libxml/globals.h>
118 #include <libxml/tree.h>
119 #include <libxml/parser.h>
120 #include <libxml/encoding.h>
125 struct _xmlParserInputBuffer
{
127 xmlInputReadCallback readcallback
;
128 xmlInputCloseCallback closecallback
;
130 xmlCharEncodingHandlerPtr encoder
; /* I18N conversions to UTF-8 */
132 xmlBufPtr buffer
; /* Local buffer encoded in UTF-8 */
133 xmlBufPtr raw
; /* if encoder != NULL buffer for raw input */
134 int compressed
; /* -1=unknown, 0=not compressed, 1=compressed */
136 unsigned long rawconsumed
;/* amount consumed from raw */
140 #ifdef LIBXML_OUTPUT_ENABLED
141 struct _xmlOutputBuffer
{
143 xmlOutputWriteCallback writecallback
;
144 xmlOutputCloseCallback closecallback
;
146 xmlCharEncodingHandlerPtr encoder
; /* I18N conversions to UTF-8 */
148 xmlBufPtr buffer
; /* Local buffer encoded in UTF-8 or ISOLatin */
149 xmlBufPtr conv
; /* if encoder != NULL buffer for output */
150 int written
; /* total number of byte written */
153 #endif /* LIBXML_OUTPUT_ENABLED */
156 * Interfaces for input
158 XMLPUBFUN
void XMLCALL
159 xmlCleanupInputCallbacks (void);
161 XMLPUBFUN
int XMLCALL
162 xmlPopInputCallbacks (void);
164 XMLPUBFUN
void XMLCALL
165 xmlRegisterDefaultInputCallbacks (void);
166 XMLPUBFUN xmlParserInputBufferPtr XMLCALL
167 xmlAllocParserInputBuffer (xmlCharEncoding enc
);
169 XMLPUBFUN xmlParserInputBufferPtr XMLCALL
170 xmlParserInputBufferCreateFilename (const char *URI
,
171 xmlCharEncoding enc
);
172 XMLPUBFUN xmlParserInputBufferPtr XMLCALL
173 xmlParserInputBufferCreateFile (FILE *file
,
174 xmlCharEncoding enc
);
175 XMLPUBFUN xmlParserInputBufferPtr XMLCALL
176 xmlParserInputBufferCreateFd (int fd
,
177 xmlCharEncoding enc
);
178 XMLPUBFUN xmlParserInputBufferPtr XMLCALL
179 xmlParserInputBufferCreateMem (const char *mem
, int size
,
180 xmlCharEncoding enc
);
181 XMLPUBFUN xmlParserInputBufferPtr XMLCALL
182 xmlParserInputBufferCreateStatic (const char *mem
, int size
,
183 xmlCharEncoding enc
);
184 XMLPUBFUN xmlParserInputBufferPtr XMLCALL
185 xmlParserInputBufferCreateIO (xmlInputReadCallback ioread
,
186 xmlInputCloseCallback ioclose
,
188 xmlCharEncoding enc
);
189 XMLPUBFUN
int XMLCALL
190 xmlParserInputBufferRead (xmlParserInputBufferPtr in
,
192 XMLPUBFUN
int XMLCALL
193 xmlParserInputBufferGrow (xmlParserInputBufferPtr in
,
195 XMLPUBFUN
int XMLCALL
196 xmlParserInputBufferPush (xmlParserInputBufferPtr in
,
199 XMLPUBFUN
void XMLCALL
200 xmlFreeParserInputBuffer (xmlParserInputBufferPtr in
);
201 XMLPUBFUN
char * XMLCALL
202 xmlParserGetDirectory (const char *filename
);
204 XMLPUBFUN
int XMLCALL
205 xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc
,
206 xmlInputOpenCallback openFunc
,
207 xmlInputReadCallback readFunc
,
208 xmlInputCloseCallback closeFunc
);
210 xmlParserInputBufferPtr
211 __xmlParserInputBufferCreateFilename(const char *URI
,
212 xmlCharEncoding enc
);
214 #ifdef LIBXML_OUTPUT_ENABLED
216 * Interfaces for output
218 XMLPUBFUN
void XMLCALL
219 xmlCleanupOutputCallbacks (void);
220 XMLPUBFUN
void XMLCALL
221 xmlRegisterDefaultOutputCallbacks(void);
222 XMLPUBFUN xmlOutputBufferPtr XMLCALL
223 xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder
);
225 XMLPUBFUN xmlOutputBufferPtr XMLCALL
226 xmlOutputBufferCreateFilename (const char *URI
,
227 xmlCharEncodingHandlerPtr encoder
,
230 XMLPUBFUN xmlOutputBufferPtr XMLCALL
231 xmlOutputBufferCreateFile (FILE *file
,
232 xmlCharEncodingHandlerPtr encoder
);
234 XMLPUBFUN xmlOutputBufferPtr XMLCALL
235 xmlOutputBufferCreateBuffer (xmlBufferPtr buffer
,
236 xmlCharEncodingHandlerPtr encoder
);
238 XMLPUBFUN xmlOutputBufferPtr XMLCALL
239 xmlOutputBufferCreateFd (int fd
,
240 xmlCharEncodingHandlerPtr encoder
);
242 XMLPUBFUN xmlOutputBufferPtr XMLCALL
243 xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite
,
244 xmlOutputCloseCallback ioclose
,
246 xmlCharEncodingHandlerPtr encoder
);
248 /* Couple of APIs to get the output without digging into the buffers */
249 XMLPUBFUN
const xmlChar
* XMLCALL
250 xmlOutputBufferGetContent (xmlOutputBufferPtr out
);
251 XMLPUBFUN
size_t XMLCALL
252 xmlOutputBufferGetSize (xmlOutputBufferPtr out
);
254 XMLPUBFUN
int XMLCALL
255 xmlOutputBufferWrite (xmlOutputBufferPtr out
,
258 XMLPUBFUN
int XMLCALL
259 xmlOutputBufferWriteString (xmlOutputBufferPtr out
,
261 XMLPUBFUN
int XMLCALL
262 xmlOutputBufferWriteEscape (xmlOutputBufferPtr out
,
264 xmlCharEncodingOutputFunc escaping
);
266 XMLPUBFUN
int XMLCALL
267 xmlOutputBufferFlush (xmlOutputBufferPtr out
);
268 XMLPUBFUN
int XMLCALL
269 xmlOutputBufferClose (xmlOutputBufferPtr out
);
271 XMLPUBFUN
int XMLCALL
272 xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc
,
273 xmlOutputOpenCallback openFunc
,
274 xmlOutputWriteCallback writeFunc
,
275 xmlOutputCloseCallback closeFunc
);
278 __xmlOutputBufferCreateFilename(const char *URI
,
279 xmlCharEncodingHandlerPtr encoder
,
282 #ifdef LIBXML_HTTP_ENABLED
283 /* This function only exists if HTTP support built into the library */
284 XMLPUBFUN
void XMLCALL
285 xmlRegisterHTTPPostCallbacks (void );
286 #endif /* LIBXML_HTTP_ENABLED */
288 #endif /* LIBXML_OUTPUT_ENABLED */
290 XMLPUBFUN xmlParserInputPtr XMLCALL
291 xmlCheckHTTPInput (xmlParserCtxtPtr ctxt
,
292 xmlParserInputPtr ret
);
295 * A predefined entity loader disabling network accesses
297 XMLPUBFUN xmlParserInputPtr XMLCALL
298 xmlNoNetExternalEntityLoader (const char *URL
,
300 xmlParserCtxtPtr ctxt
);
303 * xmlNormalizeWindowsPath is obsolete, don't use it.
304 * Check xmlCanonicPath in uri.h for a better alternative.
306 XMLPUBFUN xmlChar
* XMLCALL
307 xmlNormalizeWindowsPath (const xmlChar
*path
);
309 XMLPUBFUN
int XMLCALL
310 xmlCheckFilename (const char *path
);
312 * Default 'file://' protocol callbacks
314 XMLPUBFUN
int XMLCALL
315 xmlFileMatch (const char *filename
);
316 XMLPUBFUN
void * XMLCALL
317 xmlFileOpen (const char *filename
);
318 XMLPUBFUN
int XMLCALL
319 xmlFileRead (void * context
,
322 XMLPUBFUN
int XMLCALL
323 xmlFileClose (void * context
);
326 * Default 'http://' protocol callbacks
328 #ifdef LIBXML_HTTP_ENABLED
329 XMLPUBFUN
int XMLCALL
330 xmlIOHTTPMatch (const char *filename
);
331 XMLPUBFUN
void * XMLCALL
332 xmlIOHTTPOpen (const char *filename
);
333 #ifdef LIBXML_OUTPUT_ENABLED
334 XMLPUBFUN
void * XMLCALL
335 xmlIOHTTPOpenW (const char * post_uri
,
337 #endif /* LIBXML_OUTPUT_ENABLED */
338 XMLPUBFUN
int XMLCALL
339 xmlIOHTTPRead (void * context
,
342 XMLPUBFUN
int XMLCALL
343 xmlIOHTTPClose (void * context
);
344 #endif /* LIBXML_HTTP_ENABLED */
347 * Default 'ftp://' protocol callbacks
349 #ifdef LIBXML_FTP_ENABLED
350 XMLPUBFUN
int XMLCALL
351 xmlIOFTPMatch (const char *filename
);
352 XMLPUBFUN
void * XMLCALL
353 xmlIOFTPOpen (const char *filename
);
354 XMLPUBFUN
int XMLCALL
355 xmlIOFTPRead (void * context
,
358 XMLPUBFUN
int XMLCALL
359 xmlIOFTPClose (void * context
);
360 #endif /* LIBXML_FTP_ENABLED */
366 #endif /* __XML_IO_H__ */