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