1998-08-13 07:39:55 +04:00
/*
* parser . h : constants and stuff related to the XML parser .
*
* See Copyright for the status of this software .
*
1999-01-17 22:11:59 +03:00
* Daniel . Veillard @ w3 . org
1998-08-13 07:39:55 +04:00
*/
# ifndef __XML_PARSER_H__
# define __XML_PARSER_H__
# include "tree.h"
1999-06-23 01:49:07 +04:00
# include "xmlIO.h"
1998-08-13 07:39:55 +04:00
# ifdef __cplusplus
extern " C " {
# endif
/*
* Constants .
*/
# define XML_DEFAULT_VERSION "1.0"
1999-03-01 00:54:31 +03:00
typedef void ( * xmlParserInputDeallocate ) ( CHAR * ) ;
1998-08-13 07:39:55 +04:00
typedef struct xmlParserInput {
1999-06-23 01:49:07 +04:00
/* Input buffer */
xmlParserInputBufferPtr buf ; /* UTF-8 encoded buffer */
1998-08-13 07:39:55 +04:00
const char * filename ; /* The file analyzed, if any */
const CHAR * base ; /* Base of the array to parse */
const CHAR * cur ; /* Current char being parsed */
int line ; /* Current line */
int col ; /* Current column */
1999-03-01 00:54:31 +03:00
xmlParserInputDeallocate free ; /* function to deallocate the base */
1999-02-22 13:33:01 +03:00
} xmlParserInput ;
typedef xmlParserInput * xmlParserInputPtr ;
1998-08-13 07:39:55 +04:00
1999-02-22 13:33:01 +03:00
typedef struct _xmlParserNodeInfo {
1998-08-13 07:39:55 +04:00
const struct xmlNode * node ;
/* Position & line # that text that created the node begins & ends on */
unsigned long begin_pos ;
unsigned long begin_line ;
unsigned long end_pos ;
unsigned long end_line ;
1999-02-22 13:33:01 +03:00
} _xmlParserNodeInfo ;
typedef _xmlParserNodeInfo xmlParserNodeInfo ;
1998-08-13 07:39:55 +04:00
typedef struct xmlParserNodeInfoSeq {
unsigned long maximum ;
unsigned long length ;
xmlParserNodeInfo * buffer ;
1999-02-22 13:33:01 +03:00
} _xmlParserNodeInfoSeq ;
typedef _xmlParserNodeInfoSeq xmlParserNodeInfoSeq ;
typedef xmlParserNodeInfoSeq * xmlParserNodeInfoSeqPtr ;
1998-08-13 07:39:55 +04:00
1999-02-22 13:33:01 +03:00
typedef struct _xmlParserCtxt {
1998-08-13 07:39:55 +04:00
struct xmlSAXHandler * sax ; /* The SAX handler */
1999-04-05 16:20:10 +04:00
void * userData ; /* the document being built */
xmlDocPtr myDoc ; /* the document being built */
1999-01-17 22:11:59 +03:00
int wellFormed ; /* is the document well formed */
1999-06-02 21:44:04 +04:00
int replaceEntities ; /* shall we replace entities ? */
1999-04-05 16:20:10 +04:00
const CHAR * version ; /* the XML version string */
const CHAR * encoding ; /* encoding, if any */
int standalone ; /* standalone document */
1998-08-13 07:39:55 +04:00
/* Input stream stack */
xmlParserInputPtr input ; /* Current input stream */
int inputNr ; /* Number of current input streams */
int inputMax ; /* Max number of input streams */
xmlParserInputPtr * inputTab ; /* stack of inputs */
/* Node analysis stack */
xmlNodePtr node ; /* Current parsed Node */
int nodeNr ; /* Depth of the parsing stack */
int nodeMax ; /* Max depth of the parsing stack */
xmlNodePtr * nodeTab ; /* array of nodes */
int record_info ; /* Whether node info should be kept */
xmlParserNodeInfoSeq node_seq ; /* info about each node parsed */
1999-02-22 13:33:01 +03:00
} _xmlParserCtxt ;
typedef _xmlParserCtxt xmlParserCtxt ;
typedef xmlParserCtxt * xmlParserCtxtPtr ;
1998-08-13 07:39:55 +04:00
/*
* a SAX Locator .
*/
typedef struct xmlSAXLocator {
1999-05-29 15:51:49 +04:00
const CHAR * ( * getPublicId ) ( void * ctx ) ;
const CHAR * ( * getSystemId ) ( void * ctx ) ;
int ( * getLineNumber ) ( void * ctx ) ;
int ( * getColumnNumber ) ( void * ctx ) ;
1999-02-22 13:33:01 +03:00
} _xmlSAXLocator ;
typedef _xmlSAXLocator xmlSAXLocator ;
typedef xmlSAXLocator * xmlSAXLocatorPtr ;
1998-08-13 07:39:55 +04:00
/*
* a SAX Exception .
*/
1999-04-05 16:20:10 +04:00
# include "entities.h"
1999-05-29 15:51:49 +04:00
typedef xmlParserInputPtr ( * resolveEntitySAXFunc ) ( void * ctx ,
1998-08-13 07:39:55 +04:00
const CHAR * publicId , const CHAR * systemId ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * internalSubsetSAXFunc ) ( void * ctx , const CHAR * name ,
1999-04-05 16:20:10 +04:00
const CHAR * ExternalID , const CHAR * SystemID ) ;
1999-05-29 15:51:49 +04:00
typedef xmlEntityPtr ( * getEntitySAXFunc ) ( void * ctx ,
1999-04-05 16:20:10 +04:00
const CHAR * name ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * entityDeclSAXFunc ) ( void * ctx ,
1999-04-05 16:20:10 +04:00
const CHAR * name , int type , const CHAR * publicId ,
const CHAR * systemId , CHAR * content ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * notationDeclSAXFunc ) ( void * ctx , const CHAR * name ,
1998-08-13 07:39:55 +04:00
const CHAR * publicId , const CHAR * systemId ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * attributeDeclSAXFunc ) ( void * ctx , const CHAR * elem ,
1999-04-05 16:20:10 +04:00
const CHAR * name , int type , int def ,
const CHAR * defaultValue , xmlEnumerationPtr tree ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * elementDeclSAXFunc ) ( void * ctx , const CHAR * name ,
1999-04-05 16:20:10 +04:00
int type , xmlElementContentPtr content ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * unparsedEntityDeclSAXFunc ) ( void * ctx ,
1998-08-13 07:39:55 +04:00
const CHAR * name , const CHAR * publicId ,
const CHAR * systemId , const CHAR * notationName ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * setDocumentLocatorSAXFunc ) ( void * ctx ,
1998-08-13 07:39:55 +04:00
xmlSAXLocatorPtr loc ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * startDocumentSAXFunc ) ( void * ctx ) ;
typedef void ( * endDocumentSAXFunc ) ( void * ctx ) ;
typedef void ( * startElementSAXFunc ) ( void * ctx , const CHAR * name ,
1999-04-05 16:20:10 +04:00
const CHAR * * atts ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * endElementSAXFunc ) ( void * ctx , const CHAR * name ) ;
typedef void ( * attributeSAXFunc ) ( void * ctx , const CHAR * name ,
1998-10-24 22:27:49 +04:00
const CHAR * value ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * referenceSAXFunc ) ( void * ctx , const CHAR * name ) ;
typedef void ( * charactersSAXFunc ) ( void * ctx , const CHAR * ch ,
1999-04-05 16:20:10 +04:00
int len ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * ignorableWhitespaceSAXFunc ) ( void * ctx ,
1999-04-05 16:20:10 +04:00
const CHAR * ch , int len ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * processingInstructionSAXFunc ) ( void * ctx ,
1998-08-13 07:39:55 +04:00
const CHAR * target , const CHAR * data ) ;
1999-05-29 15:51:49 +04:00
typedef void ( * commentSAXFunc ) ( void * ctx , const CHAR * value ) ;
typedef void ( * warningSAXFunc ) ( void * ctx , const char * msg , . . . ) ;
typedef void ( * errorSAXFunc ) ( void * ctx , const char * msg , . . . ) ;
typedef void ( * fatalErrorSAXFunc ) ( void * ctx , const char * msg , . . . ) ;
typedef int ( * isStandaloneSAXFunc ) ( void * ctx ) ;
typedef int ( * hasInternalSubsetSAXFunc ) ( void * ctx ) ;
typedef int ( * hasExternalSubsetSAXFunc ) ( void * ctx ) ;
1998-08-13 07:39:55 +04:00
typedef struct xmlSAXHandler {
1999-04-05 16:20:10 +04:00
internalSubsetSAXFunc internalSubset ;
isStandaloneSAXFunc isStandalone ;
hasInternalSubsetSAXFunc hasInternalSubset ;
hasExternalSubsetSAXFunc hasExternalSubset ;
1998-08-13 07:39:55 +04:00
resolveEntitySAXFunc resolveEntity ;
1999-04-05 16:20:10 +04:00
getEntitySAXFunc getEntity ;
entityDeclSAXFunc entityDecl ;
1998-08-13 07:39:55 +04:00
notationDeclSAXFunc notationDecl ;
1999-04-05 16:20:10 +04:00
attributeDeclSAXFunc attributeDecl ;
elementDeclSAXFunc elementDecl ;
1998-08-13 07:39:55 +04:00
unparsedEntityDeclSAXFunc unparsedEntityDecl ;
setDocumentLocatorSAXFunc setDocumentLocator ;
startDocumentSAXFunc startDocument ;
endDocumentSAXFunc endDocument ;
startElementSAXFunc startElement ;
endElementSAXFunc endElement ;
1999-04-05 16:20:10 +04:00
referenceSAXFunc reference ;
1998-08-13 07:39:55 +04:00
charactersSAXFunc characters ;
ignorableWhitespaceSAXFunc ignorableWhitespace ;
processingInstructionSAXFunc processingInstruction ;
1999-04-05 16:20:10 +04:00
commentSAXFunc comment ;
1998-08-13 07:39:55 +04:00
warningSAXFunc warning ;
errorSAXFunc error ;
fatalErrorSAXFunc fatalError ;
1999-02-22 13:33:01 +03:00
} xmlSAXHandler ;
typedef xmlSAXHandler * xmlSAXHandlerPtr ;
1998-08-13 07:39:55 +04:00
/*
* Global variables : just the SAX interface tables we are looking for full
1999-06-23 01:49:07 +04:00
* reentrancy of the code and version infos .
1998-08-13 07:39:55 +04:00
*/
1999-06-23 01:49:07 +04:00
extern const char * xmlParserVersion ;
1998-09-23 04:49:46 +04:00
extern xmlSAXLocator xmlDefaultSAXLocator ;
extern xmlSAXHandler xmlDefaultSAXHandler ;
1998-08-13 07:39:55 +04:00
1998-10-27 09:21:04 +03:00
# include "entities.h"
1999-03-05 09:26:45 +03:00
# include "xml-error.h"
1998-10-27 09:21:04 +03:00
1998-08-13 07:39:55 +04:00
/*
1999-01-17 22:11:59 +03:00
* CHAR handling
1998-08-13 07:39:55 +04:00
*/
1999-02-22 13:33:01 +03:00
CHAR * xmlStrdup ( const CHAR * cur ) ;
CHAR * xmlStrndup ( const CHAR * cur , int len ) ;
CHAR * xmlStrchr ( const CHAR * str , CHAR val ) ;
int xmlStrcmp ( const CHAR * str1 , const CHAR * str2 ) ;
int xmlStrncmp ( const CHAR * str1 , const CHAR * str2 , int len ) ;
int xmlStrlen ( const CHAR * str ) ;
CHAR * xmlStrcat ( CHAR * cur , const CHAR * add ) ;
CHAR * xmlStrncat ( CHAR * cur , const CHAR * add , int len ) ;
1998-08-13 07:39:55 +04:00
1999-01-17 22:11:59 +03:00
/*
* Interfaces
*/
1999-02-22 13:33:01 +03:00
xmlDocPtr xmlParseDoc ( CHAR * cur ) ;
xmlDocPtr xmlParseMemory ( char * buffer , int size ) ;
xmlDocPtr xmlParseFile ( const char * filename ) ;
1999-06-02 21:44:04 +04:00
int xmlSubstituteEntitiesDefault ( int val ) ;
1999-01-17 22:11:59 +03:00
/*
* Recovery mode
*/
1999-02-22 13:33:01 +03:00
xmlDocPtr xmlRecoverDoc ( CHAR * cur ) ;
xmlDocPtr xmlRecoverMemory ( char * buffer , int size ) ;
xmlDocPtr xmlRecoverFile ( const char * filename ) ;
1999-01-17 22:11:59 +03:00
/*
* Internal routines
*/
1999-02-22 13:33:01 +03:00
int xmlParseDocument ( xmlParserCtxtPtr ctxt ) ;
xmlDocPtr xmlSAXParseDoc ( xmlSAXHandlerPtr sax , CHAR * cur , int recovery ) ;
xmlDocPtr xmlSAXParseMemory ( xmlSAXHandlerPtr sax , char * buffer ,
1999-01-17 22:11:59 +03:00
int size , int recovery ) ;
1999-02-22 13:33:01 +03:00
xmlDocPtr xmlSAXParseFile ( xmlSAXHandlerPtr sax , const char * filename ,
1999-01-17 22:11:59 +03:00
int recovery ) ;
1999-06-02 21:44:04 +04:00
xmlDtdPtr xmlParseDTD ( const CHAR * ExternalID , const CHAR * SystemID ) ;
xmlDtdPtr xmlSAXParseDTD ( xmlSAXHandlerPtr sax , const CHAR * ExternalID ,
const CHAR * SystemID ) ;
1999-02-22 13:33:01 +03:00
void xmlInitParserCtxt ( xmlParserCtxtPtr ctxt ) ;
void xmlClearParserCtxt ( xmlParserCtxtPtr ctxt ) ;
void xmlSetupParserForBuffer ( xmlParserCtxtPtr ctxt , const CHAR * buffer ,
1998-08-13 07:39:55 +04:00
const char * filename ) ;
1999-02-22 13:33:01 +03:00
const xmlParserNodeInfo * xmlParserFindNodeInfo ( const xmlParserCtxt * ctxt ,
const xmlNode * node ) ;
void xmlInitNodeInfoSeq ( xmlParserNodeInfoSeqPtr seq ) ;
void xmlClearNodeInfoSeq ( xmlParserNodeInfoSeqPtr seq ) ;
1998-08-13 07:39:55 +04:00
unsigned long xmlParserFindNodeInfoIndex ( const xmlParserNodeInfoSeq * seq ,
const xmlNode * node ) ;
1999-02-22 13:33:01 +03:00
void xmlParserAddNodeInfo ( xmlParserCtxtPtr ctxt ,
const xmlParserNodeInfo * info ) ;
1998-08-13 07:39:55 +04:00
1999-02-22 13:33:01 +03:00
void xmlDefaultSAXHandlerInit ( void ) ;
1998-08-13 07:39:55 +04:00
# ifdef __cplusplus
}
# endif
# endif /* __XML_PARSER_H__ */