Newer
Older
* Copyright 1999-2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/internal/ValidationContextImpl.hpp>
#include <xercesc/util/Janitor.hpp>
#include <xercesc/util/Mutexes.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/UnexpectedEOFException.hpp>
#include <xercesc/util/XMLMsgLoader.hpp>
#include <xercesc/util/XMLRegisterCleanup.hpp>
#include <xercesc/util/XMLInitializer.hpp>
#include <xercesc/framework/LocalFileInputSource.hpp>
#include <xercesc/framework/URLInputSource.hpp>
#include <xercesc/framework/XMLDocumentHandler.hpp>
#include <xercesc/framework/XMLEntityHandler.hpp>
#include <xercesc/framework/XMLPScanToken.hpp>
#include <xercesc/framework/XMLValidator.hpp>
#include <xercesc/internal/EndOfEntityException.hpp>
#include <xercesc/validators/DTD/DocTypeHandler.hpp>
#include <xercesc/validators/common/GrammarResolver.hpp>
Neil Graham
committed
#include <xercesc/util/OutOfMemoryException.hpp>
#include <xercesc/util/XMLResourceIdentifier.hpp>
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// ---------------------------------------------------------------------------
// Local static data
// ---------------------------------------------------------------------------
static XMLUInt32 gScannerId;
static bool sRegistered = false;
static XMLMutex* sScannerMutex = 0;
static XMLRegisterCleanup scannerMutexCleanup;
static XMLMsgLoader* gMsgLoader = 0;
static XMLRegisterCleanup cleanupMsgLoader;
// ---------------------------------------------------------------------------
// Local, static functions
// ---------------------------------------------------------------------------
// Cleanup for the message loader
void XMLScanner::reinitMsgLoader()
{
delete gMsgLoader;
gMsgLoader = 0;
}
// Cleanup for the scanner mutex
void XMLScanner::reinitScannerMutex()
{
delete sScannerMutex;
sScannerMutex = 0;
sRegistered = false;
}
//
// We need to fault in this mutex. But, since its used for synchronization
// itself, we have to do this the low level way using a compare and swap.
//
static XMLMutex& gScannerMutex()
{
Khaled Noaman
committed
if (!sRegistered)
Khaled Noaman
committed
XMLMutexLock lockInit(XMLPlatformUtils::fgAtomicMutex);
sScannerMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager);
Khaled Noaman
committed
scannerMutexCleanup.registerCleanup(XMLScanner::reinitScannerMutex);
sRegistered = true;
}
}
return *sScannerMutex;
}
static XMLMsgLoader& gScannerMsgLoader()
{
if (!gMsgLoader)
{
Khaled Noaman
committed
XMLMutexLock lockInit(&gScannerMutex());
// If we haven't loaded our message yet, then do that
Khaled Noaman
committed
{
gMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLErrDomain);
if (!gMsgLoader)
XMLPlatformUtils::panic(PanicHandler::Panic_CantLoadMsgDomain);
Khaled Noaman
committed
// Register this object to be cleaned up at termination
cleanupMsgLoader.registerCleanup(XMLScanner::reinitMsgLoader);
}
}
return *gMsgLoader;
}
void XMLInitializer::initializeScannerMsgLoader()
{
gMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLErrDomain);
// Register this object to be cleaned up at termination
if (gMsgLoader) {
cleanupMsgLoader.registerCleanup(XMLScanner::reinitMsgLoader);
}
sScannerMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager);
if (sScannerMutex) {
scannerMutexCleanup.registerCleanup(XMLScanner::reinitScannerMutex);
sRegistered = true;
}
}
typedef JanitorMemFunCall<XMLScanner> CleanupType;
typedef JanitorMemFunCall<ReaderMgr> ReaderMgrResetType;
// ---------------------------------------------------------------------------
// XMLScanner: Constructors and Destructor
// ---------------------------------------------------------------------------
XMLScanner::XMLScanner(XMLValidator* const valToAdopt,
GrammarResolver* const grammarResolver,
David Abram Cargill
committed
MemoryManager* const manager)
: fBufferSize(1024 * 1024)
, fStandardUriConformant(false)
David Abram Cargill
committed
, fCalculateSrcOfs(false)
, fExitOnFirstFatal(true)
, fValidationConstraintFatal(false)
, fInException(false)
, fStandalone(false)
, fHasNoDTD(true)
, fValidate(false)
, fValidatorFromUser(false)
, fDoSchema(false)
, fSchemaFullChecking(false)
, fToCacheGrammar(false)
, fUseCachedGrammar(false)
, fLoadExternalDTD(true)
, fNormalizeData(true)
David Abram Cargill
committed
, fGenerateSyntheticAnnotations(false)
, fValidateAnnotations(false)
, fIgnoreCachedDTD(false)
David Abram Cargill
committed
, fIgnoreAnnotations(false)
, fDisableDefaultEntityResolution(false)
, fSkipDTDValidation(false)
David Abram Cargill
committed
, fEntityExpansionLimit(0)
, fEntityExpansionCount(0)
, fEmptyNamespaceId(0)
, fUnknownNamespaceId(0)
, fXMLNamespaceId(0)
, fXMLNSNamespaceId(0)
, fSchemaNamespaceId(0)
David Abram Cargill
committed
, fUIntPool(0)
, fUIntPoolRow(0)
, fUIntPoolCol(0)
, fUIntPoolRowTotal(2)
, fScannerId(0)
, fSequenceId(0)
, fAttrList(0)
, fAttrDupChkRegistry(0)
, fDocHandler(0)
, fDocTypeHandler(0)
, fEntityHandler(0)
, fErrorReporter(0)
, fErrorHandler(0)
David Abram Cargill
committed
, fPSVIHandler(0)
, fValidationContext(0)
, fEntityDeclPoolRetrieved(false)
, fReaderMgr(manager)
, fGrammarResolver(grammarResolver)
, fGrammarPoolMemoryManager(grammarResolver->getGrammarPoolMemoryManager())
Loading
Loading full blame...