[964] | 1 | /* |
---|
| 2 | * Summary: interface for the I/O interfaces used by the parser |
---|
| 3 | * Description: interface for the I/O interfaces used by the parser |
---|
| 4 | * |
---|
| 5 | * Copy: See Copyright for the status of this software. |
---|
| 6 | * |
---|
| 7 | * Author: Daniel Veillard |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | #ifndef __XML_IO_H__ |
---|
| 11 | #define __XML_IO_H__ |
---|
| 12 | |
---|
| 13 | #include <stdio.h> |
---|
| 14 | #include <libxml/xmlversion.h> |
---|
| 15 | |
---|
| 16 | #ifdef __cplusplus |
---|
| 17 | extern "C" { |
---|
| 18 | #endif |
---|
| 19 | |
---|
| 20 | /* |
---|
| 21 | * Those are the functions and datatypes for the parser input |
---|
| 22 | * I/O structures. |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | * xmlInputMatchCallback: |
---|
| 27 | * @filename: the filename or URI |
---|
| 28 | * |
---|
| 29 | * Callback used in the I/O Input API to detect if the current handler |
---|
| 30 | * can provide input fonctionnalities for this resource. |
---|
| 31 | * |
---|
| 32 | * Returns 1 if yes and 0 if another Input module should be used |
---|
| 33 | */ |
---|
| 34 | typedef int (*xmlInputMatchCallback) (char const *filename); |
---|
| 35 | /** |
---|
| 36 | * xmlInputOpenCallback: |
---|
| 37 | * @filename: the filename or URI |
---|
| 38 | * |
---|
| 39 | * Callback used in the I/O Input API to open the resource |
---|
| 40 | * |
---|
| 41 | * Returns an Input context or NULL in case or error |
---|
| 42 | */ |
---|
| 43 | typedef void * (*xmlInputOpenCallback) (char const *filename); |
---|
| 44 | /** |
---|
| 45 | * xmlInputReadCallback: |
---|
| 46 | * @context: an Input context |
---|
| 47 | * @buffer: the buffer to store data read |
---|
| 48 | * @len: the length of the buffer in bytes |
---|
| 49 | * |
---|
| 50 | * Callback used in the I/O Input API to read the resource |
---|
| 51 | * |
---|
| 52 | * Returns the number of bytes read or -1 in case of error |
---|
| 53 | */ |
---|
| 54 | typedef intptr_t (*xmlInputReadCallback) (void * context, char * buffer, size_t len); |
---|
| 55 | /** |
---|
| 56 | * xmlInputCloseCallback: |
---|
| 57 | * @context: an Input context |
---|
| 58 | * |
---|
| 59 | * Callback used in the I/O Input API to close the resource |
---|
| 60 | * |
---|
| 61 | * Returns 0 or -1 in case of error |
---|
| 62 | */ |
---|
| 63 | typedef int (*xmlInputCloseCallback) (void * context); |
---|
| 64 | |
---|
| 65 | #ifdef LIBXML_OUTPUT_ENABLED |
---|
| 66 | /* |
---|
| 67 | * Those are the functions and datatypes for the library output |
---|
| 68 | * I/O structures. |
---|
| 69 | */ |
---|
| 70 | |
---|
| 71 | /** |
---|
| 72 | * xmlOutputMatchCallback: |
---|
| 73 | * @filename: the filename or URI |
---|
| 74 | * |
---|
| 75 | * Callback used in the I/O Output API to detect if the current handler |
---|
| 76 | * can provide output fonctionnalities for this resource. |
---|
| 77 | * |
---|
| 78 | * Returns 1 if yes and 0 if another Output module should be used |
---|
| 79 | */ |
---|
| 80 | typedef int (*xmlOutputMatchCallback) (char const *filename); |
---|
| 81 | /** |
---|
| 82 | * xmlOutputOpenCallback: |
---|
| 83 | * @filename: the filename or URI |
---|
| 84 | * |
---|
| 85 | * Callback used in the I/O Output API to open the resource |
---|
| 86 | * |
---|
| 87 | * Returns an Output context or NULL in case or error |
---|
| 88 | */ |
---|
| 89 | typedef void * (*xmlOutputOpenCallback) (char const *filename); |
---|
| 90 | /** |
---|
| 91 | * xmlOutputWriteCallback: |
---|
| 92 | * @context: an Output context |
---|
| 93 | * @buffer: the buffer of data to write |
---|
| 94 | * @len: the length of the buffer in bytes |
---|
| 95 | * |
---|
| 96 | * Callback used in the I/O Output API to write to the resource |
---|
| 97 | * |
---|
| 98 | * Returns the number of bytes written or -1 in case of error |
---|
| 99 | */ |
---|
| 100 | typedef intptr_t (*xmlOutputWriteCallback) (void * context, const char * buffer, |
---|
| 101 | size_t len); |
---|
| 102 | /** |
---|
| 103 | * xmlOutputCloseCallback: |
---|
| 104 | * @context: an Output context |
---|
| 105 | * |
---|
| 106 | * Callback used in the I/O Output API to close the resource |
---|
| 107 | * |
---|
| 108 | * Returns 0 or -1 in case of error |
---|
| 109 | */ |
---|
| 110 | typedef int (*xmlOutputCloseCallback) (void * context); |
---|
| 111 | #endif /* LIBXML_OUTPUT_ENABLED */ |
---|
| 112 | |
---|
| 113 | #ifdef __cplusplus |
---|
| 114 | } |
---|
| 115 | #endif |
---|
| 116 | |
---|
| 117 | #include <libxml/globals.h> |
---|
| 118 | #include <libxml/tree.h> |
---|
| 119 | #include <libxml/parser.h> |
---|
| 120 | #include <libxml/encoding.h> |
---|
| 121 | |
---|
| 122 | #ifdef __cplusplus |
---|
| 123 | extern "C" { |
---|
| 124 | #endif |
---|
| 125 | struct _xmlParserInputBuffer { |
---|
| 126 | void* context; |
---|
| 127 | xmlInputReadCallback readcallback; |
---|
| 128 | xmlInputCloseCallback closecallback; |
---|
| 129 | |
---|
| 130 | xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ |
---|
| 131 | |
---|
| 132 | xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */ |
---|
| 133 | xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */ |
---|
| 134 | int compressed; /* -1=unknown, 0=not compressed, 1=compressed */ |
---|
| 135 | int error; |
---|
| 136 | size_t rawconsumed;/* amount consumed from raw */ |
---|
| 137 | }; |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | #ifdef LIBXML_OUTPUT_ENABLED |
---|
| 141 | struct _xmlOutputBuffer { |
---|
| 142 | void* context; |
---|
| 143 | xmlOutputWriteCallback writecallback; |
---|
| 144 | xmlOutputCloseCallback closecallback; |
---|
| 145 | |
---|
| 146 | xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ |
---|
| 147 | |
---|
| 148 | xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */ |
---|
| 149 | xmlBufferPtr conv; /* if encoder != NULL buffer for output */ |
---|
| 150 | intptr_t written; /* total number of byte written */ |
---|
| 151 | int error; |
---|
| 152 | }; |
---|
| 153 | #endif /* LIBXML_OUTPUT_ENABLED */ |
---|
| 154 | |
---|
| 155 | /* |
---|
| 156 | * Interfaces for input |
---|
| 157 | */ |
---|
| 158 | XMLPUBFUN void XMLCALL |
---|
| 159 | xmlCleanupInputCallbacks (void); |
---|
| 160 | |
---|
| 161 | XMLPUBFUN int XMLCALL |
---|
| 162 | xmlPopInputCallbacks (void); |
---|
| 163 | |
---|
| 164 | XMLPUBFUN void XMLCALL |
---|
| 165 | xmlRegisterDefaultInputCallbacks (void); |
---|
| 166 | XMLPUBFUN xmlParserInputBufferPtr XMLCALL |
---|
| 167 | xmlAllocParserInputBuffer (xmlCharEncoding enc); |
---|
| 168 | |
---|
| 169 | XMLPUBFUN xmlParserInputBufferPtr XMLCALL |
---|
| 170 | xmlParserInputBufferCreateFilename (const char *URI, |
---|
| 171 | xmlCharEncoding enc); |
---|
| 172 | XMLPUBFUN xmlParserInputBufferPtr XMLCALL |
---|
| 173 | xmlParserInputBufferCreateFile (FILE *file, |
---|
| 174 | xmlCharEncoding enc); |
---|
| 175 | XMLPUBFUN xmlParserInputBufferPtr XMLCALL |
---|
| 176 | xmlParserInputBufferCreateFd (int fd, |
---|
| 177 | xmlCharEncoding enc); |
---|
| 178 | XMLPUBFUN xmlParserInputBufferPtr XMLCALL |
---|
| 179 | xmlParserInputBufferCreateMem (const char *mem, intptr_t size, |
---|
| 180 | xmlCharEncoding enc); |
---|
| 181 | XMLPUBFUN xmlParserInputBufferPtr XMLCALL |
---|
| 182 | xmlParserInputBufferCreateStatic (const char *mem, intptr_t size, |
---|
| 183 | xmlCharEncoding enc); |
---|
| 184 | XMLPUBFUN xmlParserInputBufferPtr XMLCALL |
---|
| 185 | xmlParserInputBufferCreateIO (xmlInputReadCallback ioread, |
---|
| 186 | xmlInputCloseCallback ioclose, |
---|
| 187 | void *ioctx, |
---|
| 188 | xmlCharEncoding enc); |
---|
| 189 | XMLPUBFUN intptr_t XMLCALL |
---|
| 190 | xmlParserInputBufferRead (xmlParserInputBufferPtr in, |
---|
| 191 | intptr_t len); |
---|
| 192 | XMLPUBFUN intptr_t XMLCALL |
---|
| 193 | xmlParserInputBufferGrow (xmlParserInputBufferPtr in, |
---|
| 194 | intptr_t len); |
---|
| 195 | XMLPUBFUN intptr_t XMLCALL |
---|
| 196 | xmlParserInputBufferPush (xmlParserInputBufferPtr in, |
---|
| 197 | intptr_t len, |
---|
| 198 | const char *buf); |
---|
| 199 | XMLPUBFUN void XMLCALL |
---|
| 200 | xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); |
---|
| 201 | XMLPUBFUN char * XMLCALL |
---|
| 202 | xmlParserGetDirectory (const char *filename); |
---|
| 203 | |
---|
| 204 | XMLPUBFUN int XMLCALL |
---|
| 205 | xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc, |
---|
| 206 | xmlInputOpenCallback openFunc, |
---|
| 207 | xmlInputReadCallback readFunc, |
---|
| 208 | xmlInputCloseCallback closeFunc); |
---|
| 209 | |
---|
| 210 | xmlParserInputBufferPtr |
---|
| 211 | __xmlParserInputBufferCreateFilename(const char *URI, |
---|
| 212 | xmlCharEncoding enc); |
---|
| 213 | |
---|
| 214 | #ifdef LIBXML_OUTPUT_ENABLED |
---|
| 215 | /* |
---|
| 216 | * Interfaces for output |
---|
| 217 | */ |
---|
| 218 | XMLPUBFUN void XMLCALL |
---|
| 219 | xmlCleanupOutputCallbacks (void); |
---|
| 220 | XMLPUBFUN void XMLCALL |
---|
| 221 | xmlRegisterDefaultOutputCallbacks(void); |
---|
| 222 | XMLPUBFUN xmlOutputBufferPtr XMLCALL |
---|
| 223 | xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder); |
---|
| 224 | |
---|
| 225 | XMLPUBFUN xmlOutputBufferPtr XMLCALL |
---|
| 226 | xmlOutputBufferCreateFilename (const char *URI, |
---|
| 227 | xmlCharEncodingHandlerPtr encoder, |
---|
| 228 | int compression); |
---|
| 229 | |
---|
| 230 | XMLPUBFUN xmlOutputBufferPtr XMLCALL |
---|
| 231 | xmlOutputBufferCreateFile (FILE *file, |
---|
| 232 | xmlCharEncodingHandlerPtr encoder); |
---|
| 233 | |
---|
| 234 | XMLPUBFUN xmlOutputBufferPtr XMLCALL |
---|
| 235 | xmlOutputBufferCreateFd (int fd, |
---|
| 236 | xmlCharEncodingHandlerPtr encoder); |
---|
| 237 | |
---|
| 238 | XMLPUBFUN xmlOutputBufferPtr XMLCALL |
---|
| 239 | xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite, |
---|
| 240 | xmlOutputCloseCallback ioclose, |
---|
| 241 | void *ioctx, |
---|
| 242 | xmlCharEncodingHandlerPtr encoder); |
---|
| 243 | |
---|
| 244 | XMLPUBFUN intptr_t XMLCALL |
---|
| 245 | xmlOutputBufferWrite (xmlOutputBufferPtr out, |
---|
| 246 | intptr_t len, |
---|
| 247 | const char *buf); |
---|
| 248 | XMLPUBFUN intptr_t XMLCALL |
---|
| 249 | xmlOutputBufferWriteString (xmlOutputBufferPtr out, |
---|
| 250 | const char *str); |
---|
| 251 | XMLPUBFUN intptr_t XMLCALL |
---|
| 252 | xmlOutputBufferWriteEscape (xmlOutputBufferPtr out, |
---|
| 253 | const xmlChar *str, |
---|
| 254 | xmlCharEncodingOutputFunc escaping); |
---|
| 255 | |
---|
| 256 | XMLPUBFUN intptr_t XMLCALL |
---|
| 257 | xmlOutputBufferFlush (xmlOutputBufferPtr out); |
---|
| 258 | XMLPUBFUN intptr_t XMLCALL |
---|
| 259 | xmlOutputBufferClose (xmlOutputBufferPtr out); |
---|
| 260 | |
---|
| 261 | XMLPUBFUN int XMLCALL |
---|
| 262 | xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc, |
---|
| 263 | xmlOutputOpenCallback openFunc, |
---|
| 264 | xmlOutputWriteCallback writeFunc, |
---|
| 265 | xmlOutputCloseCallback closeFunc); |
---|
| 266 | |
---|
| 267 | xmlOutputBufferPtr |
---|
| 268 | __xmlOutputBufferCreateFilename(const char *URI, |
---|
| 269 | xmlCharEncodingHandlerPtr encoder, |
---|
| 270 | int compression); |
---|
| 271 | |
---|
| 272 | #ifdef LIBXML_HTTP_ENABLED |
---|
| 273 | /* This function only exists if HTTP support built into the library */ |
---|
| 274 | XMLPUBFUN void XMLCALL |
---|
| 275 | xmlRegisterHTTPPostCallbacks (void ); |
---|
| 276 | #endif /* LIBXML_HTTP_ENABLED */ |
---|
| 277 | |
---|
| 278 | #endif /* LIBXML_OUTPUT_ENABLED */ |
---|
| 279 | |
---|
| 280 | XMLPUBFUN xmlParserInputPtr XMLCALL |
---|
| 281 | xmlCheckHTTPInput (xmlParserCtxtPtr ctxt, |
---|
| 282 | xmlParserInputPtr ret); |
---|
| 283 | |
---|
| 284 | /* |
---|
| 285 | * A predefined entity loader disabling network accesses |
---|
| 286 | */ |
---|
| 287 | XMLPUBFUN xmlParserInputPtr XMLCALL |
---|
| 288 | xmlNoNetExternalEntityLoader (const char *URL, |
---|
| 289 | const char *ID, |
---|
| 290 | xmlParserCtxtPtr ctxt); |
---|
| 291 | |
---|
| 292 | /* |
---|
| 293 | * xmlNormalizeWindowsPath is obsolete, don't use it. |
---|
| 294 | * Check xmlCanonicPath in uri.h for a better alternative. |
---|
| 295 | */ |
---|
| 296 | XMLPUBFUN xmlChar * XMLCALL |
---|
| 297 | xmlNormalizeWindowsPath (const xmlChar *path); |
---|
| 298 | |
---|
| 299 | XMLPUBFUN int XMLCALL |
---|
| 300 | xmlCheckFilename (const char *path); |
---|
| 301 | /** |
---|
| 302 | * Default 'file://' protocol callbacks |
---|
| 303 | */ |
---|
| 304 | XMLPUBFUN int XMLCALL |
---|
| 305 | xmlFileMatch (const char *filename); |
---|
| 306 | XMLPUBFUN void * XMLCALL |
---|
| 307 | xmlFileOpen (const char *filename); |
---|
| 308 | XMLPUBFUN intptr_t XMLCALL |
---|
| 309 | xmlFileRead (void * context, |
---|
| 310 | char * buffer, |
---|
| 311 | size_t len); |
---|
| 312 | XMLPUBFUN int XMLCALL |
---|
| 313 | xmlFileClose (void * context); |
---|
| 314 | |
---|
| 315 | /** |
---|
| 316 | * Default 'http://' protocol callbacks |
---|
| 317 | */ |
---|
| 318 | #ifdef LIBXML_HTTP_ENABLED |
---|
| 319 | XMLPUBFUN int XMLCALL |
---|
| 320 | xmlIOHTTPMatch (const char *filename); |
---|
| 321 | XMLPUBFUN void * XMLCALL |
---|
| 322 | xmlIOHTTPOpen (const char *filename); |
---|
| 323 | #ifdef LIBXML_OUTPUT_ENABLED |
---|
| 324 | XMLPUBFUN void * XMLCALL |
---|
| 325 | xmlIOHTTPOpenW (const char * post_uri, |
---|
| 326 | int compression ); |
---|
| 327 | #endif /* LIBXML_OUTPUT_ENABLED */ |
---|
| 328 | XMLPUBFUN int XMLCALL |
---|
| 329 | xmlIOHTTPRead (void * context, |
---|
| 330 | char * buffer, |
---|
| 331 | int len); |
---|
| 332 | XMLPUBFUN int XMLCALL |
---|
| 333 | xmlIOHTTPClose (void * context); |
---|
| 334 | #endif /* LIBXML_HTTP_ENABLED */ |
---|
| 335 | |
---|
| 336 | /** |
---|
| 337 | * Default 'ftp://' protocol callbacks |
---|
| 338 | */ |
---|
| 339 | #ifdef LIBXML_FTP_ENABLED |
---|
| 340 | XMLPUBFUN int XMLCALL |
---|
| 341 | xmlIOFTPMatch (const char *filename); |
---|
| 342 | XMLPUBFUN void * XMLCALL |
---|
| 343 | xmlIOFTPOpen (const char *filename); |
---|
| 344 | XMLPUBFUN int XMLCALL |
---|
| 345 | xmlIOFTPRead (void * context, |
---|
| 346 | char * buffer, |
---|
| 347 | int len); |
---|
| 348 | XMLPUBFUN int XMLCALL |
---|
| 349 | xmlIOFTPClose (void * context); |
---|
| 350 | #endif /* LIBXML_FTP_ENABLED */ |
---|
| 351 | |
---|
| 352 | #ifdef __cplusplus |
---|
| 353 | } |
---|
| 354 | #endif |
---|
| 355 | |
---|
| 356 | #endif /* __XML_IO_H__ */ |
---|