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 |
|
---|
10 | #ifndef __XML_IO_H__
|
---|
11 | #define __XML_IO_H__
|
---|
12 |
|
---|
13 | /** DOC_DISABLE */
|
---|
14 | #include <stdio.h>
|
---|
15 | #include <libxml/xmlversion.h>
|
---|
16 | #include <libxml/encoding.h>
|
---|
17 | #define XML_TREE_INTERNALS
|
---|
18 | #include <libxml/tree.h>
|
---|
19 | #undef XML_TREE_INTERNALS
|
---|
20 | /** DOC_ENABLE */
|
---|
21 |
|
---|
22 | #ifdef __cplusplus
|
---|
23 | extern "C" {
|
---|
24 | #endif
|
---|
25 |
|
---|
26 | /*
|
---|
27 | * Those are the functions and datatypes for the parser input
|
---|
28 | * I/O structures.
|
---|
29 | */
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * xmlInputMatchCallback:
|
---|
33 | * @filename: the filename or URI
|
---|
34 | *
|
---|
35 | * Callback used in the I/O Input API to detect if the current handler
|
---|
36 | * can provide input functionality for this resource.
|
---|
37 | *
|
---|
38 | * Returns 1 if yes and 0 if another Input module should be used
|
---|
39 | */
|
---|
40 | typedef int (*xmlInputMatchCallback) (char const *filename);
|
---|
41 | /**
|
---|
42 | * xmlInputOpenCallback:
|
---|
43 | * @filename: the filename or URI
|
---|
44 | *
|
---|
45 | * Callback used in the I/O Input API to open the resource
|
---|
46 | *
|
---|
47 | * Returns an Input context or NULL in case or error
|
---|
48 | */
|
---|
49 | typedef void * (*xmlInputOpenCallback) (char const *filename);
|
---|
50 | /**
|
---|
51 | * xmlInputReadCallback:
|
---|
52 | * @context: an Input context
|
---|
53 | * @buffer: the buffer to store data read
|
---|
54 | * @len: the length of the buffer in bytes
|
---|
55 | *
|
---|
56 | * Callback used in the I/O Input API to read the resource
|
---|
57 | *
|
---|
58 | * Returns the number of bytes read or -1 in case of error
|
---|
59 | */
|
---|
60 | typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
|
---|
61 | /**
|
---|
62 | * xmlInputCloseCallback:
|
---|
63 | * @context: an Input context
|
---|
64 | *
|
---|
65 | * Callback used in the I/O Input API to close the resource
|
---|
66 | *
|
---|
67 | * Returns 0 or -1 in case of error
|
---|
68 | */
|
---|
69 | typedef int (*xmlInputCloseCallback) (void * context);
|
---|
70 |
|
---|
71 | #ifdef LIBXML_OUTPUT_ENABLED
|
---|
72 | /*
|
---|
73 | * Those are the functions and datatypes for the library output
|
---|
74 | * I/O structures.
|
---|
75 | */
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * xmlOutputMatchCallback:
|
---|
79 | * @filename: the filename or URI
|
---|
80 | *
|
---|
81 | * Callback used in the I/O Output API to detect if the current handler
|
---|
82 | * can provide output functionality for this resource.
|
---|
83 | *
|
---|
84 | * Returns 1 if yes and 0 if another Output module should be used
|
---|
85 | */
|
---|
86 | typedef int (*xmlOutputMatchCallback) (char const *filename);
|
---|
87 | /**
|
---|
88 | * xmlOutputOpenCallback:
|
---|
89 | * @filename: the filename or URI
|
---|
90 | *
|
---|
91 | * Callback used in the I/O Output API to open the resource
|
---|
92 | *
|
---|
93 | * Returns an Output context or NULL in case or error
|
---|
94 | */
|
---|
95 | typedef void * (*xmlOutputOpenCallback) (char const *filename);
|
---|
96 | /**
|
---|
97 | * xmlOutputWriteCallback:
|
---|
98 | * @context: an Output context
|
---|
99 | * @buffer: the buffer of data to write
|
---|
100 | * @len: the length of the buffer in bytes
|
---|
101 | *
|
---|
102 | * Callback used in the I/O Output API to write to the resource
|
---|
103 | *
|
---|
104 | * Returns the number of bytes written or -1 in case of error
|
---|
105 | */
|
---|
106 | typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
|
---|
107 | int len);
|
---|
108 | /**
|
---|
109 | * xmlOutputCloseCallback:
|
---|
110 | * @context: an Output context
|
---|
111 | *
|
---|
112 | * Callback used in the I/O Output API to close the resource
|
---|
113 | *
|
---|
114 | * Returns 0 or -1 in case of error
|
---|
115 | */
|
---|
116 | typedef int (*xmlOutputCloseCallback) (void * context);
|
---|
117 | #endif /* LIBXML_OUTPUT_ENABLED */
|
---|
118 |
|
---|
119 | /**
|
---|
120 | * xmlParserInputBufferCreateFilenameFunc:
|
---|
121 | * @URI: the URI to read from
|
---|
122 | * @enc: the requested source encoding
|
---|
123 | *
|
---|
124 | * Signature for the function doing the lookup for a suitable input method
|
---|
125 | * corresponding to an URI.
|
---|
126 | *
|
---|
127 | * Returns the new xmlParserInputBufferPtr in case of success or NULL if no
|
---|
128 | * method was found.
|
---|
129 | */
|
---|
130 | typedef xmlParserInputBufferPtr
|
---|
131 | (*xmlParserInputBufferCreateFilenameFunc)(const char *URI, xmlCharEncoding enc);
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * xmlOutputBufferCreateFilenameFunc:
|
---|
135 | * @URI: the URI to write to
|
---|
136 | * @enc: the requested target encoding
|
---|
137 | *
|
---|
138 | * Signature for the function doing the lookup for a suitable output method
|
---|
139 | * corresponding to an URI.
|
---|
140 | *
|
---|
141 | * Returns the new xmlOutputBufferPtr in case of success or NULL if no
|
---|
142 | * method was found.
|
---|
143 | */
|
---|
144 | typedef xmlOutputBufferPtr
|
---|
145 | (*xmlOutputBufferCreateFilenameFunc)(const char *URI,
|
---|
146 | xmlCharEncodingHandlerPtr encoder, int compression);
|
---|
147 |
|
---|
148 | struct _xmlParserInputBuffer {
|
---|
149 | void* context;
|
---|
150 | xmlInputReadCallback readcallback;
|
---|
151 | xmlInputCloseCallback closecallback;
|
---|
152 |
|
---|
153 | xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
---|
154 |
|
---|
155 | xmlBufPtr buffer; /* Local buffer encoded in UTF-8 */
|
---|
156 | xmlBufPtr raw; /* if encoder != NULL buffer for raw input */
|
---|
157 | int compressed; /* -1=unknown, 0=not compressed, 1=compressed */
|
---|
158 | int error;
|
---|
159 | unsigned long rawconsumed;/* amount consumed from raw */
|
---|
160 | };
|
---|
161 |
|
---|
162 |
|
---|
163 | #ifdef LIBXML_OUTPUT_ENABLED
|
---|
164 | struct _xmlOutputBuffer {
|
---|
165 | void* context;
|
---|
166 | xmlOutputWriteCallback writecallback;
|
---|
167 | xmlOutputCloseCallback closecallback;
|
---|
168 |
|
---|
169 | xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
---|
170 |
|
---|
171 | xmlBufPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
|
---|
172 | xmlBufPtr conv; /* if encoder != NULL buffer for output */
|
---|
173 | int written; /* total number of byte written */
|
---|
174 | int error;
|
---|
175 | };
|
---|
176 | #endif /* LIBXML_OUTPUT_ENABLED */
|
---|
177 |
|
---|
178 | /** DOC_DISABLE */
|
---|
179 | #define XML_GLOBALS_IO \
|
---|
180 | XML_OP(xmlParserInputBufferCreateFilenameValue, \
|
---|
181 | xmlParserInputBufferCreateFilenameFunc, XML_DEPRECATED) \
|
---|
182 | XML_OP(xmlOutputBufferCreateFilenameValue, \
|
---|
183 | xmlOutputBufferCreateFilenameFunc, XML_DEPRECATED)
|
---|
184 |
|
---|
185 | #define XML_OP XML_DECLARE_GLOBAL
|
---|
186 | XML_GLOBALS_IO
|
---|
187 | #undef XML_OP
|
---|
188 |
|
---|
189 | #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
---|
190 | #define xmlParserInputBufferCreateFilenameValue \
|
---|
191 | XML_GLOBAL_MACRO(xmlParserInputBufferCreateFilenameValue)
|
---|
192 | #define xmlOutputBufferCreateFilenameValue \
|
---|
193 | XML_GLOBAL_MACRO(xmlOutputBufferCreateFilenameValue)
|
---|
194 | #endif
|
---|
195 | /** DOC_ENABLE */
|
---|
196 |
|
---|
197 | /*
|
---|
198 | * Interfaces for input
|
---|
199 | */
|
---|
200 | XMLPUBFUN void
|
---|
201 | xmlCleanupInputCallbacks (void);
|
---|
202 |
|
---|
203 | XMLPUBFUN int
|
---|
204 | xmlPopInputCallbacks (void);
|
---|
205 |
|
---|
206 | XMLPUBFUN void
|
---|
207 | xmlRegisterDefaultInputCallbacks (void);
|
---|
208 | XMLPUBFUN xmlParserInputBufferPtr
|
---|
209 | xmlAllocParserInputBuffer (xmlCharEncoding enc);
|
---|
210 |
|
---|
211 | XMLPUBFUN xmlParserInputBufferPtr
|
---|
212 | xmlParserInputBufferCreateFilename (const char *URI,
|
---|
213 | xmlCharEncoding enc);
|
---|
214 | XMLPUBFUN xmlParserInputBufferPtr
|
---|
215 | xmlParserInputBufferCreateFile (FILE *file,
|
---|
216 | xmlCharEncoding enc);
|
---|
217 | XMLPUBFUN xmlParserInputBufferPtr
|
---|
218 | xmlParserInputBufferCreateFd (int fd,
|
---|
219 | xmlCharEncoding enc);
|
---|
220 | XMLPUBFUN xmlParserInputBufferPtr
|
---|
221 | xmlParserInputBufferCreateMem (const char *mem, int size,
|
---|
222 | xmlCharEncoding enc);
|
---|
223 | XMLPUBFUN xmlParserInputBufferPtr
|
---|
224 | xmlParserInputBufferCreateStatic (const char *mem, int size,
|
---|
225 | xmlCharEncoding enc);
|
---|
226 | XMLPUBFUN xmlParserInputBufferPtr
|
---|
227 | xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
|
---|
228 | xmlInputCloseCallback ioclose,
|
---|
229 | void *ioctx,
|
---|
230 | xmlCharEncoding enc);
|
---|
231 | XMLPUBFUN int
|
---|
232 | xmlParserInputBufferRead (xmlParserInputBufferPtr in,
|
---|
233 | int len);
|
---|
234 | XMLPUBFUN int
|
---|
235 | xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
|
---|
236 | int len);
|
---|
237 | XMLPUBFUN int
|
---|
238 | xmlParserInputBufferPush (xmlParserInputBufferPtr in,
|
---|
239 | int len,
|
---|
240 | const char *buf);
|
---|
241 | XMLPUBFUN void
|
---|
242 | xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
|
---|
243 | XMLPUBFUN char *
|
---|
244 | xmlParserGetDirectory (const char *filename);
|
---|
245 |
|
---|
246 | XMLPUBFUN int
|
---|
247 | xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
|
---|
248 | xmlInputOpenCallback openFunc,
|
---|
249 | xmlInputReadCallback readFunc,
|
---|
250 | xmlInputCloseCallback closeFunc);
|
---|
251 |
|
---|
252 | xmlParserInputBufferPtr
|
---|
253 | __xmlParserInputBufferCreateFilename(const char *URI,
|
---|
254 | xmlCharEncoding enc);
|
---|
255 |
|
---|
256 | #ifdef LIBXML_OUTPUT_ENABLED
|
---|
257 | /*
|
---|
258 | * Interfaces for output
|
---|
259 | */
|
---|
260 | XMLPUBFUN void
|
---|
261 | xmlCleanupOutputCallbacks (void);
|
---|
262 | XMLPUBFUN int
|
---|
263 | xmlPopOutputCallbacks (void);
|
---|
264 | XMLPUBFUN void
|
---|
265 | xmlRegisterDefaultOutputCallbacks(void);
|
---|
266 | XMLPUBFUN xmlOutputBufferPtr
|
---|
267 | xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
|
---|
268 |
|
---|
269 | XMLPUBFUN xmlOutputBufferPtr
|
---|
270 | xmlOutputBufferCreateFilename (const char *URI,
|
---|
271 | xmlCharEncodingHandlerPtr encoder,
|
---|
272 | int compression);
|
---|
273 |
|
---|
274 | XMLPUBFUN xmlOutputBufferPtr
|
---|
275 | xmlOutputBufferCreateFile (FILE *file,
|
---|
276 | xmlCharEncodingHandlerPtr encoder);
|
---|
277 |
|
---|
278 | XMLPUBFUN xmlOutputBufferPtr
|
---|
279 | xmlOutputBufferCreateBuffer (xmlBufferPtr buffer,
|
---|
280 | xmlCharEncodingHandlerPtr encoder);
|
---|
281 |
|
---|
282 | XMLPUBFUN xmlOutputBufferPtr
|
---|
283 | xmlOutputBufferCreateFd (int fd,
|
---|
284 | xmlCharEncodingHandlerPtr encoder);
|
---|
285 |
|
---|
286 | XMLPUBFUN xmlOutputBufferPtr
|
---|
287 | xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
|
---|
288 | xmlOutputCloseCallback ioclose,
|
---|
289 | void *ioctx,
|
---|
290 | xmlCharEncodingHandlerPtr encoder);
|
---|
291 |
|
---|
292 | /* Couple of APIs to get the output without digging into the buffers */
|
---|
293 | XMLPUBFUN const xmlChar *
|
---|
294 | xmlOutputBufferGetContent (xmlOutputBufferPtr out);
|
---|
295 | XMLPUBFUN size_t
|
---|
296 | xmlOutputBufferGetSize (xmlOutputBufferPtr out);
|
---|
297 |
|
---|
298 | XMLPUBFUN int
|
---|
299 | xmlOutputBufferWrite (xmlOutputBufferPtr out,
|
---|
300 | int len,
|
---|
301 | const char *buf);
|
---|
302 | XMLPUBFUN int
|
---|
303 | xmlOutputBufferWriteString (xmlOutputBufferPtr out,
|
---|
304 | const char *str);
|
---|
305 | XMLPUBFUN int
|
---|
306 | xmlOutputBufferWriteEscape (xmlOutputBufferPtr out,
|
---|
307 | const xmlChar *str,
|
---|
308 | xmlCharEncodingOutputFunc escaping);
|
---|
309 |
|
---|
310 | XMLPUBFUN int
|
---|
311 | xmlOutputBufferFlush (xmlOutputBufferPtr out);
|
---|
312 | XMLPUBFUN int
|
---|
313 | xmlOutputBufferClose (xmlOutputBufferPtr out);
|
---|
314 |
|
---|
315 | XMLPUBFUN int
|
---|
316 | xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
|
---|
317 | xmlOutputOpenCallback openFunc,
|
---|
318 | xmlOutputWriteCallback writeFunc,
|
---|
319 | xmlOutputCloseCallback closeFunc);
|
---|
320 |
|
---|
321 | xmlOutputBufferPtr
|
---|
322 | __xmlOutputBufferCreateFilename(const char *URI,
|
---|
323 | xmlCharEncodingHandlerPtr encoder,
|
---|
324 | int compression);
|
---|
325 |
|
---|
326 | #ifdef LIBXML_HTTP_ENABLED
|
---|
327 | /* This function only exists if HTTP support built into the library */
|
---|
328 | XML_DEPRECATED
|
---|
329 | XMLPUBFUN void
|
---|
330 | xmlRegisterHTTPPostCallbacks (void );
|
---|
331 | #endif /* LIBXML_HTTP_ENABLED */
|
---|
332 |
|
---|
333 | #endif /* LIBXML_OUTPUT_ENABLED */
|
---|
334 |
|
---|
335 | XML_DEPRECATED
|
---|
336 | XMLPUBFUN xmlParserInputPtr
|
---|
337 | xmlCheckHTTPInput (xmlParserCtxtPtr ctxt,
|
---|
338 | xmlParserInputPtr ret);
|
---|
339 |
|
---|
340 | /*
|
---|
341 | * A predefined entity loader disabling network accesses
|
---|
342 | */
|
---|
343 | XMLPUBFUN xmlParserInputPtr
|
---|
344 | xmlNoNetExternalEntityLoader (const char *URL,
|
---|
345 | const char *ID,
|
---|
346 | xmlParserCtxtPtr ctxt);
|
---|
347 |
|
---|
348 | XML_DEPRECATED
|
---|
349 | XMLPUBFUN xmlChar *
|
---|
350 | xmlNormalizeWindowsPath (const xmlChar *path);
|
---|
351 |
|
---|
352 | XML_DEPRECATED
|
---|
353 | XMLPUBFUN int
|
---|
354 | xmlCheckFilename (const char *path);
|
---|
355 | /**
|
---|
356 | * Default 'file://' protocol callbacks
|
---|
357 | */
|
---|
358 | XML_DEPRECATED
|
---|
359 | XMLPUBFUN int
|
---|
360 | xmlFileMatch (const char *filename);
|
---|
361 | XML_DEPRECATED
|
---|
362 | XMLPUBFUN void *
|
---|
363 | xmlFileOpen (const char *filename);
|
---|
364 | XML_DEPRECATED
|
---|
365 | XMLPUBFUN int
|
---|
366 | xmlFileRead (void * context,
|
---|
367 | char * buffer,
|
---|
368 | int len);
|
---|
369 | XML_DEPRECATED
|
---|
370 | XMLPUBFUN int
|
---|
371 | xmlFileClose (void * context);
|
---|
372 |
|
---|
373 | /**
|
---|
374 | * Default 'http://' protocol callbacks
|
---|
375 | */
|
---|
376 | #ifdef LIBXML_HTTP_ENABLED
|
---|
377 | XML_DEPRECATED
|
---|
378 | XMLPUBFUN int
|
---|
379 | xmlIOHTTPMatch (const char *filename);
|
---|
380 | XML_DEPRECATED
|
---|
381 | XMLPUBFUN void *
|
---|
382 | xmlIOHTTPOpen (const char *filename);
|
---|
383 | #ifdef LIBXML_OUTPUT_ENABLED
|
---|
384 | XML_DEPRECATED
|
---|
385 | XMLPUBFUN void *
|
---|
386 | xmlIOHTTPOpenW (const char * post_uri,
|
---|
387 | int compression );
|
---|
388 | #endif /* LIBXML_OUTPUT_ENABLED */
|
---|
389 | XML_DEPRECATED
|
---|
390 | XMLPUBFUN int
|
---|
391 | xmlIOHTTPRead (void * context,
|
---|
392 | char * buffer,
|
---|
393 | int len);
|
---|
394 | XML_DEPRECATED
|
---|
395 | XMLPUBFUN int
|
---|
396 | xmlIOHTTPClose (void * context);
|
---|
397 | #endif /* LIBXML_HTTP_ENABLED */
|
---|
398 |
|
---|
399 | /**
|
---|
400 | * Default 'ftp://' protocol callbacks
|
---|
401 | */
|
---|
402 | #if defined(LIBXML_FTP_ENABLED)
|
---|
403 | XML_DEPRECATED
|
---|
404 | XMLPUBFUN int
|
---|
405 | xmlIOFTPMatch (const char *filename);
|
---|
406 | XML_DEPRECATED
|
---|
407 | XMLPUBFUN void *
|
---|
408 | xmlIOFTPOpen (const char *filename);
|
---|
409 | XML_DEPRECATED
|
---|
410 | XMLPUBFUN int
|
---|
411 | xmlIOFTPRead (void * context,
|
---|
412 | char * buffer,
|
---|
413 | int len);
|
---|
414 | XML_DEPRECATED
|
---|
415 | XMLPUBFUN int
|
---|
416 | xmlIOFTPClose (void * context);
|
---|
417 | #endif /* defined(LIBXML_FTP_ENABLED) */
|
---|
418 |
|
---|
419 | XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
|
---|
420 | xmlParserInputBufferCreateFilenameDefault(
|
---|
421 | xmlParserInputBufferCreateFilenameFunc func);
|
---|
422 | XMLPUBFUN xmlOutputBufferCreateFilenameFunc
|
---|
423 | xmlOutputBufferCreateFilenameDefault(
|
---|
424 | xmlOutputBufferCreateFilenameFunc func);
|
---|
425 | XML_DEPRECATED
|
---|
426 | XMLPUBFUN xmlOutputBufferCreateFilenameFunc
|
---|
427 | xmlThrDefOutputBufferCreateFilenameDefault(
|
---|
428 | xmlOutputBufferCreateFilenameFunc func);
|
---|
429 | XML_DEPRECATED
|
---|
430 | XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
|
---|
431 | xmlThrDefParserInputBufferCreateFilenameDefault(
|
---|
432 | xmlParserInputBufferCreateFilenameFunc func);
|
---|
433 |
|
---|
434 | #ifdef __cplusplus
|
---|
435 | }
|
---|
436 | #endif
|
---|
437 |
|
---|
438 | #endif /* __XML_IO_H__ */
|
---|