xmlIO.h
1 /*
2 * xmlIO.h : interface for the I/O interfaces used by the parser
3 *
4 * See Copyright for the status of this software.
5 *
6 * daniel@veillard.com
7 *
8 */
9
10 #ifndef __XML_IO_H__
11 #define __XML_IO_H__
12
13 #include
14 #include
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 /*
21 * Those are the functions and datatypes for the parser input
22 * I/O structures.
23 */
24
25 /**
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 */
34 typedef int (*xmlInputMatchCallback) (char const *filename); <typedef:xmlInputMatchCallback>
35 /**
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 */
43 typedef void * (*xmlInputOpenCallback) (char const *filename); <typedef:xmlInputOpenCallback>
44 /**
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 */
54 typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len); <typedef:xmlInputReadCallback>
55 /**
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 */
63 typedef int (*xmlInputCloseCallback) (void * context); <typedef:xmlInputCloseCallback>
64
65 /*
66 * Those are the functions and datatypes for the library output
67 * I/O structures.
68 */
69
70 /**
71 * xmlOutputMatchCallback:
72 * @filename: the filename or URI
73 *
74 * Callback used in the I/O Output API to detect if the current handler
75 * can provide output fonctionnalities for this resource.
76 *
77 * Returns 1 if yes and 0 if another Output module should be used
78 */
79 typedef int (*xmlOutputMatchCallback) (char const *filename); <typedef:xmlOutputMatchCallback>
80 /**
81 * xmlOutputOpenCallback:
82 * @filename: the filename or URI
83 *
84 * Callback used in the I/O Output API to open the resource
85 *
86 * Returns an Output context or NULL in case or error
87 */
88 typedef void * (*xmlOutputOpenCallback) (char const *filename); <typedef:xmlOutputOpenCallback>
89 /**
90 * xmlOutputWriteCallback:
91 * @context: an Output context
92 * @buffer: the buffer of data to write
93 * @len: the length of the buffer in bytes
94 *
95 * Callback used in the I/O Output API to write to the resource
96 *
97 * Returns the number of bytes written or -1 in case of error
98 */
99 typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
100 int len); <typedef:xmlOutputWriteCallback>
101 /**
102 * xmlOutputCloseCallback:
103 * @context: an Output context
104 *
105 * Callback used in the I/O Output API to close the resource
106 *
107 * Returns 0 or -1 in case of error
108 */
109 typedef int (*xmlOutputCloseCallback) (void * context); <typedef:xmlOutputCloseCallback>
110
111 #ifdef __cplusplus
112 }
113 #endif
114
115 #include
116 #include
117 #include
118 #include
119
120 #ifdef __cplusplus
121 extern "C" {
122 #endif
123 struct _xmlParserInputBuffer {
124 void* context;
125 xmlInputReadCallback readcallback;
126 xmlInputCloseCallback closecallback;
127
128 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
129
130 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
131 xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
132 };
133
134
135 struct _xmlOutputBuffer {
136 void* context;
137 xmlOutputWriteCallback writecallback;
138 xmlOutputCloseCallback closecallback;
139
140 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
141
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 */
145 };
146
147 /*
148 * Interfaces for input
149 */
150 void xmlCleanupInputCallbacks (void);
151 void xmlCleanupOutputCallbacks (void);
152
153 void xmlRegisterDefaultInputCallbacks (void);
154 xmlParserInputBufferPtr
155 xmlAllocParserInputBuffer (xmlCharEncoding enc);
156
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,
172 void *ioctx,
173 xmlCharEncoding enc);
174 int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
175 int len);
176 int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
177 int len);
178 int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
179 int len,
180 const char *buf);
181 void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
182 char * xmlParserGetDirectory (const char *filename);
183
184 int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
185 xmlInputOpenCallback openFunc,
186 xmlInputReadCallback readFunc,
187 xmlInputCloseCallback closeFunc);
188 /*
189 * Interfaces for output
190 */
191 void xmlRegisterDefaultOutputCallbacks(void);
192 xmlOutputBufferPtr
193 xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
194
195 xmlOutputBufferPtr
196 xmlOutputBufferCreateFilename (const char *URI,
197 xmlCharEncodingHandlerPtr encoder,
198 int compression);
199
200 xmlOutputBufferPtr
201 xmlOutputBufferCreateFile (FILE *file,
202 xmlCharEncodingHandlerPtr encoder);
203
204 xmlOutputBufferPtr
205 xmlOutputBufferCreateFd (int fd,
206 xmlCharEncodingHandlerPtr encoder);
207
208 xmlOutputBufferPtr
209 xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
210 xmlOutputCloseCallback ioclose,
211 void *ioctx,
212 xmlCharEncodingHandlerPtr encoder);
213
214 int xmlOutputBufferWrite (xmlOutputBufferPtr out,
215 int len,
216 const char *buf);
217 int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
218 const char *str);
219
220 int xmlOutputBufferFlush (xmlOutputBufferPtr out);
221 int xmlOutputBufferClose (xmlOutputBufferPtr out);
222
223 int xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
224 xmlOutputOpenCallback openFunc,
225 xmlOutputWriteCallback writeFunc,
226 xmlOutputCloseCallback closeFunc);
227
228 /* This function only exists if HTTP support built into the library */
229 #ifdef LIBXML_HTTP_ENABLED
230 void * xmlIOHTTPOpenW (const char * post_uri,
231 int compression );
232 void xmlRegisterHTTPPostCallbacks (void );
233 #endif
234
235 /*
236 * A predefined entity loader disabling network accesses
237 */
238 xmlParserInputPtr xmlNoNetExternalEntityLoader(const char *URL,
239 const char *ID,
240 xmlParserCtxtPtr ctxt);
241
242 xmlChar *xmlNormalizeWindowsPath (const xmlChar *path);
243
244 int xmlCheckFilename (const char *path);
245 /**
246 * Default 'file://' protocol callbacks
247 */
248 int xmlFileMatch (const char *filename);
249 void * xmlFileOpen (const char *filename);
250 int xmlFileRead (void * context,
251 char * buffer,
252 int len);
253 int xmlFileClose (void * context);
254
255 /**
256 * Default 'http://' protocol callbacks
257 */
258 #ifdef LIBXML_HTTP_ENABLED
259 int xmlIOHTTPMatch (const char *filename);
260 void * xmlIOHTTPOpen (const char *filename);
261 int xmlIOHTTPRead (void * context,
262 char * buffer,
263 int len);
264 int xmlIOHTTPClose (void * context);
265 #endif /* LIBXML_HTTP_ENABLED */
266
267 /**
268 * Default 'ftp://' protocol callbacks
269 */
270 #ifdef LIBXML_FTP_ENABLED
271 int xmlIOFTPMatch (const char *filename);
272 void * xmlIOFTPOpen (const char *filename);
273 int xmlIOFTPRead (void * context,
274 char * buffer,
275 int len);
276 int xmlIOFTPClose (void * context);
277 #endif /* LIBXML_FTP_ENABLED */
278
279 #ifdef __cplusplus
280 }
281 #endif
282
283 #endif /* __XML_IO_H__ */