blob: 7fc43e01de2217f9b937f6fb24ae1ba9a32d7af2 [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +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 *
Daniel Veillardc5d64342001-06-24 12:13:24 +00006 * daniel@veillard.com
Owen Taylor3473f882001-02-23 17:55:21 +00007 *
8 * 15 Nov 2000 ht - modified for VMS
9 */
10
11#ifndef __XML_IO_H__
12#define __XML_IO_H__
13
14#include <stdio.h>
Daniel Veillard57905372001-07-31 15:52:17 +000015#if defined(WIN32) && defined(_MSC_VER)
16#include <libxml/xmlwin32version.h>
17#else
Daniel Veillardf012a642001-07-23 19:10:52 +000018#include <libxml/xmlversion.h>
Daniel Veillard57905372001-07-31 15:52:17 +000019#endif
Owen Taylor3473f882001-02-23 17:55:21 +000020#include <libxml/tree.h>
21#include <libxml/parser.h>
22#include <libxml/encoding.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/*
29 * Those are the functions and datatypes for the parser input
30 * I/O structures.
31 */
32
33typedef int (*xmlInputMatchCallback) (char const *filename);
34typedef void * (*xmlInputOpenCallback) (char const *filename);
35typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
Daniel Veillardf012a642001-07-23 19:10:52 +000036typedef int (*xmlInputCloseCallback) (void * context);
Owen Taylor3473f882001-02-23 17:55:21 +000037
Owen Taylor3473f882001-02-23 17:55:21 +000038struct _xmlParserInputBuffer {
39 void* context;
40 xmlInputReadCallback readcallback;
41 xmlInputCloseCallback closecallback;
42
43 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
44
45 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
46 xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
47};
48
49
50/*
51 * Those are the functions and datatypes for the library output
52 * I/O structures.
53 */
54
55typedef int (*xmlOutputMatchCallback) (char const *filename);
56typedef void * (*xmlOutputOpenCallback) (char const *filename);
57typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
58 int len);
Daniel Veillardf012a642001-07-23 19:10:52 +000059typedef int (*xmlOutputCloseCallback) (void * context);
Owen Taylor3473f882001-02-23 17:55:21 +000060
61typedef struct _xmlOutputBuffer xmlOutputBuffer;
62typedef xmlOutputBuffer *xmlOutputBufferPtr;
63struct _xmlOutputBuffer {
64 void* context;
65 xmlOutputWriteCallback writecallback;
66 xmlOutputCloseCallback closecallback;
67
68 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
69
70 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
71 xmlBufferPtr conv; /* if encoder != NULL buffer for output */
72 int written; /* total number of byte written */
73};
74
75/*
76 * Interfaces for input
77 */
Daniel Veillardacf7ff02001-10-29 20:21:47 +000078void xmlCleanupInputCallbacks (void);
79void xmlCleanupOutputCallbacks (void);
Owen Taylor3473f882001-02-23 17:55:21 +000080
81void xmlRegisterDefaultInputCallbacks (void);
82xmlParserInputBufferPtr
83 xmlAllocParserInputBuffer (xmlCharEncoding enc);
84
85#ifdef VMS
86xmlParserInputBufferPtr
87 xmlParserInputBufferCreateFname (const char *URI,
88 xmlCharEncoding enc);
89#define xmlParserInputBufferCreateFilename xmlParserInputBufferCreateFname
90#else
91xmlParserInputBufferPtr
92 xmlParserInputBufferCreateFilename (const char *URI,
93 xmlCharEncoding enc);
94#endif
95
96xmlParserInputBufferPtr
97 xmlParserInputBufferCreateFile (FILE *file,
98 xmlCharEncoding enc);
99xmlParserInputBufferPtr
100 xmlParserInputBufferCreateFd (int fd,
101 xmlCharEncoding enc);
102xmlParserInputBufferPtr
103 xmlParserInputBufferCreateMem (const char *mem, int size,
104 xmlCharEncoding enc);
105xmlParserInputBufferPtr
106 xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
107 xmlInputCloseCallback ioclose,
108 void *ioctx,
109 xmlCharEncoding enc);
110int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
111 int len);
112int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
113 int len);
114int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
115 int len,
116 const char *buf);
117void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
118char * xmlParserGetDirectory (const char *filename);
119
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000120int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
121 xmlInputOpenCallback openFunc,
122 xmlInputReadCallback readFunc,
123 xmlInputCloseCallback closeFunc);
Owen Taylor3473f882001-02-23 17:55:21 +0000124/*
125 * Interfaces for output
126 */
127void xmlRegisterDefaultOutputCallbacks(void);
128xmlOutputBufferPtr
129 xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
130
131xmlOutputBufferPtr
132 xmlOutputBufferCreateFilename (const char *URI,
133 xmlCharEncodingHandlerPtr encoder,
134 int compression);
135
136xmlOutputBufferPtr
137 xmlOutputBufferCreateFile (FILE *file,
138 xmlCharEncodingHandlerPtr encoder);
139
140xmlOutputBufferPtr
141 xmlOutputBufferCreateFd (int fd,
142 xmlCharEncodingHandlerPtr encoder);
143
144xmlOutputBufferPtr
145 xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
146 xmlOutputCloseCallback ioclose,
147 void *ioctx,
148 xmlCharEncodingHandlerPtr encoder);
149
150int xmlOutputBufferWrite (xmlOutputBufferPtr out,
151 int len,
152 const char *buf);
153int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
154 const char *str);
155
156int xmlOutputBufferFlush (xmlOutputBufferPtr out);
157int xmlOutputBufferClose (xmlOutputBufferPtr out);
158
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000159int xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
160 xmlOutputOpenCallback openFunc,
161 xmlOutputWriteCallback writeFunc,
162 xmlOutputCloseCallback closeFunc);
Owen Taylor3473f882001-02-23 17:55:21 +0000163
Daniel Veillardf012a642001-07-23 19:10:52 +0000164/* This function only exists if HTTP support built into the library */
165#ifdef LIBXML_HTTP_ENABLED
166void * xmlIOHTTPOpenW (const char * post_uri,
167 int compression );
Daniel Veillard5d90b6c2001-08-22 14:29:45 +0000168void xmlRegisterHTTPPostCallbacks (void );
Daniel Veillardf012a642001-07-23 19:10:52 +0000169#endif
170
Owen Taylor3473f882001-02-23 17:55:21 +0000171/*
172 * This save function are part of tree.h and HTMLtree.h actually
173 */
174int xmlSaveFileTo (xmlOutputBuffer *buf,
175 xmlDocPtr cur,
176 const char *encoding);
Daniel Veillardeefd4492001-04-28 16:55:50 +0000177int xmlSaveFormatFileTo (xmlOutputBuffer *buf,
178 xmlDocPtr cur,
179 const char *encoding,
180 int format);
Owen Taylor3473f882001-02-23 17:55:21 +0000181void xmlNodeDumpOutput (xmlOutputBufferPtr buf,
182 xmlDocPtr doc,
183 xmlNodePtr cur,
184 int level,
185 int format,
186 const char *encoding);
187void htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
188 xmlDocPtr cur,
189 const char *encoding);
Daniel Veillard8bdb91d2001-10-31 17:52:43 +0000190/*
191 * A predefined entity loader disabling network accesses
192 */
193xmlParserInputPtr xmlNoNetExternalEntityLoader(const char *URL,
194 const char *ID,
195 xmlParserCtxtPtr ctxt);
196
Owen Taylor3473f882001-02-23 17:55:21 +0000197#ifdef __cplusplus
198}
199#endif
200
201#endif /* __XML_IO_H__ */