Path: blob/master/venv/Lib/site-packages/lxml/includes/libxml/xmlIO.h
811 views
/*1* Summary: interface for the I/O interfaces used by the parser2* Description: interface for the I/O interfaces used by the parser3*4* Copy: See Copyright for the status of this software.5*6* Author: Daniel Veillard7*/89#ifndef __XML_IO_H__10#define __XML_IO_H__1112#include <stdio.h>13#include <libxml/xmlversion.h>1415#ifdef __cplusplus16extern "C" {17#endif1819/*20* Those are the functions and datatypes for the parser input21* I/O structures.22*/2324/**25* xmlInputMatchCallback:26* @filename: the filename or URI27*28* Callback used in the I/O Input API to detect if the current handler29* can provide input fonctionnalities for this resource.30*31* Returns 1 if yes and 0 if another Input module should be used32*/33typedef int (XMLCALL *xmlInputMatchCallback) (char const *filename);34/**35* xmlInputOpenCallback:36* @filename: the filename or URI37*38* Callback used in the I/O Input API to open the resource39*40* Returns an Input context or NULL in case or error41*/42typedef void * (XMLCALL *xmlInputOpenCallback) (char const *filename);43/**44* xmlInputReadCallback:45* @context: an Input context46* @buffer: the buffer to store data read47* @len: the length of the buffer in bytes48*49* Callback used in the I/O Input API to read the resource50*51* Returns the number of bytes read or -1 in case of error52*/53typedef int (XMLCALL *xmlInputReadCallback) (void * context, char * buffer, int len);54/**55* xmlInputCloseCallback:56* @context: an Input context57*58* Callback used in the I/O Input API to close the resource59*60* Returns 0 or -1 in case of error61*/62typedef int (XMLCALL *xmlInputCloseCallback) (void * context);6364#ifdef LIBXML_OUTPUT_ENABLED65/*66* Those are the functions and datatypes for the library output67* I/O structures.68*/6970/**71* xmlOutputMatchCallback:72* @filename: the filename or URI73*74* Callback used in the I/O Output API to detect if the current handler75* can provide output fonctionnalities for this resource.76*77* Returns 1 if yes and 0 if another Output module should be used78*/79typedef int (XMLCALL *xmlOutputMatchCallback) (char const *filename);80/**81* xmlOutputOpenCallback:82* @filename: the filename or URI83*84* Callback used in the I/O Output API to open the resource85*86* Returns an Output context or NULL in case or error87*/88typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename);89/**90* xmlOutputWriteCallback:91* @context: an Output context92* @buffer: the buffer of data to write93* @len: the length of the buffer in bytes94*95* Callback used in the I/O Output API to write to the resource96*97* Returns the number of bytes written or -1 in case of error98*/99typedef int (XMLCALL *xmlOutputWriteCallback) (void * context, const char * buffer,100int len);101/**102* xmlOutputCloseCallback:103* @context: an Output context104*105* Callback used in the I/O Output API to close the resource106*107* Returns 0 or -1 in case of error108*/109typedef int (XMLCALL *xmlOutputCloseCallback) (void * context);110#endif /* LIBXML_OUTPUT_ENABLED */111112#ifdef __cplusplus113}114#endif115116#include <libxml/globals.h>117#include <libxml/tree.h>118#include <libxml/parser.h>119#include <libxml/encoding.h>120121#ifdef __cplusplus122extern "C" {123#endif124struct _xmlParserInputBuffer {125void* context;126xmlInputReadCallback readcallback;127xmlInputCloseCallback closecallback;128129xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */130131xmlBufPtr buffer; /* Local buffer encoded in UTF-8 */132xmlBufPtr raw; /* if encoder != NULL buffer for raw input */133int compressed; /* -1=unknown, 0=not compressed, 1=compressed */134int error;135unsigned long rawconsumed;/* amount consumed from raw */136};137138139#ifdef LIBXML_OUTPUT_ENABLED140struct _xmlOutputBuffer {141void* context;142xmlOutputWriteCallback writecallback;143xmlOutputCloseCallback closecallback;144145xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */146147xmlBufPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */148xmlBufPtr conv; /* if encoder != NULL buffer for output */149int written; /* total number of byte written */150int error;151};152#endif /* LIBXML_OUTPUT_ENABLED */153154/*155* Interfaces for input156*/157XMLPUBFUN void XMLCALL158xmlCleanupInputCallbacks (void);159160XMLPUBFUN int XMLCALL161xmlPopInputCallbacks (void);162163XMLPUBFUN void XMLCALL164xmlRegisterDefaultInputCallbacks (void);165XMLPUBFUN xmlParserInputBufferPtr XMLCALL166xmlAllocParserInputBuffer (xmlCharEncoding enc);167168XMLPUBFUN xmlParserInputBufferPtr XMLCALL169xmlParserInputBufferCreateFilename (const char *URI,170xmlCharEncoding enc);171XMLPUBFUN xmlParserInputBufferPtr XMLCALL172xmlParserInputBufferCreateFile (FILE *file,173xmlCharEncoding enc);174XMLPUBFUN xmlParserInputBufferPtr XMLCALL175xmlParserInputBufferCreateFd (int fd,176xmlCharEncoding enc);177XMLPUBFUN xmlParserInputBufferPtr XMLCALL178xmlParserInputBufferCreateMem (const char *mem, int size,179xmlCharEncoding enc);180XMLPUBFUN xmlParserInputBufferPtr XMLCALL181xmlParserInputBufferCreateStatic (const char *mem, int size,182xmlCharEncoding enc);183XMLPUBFUN xmlParserInputBufferPtr XMLCALL184xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,185xmlInputCloseCallback ioclose,186void *ioctx,187xmlCharEncoding enc);188XMLPUBFUN int XMLCALL189xmlParserInputBufferRead (xmlParserInputBufferPtr in,190int len);191XMLPUBFUN int XMLCALL192xmlParserInputBufferGrow (xmlParserInputBufferPtr in,193int len);194XMLPUBFUN int XMLCALL195xmlParserInputBufferPush (xmlParserInputBufferPtr in,196int len,197const char *buf);198XMLPUBFUN void XMLCALL199xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);200XMLPUBFUN char * XMLCALL201xmlParserGetDirectory (const char *filename);202203XMLPUBFUN int XMLCALL204xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,205xmlInputOpenCallback openFunc,206xmlInputReadCallback readFunc,207xmlInputCloseCallback closeFunc);208209xmlParserInputBufferPtr210__xmlParserInputBufferCreateFilename(const char *URI,211xmlCharEncoding enc);212213#ifdef LIBXML_OUTPUT_ENABLED214/*215* Interfaces for output216*/217XMLPUBFUN void XMLCALL218xmlCleanupOutputCallbacks (void);219XMLPUBFUN void XMLCALL220xmlRegisterDefaultOutputCallbacks(void);221XMLPUBFUN xmlOutputBufferPtr XMLCALL222xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);223224XMLPUBFUN xmlOutputBufferPtr XMLCALL225xmlOutputBufferCreateFilename (const char *URI,226xmlCharEncodingHandlerPtr encoder,227int compression);228229XMLPUBFUN xmlOutputBufferPtr XMLCALL230xmlOutputBufferCreateFile (FILE *file,231xmlCharEncodingHandlerPtr encoder);232233XMLPUBFUN xmlOutputBufferPtr XMLCALL234xmlOutputBufferCreateBuffer (xmlBufferPtr buffer,235xmlCharEncodingHandlerPtr encoder);236237XMLPUBFUN xmlOutputBufferPtr XMLCALL238xmlOutputBufferCreateFd (int fd,239xmlCharEncodingHandlerPtr encoder);240241XMLPUBFUN xmlOutputBufferPtr XMLCALL242xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,243xmlOutputCloseCallback ioclose,244void *ioctx,245xmlCharEncodingHandlerPtr encoder);246247/* Couple of APIs to get the output without digging into the buffers */248XMLPUBFUN const xmlChar * XMLCALL249xmlOutputBufferGetContent (xmlOutputBufferPtr out);250XMLPUBFUN size_t XMLCALL251xmlOutputBufferGetSize (xmlOutputBufferPtr out);252253XMLPUBFUN int XMLCALL254xmlOutputBufferWrite (xmlOutputBufferPtr out,255int len,256const char *buf);257XMLPUBFUN int XMLCALL258xmlOutputBufferWriteString (xmlOutputBufferPtr out,259const char *str);260XMLPUBFUN int XMLCALL261xmlOutputBufferWriteEscape (xmlOutputBufferPtr out,262const xmlChar *str,263xmlCharEncodingOutputFunc escaping);264265XMLPUBFUN int XMLCALL266xmlOutputBufferFlush (xmlOutputBufferPtr out);267XMLPUBFUN int XMLCALL268xmlOutputBufferClose (xmlOutputBufferPtr out);269270XMLPUBFUN int XMLCALL271xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,272xmlOutputOpenCallback openFunc,273xmlOutputWriteCallback writeFunc,274xmlOutputCloseCallback closeFunc);275276xmlOutputBufferPtr277__xmlOutputBufferCreateFilename(const char *URI,278xmlCharEncodingHandlerPtr encoder,279int compression);280281#ifdef LIBXML_HTTP_ENABLED282/* This function only exists if HTTP support built into the library */283XMLPUBFUN void XMLCALL284xmlRegisterHTTPPostCallbacks (void );285#endif /* LIBXML_HTTP_ENABLED */286287#endif /* LIBXML_OUTPUT_ENABLED */288289XMLPUBFUN xmlParserInputPtr XMLCALL290xmlCheckHTTPInput (xmlParserCtxtPtr ctxt,291xmlParserInputPtr ret);292293/*294* A predefined entity loader disabling network accesses295*/296XMLPUBFUN xmlParserInputPtr XMLCALL297xmlNoNetExternalEntityLoader (const char *URL,298const char *ID,299xmlParserCtxtPtr ctxt);300301/*302* xmlNormalizeWindowsPath is obsolete, don't use it.303* Check xmlCanonicPath in uri.h for a better alternative.304*/305XMLPUBFUN xmlChar * XMLCALL306xmlNormalizeWindowsPath (const xmlChar *path);307308XMLPUBFUN int XMLCALL309xmlCheckFilename (const char *path);310/**311* Default 'file://' protocol callbacks312*/313XMLPUBFUN int XMLCALL314xmlFileMatch (const char *filename);315XMLPUBFUN void * XMLCALL316xmlFileOpen (const char *filename);317XMLPUBFUN int XMLCALL318xmlFileRead (void * context,319char * buffer,320int len);321XMLPUBFUN int XMLCALL322xmlFileClose (void * context);323324/**325* Default 'http://' protocol callbacks326*/327#ifdef LIBXML_HTTP_ENABLED328XMLPUBFUN int XMLCALL329xmlIOHTTPMatch (const char *filename);330XMLPUBFUN void * XMLCALL331xmlIOHTTPOpen (const char *filename);332#ifdef LIBXML_OUTPUT_ENABLED333XMLPUBFUN void * XMLCALL334xmlIOHTTPOpenW (const char * post_uri,335int compression );336#endif /* LIBXML_OUTPUT_ENABLED */337XMLPUBFUN int XMLCALL338xmlIOHTTPRead (void * context,339char * buffer,340int len);341XMLPUBFUN int XMLCALL342xmlIOHTTPClose (void * context);343#endif /* LIBXML_HTTP_ENABLED */344345/**346* Default 'ftp://' protocol callbacks347*/348#ifdef LIBXML_FTP_ENABLED349XMLPUBFUN int XMLCALL350xmlIOFTPMatch (const char *filename);351XMLPUBFUN void * XMLCALL352xmlIOFTPOpen (const char *filename);353XMLPUBFUN int XMLCALL354xmlIOFTPRead (void * context,355char * buffer,356int len);357XMLPUBFUN int XMLCALL358xmlIOFTPClose (void * context);359#endif /* LIBXML_FTP_ENABLED */360361#ifdef __cplusplus362}363#endif364365#endif /* __XML_IO_H__ */366367368