Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:41:51

0001 /*
0002  * Summary: interface for the I/O interfaces used by the parser
0003  * Description: interface for the I/O interfaces used by the parser
0004  *
0005  * Copy: See Copyright for the status of this software.
0006  *
0007  * Author: Daniel Veillard
0008  */
0009 
0010 #ifndef __XML_IO_H__
0011 #define __XML_IO_H__
0012 
0013 /** DOC_DISABLE */
0014 #include <stdio.h>
0015 #include <libxml/xmlversion.h>
0016 #include <libxml/encoding.h>
0017 #define XML_TREE_INTERNALS
0018 #include <libxml/tree.h>
0019 #undef XML_TREE_INTERNALS
0020 /** DOC_ENABLE */
0021 
0022 #ifdef __cplusplus
0023 extern "C" {
0024 #endif
0025 
0026 /*
0027  * Those are the functions and datatypes for the parser input
0028  * I/O structures.
0029  */
0030 
0031 /**
0032  * xmlInputMatchCallback:
0033  * @filename: the filename or URI
0034  *
0035  * Callback used in the I/O Input API to detect if the current handler
0036  * can provide input functionality for this resource.
0037  *
0038  * Returns 1 if yes and 0 if another Input module should be used
0039  */
0040 typedef int (*xmlInputMatchCallback) (char const *filename);
0041 /**
0042  * xmlInputOpenCallback:
0043  * @filename: the filename or URI
0044  *
0045  * Callback used in the I/O Input API to open the resource
0046  *
0047  * Returns an Input context or NULL in case or error
0048  */
0049 typedef void * (*xmlInputOpenCallback) (char const *filename);
0050 /**
0051  * xmlInputReadCallback:
0052  * @context:  an Input context
0053  * @buffer:  the buffer to store data read
0054  * @len:  the length of the buffer in bytes
0055  *
0056  * Callback used in the I/O Input API to read the resource
0057  *
0058  * Returns the number of bytes read or -1 in case of error
0059  */
0060 typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
0061 /**
0062  * xmlInputCloseCallback:
0063  * @context:  an Input context
0064  *
0065  * Callback used in the I/O Input API to close the resource
0066  *
0067  * Returns 0 or -1 in case of error
0068  */
0069 typedef int (*xmlInputCloseCallback) (void * context);
0070 
0071 #ifdef LIBXML_OUTPUT_ENABLED
0072 /*
0073  * Those are the functions and datatypes for the library output
0074  * I/O structures.
0075  */
0076 
0077 /**
0078  * xmlOutputMatchCallback:
0079  * @filename: the filename or URI
0080  *
0081  * Callback used in the I/O Output API to detect if the current handler
0082  * can provide output functionality for this resource.
0083  *
0084  * Returns 1 if yes and 0 if another Output module should be used
0085  */
0086 typedef int (*xmlOutputMatchCallback) (char const *filename);
0087 /**
0088  * xmlOutputOpenCallback:
0089  * @filename: the filename or URI
0090  *
0091  * Callback used in the I/O Output API to open the resource
0092  *
0093  * Returns an Output context or NULL in case or error
0094  */
0095 typedef void * (*xmlOutputOpenCallback) (char const *filename);
0096 /**
0097  * xmlOutputWriteCallback:
0098  * @context:  an Output context
0099  * @buffer:  the buffer of data to write
0100  * @len:  the length of the buffer in bytes
0101  *
0102  * Callback used in the I/O Output API to write to the resource
0103  *
0104  * Returns the number of bytes written or -1 in case of error
0105  */
0106 typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
0107                                        int len);
0108 /**
0109  * xmlOutputCloseCallback:
0110  * @context:  an Output context
0111  *
0112  * Callback used in the I/O Output API to close the resource
0113  *
0114  * Returns 0 or -1 in case of error
0115  */
0116 typedef int (*xmlOutputCloseCallback) (void * context);
0117 #endif /* LIBXML_OUTPUT_ENABLED */
0118 
0119 /**
0120  * xmlParserInputBufferCreateFilenameFunc:
0121  * @URI: the URI to read from
0122  * @enc: the requested source encoding
0123  *
0124  * Signature for the function doing the lookup for a suitable input method
0125  * corresponding to an URI.
0126  *
0127  * Returns the new xmlParserInputBufferPtr in case of success or NULL if no
0128  *         method was found.
0129  */
0130 typedef xmlParserInputBufferPtr
0131 (*xmlParserInputBufferCreateFilenameFunc)(const char *URI, xmlCharEncoding enc);
0132 
0133 /**
0134  * xmlOutputBufferCreateFilenameFunc:
0135  * @URI: the URI to write to
0136  * @enc: the requested target encoding
0137  *
0138  * Signature for the function doing the lookup for a suitable output method
0139  * corresponding to an URI.
0140  *
0141  * Returns the new xmlOutputBufferPtr in case of success or NULL if no
0142  *         method was found.
0143  */
0144 typedef xmlOutputBufferPtr
0145 (*xmlOutputBufferCreateFilenameFunc)(const char *URI,
0146         xmlCharEncodingHandlerPtr encoder, int compression);
0147 
0148 struct _xmlParserInputBuffer {
0149     void*                  context;
0150     xmlInputReadCallback   readcallback;
0151     xmlInputCloseCallback  closecallback;
0152 
0153     xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
0154 
0155     xmlBufPtr buffer;    /* Local buffer encoded in UTF-8 */
0156     xmlBufPtr raw;       /* if encoder != NULL buffer for raw input */
0157     int compressed;     /* -1=unknown, 0=not compressed, 1=compressed */
0158     int error;
0159     unsigned long rawconsumed;/* amount consumed from raw */
0160 };
0161 
0162 
0163 #ifdef LIBXML_OUTPUT_ENABLED
0164 struct _xmlOutputBuffer {
0165     void*                   context;
0166     xmlOutputWriteCallback  writecallback;
0167     xmlOutputCloseCallback  closecallback;
0168 
0169     xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
0170 
0171     xmlBufPtr buffer;    /* Local buffer encoded in UTF-8 or ISOLatin */
0172     xmlBufPtr conv;      /* if encoder != NULL buffer for output */
0173     int written;            /* total number of byte written */
0174     int error;
0175 };
0176 #endif /* LIBXML_OUTPUT_ENABLED */
0177 
0178 /** DOC_DISABLE */
0179 #define XML_GLOBALS_IO \
0180   XML_OP(xmlParserInputBufferCreateFilenameValue, \
0181            xmlParserInputBufferCreateFilenameFunc, XML_DEPRECATED) \
0182   XML_OP(xmlOutputBufferCreateFilenameValue, \
0183            xmlOutputBufferCreateFilenameFunc, XML_DEPRECATED)
0184 
0185 #define XML_OP XML_DECLARE_GLOBAL
0186 XML_GLOBALS_IO
0187 #undef XML_OP
0188 
0189 #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
0190   #define xmlParserInputBufferCreateFilenameValue \
0191     XML_GLOBAL_MACRO(xmlParserInputBufferCreateFilenameValue)
0192   #define xmlOutputBufferCreateFilenameValue \
0193     XML_GLOBAL_MACRO(xmlOutputBufferCreateFilenameValue)
0194 #endif
0195 /** DOC_ENABLE */
0196 
0197 /*
0198  * Interfaces for input
0199  */
0200 XMLPUBFUN void
0201     xmlCleanupInputCallbacks        (void);
0202 
0203 XMLPUBFUN int
0204     xmlPopInputCallbacks            (void);
0205 
0206 XMLPUBFUN void
0207     xmlRegisterDefaultInputCallbacks    (void);
0208 XMLPUBFUN xmlParserInputBufferPtr
0209     xmlAllocParserInputBuffer       (xmlCharEncoding enc);
0210 
0211 XMLPUBFUN xmlParserInputBufferPtr
0212     xmlParserInputBufferCreateFilename  (const char *URI,
0213                                                  xmlCharEncoding enc);
0214 XMLPUBFUN xmlParserInputBufferPtr
0215     xmlParserInputBufferCreateFile      (FILE *file,
0216                                                  xmlCharEncoding enc);
0217 XMLPUBFUN xmlParserInputBufferPtr
0218     xmlParserInputBufferCreateFd        (int fd,
0219                                              xmlCharEncoding enc);
0220 XMLPUBFUN xmlParserInputBufferPtr
0221     xmlParserInputBufferCreateMem       (const char *mem, int size,
0222                                              xmlCharEncoding enc);
0223 XMLPUBFUN xmlParserInputBufferPtr
0224     xmlParserInputBufferCreateStatic    (const char *mem, int size,
0225                                              xmlCharEncoding enc);
0226 XMLPUBFUN xmlParserInputBufferPtr
0227     xmlParserInputBufferCreateIO        (xmlInputReadCallback   ioread,
0228                          xmlInputCloseCallback  ioclose,
0229                          void *ioctx,
0230                                              xmlCharEncoding enc);
0231 XMLPUBFUN int
0232     xmlParserInputBufferRead        (xmlParserInputBufferPtr in,
0233                          int len);
0234 XMLPUBFUN int
0235     xmlParserInputBufferGrow        (xmlParserInputBufferPtr in,
0236                          int len);
0237 XMLPUBFUN int
0238     xmlParserInputBufferPush        (xmlParserInputBufferPtr in,
0239                          int len,
0240                          const char *buf);
0241 XMLPUBFUN void
0242     xmlFreeParserInputBuffer        (xmlParserInputBufferPtr in);
0243 XMLPUBFUN char *
0244     xmlParserGetDirectory           (const char *filename);
0245 
0246 XMLPUBFUN int
0247     xmlRegisterInputCallbacks       (xmlInputMatchCallback matchFunc,
0248                          xmlInputOpenCallback openFunc,
0249                          xmlInputReadCallback readFunc,
0250                          xmlInputCloseCallback closeFunc);
0251 
0252 xmlParserInputBufferPtr
0253     __xmlParserInputBufferCreateFilename(const char *URI,
0254                         xmlCharEncoding enc);
0255 
0256 #ifdef LIBXML_OUTPUT_ENABLED
0257 /*
0258  * Interfaces for output
0259  */
0260 XMLPUBFUN void
0261     xmlCleanupOutputCallbacks       (void);
0262 XMLPUBFUN int
0263     xmlPopOutputCallbacks           (void);
0264 XMLPUBFUN void
0265     xmlRegisterDefaultOutputCallbacks(void);
0266 XMLPUBFUN xmlOutputBufferPtr
0267     xmlAllocOutputBuffer        (xmlCharEncodingHandlerPtr encoder);
0268 
0269 XMLPUBFUN xmlOutputBufferPtr
0270     xmlOutputBufferCreateFilename   (const char *URI,
0271                      xmlCharEncodingHandlerPtr encoder,
0272                      int compression);
0273 
0274 XMLPUBFUN xmlOutputBufferPtr
0275     xmlOutputBufferCreateFile   (FILE *file,
0276                      xmlCharEncodingHandlerPtr encoder);
0277 
0278 XMLPUBFUN xmlOutputBufferPtr
0279     xmlOutputBufferCreateBuffer (xmlBufferPtr buffer,
0280                      xmlCharEncodingHandlerPtr encoder);
0281 
0282 XMLPUBFUN xmlOutputBufferPtr
0283     xmlOutputBufferCreateFd     (int fd,
0284                      xmlCharEncodingHandlerPtr encoder);
0285 
0286 XMLPUBFUN xmlOutputBufferPtr
0287     xmlOutputBufferCreateIO     (xmlOutputWriteCallback   iowrite,
0288                      xmlOutputCloseCallback  ioclose,
0289                      void *ioctx,
0290                      xmlCharEncodingHandlerPtr encoder);
0291 
0292 /* Couple of APIs to get the output without digging into the buffers */
0293 XMLPUBFUN const xmlChar *
0294         xmlOutputBufferGetContent       (xmlOutputBufferPtr out);
0295 XMLPUBFUN size_t
0296         xmlOutputBufferGetSize          (xmlOutputBufferPtr out);
0297 
0298 XMLPUBFUN int
0299     xmlOutputBufferWrite        (xmlOutputBufferPtr out,
0300                      int len,
0301                      const char *buf);
0302 XMLPUBFUN int
0303     xmlOutputBufferWriteString  (xmlOutputBufferPtr out,
0304                      const char *str);
0305 XMLPUBFUN int
0306     xmlOutputBufferWriteEscape  (xmlOutputBufferPtr out,
0307                      const xmlChar *str,
0308                      xmlCharEncodingOutputFunc escaping);
0309 
0310 XMLPUBFUN int
0311     xmlOutputBufferFlush        (xmlOutputBufferPtr out);
0312 XMLPUBFUN int
0313     xmlOutputBufferClose        (xmlOutputBufferPtr out);
0314 
0315 XMLPUBFUN int
0316     xmlRegisterOutputCallbacks  (xmlOutputMatchCallback matchFunc,
0317                      xmlOutputOpenCallback openFunc,
0318                      xmlOutputWriteCallback writeFunc,
0319                      xmlOutputCloseCallback closeFunc);
0320 
0321 xmlOutputBufferPtr
0322     __xmlOutputBufferCreateFilename(const char *URI,
0323                               xmlCharEncodingHandlerPtr encoder,
0324                               int compression);
0325 
0326 #ifdef LIBXML_HTTP_ENABLED
0327 /*  This function only exists if HTTP support built into the library  */
0328 XML_DEPRECATED
0329 XMLPUBFUN void
0330     xmlRegisterHTTPPostCallbacks    (void );
0331 #endif /* LIBXML_HTTP_ENABLED */
0332 
0333 #endif /* LIBXML_OUTPUT_ENABLED */
0334 
0335 XML_DEPRECATED
0336 XMLPUBFUN xmlParserInputPtr
0337     xmlCheckHTTPInput       (xmlParserCtxtPtr ctxt,
0338                      xmlParserInputPtr ret);
0339 
0340 /*
0341  * A predefined entity loader disabling network accesses
0342  */
0343 XMLPUBFUN xmlParserInputPtr
0344     xmlNoNetExternalEntityLoader    (const char *URL,
0345                      const char *ID,
0346                      xmlParserCtxtPtr ctxt);
0347 
0348 XML_DEPRECATED
0349 XMLPUBFUN xmlChar *
0350     xmlNormalizeWindowsPath     (const xmlChar *path);
0351 
0352 XML_DEPRECATED
0353 XMLPUBFUN int
0354     xmlCheckFilename        (const char *path);
0355 /**
0356  * Default 'file://' protocol callbacks
0357  */
0358 XML_DEPRECATED
0359 XMLPUBFUN int
0360     xmlFileMatch            (const char *filename);
0361 XML_DEPRECATED
0362 XMLPUBFUN void *
0363     xmlFileOpen         (const char *filename);
0364 XML_DEPRECATED
0365 XMLPUBFUN int
0366     xmlFileRead         (void * context,
0367                      char * buffer,
0368                      int len);
0369 XML_DEPRECATED
0370 XMLPUBFUN int
0371     xmlFileClose            (void * context);
0372 
0373 /**
0374  * Default 'http://' protocol callbacks
0375  */
0376 #ifdef LIBXML_HTTP_ENABLED
0377 XML_DEPRECATED
0378 XMLPUBFUN int
0379     xmlIOHTTPMatch          (const char *filename);
0380 XML_DEPRECATED
0381 XMLPUBFUN void *
0382     xmlIOHTTPOpen           (const char *filename);
0383 #ifdef LIBXML_OUTPUT_ENABLED
0384 XML_DEPRECATED
0385 XMLPUBFUN void *
0386     xmlIOHTTPOpenW          (const char * post_uri,
0387                      int   compression );
0388 #endif /* LIBXML_OUTPUT_ENABLED */
0389 XML_DEPRECATED
0390 XMLPUBFUN int
0391     xmlIOHTTPRead           (void * context,
0392                      char * buffer,
0393                      int len);
0394 XML_DEPRECATED
0395 XMLPUBFUN int
0396     xmlIOHTTPClose          (void * context);
0397 #endif /* LIBXML_HTTP_ENABLED */
0398 
0399 /**
0400  * Default 'ftp://' protocol callbacks
0401  */
0402 #if defined(LIBXML_FTP_ENABLED)
0403 XML_DEPRECATED
0404 XMLPUBFUN int
0405     xmlIOFTPMatch           (const char *filename);
0406 XML_DEPRECATED
0407 XMLPUBFUN void *
0408     xmlIOFTPOpen            (const char *filename);
0409 XML_DEPRECATED
0410 XMLPUBFUN int
0411     xmlIOFTPRead            (void * context,
0412                      char * buffer,
0413                      int len);
0414 XML_DEPRECATED
0415 XMLPUBFUN int
0416     xmlIOFTPClose           (void * context);
0417 #endif /* defined(LIBXML_FTP_ENABLED) */
0418 
0419 XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
0420     xmlParserInputBufferCreateFilenameDefault(
0421         xmlParserInputBufferCreateFilenameFunc func);
0422 XMLPUBFUN xmlOutputBufferCreateFilenameFunc
0423     xmlOutputBufferCreateFilenameDefault(
0424         xmlOutputBufferCreateFilenameFunc func);
0425 XML_DEPRECATED
0426 XMLPUBFUN xmlOutputBufferCreateFilenameFunc
0427     xmlThrDefOutputBufferCreateFilenameDefault(
0428         xmlOutputBufferCreateFilenameFunc func);
0429 XML_DEPRECATED
0430 XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
0431     xmlThrDefParserInputBufferCreateFilenameDefault(
0432         xmlParserInputBufferCreateFilenameFunc func);
0433 
0434 #ifdef __cplusplus
0435 }
0436 #endif
0437 
0438 #endif /* __XML_IO_H__ */