blob: 5289367e21013cf6a500832dc96baaffdd1520c5 [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 Veillardbe803962000-06-28 23:40:59 +000040 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
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 Veillardb96e6431999-08-29 21:02:19 +000074xmlParserInputBufferPtr
Daniel Veillarddbfd6411999-12-28 16:35:14 +000075 xmlAllocParserInputBuffer (xmlCharEncoding enc);
76
77xmlParserInputBufferPtr
Daniel Veillard06047432000-04-24 11:33:38 +000078 xmlParserInputBufferCreateFilename (const char *URI,
Daniel Veillardb96e6431999-08-29 21:02:19 +000079 xmlCharEncoding enc);
80xmlParserInputBufferPtr
81 xmlParserInputBufferCreateFile (FILE *file,
82 xmlCharEncoding enc);
83xmlParserInputBufferPtr
84 xmlParserInputBufferCreateFd (int fd,
85 xmlCharEncoding enc);
Daniel Veillard5e873c42000-04-12 13:27:38 +000086xmlParserInputBufferPtr
87 xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
88 xmlInputCloseCallback ioclose,
89 void *ioctx,
90 xmlCharEncoding enc);
Daniel Veillardb96e6431999-08-29 21:02:19 +000091int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
92 int len);
93int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
94 int len);
Daniel Veillard7f858501999-11-17 17:32:38 +000095int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
96 int len,
Daniel Veillarda819dac1999-11-24 18:04:22 +000097 const char *buf);
Daniel Veillardb96e6431999-08-29 21:02:19 +000098void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
99char * xmlParserGetDirectory (const char *filename);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000100
Daniel Veillard5d211f42000-04-07 17:00:24 +0000101int xmlRegisterInputCallbacks (xmlInputMatchCallback match,
102 xmlInputOpenCallback open,
103 xmlInputReadCallback read,
104 xmlInputCloseCallback close);
Daniel Veillardbe803962000-06-28 23:40:59 +0000105/*
106 * Interfaces for output
107 */
108xmlOutputBufferPtr
109 xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
110
111xmlOutputBufferPtr
112 xmlOutputBufferCreateFilename (const char *URI,
113 xmlCharEncodingHandlerPtr encoder,
114 int compression);
115
116xmlOutputBufferPtr
117 xmlOutputBufferCreateFile (FILE *file,
118 xmlCharEncodingHandlerPtr encoder);
119
120xmlOutputBufferPtr
121 xmlOutputBufferCreateFd (int fd,
122 xmlCharEncodingHandlerPtr encoder);
123
124xmlOutputBufferPtr
125 xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
126 xmlOutputCloseCallback ioclose,
127 void *ioctx,
128 xmlCharEncodingHandlerPtr encoder);
129
130int xmlOutputBufferWrite (xmlOutputBufferPtr out,
131 int len,
132 const char *buf);
133int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
134 const char *str);
135
136int xmlOutputBufferFlush (xmlOutputBufferPtr out);
137int xmlOutputBufferClose (xmlOutputBufferPtr out);
138
139int xmlRegisterOutputCallbacks (xmlOutputMatchCallback match,
140 xmlOutputOpenCallback open,
141 xmlOutputWriteCallback write,
142 xmlOutputCloseCallback close);
143
144/*
145 * This save function is part of tree.h actually
146 */
147int xmlSaveFileTo (xmlOutputBuffer *buf,
148 xmlDocPtr cur,
149 const char *encoding);
Daniel Veillard14fff061999-06-22 21:49:07 +0000150#ifdef __cplusplus
151}
152#endif
153
154#endif /* __XML_IO_H__ */