(root)/
gettext-0.22.4/
libtextstyle/
lib/
libxml/
xmlIO.in.h
       1  /* libxml2 - Library for parsing XML documents
       2   * Copyright (C) 2006-2019 Free Software Foundation, Inc.
       3   *
       4   * This file is not part of the GNU gettext program, but is used with
       5   * GNU gettext.
       6   *
       7   * The original copyright notice is as follows:
       8   */
       9  
      10  /*
      11   * Copyright (C) 1998-2012 Daniel Veillard.  All Rights Reserved.
      12   *
      13   * Permission is hereby granted, free of charge, to any person obtaining a copy
      14   * of this software and associated documentation files (the "Software"), to deal
      15   * in the Software without restriction, including without limitation the rights
      16   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      17   * copies of the Software, and to permit persons to whom the Software is fur-
      18   * nished to do so, subject to the following conditions:
      19   *
      20   * The above copyright notice and this permission notice shall be included in
      21   * all copies or substantial portions of the Software.
      22   *
      23   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      24   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
      25   * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
      26   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      27   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      28   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      29   * THE SOFTWARE.
      30   *
      31   * Author: Daniel Veillard
      32   */
      33  
      34  /*
      35   * Summary: interface for the I/O interfaces used by the parser
      36   * Description: interface for the I/O interfaces used by the parser
      37   */
      38  
      39  #ifndef __XML_IO_H__
      40  #define __XML_IO_H__
      41  
      42  #include <stdio.h>
      43  #include <libxml/xmlversion.h>
      44  
      45  #ifdef __cplusplus
      46  extern "C" {
      47  #endif
      48  
      49  /*
      50   * Those are the functions and datatypes for the parser input
      51   * I/O structures.
      52   */
      53  
      54  /**
      55   * xmlInputMatchCallback:
      56   * @filename: the filename or URI
      57   *
      58   * Callback used in the I/O Input API to detect if the current handler
      59   * can provide input fonctionnalities for this resource.
      60   *
      61   * Returns 1 if yes and 0 if another Input module should be used
      62   */
      63  typedef int (XMLCALL *xmlInputMatchCallback) (char const *filename);
      64  /**
      65   * xmlInputOpenCallback:
      66   * @filename: the filename or URI
      67   *
      68   * Callback used in the I/O Input API to open the resource
      69   *
      70   * Returns an Input context or NULL in case or error
      71   */
      72  typedef void * (XMLCALL *xmlInputOpenCallback) (char const *filename);
      73  /**
      74   * xmlInputReadCallback:
      75   * @context:  an Input context
      76   * @buffer:  the buffer to store data read
      77   * @len:  the length of the buffer in bytes
      78   *
      79   * Callback used in the I/O Input API to read the resource
      80   *
      81   * Returns the number of bytes read or -1 in case of error
      82   */
      83  typedef int (XMLCALL *xmlInputReadCallback) (void * context, char * buffer, int len);
      84  /**
      85   * xmlInputCloseCallback:
      86   * @context:  an Input context
      87   *
      88   * Callback used in the I/O Input API to close the resource
      89   *
      90   * Returns 0 or -1 in case of error
      91   */
      92  typedef int (XMLCALL *xmlInputCloseCallback) (void * context);
      93  
      94  #ifdef LIBXML_OUTPUT_ENABLED
      95  /*
      96   * Those are the functions and datatypes for the library output
      97   * I/O structures.
      98   */
      99  
     100  /**
     101   * xmlOutputMatchCallback:
     102   * @filename: the filename or URI
     103   *
     104   * Callback used in the I/O Output API to detect if the current handler
     105   * can provide output fonctionnalities for this resource.
     106   *
     107   * Returns 1 if yes and 0 if another Output module should be used
     108   */
     109  typedef int (XMLCALL *xmlOutputMatchCallback) (char const *filename);
     110  /**
     111   * xmlOutputOpenCallback:
     112   * @filename: the filename or URI
     113   *
     114   * Callback used in the I/O Output API to open the resource
     115   *
     116   * Returns an Output context or NULL in case or error
     117   */
     118  typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename);
     119  /**
     120   * xmlOutputWriteCallback:
     121   * @context:  an Output context
     122   * @buffer:  the buffer of data to write
     123   * @len:  the length of the buffer in bytes
     124   *
     125   * Callback used in the I/O Output API to write to the resource
     126   *
     127   * Returns the number of bytes written or -1 in case of error
     128   */
     129  typedef int (XMLCALL *xmlOutputWriteCallback) (void * context, const char * buffer,
     130                                         int len);
     131  /**
     132   * xmlOutputCloseCallback:
     133   * @context:  an Output context
     134   *
     135   * Callback used in the I/O Output API to close the resource
     136   *
     137   * Returns 0 or -1 in case of error
     138   */
     139  typedef int (XMLCALL *xmlOutputCloseCallback) (void * context);
     140  #endif /* LIBXML_OUTPUT_ENABLED */
     141  
     142  #ifdef __cplusplus
     143  }
     144  #endif
     145  
     146  #include <libxml/globals.h>
     147  #include <libxml/tree.h>
     148  #include <libxml/parser.h>
     149  #include <libxml/encoding.h>
     150  
     151  #ifdef __cplusplus
     152  extern "C" {
     153  #endif
     154  struct _xmlParserInputBuffer {
     155      void*                  context;
     156      xmlInputReadCallback   readcallback;
     157      xmlInputCloseCallback  closecallback;
     158  
     159      xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
     160  
     161      xmlBufPtr buffer;    /* Local buffer encoded in UTF-8 */
     162      xmlBufPtr raw;       /* if encoder != NULL buffer for raw input */
     163      int	compressed;	    /* -1=unknown, 0=not compressed, 1=compressed */
     164      int error;
     165      unsigned long rawconsumed;/* amount consumed from raw */
     166  };
     167  
     168  
     169  #ifdef LIBXML_OUTPUT_ENABLED
     170  struct _xmlOutputBuffer {
     171      void*                   context;
     172      xmlOutputWriteCallback  writecallback;
     173      xmlOutputCloseCallback  closecallback;
     174  
     175      xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
     176  
     177      xmlBufPtr buffer;    /* Local buffer encoded in UTF-8 or ISOLatin */
     178      xmlBufPtr conv;      /* if encoder != NULL buffer for output */
     179      int written;            /* total number of byte written */
     180      int error;
     181  };
     182  #endif /* LIBXML_OUTPUT_ENABLED */
     183  
     184  /*
     185   * Interfaces for input
     186   */
     187  XMLPUBFUN void XMLCALL
     188  	xmlCleanupInputCallbacks		(void);
     189  
     190  XMLPUBFUN int XMLCALL
     191  	xmlPopInputCallbacks			(void);
     192  
     193  XMLPUBFUN void XMLCALL
     194  	xmlRegisterDefaultInputCallbacks	(void);
     195  XMLPUBFUN xmlParserInputBufferPtr XMLCALL
     196  	xmlAllocParserInputBuffer		(xmlCharEncoding enc);
     197  
     198  XMLPUBFUN xmlParserInputBufferPtr XMLCALL
     199  	xmlParserInputBufferCreateFilename	(const char *URI,
     200                                                   xmlCharEncoding enc);
     201  XMLPUBFUN xmlParserInputBufferPtr XMLCALL
     202  	xmlParserInputBufferCreateFile		(FILE *file,
     203                                                   xmlCharEncoding enc);
     204  XMLPUBFUN xmlParserInputBufferPtr XMLCALL
     205  	xmlParserInputBufferCreateFd		(int fd,
     206  	                                         xmlCharEncoding enc);
     207  XMLPUBFUN xmlParserInputBufferPtr XMLCALL
     208  	xmlParserInputBufferCreateMem		(const char *mem, int size,
     209  	                                         xmlCharEncoding enc);
     210  XMLPUBFUN xmlParserInputBufferPtr XMLCALL
     211  	xmlParserInputBufferCreateStatic	(const char *mem, int size,
     212  	                                         xmlCharEncoding enc);
     213  XMLPUBFUN xmlParserInputBufferPtr XMLCALL
     214  	xmlParserInputBufferCreateIO		(xmlInputReadCallback   ioread,
     215  						 xmlInputCloseCallback  ioclose,
     216  						 void *ioctx,
     217  	                                         xmlCharEncoding enc);
     218  XMLPUBFUN int XMLCALL
     219  	xmlParserInputBufferRead		(xmlParserInputBufferPtr in,
     220  						 int len);
     221  XMLPUBFUN int XMLCALL
     222  	xmlParserInputBufferGrow		(xmlParserInputBufferPtr in,
     223  						 int len);
     224  XMLPUBFUN int XMLCALL
     225  	xmlParserInputBufferPush		(xmlParserInputBufferPtr in,
     226  						 int len,
     227  						 const char *buf);
     228  XMLPUBFUN void XMLCALL
     229  	xmlFreeParserInputBuffer		(xmlParserInputBufferPtr in);
     230  XMLPUBFUN char * XMLCALL
     231  	xmlParserGetDirectory			(const char *filename);
     232  
     233  XMLPUBFUN int XMLCALL
     234  	xmlRegisterInputCallbacks		(xmlInputMatchCallback matchFunc,
     235  						 xmlInputOpenCallback openFunc,
     236  						 xmlInputReadCallback readFunc,
     237  						 xmlInputCloseCallback closeFunc);
     238  
     239  xmlParserInputBufferPtr
     240  	__xmlParserInputBufferCreateFilename(const char *URI,
     241  						xmlCharEncoding enc);
     242  
     243  #ifdef LIBXML_OUTPUT_ENABLED
     244  /*
     245   * Interfaces for output
     246   */
     247  XMLPUBFUN void XMLCALL
     248  	xmlCleanupOutputCallbacks		(void);
     249  XMLPUBFUN void XMLCALL
     250  	xmlRegisterDefaultOutputCallbacks(void);
     251  XMLPUBFUN xmlOutputBufferPtr XMLCALL
     252  	xmlAllocOutputBuffer		(xmlCharEncodingHandlerPtr encoder);
     253  
     254  XMLPUBFUN xmlOutputBufferPtr XMLCALL
     255  	xmlOutputBufferCreateFilename	(const char *URI,
     256  					 xmlCharEncodingHandlerPtr encoder,
     257  					 int compression);
     258  
     259  XMLPUBFUN xmlOutputBufferPtr XMLCALL
     260  	xmlOutputBufferCreateFile	(FILE *file,
     261  					 xmlCharEncodingHandlerPtr encoder);
     262  
     263  XMLPUBFUN xmlOutputBufferPtr XMLCALL
     264  	xmlOutputBufferCreateBuffer	(xmlBufferPtr buffer,
     265  					 xmlCharEncodingHandlerPtr encoder);
     266  
     267  XMLPUBFUN xmlOutputBufferPtr XMLCALL
     268  	xmlOutputBufferCreateFd		(int fd,
     269  					 xmlCharEncodingHandlerPtr encoder);
     270  
     271  XMLPUBFUN xmlOutputBufferPtr XMLCALL
     272  	xmlOutputBufferCreateIO		(xmlOutputWriteCallback   iowrite,
     273  					 xmlOutputCloseCallback  ioclose,
     274  					 void *ioctx,
     275  					 xmlCharEncodingHandlerPtr encoder);
     276  
     277  /* Couple of APIs to get the output without digging into the buffers */
     278  XMLPUBFUN const xmlChar * XMLCALL
     279          xmlOutputBufferGetContent       (xmlOutputBufferPtr out);
     280  XMLPUBFUN size_t XMLCALL
     281          xmlOutputBufferGetSize          (xmlOutputBufferPtr out);
     282  
     283  XMLPUBFUN int XMLCALL
     284  	xmlOutputBufferWrite		(xmlOutputBufferPtr out,
     285  					 int len,
     286  					 const char *buf);
     287  XMLPUBFUN int XMLCALL
     288  	xmlOutputBufferWriteString	(xmlOutputBufferPtr out,
     289  					 const char *str);
     290  XMLPUBFUN int XMLCALL
     291  	xmlOutputBufferWriteEscape	(xmlOutputBufferPtr out,
     292  					 const xmlChar *str,
     293  					 xmlCharEncodingOutputFunc escaping);
     294  
     295  XMLPUBFUN int XMLCALL
     296  	xmlOutputBufferFlush		(xmlOutputBufferPtr out);
     297  XMLPUBFUN int XMLCALL
     298  	xmlOutputBufferClose		(xmlOutputBufferPtr out);
     299  
     300  XMLPUBFUN int XMLCALL
     301  	xmlRegisterOutputCallbacks	(xmlOutputMatchCallback matchFunc,
     302  					 xmlOutputOpenCallback openFunc,
     303  					 xmlOutputWriteCallback writeFunc,
     304  					 xmlOutputCloseCallback closeFunc);
     305  
     306  xmlOutputBufferPtr
     307  	__xmlOutputBufferCreateFilename(const char *URI,
     308                                xmlCharEncodingHandlerPtr encoder,
     309                                int compression);
     310  
     311  #ifdef LIBXML_HTTP_ENABLED
     312  /*  This function only exists if HTTP support built into the library  */
     313  XMLPUBFUN void XMLCALL
     314  	xmlRegisterHTTPPostCallbacks	(void );
     315  #endif /* LIBXML_HTTP_ENABLED */
     316  
     317  #endif /* LIBXML_OUTPUT_ENABLED */
     318  
     319  XMLPUBFUN xmlParserInputPtr XMLCALL
     320  	xmlCheckHTTPInput		(xmlParserCtxtPtr ctxt,
     321  					 xmlParserInputPtr ret);
     322  
     323  /*
     324   * A predefined entity loader disabling network accesses
     325   */
     326  XMLPUBFUN xmlParserInputPtr XMLCALL
     327  	xmlNoNetExternalEntityLoader	(const char *URL,
     328  					 const char *ID,
     329  					 xmlParserCtxtPtr ctxt);
     330  
     331  /*
     332   * xmlNormalizeWindowsPath is obsolete, don't use it.
     333   * Check xmlCanonicPath in uri.h for a better alternative.
     334   */
     335  XMLPUBFUN xmlChar * XMLCALL
     336  	xmlNormalizeWindowsPath		(const xmlChar *path);
     337  
     338  XMLPUBFUN int XMLCALL
     339  	xmlCheckFilename		(const char *path);
     340  /**
     341   * Default 'file://' protocol callbacks
     342   */
     343  XMLPUBFUN int XMLCALL
     344  	xmlFileMatch			(const char *filename);
     345  XMLPUBFUN void * XMLCALL
     346  	xmlFileOpen			(const char *filename);
     347  XMLPUBFUN int XMLCALL
     348  	xmlFileRead			(void * context,
     349  					 char * buffer,
     350  					 int len);
     351  XMLPUBFUN int XMLCALL
     352  	xmlFileClose			(void * context);
     353  
     354  /**
     355   * Default 'http://' protocol callbacks
     356   */
     357  #ifdef LIBXML_HTTP_ENABLED
     358  XMLPUBFUN int XMLCALL
     359  	xmlIOHTTPMatch			(const char *filename);
     360  XMLPUBFUN void * XMLCALL
     361  	xmlIOHTTPOpen			(const char *filename);
     362  #ifdef LIBXML_OUTPUT_ENABLED
     363  XMLPUBFUN void * XMLCALL
     364  	xmlIOHTTPOpenW			(const char * post_uri,
     365  					 int   compression );
     366  #endif /* LIBXML_OUTPUT_ENABLED */
     367  XMLPUBFUN int XMLCALL
     368  	xmlIOHTTPRead			(void * context,
     369  					 char * buffer,
     370  					 int len);
     371  XMLPUBFUN int XMLCALL
     372  	xmlIOHTTPClose			(void * context);
     373  #endif /* LIBXML_HTTP_ENABLED */
     374  
     375  /**
     376   * Default 'ftp://' protocol callbacks
     377   */
     378  #ifdef LIBXML_FTP_ENABLED
     379  XMLPUBFUN int XMLCALL
     380  	xmlIOFTPMatch			(const char *filename);
     381  XMLPUBFUN void * XMLCALL
     382  	xmlIOFTPOpen			(const char *filename);
     383  XMLPUBFUN int XMLCALL
     384  	xmlIOFTPRead			(void * context,
     385  					 char * buffer,
     386  					 int len);
     387  XMLPUBFUN int XMLCALL
     388  	xmlIOFTPClose			(void * context);
     389  #endif /* LIBXML_FTP_ENABLED */
     390  
     391  #ifdef __cplusplus
     392  }
     393  #endif
     394  
     395  #endif /* __XML_IO_H__ */