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 | 39c7d71 | 2000-09-10 16:14:55 +0000 | [diff] [blame] | 40 | xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */ |
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 | 7cfce32 | 2000-10-04 12:40:27 +0000 | [diff] [blame] | 74 | void xmlRegisterDefaultInputCallbacks (void); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 75 | xmlParserInputBufferPtr |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 76 | xmlAllocParserInputBuffer (xmlCharEncoding enc); |
| 77 | |
| 78 | xmlParserInputBufferPtr |
Daniel Veillard | 0604743 | 2000-04-24 11:33:38 +0000 | [diff] [blame] | 79 | xmlParserInputBufferCreateFilename (const char *URI, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 80 | xmlCharEncoding enc); |
| 81 | xmlParserInputBufferPtr |
| 82 | xmlParserInputBufferCreateFile (FILE *file, |
| 83 | xmlCharEncoding enc); |
| 84 | xmlParserInputBufferPtr |
| 85 | xmlParserInputBufferCreateFd (int fd, |
| 86 | xmlCharEncoding enc); |
Daniel Veillard | 5e873c4 | 2000-04-12 13:27:38 +0000 | [diff] [blame] | 87 | xmlParserInputBufferPtr |
Daniel Veillard | 46e370e | 2000-07-21 20:32:03 +0000 | [diff] [blame] | 88 | xmlParserInputBufferCreateMem (const char *mem, int size, |
| 89 | xmlCharEncoding enc); |
| 90 | xmlParserInputBufferPtr |
Daniel Veillard | 5e873c4 | 2000-04-12 13:27:38 +0000 | [diff] [blame] | 91 | xmlParserInputBufferCreateIO (xmlInputReadCallback ioread, |
| 92 | xmlInputCloseCallback ioclose, |
| 93 | void *ioctx, |
| 94 | xmlCharEncoding enc); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 95 | int xmlParserInputBufferRead (xmlParserInputBufferPtr in, |
| 96 | int len); |
| 97 | int xmlParserInputBufferGrow (xmlParserInputBufferPtr in, |
| 98 | int len); |
Daniel Veillard | 7f85850 | 1999-11-17 17:32:38 +0000 | [diff] [blame] | 99 | int xmlParserInputBufferPush (xmlParserInputBufferPtr in, |
| 100 | int len, |
Daniel Veillard | a819dac | 1999-11-24 18:04:22 +0000 | [diff] [blame] | 101 | const char *buf); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 102 | void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); |
| 103 | char * xmlParserGetDirectory (const char *filename); |
Daniel Veillard | e2d034d | 1999-07-27 19:52:06 +0000 | [diff] [blame] | 104 | |
Daniel Veillard | 5d211f4 | 2000-04-07 17:00:24 +0000 | [diff] [blame] | 105 | int xmlRegisterInputCallbacks (xmlInputMatchCallback match, |
| 106 | xmlInputOpenCallback open, |
| 107 | xmlInputReadCallback read, |
| 108 | xmlInputCloseCallback close); |
Daniel Veillard | be80396 | 2000-06-28 23:40:59 +0000 | [diff] [blame] | 109 | /* |
| 110 | * Interfaces for output |
| 111 | */ |
Daniel Veillard | 7cfce32 | 2000-10-04 12:40:27 +0000 | [diff] [blame] | 112 | void xmlRegisterDefaultOutputCallbacks(void); |
Daniel Veillard | be80396 | 2000-06-28 23:40:59 +0000 | [diff] [blame] | 113 | xmlOutputBufferPtr |
| 114 | xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder); |
| 115 | |
| 116 | xmlOutputBufferPtr |
| 117 | xmlOutputBufferCreateFilename (const char *URI, |
| 118 | xmlCharEncodingHandlerPtr encoder, |
| 119 | int compression); |
| 120 | |
| 121 | xmlOutputBufferPtr |
| 122 | xmlOutputBufferCreateFile (FILE *file, |
| 123 | xmlCharEncodingHandlerPtr encoder); |
| 124 | |
| 125 | xmlOutputBufferPtr |
| 126 | xmlOutputBufferCreateFd (int fd, |
| 127 | xmlCharEncodingHandlerPtr encoder); |
| 128 | |
| 129 | xmlOutputBufferPtr |
| 130 | xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite, |
| 131 | xmlOutputCloseCallback ioclose, |
| 132 | void *ioctx, |
| 133 | xmlCharEncodingHandlerPtr encoder); |
| 134 | |
| 135 | int xmlOutputBufferWrite (xmlOutputBufferPtr out, |
| 136 | int len, |
| 137 | const char *buf); |
| 138 | int xmlOutputBufferWriteString (xmlOutputBufferPtr out, |
| 139 | const char *str); |
| 140 | |
| 141 | int xmlOutputBufferFlush (xmlOutputBufferPtr out); |
| 142 | int xmlOutputBufferClose (xmlOutputBufferPtr out); |
| 143 | |
| 144 | int xmlRegisterOutputCallbacks (xmlOutputMatchCallback match, |
| 145 | xmlOutputOpenCallback open, |
| 146 | xmlOutputWriteCallback write, |
| 147 | xmlOutputCloseCallback close); |
| 148 | |
| 149 | /* |
| 150 | * This save function is part of tree.h actually |
| 151 | */ |
| 152 | int xmlSaveFileTo (xmlOutputBuffer *buf, |
| 153 | xmlDocPtr cur, |
| 154 | const char *encoding); |
Daniel Veillard | b656ebe | 2000-09-22 13:51:48 +0000 | [diff] [blame] | 155 | void xmlNodeDumpOutput (xmlOutputBufferPtr buf, |
| 156 | xmlDocPtr doc, |
| 157 | xmlNodePtr cur, |
| 158 | int level, |
| 159 | int format, |
| 160 | const char *encoding); |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 161 | #ifdef __cplusplus |
| 162 | } |
| 163 | #endif |
| 164 | |
| 165 | #endif /* __XML_IO_H__ */ |