/** * 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) { #ifdef DEBUG_GLOBALS fprintf(stderr, "Initializing globals at %lu for thread %d\n", (unsigned long) gs, xmlGetThreadId()); #endif /* * Perform initialization as required by libxml */ initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1); #ifdef LIBXML_DOCB_ENABLED initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler); #endif #ifdef LIBXML_HTML_ENABLED inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler); #endif initGenericErrorDefaultFunc(&gs->xmlGenericError); 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) xmlStrdup; #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; }
void xmlInitializeGlobalState(xmlGlobalStatePtr gs) { #ifdef DEBUG_GLOBALS fprintf(stderr, "Initializing globals at %lu for thread %d\n", (unsigned long) gs, xmlGetThreadId()); #endif #if 0 /* * Perform initialization as required by libxml */ if (xmlThrDefMutex == NULL) xmlInitGlobals(); xmlMutexLock(xmlThrDefMutex); #ifdef LIBXML_DOCB_ENABLED initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler); #endif #ifdef LIBXML_HTML_ENABLED inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler); #endif #endif gs->oldXMLWDcompatibility = 0; gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef; gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef; #if 0 #ifdef LIBXML_SAX1_ENABLED initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1); #endif /* LIBXML_SAX1_ENABLED */ gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId; gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId; gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber; gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber; #endif gs->xmlDoValidityCheckingDefaultValue = xmlDoValidityCheckingDefaultValueThrDef; /*#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)*/ #if 0 gs->xmlFree = (xmlFreeFunc) xmlMemFree; gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc; gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc; gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc; gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup; #else gs->xmlFree = (xmlFreeFunc) free; gs->xmlMalloc = (xmlMallocFunc) malloc; gs->xmlMallocAtomic = (xmlMallocFunc) malloc; gs->xmlRealloc = (xmlReallocFunc) realloc; gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup; /*gs->xmlMemStrdup = &of_strdup;*/ #endif gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef; gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef; gs->xmlTreeIndentString = xmlTreeIndentStringThrDef; gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef; gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef; gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef; gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef; gs->xmlParserVersion = LIBXML_VERSION_STRING; gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef; gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef; gs->xmlSubstituteEntitiesDefaultValue = xmlSubstituteEntitiesDefaultValueThrDef; gs->xmlGenericError = xmlGenericErrorThrDef; gs->xmlStructuredError = xmlStructuredErrorThrDef; gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef; gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef; gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef; gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef; gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef; memset(&gs->xmlLastError, 0, sizeof(xmlError)); #if 0 xmlMutexUnlock(xmlThrDefMutex); #endif }