blob: ecff73bc92285cdfc10f62c48694a4e30740a60d [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 *
6 * Daniel.Veillard@w3.org
7 *
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>
15#include <libxml/tree.h>
16#include <libxml/parser.h>
17#include <libxml/encoding.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/*
24 * Those are the functions and datatypes for the parser input
25 * I/O structures.
26 */
27
28typedef 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
33typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
34typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
35struct _xmlParserInputBuffer {
36 void* context;
37 xmlInputReadCallback readcallback;
38 xmlInputCloseCallback closecallback;
39
40 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
41
42 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
43 xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
44};
45
46
47/*
48 * 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
74 */
75
76void xmlRegisterDefaultInputCallbacks (void);
77xmlParserInputBufferPtr
78 xmlAllocParserInputBuffer (xmlCharEncoding enc);
79
80#ifdef VMS
81xmlParserInputBufferPtr
82 xmlParserInputBufferCreateFname (const char *URI,
83 xmlCharEncoding enc);
84#define xmlParserInputBufferCreateFilename xmlParserInputBufferCreateFname
85#else
86xmlParserInputBufferPtr
87 xmlParserInputBufferCreateFilename (const char *URI,
88 xmlCharEncoding enc);
89#endif
90
91xmlParserInputBufferPtr
92 xmlParserInputBufferCreateFile (FILE *file,
93 xmlCharEncoding enc);
94xmlParserInputBufferPtr
95 xmlParserInputBufferCreateFd (int fd,
96 xmlCharEncoding enc);
97xmlParserInputBufferPtr
98 xmlParserInputBufferCreateMem (const char *mem, int size,
99 xmlCharEncoding enc);
100xmlParserInputBufferPtr
101 xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
102 xmlInputCloseCallback ioclose,
103 void *ioctx,
104 xmlCharEncoding enc);
105int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
106 int len);
107int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
108 int len);
109int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
110 int len,
111 const char *buf);
112void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
113char * xmlParserGetDirectory (const char *filename);
114
115int xmlRegisterInputCallbacks (xmlInputMatchCallback match,
116 xmlInputOpenCallback open,
117 xmlInputReadCallback read,
118 xmlInputCloseCallback close);
119/*
120 * Interfaces for output
121 */
122void xmlRegisterDefaultOutputCallbacks(void);
123xmlOutputBufferPtr
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/*
160 * This save function are part of tree.h and HTMLtree.h actually
161 */
162int xmlSaveFileTo (xmlOutputBuffer *buf,
163 xmlDocPtr cur,
164 const char *encoding);
165void xmlNodeDumpOutput (xmlOutputBufferPtr buf,
166 xmlDocPtr doc,
167 xmlNodePtr cur,
168 int level,
169 int format,
170 const char *encoding);
171void htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
172 xmlDocPtr cur,
173 const char *encoding);
174#ifdef __cplusplus
175}
176#endif
177
178#endif /* __XML_IO_H__ */