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