blob: ff0114d55627f887f4fafab9028079dc9efd9e90 [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
7 */
8
9#ifndef __XML_IO_H__
10#define __XML_IO_H__
11
12#include <stdio.h>
Daniel Veillard361d8452000-04-03 19:48:13 +000013#include <libxml/tree.h>
14#include <libxml/parser.h>
15#include <libxml/encoding.h>
Daniel Veillard14fff061999-06-22 21:49:07 +000016
17#ifdef __cplusplus
18extern "C" {
19#endif
20
Daniel Veillardbe803962000-06-28 23:40:59 +000021/*
22 * Those are the functions and datatypes for the parser input
23 * I/O structures.
24 */
25
Daniel Veillard5d211f42000-04-07 17:00:24 +000026typedef int (*xmlInputMatchCallback) (char const *filename);
27typedef void * (*xmlInputOpenCallback) (char const *filename);
28typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
29typedef void (*xmlInputCloseCallback) (void * context);
30
Daniel Veillard71b656e2000-01-05 14:46:17 +000031typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
32typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
33struct _xmlParserInputBuffer {
Daniel Veillard5d211f42000-04-07 17:00:24 +000034 void* context;
35 xmlInputReadCallback readcallback;
36 xmlInputCloseCallback closecallback;
Daniel Veillard14fff061999-06-22 21:49:07 +000037
Daniel Veillarde2d034d1999-07-27 19:52:06 +000038 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
Daniel Veillard14fff061999-06-22 21:49:07 +000039
Daniel Veillard39c7d712000-09-10 16:14:55 +000040 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
Daniel Veillard496a1cf2000-05-03 14:20:55 +000041 xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
Daniel Veillard71b656e2000-01-05 14:46:17 +000042};
Daniel Veillard14fff061999-06-22 21:49:07 +000043
Daniel Veillard14fff061999-06-22 21:49:07 +000044
Daniel Veillarde2d034d1999-07-27 19:52:06 +000045/*
Daniel Veillardbe803962000-06-28 23:40:59 +000046 * Those are the functions and datatypes for the library output
47 * I/O structures.
48 */
49
50typedef int (*xmlOutputMatchCallback) (char const *filename);
51typedef void * (*xmlOutputOpenCallback) (char const *filename);
52typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
53 int len);
54typedef void (*xmlOutputCloseCallback) (void * context);
55
56typedef struct _xmlOutputBuffer xmlOutputBuffer;
57typedef xmlOutputBuffer *xmlOutputBufferPtr;
58struct _xmlOutputBuffer {
59 void* context;
60 xmlOutputWriteCallback writecallback;
61 xmlOutputCloseCallback closecallback;
62
63 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
64
65 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
66 xmlBufferPtr conv; /* if encoder != NULL buffer for output */
67 int written; /* total number of byte written */
68};
69
70/*
71 * Interfaces for input
Daniel Veillarde2d034d1999-07-27 19:52:06 +000072 */
73
Daniel Veillard7cfce322000-10-04 12:40:27 +000074void xmlRegisterDefaultInputCallbacks (void);
Daniel Veillardb96e6431999-08-29 21:02:19 +000075xmlParserInputBufferPtr
Daniel Veillarddbfd6411999-12-28 16:35:14 +000076 xmlAllocParserInputBuffer (xmlCharEncoding enc);
77
78xmlParserInputBufferPtr
Daniel Veillard06047432000-04-24 11:33:38 +000079 xmlParserInputBufferCreateFilename (const char *URI,
Daniel Veillardb96e6431999-08-29 21:02:19 +000080 xmlCharEncoding enc);
81xmlParserInputBufferPtr
82 xmlParserInputBufferCreateFile (FILE *file,
83 xmlCharEncoding enc);
84xmlParserInputBufferPtr
85 xmlParserInputBufferCreateFd (int fd,
86 xmlCharEncoding enc);
Daniel Veillard5e873c42000-04-12 13:27:38 +000087xmlParserInputBufferPtr
Daniel Veillard46e370e2000-07-21 20:32:03 +000088 xmlParserInputBufferCreateMem (const char *mem, int size,
89 xmlCharEncoding enc);
90xmlParserInputBufferPtr
Daniel Veillard5e873c42000-04-12 13:27:38 +000091 xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
92 xmlInputCloseCallback ioclose,
93 void *ioctx,
94 xmlCharEncoding enc);
Daniel Veillardb96e6431999-08-29 21:02:19 +000095int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
96 int len);
97int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
98 int len);
Daniel Veillard7f858501999-11-17 17:32:38 +000099int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
100 int len,
Daniel Veillarda819dac1999-11-24 18:04:22 +0000101 const char *buf);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000102void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
103char * xmlParserGetDirectory (const char *filename);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000104
Daniel Veillard5d211f42000-04-07 17:00:24 +0000105int xmlRegisterInputCallbacks (xmlInputMatchCallback match,
106 xmlInputOpenCallback open,
107 xmlInputReadCallback read,
108 xmlInputCloseCallback close);
Daniel Veillardbe803962000-06-28 23:40:59 +0000109/*
110 * Interfaces for output
111 */
Daniel Veillard7cfce322000-10-04 12:40:27 +0000112void xmlRegisterDefaultOutputCallbacks(void);
Daniel Veillardbe803962000-06-28 23:40:59 +0000113xmlOutputBufferPtr
114 xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
115
116xmlOutputBufferPtr
117 xmlOutputBufferCreateFilename (const char *URI,
118 xmlCharEncodingHandlerPtr encoder,
119 int compression);
120
121xmlOutputBufferPtr
122 xmlOutputBufferCreateFile (FILE *file,
123 xmlCharEncodingHandlerPtr encoder);
124
125xmlOutputBufferPtr
126 xmlOutputBufferCreateFd (int fd,
127 xmlCharEncodingHandlerPtr encoder);
128
129xmlOutputBufferPtr
130 xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
131 xmlOutputCloseCallback ioclose,
132 void *ioctx,
133 xmlCharEncodingHandlerPtr encoder);
134
135int xmlOutputBufferWrite (xmlOutputBufferPtr out,
136 int len,
137 const char *buf);
138int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
139 const char *str);
140
141int xmlOutputBufferFlush (xmlOutputBufferPtr out);
142int xmlOutputBufferClose (xmlOutputBufferPtr out);
143
144int xmlRegisterOutputCallbacks (xmlOutputMatchCallback match,
145 xmlOutputOpenCallback open,
146 xmlOutputWriteCallback write,
147 xmlOutputCloseCallback close);
148
149/*
150 * This save function is part of tree.h actually
151 */
152int xmlSaveFileTo (xmlOutputBuffer *buf,
153 xmlDocPtr cur,
154 const char *encoding);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000155void xmlNodeDumpOutput (xmlOutputBufferPtr buf,
156 xmlDocPtr doc,
157 xmlNodePtr cur,
158 int level,
159 int format,
160 const char *encoding);
Daniel Veillard14fff061999-06-22 21:49:07 +0000161#ifdef __cplusplus
162}
163#endif
164
165#endif /* __XML_IO_H__ */