2 * xmlIO.h : interface for the I/O interfaces used by the parser
4 * See Copyright for the status of this software.
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 (*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 * (*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 (*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 (*xmlInputCloseCallback) (void * context);
66 * Those are the functions and datatypes for the library output
71 * xmlOutputMatchCallback:
72 * @filename: the filename or URI
74 * Callback used in the I/O Output API to detect if the current handler
75 * can provide output fonctionnalities for this resource.
77 * Returns 1 if yes and 0 if another Output module should be used
79 typedef int (*xmlOutputMatchCallback) (char const *filename);
81 * xmlOutputOpenCallback:
82 * @filename: the filename or URI
84 * Callback used in the I/O Output API to open the resource
86 * Returns an Output context or NULL in case or error
88 typedef void * (*xmlOutputOpenCallback) (char const *filename);
90 * xmlOutputWriteCallback:
91 * @context: an Output context
92 * @buffer: the buffer of data to write
93 * @len: the length of the buffer in bytes
95 * Callback used in the I/O Output API to write to the resource
97 * Returns the number of bytes written or -1 in case of error
99 typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
102 * xmlOutputCloseCallback:
103 * @context: an Output context
105 * Callback used in the I/O Output API to close the resource
107 * Returns 0 or -1 in case of error
109 typedef int (*xmlOutputCloseCallback) (void * context);
115 #include <libxml/globals.h>
116 #include <libxml/tree.h>
117 #include <libxml/parser.h>
118 #include <libxml/encoding.h>
123 struct _xmlParserInputBuffer {
125 xmlInputReadCallback readcallback;
126 xmlInputCloseCallback closecallback;
128 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
130 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
131 xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
135 struct _xmlOutputBuffer {
137 xmlOutputWriteCallback writecallback;
138 xmlOutputCloseCallback closecallback;
140 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
142 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
143 xmlBufferPtr conv; /* if encoder != NULL buffer for output */
144 int written; /* total number of byte written */
148 * Interfaces for input
150 void xmlCleanupInputCallbacks (void);
151 void xmlCleanupOutputCallbacks (void);
153 void xmlRegisterDefaultInputCallbacks (void);
154 xmlParserInputBufferPtr
155 xmlAllocParserInputBuffer (xmlCharEncoding enc);
157 xmlParserInputBufferPtr
158 xmlParserInputBufferCreateFilename (const char *URI,
159 xmlCharEncoding enc);
160 xmlParserInputBufferPtr
161 xmlParserInputBufferCreateFile (FILE *file,
162 xmlCharEncoding enc);
163 xmlParserInputBufferPtr
164 xmlParserInputBufferCreateFd (int fd,
165 xmlCharEncoding enc);
166 xmlParserInputBufferPtr
167 xmlParserInputBufferCreateMem (const char *mem, int size,
168 xmlCharEncoding enc);
169 xmlParserInputBufferPtr
170 xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
171 xmlInputCloseCallback ioclose,
173 xmlCharEncoding enc);
174 int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
176 int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
178 int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
181 void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
182 char * xmlParserGetDirectory (const char *filename);
184 int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
185 xmlInputOpenCallback openFunc,
186 xmlInputReadCallback readFunc,
187 xmlInputCloseCallback closeFunc);
189 * Interfaces for output
191 void xmlRegisterDefaultOutputCallbacks(void);
193 xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
196 xmlOutputBufferCreateFilename (const char *URI,
197 xmlCharEncodingHandlerPtr encoder,
201 xmlOutputBufferCreateFile (FILE *file,
202 xmlCharEncodingHandlerPtr encoder);
205 xmlOutputBufferCreateFd (int fd,
206 xmlCharEncodingHandlerPtr encoder);
209 xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
210 xmlOutputCloseCallback ioclose,
212 xmlCharEncodingHandlerPtr encoder);
214 int xmlOutputBufferWrite (xmlOutputBufferPtr out,
217 int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
220 int xmlOutputBufferFlush (xmlOutputBufferPtr out);
221 int xmlOutputBufferClose (xmlOutputBufferPtr out);
223 int xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
224 xmlOutputOpenCallback openFunc,
225 xmlOutputWriteCallback writeFunc,
226 xmlOutputCloseCallback closeFunc);
228 /* This function only exists if HTTP support built into the library */
229 #ifdef LIBXML_HTTP_ENABLED
230 void * xmlIOHTTPOpenW (const char * post_uri,
232 void xmlRegisterHTTPPostCallbacks (void );
236 * A predefined entity loader disabling network accesses
238 xmlParserInputPtr xmlNoNetExternalEntityLoader(const char *URL,
240 xmlParserCtxtPtr ctxt);
243 * xmlNormalizeWindowsPath is obsolete, don't use it.
244 * Check xmlCanonicPath in uri.h for a better alternative.
246 xmlChar * xmlNormalizeWindowsPath (const xmlChar *path);
248 int xmlCheckFilename (const char *path);
250 * Default 'file://' protocol callbacks
252 int xmlFileMatch (const char *filename);
253 void * xmlFileOpen (const char *filename);
254 int xmlFileRead (void * context,
257 int xmlFileClose (void * context);
260 * Default 'http://' protocol callbacks
262 #ifdef LIBXML_HTTP_ENABLED
263 int xmlIOHTTPMatch (const char *filename);
264 void * xmlIOHTTPOpen (const char *filename);
265 int xmlIOHTTPRead (void * context,
268 int xmlIOHTTPClose (void * context);
269 #endif /* LIBXML_HTTP_ENABLED */
272 * Default 'ftp://' protocol callbacks
274 #ifdef LIBXML_FTP_ENABLED
275 int xmlIOFTPMatch (const char *filename);
276 void * xmlIOFTPOpen (const char *filename);
277 int xmlIOFTPRead (void * context,
280 int xmlIOFTPClose (void * context);
281 #endif /* LIBXML_FTP_ENABLED */
287 #endif /* __XML_IO_H__ */