blob: ecff73bc92285cdfc10f62c48694a4e30740a60d [file] [log] [blame]
Daniel Veillard14fff061999-06-22 21:49:07 +00001/*
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@w3.org
Daniel Veillardce6e98d2000-11-25 09:54:49 +00007 *
8 * 15 Nov 2000 ht - modified for VMS
Daniel Veillard14fff061999-06-22 21:49:07 +00009 */
10
11#ifndef __XML_IO_H__
12#define __XML_IO_H__
13
14#include <stdio.h>
Daniel Veillard361d8452000-04-03 19:48:13 +000015#include <libxml/tree.h>
16#include <libxml/parser.h>
17#include <libxml/encoding.h>
Daniel Veillard14fff061999-06-22 21:49:07 +000018
19#ifdef __cplusplus
20extern "C" {
21#endif
22
Daniel Veillardbe803962000-06-28 23:40:59 +000023/*
24 * Those are the functions and datatypes for the parser input
25 * I/O structures.
26 */
27
Daniel Veillard5d211f42000-04-07 17:00:24 +000028typedef int (*xmlInputMatchCallback) (char const *filename);
29typedef void * (*xmlInputOpenCallback) (char const *filename);
30typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
31typedef void (*xmlInputCloseCallback) (void * context);
32
Daniel Veillard71b656e2000-01-05 14:46:17 +000033typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
34typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
35struct _xmlParserInputBuffer {
Daniel Veillard5d211f42000-04-07 17:00:24 +000036 void* context;
37 xmlInputReadCallback readcallback;
38 xmlInputCloseCallback closecallback;
Daniel Veillard14fff061999-06-22 21:49:07 +000039
Daniel Veillarde2d034d1999-07-27 19:52:06 +000040 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
Daniel Veillard14fff061999-06-22 21:49:07 +000041
Daniel Veillard39c7d712000-09-10 16:14:55 +000042 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
Daniel Veillard496a1cf2000-05-03 14:20:55 +000043 xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
Daniel Veillard71b656e2000-01-05 14:46:17 +000044};
Daniel Veillard14fff061999-06-22 21:49:07 +000045
Daniel Veillard14fff061999-06-22 21:49:07 +000046
Daniel Veillarde2d034d1999-07-27 19:52:06 +000047/*
Daniel Veillardbe803962000-06-28 23:40:59 +000048 * Those are the functions and datatypes for the library output
49 * I/O structures.
50 */
51
52typedef int (*xmlOutputMatchCallback) (char const *filename);
53typedef void * (*xmlOutputOpenCallback) (char const *filename);
54typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
55 int len);
56typedef void (*xmlOutputCloseCallback) (void * context);
57
58typedef struct _xmlOutputBuffer xmlOutputBuffer;
59typedef xmlOutputBuffer *xmlOutputBufferPtr;
60struct _xmlOutputBuffer {
61 void* context;
62 xmlOutputWriteCallback writecallback;
63 xmlOutputCloseCallback closecallback;
64
65 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
66
67 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
68 xmlBufferPtr conv; /* if encoder != NULL buffer for output */
69 int written; /* total number of byte written */
70};
71
72/*
73 * Interfaces for input
Daniel Veillarde2d034d1999-07-27 19:52:06 +000074 */
75
Daniel Veillard7cfce322000-10-04 12:40:27 +000076void xmlRegisterDefaultInputCallbacks (void);
Daniel Veillardb96e6431999-08-29 21:02:19 +000077xmlParserInputBufferPtr
Daniel Veillarddbfd6411999-12-28 16:35:14 +000078 xmlAllocParserInputBuffer (xmlCharEncoding enc);
79
Daniel Veillardce6e98d2000-11-25 09:54:49 +000080#ifdef VMS
81xmlParserInputBufferPtr
82 xmlParserInputBufferCreateFname (const char *URI,
83 xmlCharEncoding enc);
84#define xmlParserInputBufferCreateFilename xmlParserInputBufferCreateFname
85#else
Daniel Veillarddbfd6411999-12-28 16:35:14 +000086xmlParserInputBufferPtr
Daniel Veillard06047432000-04-24 11:33:38 +000087 xmlParserInputBufferCreateFilename (const char *URI,
Daniel Veillardb96e6431999-08-29 21:02:19 +000088 xmlCharEncoding enc);
Daniel Veillardce6e98d2000-11-25 09:54:49 +000089#endif
90
Daniel Veillardb96e6431999-08-29 21:02:19 +000091xmlParserInputBufferPtr
92 xmlParserInputBufferCreateFile (FILE *file,
93 xmlCharEncoding enc);
94xmlParserInputBufferPtr
95 xmlParserInputBufferCreateFd (int fd,
96 xmlCharEncoding enc);
Daniel Veillard5e873c42000-04-12 13:27:38 +000097xmlParserInputBufferPtr
Daniel Veillard46e370e2000-07-21 20:32:03 +000098 xmlParserInputBufferCreateMem (const char *mem, int size,
99 xmlCharEncoding enc);
100xmlParserInputBufferPtr
Daniel Veillard5e873c42000-04-12 13:27:38 +0000101 xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
102 xmlInputCloseCallback ioclose,
103 void *ioctx,
104 xmlCharEncoding enc);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000105int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
106 int len);
107int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
108 int len);
Daniel Veillard7f858501999-11-17 17:32:38 +0000109int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
110 int len,
Daniel Veillarda819dac1999-11-24 18:04:22 +0000111 const char *buf);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000112void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
113char * xmlParserGetDirectory (const char *filename);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000114
Daniel Veillard5d211f42000-04-07 17:00:24 +0000115int xmlRegisterInputCallbacks (xmlInputMatchCallback match,
116 xmlInputOpenCallback open,
117 xmlInputReadCallback read,
118 xmlInputCloseCallback close);
Daniel Veillardbe803962000-06-28 23:40:59 +0000119/*
120 * Interfaces for output
121 */
Daniel Veillard7cfce322000-10-04 12:40:27 +0000122void xmlRegisterDefaultOutputCallbacks(void);
Daniel Veillardbe803962000-06-28 23:40:59 +0000123xmlOutputBufferPtr
124 xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
125
126xmlOutputBufferPtr
127 xmlOutputBufferCreateFilename (const char *URI,
128 xmlCharEncodingHandlerPtr encoder,
129 int compression);
130
131xmlOutputBufferPtr
132 xmlOutputBufferCreateFile (FILE *file,
133 xmlCharEncodingHandlerPtr encoder);
134
135xmlOutputBufferPtr
136 xmlOutputBufferCreateFd (int fd,
137 xmlCharEncodingHandlerPtr encoder);
138
139xmlOutputBufferPtr
140 xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
141 xmlOutputCloseCallback ioclose,
142 void *ioctx,
143 xmlCharEncodingHandlerPtr encoder);
144
145int xmlOutputBufferWrite (xmlOutputBufferPtr out,
146 int len,
147 const char *buf);
148int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
149 const char *str);
150
151int xmlOutputBufferFlush (xmlOutputBufferPtr out);
152int xmlOutputBufferClose (xmlOutputBufferPtr out);
153
154int xmlRegisterOutputCallbacks (xmlOutputMatchCallback match,
155 xmlOutputOpenCallback open,
156 xmlOutputWriteCallback write,
157 xmlOutputCloseCallback close);
158
159/*
Daniel Veillard701c7362001-01-21 09:48:59 +0000160 * This save function are part of tree.h and HTMLtree.h actually
Daniel Veillardbe803962000-06-28 23:40:59 +0000161 */
162int xmlSaveFileTo (xmlOutputBuffer *buf,
163 xmlDocPtr cur,
164 const char *encoding);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000165void xmlNodeDumpOutput (xmlOutputBufferPtr buf,
166 xmlDocPtr doc,
167 xmlNodePtr cur,
168 int level,
169 int format,
170 const char *encoding);
Daniel Veillard701c7362001-01-21 09:48:59 +0000171void htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
172 xmlDocPtr cur,
173 const char *encoding);
Daniel Veillard14fff061999-06-22 21:49:07 +0000174#ifdef __cplusplus
175}
176#endif
177
178#endif /* __XML_IO_H__ */