2001-10-12 21:29:10 +04:00
/*
* globals . c : definition and handling of the set of global variables
* of the library
*
* The bottom of this file is automatically generated by build_glob . py
* based on the description file global . data
*
* See Copyright for the status of this software .
*
* Gary Pennington < Gary . Pennington @ uk . sun . com >
* daniel @ veillard . com
*/
# include "libxml.h"
2001-10-13 16:18:28 +04:00
# ifdef HAVE_STDLIB_H
2001-10-13 16:06:09 +04:00
# include <stdlib.h>
2001-10-13 16:18:28 +04:00
# endif
2001-10-13 16:06:09 +04:00
# include <string.h>
2001-10-17 19:58:35 +04:00
# include <libxml/globals.h>
2001-10-13 16:18:28 +04:00
# include <libxml/xmlmemory.h>
2001-10-17 19:58:35 +04:00
/* #define DEBUG_GLOBALS */
2001-10-12 21:29:10 +04:00
/*
* Helpful Macro
*/
2001-10-17 19:58:35 +04:00
# ifdef LIBXML_THREAD_ENABLED
# define IS_MAIN_THREAD (xmlIsMainThread())
2001-10-12 21:29:10 +04:00
# else
# define IS_MAIN_THREAD 1
# endif
/************************************************************************
* *
* All the user accessible global variables of the library *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Memory allocation routines
*/
# if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
2001-10-13 13:15:48 +04:00
extern void xmlMemFree ( void * ptr ) ;
extern void * xmlMemMalloc ( size_t size ) ;
extern void * xmlMemRealloc ( void * ptr , size_t size ) ;
extern char * xmlMemoryStrdup ( const char * str ) ;
2001-10-12 21:29:10 +04:00
xmlFreeFunc xmlFree = ( xmlFreeFunc ) xmlMemFree ;
xmlMallocFunc xmlMalloc = ( xmlMallocFunc ) xmlMemMalloc ;
xmlReallocFunc xmlRealloc = ( xmlReallocFunc ) xmlMemRealloc ;
xmlStrdupFunc xmlMemStrdup = ( xmlStrdupFunc ) xmlMemoryStrdup ;
# else
xmlFreeFunc xmlFree = ( xmlFreeFunc ) free ;
xmlMallocFunc xmlMalloc = ( xmlMallocFunc ) malloc ;
xmlReallocFunc xmlRealloc = ( xmlReallocFunc ) realloc ;
xmlStrdupFunc xmlMemStrdup = ( xmlStrdupFunc ) strdup ;
# endif
2001-10-13 13:15:48 +04:00
# include <libxml/threads.h>
# include <libxml/globals.h>
# include <libxml/SAX.h>
# undef docbDefaultSAXHandler
# undef htmlDefaultSAXHandler
# undef oldXMLWDcompatibility
# undef xmlBufferAllocScheme
# undef xmlDefaultBufferSize
# undef xmlDefaultSAXHandler
# undef xmlDefaultSAXLocator
# undef xmlDoValidityCheckingDefaultValue
# undef xmlGenericError
# undef xmlGenericErrorContext
# undef xmlGetWarningsDefaultValue
# undef xmlIndentTreeOutput
# undef xmlKeepBlanksDefaultValue
# undef xmlLineNumbersDefaultValue
# undef xmlLoadExtDtdDefaultValue
# undef xmlParserDebugEntities
# undef xmlParserVersion
# undef xmlPedanticParserDefaultValue
# undef xmlSaveNoEmptyTags
# undef xmlSubstituteEntitiesDefaultValue
# undef xmlFree
# undef xmlMalloc
# undef xmlMemStrdup
# undef xmlRealloc
2001-10-17 19:58:35 +04:00
const char * xmlParserVersion = LIBXML_VERSION_STRING ;
2001-10-12 21:29:10 +04:00
/*
* Buffers stuff
*/
xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT ;
int xmlDefaultBufferSize = BASE_BUFFER_SIZE ;
/*
* Parser defaults
*/
2001-10-13 13:15:48 +04:00
2001-10-12 21:29:10 +04:00
int oldXMLWDcompatibility = 0 ; /* DEPRECATED */
int xmlParserDebugEntities = 0 ;
int xmlDoValidityCheckingDefaultValue = 0 ;
int xmlGetWarningsDefaultValue = 1 ;
int xmlLoadExtDtdDefaultValue = 0 ;
int xmlPedanticParserDefaultValue = 0 ;
int xmlLineNumbersDefaultValue = 0 ;
int xmlKeepBlanksDefaultValue = 1 ;
int xmlSubstituteEntitiesDefaultValue = 0 ;
/*
* Error handling
*/
/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
/* Must initialize xmlGenericError in xmlInitParser */
2001-10-29 14:48:19 +03:00
void xmlGenericErrorDefaultFunc ( void * ctx ATTRIBUTE_UNUSED ,
const char * msg ,
. . . ) ;
xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc ;
2001-10-12 21:29:10 +04:00
void * xmlGenericErrorContext = NULL ;
/*
* output defaults
*/
int xmlIndentTreeOutput = 0 ;
int xmlSaveNoEmptyTags = 0 ;
/*
* Default handler for XML , builds the DOM tree
*/
xmlSAXHandler xmlDefaultSAXHandler = {
internalSubset ,
isStandalone ,
hasInternalSubset ,
hasExternalSubset ,
resolveEntity ,
getEntity ,
entityDecl ,
notationDecl ,
attributeDecl ,
elementDecl ,
unparsedEntityDecl ,
setDocumentLocator ,
startDocument ,
endDocument ,
startElement ,
endElement ,
reference ,
characters ,
characters ,
processingInstruction ,
comment ,
xmlParserWarning ,
xmlParserError ,
xmlParserError ,
getParameterEntity ,
cdataBlock ,
externalSubset ,
0
} ;
/*
* The default SAX Locator .
*/
xmlSAXLocator xmlDefaultSAXLocator = {
getPublicId , getSystemId , getLineNumber , getColumnNumber
} ;
# ifdef LIBXML_HTML_ENABLED
/*
* Default handler for HTML , builds the DOM tree
*/
xmlSAXHandler htmlDefaultSAXHandler = {
internalSubset ,
NULL ,
NULL ,
NULL ,
NULL ,
getEntity ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
setDocumentLocator ,
startDocument ,
endDocument ,
startElement ,
endElement ,
NULL ,
characters ,
ignorableWhitespace ,
NULL ,
comment ,
xmlParserWarning ,
xmlParserError ,
xmlParserError ,
getParameterEntity ,
cdataBlock ,
NULL ,
0
} ;
# endif /* LIBXML_HTML_ENABLED */
# ifdef LIBXML_DOCB_ENABLED
/*
* Default handler for SGML DocBook , builds the DOM tree
*/
xmlSAXHandler docbDefaultSAXHandler = {
internalSubset ,
isStandalone ,
hasInternalSubset ,
hasExternalSubset ,
resolveEntity ,
getEntity ,
entityDecl ,
NULL ,
NULL ,
NULL ,
NULL ,
setDocumentLocator ,
startDocument ,
endDocument ,
startElement ,
endElement ,
reference ,
characters ,
ignorableWhitespace ,
NULL ,
comment ,
xmlParserWarning ,
xmlParserError ,
xmlParserError ,
getParameterEntity ,
NULL ,
NULL ,
0
} ;
# endif /* LIBXML_DOCB_ENABLED */
/**
* xmlInitializeGlobalState :
* @ gs : a pointer to a newly allocated global state
*
* xmlInitializeGlobalState ( ) initialize a global state with all the
* default values of the library .
*/
void
xmlInitializeGlobalState ( xmlGlobalStatePtr gs )
{
2001-10-17 19:58:35 +04:00
# ifdef DEBUG_GLOBALS
fprintf ( stderr , " Initializing globals at %lu for thread %d \n " ,
( unsigned long ) gs , xmlGetThreadId ( ) ) ;
# endif
2001-10-12 21:29:10 +04:00
/*
* Perform initialisation as required by libxml
*/
2001-10-17 19:58:35 +04:00
initxmlDefaultSAXHandler ( & gs - > xmlDefaultSAXHandler , 1 ) ;
2001-11-04 23:19:12 +03:00
# ifdef LIBXML_DOCB_ENABLED
2001-10-12 21:29:10 +04:00
initdocbDefaultSAXHandler ( & gs - > docbDefaultSAXHandler ) ;
2001-11-04 23:19:12 +03:00
# endif
# ifdef LIBXML_HTML_ENABLED
2001-10-12 21:29:10 +04:00
inithtmlDefaultSAXHandler ( & gs - > htmlDefaultSAXHandler ) ;
2001-11-04 23:19:12 +03:00
# endif
2001-10-17 19:58:35 +04:00
initGenericErrorDefaultFunc ( & gs - > xmlGenericError ) ;
2001-10-12 21:29:10 +04:00
gs - > oldXMLWDcompatibility = 0 ;
gs - > xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT ;
gs - > xmlDefaultBufferSize = BASE_BUFFER_SIZE ;
initxmlDefaultSAXHandler ( & gs - > xmlDefaultSAXHandler , 1 ) ;
gs - > xmlDefaultSAXLocator . getPublicId = getPublicId ;
gs - > xmlDefaultSAXLocator . getSystemId = getSystemId ;
gs - > xmlDefaultSAXLocator . getLineNumber = getLineNumber ;
gs - > xmlDefaultSAXLocator . getColumnNumber = getColumnNumber ;
gs - > xmlDoValidityCheckingDefaultValue = 0 ;
# if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
gs - > xmlFree = ( xmlFreeFunc ) xmlMemFree ;
gs - > xmlMalloc = ( xmlMallocFunc ) xmlMemMalloc ;
gs - > xmlRealloc = ( xmlReallocFunc ) xmlMemRealloc ;
gs - > xmlMemStrdup = ( xmlStrdupFunc ) xmlMemoryStrdup ;
# else
gs - > xmlFree = ( xmlFreeFunc ) free ;
gs - > xmlMalloc = ( xmlMallocFunc ) malloc ;
gs - > xmlRealloc = ( xmlReallocFunc ) realloc ;
gs - > xmlMemStrdup = ( xmlStrdupFunc ) strdup ;
# endif
gs - > xmlGenericErrorContext = NULL ;
gs - > xmlGetWarningsDefaultValue = 1 ;
gs - > xmlIndentTreeOutput = 0 ;
gs - > xmlKeepBlanksDefaultValue = 1 ;
gs - > xmlLineNumbersDefaultValue = 0 ;
gs - > xmlLoadExtDtdDefaultValue = 0 ;
gs - > xmlParserDebugEntities = 0 ;
gs - > xmlParserVersion = LIBXML_VERSION_STRING ;
gs - > xmlPedanticParserDefaultValue = 0 ;
gs - > xmlSaveNoEmptyTags = 0 ;
gs - > xmlSubstituteEntitiesDefaultValue = 0 ;
}
2001-11-04 23:19:12 +03:00
# ifdef LIBXML_DOCB_ENABLED
2001-10-12 21:29:10 +04:00
extern xmlSAXHandler docbDefaultSAXHandler ;
# undef docbDefaultSAXHandler
xmlSAXHandler *
__docbDefaultSAXHandler ( void ) {
if ( IS_MAIN_THREAD )
return ( & docbDefaultSAXHandler ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > docbDefaultSAXHandler ) ;
2001-10-12 21:29:10 +04:00
}
2001-11-04 23:19:12 +03:00
# endif
2001-10-12 21:29:10 +04:00
2001-11-04 23:19:12 +03:00
# ifdef LIBXML_HTML_ENABLED
2001-10-12 21:29:10 +04:00
extern xmlSAXHandler htmlDefaultSAXHandler ;
# undef htmlDefaultSAXHandler
xmlSAXHandler *
__htmlDefaultSAXHandler ( void ) {
if ( IS_MAIN_THREAD )
return ( & htmlDefaultSAXHandler ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > htmlDefaultSAXHandler ) ;
2001-10-12 21:29:10 +04:00
}
2001-11-04 23:19:12 +03:00
# endif
/*
* Everything starting from the line below is
* Automatically generated by build_glob . py .
* Do not modify the previous line .
*/
2001-10-12 21:29:10 +04:00
extern int oldXMLWDcompatibility ;
# undef oldXMLWDcompatibility
int *
__oldXMLWDcompatibility ( void ) {
if ( IS_MAIN_THREAD )
return ( & oldXMLWDcompatibility ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > oldXMLWDcompatibility ) ;
2001-10-12 21:29:10 +04:00
}
extern xmlBufferAllocationScheme xmlBufferAllocScheme ;
# undef xmlBufferAllocScheme
xmlBufferAllocationScheme *
__xmlBufferAllocScheme ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlBufferAllocScheme ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlBufferAllocScheme ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlDefaultBufferSize ;
# undef xmlDefaultBufferSize
int *
__xmlDefaultBufferSize ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlDefaultBufferSize ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlDefaultBufferSize ) ;
2001-10-12 21:29:10 +04:00
}
extern xmlSAXHandler xmlDefaultSAXHandler ;
# undef xmlDefaultSAXHandler
xmlSAXHandler *
__xmlDefaultSAXHandler ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlDefaultSAXHandler ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlDefaultSAXHandler ) ;
2001-10-12 21:29:10 +04:00
}
extern xmlSAXLocator xmlDefaultSAXLocator ;
# undef xmlDefaultSAXLocator
xmlSAXLocator *
__xmlDefaultSAXLocator ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlDefaultSAXLocator ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlDefaultSAXLocator ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlDoValidityCheckingDefaultValue ;
# undef xmlDoValidityCheckingDefaultValue
int *
__xmlDoValidityCheckingDefaultValue ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlDoValidityCheckingDefaultValue ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlDoValidityCheckingDefaultValue ) ;
2001-10-12 21:29:10 +04:00
}
extern xmlFreeFunc xmlFree ;
# undef xmlFree
xmlFreeFunc *
__xmlFree ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlFree ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlFree ) ;
2001-10-12 21:29:10 +04:00
}
extern xmlGenericErrorFunc xmlGenericError ;
# undef xmlGenericError
xmlGenericErrorFunc *
__xmlGenericError ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlGenericError ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlGenericError ) ;
2001-10-12 21:29:10 +04:00
}
extern void * xmlGenericErrorContext ;
# undef xmlGenericErrorContext
void * *
__xmlGenericErrorContext ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlGenericErrorContext ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlGenericErrorContext ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlGetWarningsDefaultValue ;
# undef xmlGetWarningsDefaultValue
int *
__xmlGetWarningsDefaultValue ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlGetWarningsDefaultValue ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlGetWarningsDefaultValue ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlIndentTreeOutput ;
# undef xmlIndentTreeOutput
int *
__xmlIndentTreeOutput ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlIndentTreeOutput ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlIndentTreeOutput ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlKeepBlanksDefaultValue ;
# undef xmlKeepBlanksDefaultValue
int *
__xmlKeepBlanksDefaultValue ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlKeepBlanksDefaultValue ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlKeepBlanksDefaultValue ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlLineNumbersDefaultValue ;
# undef xmlLineNumbersDefaultValue
int *
__xmlLineNumbersDefaultValue ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlLineNumbersDefaultValue ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlLineNumbersDefaultValue ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlLoadExtDtdDefaultValue ;
# undef xmlLoadExtDtdDefaultValue
int *
__xmlLoadExtDtdDefaultValue ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlLoadExtDtdDefaultValue ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlLoadExtDtdDefaultValue ) ;
2001-10-12 21:29:10 +04:00
}
extern xmlMallocFunc xmlMalloc ;
# undef xmlMalloc
xmlMallocFunc *
__xmlMalloc ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlMalloc ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlMalloc ) ;
2001-10-12 21:29:10 +04:00
}
extern xmlStrdupFunc xmlMemStrdup ;
# undef xmlMemStrdup
xmlStrdupFunc *
__xmlMemStrdup ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlMemStrdup ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlMemStrdup ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlParserDebugEntities ;
# undef xmlParserDebugEntities
int *
__xmlParserDebugEntities ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlParserDebugEntities ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlParserDebugEntities ) ;
2001-10-12 21:29:10 +04:00
}
extern const char * xmlParserVersion ;
# undef xmlParserVersion
const char * *
__xmlParserVersion ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlParserVersion ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlParserVersion ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlPedanticParserDefaultValue ;
# undef xmlPedanticParserDefaultValue
int *
__xmlPedanticParserDefaultValue ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlPedanticParserDefaultValue ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlPedanticParserDefaultValue ) ;
2001-10-12 21:29:10 +04:00
}
extern xmlReallocFunc xmlRealloc ;
# undef xmlRealloc
xmlReallocFunc *
__xmlRealloc ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlRealloc ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlRealloc ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlSaveNoEmptyTags ;
# undef xmlSaveNoEmptyTags
int *
__xmlSaveNoEmptyTags ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlSaveNoEmptyTags ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlSaveNoEmptyTags ) ;
2001-10-12 21:29:10 +04:00
}
extern int xmlSubstituteEntitiesDefaultValue ;
# undef xmlSubstituteEntitiesDefaultValue
int *
__xmlSubstituteEntitiesDefaultValue ( void ) {
if ( IS_MAIN_THREAD )
return ( & xmlSubstituteEntitiesDefaultValue ) ;
else
2001-10-13 13:15:48 +04:00
return ( & xmlGetGlobalState ( ) - > xmlSubstituteEntitiesDefaultValue ) ;
2001-10-12 21:29:10 +04:00
}