Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1 | /* |
| 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 Veillard | c5d6434 | 2001-06-24 12:13:24 +0000 | [diff] [blame] | 6 | * daniel@veillard.com |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 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> |
Daniel Veillard | 5790537 | 2001-07-31 15:52:17 +0000 | [diff] [blame] | 15 | #if defined(WIN32) && defined(_MSC_VER) |
| 16 | #include <libxml/xmlwin32version.h> |
| 17 | #else |
Daniel Veillard | f012a64 | 2001-07-23 19:10:52 +0000 | [diff] [blame] | 18 | #include <libxml/xmlversion.h> |
Daniel Veillard | 5790537 | 2001-07-31 15:52:17 +0000 | [diff] [blame] | 19 | #endif |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 20 | #include <libxml/tree.h> |
| 21 | #include <libxml/parser.h> |
| 22 | #include <libxml/encoding.h> |
| 23 | |
| 24 | #ifdef __cplusplus |
| 25 | extern "C" { |
| 26 | #endif |
| 27 | |
| 28 | /* |
| 29 | * Those are the functions and datatypes for the parser input |
| 30 | * I/O structures. |
| 31 | */ |
| 32 | |
| 33 | typedef int (*xmlInputMatchCallback) (char const *filename); |
| 34 | typedef void * (*xmlInputOpenCallback) (char const *filename); |
| 35 | typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len); |
Daniel Veillard | f012a64 | 2001-07-23 19:10:52 +0000 | [diff] [blame] | 36 | typedef int (*xmlInputCloseCallback) (void * context); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 37 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 38 | struct _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 | |
| 55 | typedef int (*xmlOutputMatchCallback) (char const *filename); |
| 56 | typedef void * (*xmlOutputOpenCallback) (char const *filename); |
| 57 | typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer, |
| 58 | int len); |
Daniel Veillard | f012a64 | 2001-07-23 19:10:52 +0000 | [diff] [blame] | 59 | typedef int (*xmlOutputCloseCallback) (void * context); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 60 | |
| 61 | typedef struct _xmlOutputBuffer xmlOutputBuffer; |
| 62 | typedef xmlOutputBuffer *xmlOutputBufferPtr; |
| 63 | struct _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 Veillard | acf7ff0 | 2001-10-29 20:21:47 +0000 | [diff] [blame] | 78 | void xmlCleanupInputCallbacks (void); |
| 79 | void xmlCleanupOutputCallbacks (void); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 80 | |
| 81 | void xmlRegisterDefaultInputCallbacks (void); |
| 82 | xmlParserInputBufferPtr |
| 83 | xmlAllocParserInputBuffer (xmlCharEncoding enc); |
| 84 | |
| 85 | #ifdef VMS |
| 86 | xmlParserInputBufferPtr |
| 87 | xmlParserInputBufferCreateFname (const char *URI, |
| 88 | xmlCharEncoding enc); |
| 89 | #define xmlParserInputBufferCreateFilename xmlParserInputBufferCreateFname |
| 90 | #else |
| 91 | xmlParserInputBufferPtr |
| 92 | xmlParserInputBufferCreateFilename (const char *URI, |
| 93 | xmlCharEncoding enc); |
| 94 | #endif |
| 95 | |
| 96 | xmlParserInputBufferPtr |
| 97 | xmlParserInputBufferCreateFile (FILE *file, |
| 98 | xmlCharEncoding enc); |
| 99 | xmlParserInputBufferPtr |
| 100 | xmlParserInputBufferCreateFd (int fd, |
| 101 | xmlCharEncoding enc); |
| 102 | xmlParserInputBufferPtr |
| 103 | xmlParserInputBufferCreateMem (const char *mem, int size, |
| 104 | xmlCharEncoding enc); |
| 105 | xmlParserInputBufferPtr |
| 106 | xmlParserInputBufferCreateIO (xmlInputReadCallback ioread, |
| 107 | xmlInputCloseCallback ioclose, |
| 108 | void *ioctx, |
| 109 | xmlCharEncoding enc); |
| 110 | int xmlParserInputBufferRead (xmlParserInputBufferPtr in, |
| 111 | int len); |
| 112 | int xmlParserInputBufferGrow (xmlParserInputBufferPtr in, |
| 113 | int len); |
| 114 | int xmlParserInputBufferPush (xmlParserInputBufferPtr in, |
| 115 | int len, |
| 116 | const char *buf); |
| 117 | void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); |
| 118 | char * xmlParserGetDirectory (const char *filename); |
| 119 | |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 120 | int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc, |
| 121 | xmlInputOpenCallback openFunc, |
| 122 | xmlInputReadCallback readFunc, |
| 123 | xmlInputCloseCallback closeFunc); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 124 | /* |
| 125 | * Interfaces for output |
| 126 | */ |
| 127 | void xmlRegisterDefaultOutputCallbacks(void); |
| 128 | xmlOutputBufferPtr |
| 129 | xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder); |
| 130 | |
| 131 | xmlOutputBufferPtr |
| 132 | xmlOutputBufferCreateFilename (const char *URI, |
| 133 | xmlCharEncodingHandlerPtr encoder, |
| 134 | int compression); |
| 135 | |
| 136 | xmlOutputBufferPtr |
| 137 | xmlOutputBufferCreateFile (FILE *file, |
| 138 | xmlCharEncodingHandlerPtr encoder); |
| 139 | |
| 140 | xmlOutputBufferPtr |
| 141 | xmlOutputBufferCreateFd (int fd, |
| 142 | xmlCharEncodingHandlerPtr encoder); |
| 143 | |
| 144 | xmlOutputBufferPtr |
| 145 | xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite, |
| 146 | xmlOutputCloseCallback ioclose, |
| 147 | void *ioctx, |
| 148 | xmlCharEncodingHandlerPtr encoder); |
| 149 | |
| 150 | int xmlOutputBufferWrite (xmlOutputBufferPtr out, |
| 151 | int len, |
| 152 | const char *buf); |
| 153 | int xmlOutputBufferWriteString (xmlOutputBufferPtr out, |
| 154 | const char *str); |
| 155 | |
| 156 | int xmlOutputBufferFlush (xmlOutputBufferPtr out); |
| 157 | int xmlOutputBufferClose (xmlOutputBufferPtr out); |
| 158 | |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 159 | int xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc, |
| 160 | xmlOutputOpenCallback openFunc, |
| 161 | xmlOutputWriteCallback writeFunc, |
| 162 | xmlOutputCloseCallback closeFunc); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 163 | |
Daniel Veillard | f012a64 | 2001-07-23 19:10:52 +0000 | [diff] [blame] | 164 | /* This function only exists if HTTP support built into the library */ |
| 165 | #ifdef LIBXML_HTTP_ENABLED |
| 166 | void * xmlIOHTTPOpenW (const char * post_uri, |
| 167 | int compression ); |
Daniel Veillard | 5d90b6c | 2001-08-22 14:29:45 +0000 | [diff] [blame] | 168 | void xmlRegisterHTTPPostCallbacks (void ); |
Daniel Veillard | f012a64 | 2001-07-23 19:10:52 +0000 | [diff] [blame] | 169 | #endif |
| 170 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 171 | /* |
| 172 | * This save function are part of tree.h and HTMLtree.h actually |
| 173 | */ |
| 174 | int xmlSaveFileTo (xmlOutputBuffer *buf, |
| 175 | xmlDocPtr cur, |
| 176 | const char *encoding); |
Daniel Veillard | eefd449 | 2001-04-28 16:55:50 +0000 | [diff] [blame] | 177 | int xmlSaveFormatFileTo (xmlOutputBuffer *buf, |
| 178 | xmlDocPtr cur, |
| 179 | const char *encoding, |
| 180 | int format); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 181 | void xmlNodeDumpOutput (xmlOutputBufferPtr buf, |
| 182 | xmlDocPtr doc, |
| 183 | xmlNodePtr cur, |
| 184 | int level, |
| 185 | int format, |
| 186 | const char *encoding); |
| 187 | void htmlDocContentDumpOutput(xmlOutputBufferPtr buf, |
| 188 | xmlDocPtr cur, |
| 189 | const char *encoding); |
Daniel Veillard | 8bdb91d | 2001-10-31 17:52:43 +0000 | [diff] [blame^] | 190 | /* |
| 191 | * A predefined entity loader disabling network accesses |
| 192 | */ |
| 193 | xmlParserInputPtr xmlNoNetExternalEntityLoader(const char *URL, |
| 194 | const char *ID, |
| 195 | xmlParserCtxtPtr ctxt); |
| 196 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 197 | #ifdef __cplusplus |
| 198 | } |
| 199 | #endif |
| 200 | |
| 201 | #endif /* __XML_IO_H__ */ |