Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +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 | * |
| 6 | * Daniel.Veillard@w3.org |
| 7 | */ |
| 8 | |
| 9 | #ifndef __XML_IO_H__ |
| 10 | #define __XML_IO_H__ |
| 11 | |
| 12 | #include <stdio.h> |
Daniel Veillard | 361d845 | 2000-04-03 19:48:13 +0000 | [diff] [blame] | 13 | #include <libxml/tree.h> |
| 14 | #include <libxml/parser.h> |
| 15 | #include <libxml/encoding.h> |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 16 | |
| 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
Daniel Veillard | be80396 | 2000-06-28 23:40:59 +0000 | [diff] [blame] | 21 | /* |
| 22 | * Those are the functions and datatypes for the parser input |
| 23 | * I/O structures. |
| 24 | */ |
| 25 | |
Daniel Veillard | 5d211f4 | 2000-04-07 17:00:24 +0000 | [diff] [blame] | 26 | typedef int (*xmlInputMatchCallback) (char const *filename); |
| 27 | typedef void * (*xmlInputOpenCallback) (char const *filename); |
| 28 | typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len); |
| 29 | typedef void (*xmlInputCloseCallback) (void * context); |
| 30 | |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 31 | typedef struct _xmlParserInputBuffer xmlParserInputBuffer; |
| 32 | typedef xmlParserInputBuffer *xmlParserInputBufferPtr; |
| 33 | struct _xmlParserInputBuffer { |
Daniel Veillard | 5d211f4 | 2000-04-07 17:00:24 +0000 | [diff] [blame] | 34 | void* context; |
| 35 | xmlInputReadCallback readcallback; |
| 36 | xmlInputCloseCallback closecallback; |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 37 | |
Daniel Veillard | e2d034d | 1999-07-27 19:52:06 +0000 | [diff] [blame] | 38 | xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 39 | |
Daniel Veillard | be80396 | 2000-06-28 23:40:59 +0000 | [diff] [blame] | 40 | xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */ |
Daniel Veillard | 496a1cf | 2000-05-03 14:20:55 +0000 | [diff] [blame] | 41 | xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */ |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 42 | }; |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 43 | |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 44 | |
Daniel Veillard | e2d034d | 1999-07-27 19:52:06 +0000 | [diff] [blame] | 45 | /* |
Daniel Veillard | be80396 | 2000-06-28 23:40:59 +0000 | [diff] [blame] | 46 | * Those are the functions and datatypes for the library output |
| 47 | * I/O structures. |
| 48 | */ |
| 49 | |
| 50 | typedef int (*xmlOutputMatchCallback) (char const *filename); |
| 51 | typedef void * (*xmlOutputOpenCallback) (char const *filename); |
| 52 | typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer, |
| 53 | int len); |
| 54 | typedef void (*xmlOutputCloseCallback) (void * context); |
| 55 | |
| 56 | typedef struct _xmlOutputBuffer xmlOutputBuffer; |
| 57 | typedef xmlOutputBuffer *xmlOutputBufferPtr; |
| 58 | struct _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 Veillard | e2d034d | 1999-07-27 19:52:06 +0000 | [diff] [blame] | 72 | */ |
| 73 | |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 74 | xmlParserInputBufferPtr |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 75 | xmlAllocParserInputBuffer (xmlCharEncoding enc); |
| 76 | |
| 77 | xmlParserInputBufferPtr |
Daniel Veillard | 0604743 | 2000-04-24 11:33:38 +0000 | [diff] [blame] | 78 | xmlParserInputBufferCreateFilename (const char *URI, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 79 | xmlCharEncoding enc); |
| 80 | xmlParserInputBufferPtr |
| 81 | xmlParserInputBufferCreateFile (FILE *file, |
| 82 | xmlCharEncoding enc); |
| 83 | xmlParserInputBufferPtr |
| 84 | xmlParserInputBufferCreateFd (int fd, |
| 85 | xmlCharEncoding enc); |
Daniel Veillard | 5e873c4 | 2000-04-12 13:27:38 +0000 | [diff] [blame] | 86 | xmlParserInputBufferPtr |
Daniel Veillard | 46e370e | 2000-07-21 20:32:03 +0000 | [diff] [blame] | 87 | xmlParserInputBufferCreateMem (const char *mem, int size, |
| 88 | xmlCharEncoding enc); |
| 89 | xmlParserInputBufferPtr |
Daniel Veillard | 5e873c4 | 2000-04-12 13:27:38 +0000 | [diff] [blame] | 90 | xmlParserInputBufferCreateIO (xmlInputReadCallback ioread, |
| 91 | xmlInputCloseCallback ioclose, |
| 92 | void *ioctx, |
| 93 | xmlCharEncoding enc); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 94 | int xmlParserInputBufferRead (xmlParserInputBufferPtr in, |
| 95 | int len); |
| 96 | int xmlParserInputBufferGrow (xmlParserInputBufferPtr in, |
| 97 | int len); |
Daniel Veillard | 7f85850 | 1999-11-17 17:32:38 +0000 | [diff] [blame] | 98 | int xmlParserInputBufferPush (xmlParserInputBufferPtr in, |
| 99 | int len, |
Daniel Veillard | a819dac | 1999-11-24 18:04:22 +0000 | [diff] [blame] | 100 | const char *buf); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 101 | void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); |
| 102 | char * xmlParserGetDirectory (const char *filename); |
Daniel Veillard | e2d034d | 1999-07-27 19:52:06 +0000 | [diff] [blame] | 103 | |
Daniel Veillard | 5d211f4 | 2000-04-07 17:00:24 +0000 | [diff] [blame] | 104 | int xmlRegisterInputCallbacks (xmlInputMatchCallback match, |
| 105 | xmlInputOpenCallback open, |
| 106 | xmlInputReadCallback read, |
| 107 | xmlInputCloseCallback close); |
Daniel Veillard | be80396 | 2000-06-28 23:40:59 +0000 | [diff] [blame] | 108 | /* |
| 109 | * Interfaces for output |
| 110 | */ |
| 111 | xmlOutputBufferPtr |
| 112 | xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder); |
| 113 | |
| 114 | xmlOutputBufferPtr |
| 115 | xmlOutputBufferCreateFilename (const char *URI, |
| 116 | xmlCharEncodingHandlerPtr encoder, |
| 117 | int compression); |
| 118 | |
| 119 | xmlOutputBufferPtr |
| 120 | xmlOutputBufferCreateFile (FILE *file, |
| 121 | xmlCharEncodingHandlerPtr encoder); |
| 122 | |
| 123 | xmlOutputBufferPtr |
| 124 | xmlOutputBufferCreateFd (int fd, |
| 125 | xmlCharEncodingHandlerPtr encoder); |
| 126 | |
| 127 | xmlOutputBufferPtr |
| 128 | xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite, |
| 129 | xmlOutputCloseCallback ioclose, |
| 130 | void *ioctx, |
| 131 | xmlCharEncodingHandlerPtr encoder); |
| 132 | |
| 133 | int xmlOutputBufferWrite (xmlOutputBufferPtr out, |
| 134 | int len, |
| 135 | const char *buf); |
| 136 | int xmlOutputBufferWriteString (xmlOutputBufferPtr out, |
| 137 | const char *str); |
| 138 | |
| 139 | int xmlOutputBufferFlush (xmlOutputBufferPtr out); |
| 140 | int xmlOutputBufferClose (xmlOutputBufferPtr out); |
| 141 | |
| 142 | int xmlRegisterOutputCallbacks (xmlOutputMatchCallback match, |
| 143 | xmlOutputOpenCallback open, |
| 144 | xmlOutputWriteCallback write, |
| 145 | xmlOutputCloseCallback close); |
| 146 | |
| 147 | /* |
| 148 | * This save function is part of tree.h actually |
| 149 | */ |
| 150 | int xmlSaveFileTo (xmlOutputBuffer *buf, |
| 151 | xmlDocPtr cur, |
| 152 | const char *encoding); |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 153 | #ifdef __cplusplus |
| 154 | } |
| 155 | #endif |
| 156 | |
| 157 | #endif /* __XML_IO_H__ */ |