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